This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][SCF] Enable better bufferization for `TileConsumerAndFuseProducersUsingSCFForOp`
ClosedPublic

Authored by chelini on Jul 19 2022, 6:55 AM.

Details

Summary

Replace iterators of the outermost loop with region arguments of the innermost
one. The changes avoid later bufferization passes to insert allocation within
the body of the innermost loop.

Diff Detail

Event Timeline

chelini created this revision.Jul 19 2022, 6:55 AM
chelini requested review of this revision.Jul 19 2022, 6:55 AM
chelini retitled this revision from [MLIR][SCF] Enable better bufferization for `TileConsumerAndFuseProducersUsingSCFForOp` to [RFC][MLIR][SCF] Enable better bufferization for `TileConsumerAndFuseProducersUsingSCFForOp`.
chelini updated this revision to Diff 445812.Jul 19 2022, 7:07 AM

Small change.

mravishankar requested changes to this revision.Jul 19 2022, 10:16 AM

Thanks! Just a minor suggestion.

mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
360

Couple of suggestions here

  1. We dont need to walk the body and just replace tensor.extract_slice. It should be OK to just do
Block *block = &(*innerFor.getRegion().begin());
for (auto it : llvm::zip(outerFor.getIterOperands(), innerFor.getRegionIterArgs()) {
  Value source = std::get<0>(it);
  Value target = std::get<1>(it);
  source.replaceAllUsesWithIf(target, [&](OpOperand &use) { return use.getOwner()->getBlock() == block; });
}
  1. Not relevant here, but I think updateRootInPlace is really for the root of the pattern.
This revision now requires changes to proceed.Jul 19 2022, 10:16 AM
chelini updated this revision to Diff 446116.Jul 20 2022, 5:14 AM

Update as suggested.

chelini marked an inline comment as done.Jul 20 2022, 5:16 AM
chelini added inline comments.
mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
360

Updated. Nice solution :)

mravishankar accepted this revision.Jul 20 2022, 9:48 AM

Awesome!

This revision is now accepted and ready to land.Jul 20 2022, 9:48 AM
This revision was automatically updated to reflect the committed changes.
chelini marked an inline comment as done.
chelini reopened this revision.Jul 21 2022, 12:42 AM
This revision is now accepted and ready to land.Jul 21 2022, 12:42 AM
chelini updated this revision to Diff 446377.Jul 21 2022, 1:11 AM

Rebase on main

chelini retitled this revision from [RFC][MLIR][SCF] Enable better bufferization for `TileConsumerAndFuseProducersUsingSCFForOp` to [MLIR][SCF] Enable better bufferization for `TileConsumerAndFuseProducersUsingSCFForOp`.Jul 21 2022, 1:11 AM
This revision was landed with ongoing or failed builds.Jul 21 2022, 1:14 AM
This revision was automatically updated to reflect the committed changes.