This is an archive of the discontinued LLVM Phabricator instance.

Add support for moving reductions to outer most dimensions in vector.multi_reduction
ClosedPublic

Authored by harsh on Aug 6 2021, 3:44 PM.

Details

Summary

The approach for handling reductions in the outer most
dimension follows that for inner most dimensions, outlined
below

  • First, transpose to move reduction dims, if needed
  • Convert reduction from n-d to 2-d canonical form

Then, for outer reductions, we emit the appropriate op
(add/mul/min/max/or/and/xor) and combine the results.

Diff Detail

Event Timeline

harsh created this revision.Aug 6 2021, 3:44 PM
harsh requested review of this revision.Aug 6 2021, 3:44 PM
ThomasRaoux accepted this revision.Aug 9 2021, 2:25 PM
ThomasRaoux added a subscriber: ThomasRaoux.
ThomasRaoux added inline comments.
mlir/lib/Dialect/Vector/VectorTransforms.cpp
3671

nit: spell out the type here as it not not obvious. I would potentially do it for elementType and srcShape as well. In general the rule is that if the type is obvious you should use auto otherwise you should spell out the type.

https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable

3674

nit: should be int64_t to be consistent with srcShape[0]?

This revision is now accepted and ready to land.Aug 9 2021, 2:25 PM
harsh updated this revision to Diff 366324.Aug 13 2021, 11:41 AM

Added explicit type annotations as per comments.

harsh marked 2 inline comments as done.Aug 13 2021, 11:42 AM
ThomasRaoux accepted this revision.Aug 13 2021, 11:48 AM

Nice, thanks for adding this lowering @harsh !