This is an archive of the discontinued LLVM Phabricator instance.

Re-apply [NFC] Generalize a couple of passes so they can operate on any FunctionLike op.
ClosedPublic

Authored by stellaraccident on Dec 13 2021, 1:23 PM.

Details

Summary
  • Generalizes passes linalg-detensorize, linalg-fold-unit-extent-dims, convert-elementwise-to-linalg.
  • I feel that more work could be done in the future (i.e. make FunctionLike into a proper OpInterface and extend actions in dialect conversion to be trait based), and this patch would be a good record of why that is useful.
  • Note for downstreams:
    • Since these passes are now generic, they do not automatically nest with pass managers set up for that.
    • If running them over nested functions, you must nest explicitly. Upstream has adopted this style but *-opt still has some uses of implicit pipelines via args. See tests for argument changes needed.
  • Addressed missed comments from the original and per-suggestion removed the assert on FunctionLike in ElementwiseToLinalg, which also is what was causing the integration test to fail.

This reverts commit aa8815e42e646a98663af4cf036dbb913ad047a7.

Diff Detail

Event Timeline

stellaraccident requested review of this revision.Dec 13 2021, 1:23 PM
mehdi_amini added inline comments.Dec 13 2021, 1:28 PM
mlir/lib/Dialect/Linalg/Transforms/ElementwiseToLinalg.cpp
130

Remove restriction on DropUnitDims.

mehdi_amini added inline comments.Dec 13 2021, 1:29 PM
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
562
570

We should be able to run applyPatternsAndFoldGreedily directly on the op here?

mehdi_amini accepted this revision.Dec 13 2021, 1:29 PM
This revision is now accepted and ready to land.Dec 13 2021, 1:29 PM
stellaraccident marked an inline comment as done.

Comments.

stellaraccident marked an inline comment as done.Dec 13 2021, 1:32 PM
This revision was landed with ongoing or failed builds.Dec 13 2021, 1:33 PM
This revision was automatically updated to reflect the committed changes.