Instead of interchanging loops during the loop lowering this pass performs the interchange by permuting the indexing maps. It also updates the iterator types and the index accesses in the body of the operation.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
The pass uses the existing LinalgInterchangePattern extended with the functionality to update the index operations in the body of the interchanged generic op. I relaxed the constraint that the pass can only run ops with buffer semantics but kept the limitation on generic operations. Should we relax these constraints to support all linalgOps?
I'd think there is very little chance that this pass is going to be useful in real compilation flows (granularity of control, need for heurisitcs, phase orderings etc etc).
I'd rather add a new case + attribute in the test pass that tests individual patterns and call it a day.
Add the pattern as option to the test pass instead of having a separate interchange pass.
mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp | ||
---|---|---|
90 | Added a TODO to fix this once all LinalgOps have a body |
Nice!
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h | ||
---|---|---|
207–208 | How about just taking an OpBuilder here ? | |
mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp | ||
68 | These days, we should be able to simplify this with something like SmallVector<AffineMap> newIndexingMaps; for (auto m : op.indexing_maps().getAsValueRange<AffineMap>()) { if (!permutationMap.isEmpty()) m = m.compose(permutationMap); newIndexingMaps.push_back(m); } op->setAttr(getIndexingMapsAttrName(), rewriter.getAffineMapArrayAttr(newIndexingMaps)); | |
90 | yes sorry this is a bad suggestion, getBlock() gives you the parent block, please disregard. |
How about just taking an OpBuilder here ?
That would be more generally applicable.