@@ -1753,3 +1753,102 @@ func.func @test_negate_output_zp_non_zero(%arg0: tensor<1x16x16x8xf32>) -> tenso
1753
1753
: (tensor <1 x16 x16 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x16 x16 x8 xf32 >
1754
1754
return %0 : tensor <1 x16 x16 x8 xf32 >
1755
1755
}
1756
+
1757
+ // -----
1758
+
1759
+ 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 > {
1760
+ // expected-error@+1 {{'tosa.avg_pool2d' op expect all kernel values to be >= 1, got 0, -1}}
1761
+ %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 } :
1762
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1763
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1764
+ }
1765
+
1766
+ // -----
1767
+
1768
+ 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 > {
1769
+ // expected-error@+1 {{'tosa.avg_pool2d' op expect all stride values to be >= 1, got 1, 0}}
1770
+ %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 } :
1771
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1772
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1773
+ }
1774
+
1775
+ // -----
1776
+
1777
+ 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 > {
1778
+ // expected-error@+1 {{'tosa.avg_pool2d' op expect all padding values to be >= 0, got 0, 0, 0, -1}}
1779
+ %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 } :
1780
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1781
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1782
+ }
1783
+
1784
+ // -----
1785
+
1786
+ 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 > {
1787
+ // 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}}
1788
+ %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 } :
1789
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1790
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1791
+ }
1792
+
1793
+ // -----
1794
+
1795
+ 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 > {
1796
+ // 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}}
1797
+ %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 } :
1798
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1799
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1800
+ }
1801
+
1802
+ // -----
1803
+
1804
+ 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 > {
1805
+ // 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}}
1806
+ %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 } :
1807
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1808
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1809
+ }
1810
+
1811
+ // -----
1812
+
1813
+ 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 > {
1814
+ // 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}}
1815
+ %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 } :
1816
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x32 x32 x8 xf32 >
1817
+ return %0 : tensor <1 x32 x32 x8 xf32 >
1818
+ }
1819
+
1820
+ // -----
1821
+
1822
+ 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 > {
1823
+ // expected-error@+1 {{'tosa.avg_pool2d' op calculated output height did not match expected: calculated=32, expected=33}}
1824
+ %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 } :
1825
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x33 x32 x8 xf32 >
1826
+ return %0 : tensor <1 x33 x32 x8 xf32 >
1827
+ }
1828
+
1829
+ // -----
1830
+
1831
+ 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 > {
1832
+ // expected-error@+1 {{'tosa.avg_pool2d' op calculated output width did not match expected: calculated=32, expected=33}}
1833
+ %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 } :
1834
+ (tensor <1 x32 x32 x8 xf32 >, tensor <1 xf32 >, tensor <1 xf32 >) -> tensor <1 x?x33 x8 xf32 >
1835
+ return %0 : tensor <1 x?x33 x8 xf32 >
1836
+ }
1837
+
1838
+ // -----
1839
+
1840
+ func.func @test_maxpool2d_invalid_kernel (%arg0: tensor <1 x32 x32 x8 xf32 >) -> tensor <1 x2 x32 x8 xf32 > {
1841
+ // expected-error@+1 {{'tosa.max_pool2d' op expect all kernel values to be >= 1, got 0, 1}}
1842
+ %0 = " tosa.max_pool2d" (%arg0 ) {kernel = array<i64 : 0 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 1 >} :
1843
+ (tensor <1 x32 x32 x8 xf32 >) -> tensor <1 x2 x32 x8 xf32 >
1844
+ return %0 : tensor <1 x2 x32 x8 xf32 >
1845
+ }
1846
+
1847
+ // -----
1848
+
1849
+ func.func @test_maxpool2d_unexpected_output_width (%arg0: tensor <1 x32 x32 x8 xf32 >) -> tensor <1 x32 x2 x8 xf32 > {
1850
+ // expected-error@+1 {{'tosa.max_pool2d' op calculated output width did not match expected: calculated=32, expected=2}}
1851
+ %0 = " tosa.max_pool2d" (%arg0 ) {kernel = array<i64 : 1 , 1 >, pad = array<i64 : 0 , 0 , 0 , 0 >, stride = array<i64 : 1 , 1 >} :
1852
+ (tensor <1 x32 x32 x8 xf32 >) -> tensor <1 x32 x2 x8 xf32 >
1853
+ return %0 : tensor <1 x32 x2 x8 xf32 >
1854
+ }
0 commit comments