[Mlir-commits] [mlir] [MLIR] Determine contiguousness of memrefs with dynamic dimensions (PR #142421)
Momchil Velikov
llvmlistbot at llvm.org
Wed Jun 18 02:09:38 PDT 2025
================
@@ -188,9 +188,31 @@ func.func @transfer_read_leading_dynamic_dims(
// -----
-// One of the dims to be flattened is dynamic - not supported ATM.
+// The vector could be a non-contiguous slice of the input
+// memref.
func.func @negative_transfer_read_dynamic_dim_to_flatten(
+ %mem : memref<4x?x?x2xi8>) -> vector<2x2x2xi8> {
+
+ %c0 = arith.constant 0 : index
+ %cst = arith.constant 0 : i8
+ %res = vector.transfer_read %mem[%c0, %c0, %c0, %c0], %cst :
+ memref<4x?x?x2xi8>, vector<2x2x2xi8>
+ return %res : vector<2x2x2xi8>
+}
+
+// CHECK-LABEL: func.func @negative_transfer_read_dynamic_dim_to_flatten(
+// CHECK-NOT: memref.collapse_shape
+// CHECK-NOT: vector.shape_cast
+
+// CHECK-128B-LABEL: func @negative_transfer_read_dynamic_dim_to_flatten(
+// CHECK-128B-NOT: memref.collapse_shape
+
+// -----
+
+// Can flatten the righmost dynamic dimension
----------------
momchil-velikov wrote:
As everywhere, can flatten because read/written area is contiguous. This is the whole premise of the transformation and the test files, I didn't think it needed more explanation.
Such an explanation of program logic (or in this case, a theorem "from these and these properties it follows the area is contiguous") is in appropriate in a test file.
https://github.com/llvm/llvm-project/pull/142421
More information about the Mlir-commits
mailing list