This is an archive of the discontinued LLVM Phabricator instance.

Create Opt Reduction Pass
ClosedPublic

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

Details

Summary

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: https://reviews.llvm.org/D83969.

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
mlir/include/mlir/Reducer/OptReductionPass.h
55

Nit: prefer member functions before data

mlir/include/mlir/Reducer/Passes.td
25

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

28

Typo

mlir/tools/mlir-reduce/OptReductionPass.cpp
35

What about

if (ReductionNode* transformed = singleTransform())

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

?

52

Where is this memory reclaimed?

55

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

mlir/include/mlir/Reducer/OptReductionPass.h
1

Need C++ file type designator here

18

I don't think this is needed here

21

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

29

Move this to the cpp file

mlir/include/mlir/Reducer/Passes.td
23

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)

mlir/tools/mlir-reduce/mlir-reduce.cpp
102

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.