@@ -287,7 +287,7 @@ func.func @test_pad_invalid_padConst_rank(%arg0: tensor<13x21xf32>, %arg1: tenso
287
287
// -----
288
288
289
289
func.func @test_pad_padding_shape_mismatch (%arg0: tensor <13 x21 x3 xf32 >) -> tensor <13 x21 x3 xf32 > {
290
- %0 = tosa.const_shape {value = dense <1 > : tensor <4 xindex >} : () -> !tosa.shape <4 >
290
+ %0 = tosa.const_shape {value = dense <1 > : tensor <4 xindex >} : () -> !tosa.shape <4 >
291
291
%pad_const = " tosa.const" () {value = dense <3.14 > : tensor <1 xf32 >} : () -> tensor <1 xf32 >
292
292
// expected-error@+1 {{'tosa.pad' op expected padding tensor dim 0 to have size 6 (2*rank(shape1)) but got size 4}}
293
293
%1 = tosa.pad %arg0 , %0 , %pad_const : (tensor <13 x21 x3 xf32 >, !tosa.shape <4 >, tensor <1 xf32 >) -> tensor <13 x21 x3 xf32 >
@@ -1431,3 +1431,102 @@ func.func @test_argmax_invalid_output_shape(%arg0: tensor<1x2x3xf32>) -> tensor<
1431
1431
%0 = tosa.argmax %arg0 {axis = 0 : i32 }: (tensor <1 x2 x3 xf32 >) -> tensor <1 x2 x3 xi32 >
1432
1432
return %0 : tensor <1 x2 x3 xi32 >
1433
1433
}
1434
+
1435
+ // -----
1436
+
1437
+ func.func @test_avgpool2d_invalid_kernel (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 > {
1438
+ // expected-error@+1 {{'tosa.avg_pool2d' op expect all kernel values to be >= 1, got 0, -1}}
1439
+ %0 = " tosa.avg_pool2d" (%arg0 , %arg1 , %arg2 ) {kernel = array<i64 : 0 , -1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 1 >, acc_type = f32 } :
1440
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1441
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1442
+ }
1443
+
1444
+ // -----
1445
+
1446
+ func.func @test_avgpool2d_invalid_stride (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 > {
1447
+ // expected-error@+1 {{'tosa.avg_pool2d' op expect all stride values to be >= 1, got 1, 0}}
1448
+ %0 = " tosa.avg_pool2d" (%arg0 , %arg1 , %arg2 ) {kernel = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 0 >, acc_type = f32 } :
1449
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1450
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1451
+ }
1452
+
1453
+ // -----
1454
+
1455
+ func.func @test_avgpool2d_invalid_padding (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 > {
1456
+ // expected-error@+1 {{'tosa.avg_pool2d' op expect all padding values to be >= 0, got 0, 0, 0, -1}}
1457
+ %0 = " tosa.avg_pool2d" (%arg0 , %arg1 , %arg2 ) {kernel = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , -1 >, stride = array<i64 : 1 , 1 >, acc_type = f32 } :
1458
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1459
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1460
+ }
1461
+
1462
+ // -----
1463
+
1464
+ func.func @test_avgpool2d_padding_not_less_than_kernel_x (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 > {
1465
+ // expected-error@+1 {{'tosa.avg_pool2d' op expected left/right padding to be less than the width of the kernel, got pad_left=0, pad_right=1, kernel_x=1}}
1466
+ %0 = " tosa.avg_pool2d" (%arg0 , %arg1 , %arg2 ) {kernel = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , 1 >, stride = array<i64 : 1 , 1 >, acc_type = f32 } :
1467
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1468
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1469
+ }
1470
+
1471
+ // -----
1472
+
1473
+ func.func @test_avgpool2d_padding_not_less_than_kernel_y (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 > {
1474
+ // expected-error@+1 {{'tosa.avg_pool2d' op expected top/bottom padding to be less than the height of the kernel, got pad_top=2, pad_bottom=0, kernel_y=1}}
1475
+ %0 = " tosa.avg_pool2d" (%arg0 , %arg1 , %arg2 ) {kernel = array<i64 : 1 , 1 >, pad = array<i64 : 2 , 0 , 0 , 0 >, stride = array<i64 : 1 , 1 >, acc_type = f32 } :
1476
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1477
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1478
+ }
1479
+
1480
+ // -----
1481
+
1482
+ func.func @test_avgpool2d_wholly_divisible_height (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 > {
1483
+ // expected-error@+1 {{'tosa.avg_pool2d' op expected input_height + pad_top + pad_bottom - kernel_y to be wholly divisible by stride_y, got (32 + 0 + 0 - 1) / 2}}
1484
+ %0 = " tosa.avg_pool2d" (%arg0 , %arg1 , %arg2 ) {kernel = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 2 , 1 >, acc_type = f32 } :
1485
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1486
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1487
+ }
1488
+
1489
+ // -----
1490
+
1491
+ func.func @test_avgpool2d_wholly_divisible_width (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 > {
1492
+ // expected-error@+1 {{'tosa.avg_pool2d' op expected input_width + pad_left + pad_right - kernel_x to be wholly divisible by stride_x, got (32 + 0 + 0 - 1) / 2}}
1493
+ %0 = " tosa.avg_pool2d" (%arg0 , %arg1 , %arg2 ) {kernel = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 2 >, acc_type = f32 } :
1494
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1495
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1496
+ }
1497
+
1498
+ // -----
1499
+
1500
+ func.func @test_avgpool2d_unexpected_output_height (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xf32 >) -> tensor <1 x33 x32 x8 xf32 > {
1501
+ // expected-error@+1 {{'tosa.avg_pool2d' op calculated output height did not match expected: calculated=32, expected=33}}
1502
+ %0 = " tosa.avg_pool2d" (%arg0 , %arg1 , %arg2 ) {kernel = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 1 >, acc_type = f32 } :
1503
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x33 x32 x8 xf32 >
1504
+ return %0 : tensor <1 x33 x32 x8 xf32 >
1505
+ }
1506
+
1507
+ // -----
1508
+
1509
+ func.func @test_avgpool2d_unexpected_output_width (%arg0: tensor <1 x32 x32 x8 xf32 >, %arg1: tensor <1 xf32 >, %arg2: tensor <1 xf32 >) -> tensor <1 x?x33 x8 xf32 > {
1510
+ // expected-error@+1 {{'tosa.avg_pool2d' op calculated output width did not match expected: calculated=32, expected=33}}
1511
+ %0 = " tosa.avg_pool2d" (%arg0 , %arg1 , %arg2 ) {kernel = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 1 >, acc_type = f32 } :
1512
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x?x33 x8 xf32 >
1513
+ return %0 : tensor <1 x?x33 x8 xf32 >
1514
+ }
1515
+
1516
+ // -----
1517
+
1518
+ func.func @test_maxpool2d_invalid_kernel (%arg0: tensor <1 x32 x32 x8 xf32 >) -> tensor <1 x2 x32 x8 xf32 > {
1519
+ // expected-error@+1 {{'tosa.max_pool2d' op expect all kernel values to be >= 1, got 0, 1}}
1520
+ %0 = " tosa.max_pool2d" (%arg0 ) {kernel = array<i64 : 0 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 1 >} :
1521
+ (tensor <1 x32 x32 x8 xf32 >) -> tensor <1 x2 x32 x8 xf32 >
1522
+ return %0 : tensor <1 x2 x32 x8 xf32 >
1523
+ }
1524
+
1525
+ // -----
1526
+
1527
+ func.func @test_maxpool2d_unexpected_output_width (%arg0: tensor <1 x32 x32 x8 xf32 >) -> tensor <1 x32 x2 x8 xf32 > {
1528
+ // expected-error@+1 {{'tosa.max_pool2d' op calculated output width did not match expected: calculated=32, expected=2}}
1529
+ %0 = " tosa.max_pool2d" (%arg0 ) {kernel = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 1 >} :
1530
+ (tensor <1 x32 x32 x8 xf32 >) -> tensor <1 x32 x2 x8 xf32 >
1531
+ return %0 : tensor <1 x32 x2 x8 xf32 >
1532
+ }
0 commit comments