1
1
// RUN: mlir-opt %s -canonicalize="test-convergence" -split-input-file -allow-unregistered-dialect | FileCheck %s
2
2
3
- // This file contains some canonicalizations tests involving vector.transpose.
3
+ // This file contains some tests of canonicalizations and foldings involving vector.transpose.
4
+
5
+ // +----------------------------------------
6
+ // Tests of FoldTransposeBroadcast
7
+ // +----------------------------------------
4
8
5
9
// CHECK-LABEL: func @transpose_scalar_broadcast1
6
10
// CHECK-SAME: (%[[ARG:.+]]: vector<1xf32>)
@@ -140,7 +144,10 @@ func.func @negative_broadcast_transpose_021(%arg0 : vector<3x1x3xi8>) -> vector<
140
144
141
145
// -----
142
146
143
- // Test of FoldTransposeShapeCast
147
+ // +-------------------------------------------
148
+ // Tests of FoldTransposeShapeCast
149
+ // +-------------------------------------------
150
+
144
151
// In this test, the permutation maps the non-unit dimensions (1 and 2) as follows:
145
152
// 1 -> 0
146
153
// 2 -> 4
@@ -159,7 +166,6 @@ func.func @transpose_shape_cast(%arg : vector<1x4x4x1x1xi8>) -> vector<4x4xi8> {
159
166
160
167
// -----
161
168
162
- // Test of FoldTransposeShapeCast
163
169
// In this test, the mapping of non-unit dimensions (1 and 2) is as follows:
164
170
// 1 -> 2
165
171
// 2 -> 1
@@ -179,7 +185,6 @@ func.func @negative_transpose_shape_cast(%arg : vector<1x4x4x1xi8>) -> vector<4x
179
185
180
186
// -----
181
187
182
- // Test of FoldTransposeShapeCast
183
188
// Currently the conversion shape_cast(transpose) -> shape_cast is disabled for
184
189
// scalable vectors because of bad interaction with ConvertIllegalShapeCastOpsToTransposes
185
190
// CHECK-LABEL: @negative_transpose_shape_cast_scalable
@@ -193,7 +198,10 @@ func.func @negative_transpose_shape_cast_scalable(%arg : vector<[4]x1xi8>) -> ve
193
198
194
199
// -----
195
200
196
- // Test of shape_cast folding.
201
+ // +----------------------------------------
202
+ // Tests of shape_cast folding
203
+ // +----------------------------------------
204
+
197
205
// The conversion transpose(shape_cast) -> shape_cast is not disabled for scalable
198
206
// vectors.
199
207
// CHECK-LABEL: @shape_cast_transpose_scalable
@@ -207,7 +215,6 @@ func.func @shape_cast_transpose_scalable(%arg : vector<[4]xi8>) -> vector<[4]x1x
207
215
208
216
// -----
209
217
210
- // Test of shape_cast folding.
211
218
// A transpose that is 'order preserving' can be treated like a shape_cast.
212
219
// CHECK-LABEL: @shape_cast_transpose
213
220
// CHECK-SAME: %[[ARG:.*]]: vector<2x3x1x1xi8>) -> vector<6x1x1xi8> {
@@ -223,7 +230,6 @@ func.func @shape_cast_transpose(%arg : vector<2x3x1x1xi8>) -> vector<6x1x1xi8>
223
230
224
231
// -----
225
232
226
- // Test of shape_cast folding.
227
233
// Scalable dimensions should be treated as non-unit dimensions.
228
234
// CHECK-LABEL: @shape_cast_transpose_scalable
229
235
// CHECK: vector.shape_cast
@@ -236,7 +242,6 @@ func.func @shape_cast_transpose_scalable_unit(%arg : vector<[1]x4x1xi8>) -> vect
236
242
237
243
// -----
238
244
239
- // Test of shape_cast (not) folding.
240
245
// CHECK-LABEL: @negative_shape_cast_transpose
241
246
// CHECK-SAME: %[[ARG:.*]]: vector<6xi8>) -> vector<2x3xi8> {
242
247
// CHECK: %[[SHAPE_CAST:.*]] = vector.shape_cast %[[ARG]] :
@@ -250,7 +255,10 @@ func.func @negative_shape_cast_transpose(%arg : vector<6xi8>) -> vector<2x3xi8>
250
255
251
256
// -----
252
257
253
- // Test of transpose folding
258
+ // +-----------------------------------
259
+ // Tests of transpose folding
260
+ // +-----------------------------------
261
+
254
262
// CHECK-LABEL: transpose_1D_identity
255
263
// CHECK-SAME: [[ARG:%.*]]: vector<4xf32>
256
264
// CHECK-NEXT: return [[ARG]]
@@ -261,7 +269,6 @@ func.func @transpose_1D_identity(%arg : vector<4xf32>) -> vector<4xf32> {
261
269
262
270
// -----
263
271
264
- // Test of transpose folding
265
272
// CHECK-LABEL: transpose_2D_identity
266
273
// CHECK-SAME: [[ARG:%.*]]: vector<4x3xf32>
267
274
// CHECK-NEXT: return [[ARG]]
@@ -272,11 +279,20 @@ func.func @transpose_2D_identity(%arg : vector<4x3xf32>) -> vector<4x3xf32> {
272
279
273
280
// -----
274
281
275
- // Test of transpose folding
276
282
// CHECK-LABEL: transpose_shape_and_order_preserving
277
283
// CHECK-SAME: [[ARG:%.*]]: vector<6x1x1x4xi8>
278
284
// CHECK-NEXT: return [[ARG]]
279
285
func.func @transpose_shape_and_order_preserving (%arg : vector <6 x1 x1 x4 xi8 >) -> vector <6 x1 x1 x4 xi8 > {
280
286
%0 = vector.transpose %arg , [0 , 2 , 1 , 3 ] : vector <6 x1 x1 x4 xi8 > to vector <6 x1 x1 x4 xi8 >
281
287
return %0 : vector <6 x1 x1 x4 xi8 >
282
288
}
289
+
290
+ // -----
291
+
292
+ // CHECK-LABEL: negative_transpose_fold
293
+ // CHECK: [[TRANSP:%.*]] = vector.transpose
294
+ // CHECK: return [[TRANSP]]
295
+ func.func @negative_transpose_fold (%arg : vector <2 x2 xi8 >) -> vector <2 x2 xi8 > {
296
+ %0 = vector.transpose %arg , [1 , 0 ] : vector <2 x2 xi8 > to vector <2 x2 xi8 >
297
+ return %0 : vector <2 x2 xi8 >
298
+ }
0 commit comments