Skip to content

Cleanup TensorPrimitives#127916

Open
lilinus wants to merge 4 commits intodotnet:mainfrom
lilinus:cleanup-tensor-primitives
Open

Cleanup TensorPrimitives#127916
lilinus wants to merge 4 commits intodotnet:mainfrom
lilinus:cleanup-tensor-primitives

Conversation

@lilinus
Copy link
Copy Markdown
Contributor

@lilinus lilinus commented May 7, 2026

  • Delete unused code behind #if !NET directives but the files are only compiled for NETCoreApp.
  • Delete IsNan/IsPositive/IsNegative helpers and just use the methods on vector classes directly.

Copilot AI review requested due to automatic review settings May 7, 2026 14:44
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 7, 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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 direct Vector128/256/512 calls.
  • Removed #if !NET fallback implementations for Exp, Log, and Log2 operators.
  • Simplified vector Min/Max operators to expression-bodied calls to Vector*.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

2 participants