@@ -56,6 +56,48 @@ func.func @test_concat_element_type_mismatch(%arg0 : tensor<1x2xf32>, %arg1 : te
56
56
57
57
// -----
58
58
59
+ func.func @test_concat_output_shape_mismatch (%arg0 : tensor <2 x1 xf32 >, %arg1 : tensor <2 x2 xf32 >) -> tensor <2 x2 xf32 > {
60
+ // expected-error@+2 {{failed to infer returned types}}
61
+ // expected-error@+1 {{inferred type(s) 'tensor<2x3xf32>' are incompatible with return type(s) of operation 'tensor<2x2xf32>}}
62
+ %0 = " tosa.concat" (%arg0 , %arg1 ) {axis = 1 : i64 } : (tensor <2 x1 xf32 >, tensor <2 x2 xf32 >) -> tensor <2 x2 xf32 >
63
+ return %0 : tensor <2 x2 xf32 >
64
+ }
65
+
66
+ // -----
67
+
68
+ func.func @test_concat_output_rank_mismatch (%arg0 : tensor <2 x1 xf32 >, %arg1 : tensor <2 x2 xf32 >) -> tensor <?x?x?xf32 > {
69
+ // expected-error@+2 {{failed to infer returned types}}
70
+ // expected-error@+1 {{inferred type(s) 'tensor<2x3xf32>' are incompatible with return type(s) of operation 'tensor<?x?x?xf32>}}
71
+ %0 = " tosa.concat" (%arg0 , %arg1 ) {axis = 1 : i64 } : (tensor <2 x1 xf32 >, tensor <2 x2 xf32 >) -> tensor <?x?x?xf32 >
72
+ return %0 : tensor <?x?x?xf32 >
73
+ }
74
+
75
+ // -----
76
+
77
+ func.func @test_concat_input_rank_mismatch (%arg0 : tensor <1 x2 xf32 >, %arg1 : tensor <2 x2 x2 xf32 >) -> tensor <?x?xf32 > {
78
+ // expected-error@+1 {{'tosa.concat' op rank of input 'tensor<2x2x2xf32>' does not match other input rank(s) (2)}}
79
+ %0 = " tosa.concat" (%arg0 , %arg1 ) {axis = 0 : i64 } : (tensor <1 x2 xf32 >, tensor <2 x2 x2 xf32 >) -> tensor <?x?xf32 >
80
+ return %0 : tensor <?x?xf32 >
81
+ }
82
+
83
+ // -----
84
+
85
+ func.func @test_concat_axis_out_of_range (%arg0 : tensor <1 x2 xf32 >, %arg1 : tensor <2 x2 xf32 >) -> tensor <?x?xf32 > {
86
+ // expected-error@+1 {{'tosa.concat' op axis must be in range 0 to 1}}
87
+ %0 = " tosa.concat" (%arg0 , %arg1 ) {axis = -1 : i64 } : (tensor <1 x2 xf32 >, tensor <2 x2 xf32 >) -> tensor <?x?xf32 >
88
+ return %0 : tensor <?x?xf32 >
89
+ }
90
+
91
+ // -----
92
+
93
+ func.func @test_concat_axis_out_of_range (%arg0 : tensor <10 x11 x12 xf32 >, %arg1 : tensor <10 x11 x21 xf32 >) -> tensor <?x?x?xf32 > {
94
+ // expected-error@+1 {{'tosa.concat' op axis must be in range 0 to 2}}
95
+ %0 = " tosa.concat" (%arg0 , %arg1 ) {axis = 3 : i64 } : (tensor <10 x11 x12 xf32 >, tensor <10 x11 x21 xf32 >) -> tensor <?x?x?xf32 >
96
+ return %0 : tensor <?x?x?xf32 >
97
+ }
98
+
99
+ // -----
100
+
59
101
func.func @test_pad_non_const (%arg0: tensor <13 x21 x3 xf32 >, %arg1: tensor <3 x2 xi32 >) -> tensor <13 x21 x3 xf32 > {
60
102
// expected-error@+1 {{'tosa.pad' op padding of pad is not constant}}
61
103
%0 = " tosa.pad" (%arg0 , %arg1 ) : (tensor <13 x21 x3 xf32 >, tensor <3 x2 xi32 >) -> tensor <13 x21 x3 xf32 >
@@ -64,11 +106,83 @@ func.func @test_pad_non_const(%arg0: tensor<13x21x3xf32>, %arg1: tensor<3x2xi32>
64
106
65
107
// -----
66
108
67
- func.func @test_pad_non_const (%arg0: tensor <13 x21 x3 xi8 >, %arg1: tensor <i8 >) -> tensor <13 x 21 x 3 x i8 > {
109
+ func.func @test_pad_non_const (%arg0: tensor <13 x21 x3 xi8 >, %arg1: tensor <i8 >) -> tensor <?x?x?x i8 > {
68
110
%0 = " tosa.const" () {value = dense <[[0 , 0 ], [0 , 1 ], [0 , 1 ]]> : tensor <3 x2 xi32 >} : () -> tensor <3 x2 xi32 >
69
111
// expected-error@+1 {{'tosa.pad' op pad_const of pad is not constant}}
70
- %1 = " tosa.pad" (%arg0 , %0 , %arg1 ) : (tensor <13 x21 x3 xi8 >, tensor <3 x2 xi32 >, tensor <i8 >) -> tensor <13 x21 x3 xi8 >
71
- return %1 : tensor <13 x21 x3 xi8 >
112
+ %1 = " tosa.pad" (%arg0 , %0 , %arg1 ) : (tensor <13 x21 x3 xi8 >, tensor <3 x2 xi32 >, tensor <i8 >) -> tensor <?x?x?xi8 >
113
+ return %1 : tensor <?x?x?xi8 >
114
+ }
115
+
116
+ // -----
117
+
118
+ func.func @test_pad_output_shape_mismatch (%arg0: tensor <13 x21 x3 xf32 >) -> tensor <13 x21 x3 xf32 > {
119
+ %0 = " tosa.const" () {value = dense <[[1 , 1 ], [1 , 1 ], [1 , 1 ]]> : tensor <3 x2 xi32 >} : () -> tensor <3 x2 xi32 >
120
+ // expected-error@+2 {{'tosa.pad' op failed to infer returned types}}
121
+ // expected-error@+1 {{'tosa.pad' op inferred type(s) 'tensor<15x23x5xf32>' are incompatible with return type(s) of operation 'tensor<13x21x3xf32>}}
122
+ %1 = " tosa.pad" (%arg0 , %0 ) : (tensor <13 x21 x3 xf32 >, tensor <3 x2 xi32 >) -> tensor <13 x21 x3 xf32 >
123
+ return %1 : tensor <13 x21 x3 xf32 >
124
+ }
125
+
126
+ // -----
127
+
128
+ func.func @test_pad_type_mismatch (%arg0: tensor <13 x21 x3 xf32 >) -> tensor <15 x23 x5 xi32 > {
129
+ %0 = " tosa.const" () {value = dense <[[1 , 1 ], [1 , 1 ], [1 , 1 ]]> : tensor <3 x2 xi32 >} : () -> tensor <3 x2 xi32 >
130
+ // expected-error@+2 {{'tosa.pad' op failed to infer returned types}}
131
+ // expected-error@+1 {{'tosa.pad' op inferred type(s) 'tensor<15x23x5xf32>' are incompatible with return type(s) of operation 'tensor<15x23x5xi32>}}
132
+ %1 = " tosa.pad" (%arg0 , %0 ) : (tensor <13 x21 x3 xf32 >, tensor <3 x2 xi32 >) -> tensor <15 x23 x5 xi32 >
133
+ return %1 : tensor <15 x23 x5 xi32 >
134
+ }
135
+
136
+ // -----
137
+
138
+ func.func @test_pad_incorret_padding_rank (%arg0: tensor <13 x21 xf32 >) -> tensor <13 x21 xf32 > {
139
+ %0 = " tosa.const" () {value = dense <[0 , 1 ]> : tensor <2 xi32 >} : () -> tensor <2 xi32 >
140
+ // expected-error@+1 {{'tosa.pad' op paddings must be a tensor of rank 2}}
141
+ %1 = " tosa.pad" (%arg0 , %0 ) : (tensor <13 x21 xf32 >, tensor <2 xi32 >) -> tensor <13 x21 xf32 >
142
+ return %1 : tensor <13 x21 xf32 >
143
+ }
144
+
145
+ // -----
146
+
147
+ func.func @test_pad_incorret_padding_shape (%arg0: tensor <13 x21 xf32 >) -> tensor <13 x21 xf32 > {
148
+ %0 = " tosa.const" () {value = dense <[[0 , 0 ], [0 , 1 ], [0 , 1 ], [1 , 1 ]]> : tensor <4 x2 xi32 >} : () -> tensor <4 x2 xi32 >
149
+ // expected-error@+1 {{'tosa.pad' op paddings must be a tensor of shape [2, 2]}}
150
+ %1 = " tosa.pad" (%arg0 , %0 ) : (tensor <13 x21 xf32 >, tensor <4 x2 xi32 >) -> tensor <13 x21 xf32 >
151
+ return %1 : tensor <13 x21 xf32 >
152
+ }
153
+
154
+ // -----
155
+
156
+ func.func @test_pad_incorret_padding_shape (%arg0: tensor <13 x21 xf32 >) -> tensor <13 x21 xf32 > {
157
+ %0 = " tosa.const" () {value = dense <[[0 , 0 , 0 , 1 ], [0 , 1 , 1 , 1 ]]> : tensor <2 x4 xi32 >} : () -> tensor <2 x4 xi32 >
158
+ // expected-error@+1 {{'tosa.pad' op paddings must be a tensor of shape [2, 2]}}
159
+ %1 = " tosa.pad" (%arg0 , %0 ) : (tensor <13 x21 xf32 >, tensor <2 x4 xi32 >) -> tensor <13 x21 xf32 >
160
+ return %1 : tensor <13 x21 xf32 >
161
+ }
162
+
163
+ // -----
164
+
165
+ func.func @test_pad_negative_padding (%arg0: tensor <13 x21 xf32 >) -> tensor <?x?xf32 > {
166
+ %0 = " tosa.const" () {value = dense <[[0 , 0 ], [0 , -1 ]]> : tensor <2 x2 xi32 >} : () -> tensor <2 x2 xi32 >
167
+ // expected-error@+1 {{'tosa.pad' op number of pad elements must be positive}}
168
+ %1 = " tosa.pad" (%arg0 , %0 ) : (tensor <13 x21 xf32 >, tensor <2 x2 xi32 >) -> tensor <?x?xf32 >
169
+ return %1 : tensor <?x?xf32 >
170
+ }
171
+
172
+ // -----
173
+
174
+ func.func @test_pad_incorrect_input (%arg0: f32 , %arg1: i32 ) -> f32 {
175
+ // expected-error@+1 {{'tosa.pad' op operand #0 must be ranked tensor of number values, but got 'f32'}}
176
+ %1 = " tosa.pad" (%arg0 , %arg1 ) : (f32 , i32 ) -> f32
177
+ return %1 : f32
178
+ }
179
+
180
+ // -----
181
+
182
+ func.func @test_pad_zero_rank_input (%arg0: tensor <f32 >, %arg1: tensor <i32 >) -> tensor <f32 > {
183
+ // expected-error@+1 {{'tosa.pad' op input tensor rank must not be 0}}
184
+ %1 = " tosa.pad" (%arg0 , %arg1 ) : (tensor <f32 >, tensor <i32 >) -> tensor <f32 >
185
+ return %1 : tensor <f32 >
72
186
}
73
187
74
188
// -----
0 commit comments