[Mlir-commits] [mlir] [mlir][Bufferization] Fix to_buffer(tensor.cast) folder (PR #150511)

Matthias Springer llvmlistbot at llvm.org
Tue Aug 5 05:57:33 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)
----------------
matthias-springer wrote:

I'm not sure if that's what's happening here, but it looks like this PR changes the pattern so that it no longer applies to IR such as:
```
%0 = tensor.cast %src : ranked -> unranked
%1 = bufferization.to_buffer %0
```

Should we be looking for `BaseMemRefType` here instead of `MemRefType`?


https://github.com/llvm/llvm-project/pull/150511


More information about the Mlir-commits mailing list