[Mlir-commits] [mlir] [mlir] [tensor] Add patterns to remove whole slicing of tensors (PR #107046)

Matthias Springer llvmlistbot at llvm.org
Mon Sep 9 04:21:27 PDT 2024


matthias-springer wrote:

When bufferizing a tensor operation, the buffer in which the result is materialized is determined by the tensor operands of the operations. So if some other transformation/canonicalization/folding changes the IR, it may bufferize in a different way. (Still in a functionally correct, but maybe less efficient way.) Ideally, we would have a more powerful bufferization analysis that can reason about tensor subsets/aliasing and generate the same efficient IR given two functionally equivalent input programs. (Also see this discussion [here](https://discourse.llvm.org/t/in-place-memory-bufferization/80899/7).)

I see 3 ways to address this issue (ordered from best to worst):

1. Improve the bufferization analysis, so that the bufferization framework can generate efficient output IR for a wider variety of input IR. Maybe such an analysis is no longer based on "destination-passing style". (But the reason that we have DPS is because such an analysis is difficult and DPS is a way to inject hints into the analysis.) This has come up multiple times so far, and I haven't seen anyone willing to sign up for this task so far.
2. Not using the canoncalizer pass in a compilation pipeline (between the part that generates/"prepares" tensor IR and the bufferization pass). Only run the patterns/foldings that you actually need for the lowering.
3. Not adding canonicalization/folding patterns to the canonicalizer pass that could mess with the bufferization. That's what we've been doing so far.


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


More information about the Mlir-commits mailing list