This is an archive of the discontinued LLVM Phabricator instance.

Create ReductionTree and ReductionNode classes
AbandonedPublic

Authored by msifontes on Jul 12 2020, 7:56 PM.

Details

Reviewers
jpienaar
tpopp
Summary

Implement the ReductionNode and ReductionTree data structures for the purpose of creating a framework to track the reductions within each pass in the MLIR Reduce tool.
This is a flexible framework that offers a general structure for the reduction implementation while allowing for different transformations to be integrated depending on the reduction pass objective.

Diff Detail

Event Timeline

msifontes created this revision.Jul 12 2020, 7:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 12 2020, 7:56 PM
msifontes updated this revision to Diff 277319.Jul 12 2020, 8:00 PM

Delete commented out function call in mlir-reduce.cpp

msifontes updated this revision to Diff 277320.Jul 12 2020, 8:03 PM

Formatting changes

mehdi_amini added inline comments.Jul 12 2020, 8:34 PM
mlir/include/mlir/Reducer/ReductionNode.h
19

(please fix the clang-tidy warning)

21

Is this needed in this header?

25

Same as above: is this include needed here?

53

Seems like this could return a const & to the member vector, and I think we wouldn't need the getVariant API (because getVariants()[i]would just work)

63

Could/should this be a vector of unique_ptr?

mlir/include/mlir/Reducer/ReductionTree.h
47

Can this be a unique_ptr?

51

(nit: fix clang-tidy naming)

mlir/tools/mlir-reduce/ReductionNode.cpp
93

Nit: replace at with subscript operator[]

mlir/tools/mlir-reduce/ReductionTree.cpp
41

You don't take ownership of the callback, so seems like a case to use llvm::function_ref instead of std::function

53

Side-note: I'm still unsure why the "tester" is the right place to keep track of the most reduced module)

jpienaar added inline comments.Jul 13 2020, 9:04 AM
mlir/include/mlir/Reducer/ReductionTree.h
33

As discussed offline, lets explore making this a module pass parameterized on a reducer class which has a generateVariants method and then can use pass manager.

msifontes marked 9 inline comments as done.

Apply requested changes

  • Delete getVariant method
  • Modify getVariants return type
  • Formatting changes
  • Replace std::function with llvm::function_ref

Will make the unique_ptr changes in the following update along with making the reduction tree a module pass and use the pass manager.

msifontes added inline comments.Jul 13 2020, 11:50 AM
mlir/tools/mlir-reduce/ReductionTree.cpp
53

Currently, the tester is the only object that gets passed from one pass to another in the reduction pipeline. The 'mostReduced' refers to the most reduced test case up to that point: it is used as the starting point in a pass and it is updated at the end of a pass if the reduction was effective. I agree it is somewhat counter intuitive so I am currently trying to refactor this.

msifontes abandoned this revision.Jul 16 2020, 10:14 AM