[Mlir-commits] [mlir] [mlir][Bufferization] Fix to_buffer(tensor.cast) folder (PR #150511)
Adrian Kuegel
llvmlistbot at llvm.org
Tue Aug 5 05:47:53 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:
I don't know what to make out of this, but it looks like some Tensorflow tests started failing due to this early return. If I change it to this code and remove the return failure(), the test passes again:
```
Type memrefType;
if (currentOutputMemRefType) {
memrefType = MemRefType::get(srcTensorType.getShape(),
srcTensorType.getElementType(),
currentOutputMemRefType.getLayout(),
currentOutputMemRefType.getMemorySpace());
} else {
memrefType = MemRefType::get(srcTensorType.getShape(),
srcTensorType.getElementType());
}
```
https://github.com/llvm/llvm-project/pull/150511
More information about the Mlir-commits
mailing list