Allow fusing linalg.tensor_reshape with its consumer when the consumer is applying a permutation map (e.g linalg.generic implementing a transpose)
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp | ||
---|---|---|
328 | I think isPermutation covers isIdentity, so maybe no need to check the first case, ie, useIndexMap.isIdentity() || ? | |
385–387 | I think we actually just want to make sure the map is invertible, so the comment is a bit not accurate. The identity map or permutation map is guaranteed to be invertible, so you don't need to check if invMap is null. |
Thanks Ahmed, just one minor comment.
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp | ||
---|---|---|
328 | Do we need to make a distinction for when it is asProducer and not. I think you can make it isPermutation always? Then you can maybe also add a test where the reshape is the consumer? |
I need to look closely into FuseTensorReshapeOpAsConsumer to see why it isn't producing the correct indexing map for the permutation case. I can do this in a follow up diff.
NVM, that was a silly test bug :D, ignore my comment.
I think isPermutation covers isIdentity, so maybe no need to check the first case, ie, useIndexMap.isIdentity() || ?