1// RUN: mlir-opt %s | mlir-opt | FileCheck %s 2// RUN: mlir-opt %s --mlir-print-op-generic | mlir-opt | FileCheck %s 3 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]] : f32 8 %0 = math.atan %f : f32 9 // 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 return 14} 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]] : f32 21 %0 = math.atan2 %f, %f : f32 22 // 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 return 27} 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]] : f32 33 %0 = math.cbrt %f : f32 34 // 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 return 39} 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]] : f32 45 %0 = math.cos %f : f32 46 // 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 return 51} 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]] : f32 57 %0 = math.sin %f : f32 58 // 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 return 63} 64 65// CHECK-LABEL: func @erf( 66// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 67func.func @erf(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 68 // CHECK: %{{.*}} = math.erf %[[F]] : f32 69 %0 = math.erf %f : f32 70 // CHECK: %{{.*}} = math.erf %[[V]] : vector<4xf32> 71 %1 = math.erf %v : vector<4xf32> 72 // CHECK: %{{.*}} = math.erf %[[T]] : tensor<4x4x?xf32> 73 %2 = math.erf %t : tensor<4x4x?xf32> 74 return 75} 76 77// CHECK-LABEL: func @exp( 78// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 79func.func @exp(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 80 // CHECK: %{{.*}} = math.exp %[[F]] : f32 81 %0 = math.exp %f : f32 82 // CHECK: %{{.*}} = math.exp %[[V]] : vector<4xf32> 83 %1 = math.exp %v : vector<4xf32> 84 // CHECK: %{{.*}} = math.exp %[[T]] : tensor<4x4x?xf32> 85 %2 = math.exp %t : tensor<4x4x?xf32> 86 return 87} 88 89// CHECK-LABEL: func @exp2( 90// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 91func.func @exp2(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 92 // CHECK: %{{.*}} = math.exp2 %[[F]] : f32 93 %0 = math.exp2 %f : f32 94 // CHECK: %{{.*}} = math.exp2 %[[V]] : vector<4xf32> 95 %1 = math.exp2 %v : vector<4xf32> 96 // CHECK: %{{.*}} = math.exp2 %[[T]] : tensor<4x4x?xf32> 97 %2 = math.exp2 %t : tensor<4x4x?xf32> 98 return 99} 100 101// CHECK-LABEL: func @expm1( 102// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 103func.func @expm1(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 104 // CHECK: %{{.*}} = math.expm1 %[[F]] : f32 105 %0 = math.expm1 %f : f32 106 // CHECK: %{{.*}} = math.expm1 %[[V]] : vector<4xf32> 107 %1 = math.expm1 %v : vector<4xf32> 108 // CHECK: %{{.*}} = math.expm1 %[[T]] : tensor<4x4x?xf32> 109 %2 = math.expm1 %t : tensor<4x4x?xf32> 110 return 111} 112 113// CHECK-LABEL: func @log( 114// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 115func.func @log(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 116 // CHECK: %{{.*}} = math.log %[[F]] : f32 117 %0 = math.log %f : f32 118 // CHECK: %{{.*}} = math.log %[[V]] : vector<4xf32> 119 %1 = math.log %v : vector<4xf32> 120 // CHECK: %{{.*}} = math.log %[[T]] : tensor<4x4x?xf32> 121 %2 = math.log %t : tensor<4x4x?xf32> 122 return 123} 124 125// CHECK-LABEL: func @log10( 126// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 127func.func @log10(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 128 // CHECK: %{{.*}} = math.log10 %[[F]] : f32 129 %0 = math.log10 %f : f32 130 // CHECK: %{{.*}} = math.log10 %[[V]] : vector<4xf32> 131 %1 = math.log10 %v : vector<4xf32> 132 // CHECK: %{{.*}} = math.log10 %[[T]] : tensor<4x4x?xf32> 133 %2 = math.log10 %t : tensor<4x4x?xf32> 134 return 135} 136 137// CHECK-LABEL: func @log1p( 138// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 139func.func @log1p(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 140 // CHECK: %{{.*}} = math.log1p %[[F]] : f32 141 %0 = math.log1p %f : f32 142 // CHECK: %{{.*}} = math.log1p %[[V]] : vector<4xf32> 143 %1 = math.log1p %v : vector<4xf32> 144 // CHECK: %{{.*}} = math.log1p %[[T]] : tensor<4x4x?xf32> 145 %2 = math.log1p %t : tensor<4x4x?xf32> 146 return 147} 148 149// CHECK-LABEL: func @log2( 150// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 151func.func @log2(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 152 // CHECK: %{{.*}} = math.log2 %[[F]] : f32 153 %0 = math.log2 %f : f32 154 // CHECK: %{{.*}} = math.log2 %[[V]] : vector<4xf32> 155 %1 = math.log2 %v : vector<4xf32> 156 // CHECK: %{{.*}} = math.log2 %[[T]] : tensor<4x4x?xf32> 157 %2 = math.log2 %t : tensor<4x4x?xf32> 158 return 159} 160 161// CHECK-LABEL: func @powf( 162// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 163func.func @powf(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 164 // CHECK: %{{.*}} = math.powf %[[F]], %[[F]] : f32 165 %0 = math.powf %f, %f : f32 166 // CHECK: %{{.*}} = math.powf %[[V]], %[[V]] : vector<4xf32> 167 %1 = math.powf %v, %v : vector<4xf32> 168 // CHECK: %{{.*}} = math.powf %[[T]], %[[T]] : tensor<4x4x?xf32> 169 %2 = math.powf %t, %t : tensor<4x4x?xf32> 170 return 171} 172 173// CHECK-LABEL: func @fpowi( 174// CHECK-SAME: %[[SB:.*]]: f32, %[[SP:.*]]: i32, 175// CHECK-SAME: %[[VB:.*]]: vector<4xf64>, %[[VP:.*]]: vector<4xi16>, 176// CHECK-SAME: %[[TB:.*]]: tensor<4x3x?xf16>, %[[TP:.*]]: tensor<4x3x?xi64>) { 177func.func @fpowi(%b: f32, %p: i32, %vb: vector<4xf64>, %vp: vector<4xi16>, %tb: tensor<4x3x?xf16>, %tp: tensor<4x3x?xi64>) { 178// CHECK: {{.*}} = math.fpowi %[[SB]], %[[SP]] : f32, i32 179 %0 = math.fpowi %b, %p : f32, i32 180// CHECK: {{.*}} = math.fpowi %[[VB]], %[[VP]] : vector<4xf64>, vector<4xi16> 181 %1 = math.fpowi %vb, %vp : vector<4xf64>, vector<4xi16> 182// CHECK: {{.*}} = math.fpowi %[[TB]], %[[TP]] : tensor<4x3x?xf16>, tensor<4x3x?xi64> 183 %2 = math.fpowi %tb, %tp : tensor<4x3x?xf16>, tensor<4x3x?xi64> 184 return 185} 186 187// CHECK-LABEL: func @rsqrt( 188// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 189func.func @rsqrt(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 190 // CHECK: %{{.*}} = math.rsqrt %[[F]] : f32 191 %0 = math.rsqrt %f : f32 192 // CHECK: %{{.*}} = math.rsqrt %[[V]] : vector<4xf32> 193 %1 = math.rsqrt %v : vector<4xf32> 194 // CHECK: %{{.*}} = math.rsqrt %[[T]] : tensor<4x4x?xf32> 195 %2 = math.rsqrt %t : tensor<4x4x?xf32> 196 return 197} 198 199 200// CHECK-LABEL: func @sqrt( 201// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 202func.func @sqrt(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 203 // CHECK: %{{.*}} = math.sqrt %[[F]] : f32 204 %0 = math.sqrt %f : f32 205 // CHECK: %{{.*}} = math.sqrt %[[V]] : vector<4xf32> 206 %1 = math.sqrt %v : vector<4xf32> 207 // CHECK: %{{.*}} = math.sqrt %[[T]] : tensor<4x4x?xf32> 208 %2 = math.sqrt %t : tensor<4x4x?xf32> 209 return 210} 211 212// CHECK-LABEL: func @tan( 213// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 214func.func @tan(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 215 // CHECK: %{{.*}} = math.tan %[[F]] : f32 216 %0 = math.tan %f : f32 217 // CHECK: %{{.*}} = math.tan %[[V]] : vector<4xf32> 218 %1 = math.tan %v : vector<4xf32> 219 // CHECK: %{{.*}} = math.tan %[[T]] : tensor<4x4x?xf32> 220 %2 = math.tan %t : tensor<4x4x?xf32> 221 return 222} 223 224// CHECK-LABEL: func @tanh( 225// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 226func.func @tanh(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 227 // CHECK: %{{.*}} = math.tanh %[[F]] : f32 228 %0 = math.tanh %f : f32 229 // CHECK: %{{.*}} = math.tanh %[[V]] : vector<4xf32> 230 %1 = math.tanh %v : vector<4xf32> 231 // CHECK: %{{.*}} = math.tanh %[[T]] : tensor<4x4x?xf32> 232 %2 = math.tanh %t : tensor<4x4x?xf32> 233 return 234} 235 236// CHECK-LABEL: func @round( 237// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 238func.func @round(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 239 // CHECK: %{{.*}} = math.round %[[F]] : f32 240 %0 = math.round %f : f32 241 // CHECK: %{{.*}} = math.round %[[V]] : vector<4xf32> 242 %1 = math.round %v : vector<4xf32> 243 // CHECK: %{{.*}} = math.round %[[T]] : tensor<4x4x?xf32> 244 %2 = math.round %t : tensor<4x4x?xf32> 245 return 246} 247 248// CHECK-LABEL: func @roundeven( 249// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 250func.func @roundeven(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 251 // CHECK: %{{.*}} = math.roundeven %[[F]] : f32 252 %0 = math.roundeven %f : f32 253 // CHECK: %{{.*}} = math.roundeven %[[V]] : vector<4xf32> 254 %1 = math.roundeven %v : vector<4xf32> 255 // CHECK: %{{.*}} = math.roundeven %[[T]] : tensor<4x4x?xf32> 256 %2 = math.roundeven %t : tensor<4x4x?xf32> 257 return 258} 259 260 261// CHECK-LABEL: func @ipowi( 262// CHECK-SAME: %[[I:.*]]: i32, %[[V:.*]]: vector<4xi32>, %[[T:.*]]: tensor<4x4x?xi32>) 263func.func @ipowi(%i: i32, %v: vector<4xi32>, %t: tensor<4x4x?xi32>) { 264 // CHECK: %{{.*}} = math.ipowi %[[I]], %[[I]] : i32 265 %0 = math.ipowi %i, %i : i32 266 // CHECK: %{{.*}} = math.ipowi %[[V]], %[[V]] : vector<4xi32> 267 %1 = math.ipowi %v, %v : vector<4xi32> 268 // CHECK: %{{.*}} = math.ipowi %[[T]], %[[T]] : tensor<4x4x?xi32> 269 %2 = math.ipowi %t, %t : tensor<4x4x?xi32> 270 return 271} 272 273// CHECK-LABEL: func @trunc( 274// CHECK-SAME: %[[F:.*]]: f32, %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 275func.func @trunc(%f: f32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 276 // CHECK: %{{.*}} = math.trunc %[[F]] : f32 277 %0 = math.trunc %f : f32 278 // CHECK: %{{.*}} = math.trunc %[[V]] : vector<4xf32> 279 %1 = math.trunc %v : vector<4xf32> 280 // CHECK: %{{.*}} = math.trunc %[[T]] : tensor<4x4x?xf32> 281 %2 = math.trunc %t : tensor<4x4x?xf32> 282 return 283} 284 285// CHECK-LABEL: func @fastmath( 286// CHECK-SAME: %[[F:.*]]: f32, %[[I:.*]]: i32, 287// CHECK-SAME: %[[V:.*]]: vector<4xf32>, %[[T:.*]]: tensor<4x4x?xf32>) 288func.func @fastmath(%f: f32, %i: i32, %v: vector<4xf32>, %t: tensor<4x4x?xf32>) { 289 // CHECK: math.trunc %[[F]] fastmath<fast> : f32 290 %0 = math.trunc %f fastmath<fast> : f32 291 // CHECK: math.powf %[[V]], %[[V]] fastmath<fast> : vector<4xf32> 292 %1 = math.powf %v, %v fastmath<reassoc,nnan,ninf,nsz,arcp,contract,afn> : vector<4xf32> 293 // CHECK: math.fma %[[T]], %[[T]], %[[T]] : tensor<4x4x?xf32> 294 %2 = math.fma %t, %t, %t fastmath<none> : tensor<4x4x?xf32> 295 // CHECK: math.absf %[[F]] fastmath<ninf> : f32 296 %3 = math.absf %f fastmath<ninf> : f32 297 // CHECK: math.fpowi %[[F]], %[[I]] fastmath<fast> : f32, i32 298 %4 = math.fpowi %f, %i fastmath<fast> : f32, i32 299 return 300} 301