brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.8 KiB · 7bb50f3 Raw
327 lines · plain
1// RUN: mlir-opt %s -split-input-file -verify-diagnostics2 3func.func @dcast_invalid_input(%arg0: f32) {4  // expected-error@+1 {{operand #0 must be scalar or tensor of quantized type}}5  %0 = quant.dcast %arg0 : f32 to f326  return7}8 9// -----10 11!qalias = !quant.uniform<i8:f32, 1.0>12func.func @dcast_invalid_result(%arg0: !qalias) {13  // expected-error@+1 {{result #0 must be scalar or tensor of floating-point}}14  %0 = quant.dcast %arg0 : !qalias to !qalias15  return16}17 18// -----19 20!qalias = !quant.uniform<i8:f32, 1.0>21func.func @dcast_mismatch_scalar_tensor(%arg0: !qalias) {22  // expected-error@+1 {{input and result are both scalars or both tensors with matching shape}}23  %0 = quant.dcast %arg0 : !qalias to tensor<f32>24  return25}26 27// -----28 29!qalias = !quant.uniform<i8:f32, 1.0>30func.func @dcast_mismatch_ranked_unranked_tensor(%arg0: tensor<!qalias>) {31  // expected-error@+1 {{input and result are both scalars or both tensors with matching shape}}32  %0 = quant.dcast %arg0 : tensor<!qalias> to tensor<*xf32>33  return34}35 36// -----37 38!qalias = !quant.uniform<i8:f32, 1.0>39func.func @dcast_mismatch_static_dynamic_tensor(%arg0: tensor<2x3x!qalias>) {40  // expected-error@+1 {{input and result are both scalars or both tensors with matching shape}}41  %0 = quant.dcast %arg0 : tensor<2x3x!qalias> to tensor<?x3xf32>42  return43}44 45// -----46 47!qalias = !quant.uniform<i8:f32, 1.0>48func.func @dcast_float_type_mismatch(%arg0: !qalias) {49  // expected-error@+1 {{expressed type in quantized type expected to match float type}}50  %0 = quant.dcast %arg0 : !qalias to f6451  return52}53 54// -----55 56!qalias = !quant.uniform<i8:f32:2, {1.0, 2.0}>57func.func @dcast_per_axis_scalar(%arg0: !qalias) {58  // expected-error@+1 {{scalar types may not use per-axis quantization}}59  %0 = quant.dcast %arg0 : !qalias to f3260  return61}62 63// -----64 65!qalias = !quant.uniform<i8:f32:2, {1.0, 2.0}>66func.func @dcast_per_axis_invalid_rank(%arg0: tensor<2x3x!qalias>) {67  // expected-error@+1 {{quantized dimension must be less than tensor rank}}68  %0 = quant.dcast %arg0 : tensor<2x3x!qalias> to tensor<2x3xf32>69  return70}71 72// -----73 74!qalias = !quant.uniform<i8:f32:2, {1.0, 2.0, 3.0}>75func.func @dcast_per_axis_invalid_rank(%arg0: tensor<2x3x4x!qalias>) {76  // expected-error@+1 {{quantized dimension size does not match number of scales}}77  %0 = quant.dcast %arg0 : tensor<2x3x4x!qalias> to tensor<2x3x4xf32>78  return79}80 81// -----82 83func.func @qcast_invalid_input(%arg0: f32) {84  // expected-error@+1 {{result #0 must be scalar or tensor of quantized type}}85  %0 = quant.qcast %arg0 : f32 to f3286  return87}88 89// -----90 91!qalias = !quant.uniform<i8:f32, 1.0>92func.func @qcast_invalid_result(%arg0: !qalias) {93  // expected-error@+1 {{operand #0 must be scalar or tensor of floating-point}}94  %0 = quant.qcast %arg0 : !qalias to !qalias95  return96}97 98// -----99 100!qalias = !quant.uniform<i8:f32, 1.0>101func.func @qcast_mismatch_scalar_tensor(%arg0: tensor<f32>) {102  // expected-error@+1 {{input and result are both scalars or both tensors with matching shape}}103  %0 = quant.qcast %arg0 : tensor<f32> to !qalias104  return105}106 107// -----108 109!qalias = !quant.uniform<i8:f32, 1.0>110func.func @qcast_mismatch_ranked_unranked_tensor(%arg0: tensor<f32>) {111  // expected-error@+1 {{input and result are both scalars or both tensors with matching shape}}112  %0 = quant.qcast %arg0 : tensor<f32> to tensor<*x!qalias>113  return114}115 116// -----117 118!qalias = !quant.uniform<i8:f32, 1.0>119func.func @qcast_mismatch_static_dynamic_tensor(%arg0: tensor<2x3xf32>) {120  // expected-error@+1 {{input and result are both scalars or both tensors with matching shape}}121  %0 = quant.qcast %arg0 : tensor<2x3xf32> to tensor<?x3x!qalias>122  return123}124 125// -----126 127!qalias = !quant.uniform<i8:f32, 1.0>128func.func @qcast_float_type_mismatch(%arg0: f64) {129  // expected-error@+1 {{expressed type in quantized type expected to match float type}}130  %0 = quant.qcast %arg0 : f64 to !qalias131  return132}133 134// -----135 136!qalias = !quant.uniform<i8:f32:2, {1.0, 2.0}>137func.func @qcast_per_axis_scalar(%arg0: f32) {138  // expected-error@+1 {{scalar types may not use per-axis quantization}}139  %0 = quant.qcast %arg0 : f32 to !qalias140  return141}142 143// -----144 145!qalias = !quant.uniform<i8:f32:2, {1.0, 2.0}>146func.func @qcast_per_axis_invalid_rank(%arg0: tensor<2x3xf32>) {147  // expected-error@+1 {{quantized dimension must be less than tensor rank}}148  %0 = quant.qcast %arg0 : tensor<2x3xf32> to tensor<2x3x!qalias>149  return150}151 152// -----153 154!qalias = !quant.uniform<i8:f32:2, {1.0, 2.0, 3.0}>155func.func @qcast_per_axis_invalid_rank(%arg0: tensor<2x3x4xf32>) {156  // expected-error@+1 {{quantized dimension size does not match number of scales}}157  %0 = quant.qcast %arg0 : tensor<2x3x4xf32> to tensor<2x3x4x!qalias>158  return159}160 161// -----162 163!qalias = !quant.uniform<i8:f32, 1.0>164func.func @scast_invalid_input(%arg0: si32) {165  // expected-error@+1 {{operand #0 must be scalar or tensor of signless integer or quantized type}}166  %0 = quant.scast %arg0 : si32 to !qalias167  return168}169 170// -----171 172!qalias = !quant.uniform<i8:f32, 1.0>173func.func @scast_invalid_result(%arg0: !qalias) {174  // expected-error@+1 {{result #0 must be scalar or tensor of signless integer or quantized type}}175  %0 = quant.scast %arg0 : !qalias to si32176  return177}178 179// -----180 181func.func @scast_both_integers(%arg0: i8) {182  // expected-error@+1 {{input must be integer and result must be quantized, or vice versa}}183  %0 = quant.scast %arg0 : i8 to i8184  return185}186 187// -----188 189!qalias = !quant.uniform<i8:f32, 1.0>190func.func @scast_both_quantized(%arg0: !qalias) {191  // expected-error@+1 {{input must be integer and result must be quantized, or vice versa}}192  %0 = quant.scast %arg0 : !qalias to !qalias193  return194}195 196// -----197 198!qalias = !quant.uniform<i8:f32, 1.0>199func.func @scast_mismatch_scalar_tensor(%arg0: tensor<i8>) {200  // expected-error@+1 {{input and result are both scalars or both tensors with matching shape}}201  %0 = quant.scast %arg0 : tensor<i8> to !qalias202  return203}204 205// -----206 207!qalias = !quant.uniform<i8:f32, 1.0>208func.func @scast_mismatch_ranked_unranked_tensor(%arg0: tensor<i8>) {209  // expected-error@+1 {{input and result are both scalars or both tensors with matching shape}}210  %0 = quant.scast %arg0 : tensor<i8> to tensor<*x!qalias>211  return212}213 214// -----215 216!qalias = !quant.uniform<i8:f32, 1.0>217func.func @scast_mismatch_static_dynamic_tensor(%arg0: tensor<2x3xi8>) {218  // expected-error@+1 {{input and result are both scalars or both tensors with matching shape}}219  %0 = quant.scast %arg0 : tensor<2x3xi8> to tensor<?x3x!qalias>220  return221}222 223// -----224 225!qalias = !quant.uniform<i8:f32, 1.0>226func.func @qcast_integer_type_mismatch(%arg0: i32) {227  // expected-error@+1 {{storage type in quantized type expected to match integer type}}228  %0 = quant.scast %arg0 : i32 to !qalias229  return230}231 232// -----233 234!qalias = !quant.uniform<i8:f32:2, {1.0, 2.0}>235func.func @scast_per_axis_scalar(%arg0: i8) {236  // expected-error@+1 {{scalar types may not use per-axis quantization}}237  %0 = quant.scast %arg0 : i8 to !qalias238  return239}240 241// -----242 243!qalias = !quant.uniform<i8:f32:2, {1.0, 2.0}>244func.func @scast_per_axis_invalid_rank(%arg0: tensor<2x3xi8>) {245  // expected-error@+1 {{quantized dimension must be less than tensor rank}}246  %0 = quant.scast %arg0 : tensor<2x3xi8> to tensor<2x3x!qalias>247  return248}249 250// -----251 252!qalias = !quant.uniform<i8:f32:2, {1.0, 2.0, 3.0}>253func.func @scast_per_axis_invalid_rank(%arg0: tensor<2x3x4xi8>) {254  // expected-error@+1 {{quantized dimension size does not match number of scales}}255  %0 = quant.scast %arg0 : tensor<2x3x4xi8> to tensor<2x3x4x!qalias>256  return257}258 259// -----260 261!qalias = !quant.uniform<u8:f32:{0:1,1:2},262    {{2.000000e+02:120,9.987200e-01:127}, {2.000000e+02,9.987200e-01}}>263func.func @qcast_sub_channel_scalar(%arg0: f32) {264  // expected-error@+1 {{scalar types may not use sub-channel quantization}}265  %0 = quant.qcast %arg0 : f32 to !qalias266  return267}268 269// -----270 271!qalias = !quant.uniform<u8:f32:{0:1,1:2},272    {{2.000000e+02:120,9.987200e-01:127}, {2.000000e+02,9.987200e-01}}>273func.func @qcast_sub_channel_unranked(%arg0: tensor<*xf32>) {274  // expected-error@+1 {{tensor containing the sub-channel quantized type must be ranked}}275  %0 = quant.qcast %arg0 : tensor<*xf32> to tensor<*x!qalias>276  return277}278 279// -----280 281!qalias = !quant.uniform<u8:f32:{0:1,3:2},282    {{2.000000e+02:120,9.987200e-01:127}, {2.000000e+02,9.987200e-01}}>283func.func @qcast_sub_channel_invalid_quantized_dimension(%arg0: tensor<2x4xf32>) {284  // expected-error@+1 {{quantized dimension 3 must be less than tensor rank 2}}285  %0 = quant.qcast %arg0 : tensor<2x4xf32> to tensor<2x4x!qalias>286  return287}288 289// -----290 291!qalias = !quant.uniform<u8:f32:{0:1,1:3},292    {{2.000000e+02:120,9.987200e-01:127}, {2.000000e+02,9.987200e-01}}>293func.func @qcast_sub_channel_invalid_tensor_dim_size(%arg0: tensor<2x4xf32>) {294  // expected-error@+1 {{tensor dimension size 4 at axis 1 must be divisible by the corresponding block size 3}}295  %0 = quant.qcast %arg0 : tensor<2x4xf32> to tensor<2x4x!qalias>296  return297}298 299// -----300 301!qalias = !quant.uniform<u8:f32:{1:2},302    {{2.000000e+02:120,9.987200e-01:127}, {2.000000e+02,9.987200e-01}}>303func.func @qcast_sub_channel_invalid_zero_tensor_dim_size(%arg0: tensor<0x4xf32>) {304  // expected-error@+1 {{tensor dimension size of zero is not allowed with sub-channel quantization}}305  %0 = quant.qcast %arg0 : tensor<0x4xf32> to tensor<0x4x!qalias>306  return307}308 309// -----310 311!qalias = !quant.uniform<u8:f32:{0:1,1:2},312    {{2.000000e+02:120}, {2.000000e+02}}>313func.func @qcast_sub_channel_invalid_scale_dim_size(%arg0: tensor<2x4xf32>) {314  // expected-error@+1 {{dimension size 2 of scales tensor at axis 1 should match (tensor dimension at axis / block sizes at axis) = 2}}315  %0 = quant.qcast %arg0 : tensor<2x4xf32> to tensor<2x4x!qalias>316  return317}318 319// -----320 321!qalias = !quant.uniform<u8:f32:{},{{{2.000000e+02:120}}}>322func.func @qcast_sub_channel_invalid_scale_dim_size(%arg0: tensor<?x?xf32>) {323  // expected-error@+1 {{Rank of scales 3 must match the rank of the tensor 2}}324  %0 = quant.qcast %arg0 : tensor<?x?xf32> to tensor<?x?x!qalias>325  return326}327