This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Add folding for masked reductions and vector.mask
ClosedPublic

Authored by dcaballe on Feb 20 2023, 10:32 AM.

Details

Summary

This patch adds support for folding trivial masked reductions and
multi-reductions (e.g., multi-reductions with only parallel dims,
reductions of a single element, etc.). To support those foldings in
a composable way we also add support for folding different flavors of
empty vector.mask opertions.

Diff Detail

Event Timeline

dcaballe created this revision.Feb 20 2023, 10:32 AM
dcaballe requested review of this revision.Feb 20 2023, 10:32 AM

Looks good overall, added few nits

mlir/lib/Dialect/Vector/IR/VectorOps.cpp
372

nit: do you need this cast? The functions should be accessible from MultiDimReductionOp

5512

this is not used? Remove?

5606

nit: this might be worth adding a helper if you use that in a few places.

dcaballe updated this revision to Diff 499344.Feb 21 2023, 6:39 PM
dcaballe marked 2 inline comments as done.

Addressed feedback

mlir/lib/Dialect/Vector/IR/VectorOps.cpp
372

Thanks! I have a quite a few castings to remove all over the place now :)

ThomasRaoux accepted this revision.Feb 21 2023, 7:27 PM
This revision is now accepted and ready to land.Feb 21 2023, 7:27 PM
This revision was landed with ongoing or failed builds.Feb 21 2023, 10:51 PM
This revision was automatically updated to reflect the committed changes.