@@ -137,20 +137,22 @@ func.func @negative_broadcast_transpose_021(%arg0 : vector<3x1x3xi8>) -> vector<
137
137
return %1 : vector <3 x3 x3 xi8 >
138
138
}
139
139
140
-
141
140
// -----
142
141
143
- // Test of FoldTransposeShapeCast
142
+ /// +--------------------------------------------------------------------------
143
+ /// Tests of ShapeCastOp::fold: shape_cast(transpose) -> shape_cast
144
+ /// +--------------------------------------------------------------------------
145
+
144
146
// In this test, the permutation maps the non-unit dimensions (1 and 2) as follows:
145
147
// 1 -> 0
146
148
// 2 -> 4
147
149
// Because 0 < 4, this permutation is order preserving and effectively a shape_cast.
148
- // CHECK-LABEL: @transpose_shape_cast
150
+ // CHECK-LABEL: @shape_cast_of_transpose
149
151
// CHECK-SAME: %[[ARG:.*]]: vector<1x4x4x1x1xi8>) -> vector<4x4xi8> {
150
152
// CHECK: %[[SHAPE_CAST:.*]] = vector.shape_cast %[[ARG]] :
151
153
// CHECK-SAME: vector<1x4x4x1x1xi8> to vector<4x4xi8>
152
154
// CHECK: return %[[SHAPE_CAST]] : vector<4x4xi8>
153
- func.func @transpose_shape_cast (%arg : vector <1 x4 x4 x1 x1 xi8 >) -> vector <4 x4 xi8 > {
155
+ func.func @shape_cast_of_transpose (%arg : vector <1 x4 x4 x1 x1 xi8 >) -> vector <4 x4 xi8 > {
154
156
%0 = vector.transpose %arg , [1 , 0 , 3 , 4 , 2 ]
155
157
: vector <1 x4 x4 x1 x1 xi8 > to vector <4 x1 x1 x1 x4 xi8 >
156
158
%1 = vector.shape_cast %0 : vector <4 x1 x1 x1 x4 xi8 > to vector <4 x4 xi8 >
@@ -159,18 +161,17 @@ func.func @transpose_shape_cast(%arg : vector<1x4x4x1x1xi8>) -> vector<4x4xi8> {
159
161
160
162
// -----
161
163
162
- // Test of FoldTransposeShapeCast
163
164
// In this test, the mapping of non-unit dimensions (1 and 2) is as follows:
164
165
// 1 -> 2
165
166
// 2 -> 1
166
167
// As this is not increasing (2 > 1), this transpose is not order
167
168
// preserving and cannot be treated as a shape_cast.
168
- // CHECK-LABEL: @negative_transpose_shape_cast
169
+ // CHECK-LABEL: @negative_shape_cast_of_transpose
169
170
// CHECK-SAME: %[[ARG:.*]]: vector<1x4x4x1xi8>) -> vector<4x4xi8> {
170
171
// CHECK: %[[TRANSPOSE:.*]] = vector.transpose %[[ARG]]
171
172
// CHECK: %[[SHAPE_CAST:.*]] = vector.shape_cast %[[TRANSPOSE]]
172
173
// CHECK: return %[[SHAPE_CAST]] : vector<4x4xi8>
173
- func.func @negative_transpose_shape_cast (%arg : vector <1 x4 x4 x1 xi8 >) -> vector <4 x4 xi8 > {
174
+ func.func @negative_shape_cast_of_transpose (%arg : vector <1 x4 x4 x1 xi8 >) -> vector <4 x4 xi8 > {
174
175
%0 = vector.transpose %arg , [0 , 2 , 1 , 3 ]
175
176
: vector <1 x4 x4 x1 xi8 > to vector <1 x4 x4 x1 xi8 >
176
177
%1 = vector.shape_cast %0 : vector <1 x4 x4 x1 xi8 > to vector <4 x4 xi8 >
@@ -179,42 +180,43 @@ func.func @negative_transpose_shape_cast(%arg : vector<1x4x4x1xi8>) -> vector<4x
179
180
180
181
// -----
181
182
182
- // Test of FoldTransposeShapeCast
183
183
// Currently the conversion shape_cast(transpose) -> shape_cast is disabled for
184
184
// scalable vectors because of bad interaction with ConvertIllegalShapeCastOpsToTransposes
185
- // CHECK-LABEL: @negative_transpose_shape_cast_scalable
185
+ // CHECK-LABEL: @negative_shape_cast_of_transpose_scalable
186
186
// CHECK: vector.transpose
187
187
// CHECK: vector.shape_cast
188
- func.func @negative_transpose_shape_cast_scalable (%arg : vector <[4 ]x1 xi8 >) -> vector <[4 ]xi8 > {
188
+ func.func @negative_shape_cast_of_transpose_scalable (%arg : vector <[4 ]x1 xi8 >) -> vector <[4 ]xi8 > {
189
189
%0 = vector.transpose %arg , [1 , 0 ] : vector <[4 ]x1 xi8 > to vector <1 x[4 ]xi8 >
190
190
%1 = vector.shape_cast %0 : vector <1 x[4 ]xi8 > to vector <[4 ]xi8 >
191
191
return %1 : vector <[4 ]xi8 >
192
192
}
193
193
194
194
// -----
195
195
196
- // Test of shape_cast folding.
196
+ /// +--------------------------------------------------------------------------
197
+ /// Tests of FoldTransposeShapeCast: transpose(shape_cast) -> shape_cast
198
+ /// +--------------------------------------------------------------------------
199
+
197
200
// The conversion transpose(shape_cast) -> shape_cast is not disabled for scalable
198
201
// vectors.
199
- // CHECK-LABEL: @shape_cast_transpose_scalable
202
+ // CHECK-LABEL: @transpose_of_shape_cast_scalable
200
203
// CHECK: vector.shape_cast
201
204
// CHECK-SAME: vector<[4]xi8> to vector<[4]x1xi8>
202
- func.func @shape_cast_transpose_scalable (%arg : vector <[4 ]xi8 >) -> vector <[4 ]x1 xi8 > {
205
+ func.func @transpose_of_shape_cast_scalable (%arg : vector <[4 ]xi8 >) -> vector <[4 ]x1 xi8 > {
203
206
%0 = vector.shape_cast %arg : vector <[4 ]xi8 > to vector <1 x[4 ]xi8 >
204
207
%1 = vector.transpose %0 , [1 , 0 ] : vector <1 x[4 ]xi8 > to vector <[4 ]x1 xi8 >
205
208
return %1 : vector <[4 ]x1 xi8 >
206
209
}
207
210
208
211
// -----
209
212
210
- // Test of shape_cast folding.
211
213
// A transpose that is 'order preserving' can be treated like a shape_cast.
212
- // CHECK-LABEL: @shape_cast_transpose
214
+ // CHECK-LABEL: @transpose_of_shape_cast
213
215
// CHECK-SAME: %[[ARG:.*]]: vector<2x3x1x1xi8>) -> vector<6x1x1xi8> {
214
216
// CHECK: %[[SHAPE_CAST:.*]] = vector.shape_cast %[[ARG]] :
215
217
// CHECK-SAME: vector<2x3x1x1xi8> to vector<6x1x1xi8>
216
218
// CHECK: return %[[SHAPE_CAST]] : vector<6x1x1xi8>
217
- func.func @shape_cast_transpose (%arg : vector <2 x3 x1 x1 xi8 >) -> vector <6 x1 x1 xi8 > {
219
+ func.func @transpose_of_shape_cast (%arg : vector <2 x3 x1 x1 xi8 >) -> vector <6 x1 x1 xi8 > {
218
220
%0 = vector.shape_cast %arg : vector <2 x3 x1 x1 xi8 > to vector <6 x1 x1 xi8 >
219
221
%1 = vector.transpose %0 , [0 , 2 , 1 ]
220
222
: vector <6 x1 x1 xi8 > to vector <6 x1 x1 xi8 >
@@ -223,12 +225,11 @@ func.func @shape_cast_transpose(%arg : vector<2x3x1x1xi8>) -> vector<6x1x1xi8>
223
225
224
226
// -----
225
227
226
- // Test of shape_cast folding.
227
228
// Scalable dimensions should be treated as non-unit dimensions.
228
- // CHECK-LABEL: @shape_cast_transpose_scalable
229
+ // CHECK-LABEL: @transpose_of_shape_cast_scalable
229
230
// CHECK: vector.shape_cast
230
231
// CHECK: vector.transpose
231
- func.func @shape_cast_transpose_scalable_unit (%arg : vector <[1 ]x4 x1 xi8 >) -> vector <4 x[1 ]xi8 > {
232
+ func.func @transpose_of_shape_cast_scalable_unit (%arg : vector <[1 ]x4 x1 xi8 >) -> vector <4 x[1 ]xi8 > {
232
233
%0 = vector.shape_cast %arg : vector <[1 ]x4 x1 xi8 > to vector <[1 ]x4 xi8 >
233
234
%1 = vector.transpose %0 , [1 , 0 ] : vector <[1 ]x4 xi8 > to vector <4 x[1 ]xi8 >
234
235
return %1 : vector <4 x[1 ]xi8 >
@@ -237,12 +238,12 @@ func.func @shape_cast_transpose_scalable_unit(%arg : vector<[1]x4x1xi8>) -> vect
237
238
// -----
238
239
239
240
// Test of shape_cast (not) folding.
240
- // CHECK-LABEL: @negative_shape_cast_transpose
241
+ // CHECK-LABEL: @negative_transpose_of_shape_cast
241
242
// CHECK-SAME: %[[ARG:.*]]: vector<6xi8>) -> vector<2x3xi8> {
242
243
// CHECK: %[[SHAPE_CAST:.*]] = vector.shape_cast %[[ARG]] :
243
244
// CHECK: %[[TRANSPOSE:.*]] = vector.transpose %[[SHAPE_CAST]]
244
245
// CHECK: return %[[TRANSPOSE]] : vector<2x3xi8>
245
- func.func @negative_shape_cast_transpose (%arg : vector <6 xi8 >) -> vector <2 x3 xi8 > {
246
+ func.func @negative_transpose_of_shape_cast (%arg : vector <6 xi8 >) -> vector <2 x3 xi8 > {
246
247
%0 = vector.shape_cast %arg : vector <6 xi8 > to vector <3 x2 xi8 >
247
248
%1 = vector.transpose %0 , [1 , 0 ] : vector <3 x2 xi8 > to vector <2 x3 xi8 >
248
249
return %1 : vector <2 x3 xi8 >
0 commit comments