Skip to content

Fix tensor EqualWithTolerance test helper - #127868

Merged
tannergooding merged 8 commits into
dotnet:mainfrom
lilinus:fix-tensor-equal-with-tolerance
Jul 10, 2026
Merged

tannergooding merged 8 commits into
dotnet:mainfrom
lilinus:fix-tensor-equal-with-tolerance

Conversation

@lilinus

@lilinus lilinus commented May 6, 2026

Copy link
Copy Markdown
Contributor

Addresses the issues special values with IsEqualWithTolerance described in #107934.

If vectorization is enabled again then tests are failing (which is expected, since the vectorized versions give a different answer).

Copilot AI review requested due to automatic review settings May 6, 2026 14:50
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 6, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR refactors tensor test comparisons to centralize tolerance-based equality assertions, and expands test assertion utilities to support NFloat comparisons.

Changes:

  • Replace manual tolerance checks and custom exception throwing with Helpers.AssertEqualWithTolerance(...) across tensor tests.
  • Rework Helpers tolerance comparison helper from predicate-style (IsEqualWithTolerance) to assertion-style, delegating to AssertExtensions.Equal where applicable.
  • Add AssertExtensions.Equal overloads for NFloat (variance-based and bitwise-equal variants) and fix NFloat tolerance selection.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/libraries/System.Numerics.Tensors/tests/TensorPrimitives.NonGeneric.Single.cs Switches float tolerance comparison to centralized assertion helper.
src/libraries/System.Numerics.Tensors/tests/TensorPrimitives.Generic.cs Replaces several per-element tolerance checks and detailed failure messages with centralized assertions.
src/libraries/System.Numerics.Tensors/tests/Helpers.cs Introduces AssertEqualWithTolerance with scaled tolerance and routes to AssertExtensions (including NFloat), plus fixes NFloat tolerance selection.
src/libraries/Common/tests/TestUtilities/System/AssertExtensions.cs Adds NFloat equality assertions (variance-based and bitwise) with documentation.

Copilot AI review requested due to automatic review settings May 8, 2026 10:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

@tannergooding
tannergooding merged commit 7aa830a into dotnet:main Jul 10, 2026
83 of 87 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 11, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
Addresses the issues special values with IsEqualWithTolerance described
in #107934.

If
[vectorization](https://github.com/dotnet/runtime/blob/5a73be0dfd3abe369fc9b42af394711b3abf0a0e/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Pow.cs#L62)
is enabled again then tests are failing (which is expected, since the
vectorized versions give a different answer).

---------

Co-authored-by: Tanner Gooding <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Numerics.Tensors community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants