Skip to content

Ensure that the TensorPrimitives.Min/MaxNumber functions follow the IEEE 754:2019 spec #102162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2024

Conversation

tannergooding
Copy link
Member

This resolves #102156

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


Vector128<T> max;

if (Sse.IsSupported && typeof(T) == typeof(float))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: presumably this change is unrelated to the test fix at hand, would it be possible to update the PR title/commit message to include this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a change. It's preserving the behavior and perf for xarch from prior to this PR

Copy link
Member Author

@tannergooding tannergooding May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is, Vector128.Min on xarch currently emits minps/minpd (Sse.Min for float and Sse2.Min for double) while on Arm64 it emits fmin.

We therefore cannot use Vector128.Min on Arm64 since it propagates NaN (and longterm wouldn't work for xarch either, as we're working towards ensuring consistency there). But, it's safe to continue using the underlying intrsinsics for xarch as part of the MinNumber algorithm and thus allows us to preserve codegen as-is there.

(same general commentary applies to MaxNumber)

Co-authored-by: Stephen Toub <stoub@microsoft.com>
@tannergooding tannergooding merged commit 29cb8a6 into dotnet:main May 13, 2024
80 of 83 checks passed
@tannergooding tannergooding deleted the fix-102156 branch May 13, 2024 21:19
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull request May 30, 2024
…EEE 754:2019 spec (dotnet#102162)

* Ensure that the TensorPrimitives.Min/MaxNumber functions follow the IEEE 754:2019 spec

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>

---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure for TensorPrimitives MinNumber and MaxNumber on Arm64
3 participants