@@ -105,83 +105,36 @@ func.func @test_pad_non_const(%arg0: tensor<13x21x3xf32>, %arg1: tensor<3x2xi32>
105105
106106// -----
107107
108- func.func @test_pad_non_const (%arg0: tensor <13 x21 x3 xi8 >, %arg1: tensor <i8 >) -> tensor <?x?x?x i8 > {
108+ func.func @test_pad_non_const (%arg0: tensor <13 x21 x3 xi8 >, %arg1: tensor <i8 >) -> tensor <13 x 21 x 3 x i8 > {
109109 %0 = " tosa.const" () {value = dense <[[0 , 0 ], [0 , 1 ], [0 , 1 ]]> : tensor <3 x2 xi32 >} : () -> tensor <3 x2 xi32 >
110110 // expected-error@+1 {{'tosa.pad' op pad_const of pad is not constant}}
111- %1 = tosa.pad %arg0 , %0 , %arg1 : (tensor <13 x21 x3 xi8 >, tensor <3 x2 xi32 >, tensor <i8 >) -> tensor <?x?x?x i8 >
112- return %1 : tensor <?x?x?x i8 >
111+ %1 = tosa.pad %arg0 , %0 , %arg1 : (tensor <13 x21 x3 xi8 >, tensor <3 x2 xi32 >, tensor <i8 >) -> tensor <13 x 21 x 3 x i8 >
112+ return %1 : tensor <13 x 21 x 3 x i8 >
113113}
114114
115115// -----
116116
117- func.func @test_pad_output_shape_mismatch (%arg0: tensor <13 x21 x3 xf32 >) -> tensor <13 x21 x3 xf32 > {
118- %0 = " tosa.const" () {value = dense <[[1 , 1 ], [1 , 1 ], [1 , 1 ]]> : tensor <3 x2 xi32 >} : () -> tensor <3 x2 xi32 >
119- // expected-error@+2 {{'tosa.pad' op failed to infer returned types}}
120- // expected-error@+1 {{'tosa.pad' op inferred type(s) 'tensor<15x23x5xf32>' are incompatible with return type(s) of operation 'tensor<13x21x3xf32>}}
121- %1 = tosa.pad %arg0 , %0 : (tensor <13 x21 x3 xf32 >, tensor <3 x2 xi32 >) -> tensor <13 x21 x3 xf32 >
122- return %1 : tensor <13 x21 x3 xf32 >
123- }
124-
125- // -----
126-
127- func.func @test_pad_type_mismatch (%arg0: tensor <13 x21 x3 xf32 >) -> tensor <15 x23 x5 xi32 > {
128- %0 = " tosa.const" () {value = dense <[[1 , 1 ], [1 , 1 ], [1 , 1 ]]> : tensor <3 x2 xi32 >} : () -> tensor <3 x2 xi32 >
129- // expected-error@+2 {{'tosa.pad' op failed to infer returned types}}
130- // expected-error@+1 {{'tosa.pad' op inferred type(s) 'tensor<15x23x5xf32>' are incompatible with return type(s) of operation 'tensor<15x23x5xi32>}}
131- %1 = tosa.pad %arg0 , %0 : (tensor <13 x21 x3 xf32 >, tensor <3 x2 xi32 >) -> tensor <15 x23 x5 xi32 >
132- return %1 : tensor <15 x23 x5 xi32 >
133- }
134-
135- // -----
136-
137- func.func @test_pad_incorret_padding_rank (%arg0: tensor <13 x21 xf32 >) -> tensor <13 x21 xf32 > {
138- %0 = " tosa.const" () {value = dense <[0 , 1 ]> : tensor <2 xi32 >} : () -> tensor <2 xi32 >
139- // expected-error@+1 {{'tosa.pad' op paddings must be a tensor of rank 2}}
140- %1 = tosa.pad %arg0 , %0 : (tensor <13 x21 xf32 >, tensor <2 xi32 >) -> tensor <13 x21 xf32 >
141- return %1 : tensor <13 x21 xf32 >
142- }
143-
144- // -----
145-
146- func.func @test_pad_incorret_padding_shape (%arg0: tensor <13 x21 xf32 >) -> tensor <13 x21 xf32 > {
147- %0 = " tosa.const" () {value = dense <[[0 , 0 ], [0 , 1 ], [0 , 1 ], [1 , 1 ]]> : tensor <4 x2 xi32 >} : () -> tensor <4 x2 xi32 >
148- // expected-error@+1 {{'tosa.pad' op paddings must be a tensor of shape [2, 2]}}
149- %1 = tosa.pad %arg0 , %0 : (tensor <13 x21 xf32 >, tensor <4 x2 xi32 >) -> tensor <13 x21 xf32 >
150- return %1 : tensor <13 x21 xf32 >
151- }
152-
153- // -----
154-
155- func.func @test_pad_incorret_padding_shape (%arg0: tensor <13 x21 xf32 >) -> tensor <13 x21 xf32 > {
156- %0 = " tosa.const" () {value = dense <[[0 , 0 , 0 , 1 ], [0 , 1 , 1 , 1 ]]> : tensor <2 x4 xi32 >} : () -> tensor <2 x4 xi32 >
157- // expected-error@+1 {{'tosa.pad' op paddings must be a tensor of shape [2, 2]}}
158- %1 = tosa.pad %arg0 , %0 : (tensor <13 x21 xf32 >, tensor <2 x4 xi32 >) -> tensor <13 x21 xf32 >
159- return %1 : tensor <13 x21 xf32 >
160- }
161-
162- // -----
163-
164- func.func @test_pad_negative_padding (%arg0: tensor <13 x21 xf32 >) -> tensor <?x?xf32 > {
165- %0 = " tosa.const" () {value = dense <[[0 , 0 ], [0 , -1 ]]> : tensor <2 x2 xi32 >} : () -> tensor <2 x2 xi32 >
166- // expected-error@+1 {{'tosa.pad' op number of pad elements must be positive}}
167- %1 = tosa.pad %arg0 , %0 : (tensor <13 x21 xf32 >, tensor <2 x2 xi32 >) -> tensor <?x?xf32 >
168- return %1 : tensor <?x?xf32 >
117+ func.func @test_pad_io_rank_mismatch (%arg0: tensor <13 x21 xf32 >, %arg1: tensor <2 x2 xi32 >) {
118+ // expected-error@+1 {{'tosa.pad' op expect same input and output tensor rank.}}
119+ %1 = tosa.pad %arg0 , %arg1 : (tensor <13 x21 xf32 >, tensor <2 x2 xi32 >) -> tensor <13 x21 x3 xf32 >
120+ return
169121}
170122
171123// -----
172124
173- func.func @test_pad_incorrect_input (%arg0: f32 , %arg1: i32 ) -> f32 {
174- // expected-error@+1 {{'tosa.pad' op operand #0 must be ranked tensor of number values, but got 'f32' }}
175- %1 = tosa.pad %arg0 , %arg1 : (f32 , i32 ) -> f32
176- return %1 : f32
125+ func.func @test_pad_invalid_padding_rank (%arg0: tensor < 13 x 21 x f32 > , %arg1: tensor < 2 x i32 >) {
126+ // expected-error@+1 {{'tosa.pad' op expect 'padding' tensor rank equal to 2. }}
127+ %1 = tosa.pad %arg0 , %arg1 : (tensor < 13 x 21 x f32 >, tensor < 2 x i32 > ) -> tensor < 13 x 21 x f32 >
128+ return
177129}
178130
179131// -----
180132
181- func.func @test_pad_zero_rank_input (%arg0: tensor <f32 >, %arg1: tensor <i32 >) -> tensor <f32 > {
182- // expected-error@+1 {{'tosa.pad' op input tensor rank must not be 0}}
183- %1 = tosa.pad %arg0 , %arg1 : (tensor <f32 >, tensor <i32 >) -> tensor <f32 >
184- return %1 : tensor <f32 >
133+ func.func @test_pad_invalid_padConst_rank (%arg0: tensor <13 x21 xf32 >, %arg1: tensor <2 x2 xi32 >) {
134+ %0 = " tosa.const" () {value = dense <3.14 > : tensor <1 xf32 >} : () -> tensor <1 xf32 >
135+ // expected-error@+1 {{'tosa.pad' op operand #2 must be 0D tensor of number values, but got 'tensor<1xf32>'}}
136+ %1 = tosa.pad %arg0 , %arg1 , %0 : (tensor <13 x21 xf32 >, tensor <2 x2 xi32 >, tensor <1 xf32 >) -> tensor <13 x21 xf32 >
137+ return
185138}
186139
187140// -----
0 commit comments