[Mlir-commits] [mlir] [mlir] [linalg] Add pattern to swap transpose with broadcast (PR #97063)

Diego Caballero llvmlistbot at llvm.org
Fri Jul 12 15:31:28 PDT 2024


dcaballe wrote:

Agree with Stella that this transformation, as a canonicalization, shouldn’t be driven by cost or performance considerations. The motivating factor should be to define a canonical order between these memory/data layout operations so that we can reduce the number of op combinations to be handled in other transformations. On top of that, transposing broadcasted data is transposing duplicated data so this transformation should make the IR less redundant, which is something that falls into the canonicalization territory, IMO. 

Defining a canonical order around memory/layout operations has been a long missing gap in our representation, resulting in downstreams adopting as “canonical” form whichever random order frontends or other transformations generated. This is suboptimal because these assumptions make our transformations fragile and we are more hesitant to accept changes that might alter these assumptions. 

Should this canonical representation be suitable for all the transformations? Not really. Each transformation may have a pre-processing step where the memory/layout operations can be reordered as needed. Even those pre-processing transformations would be simpler if they start from a canonical form.  

IMO, it would be hard to define and integrate a canonical form for the full lattice in one shot. However, this case looks like a no-brainer to me and it’s an incremental step towards addressing the current situation.

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


More information about the Mlir-commits mailing list