[Mlir-commits] [mlir] [mlir][bufferization] Make alloc_tensor's bufferization customizable (PR #215590)

Victor Perez llvmlistbot at llvm.org
Wed Aug 12 07:30:47 PDT 2026


victor-eds wrote:

> Are you talking about the source operand or the result of the `collapse_shape` op? The `getBufferType` implementation of `collapse_shape` should take into account the future ("predicted") buffer type of the source operand and compute a compatible result type. (If there is no compatible result type because the "collapse" cannot be done without a new buffer copy, it will return an identity layout map, and the `bufferize` method should introduce a new buffer allocation. At least that's how I remember it.)

[Looking at the implementation](https://github.com/llvm/llvm-project/blob/6a8a09b466ae7527e0b5a24bdb49b30c2617004a/mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp#L146): we already check that, but, as we rely on calling `getBufferType` on the operand, if the "predicted" type does not match the actual type after bufferization, we may end up with the illegal code I described above.

> Can you also move all the other implementations in the bufferization dialect (to_tensor, to_buffer, etc.) to BufferizableOpInterfaceImpl.cpp? Then I'm going to take another look at this PR.

Sure thing :)


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


More information about the Mlir-commits mailing list