brintos

brintos / llvm-project-archived public Read only

0
0
Text · 31.9 KiB · 68a9578 Raw
587 lines · plain
1//--------------------------------------------------------------------------------------------------2// Enable all supported profiles to focus the verification of expected extension requirement errors.3//--------------------------------------------------------------------------------------------------4 5// RUN: mlir-opt %s -split-input-file -verify-diagnostics -tosa-attach-target="profiles=pro_int,pro_fp" -tosa-validate="strict-op-spec-alignment"6 7// -----8func.func @test_argmax(%arg0: tensor<14x19xbf16>) -> tensor<14xi32> {9  // expected-error@+1 {{'tosa.argmax' op illegal: requires [bf16] but not enabled in target}}10  %0 = tosa.argmax %arg0 {axis = 1 : i32} : (tensor<14x19xbf16>) -> tensor<14xi32>11  return %0 : tensor<14xi32>12}13 14// -----15func.func @test_avg_pool2d(%arg0: tensor<1x7x7x9xbf16>, %arg1: tensor<1xbf16>, %arg2: tensor<1xbf16>) -> tensor<1x7x7x9xbf16> {16  // expected-error@+1 {{'tosa.avg_pool2d' op illegal: requires [bf16] but not enabled in target}}17  %0 = tosa.avg_pool2d %arg0, %arg1, %arg2 {acc_type = f32, kernel = array<i64: 2, 2>, pad = array<i64: 0, 1, 0, 1>, stride = array<i64: 1, 1>} : (tensor<1x7x7x9xbf16>, tensor<1xbf16>, tensor<1xbf16>) -> tensor<1x7x7x9xbf16>18  return %0 : tensor<1x7x7x9xbf16>19}20 21// -----22func.func @test_conv2d(%arg0: tensor<1x4x4x4xi8>, %arg1: tensor<8x1x1x4xi4>, %arg2: tensor<8xi32>, %arg3: tensor<1xi8>, %arg4: tensor<1xi4>) -> tensor<1x4x4x8xi32> {23  // expected-error@+1 {{'tosa.conv2d' op illegal: requires [int4] but not enabled in target}}24  %0 = tosa.conv2d %arg0, %arg1, %arg2, %arg3, %arg4 {acc_type = i32, dilation = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>, local_bound = true} : (tensor<1x4x4x4xi8>, tensor<8x1x1x4xi4>, tensor<8xi32>, tensor<1xi8>, tensor<1xi4>) -> tensor<1x4x4x8xi32>25  return %0 : tensor<1x4x4x8xi32>26}27 28// -----29func.func @test_conv3d(%arg0: tensor<1x4x8x21x17xi16>, %arg1: tensor<34x1x1x1x17xi8>, %arg2: tensor<34xi48>, %arg3: tensor<1xi16>, %arg4: tensor<1xi8>) -> tensor<1x4x8x21x34xi48> {30  // expected-error@+1 {{'tosa.conv3d' op illegal: requires [int16] but not enabled in target}}31  %0 = tosa.conv3d %arg0, %arg1, %arg2, %arg3, %arg4 {acc_type = i48, dilation = array<i64: 1, 1, 1>, pad = array<i64: 0, 0, 0, 0, 0, 0>, stride = array<i64: 1, 1, 1>} : (tensor<1x4x8x21x17xi16>, tensor<34x1x1x1x17xi8>, tensor<34xi48>, tensor<1xi16>, tensor<1xi8>) -> tensor<1x4x8x21x34xi48>32  return %0 : tensor<1x4x8x21x34xi48>33}34 35// -----36func.func @test_depthwise_conv2d(%arg0: tensor<1x4x4x4xbf16>, %arg1: tensor<1x1x4x2xbf16>, %arg2: tensor<8xbf16>, %arg3: tensor<1xbf16>, %arg4: tensor<1xbf16>) -> tensor<1x4x4x8xbf16> {37  // expected-error@+1 {{'tosa.depthwise_conv2d' op illegal: requires [bf16] but not enabled in target}}38  %0 = tosa.depthwise_conv2d %arg0, %arg1, %arg2, %arg3, %arg4 {acc_type = f32, dilation = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>} : (tensor<1x4x4x4xbf16>, tensor<1x1x4x2xbf16>, tensor<8xbf16>, tensor<1xbf16>, tensor<1xbf16>) -> tensor<1x4x4x8xbf16>39  return %0 : tensor<1x4x4x8xbf16>40}41 42// -----43func.func @test_max_pool2d(%arg0: tensor<1x32x32x8xi16>) -> tensor<1x32x32x8xi16> {44  // expected-error@+1 {{'tosa.max_pool2d' op illegal: requires [int16] but not enabled in target}}45  %0 = tosa.max_pool2d %arg0 {kernel = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>} : (tensor<1x32x32x8xi16>) -> tensor<1x32x32x8xi16>46  return %0 : tensor<1x32x32x8xi16>47}48 49// -----50func.func @test_clamp(%arg0: tensor<13x21x3xi16>) -> tensor<13x21x3xi16> {51  // expected-error@+1 {{'tosa.clamp' op illegal: requires [int16] but not enabled in target}}52  %0 = tosa.clamp %arg0 {min_val = 0 : i16, max_val = 1 : i16} : (tensor<13x21x3xi16>) -> tensor<13x21x3xi16>53  return %0 : tensor<13x21x3xi16>54}55 56// -----57func.func @test_sigmoid(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {58  // expected-error@+1 {{'tosa.sigmoid' op illegal: requires [bf16] but not enabled in target}}59  %0 = tosa.sigmoid %arg0 : (tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>60  return %0 : tensor<13x21x3xbf16>61}62 63// -----64func.func @test_tanh(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {65  // expected-error@+1 {{'tosa.tanh' op illegal: requires [bf16] but not enabled in target}}66  %0 = tosa.tanh %arg0 : (tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>67  return %0 : tensor<13x21x3xbf16>68}69 70// -----71func.func @test_add(%arg0: tensor<13x21x1xbf16>, %arg1: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {72  // expected-error@+1 {{'tosa.add' op illegal: requires [bf16] but not enabled in target}}73  %0 = tosa.add %arg0, %arg1 : (tensor<13x21x1xbf16>, tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>74  return %0 : tensor<13x21x3xbf16>75}76 77// -----78func.func @test_max(%arg0: tensor<13x21x3xbf16>, %arg1: tensor<13x21x1xbf16>) -> tensor<13x21x3xbf16> {79  // expected-error@+1 {{'tosa.maximum' op illegal: requires [bf16] but not enabled in target}}80  %0 = tosa.maximum %arg0, %arg1 : (tensor<13x21x3xbf16>, tensor<13x21x1xbf16>) -> tensor<13x21x3xbf16>81  return %0 : tensor<13x21x3xbf16>82}83 84// -----85func.func @test_mul(%arg0: tensor<13x21x3xbf16>, %arg1: tensor<13x1x3xbf16>, %shift: tensor<1xi8>) -> tensor<13x21x3xbf16> {86  // expected-error@+1 {{'tosa.mul' op illegal: requires [bf16] but not enabled in target}}87  %0 = tosa.mul %arg0, %arg1, %shift : (tensor<13x21x3xbf16>, tensor<13x1x3xbf16>, tensor<1xi8>) -> tensor<13x21x3xbf16>88  return %0 : tensor<13x21x3xbf16>89}90 91// -----92func.func @test_pow(%arg0: tensor<13x21x3xbf16>, %arg1: tensor<13x21x1xbf16>) -> tensor<13x21x3xbf16> {93  // expected-error@+1 {{'tosa.pow' op illegal: requires [bf16] but not enabled in target}}94  %0 = tosa.pow %arg0, %arg1 : (tensor<13x21x3xbf16>, tensor<13x21x1xbf16>) -> tensor<13x21x3xbf16>95  return %0 : tensor<13x21x3xbf16>96}97 98// -----99func.func @test_sub(%arg0: tensor<1x21x3xbf16>, %arg1: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {100  // expected-error@+1 {{'tosa.sub' op illegal: requires [bf16] but not enabled in target}}101  %0 = tosa.sub %arg0, %arg1 : (tensor<1x21x3xbf16>, tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>102  return %0 : tensor<13x21x3xbf16>103}104 105// -----106func.func @test_table(%arg0 : tensor<4x5xi16>, %arg1 : tensor<513xi16>) -> () {107  // expected-error@+1 {{'tosa.table' op illegal: requires [int16] but not enabled in target}}108  %0 = tosa.table %arg0, %arg1 : (tensor<4x5xi16>, tensor<513xi16>) -> tensor<?x?xi32>109  return110}111 112// -----113func.func @test_abs(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {114  // expected-error@+1 {{'tosa.abs' op illegal: requires [bf16] but not enabled in target}}115  %0 = tosa.abs %arg0 : (tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>116  return %0 : tensor<13x21x3xbf16>117}118 119// -----120func.func @test_cos(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {121  // expected-error@+1 {{'tosa.cos' op illegal: requires [bf16] but not enabled in target}}122  %0 = tosa.cos %arg0 : (tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>123  return %0 : tensor<13x21x3xbf16>124}125 126// -----127func.func @test_exp(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {128  // expected-error@+1 {{'tosa.exp' op illegal: requires [bf16] but not enabled in target}}129  %0 = tosa.exp %arg0 : (tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>130  return %0 : tensor<13x21x3xbf16>131}132 133// -----134func.func @test_floor(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {135  // expected-error@+1 {{'tosa.floor' op illegal: requires [bf16] but not enabled in target}}136  %0 = tosa.floor %arg0 : (tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>137  return %0 : tensor<13x21x3xbf16>138}139 140// -----141func.func @test_log(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {142  // expected-error@+1 {{'tosa.log' op illegal: requires [bf16] but not enabled in target}}143  %0 = tosa.log %arg0 : (tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>144  return %0 : tensor<13x21x3xbf16>145}146 147// -----148func.func @test_negate(%arg0: tensor<13x21x3xbf16>, %arg1: tensor<1xbf16>, %arg2: tensor<1xbf16>) -> tensor<13x21x3xbf16> {149  // expected-error@+1 {{'tosa.negate' op illegal: requires [bf16] but not enabled in target}}150  %0 = tosa.negate %arg0, %arg1, %arg2 : (tensor<13x21x3xbf16>, tensor<1xbf16>, tensor<1xbf16>) -> tensor<13x21x3xbf16>151  return %0 : tensor<13x21x3xbf16>152}153 154// -----155func.func @test_reciprocal(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {156  // expected-error@+1 {{'tosa.reciprocal' op illegal: requires [bf16] but not enabled in target}}157  %0 = tosa.reciprocal %arg0 : (tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>158  return %0 : tensor<13x21x3xbf16>159}160 161// -----162func.func @test_rsqrt(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {163  // expected-error@+1 {{'tosa.rsqrt' op illegal: requires [bf16] but not enabled in target}}164  %0 = tosa.rsqrt %arg0 : (tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>165  return %0 : tensor<13x21x3xbf16>166}167 168// -----169func.func @test_equal(%arg0: tensor<13x21x3xbf16>, %arg1: tensor<13x1x3xbf16>) -> tensor<13x21x3xi1> {170  // expected-error@+1 {{'tosa.equal' op illegal: requires [bf16] but not enabled in target}}171  %0 = tosa.equal %arg0, %arg1 : (tensor<13x21x3xbf16>, tensor<13x1x3xbf16>) -> tensor<13x21x3xi1>172  return %0 : tensor<13x21x3xi1>173}174 175// -----176func.func @test_reduce_max(%arg0: tensor<13x21x3xbf16>) -> tensor<1x21x3xbf16> {177  // expected-error@+1 {{'tosa.reduce_max' op illegal: requires [bf16] but not enabled in target}}178  %0 = tosa.reduce_max %arg0 {axis = 0 : i32} : (tensor<13x21x3xbf16>) -> tensor<1x21x3xbf16>179  return %0 : tensor<1x21x3xbf16>180}181 182// -----183func.func @test_concat(%arg0: tensor<13x21x3xbf16>, %arg1: tensor<13x21x3xbf16>) -> tensor<26x21x3xbf16> {184  // expected-error@+1 {{'tosa.concat' op illegal: requires [bf16] but not enabled in target}}185  %0 = tosa.concat %arg0, %arg1 {axis = 0 : i32} : (tensor<13x21x3xbf16>, tensor<13x21x3xbf16>) -> tensor<26x21x3xbf16>186  return %0 : tensor<26x21x3xbf16>187}188 189// -----190func.func @test_pad(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {191  %padding = tosa.const_shape {values = dense<0> : tensor<6xindex>} : () -> !tosa.shape<6>192  // expected-error@+1 {{'tosa.const' op illegal: requires [bf16] but not enabled in target}}193  %pad_const = "tosa.const"() {values = dense<3.14> : tensor<1xbf16>} : () -> tensor<1xbf16>194  // expected-error@+1 {{'tosa.pad' op illegal: requires [bf16] but not enabled in target}}195  %0 = tosa.pad %arg0, %padding, %pad_const : (tensor<13x21x3xbf16>, !tosa.shape<6>, tensor<1xbf16>) -> tensor<13x21x3xbf16>196  return %0 : tensor<13x21x3xbf16>197}198 199// -----200func.func @test_reshape(%arg0: tensor<13x21x3xbf16>) -> tensor<1x819xbf16> {201  %1 = tosa.const_shape {values = dense<[1, 819]> : tensor<2xindex>} : () -> !tosa.shape<2>202  // expected-error@+1 {{'tosa.reshape' op illegal: requires [bf16] but not enabled in target}}203  %0 = tosa.reshape %arg0, %1 : (tensor<13x21x3xbf16>, !tosa.shape<2>) -> tensor<1x819xbf16>204  return %0 : tensor<1x819xbf16>205}206 207// -----208func.func @test_reverse(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16> {209  // expected-error@+1 {{'tosa.reverse' op illegal: requires [bf16] but not enabled in target}}210  %0 = tosa.reverse %arg0 {axis = 0 : i32} : (tensor<13x21x3xbf16>) -> tensor<13x21x3xbf16>211  return %0 : tensor<13x21x3xbf16>212}213 214// -----215func.func @test_slice(%arg0: tensor<13x21x3xbf16>) -> tensor<4x11x1xbf16> {216  %0 = tosa.const_shape {values = dense<[4, 11, 1]> : tensor<3xindex>} : () -> !tosa.shape<3>217  %1 = tosa.const_shape {values = dense<[6, 8, 0]> : tensor<3xindex>} : () -> !tosa.shape<3>218  // expected-error@+1 {{'tosa.slice' op illegal: requires [bf16] but not enabled in target}}219  %2 = tosa.slice %arg0, %0, %1 : (tensor<13x21x3xbf16>, !tosa.shape<3>, !tosa.shape<3>) -> tensor<4x11x1xbf16>220  return %2 : tensor<4x11x1xbf16>221}222 223// -----224func.func @test_tile(%arg0: tensor<13x21x3xbf16>) -> tensor<39x21x6xbf16> {225  %cst = tosa.const_shape { values = dense<[3, 1, 2]> : tensor<3xindex> } : () -> !tosa.shape<3>226  // expected-error@+1 {{'tosa.tile' op illegal: requires [bf16] but not enabled in target}}227  %0 = tosa.tile %arg0, %cst: (tensor<13x21x3xbf16>, !tosa.shape<3>) -> tensor<39x21x6xbf16>228  return %0 : tensor<39x21x6xbf16>229}230 231// -----232func.func @test_transpose(%arg0: tensor<13x21x3xbf16>) -> tensor<3x13x21xbf16> {233  // expected-error@+1 {{'tosa.transpose' op illegal: requires [bf16] but not enabled in target}}234  %1 = tosa.transpose %arg0 {perms = array<i32: 2, 0, 1>} : (tensor<13x21x3xbf16>) -> tensor<3x13x21xbf16>235  return %1 : tensor<3x13x21xbf16>236}237 238// -----239func.func @test_gather(%arg0: tensor<13x21x3xbf16>, %arg1: tensor<13x26xi32>) -> tensor<13x26x3xbf16> {240  // expected-error@+1 {{'tosa.gather' op illegal: requires [bf16] but not enabled in target}}241  %0 = tosa.gather %arg0, %arg1 : (tensor<13x21x3xbf16>, tensor<13x26xi32>) -> tensor<13x26x3xbf16>242  return %0 : tensor<13x26x3xbf16>243}244 245// -----246func.func @test_scatter(%arg0: tensor<13x26x3xbf16>, %arg1: tensor<13x26xi32>, %arg2: tensor<13x26x3xbf16>) -> tensor<13x26x3xbf16> {247  // expected-error@+1 {{'tosa.scatter' op illegal: requires [bf16] but not enabled in target}}248  %0 = tosa.scatter %arg0, %arg1, %arg2 : (tensor<13x26x3xbf16>, tensor<13x26xi32>, tensor<13x26x3xbf16>) -> tensor<13x26x3xbf16>249  return %0 : tensor<13x26x3xbf16>250}251 252// -----253func.func @test_resize(%arg0: tensor<1x32x32x8xbf16>) -> tensor<1x64x64x8xbf16> {254  %scale = tosa.const_shape { values = dense<[4, 2, 4, 2]> : tensor<4xindex> } : () -> !tosa.shape<4>255  %offset = tosa.const_shape { values = dense<[-1, -1]> : tensor<2xindex> } : () -> !tosa.shape<2>256  %border = tosa.const_shape { values = dense<[1, 1]> : tensor<2xindex> } : () -> !tosa.shape<2>257  // expected-error@+1 {{'tosa.resize' op illegal: requires [bf16] but not enabled in target}}258  %1 = tosa.resize %arg0, %scale, %offset, %border { mode = BILINEAR } : (tensor<1x32x32x8xbf16>, !tosa.shape<4>, !tosa.shape<2>, !tosa.shape<2>) -> tensor<1x64x64x8xbf16>259  return %1 : tensor<1x64x64x8xbf16>260}261 262// -----263func.func @test_cast_i8_bf16(%arg0: tensor<13x21x3xi8>) -> tensor<13x21x3xbf16> {264  // expected-error@+1 {{'tosa.cast' op illegal: requires [bf16] but not enabled in target}}265  %0 = tosa.cast %arg0 : (tensor<13x21x3xi8>) -> tensor<13x21x3xbf16>266  return %0 : tensor<13x21x3xbf16>267}268 269// -----270func.func @test_cast_bf16_i8(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xi8> {271  // expected-error@+1 {{'tosa.cast' op illegal: requires [bf16] but not enabled in target}}272  %0 = tosa.cast %arg0 : (tensor<13x21x3xbf16>) -> tensor<13x21x3xi8>273  return %0 : tensor<13x21x3xi8>274}275 276// -----277func.func @test_cast_f32_bf16(%arg0: tensor<13x21x3xf32>) -> tensor<13x21x3xbf16> {278  // expected-error@+1 {{'tosa.cast' op illegal: requires [bf16] but not enabled in target}}279  %0 = tosa.cast %arg0 : (tensor<13x21x3xf32>) -> tensor<13x21x3xbf16>280  return %0 : tensor<13x21x3xbf16>281}282 283// -----284func.func @test_fft2d(%arg0: tensor<1x4x8xf32>, %arg1: tensor<1x4x8xf32>) -> (tensor<1x4x8xf32>, tensor<1x4x8xf32>) {285  // expected-error@+1 {{'tosa.fft2d' op illegal: requires [fft] but not enabled in target}}286  %0, %1 = tosa.fft2d %arg0, %arg1 {inverse = false} : (tensor<1x4x8xf32>, tensor<1x4x8xf32>) -> (tensor<1x4x8xf32>, tensor<1x4x8xf32>)287  return %0, %1 : tensor<1x4x8xf32>, tensor<1x4x8xf32>288}289 290// -----291func.func @test_const_i4() -> tensor<3x11x11x3xi4> {292  // expected-error@+1 {{'tosa.const' op illegal: requires [int4] but not enabled in target}}293  %0 = "tosa.const"() {values = dense<0> : tensor<3x11x11x3xi4>} : () -> tensor<3x11x11x3xi4>294  return %0 : tensor<3x11x11x3xi4>295}296 297// -----298func.func @test_const_i48() -> tensor<3x11x11x3xi48> {299  // expected-error@+1 {{'tosa.const' op illegal: requires [int16] but not enabled in target}}300  %0 = "tosa.const"() {values = dense<0> : tensor<3x11x11x3xi48>} : () -> tensor<3x11x11x3xi48>301  return %0 : tensor<3x11x11x3xi48>302}303 304// -----305// CHECK-LABEL: identity306func.func @test_identity(%arg0: tensor<13x21x3xi4>) -> tensor<13x21x3xi4> {307  // expected-error@+1 {{'tosa.identity' op illegal: requires [int4] but not enabled in target}}308  %0 = tosa.identity %arg0 : (tensor<13x21x3xi4>) -> tensor<13x21x3xi4>309  return %0 : tensor<13x21x3xi4>310}311 312// -----313module {314  // expected-error@+1 {{'tosa.variable' op illegal: requires [variable] but not enabled in target}}315  tosa.variable @stored_var = dense<-1> : tensor<2x4x8xi8>316 317  func.func @test_variable_read_type(%arg0: tensor<2x4x8xi8>) -> () {318    // expected-error@+1 {{'tosa.variable_read' op illegal: requires [variable]}}319    %0 = tosa.variable_read @stored_var : tensor<2x4x8xi8>320    return321  }322}323 324// -----325module {326  // expected-error@+1 {{'tosa.variable' op illegal: requires [variable] but not enabled in target}}327  tosa.variable @stored_var = dense<-1> : tensor<2x4x8xi8>328 329  func.func @test_variable_write_type(%arg0: tensor<2x4x8xi8>) -> () {330    // expected-error@+1 {{'tosa.variable_write' op illegal: requires [variable]}}331    tosa.variable_write @stored_var, %arg0 : tensor<2x4x8xi8>332    return333  }334}335 336// -----337func.func @test_cast_bf16_i32(%arg0: tensor<13x21x3xbf16>) -> tensor<13x21x3xi32> {338  // expected-error@+1 {{'tosa.cast' op illegal: requires [bf16] but not enabled in target}}339  %0 = tosa.cast %arg0 : (tensor<13x21x3xbf16>) -> tensor<13x21x3xi32>340  return %0 : tensor<13x21x3xi32>341}342 343// -----344func.func @test_cond_if(%arg0: tensor<f32>, %arg1: tensor<f32>, %arg2: tensor<i1>) -> tensor<f32> {345  // expected-error@+1 {{'tosa.cond_if' op illegal: requires [controlflow]}}346  %0 = tosa.cond_if %arg2 : tensor<i1> -> tensor<f32> {347    %1 = tosa.add %arg0, %arg1 : (tensor<f32>, tensor<f32>) -> tensor<f32>348    tosa.yield %1 : tensor<f32>349  } else {350    %1 = tosa.sub %arg0, %arg1 : (tensor<f32>, tensor<f32>) -> tensor<f32>351    tosa.yield %1 : tensor<f32>352  }353  return %0 : tensor<f32>354}355 356// -----357func.func @test_while_loop(%arg0: tensor<10xi32>, %arg1: tensor<i32>) {358  %0 = "tosa.const"() {values = dense<0> : tensor<i32>} : () -> tensor<i32>359  // expected-error@+1 {{'tosa.while_loop' op illegal: requires [controlflow]}}360  %1:3 = tosa.while_loop (%arg2 = %0, %arg3 = %0, %arg4 = %arg0) : (tensor<i32>, tensor<i32>, tensor<10xi32>) -> (tensor<i32>, tensor<i32>, tensor<10xi32>) {361    %2 = tosa.greater_equal %arg3, %arg1 : (tensor<i32>, tensor<i32>) -> tensor<i1>362    %3 = tosa.logical_not %2 : (tensor<i1>) -> tensor<i1>363    tosa.yield %3 : tensor<i1>364  } do {365  ^bb0(%arg2: tensor<i32>, %arg3: tensor<i32>, %arg4: tensor<10xi32>):366    %2 = "tosa.const"() {values = dense<1> : tensor<i32>} : () -> tensor<i32>367    %3 = tosa.add %arg3, %2 : (tensor<i32>, tensor<i32>) -> tensor<i32>368    %7 = tosa.const_shape {values = dense<[1]> : tensor<1xindex>} : () -> !tosa.shape<1>369    %4 = tosa.reshape %2, %7 : (tensor<i32>, !tosa.shape<1>) -> tensor<1xi32>370    %5 = tosa.add %arg4, %4 : (tensor<10xi32>, tensor<1xi32>) -> tensor<10xi32>371    %6 = tosa.add %arg2, %2 : (tensor<i32>, tensor<i32>) -> tensor<i32>372    tosa.yield %6, %3, %5 : tensor<i32>, tensor<i32>, tensor<10xi32>373  }374  return375}376 377// -----378 379// CHECK-LABEL: test_single_round_rescale380func.func @test_single_round_rescale(%arg0: tensor<13x21x3xi8>) -> tensor<13x21x3xi8> {381  %multiplier = "tosa.const"() {values = dense<1073741824> : tensor<1xi32> } : () -> tensor<1xi32>382  %shift = "tosa.const"() {values = dense<30> : tensor<1xi8> } : () -> tensor<1xi8>383  %input_zp = "tosa.const"() {values = dense<0> : tensor<1xi8>} : () -> tensor<1xi8>384  %output_zp = "tosa.const"() {values = dense<0> : tensor<1xi8>} : () -> tensor<1xi8>385  // CHECK tosa.rescale386  %0 = tosa.rescale %arg0, %multiplier, %shift, %input_zp, %output_zp {rounding_mode = SINGLE_ROUND, per_channel = false, scale32 = true, input_unsigned = false, output_unsigned = false} : (tensor<13x21x3xi8>, tensor<1xi32>, tensor<1xi8>, tensor<1xi8>, tensor<1xi8>) -> tensor<13x21x3xi8>387  return %0 : tensor<13x21x3xi8>388}389 390// -----391 392func.func @test_double_round_rescale(%arg0: tensor<13x21x3xi8>) -> tensor<13x21x3xi8> {393  %multiplier = "tosa.const"() {values = dense<1073741824> : tensor<1xi32> } : () -> tensor<1xi32>394  %shift = "tosa.const"() {values = dense<30> : tensor<1xi8> } : () -> tensor<1xi8>395  %input_zp = "tosa.const"() {values = dense<0> : tensor<1xi8>} : () -> tensor<1xi8>396  %output_zp = "tosa.const"() {values = dense<0> : tensor<1xi8>} : () -> tensor<1xi8>397  // expected-error@+1 {{'tosa.rescale' op failed attribute check: rounding_mode = DOUBLE_ROUND requires extension [doubleround]}}398  %0 = tosa.rescale %arg0, %multiplier, %shift, %input_zp, %output_zp {rounding_mode = DOUBLE_ROUND, per_channel = false, scale32 = true, input_unsigned = false, output_unsigned = false} : (tensor<13x21x3xi8>, tensor<1xi32>, tensor<1xi8>, tensor<1xi8>, tensor<1xi8>) -> tensor<13x21x3xi8>399  return %0 : tensor<13x21x3xi8>400}401 402// -----403 404func.func @test_inexact_round_rescale(%arg0: tensor<13x21x3xi8>) -> tensor<13x21x3xi8> {405  %multiplier = "tosa.const"() {values = dense<1073741824> : tensor<1xi32> } : () -> tensor<1xi32>406  %shift = "tosa.const"() {values = dense<30> : tensor<1xi8> } : () -> tensor<1xi8>407  %input_zp = "tosa.const"() {values = dense<0> : tensor<1xi8>} : () -> tensor<1xi8>408  %output_zp = "tosa.const"() {values = dense<0> : tensor<1xi8>} : () -> tensor<1xi8>409  // expected-error@+1 {{'tosa.rescale' op failed attribute check: rounding_mode = INEXACT_ROUND requires extension [inexactround]}}410  %0 = tosa.rescale %arg0, %multiplier, %shift, %input_zp, %output_zp {rounding_mode = INEXACT_ROUND, per_channel = false, scale32 = true, input_unsigned = false, output_unsigned = false} : (tensor<13x21x3xi8>, tensor<1xi32>, tensor<1xi8>, tensor<1xi8>, tensor<1xi8>) -> tensor<13x21x3xi8>411  return %0 : tensor<13x21x3xi8>412}413 414// -----415 416func.func @test_pad_non_const(%arg0: tensor<13x21x3xi8>, %arg1: tensor<1xi8>) -> tensor<13x22x4xi8> {417  %0 = tosa.const_shape {values = dense<[0, 0, 0, 1, 0, 1]> : tensor<6xindex>} : () -> !tosa.shape<6>418  // expected-error@+1 {{'tosa.pad' op expected compile time resolvable constant, but got variable value for operand #2}}419  %1 = tosa.pad %arg0, %0, %arg1 : (tensor<13x21x3xi8>, !tosa.shape<6>, tensor<1xi8>) -> tensor<13x22x4xi8>420  return %1 : tensor<13x22x4xi8>421}422 423// -----424 425func.func @test_rescale_non_const_multiplier(%arg0: tensor<13x21x3xi32>, %multiplier: tensor<1xi32>) -> tensor<13x21x3xi32> {426  %zps = "tosa.const"() {values = dense<0> : tensor<1xi32> } : () -> tensor<1xi32>427  %shift = "tosa.const"() {values = dense<30> : tensor<1xi8> } : () -> tensor<1xi8>428  // expected-error@+1 {{'tosa.rescale' op expected compile time resolvable constant, but got variable value for operand #1}}429  %0 = tosa.rescale %arg0, %multiplier, %shift, %zps, %zps {rounding_mode = SINGLE_ROUND, input_zp = 0 : i32, output_zp = 0 : i32, per_channel = false, scale32 = true, input_unsigned = false, output_unsigned = false} : (tensor<13x21x3xi32>, tensor<1xi32>, tensor<1xi8>, tensor<1xi32>, tensor<1xi32>) -> tensor<13x21x3xi32>430  return %0 : tensor<13x21x3xi32>431}432 433// -----434 435func.func @test_rescale_non_const_shift(%arg0: tensor<13x21x3xi32>, %shift: tensor<1xi8>) -> tensor<13x21x3xi32> {436  %zps = "tosa.const"() {values = dense<0> : tensor<1xi32> } : () -> tensor<1xi32>437  %multiplier = "tosa.const"() {values = dense<1073741824> : tensor<1xi32> } : () -> tensor<1xi32>438  // expected-error@+1 {{'tosa.rescale' op expected compile time resolvable constant, but got variable value for operand #2}}439  %0 = tosa.rescale %arg0, %multiplier, %shift, %zps, %zps {rounding_mode = SINGLE_ROUND, input_zp = 0 : i32, output_zp = 0 : i32, per_channel = false, scale32 = true, input_unsigned = false, output_unsigned = false} : (tensor<13x21x3xi32>, tensor<1xi32>, tensor<1xi8>, tensor<1xi32>, tensor<1xi32>) -> tensor<13x21x3xi32>440  return %0 : tensor<13x21x3xi32>441}442 443// -----444 445func.func @test_conv2d_non_const_input_zp(%arg0: tensor<1x4x4x4xi8>, %arg1: tensor<8x1x1x4xi8>, %arg2: tensor<8xi32>, %arg3: tensor<1xi8>) -> tensor<1x4x4x8xi32> {446  %weight_zp = "tosa.const"() {values = dense<0> : tensor<1xi8> } : () -> tensor<1xi8>447  // expected-error@+1 {{'tosa.conv2d' op expected compile time resolvable constant, but got variable value for operand #3}}448  %0 = tosa.conv2d %arg0, %arg1, %arg2, %arg3, %weight_zp {acc_type = i32, dilation = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>, local_bound = true} : (tensor<1x4x4x4xi8>, tensor<8x1x1x4xi8>, tensor<8xi32>, tensor<1xi8>, tensor<1xi8>) -> tensor<1x4x4x8xi32>449  return %0 : tensor<1x4x4x8xi32>450}451 452// -----453 454func.func @test_conv3d_non_const_weight_zp(%arg0: tensor<1x4x8x21x17xi8>, %arg1: tensor<34x1x1x1x17xi8>, %arg2: tensor<34xi32>, %arg3: tensor<1xi8>) -> tensor<1x4x8x21x34xi32> {455  %input_zp = "tosa.const"() {values = dense<0> : tensor<1xi8> } : () -> tensor<1xi8>456  // expected-error@+1 {{'tosa.conv3d' op expected compile time resolvable constant, but got variable value for operand #4}}457  %0 = tosa.conv3d %arg0, %arg1, %arg2, %input_zp, %arg3 {acc_type = i32, dilation = array<i64: 1, 1, 1>, pad = array<i64: 0, 0, 0, 0, 0, 0>, stride = array<i64: 1, 1, 1>} : (tensor<1x4x8x21x17xi8>, tensor<34x1x1x1x17xi8>, tensor<34xi32>, tensor<1xi8>, tensor<1xi8>) -> tensor<1x4x8x21x34xi32>458  return %0 : tensor<1x4x8x21x34xi32>459}460 461// -----462 463func.func @test_depthwise_conv2d_non_const_input_zp(%arg0: tensor<1x4x4x4xi8>, %arg1: tensor<1x1x4x2xi8>, %arg2: tensor<8xi32>, %arg3: tensor<1xi8>) -> tensor<1x4x4x8xi32> {464  %weight_zp = "tosa.const"() {values = dense<0> : tensor<1xi8> } : () -> tensor<1xi8>465  // expected-error@+1 {{'tosa.depthwise_conv2d' op expected compile time resolvable constant, but got variable value for operand #3}}466  %0 = tosa.depthwise_conv2d %arg0, %arg1, %arg2, %arg3, %weight_zp {acc_type = i32, dilation = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>} : (tensor<1x4x4x4xi8>, tensor<1x1x4x2xi8>, tensor<8xi32>, tensor<1xi8>, tensor<1xi8>) -> tensor<1x4x4x8xi32>467  return %0 : tensor<1x4x4x8xi32>468}469 470// -----471 472func.func @test_transpose_conv2d_non_const_weight_zp(%arg0: tensor<1x4x4x4xi8>, %arg1: tensor<1x1x4x2xi8>, %arg2: tensor<8xi32>, %arg3: tensor<1xi8>) -> tensor<1x4x7x8xi32> {473  %input_zp = "tosa.const"() {values = dense<0> : tensor<1xi8> } : () -> tensor<1xi8>474  // expected-error@+1 {{'tosa.transpose_conv2d' op expected compile time resolvable constant, but got variable value for operand #4}}475  %0 = tosa.transpose_conv2d %arg0, %arg1, %arg2, %input_zp, %arg3 {acc_type = i32, out_pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>} : (tensor<1x4x4x4xi8>, tensor<1x1x4x2xi8>, tensor<8xi32>, tensor<1xi8>, tensor<1xi8>) -> tensor<1x4x7x8xi32>476  return %0 : tensor<1x4x7x8xi32>477}478 479// -----480 481func.func @test_matmul_non_const_a_zp(%arg0: tensor<1x14x19xf32>, %arg1: tensor<1x19x28xf32>, %a_zp: tensor<1xf32>, %b_zp: tensor<1xf32>) -> tensor<1x14x28xf32> {482  // expected-error@+1 {{'tosa.matmul' op expected compile time resolvable constant, but got variable value for operand #2}}483  %0 = tosa.matmul %arg0, %arg1, %a_zp, %b_zp : (tensor<1x14x19xf32>, tensor<1x19x28xf32>, tensor<1xf32>, tensor<1xf32>)  -> tensor<1x14x28xf32>484  return %0 : tensor<1x14x28xf32>485}486 487// -----488 489func.func @test_matmul_non_const_b_zp(%arg0: tensor<1x14x19xf32>, %arg1: tensor<1x19x28xf32>, %b_zp: tensor<1xf32>) -> tensor<1x14x28xf32> {490  %a_zp = "tosa.const"() {values = dense<0.0> : tensor<1xf32> } : () -> tensor<1xf32>491  // expected-error@+1 {{'tosa.matmul' op expected compile time resolvable constant, but got variable value for operand #3}}492  %0 = tosa.matmul %arg0, %arg1, %a_zp, %b_zp : (tensor<1x14x19xf32>, tensor<1x19x28xf32>, tensor<1xf32>, tensor<1xf32>)  -> tensor<1x14x28xf32>493  return %0 : tensor<1x14x28xf32>494}495 496// -----497 498func.func @test_mul_non_const(%arg0: tensor<13x21x3xi8>, %arg1: tensor<13x1x3xi8>, %shift: tensor<1xi8>) -> tensor<13x21x3xi32> {499  // expected-error@+1 {{'tosa.mul' op expected compile time resolvable constant, but got variable value for operand #2}}500  %0 = tosa.mul %arg0, %arg1, %shift : (tensor<13x21x3xi8>, tensor<13x1x3xi8>, tensor<1xi8>) -> tensor<13x21x3xi32>501  return %0 : tensor<13x21x3xi32>502}503 504// -----505 506func.func @test_table_non_const(%arg0 : tensor<4x5xi8>, %arg1 : tensor<256xi8>) -> () {507  // expected-error@+1 {{'tosa.table' op expected compile time resolvable constant, but got variable value for operand #1}}508  %0 = tosa.table %arg0, %arg1 : (tensor<4x5xi8>, tensor<256xi8>) -> tensor<4x5xi8>509  return510}511 512// -----513 514func.func @test_rescale_non_const_input_zp(%arg0: tensor<13x21x3xi32>, %input_zp: tensor<1xi32>) -> tensor<13x21x3xi32> {515  %shift = "tosa.const"() {values = dense<30> : tensor<1xi8> } : () -> tensor<1xi8>516  %multiplier = "tosa.const"() {values = dense<1073741824> : tensor<1xi32> } : () -> tensor<1xi32>517  %output_zp = "tosa.const"() <{values = dense<0> : tensor<1xi32>}> : () -> tensor<1xi32>518  // expected-error@+1 {{'tosa.rescale' op expected compile time resolvable constant, but got variable value for operand #3}}519  %0 = tosa.rescale %arg0, %multiplier, %shift, %input_zp, %output_zp {scale32 = true, rounding_mode = SINGLE_ROUND, per_channel = false, input_unsigned = false, output_unsigned = false} : (tensor<13x21x3xi32>, tensor<1xi32>, tensor<1xi8>, tensor<1xi32>, tensor<1xi32>) -> tensor<13x21x3xi32>520  return %0 : tensor<13x21x3xi32>521}522 523// -----524 525func.func @test_negate_non_const_input1_zp(%arg0: tensor<1xf32>, %input_zp: tensor<1xf32>) -> tensor<1xf32> {526  %output_zp = "tosa.const"() {values = dense<0.0> : tensor<1xf32>} : () -> tensor<1xf32>527  // expected-error@+1 {{'tosa.negate' op expected compile time resolvable constant, but got variable value for operand #1}}528  %0 = tosa.negate %arg0, %input_zp, %output_zp : (tensor<1xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>529  return %0 : tensor<1xf32>530}531 532// -----533 534func.func @test_avg_pool2d_non_const_output_zp(%arg0: tensor<1x32x32x8xf32>, %output_zp: tensor<1xf32>) -> tensor<1x32x32x8xf32> {535  %input_zp = "tosa.const"() {values = dense<0.0> : tensor<1xf32>} : () -> tensor<1xf32>536  // expected-error@+1 {{'tosa.avg_pool2d' op expected compile time resolvable constant, but got variable value for operand #2}}537  %0 = "tosa.avg_pool2d"(%arg0, %input_zp, %output_zp) {kernel = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>, acc_type = f32} :538         (tensor<1x32x32x8xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<1x32x32x8xf32>539  return %0 : tensor<1x32x32x8xf32>540}541 542// -----543 544func.func @test_matmul_t_block_scaled(%arg0: tensor<4x8x32xf8E4M3FN>, %arg1: tensor<4x8x1xf8E8M0FNU>, %arg2: tensor<4x16x32xf8E4M3FN>, %arg3: tensor<4x16x1xf8E8M0FNU>) -> tensor<4x8x16xf32> {545  // expected-error@+1 {{'tosa.matmul_t_block_scaled' op illegal: requires [mxfp] but not enabled in target}}546  %0 = tosa.matmul_t_block_scaled %arg0, %arg1, %arg2, %arg3 {block_size = #tosa.block_size<BLOCK_SIZE_32>} : (tensor<4x8x32xf8E4M3FN>, tensor<4x8x1xf8E8M0FNU>, tensor<4x16x32xf8E4M3FN>, tensor<4x16x1xf8E8M0FNU>) -> tensor<4x8x16xf32>547  return %0 : tensor<4x8x16xf32>548}549 550// -----551 552func.func @test_argmax_int64(%arg0: tensor<1x13x13x5xf32>) -> tensor<1x13x13xi64> {553  // expected-error@+1 {{'tosa.argmax' op illegal: requires [int64] but not enabled in target}}554  %0 = tosa.argmax %arg0 {axis = 3 : i32} : (tensor<1x13x13x5xf32>) -> tensor<1x13x13xi64>555  return %0 : tensor<1x13x13xi64>556}557 558// -----559func.func @test_const_fp6e3m2(%arg0 : index) -> tensor<4xf6E3M2FN> {560  // expected-error@+1 {{'tosa.const' op illegal: requires [mxfp] but not enabled in target}}561    %0 = "tosa.const"() {values = dense<[0.0, 0.0, 0.0, 0.0]> : tensor<4xf6E3M2FN>} : () -> tensor<4xf6E3M2FN>562    return %0 : tensor<4xf6E3M2FN>563}564 565// -----566func.func @test_cast_f4e2m1(%arg0: tensor<13x21x3xf4E2M1FN>) -> tensor<13x21x3xbf16> {567  // expected-error@+1 {{'tosa.cast' op illegal: requires all of [bf16, mxfp] but not enabled in target}}568  %0 = tosa.cast %arg0 : (tensor<13x21x3xf4E2M1FN>) -> tensor<13x21x3xbf16>569  return %0 : tensor<13x21x3xbf16>570}571 572// -----573 574func.func @test_cast_from_block_scaled_static(%arg0: tensor<4x32xf8E5M2>, %arg1: tensor<4x1xf8E8M0FNU>) -> tensor<4x32xf32> {575  // expected-error@+1 {{'tosa.cast_from_block_scaled' op illegal: requires [mxfp] but not enabled in target}}576  %0 = tosa.cast_from_block_scaled %arg0, %arg1 {block_size = #tosa.block_size<BLOCK_SIZE_32> : i32} : (tensor<4x32xf8E5M2>, tensor<4x1xf8E8M0FNU>) -> tensor<4x32xf32>577  return %0 : tensor<4x32xf32>578}579 580// -----581 582func.func @test_cast_to_block_scaled_static(%arg0: tensor<4x32xf32>) -> (tensor<4x32xf6E3M2FN>, tensor<4x1xf8E8M0FNU>) {583  // expected-error@+1 {{'tosa.cast_to_block_scaled' op illegal: requires [mxfp] but not enabled in target}}584  %0:2 = tosa.cast_to_block_scaled %arg0 {block_size = #tosa.block_size<BLOCK_SIZE_32>} : (tensor<4x32xf32>) -> (tensor<4x32xf6E3M2FN>, tensor<4x1xf8E8M0FNU>)585  return %0#0, %0#1 : tensor<4x32xf6E3M2FN>, tensor<4x1xf8E8M0FNU>586}587