@@ -1171,3 +1171,75 @@ func.func @broadcast_resize_bilinear_i8(%arg0 : tensor<3x1x1x7xi8>) -> tensor<3x
1171
1171
1172
1172
return %resize : tensor <3 x4 x5 x7 xi32 >
1173
1173
}
1174
+
1175
+ // -----
1176
+
1177
+ func.func @test_conv2d_invalid_padding (%arg0: tensor <1 x4 x4 x4 xf32 >, %arg1: tensor <8 x1 x1 x4 xf32 >, %arg2: tensor <8 xf32 >, %arg3: tensor <1 xf32 >, %arg4: tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 > {
1178
+ // expected-error@+1 {{'tosa.conv2d' op expect all padding values to be >= 0, got 0, 0, -1, 0}}
1179
+ %0 = tosa.conv2d %arg0 , %arg1 , %arg2 , %arg3 , %arg4 {acc_type = f32 , dilation = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , -1 , 0 >, stride = array<i64 : 1 , 1 >, local_bound = true }
1180
+ : (tensor <1 x4 x4 x4 xf32 >, tensor <8 x1 x1 x4 xf32 >, tensor <8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 >
1181
+ return %0 : tensor <1 x4 x4 x8 xf32 >
1182
+ }
1183
+
1184
+ // -----
1185
+
1186
+ func.func @test_conv2d_invalid_stride (%arg0: tensor <1 x4 x4 x4 xf32 >, %arg1: tensor <8 x1 x1 x4 xf32 >, %arg2: tensor <8 xf32 >, %arg3: tensor <1 xf32 >, %arg4: tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 > {
1187
+ // expected-error@+1 {{'tosa.conv2d' op expect all stride values to be >= 1, got 0, 1}}
1188
+ %0 = tosa.conv2d %arg0 , %arg1 , %arg2 , %arg3 , %arg4 {acc_type = f32 , dilation = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 0 , 1 >, local_bound = true }
1189
+ : (tensor <1 x4 x4 x4 xf32 >, tensor <8 x1 x1 x4 xf32 >, tensor <8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 >
1190
+ return %0 : tensor <1 x4 x4 x8 xf32 >
1191
+ }
1192
+
1193
+ // -----
1194
+
1195
+ func.func @test_conv2d_invalid_dilation (%arg0: tensor <1 x4 x4 x4 xf32 >, %arg1: tensor <8 x1 x1 x4 xf32 >, %arg2: tensor <8 xf32 >, %arg3: tensor <1 xf32 >, %arg4: tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 > {
1196
+ // expected-error@+1 {{'tosa.conv2d' op expect all dilation values to be >= 1, got 1, 0}}
1197
+ %0 = tosa.conv2d %arg0 , %arg1 , %arg2 , %arg3 , %arg4 {acc_type = f32 , dilation = array<i64 : 1 , 0 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 1 >, local_bound = true }
1198
+ : (tensor <1 x4 x4 x4 xf32 >, tensor <8 x1 x1 x4 xf32 >, tensor <8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 >
1199
+ return %0 : tensor <1 x4 x4 x8 xf32 >
1200
+ }
1201
+
1202
+ // -----
1203
+
1204
+ func.func @test_conv2d_wholly_divisible_height (%arg0: tensor <1 x4 x4 x4 xf32 >, %arg1: tensor <8 x1 x1 x4 xf32 >, %arg2: tensor <8 xf32 >, %arg3: tensor <1 xf32 >, %arg4: tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 > {
1205
+ // expected-error@+1 {{'tosa.conv2d' op expected input_height - 1 + pad_top + pad_bottom - (kernel_height - 1) * dilation_y to be wholly divisible by stride_y, got (4 - 1 + 0 + 0 - (1 - 1) * 1) / 2}}
1206
+ %0 = tosa.conv2d %arg0 , %arg1 , %arg2 , %arg3 , %arg4 {acc_type = f32 , dilation = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 2 , 1 >, local_bound = true }
1207
+ : (tensor <1 x4 x4 x4 xf32 >, tensor <8 x1 x1 x4 xf32 >, tensor <8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 >
1208
+ return %0 : tensor <1 x4 x4 x8 xf32 >
1209
+ }
1210
+
1211
+ // -----
1212
+
1213
+ func.func @test_conv2d_wholly_divisible_width (%arg0: tensor <1 x4 x4 x4 xf32 >, %arg1: tensor <8 x1 x1 x4 xf32 >, %arg2: tensor <8 xf32 >, %arg3: tensor <1 xf32 >, %arg4: tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 > {
1214
+ // expected-error@+1 {{'tosa.conv2d' op expected input_width - 1 + pad_left + pad_right - (kernel_width - 1) * dilation_x to be wholly divisible by stride_x, got (4 - 1 + 0 + 0 - (1 - 1) * 1) / 2}}
1215
+ %0 = tosa.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 , 2 >, local_bound = true }
1216
+ : (tensor <1 x4 x4 x4 xf32 >, tensor <8 x1 x1 x4 xf32 >, tensor <8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 >
1217
+ return %0 : tensor <1 x4 x4 x8 xf32 >
1218
+ }
1219
+
1220
+ // -----
1221
+
1222
+ func.func @test_conv2d_unexpected_output_height (%arg0: tensor <1 x4 x4 x4 xf32 >, %arg1: tensor <8 x1 x1 x4 xf32 >, %arg2: tensor <8 xf32 >, %arg3: tensor <1 xf32 >, %arg4: tensor <1 xf32 >) -> tensor <1 x6 x4 x8 xf32 > {
1223
+ // expected-error@+1 {{'tosa.conv2d' op calculated output height did not match expected: calculated=4, expected=6}}
1224
+ %0 = tosa.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 >, local_bound = true }
1225
+ : (tensor <1 x4 x4 x4 xf32 >, tensor <8 x1 x1 x4 xf32 >, tensor <8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x6 x4 x8 xf32 >
1226
+ return %0 : tensor <1 x6 x4 x8 xf32 >
1227
+ }
1228
+
1229
+ // -----
1230
+
1231
+ func.func @test_conv2d_unexpected_output_width (%arg0: tensor <1 x4 x4 x4 xf32 >, %arg1: tensor <8 x1 x1 x4 xf32 >, %arg2: tensor <8 xf32 >, %arg3: tensor <1 xf32 >, %arg4: tensor <1 xf32 >) -> tensor <1 x4 x6 x8 xf32 > {
1232
+ // expected-error@+1 {{'tosa.conv2d' op calculated output width did not match expected: calculated=4, expected=6}}
1233
+ %0 = tosa.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 >, local_bound = true }
1234
+ : (tensor <1 x4 x4 x4 xf32 >, tensor <8 x1 x1 x4 xf32 >, tensor <8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x4 x6 x8 xf32 >
1235
+ return %0 : tensor <1 x4 x6 x8 xf32 >
1236
+ }
1237
+
1238
+ // -----
1239
+
1240
+ func.func @test_conv2d_invalid_bias_size (%arg0: tensor <1 x4 x4 x4 xf32 >, %arg1: tensor <8 x1 x1 x4 xf32 >, %arg2: tensor <7 xf32 >, %arg3: tensor <1 xf32 >, %arg4: tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 > {
1241
+ // expected-error@+1 {{'tosa.conv2d' op bias channels expected to be equal to output channels (8) or 1, got 7}}
1242
+ %0 = tosa.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 >, local_bound = true }
1243
+ : (tensor <1 x4 x4 x4 xf32 >, tensor <8 x1 x1 x4 xf32 >, tensor <7 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x4 x4 x8 xf32 >
1244
+ return %0 : tensor <1 x4 x4 x8 xf32 >
1245
+ }
0 commit comments