[Mlir-commits] [mlir] [mlir] Compose expand of collapse to cast (PR #172864)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Dec 22 15:49:31 PST 2025
================
@@ -1193,6 +1193,42 @@ func.func @collapse_expand_fold_to_cast(%m: memref<?xf32, strided<[1]>, 3>, %sz0
// -----
+// CHECK-LABEL: func @expand_collapse_fold_to_cast(
+// CHECK-SAME: %[[m:.*]]: memref<1x3x2x384xui8, strided<[1179648, 768, 384, 1]>>
+// CHECK: %[[casted:.*]] = memref.cast %[[m]] : memref<1x3x2x384xui8, strided<[1179648, 768, 384, 1]>> to memref<1x3x2x384xui8, strided<[2304, 768, 384, 1]>>
----------------
MaheshRavishankar wrote:
I am not sure this cast is valid. It is changing the strides of the outer-most dimension... If you think of access into the memrefs using `sum(index[i] * stride[i])` for the same indices, `%casted` and `%m` are accessing different strides. I am not sure this is valid. Actually looking at the input, this is an interesting case. By themselves the operations are valid, but they cannot be folded into a cast operation.
https://github.com/llvm/llvm-project/pull/172864
More information about the Mlir-commits
mailing list