Skip to content

Commit 62cef6c

Browse files
stephentoubmichaelgsharp
authored andcommitted
Fix some TensorPrimitives tests failing for me locally with checked builds (dotnet#101745)
This is just: - Adding tolerance checks for NFloat that are the same as for float/double - Adding tolerance for MultiplyAddEstimate that matches our other tolerances for "Estimate" functions This addresses everything failing for me locally, but it doesn't match the failure spike recently highlighted in CI.
1 parent edac015 commit 62cef6c

File tree

2 files changed

+78
-40
lines changed

2 files changed

+78
-40
lines changed

src/libraries/System.Numerics.Tensors/tests/Helpers.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.Numerics.Tensors;
77
using Xunit;
8+
using System.Runtime.InteropServices;
89

910
namespace System.Numerics.Tensors.Tests
1011
{
@@ -74,8 +75,18 @@ public static bool IsEqualWithTolerance(float expected, float actual, float? tol
7475
{
7576
return (T?)(object)halfTolerance;
7677
}
78+
else if (typeof(T) == typeof(NFloat))
79+
{
80+
if (IntPtr.Size == 8 && doubleTolerance != null)
81+
{
82+
return (T?)(object)(NFloat)doubleTolerance;
83+
}
84+
else if (IntPtr.Size == 4 && floatTolerance != null)
85+
{
86+
return (T?)(object)(NFloat)doubleTolerance;
87+
}
88+
}
7789
#endif
78-
7990
return null;
8091
}
8192

0 commit comments

Comments
 (0)