@@ -1197,3 +1197,75 @@ func.func @broadcast_resize_bilinear_i8(%arg0 : tensor<3x1x1x7xi8>) -> tensor<3x
11971197
11981198 return %resize : tensor <3 x4 x5 x7 xi32 >
11991199}
1200+
1201+ // -----
1202+
1203+ 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 > {
1204+ // expected-error@+1 {{'tosa.conv2d' op expect all padding values to be >= 0, got 0, 0, -1, 0}}
1205+ %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 }
1206+ : (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 >
1207+ return %0 : tensor <1 x4 x4 x8 xf32 >
1208+ }
1209+
1210+ // -----
1211+
1212+ 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 > {
1213+ // expected-error@+1 {{'tosa.conv2d' op expect all stride values to be >= 1, got 0, 1}}
1214+ %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 }
1215+ : (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 >
1216+ return %0 : tensor <1 x4 x4 x8 xf32 >
1217+ }
1218+
1219+ // -----
1220+
1221+ 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 > {
1222+ // expected-error@+1 {{'tosa.conv2d' op expect all dilation values to be >= 1, got 1, 0}}
1223+ %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 }
1224+ : (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 >
1225+ return %0 : tensor <1 x4 x4 x8 xf32 >
1226+ }
1227+
1228+ // -----
1229+
1230+ 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 > {
1231+ // 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}}
1232+ %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 }
1233+ : (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 >
1234+ return %0 : tensor <1 x4 x4 x8 xf32 >
1235+ }
1236+
1237+ // -----
1238+
1239+ 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 > {
1240+ // 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}}
1241+ %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 }
1242+ : (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 >
1243+ return %0 : tensor <1 x4 x4 x8 xf32 >
1244+ }
1245+
1246+ // -----
1247+
1248+ 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 > {
1249+ // expected-error@+1 {{'tosa.conv2d' op calculated output height did not match expected: calculated=4, expected=6}}
1250+ %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 }
1251+ : (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 >
1252+ return %0 : tensor <1 x6 x4 x8 xf32 >
1253+ }
1254+
1255+ // -----
1256+
1257+ 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 > {
1258+ // expected-error@+1 {{'tosa.conv2d' op calculated output width did not match expected: calculated=4, expected=6}}
1259+ %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 }
1260+ : (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 >
1261+ return %0 : tensor <1 x4 x6 x8 xf32 >
1262+ }
1263+
1264+ // -----
1265+
1266+ 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 > {
1267+ // expected-error@+1 {{'tosa.conv2d' op bias channels expected to be equal to output channels (8) or 1, got 7}}
1268+ %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 }
1269+ : (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 >
1270+ return %0 : tensor <1 x4 x4 x8 xf32 >
1271+ }
0 commit comments