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.Exp<double> returns negative infinity instead of 0 for doubles between approximately -709.5 and -709.7 #107838
TensorPrimitives.Exp returns negative infinity instead of 0 for doubles between approximately -709.5 and -709.7.
When using Math.Exp() it correctly returns 0.
when using float also everything is fine.
I'm using System.Numerics.Tensors version 9.0.0-rc.1.24431.7
Reproduction Steps
doublevalue=-709.5;//with -709.4 and -709.8 everything works finedouble[]test=[value,value,value,value,value];double[]destination=newdouble[test.Length];TensorPrimitives.Exp<double>(test,destination);Console.WriteLine(string.Join(' ',destination));
Expected behavior
the above code should output 0 or values close to 0
Actual behavior
Output on my machine: -Infinity -Infinity -Infinity -Infinity -Infinity
I would appreciate if you can explain what happened here.
The code has a fallback code path for edge case values, which these are. The vectorized implementation of that fallback is producing different answers than the scalar implementation.
Activity
dotnet-policy-service commentedon Sep 15, 2024
Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.
BarionLP commentedon Sep 15, 2024
Same on my Surface Pro X (ARM64, 128bit simd) and an old HP ProBook (Intel Core i7 x64, 256bit simd)
stephentoub commentedon Sep 16, 2024
cc: @tannergooding
stephentoub commentedon Sep 16, 2024
Something about the vectorized implementation of Exp, e.g. this:
outputs this (vectorization will kick in for at least two doubles):
BarionLP commentedon Sep 16, 2024
I would appreciate if you can explain what happened here.
I love low level performance and would like to learn more about it.
dotnet-policy-service commentedon Sep 17, 2024
Tagging subscribers to this area: @dotnet/area-system-numerics-tensors
See info in area-owners.md if you want to be subscribed.
stephentoub commentedon Sep 17, 2024
The code has a fallback code path for edge case values, which these are. The vectorized implementation of that fallback is producing different answers than the scalar implementation.
BarionLP commentedon Oct 17, 2024
can confirm fix in .NET 9 RC 2