@@ -1144,6 +1144,79 @@ func.func @test_non_tosa_ops() {
1144
1144
1145
1145
// -----
1146
1146
1147
+ func.func @test_pad_rank0_pad_const (%arg0: tensor <13 x21 x3 xf8 E4 M3 FN>) -> tensor <13 x21 x3 xf8 E5 M2 > {
1148
+ %padding = tosa.const_shape {values = dense <0 > : tensor <6 xindex >} : () -> !tosa.shape <6 >
1149
+ %cst = " tosa.const" () { values = dense <-0.0 > : tensor <f8E4M3FN > } : () -> tensor <f8E4M3FN >
1150
+ // expected-error@+1 {{'tosa.pad' op operand #2 must be tosa-conformant scalar tensor of number values, but got 'tensor<f8E4M3FN>'}}
1151
+ %0 = tosa.pad %arg0 , %padding , %cst : (tensor <13 x21 x3 xf8 E4 M3 FN>, !tosa.shape <6 >, tensor <f8E4M3FN >) -> tensor <13 x21 x3 xf8 E5 M2 >
1152
+ return %0 : tensor <13 x21 x3 xf8 E5 M2 >
1153
+ }
1154
+
1155
+ // -----
1156
+
1157
+ func.func @test_conv2d_rank0_zp (%arg0: tensor <1 x29 x29 x4 xi8 >, %arg1: tensor <16 x3 x3 x4 xi8 >, %arg2: tensor <16 xi8 >) -> tensor <1 x27 x27 x16 xi32 > {
1158
+ %input_zp = " tosa.const" () <{values = dense <0 > : tensor <i8 >}> : () -> tensor <i8 >
1159
+ %weight_zp = " tosa.const" () <{values = dense <0 > : tensor <1 xi8 >}> : () -> tensor <1 xi8 >
1160
+ // expected-error@+1 {{'tosa.conv2d' op operand #3 must be tosa-conformant scalar tensor of unsigned integer or signless integer or floating-point values, but got 'tensor<i8>'}}
1161
+ %0 = tosa.conv2d %arg0 , %arg1 , %arg2 , %input_zp , %weight_zp {acc_type = i32 , dilation = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 1 >}
1162
+ : (tensor <1 x29 x29 x4 xi8 >, tensor <16 x3 x3 x4 xi8 >, tensor <16 xi8 >, tensor <i8 >, tensor <1 xi8 >) -> tensor <1 x27 x27 x16 xi32 >
1163
+ return %0 : tensor <1 x27 x27 x16 xi32 >
1164
+ }
1165
+
1166
+ // -----
1167
+
1168
+ // CHECK-LABEL: test_negate_same_element_type
1169
+ func.func @test_negate_same_element_type (%arg0: tensor <8 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xf32 >) -> tensor <8 x8 xf32 > {
1170
+ // expected-error@+1 {{'tosa.negate' op expect input and output to have same element type, got 'f32' and 'i32'}}
1171
+ %0 = tosa.negate %arg0 , %arg1 , %arg2 : (tensor <8 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <8 x8 xi32 >
1172
+ return %0 : tensor <8 x8 xi32 >
1173
+ }
1174
+
1175
+ // -----
1176
+
1177
+ // CHECK-LABEL: test_negate_same_shape
1178
+ func.func @test_negate_same_shape (%arg0: tensor <8 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xf32 >) -> tensor <8 x8 xf32 > {
1179
+ // expected-error@+1 {{'tosa.negate' op requires the same shape for input1 and output}}
1180
+ %0 = tosa.negate %arg0 , %arg1 , %arg2 : (tensor <8 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <8 x6 xf32 >
1181
+ return %0 : tensor <8 x6 xf32 >
1182
+ }
1183
+
1184
+ // -----
1185
+
1186
+ // CHECK-LABEL: test_negate_input_zp_same_element_type
1187
+ func.func @test_negate_input_zp_same_element_type (%arg0: tensor <8 x8 xf32 >, %arg1: tensor <1 xi32 >, %arg2: tensor <1 xf32 >) -> tensor <8 x8 xf32 > {
1188
+ // expected-error@+1 {{'tosa.negate' op expect both input1 and its zero point are the same element type, got 'f32' and 'i32'}}
1189
+ %0 = tosa.negate %arg0 , %arg1 , %arg2 : (tensor <8 x8 xf32 >, tensor <1 xi32 >, tensor <1 xf32 >) -> tensor <8 x8 xf32 >
1190
+ return %0 : tensor <8 x8 xf32 >
1191
+ }
1192
+
1193
+ // -----
1194
+
1195
+ // CHECK-LABEL: test_negate_output_zp_same_element_type
1196
+ func.func @test_negate_output_zp_same_element_type (%arg0: tensor <8 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xi32 >) -> tensor <8 x8 xf32 > {
1197
+ // expected-error@+1 {{'tosa.negate' op expect both output and its zero point are the same element type, got 'f32' and 'i32'}}
1198
+ %0 = tosa.negate %arg0 , %arg1 , %arg2 : (tensor <8 x8 xf32 >, tensor <1 xf32 >, tensor <1 xi32 >) -> tensor <8 x8 xf32 >
1199
+ return %0 : tensor <8 x8 xf32 >
1200
+ }
1201
+
1202
+ // -----
1203
+
1204
+ func.func @test_sub_with_unequal_operand_ranks (%arg0: tensor <1 x21 x3 xf32 >, %arg1: tensor <1 x13 x21 x3 xf32 >) -> tensor <1 x13 x21 x3 xf32 > {
1205
+ // expected-error@+1 {{'tosa.sub' op operands don't have matching ranks}}
1206
+ %0 = tosa.sub %arg0 , %arg1 : (tensor <1 x21 x3 xf32 >, tensor <1 x13 x21 x3 xf32 >) -> tensor <1 x13 x21 x3 xf32 >
1207
+ return %0 : tensor <1 x13 x21 x3 xf32 >
1208
+ }
1209
+
1210
+ // -----
1211
+
1212
+ func.func @test_sub_with_unequal_result_ranks (%arg0: tensor <1 x21 x3 xf32 >, %arg1: tensor <13 x21 x3 xf32 >) -> tensor <1 x13 x21 x3 xf32 > {
1213
+ // expected-error@+1 {{'tosa.sub' op result type has different rank than operands}}
1214
+ %0 = tosa.sub %arg0 , %arg1 : (tensor <1 x21 x3 xf32 >, tensor <13 x21 x3 xf32 >) -> tensor <1 x13 x21 x3 xf32 >
1215
+ return %0 : tensor <1 x13 x21 x3 xf32 >
1216
+ }
1217
+
1218
+ // -----
1219
+
1147
1220
// expected-error@+1 {{invalid rank (must be >= 0): -1}}
1148
1221
func.func @test_shape_type (%arg0: !tosa.shape <-1 >) -> !tosa.shape <-1 > {
1149
1222
return %arg0 : !tosa.shape <-1 >
0 commit comments