This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Add LLVM lowering for masked reductions
ClosedPublic

Authored by dcaballe on Jan 19 2023, 10:17 PM.

Details

Summary

This patch adds the conversion patterns to lower masked reduction
operations to the corresponding vp intrinsics in LLVM.

Diff Detail

Event Timeline

dcaballe created this revision.Jan 19 2023, 10:17 PM
Herald added a reviewer: ftynse. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
dcaballe requested review of this revision.Jan 19 2023, 10:17 PM
ftynse accepted this revision.Jan 20 2023, 6:28 AM
ftynse added inline comments.
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
498–520

Is this consistent with the NaN-propagation semantics of the related intrinsics? (I would expect negative/positive infinity as neutral for max/min).

810–840

Do you expect other uses for this? Otherwise, it can be merged into its only derived class.

This revision is now accepted and ready to land.Jan 20 2023, 6:28 AM

Thanks for the review!

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
498–520

Good point! The doc says: The neutral value is dependent on the fast-math flags. If no flags are set, the neutral value is -QNAN. If nnan and ninf are both set, then the neutral value is the smallest floating-point value for the result type. If only nnan is set then the neutral value is -Infinity. so I thought -QNAN would be the best fit for now until the min/max semantics in MLIR are revisited: https://discourse.llvm.org/t/rfc-explicitly-specifying-nan-and-signed-zero-semantics-for-minf-and-maxf/67539/25. Happy to change it if I'm missing something!

810–840

Yep, that's the idea. Any other masked vector op, or llvm op in general will implement a subclass.

This revision was landed with ongoing or failed builds.Feb 14 2023, 10:15 PM
This revision was automatically updated to reflect the committed changes.