You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TensorPrimitives.IndexOfMaxMagnitude can't handle signed min values #127610
Current implementation of TensorPrimitives.IndexOfMaxMagnitude (and IndexOfMinMagnitude) does not handle signed minimum values (e.g. int.MinValue) since the Abs operator is overflowing.
Reproduction Steps
var len = 500;
var x = new int[len];
x[0] = int.MinValue;
x[^1] = int.MinValue;
var i = TensorPrimitives.IndexOfMaxMagnitude(x);
Console.WriteLine(i);
Expected behavior
Should print 0
Actual behavior
Either gives wrong answer (1) when on vectorized path and throws OverflowException on non-vectorized path.
Activity
dotnet-policy-service commentedon Apr 30, 2026
Tagging subscribers to this area: @dotnet/area-system-numerics-tensors
See info in area-owners.md if you want to be subscribed.
Fix TensorPrimitives.IndexOfMax (dotnet#127454)
Fix TensorPrimitives.IndexOfMax (#127454)