[Mlir-commits] [mlir] [mlir][Bufferization] Fix to_buffer(tensor.cast) folder (PR #150511)
Adrian Kuegel
llvmlistbot at llvm.org
Tue Aug 5 23:32:27 PDT 2025
================
@@ -805,10 +805,18 @@ struct ToBufferOfCast : public OpRewritePattern<ToBufferOp> {
tensorCastOperand.getOperand().getType());
if (!srcTensorType)
return failure();
+ auto currentOutputMemRefType =
+ dyn_cast<MemRefType>(toBuffer.getResult().getType());
+ if (!currentOutputMemRefType)
----------------
akuegel wrote:
@matthias-springer Thanks for the hint, I tried it out and it works. We can use BaseMemRefType::cloneWith to generate the new MemRefType that will preserve layout and memory space if the output type is MemRefType. I will prepare a PR.
https://github.com/llvm/llvm-project/pull/150511
More information about the Mlir-commits
mailing list