Page MenuHomePhabricator

Create Opt Reduction Pass

Authored by msifontes on Jul 28 2020, 11:43 AM.



Implement a pass for the MLIR Reduce tool that runs any MLIR transformation pass and only replaces the output if the transformed version is smaller and still interesting to the tool. Depends on the commit: 05859f7e00ff Create Reduction Tree Pass in the following revision:

Call the pass with SymbolDCEPass as optimization pass in the tool's main function.

Diff Detail

Event Timeline

msifontes created this revision.Jul 28 2020, 11:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2020, 11:43 AM
msifontes requested review of this revision.Jul 28 2020, 11:43 AM

Include only the new changes in this commit.

Harbormaster completed remote builds in B66070: Diff 281317.
jpienaar added inline comments.Aug 17 2020, 8:42 AM

Nit: prefer member functions before data


I don't see this constructor? Wouldn't one need to pass in a pass here?




What about

if (ReductionNode* transformed = singleTransform())

utils.updateGoldenModule(module, transformed->getModule().clone());



Where is this memory reclaimed?


Prefer early exits:

if (initNode->variantsEmpty()) return initNode;

msifontes updated this revision to Diff 286062.EditedAug 17 2020, 10:15 AM

Refactor Optimization Pass

Create two static reduction nodes instead of a two level reduction tree.

Add -test-pass option to main in order to test individual passes and different pipelines.

Modify tests to use the -test-pass option.

NFC: Fix Typo

Add missing new line in simple-test.mlir

msifontes marked 6 inline comments as done.Aug 17 2020, 10:43 AM
jpienaar accepted this revision.Aug 18 2020, 8:20 AM

Nice, thanks


Need C++ file type designator here


I don't think this is needed here


Prefer to use include path here (e.g., mlir/Reducer/ReductionNode.h)


Move this to the cpp file


s/mlir-opt/optimization/ ? (mlir-opt is the tool that can be used to test the passes, but the passes are not the tool's)


Could PassPipelineCLParser be reused here? (at least for the optimization passes). See ir-printing.mlir test as an example usage with specific prefix. Can also be refined later so add a TODO for now in that case. It feels like one needs the same concept here of a reduction pipeline, where I'd think we could reuse a lot of that parsing with just some extra pass registrations here so that the pass pipeline parsing could be used here.

This revision is now accepted and ready to land.Aug 18 2020, 8:20 AM
msifontes updated this revision to Diff 286305.Aug 18 2020, 9:11 AM
msifontes marked 6 inline comments as done.

Apply requested changes

  • Add TODO to use PassPipelineCLParser instead of -test-pass option to define specific pipelines in the command line.
  • Formatting changes.
msifontes updated this revision to Diff 286321.Aug 18 2020, 9:44 AM

NFC: Amend commit message

This revision was landed with ongoing or failed builds.Aug 18 2020, 9:47 AM
This revision was automatically updated to reflect the committed changes.