Skip to content

Commit 1179bf2

Browse files
[fixup] Add some negative tests with dynamic dimensions
1 parent 3b88a09 commit 1179bf2

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

mlir/test/Dialect/Vector/vector-transfer-flatten.mlir

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,29 @@ func.func @transfer_read_leading_dynamic_dims(
188188

189189
// -----
190190

191-
// One of the dims to be flattened is dynamic - not supported ATM.
191+
// The vector could be a non-contiguous slice of the input
192+
// memref.
193+
194+
func.func @negative_transfer_read_dynamic_dim_to_flatten(
195+
%mem : memref<4x?x?x2xi8>) -> vector<2x2x2xi8> {
196+
197+
%c0 = arith.constant 0 : index
198+
%cst = arith.constant 0 : i8
199+
%res = vector.transfer_read %mem[%c0, %c0, %c0, %c0], %cst :
200+
memref<4x?x?x2xi8>, vector<2x2x2xi8>
201+
return %res : vector<2x2x2xi8>
202+
}
203+
204+
// CHECK-LABEL: func.func @negative_transfer_read_dynamic_dim_to_flatten(
205+
// CHECK-NOT: memref.collapse_shape
206+
// CHECK-NOT: vector.shape_cast
207+
208+
// CHECK-128B-LABEL: func @negative_transfer_read_dynamic_dim_to_flatten(
209+
// CHECK-128B-NOT: memref.collapse_shape
210+
211+
// -----
212+
213+
// Can flatten the righmost dynamic dimension
192214

193215
func.func @transfer_read_dynamic_dim_to_flatten(
194216
%idx_1: index,
@@ -464,8 +486,28 @@ func.func @transfer_write_leading_dynamic_dims(
464486
// CHECK-128B: memref.collapse_shape
465487

466488
// -----
489+
490+
// The vector could be a non-contiguous slice of the input
491+
// memref.
492+
493+
func.func @negative_transfer_write_dynamic_to_flatten(
494+
%mem : memref<4x?x?x2xi8>,
495+
%vec : vector<2x2x2xi8>) {
496+
497+
%c0 = arith.constant 0 : index
498+
vector.transfer_write %vec, %mem[%c0, %c0, %c0, %c0]
499+
: vector<2x2x2xi8>, memref<4x?x?x2xi8>
500+
return
501+
}
467502

468-
// One of the dims to be flattened is dynamic - not supported ATM.
503+
// CHECK-LABEL: func.func @negative_transfer_write_dynamic_to_flatten(
504+
// CHECK-NOT: memref.collapse_shape
505+
// CHECK-NOT: vector.shape_cast
506+
507+
// CHECK-128B-LABEL: func @negative_transfer_write_dynamic_to_flatten(
508+
// CHECK-128B-NOT: memref.collapse_shape
509+
510+
// -----
469511

470512
func.func @transfer_write_dynamic_to_flatten(
471513
%idx_1: index,
@@ -578,6 +620,8 @@ func.func @negative_out_of_bound_transfer_read(
578620

579621
// -----
580622

623+
// Can flatten the righmost dynamic dimension
624+
581625
func.func @negative_out_of_bound_transfer_write(
582626
%mem : memref<?x4x3x2xi8, strided<[24, 6, 2, 1], offset: ?>>, %vec : vector<1x1x3x2xi8>) {
583627
%c0 = arith.constant 0 : index

0 commit comments

Comments
 (0)