brintos

brintos / llvm-project-archived public Read only

0
0
Text · 30.4 KiB · a05f423 Raw
717 lines · plain
1//--------------------------------------------------------------------------------------------------2// Test whether the supported profile and extension are attached to the operation properly.3// The data type of arguments of operation are irrelevant in this test.4//--------------------------------------------------------------------------------------------------5 6// RUN: mlir-opt -mlir-disable-threading -test-tosa-op-availability %s | FileCheck %s7 8// -----9// CHECK-LABEL: argmax10func.func @test_argmax(%arg0: tensor<14x19xf32>) -> tensor<14xi32> {11  // CHECK: profiles: [ [pro_int, pro_fp] ]12  // CHECK: extensions: [ [int16, fp8e4m3, fp8e5m2, bf16, int64] ]13  %0 = tosa.argmax %arg0 {axis = 1 : i32} : (tensor<14x19xf32>) -> tensor<14xi32>14  return %0 : tensor<14xi32>15}16 17// -----18// CHECK-LABEL: avg_pool2d19func.func @test_avg_pool2d(%arg0: tensor<1x7x7x9xf32>) -> tensor<1x7x7x9xf32> {20  // CHECK: profiles: [ [pro_int, pro_fp] ]21  // CHECK: extensions: [ [int16, fp8e4m3, fp8e5m2, bf16] ]22  %input_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>23  %output_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>24  %0 = tosa.avg_pool2d %arg0, %input_zp, %output_zp {acc_type = f32, kernel = array<i64: 2, 2>, pad = array<i64: 0, 1, 0, 1>, stride = array<i64: 1, 1>} : (tensor<1x7x7x9xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<1x7x7x9xf32>25  return %0 : tensor<1x7x7x9xf32>26}27 28// -----29// CHECK-LABEL: conv2d30func.func @test_conv2d(%arg0: tensor<1x4x4x4xf32>, %arg1: tensor<8x1x1x4xf32>, %arg2: tensor<8xf32>) -> tensor<1x4x4x8xf32> {31  // CHECK: profiles: [ [pro_int, pro_fp] ]32  // CHECK: extensions: [ [int4, int16, fp8e4m3, fp8e5m2, bf16] ]33  %input_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>34  %weight_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>35  %0 = tosa.conv2d %arg0, %arg1, %arg2, %input_zp, %weight_zp {acc_type = f32, dilation = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>, local_bound = true} : (tensor<1x4x4x4xf32>, tensor<8x1x1x4xf32>, tensor<8xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<1x4x4x8xf32>36  return %0 : tensor<1x4x4x8xf32>37}38 39// -----40// CHECK-LABEL: conv3d41func.func @test_conv3d(%arg0: tensor<1x4x8x21x17xf32>, %arg1: tensor<34x1x1x1x17xf32>, %arg2: tensor<34xf32>) -> tensor<1x4x8x21x34xf32> {42  // CHECK: profiles: [ [pro_int, pro_fp] ]43  // CHECK: extensions: [ [int4, int16, fp8e4m3, fp8e5m2, bf16] ]44  %input_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>45  %weight_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>46  %0 = tosa.conv3d %arg0, %arg1, %arg2, %input_zp, %weight_zp {acc_type = f32, dilation = array<i64: 1, 1, 1>, pad = array<i64: 0, 0, 0, 0, 0, 0>, stride = array<i64: 1, 1, 1>} : (tensor<1x4x8x21x17xf32>, tensor<34x1x1x1x17xf32>, tensor<34xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<1x4x8x21x34xf32>47  return %0 : tensor<1x4x8x21x34xf32>48}49 50// -----51// CHECK-LABEL: depthwise_conv2d52func.func @test_depthwise_conv2d(%arg0: tensor<1x4x4x4xf32>, %arg1: tensor<1x1x4x2xf32>, %arg2: tensor<8xf32>) -> tensor<1x4x4x8xf32> {53  // CHECK: profiles: [ [pro_int, pro_fp] ]54  // CHECK: extensions: [ [int4, int16, fp8e4m3, fp8e5m2, bf16] ]55  %input_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>56  %weight_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>57  %0 = tosa.depthwise_conv2d %arg0, %arg1, %arg2, %input_zp, %weight_zp {acc_type = f32, dilation = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>} : (tensor<1x4x4x4xf32>, tensor<1x1x4x2xf32>, tensor<8xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<1x4x4x8xf32>58  return %0 : tensor<1x4x4x8xf32>59}60 61// -----62// CHECK-LABEL: fft2d63func.func @test_fft2d(%arg0: tensor<1x4x8xf32>, %arg1: tensor<1x4x8xf32>) -> (tensor<1x4x8xf32>, tensor<1x4x8xf32>) {64  // CHECK: profiles: [ ]65  // CHECK: extensions: [ [fft] ]66  %0, %1 = tosa.fft2d %arg0, %arg1 {inverse = false} : (tensor<1x4x8xf32>, tensor<1x4x8xf32>) -> (tensor<1x4x8xf32>, tensor<1x4x8xf32>)67  return %0, %1 : tensor<1x4x8xf32>, tensor<1x4x8xf32>68}69 70// -----71// CHECK-LABEL: matmul72func.func @test_matmul(%arg0: tensor<1x14x19xf32>, %arg1: tensor<1x19x28xf32>, %a_zp: tensor<1xf32>, %b_zp: tensor<1xf32>) -> tensor<1x14x28xf32> {73  // CHECK: profiles: [ [pro_int, pro_fp] ]74  // CHECK: extensions: [ [int16, fp8e4m3, fp8e5m2, bf16] ]75  %0 = tosa.matmul %arg0, %arg1, %a_zp, %b_zp : (tensor<1x14x19xf32>, tensor<1x19x28xf32>, tensor<1xf32>, tensor<1xf32>)  -> tensor<1x14x28xf32>76  return %0 : tensor<1x14x28xf32>77}78 79// -----80// CHECK-LABEL: max_pool2d_f3281func.func @test_max_pool2d_f32(%arg0: tensor<1x32x32x8xf32>) -> tensor<1x32x32x8xf32> {82  // CHECK: profiles: [ [pro_int, pro_fp] ]83  // CHECK: extensions: [ [int16, fp8e4m3, fp8e5m2, bf16] ]84  %0 = tosa.max_pool2d %arg0 {kernel = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>} : (tensor<1x32x32x8xf32>) -> tensor<1x32x32x8xf32>85  return %0 : tensor<1x32x32x8xf32>86}87 88// -----89// CHECK-LABEL: rfft2d90func.func @test_rfft2d(%arg0: tensor<13x8x16xf32>) -> (tensor<13x8x9xf32>, tensor<13x8x9xf32>) {91  // CHECK: profiles: [ ]92  // CHECK: extensions: [ [fft] ]93  %0, %1 = tosa.rfft2d %arg0 : (tensor<13x8x16xf32>) -> (tensor<13x8x9xf32>, tensor<13x8x9xf32>)94  return %0, %1 : tensor<13x8x9xf32>, tensor<13x8x9xf32>95}96 97// -----98// CHECK-LABEL: transpose_conv2d99func.func @test_transpose_conv2d(%arg0: tensor<1x32x32x8xf32>, %arg1: tensor<16x1x1x8xf32>, %arg2: tensor<16xf32>) -> tensor<1x32x32x16xf32> {100  // CHECK: profiles: [ [pro_int, pro_fp] ]101  // CHECK: extensions: [ [int4, int16, fp8e4m3, fp8e5m2, bf16] ]102  %input_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>103  %weight_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>104  %0 = tosa.transpose_conv2d %arg0, %arg1, %arg2, %input_zp, %weight_zp {acc_type = f32, out_pad = array<i64: 0, 0, 0, 0>, out_shape = array<i64: 1, 32, 32, 16>, stride = array<i64: 1, 1>} : (tensor<1x32x32x8xf32>, tensor<16x1x1x8xf32>, tensor<16xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<1x32x32x16xf32>105  return %0 : tensor<1x32x32x16xf32>106}107 108// -----109// CHECK-LABEL: clamp110func.func @test_clamp(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {111  // CHECK: profiles: [ [pro_int, pro_fp] ]112  // CHECK: extensions: [ [int16, bf16] ]113  %0 = tosa.clamp %arg0 {min_val = -3.40282347E+38 : f32, max_val = 3.40282347E+38 : f32} : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>114  return %0 : tensor<13x21x3xf32>115}116 117// -----118// CHECK-LABEL: sigmoid119func.func @test_sigmoid(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {120  // CHECK: profiles: [ [pro_fp] ]121  // CHECK: extensions: [ [bf16] ]122  %0 = tosa.sigmoid %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>123  return %0 : tensor<13x21x3xf32>124}125 126// -----127// CHECK-LABEL: tanh128func.func @test_tanh(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {129  // CHECK: profiles: [ [pro_fp] ]130  // CHECK: extensions: [ [bf16] ]131  %0 = tosa.tanh %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>132  return %0 : tensor<13x21x3xf32>133}134// -----135// CHECK-LABEL: erf136func.func @test_erf(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {137  // CHECK: profiles: [ [pro_fp] ]138  // CHECK: extensions: [ [bf16] ]139  %0 = tosa.erf %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>140  return %0 : tensor<13x21x3xf32>141}142 143// -----144// CHECK-LABEL: add145func.func @test_add(%arg0: tensor<13x21x1xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {146  // CHECK: profiles: [ [pro_int, pro_fp] ]147  // CHECK: extensions: [ [bf16, int64] ]148  %0 = tosa.add %arg0, %arg1 : (tensor<13x21x1xf32>, tensor<13x21x3xf32>) -> tensor<13x21x3xf32>149  return %0 : tensor<13x21x3xf32>150}151 152// -----153// CHECK-LABEL: arithmetic_right_shift154func.func @test_arithmetic_right_shift(%arg0: tensor<13x21x1xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {155  // CHECK: profiles: [ [pro_int] ]156  // CHECK: extensions: [ [int64] ]157  %0 = tosa.arithmetic_right_shift %arg0, %arg1 {round = false} : (tensor<13x21x1xf32>, tensor<13x21x3xf32>) -> tensor<13x21x3xf32>158  return %0 : tensor<13x21x3xf32>159}160 161// -----162// CHECK-LABEL: bitwise_and163func.func @test_bitwise_and(%arg0: tensor<13x21x3xi32>, %arg1: tensor<13x21x1xi32>) -> tensor<13x21x3xi32> {164  // CHECK: profiles: [ [pro_int] ]165  // CHECK: extensions: [ [int64] ]166  %0 = tosa.bitwise_and %arg0, %arg1 : (tensor<13x21x3xi32>, tensor<13x21x1xi32>) -> tensor<13x21x3xi32>167  return %0 : tensor<13x21x3xi32>168}169 170// -----171// CHECK-LABEL: bitwise_or172func.func @test_bitwise_or(%arg0: tensor<13x21x3xi32>, %arg1: tensor<13x1x3xi32>) -> tensor<13x21x3xi32> {173  // CHECK: profiles: [ [pro_int] ]174  // CHECK: extensions: [ [int64] ]175  %0 = tosa.bitwise_or %arg0, %arg1 : (tensor<13x21x3xi32>, tensor<13x1x3xi32>) -> tensor<13x21x3xi32>176  return %0 : tensor<13x21x3xi32>177}178 179// -----180// CHECK-LABEL: bitwise_xor181func.func @test_bitwise_xor(%arg0: tensor<13x21x1xi32>, %arg1: tensor<13x21x3xi32>) -> tensor<13x21x3xi32> {182  // CHECK: profiles: [ [pro_int] ]183  // CHECK: extensions: [ [int64] ]184  %0 = tosa.bitwise_xor %arg0, %arg1 : (tensor<13x21x1xi32>, tensor<13x21x3xi32>) -> tensor<13x21x3xi32>185  return %0 : tensor<13x21x3xi32>186}187 188// -----189// CHECK-LABEL: intdiv190func.func @test_intdiv(%arg0: tensor<13x21x1xi32>, %arg1: tensor<13x21x3xi32>) -> tensor<13x21x3xi32> {191  // CHECK: profiles: [ [pro_int, pro_fp] ]192  // CHECK: extensions: [ [int64] ]193  %0 = tosa.intdiv %arg0, %arg1 : (tensor<13x21x1xi32>, tensor<13x21x3xi32>) -> tensor<13x21x3xi32>194  return %0 : tensor<13x21x3xi32>195}196 197// -----198// CHECK-LABEL: logical_and199func.func @test_logical_and(%arg0: tensor<13x21x3xi1>, %arg1: tensor<13x21x1xi1>) -> tensor<13x21x3xi1> {200  // CHECK: profiles: [ [pro_int, pro_fp] ]201  // CHECK: extensions: [ ]202  %0 = tosa.logical_and %arg0, %arg1 : (tensor<13x21x3xi1>, tensor<13x21x1xi1>) -> tensor<13x21x3xi1>203  return %0 : tensor<13x21x3xi1>204}205 206// -----207// CHECK-LABEL: logical_left_shift208func.func @test_logical_left_shift(%arg0: tensor<13x21x3xi32>, %arg1: tensor<13x21x1xi32>) -> tensor<13x21x3xi32> {209  // CHECK: profiles: [ [pro_int, pro_fp] ]210  // CHECK: extensions: [ [int64] ]211  %0 = tosa.logical_left_shift %arg0, %arg1 : (tensor<13x21x3xi32>, tensor<13x21x1xi32>) -> tensor<13x21x3xi32>212  return %0 : tensor<13x21x3xi32>213}214 215// -----216// CHECK-LABEL: logical_right_shift217func.func @test_logical_right_shift(%arg0: tensor<13x21x3xi32>, %arg1: tensor<13x21x1xi32>) -> tensor<13x21x3xi32> {218  // CHECK: profiles: [ [pro_int, pro_fp] ]219  // CHECK: extensions: [ [int64] ]220  %0 = tosa.logical_right_shift %arg0, %arg1 : (tensor<13x21x3xi32>, tensor<13x21x1xi32>) -> tensor<13x21x3xi32>221  return %0 : tensor<13x21x3xi32>222}223 224// -----225// CHECK-LABEL: logical_or226func.func @test_logical_or(%arg0: tensor<13x1x3xi1>, %arg1: tensor<13x21x3xi1>) -> tensor<13x21x3xi1> {227  // CHECK: profiles: [ [pro_int, pro_fp] ]228  // CHECK: extensions: [ ]229  %0 = tosa.logical_or %arg0, %arg1 : (tensor<13x1x3xi1>, tensor<13x21x3xi1>) -> tensor<13x21x3xi1>230  return %0 : tensor<13x21x3xi1>231}232 233// -----234// CHECK-LABEL: logical_xor235func.func @test_logical_xor(%arg0: tensor<13x1x3xi1>, %arg1: tensor<13x21x3xi1>) -> tensor<13x21x3xi1> {236  // CHECK: profiles: [ [pro_int, pro_fp] ]237  // CHECK: extensions: [ ]238  %0 = tosa.logical_xor %arg0, %arg1 : (tensor<13x1x3xi1>, tensor<13x21x3xi1>) -> tensor<13x21x3xi1>239  return %0 : tensor<13x21x3xi1>240}241 242// -----243// CHECK-LABEL: maximum244func.func @test_max(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x21x1xf32>) -> tensor<13x21x3xf32> {245  // CHECK: profiles: [ [pro_int, pro_fp] ]246  // CHECK: extensions: [ [bf16, int64] ]247  %0 = tosa.maximum %arg0, %arg1 : (tensor<13x21x3xf32>, tensor<13x21x1xf32>) -> tensor<13x21x3xf32>248  return %0 : tensor<13x21x3xf32>249}250 251// -----252// CHECK-LABEL: minimum253func.func @test_min(%arg0: tensor<13x21x3xf32>, %arg1: tensor<1x21x3xf32>) -> tensor<13x21x3xf32> {254  // CHECK: profiles: [ [pro_int, pro_fp] ]255  // CHECK: extensions: [ [bf16, int64] ]256  %0 = tosa.minimum %arg0, %arg1 : (tensor<13x21x3xf32>, tensor<1x21x3xf32>) -> tensor<13x21x3xf32>257  return %0 : tensor<13x21x3xf32>258}259 260// -----261// CHECK-LABEL: mul262func.func @test_mul(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x1x3xf32>) -> tensor<13x21x3xf32> {263  %shift = "tosa.const"() <{values = dense<0> : tensor<1xi8>}> : () -> tensor<1xi8>264  // CHECK: profiles: [ [pro_int, pro_fp] ]265  // CHECK: extensions: [ [bf16, int64] ]266  %0 = tosa.mul %arg0, %arg1, %shift : (tensor<13x21x3xf32>, tensor<13x1x3xf32>, tensor<1xi8>) -> tensor<13x21x3xf32>267  return %0 : tensor<13x21x3xf32>268}269 270// -----271// CHECK-LABEL: pow272func.func @test_pow(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x21x1xf32>) -> tensor<13x21x3xf32> {273  // CHECK: profiles: [ [pro_fp] ]274  // CHECK: extensions: [ [bf16] ]275  %0 = tosa.pow %arg0, %arg1 : (tensor<13x21x3xf32>, tensor<13x21x1xf32>) -> tensor<13x21x3xf32>276  return %0 : tensor<13x21x3xf32>277}278 279// -----280// CHECK-LABEL: sub281func.func @test_sub(%arg0: tensor<1x21x3xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {282  // CHECK: profiles: [ [pro_int, pro_fp] ]283  // CHECK: extensions: [ [bf16, int64] ]284  %0 = tosa.sub %arg0, %arg1 : (tensor<1x21x3xf32>, tensor<13x21x3xf32>) -> tensor<13x21x3xf32>285  return %0 : tensor<13x21x3xf32>286}287 288// -----289// CHECK-LABEL: table290func.func @test_table(%arg0: tensor<64xi32>, %arg1: tensor<513x!quant.uniform<i16:f32, 1.0:0>>) -> tensor<64x!quant.uniform<i16:f32, 1.0:0>> {291  // CHECK: profiles: [ [pro_int] ]292  // CHECK: extensions: [ [int16] ]293  %0 = tosa.table %arg0, %arg1 : (tensor<64xi32>, tensor<513x!quant.uniform<i16:f32, 1.000000e+00>>) -> tensor<64x!quant.uniform<i16:f32, 1.000000e+00>>294  return %0 : tensor<64x!quant.uniform<i16:f32, 1.0:0>>295}296 297// -----298// CHECK-LABEL: abs299func.func @test_abs(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {300  // CHECK: profiles: [ [pro_int, pro_fp] ]301  // CHECK: extensions: [ [bf16, int64] ]302  %0 = tosa.abs %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>303  return %0 : tensor<13x21x3xf32>304}305 306// -----307// CHECK-LABEL: bitwise_not308func.func @test_bitwise_not(%arg0: tensor<13x21x1xi32>) -> tensor<13x21x1xi32> {309  // CHECK: profiles: [ [pro_int] ]310  // CHECK: extensions: [ [int64] ]311  %0 = tosa.bitwise_not %arg0 : (tensor<13x21x1xi32>) -> tensor<13x21x1xi32>312  return %0 : tensor<13x21x1xi32>313}314 315// -----316// CHECK-LABEL: ceil317func.func @test_ceil(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {318  // CHECK: profiles: [ [pro_fp] ]319  // CHECK: extensions: [ [bf16] ]320  %0 = tosa.ceil %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>321  return %0 : tensor<13x21x3xf32>322}323 324// -----325// CHECK-LABEL: clz326func.func @test_clz(%arg0: tensor<13x21x3xi32>) -> tensor<13x21x3xi32> {327  // CHECK: profiles: [ [pro_int] ]328  // CHECK: extensions: [ [int64] ]329  %0 = tosa.clz %arg0 : (tensor<13x21x3xi32>) -> tensor<13x21x3xi32>330  return %0 : tensor<13x21x3xi32>331}332 333// -----334// CHECK-LABEL: cos335func.func @test_cos(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {336  // CHECK: profiles: [ [pro_fp] ]337  // CHECK: extensions: [ [bf16] ]338  %0 = tosa.cos %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>339  return %0 : tensor<13x21x3xf32>340}341 342// -----343// CHECK-LABEL: exp344func.func @test_exp(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {345  // CHECK: profiles: [ [pro_fp] ]346  // CHECK: extensions: [ [bf16] ]347  %0 = tosa.exp %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>348  return %0 : tensor<13x21x3xf32>349}350 351// -----352// CHECK-LABEL: floor353func.func @test_floor(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {354  // CHECK: profiles: [ [pro_fp] ]355  // CHECK: extensions: [ [bf16] ]356  %0 = tosa.floor %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>357  return %0 : tensor<13x21x3xf32>358}359 360// -----361// CHECK-LABEL: log362func.func @test_log(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {363  // CHECK: profiles: [ [pro_fp] ]364  // CHECK: extensions: [ [bf16] ]365  %0 = tosa.log %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>366  return %0 : tensor<13x21x3xf32>367}368 369// -----370// CHECK-LABEL: logical_not371func.func @test_logical_not(%arg0: tensor<1x21x3xi1>) -> tensor<1x21x3xi1> {372  // CHECK: profiles: [ [pro_int, pro_fp] ]373  // CHECK: extensions: [ ]374  %0 = tosa.logical_not %arg0 : (tensor<1x21x3xi1>) -> tensor<1x21x3xi1>375  return %0 : tensor<1x21x3xi1>376}377 378// -----379// CHECK-LABEL: negate380func.func @test_negate(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {381  // CHECK: profiles: [ [pro_int, pro_fp] ]382  // CHECK: extensions: [ [bf16, int64] ]383  %input_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>384  %output_zp = "tosa.const"() <{values = dense<0.0> : tensor<1xf32>}> : () -> tensor<1xf32>385  %0 = tosa.negate %arg0, %input_zp, %output_zp : (tensor<13x21x3xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<13x21x3xf32>386  return %0 : tensor<13x21x3xf32>387}388 389// -----390// CHECK-LABEL: reciprocal391func.func @test_reciprocal(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {392  // CHECK: profiles: [ [pro_fp] ]393  // CHECK: extensions: [ [bf16] ]394  %0 = tosa.reciprocal %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>395  return %0 : tensor<13x21x3xf32>396}397 398// -----399// CHECK-LABEL: rsqrt400func.func @test_rsqrt(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {401  // CHECK: profiles: [ [pro_fp] ]402  // CHECK: extensions: [ [bf16] ]403  %0 = tosa.rsqrt %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>404  return %0 : tensor<13x21x3xf32>405}406 407// -----408// CHECK-LABEL: sin409func.func @test_sin(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {410  // CHECK: profiles: [ [pro_fp] ]411  // CHECK: extensions: [ [bf16] ]412  %0 = tosa.sin %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>413  return %0 : tensor<13x21x3xf32>414}415 416// -----417// CHECK-LABEL: select418func.func @test_select(%arg0: tensor<1x1x1xi1>, %arg1: tensor<13x21x3xf32>, %arg2: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {419  // CHECK: profiles: [ [pro_int, pro_fp] ]420  // CHECK: extensions: [ [bf16, int64] ]421  %0 = tosa.select %arg0, %arg1, %arg2 : (tensor<1x1x1xi1>, tensor<13x21x3xf32>, tensor<13x21x3xf32>) -> tensor<13x21x3xf32>422  return %0 : tensor<13x21x3xf32>423}424 425// -----426// CHECK-LABEL: equal427func.func @test_equal(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x1x3xf32>) -> tensor<13x21x3xi1> {428  // CHECK: profiles: [ [pro_int, pro_fp] ]429  // CHECK: extensions: [ [bf16, int64] ]430  %0 = tosa.equal %arg0, %arg1 : (tensor<13x21x3xf32>, tensor<13x1x3xf32>) -> tensor<13x21x3xi1>431  return %0 : tensor<13x21x3xi1>432}433 434// -----435// CHECK-LABEL: greater436func.func @test_greater(%arg0: tensor<13x21x1xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<13x21x3xi1> {437  // CHECK: profiles: [ [pro_int, pro_fp] ]438  // CHECK: extensions: [ [bf16, int64] ]439  %0 = tosa.greater %arg0, %arg1 : (tensor<13x21x1xf32>, tensor<13x21x3xf32>) -> tensor<13x21x3xi1>440  return %0 : tensor<13x21x3xi1>441}442 443// -----444// CHECK-LABEL: greater_equal445func.func @test_greater_equal(%arg0: tensor<13x1x3xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<13x21x3xi1> {446  // CHECK: profiles: [ [pro_int, pro_fp] ]447  // CHECK: extensions: [ [bf16, int64] ]448  %0 = tosa.greater_equal %arg0, %arg1 : (tensor<13x1x3xf32>, tensor<13x21x3xf32>) -> tensor<13x21x3xi1>449  return %0 : tensor<13x21x3xi1>450}451 452// -----453// CHECK-LABEL: reduce_all454func.func @test_reduce_all(%arg0: tensor<13x21x3xi1>) -> tensor<1x21x3xi1> {455  // CHECK: profiles: [ [pro_int, pro_fp] ]456  // CHECK: extensions: [ ]457  %0 = tosa.reduce_all %arg0 {axis = 0 : i32} : (tensor<13x21x3xi1>) -> tensor<1x21x3xi1>458  return %0 : tensor<1x21x3xi1>459}460 461// -----462// CHECK-LABEL: reduce_any463func.func @test_reduce_any(%arg0: tensor<13x21x3xi1>) -> tensor<1x21x3xi1> {464  // CHECK: profiles: [ [pro_int, pro_fp] ]465  // CHECK: extensions: [ ]466  %0 = tosa.reduce_any %arg0 {axis = 0 : i32} : (tensor<13x21x3xi1>) -> tensor<1x21x3xi1>467  return %0 : tensor<1x21x3xi1>468}469 470// -----471// CHECK-LABEL: reduce_max472func.func @test_reduce_max(%arg0: tensor<13x21x3xf32>) -> tensor<1x21x3xf32> {473  // CHECK: profiles: [ [pro_int, pro_fp] ]474  // CHECK: extensions: [ [bf16, int64] ]475  %0 = tosa.reduce_max %arg0 {axis = 0 : i32} : (tensor<13x21x3xf32>) -> tensor<1x21x3xf32>476  return %0 : tensor<1x21x3xf32>477}478 479// -----480// CHECK-LABEL: reduce_min481func.func @test_reduce_min(%arg0: tensor<13x21x3xf32>) -> tensor<1x21x3xf32> {482  // CHECK: profiles: [ [pro_int, pro_fp] ]483  // CHECK: extensions: [ [bf16, int64] ]484  %0 = tosa.reduce_min %arg0 {axis = 0 : i32} : (tensor<13x21x3xf32>) -> tensor<1x21x3xf32>485  return %0 : tensor<1x21x3xf32>486}487 488// -----489// CHECK-LABEL: reduce_product490func.func @test_reduce_product(%arg0: tensor<13x21x3xf32>) -> tensor<1x21x3xf32> {491  // CHECK: profiles: [ [pro_fp] ]492  // CHECK: extensions: [ [bf16] ]493  %0 = tosa.reduce_product %arg0 {axis = 0 : i32} : (tensor<13x21x3xf32>) -> tensor<1x21x3xf32>494  return %0 : tensor<1x21x3xf32>495}496 497// -----498// CHECK-LABEL: reduce_sum499func.func @test_reduce_sum(%arg0: tensor<13x21x3xf32>) -> tensor<1x21x3xf32> {500  // CHECK: profiles: [ [pro_int, pro_fp] ]501  // CHECK: extensions: [ [bf16, int64] ]502  %0 = tosa.reduce_sum %arg0 {axis = 0 : i32} : (tensor<13x21x3xf32>) -> tensor<1x21x3xf32>503  return %0 : tensor<1x21x3xf32>504}505 506// -----507// CHECK-LABEL: concat508func.func @test_concat(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x21x3xf32>) -> tensor<26x21x3xf32> {509  // CHECK: profiles: [ [pro_int, pro_fp] ]510  // CHECK: extensions: [ [fp8e4m3, fp8e5m2, bf16, int16, int64] ]511  %0 = tosa.concat %arg0, %arg1 {axis = 0 : i32} : (tensor<13x21x3xf32>, tensor<13x21x3xf32>) -> tensor<26x21x3xf32>512  return %0 : tensor<26x21x3xf32>513}514 515// -----516// CHECK-LABEL: pad517func.func @test_pad(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {518  %padding = tosa.const_shape {values = dense<0> : tensor<6xindex>} : () -> !tosa.shape<6>519  %pad_const = "tosa.const"() {values = dense<3.14> : tensor<1xf32>} : () -> tensor<1xf32>520  // CHECK: profiles: [ [pro_int, pro_fp] ]521  // CHECK: extensions: [ [fp8e4m3, fp8e5m2, bf16, int64] ]522  %0 = tosa.pad %arg0, %padding, %pad_const : (tensor<13x21x3xf32>, !tosa.shape<6>, tensor<1xf32>) -> tensor<13x21x3xf32>523  return %0 : tensor<13x21x3xf32>524}525 526// -----527// CHECK-LABEL: reshape528func.func @test_reshape(%arg0: tensor<13x21x3xf32>) -> tensor<1x819xf32> {529  %1 = tosa.const_shape {values = dense<[1, 819]> : tensor<2xindex>} : () -> !tosa.shape<2>530  // CHECK: profiles: [ [pro_int, pro_fp] ]531  // CHECK: extensions: [ [fp8e4m3, fp8e5m2, bf16, int64] ]532  %0 = tosa.reshape %arg0, %1 : (tensor<13x21x3xf32>, !tosa.shape<2>) -> tensor<1x819xf32>533  return %0 : tensor<1x819xf32>534}535 536// -----537// CHECK-LABEL: reverse538func.func @test_reverse(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xf32> {539  // CHECK: profiles: [ [pro_int, pro_fp] ]540  // CHECK: extensions: [ [fp8e4m3, fp8e5m2, bf16, int64] ]541  %0 = tosa.reverse %arg0 {axis = 0 : i32} : (tensor<13x21x3xf32>) -> tensor<13x21x3xf32>542  return %0 : tensor<13x21x3xf32>543}544 545// -----546// CHECK-LABEL: slice547func.func @test_slice(%arg0: tensor<13x21x3xf32>) -> tensor<4x11x1xf32> {548  %0 = tosa.const_shape {values = dense<[4, 11, 1]> : tensor<3xindex>} : () -> !tosa.shape<3>549  %1 = tosa.const_shape {values = dense<[6, 8, 0]> : tensor<3xindex>} : () -> !tosa.shape<3>550  // CHECK: profiles: [ [pro_int, pro_fp] ]551  // CHECK: extensions: [ [fp8e4m3, fp8e5m2, bf16, int64] ]552  %2 = tosa.slice %arg0, %0, %1 : (tensor<13x21x3xf32>, !tosa.shape<3>, !tosa.shape<3>) -> tensor<4x11x1xf32>553  return %2 : tensor<4x11x1xf32>554}555 556// -----557// CHECK-LABEL: tile558func.func @test_tile(%arg0: tensor<13x21x3xf32>) -> tensor<39x21x6xf32> {559  %cst = tosa.const_shape { values = dense<[3, 1, 2]> : tensor<3xindex> } : () -> !tosa.shape<3>560  // CHECK: profiles: [ [pro_int, pro_fp] ]561  // CHECK: extensions: [ [fp8e4m3, fp8e5m2, bf16, int64] ]562  %0 = tosa.tile %arg0, %cst: (tensor<13x21x3xf32>, !tosa.shape<3>) -> tensor<39x21x6xf32>563  return %0 : tensor<39x21x6xf32>564}565 566// -----567// CHECK-LABEL: transpose568func.func @test_transpose(%arg0: tensor<13x21x3xf32>) -> tensor<3x13x21xf32> {569  // CHECK: profiles: [ [pro_int, pro_fp] ]570  // CHECK: extensions: [ [fp8e4m3, fp8e5m2, bf16, int64] ]571  %1 = tosa.transpose %arg0 {perms = array<i32: 2, 0, 1>}: (tensor<13x21x3xf32>) -> tensor<3x13x21xf32>572  return %1 : tensor<3x13x21xf32>573}574 575// -----576// CHECK-LABEL: gather577func.func @test_gather(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x26xi32>) -> tensor<13x26x3xf32> {578  // CHECK: profiles: [ [pro_int, pro_fp] ]579  // CHECK: extensions: [ [fp8e4m3, fp8e5m2, bf16, int64] ]580  %0 = tosa.gather %arg0, %arg1 : (tensor<13x21x3xf32>, tensor<13x26xi32>) -> tensor<13x26x3xf32>581  return %0 : tensor<13x26x3xf32>582}583 584// -----585// CHECK-LABEL: scatter586func.func @test_scatter(%arg0: tensor<13x28x3xf32>, %arg1: tensor<13x26xi32>, %arg2: tensor<13x26x3xf32>) -> tensor<13x28x3xf32> {587  // CHECK: profiles: [ [pro_int, pro_fp] ]588  // CHECK: extensions: [ [fp8e4m3, fp8e5m2, bf16, int64] ]589  %0 = tosa.scatter %arg0, %arg1, %arg2 : (tensor<13x28x3xf32>, tensor<13x26xi32>, tensor<13x26x3xf32>) -> tensor<13x28x3xf32>590  return %0 : tensor<13x28x3xf32>591}592 593// -----594// CHECK-LABEL: resize595func.func @test_resize(%arg0: tensor<1x32x32x8xf32>) -> tensor<1x64x64x8xf32> {596  %scale = tosa.const_shape { values = dense<[4, 2, 4, 2]> : tensor<4xindex> } : () -> !tosa.shape<4>597  %offset = tosa.const_shape { values = dense<[-1, -1]> : tensor<2xindex> } : () -> !tosa.shape<2>598  %border = tosa.const_shape { values = dense<[1, 1]> : tensor<2xindex> } : () -> !tosa.shape<2>599  // CHECK: profiles: [ [pro_int, pro_fp] ]600  // CHECK: extensions: [ [int16, bf16] ]601  %1 = tosa.resize %arg0, %scale, %offset, %border {mode = BILINEAR} : (tensor<1x32x32x8xf32>, !tosa.shape<4>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<1x64x64x8xf32>602  return %1 : tensor<1x64x64x8xf32>603}604 605// -----606// CHECK-LABEL: cast607func.func @test_cast1(%arg0: tensor<13x21x3xi32>) -> tensor<13x21x3xf32> {608  // CHECK: profiles: [ [pro_int, pro_fp] ]609  // CHECK: extensions: [ [fp8e4m3, fp8e5m2, bf16, mxfp, int64] ]610  %0 = tosa.cast %arg0 : (tensor<13x21x3xi32>) -> tensor<13x21x3xf32>611  return %0 : tensor<13x21x3xf32>612}613 614// -----615// CHECK-LABEL: test_rescale616func.func @test_rescale(%arg0: tensor<13x21x3x!quant.uniform<u8:f32, 0.015655439347028732:127>>, %multiplier : tensor<1xi32>, %shift : tensor<1xi8>) -> tensor<13x21x3x!quant.uniform<i8:f32, 0.015655439347028732:-1>> {617  %input_zp = "tosa.const"() {values = dense<127> : tensor<1xi8>} : () -> tensor<1xi8>618  %output_zp = "tosa.const"() {values = dense<-1> : tensor<1xi8>} : () -> tensor<1xi8>619  // CHECK: tosa.rescale profiles: [ [pro_int] ]620  // CHECK: tosa.rescale extensions: [ [int16] ]621  %0 = tosa.rescale %arg0, %multiplier, %shift, %input_zp, %output_zp {rounding_mode = SINGLE_ROUND, scale32 = true, per_channel = false, input_unsigned = false, output_unsigned = false} : (tensor<13x21x3x!quant.uniform<u8:f32, 0.015655439347028732:127>>, tensor<1xi32>, tensor<1xi8>, tensor<1xi8>, tensor<1xi8>) -> tensor<13x21x3x!quant.uniform<i8:f32, 0.015655439347028732:-1>>622  return %0 : tensor<13x21x3x!quant.uniform<i8:f32, 0.015655439347028732:-1>>623}624 625// -----626// CHECK-LABEL: test_const627func.func @test_const(%arg0 : index) -> tensor<4xi32> {628  // CHECK: profiles: [ [pro_int, pro_fp] ]629  // CHECK: extensions: [ [int4, int16, fp8e4m3, fp8e5m2, bf16, mxfp, int64] ]630    %0 = "tosa.const"() {values = dense<[3, 0, 1, 2]> : tensor<4xi32>} : () -> tensor<4xi32>631    return %0 : tensor<4xi32>632}633 634// -----635// CHECK-LABEL: identity636func.func @test_identity(%arg0: tensor<13x21x3xi32>) -> tensor<13x21x3xi32> {637  // CHECK: profiles: [ [pro_int, pro_fp] ]638  // CHECK: extensions: [ [int4, int16, fp8e4m3, fp8e5m2, bf16, int64] ]639  %0 = tosa.identity %arg0 : (tensor<13x21x3xi32>) -> tensor<13x21x3xi32>640  return %0 : tensor<13x21x3xi32>641}642 643// -----644// CHECK-LABEL: cond_if645func.func @test_cond_if(%arg0: tensor<f32>, %arg1: tensor<f32>, %arg2: tensor<i1>) -> tensor<f32> {646  // CHECK: tosa.cond_if profiles: [ ]647  // CHECK: tosa.cond_if extensions: [ [controlflow] ]648  %0 = tosa.cond_if %arg2 : tensor<i1> -> tensor<f32> {649    %1 = tosa.add %arg0, %arg1 : (tensor<f32>, tensor<f32>) -> tensor<f32>650    tosa.yield %1 : tensor<f32>651  } else {652    %1 = tosa.sub %arg0, %arg1 : (tensor<f32>, tensor<f32>) -> tensor<f32>653    tosa.yield %1 : tensor<f32>654  }655  return %0 : tensor<f32>656}657 658// -----659// CHECK-LABEL: while_loop660func.func @test_while_loop(%arg0: tensor<10xi32>, %arg1: tensor<i32>) {661  %0 = "tosa.const"() {values = dense<0> : tensor<i32>} : () -> tensor<i32>662  // CHECK: profiles: [ ]663  // CHECK: extensions: [ [controlflow] ]664  %1:3 = tosa.while_loop (%arg2 = %0, %arg3 = %0, %arg4 = %arg0) : (tensor<i32>, tensor<i32>, tensor<10xi32>) -> (tensor<i32>, tensor<i32>, tensor<10xi32>) {665    %2 = tosa.greater_equal %arg3, %arg1 : (tensor<i32>, tensor<i32>) -> tensor<i1>666    %3 = tosa.logical_not %2 : (tensor<i1>) -> tensor<i1>667    tosa.yield %3 : tensor<i1>668  } do {669  ^bb0(%arg2: tensor<i32>, %arg3: tensor<i32>, %arg4: tensor<10xi32>):670    %2 = "tosa.const"() {values = dense<1> : tensor<i32>} : () -> tensor<i32>671    %3 = tosa.add %arg3, %2 : (tensor<i32>, tensor<i32>) -> tensor<i32>672    %7 = tosa.const_shape {values = dense<[1]> : tensor<1xindex>} : () -> !tosa.shape<1>673    %4 = tosa.reshape %2, %7 : (tensor<i32>, !tosa.shape<1>) -> tensor<1xi32>674    %5 = tosa.add %arg4, %4 : (tensor<10xi32>, tensor<1xi32>) -> tensor<10xi32>675    %6 = tosa.add %arg2, %2 : (tensor<i32>, tensor<i32>) -> tensor<i32>676    tosa.yield %6, %3, %5 : tensor<i32>, tensor<i32>, tensor<10xi32>677  }678  return679}680 681// -----682// CHECK-LABEL: custom683func.func @test_custom(%arg0: tensor<10xi32>) -> tensor<10xi32> {684  // CHECK: profiles: [ [pro_int, pro_fp] ]685  // CHECK: extensions: [ ]686  %0 = tosa.custom %arg0 {operator_name="custom_test", domain_name="tosa.mlir_test", implementation_attrs="" } : (tensor<10xi32>) -> (tensor<10xi32>)687  return %0 : tensor<10xi32>688}689 690// -----691// CHECK-LABEL: const_shape692func.func @test_const_shape() -> !tosa.shape<4> {693  // CHECK: profiles: [ [pro_int, pro_fp] ]694  // CHECK: extensions: [ ]695  %cst = tosa.const_shape {values = dense<1> : tensor<4xindex>} : () -> !tosa.shape<4>696  return %cst : !tosa.shape<4>697}698 699// -----700// CHECK-LABEL: test_cast_from_block_scaled701func.func @test_cast_from_block_scaled(%arg0: tensor<4x32xf4E2M1FN>, %arg1: tensor<4x1xf8E8M0FNU>) -> tensor<4x32xf32> {702  // CHECK: profiles: [ [pro_fp] ]703  // CHECK: extensions: [ [bf16, mxfp] ]704  %0 = tosa.cast_from_block_scaled %arg0, %arg1 {block_size = #tosa.block_size<BLOCK_SIZE_32> : i32} : (tensor<4x32xf4E2M1FN>, tensor<4x1xf8E8M0FNU>) -> tensor<4x32xf32>705  return %0 : tensor<4x32xf32>706}707 708// -----709// CHECK-LABEL: test_cast_to_block_scaled710func.func @test_cast_to_block_scaled(%arg0: tensor<4x32xf32>) -> (tensor<4x32xf4E2M1FN>, tensor<4x1xf8E8M0FNU>) {711  // CHECK: profiles: [ [pro_fp] ]712  // CHECK: extensions: [ [bf16, mxfp] ]713  %0:2 = tosa.cast_to_block_scaled %arg0 {block_size = BLOCK_SIZE_32, stochastic_round = false} : (tensor<4x32xf32>) -> (tensor<4x32xf4E2M1FN>, tensor<4x1xf8E8M0FNU>)714  return %0#0, %0#1 : tensor<4x32xf4E2M1FN>, tensor<4x1xf8E8M0FNU>715}716 717