This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Math] Fix NaN handling in ExpM1 approximation.
ClosedPublic

Authored by akuegel on Feb 15 2022, 2:15 AM.

Details

Summary

For NaN input, output should be NaN as well.

Diff Detail

Event Timeline

akuegel created this revision.Feb 15 2022, 2:15 AM
akuegel requested review of this revision.Feb 15 2022, 2:15 AM
bkramer added inline comments.Feb 15 2022, 2:41 AM
mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
1036–1037

Would changing this to UEQ do the same thing?

akuegel updated this revision to Diff 408787.Feb 15 2022, 2:53 AM

Replace UNO with UEQ.

akuegel marked an inline comment as done.Feb 15 2022, 2:53 AM
akuegel added inline comments.
mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
1036–1037

Yes, that should work as well to detect NaN. Changed.

bkramer added inline comments.Feb 15 2022, 3:00 AM
mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
1036–1037

Sorry for being unclear. My idea was to do the one check and the NaN check with a single UEQ instead of two fcmps.

akuegel updated this revision to Diff 408793.Feb 15 2022, 3:06 AM
akuegel marked an inline comment as done.

Actually do the suggested change.

bkramer accepted this revision.Feb 15 2022, 3:07 AM

thanks

This revision is now accepted and ready to land.Feb 15 2022, 3:07 AM
akuegel added inline comments.Feb 15 2022, 3:07 AM
mlir/lib/Dialect/Math/Transforms/PolynomialApproximation.cpp
1036–1037

Ah, thanks, that is a nice observation :)
And my previous change was wrong, anyway, I can use UNE or UNO when comparing x to itself to detect NaN, but not UEQ.

This revision was landed with ongoing or failed builds.Feb 15 2022, 3:10 AM
This revision was automatically updated to reflect the committed changes.