Cleanup TensorPrimitives#127916
Open
lilinus wants to merge 4 commits intodotnet:mainfrom
Open
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-numerics-tensors |
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR modernizes TensorPrimitives’ vector paths by removing #if !NET fallback implementations and switching call sites to use the Vector128/256/512 APIs directly (e.g., Vector*.IsNaN, Vector*.IsPositive/IsNegative, Vector*.Min/Max).
Changes:
- Replaced internal/helper predicates (e.g.,
IsNaN,IsPositive,IsNegative) with directVector128/256/512calls. - Removed
#if !NETfallback implementations forExp,Log, andLog2operators. - Simplified vector
Min/Maxoperators to expression-bodied calls toVector*.Min/Max.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Sign.cs | Uses Vector*.IsNaN directly for NaN detection in Sign. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Round.cs | Removes #if !NET boundary constants previously used for fallback rounding logic. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Min.cs | Drops #if !NET float/double special-casing; always uses Vector*.Min. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Max.cs | Drops #if !NET float/double special-casing; always uses Vector*.Max and removes helper predicates. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Log2.cs | Removes #if !NET polynomial/vector fallback implementations for Log2. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Log.cs | Removes #if !NET polynomial/vector fallback implementations for Log. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Exp.cs | Removes #if !NET polynomial/vector fallback implementations for Exp. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IsRealNumber.cs | Switches to direct Vector*.IsNaN for vectorized real-number testing. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IsPositive.cs | Switches to direct Vector*.IsPositive in vectorized paths. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IsNegative.cs | Switches to direct Vector*.IsNegative in vectorized paths. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IsNaN.cs | Switches to direct Vector*.IsNaN in vectorized paths. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IndexOfMinMagnitude.cs | Replaces helper sign checks with Vector*.IsNegative/IsPositive. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IndexOfMin.cs | Replaces helper sign checks with Vector*.IsNegative/IsPositive. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IndexOfMaxMagnitude.cs | Replaces helper sign checks with Vector*.IsNegative/IsPositive. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.IndexOfMax.cs | Replaces helper sign checks with Vector*.IsNegative/IsPositive. |
| src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Common/TensorPrimitives.IIndexOfMinMaxOperator.cs | Replaces NaN detection helper with Vector*.IsNaN during vectorized scans. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#if !NETdirectives but the files are only compiled forNETCoreApp.IsNan/IsPositive/IsNegativehelpers and just use the methods on vector classes directly.