[Mlir-commits] [mlir] [mlir][bufferization] Make alloc_tensor's bufferization customizable (PR #215590)
Matthias Springer
llvmlistbot at llvm.org
Wed Aug 12 06:58:38 PDT 2026
matthias-springer wrote:
> We qill create an illegal shape transformation operation when bufferizing collapse_shape, > as the analysis has told us that the type carries the identity layout:
>
> ```mlir
> %alloc = memref.alloc() : memref<8x16xf32, #layout>
> %1 = memref.collapse_shape %alloc [[0, 1]] : memref<8x16xf32, #layout> into memref<128xf32> # may be illegal
> ```
This looks like a problem with the `tensor.collapse_shape` bufferization. What does this have to do we `bufferization.alloc_tensor`? The `alloc_tensor` was bufferized correctly, right?
> as the analysis has told us that the type carries the identity layout
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.)
https://github.com/llvm/llvm-project/pull/215590
More information about the Mlir-commits
mailing list