brintos

brintos / llvm-project-archived public Read only

0
0
Text · 14.4 KiB · f085d1c Raw
365 lines · plain
1// RUN: mlir-opt %s --verify-roundtrip | FileCheck %s2// RUN: mlir-opt %s --mlir-print-op-generic | mlir-opt | FileCheck %s3 4// CHECK-LABEL: func @atan(5// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)6func.func @atan(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {7  // CHECK: %{{.*}} = math.atan %[[F]] : f328  %0 = math.atan %f : f329  // CHECK: %{{.*}} = math.atan %[[V]] : vector<4xf32>10  %1 = math.atan %v : vector<4xf32>11  // CHECK: %{{.*}} = math.atan %[[T]] : tensor<4x4x?xf32>12  %2 = math.atan %t : tensor<4x4x?xf32>13  return14}15 16 17// CHECK-LABEL: func @atan2(18// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)19func.func @atan2(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {20  // CHECK: %{{.*}} = math.atan2 %[[F]], %[[F]] : f3221  %0 = math.atan2 %f, %f : f3222  // CHECK: %{{.*}} = math.atan2 %[[V]], %[[V]] : vector<4xf32>23  %1 = math.atan2 %v, %v : vector<4xf32>24  // CHECK: %{{.*}} = math.atan2 %[[T]], %[[T]] : tensor<4x4x?xf32>25  %2 = math.atan2 %t, %t : tensor<4x4x?xf32>26  return27}28 29// CHECK-LABEL: func @cbrt(30// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)31func.func @cbrt(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {32  // CHECK: %{{.*}} = math.cbrt %[[F]] : f3233  %0 = math.cbrt %f : f3234  // CHECK: %{{.*}} = math.cbrt %[[V]] : vector<4xf32>35  %1 = math.cbrt %v : vector<4xf32>36  // CHECK: %{{.*}} = math.cbrt %[[T]] : tensor<4x4x?xf32>37  %2 = math.cbrt %t : tensor<4x4x?xf32>38  return39}40 41// CHECK-LABEL: func @cos(42// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)43func.func @cos(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {44  // CHECK: %{{.*}} = math.cos %[[F]] : f3245  %0 = math.cos %f : f3246  // CHECK: %{{.*}} = math.cos %[[V]] : vector<4xf32>47  %1 = math.cos %v : vector<4xf32>48  // CHECK: %{{.*}} = math.cos %[[T]] : tensor<4x4x?xf32>49  %2 = math.cos %t : tensor<4x4x?xf32>50  return51}52 53// CHECK-LABEL: func @sin(54// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)55func.func @sin(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {56  // CHECK: %{{.*}} = math.sin %[[F]] : f3257  %0 = math.sin %f : f3258  // CHECK: %{{.*}} = math.sin %[[V]] : vector<4xf32>59  %1 = math.sin %v : vector<4xf32>60  // CHECK: %{{.*}} = math.sin %[[T]] : tensor<4x4x?xf32>61  %2 = math.sin %t : tensor<4x4x?xf32>62  return63}64 65// CHECK-LABEL: func @sincos(66// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)67func.func @sincos(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {68  // CHECK: %{{.*}} = math.sincos %[[F]] : f3269  %0:2 = math.sincos %f : f3270  // CHECK: %{{.*}} = math.sincos %[[V]] : vector<4xf32>71  %1:2 = math.sincos %v : vector<4xf32>72  // CHECK: %{{.*}} = math.sincos %[[T]] : tensor<4x4x?xf32>73  %2:2 = math.sincos %t : tensor<4x4x?xf32>74  return75}76 77// CHECK-LABEL: func @erf(78// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)79func.func @erf(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {80  // CHECK: %{{.*}} = math.erf %[[F]] : f3281  %0 = math.erf %f : f3282  // CHECK: %{{.*}} = math.erf %[[V]] : vector<4xf32>83  %1 = math.erf %v : vector<4xf32>84  // CHECK: %{{.*}} = math.erf %[[T]] : tensor<4x4x?xf32>85  %2 = math.erf %t : tensor<4x4x?xf32>86  return87}88 89// CHECK-LABEL: func @exp(90// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)91func.func @exp(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {92  // CHECK: %{{.*}} = math.exp %[[F]] : f3293  %0 = math.exp %f : f3294  // CHECK: %{{.*}} = math.exp %[[V]] : vector<4xf32>95  %1 = math.exp %v : vector<4xf32>96  // CHECK: %{{.*}} = math.exp %[[T]] : tensor<4x4x?xf32>97  %2 = math.exp %t : tensor<4x4x?xf32>98  return99}100 101// CHECK-LABEL: func @exp2(102// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)103func.func @exp2(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {104  // CHECK: %{{.*}} = math.exp2 %[[F]] : f32105  %0 = math.exp2 %f : f32106  // CHECK: %{{.*}} = math.exp2 %[[V]] : vector<4xf32>107  %1 = math.exp2 %v : vector<4xf32>108  // CHECK: %{{.*}} = math.exp2 %[[T]] : tensor<4x4x?xf32>109  %2 = math.exp2 %t : tensor<4x4x?xf32>110  return111}112 113// CHECK-LABEL: func @expm1(114// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)115func.func @expm1(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {116  // CHECK: %{{.*}} = math.expm1 %[[F]] : f32117  %0 = math.expm1 %f : f32118  // CHECK: %{{.*}} = math.expm1 %[[V]] : vector<4xf32>119  %1 = math.expm1 %v : vector<4xf32>120  // CHECK: %{{.*}} = math.expm1 %[[T]] : tensor<4x4x?xf32>121  %2 = math.expm1 %t : tensor<4x4x?xf32>122  return123}124 125// CHECK-LABEL: func @log(126// CHECK-SAME:            %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)127func.func @log(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {128  // CHECK: %{{.*}} = math.log %[[F]] : f32129  %0 = math.log %f : f32130  // CHECK: %{{.*}} = math.log %[[V]] : vector<4xf32>131  %1 = math.log %v : vector<4xf32>132  // CHECK: %{{.*}} = math.log %[[T]] : tensor<4x4x?xf32>133  %2 = math.log %t : tensor<4x4x?xf32>134  return135}136 137// CHECK-LABEL: func @log10(138// CHECK-SAME:              %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)139func.func @log10(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {140  // CHECK: %{{.*}} = math.log10 %[[F]] : f32141  %0 = math.log10 %f : f32142  // CHECK: %{{.*}} = math.log10 %[[V]] : vector<4xf32>143  %1 = math.log10 %v : vector<4xf32>144  // CHECK: %{{.*}} = math.log10 %[[T]] : tensor<4x4x?xf32>145  %2 = math.log10 %t : tensor<4x4x?xf32>146  return147}148 149// CHECK-LABEL: func @log1p(150// CHECK-SAME:              %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)151func.func @log1p(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {152  // CHECK: %{{.*}} = math.log1p %[[F]] : f32153  %0 = math.log1p %f : f32154  // CHECK: %{{.*}} = math.log1p %[[V]] : vector<4xf32>155  %1 = math.log1p %v : vector<4xf32>156  // CHECK: %{{.*}} = math.log1p %[[T]] : tensor<4x4x?xf32>157  %2 = math.log1p %t : tensor<4x4x?xf32>158  return159}160 161// CHECK-LABEL: func @log2(162// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)163func.func @log2(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {164  // CHECK: %{{.*}} = math.log2 %[[F]] : f32165  %0 = math.log2 %f : f32166  // CHECK: %{{.*}} = math.log2 %[[V]] : vector<4xf32>167  %1 = math.log2 %v : vector<4xf32>168  // CHECK: %{{.*}} = math.log2 %[[T]] : tensor<4x4x?xf32>169  %2 = math.log2 %t : tensor<4x4x?xf32>170  return171}172 173// CHECK-LABEL: func @powf(174// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)175func.func @powf(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {176  // CHECK: %{{.*}} = math.powf %[[F]], %[[F]] : f32177  %0 = math.powf %f, %f : f32178  // CHECK: %{{.*}} = math.powf %[[V]], %[[V]] : vector<4xf32>179  %1 = math.powf %v, %v : vector<4xf32>180  // CHECK: %{{.*}} = math.powf %[[T]], %[[T]] : tensor<4x4x?xf32>181  %2 = math.powf %t, %t : tensor<4x4x?xf32>182  return183}184 185// CHECK-LABEL: func @fpowi(186// CHECK-SAME: %[[SB:.*]]: f32, %[[SP:.*]]: i32,187// CHECK-SAME: %[[VB:.*]]: vector<4xf64>, %[[VP:.*]]: vector<4xi16>,188// CHECK-SAME: %[[TB:.*]]: tensor<4x3x?xf16>, %[[TP:.*]]: tensor<4x3x?xi64>) {189func.func @fpowi(%b: f32, %p: i32, %vb: vector<4xf64>, %vp: vector<4xi16>, %tb: tensor<4x3x?xf16>, %tp: tensor<4x3x?xi64>) {190// CHECK: {{.*}} = math.fpowi %[[SB]], %[[SP]] : f32, i32191  %0 = math.fpowi %b, %p : f32, i32192// CHECK: {{.*}} = math.fpowi %[[VB]], %[[VP]] : vector<4xf64>, vector<4xi16>193  %1 = math.fpowi %vb, %vp : vector<4xf64>, vector<4xi16>194// CHECK: {{.*}} = math.fpowi %[[TB]], %[[TP]] : tensor<4x3x?xf16>, tensor<4x3x?xi64>195  %2 = math.fpowi %tb, %tp : tensor<4x3x?xf16>, tensor<4x3x?xi64>196  return197}198 199// CHECK-LABEL: func @rsqrt(200// CHECK-SAME:              %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)201func.func @rsqrt(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {202  // CHECK: %{{.*}} = math.rsqrt %[[F]] : f32203  %0 = math.rsqrt %f : f32204  // CHECK: %{{.*}} = math.rsqrt %[[V]] : vector<4xf32>205  %1 = math.rsqrt %v : vector<4xf32>206  // CHECK: %{{.*}} = math.rsqrt %[[T]] : tensor<4x4x?xf32>207  %2 = math.rsqrt %t : tensor<4x4x?xf32>208  return209}210 211 212// CHECK-LABEL: func @sqrt(213// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)214func.func @sqrt(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {215  // CHECK: %{{.*}} = math.sqrt %[[F]] : f32216  %0 = math.sqrt %f : f32217  // CHECK: %{{.*}} = math.sqrt %[[V]] : vector<4xf32>218  %1 = math.sqrt %v : vector<4xf32>219  // CHECK: %{{.*}} = math.sqrt %[[T]] : tensor<4x4x?xf32>220  %2 = math.sqrt %t : tensor<4x4x?xf32>221  return222}223 224// CHECK-LABEL: func @tan(225// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)226func.func @tan(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {227  // CHECK: %{{.*}} = math.tan %[[F]] : f32228  %0 = math.tan %f : f32229  // CHECK: %{{.*}} = math.tan %[[V]] : vector<4xf32>230  %1 = math.tan %v : vector<4xf32>231  // CHECK: %{{.*}} = math.tan %[[T]] : tensor<4x4x?xf32>232  %2 = math.tan %t : tensor<4x4x?xf32>233  return234}235 236// CHECK-LABEL: func @tanh(237// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)238func.func @tanh(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {239  // CHECK: %{{.*}} = math.tanh %[[F]] : f32240  %0 = math.tanh %f : f32241  // CHECK: %{{.*}} = math.tanh %[[V]] : vector<4xf32>242  %1 = math.tanh %v : vector<4xf32>243  // CHECK: %{{.*}} = math.tanh %[[T]] : tensor<4x4x?xf32>244  %2 = math.tanh %t : tensor<4x4x?xf32>245  return246}247 248// CHECK-LABEL: func @round(249// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)250func.func @round(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {251  // CHECK: %{{.*}} = math.round %[[F]] : f32252  %0 = math.round %f : f32253  // CHECK: %{{.*}} = math.round %[[V]] : vector<4xf32>254  %1 = math.round %v : vector<4xf32>255  // CHECK: %{{.*}} = math.round %[[T]] : tensor<4x4x?xf32>256  %2 = math.round %t : tensor<4x4x?xf32>257  return258}259 260// CHECK-LABEL: func @roundeven(261// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)262func.func @roundeven(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {263  // CHECK: %{{.*}} = math.roundeven %[[F]] : f32264  %0 = math.roundeven %f : f32265  // CHECK: %{{.*}} = math.roundeven %[[V]] : vector<4xf32>266  %1 = math.roundeven %v : vector<4xf32>267  // CHECK: %{{.*}} = math.roundeven %[[T]] : tensor<4x4x?xf32>268  %2 = math.roundeven %t : tensor<4x4x?xf32>269  return270}271 272 273// CHECK-LABEL: func @ipowi(274// CHECK-SAME:             %[[I:.*]]: i32, %[[V:.*]]: vector<4xi32>, %[[T:.*]]: tensor<4x4x?xi32>)275func.func @ipowi(%i: i32, %v: vector<4xi32>, %t: tensor<4x4x?xi32>) {276  // CHECK: %{{.*}} = math.ipowi %[[I]], %[[I]] : i32277  %0 = math.ipowi %i, %i : i32278  // CHECK: %{{.*}} = math.ipowi %[[V]], %[[V]] : vector<4xi32>279  %1 = math.ipowi %v, %v : vector<4xi32>280  // CHECK: %{{.*}} = math.ipowi %[[T]], %[[T]] : tensor<4x4x?xi32>281  %2 = math.ipowi %t, %t : tensor<4x4x?xi32>282  return283}284 285// CHECK-LABEL: func @trunc(286// CHECK-SAME:             %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)287func.func @trunc(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {288  // CHECK: %{{.*}} = math.trunc %[[F]] : f32289  %0 = math.trunc %f : f32290  // CHECK: %{{.*}} = math.trunc %[[V]] : vector<4xf32>291  %1 = math.trunc %v : vector<4xf32>292  // CHECK: %{{.*}} = math.trunc %[[T]] : tensor<4x4x?xf32>293  %2 = math.trunc %t : tensor<4x4x?xf32>294  return295}296 297// CHECK-LABEL: func @fastmath(298// CHECK-SAME:      %[[F:.*]]: f32, %[[I:.*]]: i32,299// CHECK-SAME:      %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>)300func.func @fastmath(%f: f32, %i: i32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) {301  // CHECK: math.trunc %[[F]] fastmath<fast> : f32302  %0 = math.trunc %f fastmath<fast> : f32303  // CHECK: math.powf %[[V]], %[[V]] fastmath<fast> : vector<4xf32>304  %1 = math.powf %v, %v fastmath<reassoc,nnan,ninf,nsz,arcp,contract,afn> : vector<4xf32>305  // CHECK: math.fma %[[T]], %[[T]], %[[T]] : tensor<4x4x?xf32>306  %2 = math.fma %t, %t, %t fastmath<none> : tensor<4x4x?xf32>307  // CHECK: math.absf %[[F]] fastmath<ninf> : f32308  %3 = math.absf %f fastmath<ninf> : f32309  // CHECK: math.fpowi %[[F]], %[[I]] fastmath<fast> : f32, i32310  %4 = math.fpowi %f, %i fastmath<fast> : f32, i32311  return312}313 314// CHECK-LABEL: func @fpclassify(315// CHECK-SAME:    %[[F:.+]]: f32, %[[D:.+]]: f64,316// CHECK-SAME:    %[[V:.+]]: vector<4xf32>, %[[T:.+]]: tensor<4x?xf32>317func.func @fpclassify(%f: f32, %d: f64, %v: vector<4xf32>, %t: tensor<4x?xf32>) {318  // CHECK: math.isfinite %[[F]] : f32319  // CHECK: math.isfinite %[[D]] : f64320  // CHECK: math.isfinite %[[V]] : vector<4xf32>321  // CHECK: math.isfinite %[[T]] : tensor<4x?xf32>322  math.isfinite %f : f32323  math.isfinite %d : f64324  math.isfinite %v : vector<4xf32>325  math.isfinite %t : tensor<4x?xf32>326  // CHECK: math.isinf %[[F]] : f32327  // CHECK: math.isinf %[[D]] : f64328  // CHECK: math.isinf %[[V]] : vector<4xf32>329  // CHECK: math.isinf %[[T]] : tensor<4x?xf32>330  math.isinf %f : f32331  math.isinf %d : f64332  math.isinf %v : vector<4xf32>333  math.isinf %t : tensor<4x?xf32>334  // CHECK: math.isnan %[[F]] : f32335  // CHECK: math.isnan %[[D]] : f64336  // CHECK: math.isnan %[[V]] : vector<4xf32>337  // CHECK: math.isnan %[[T]] : tensor<4x?xf32>338  math.isnan %f : f32339  math.isnan %d : f64340  math.isnan %v : vector<4xf32>341  math.isnan %t : tensor<4x?xf32>342  // CHECK: math.isnormal %[[F]] : f32343  // CHECK: math.isnormal %[[D]] : f64344  // CHECK: math.isnormal %[[V]] : vector<4xf32>345  // CHECK: math.isnormal %[[T]] : tensor<4x?xf32>346  math.isnormal %f : f32347  math.isnormal %d : f64348  math.isnormal %v : vector<4xf32>349  math.isnormal %t : tensor<4x?xf32>350  return351}352 353// CHECK-LABEL: func @clampf(354func.func @clampf(%av: vector<3x4xf32>, %mv: vector<3x4xf32>, %Mv: vector<3x4xf32>,355                  %as: f32, %ms: f32, %Ms: f32,356                  %at: tensor<?xf80>, %mt: tensor<?xf80>, %Mt: tensor<?xf80>) {357  // CHECK: math.clampf %{{.*}} to [%{{.*}}, %{{.*}}] fastmath<fast> : vector<3x4xf32>358  %rv = math.clampf %av to [%mv, %Mv] fastmath<fast> : vector<3x4xf32>359  // CHECK: math.clampf %{{.*}} to [%{{.*}}, %{{.*}}] : f32360  %rs = math.clampf %as to [%ms, %Ms] fastmath<none> : f32361  // CHECK: math.clampf %{{.*}} to [%{{.*}}, %{{.*}}] : tensor<?xf80>362  %rt = math.clampf %at to [%mt, %Mt] : tensor<?xf80>363  return 364}365