Skip to content

Commit fc76b1c

Browse files
authored
Fix some TensorPrimitives tests failing for me locally with checked builds (#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 f95a76b commit fc76b1c

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
@@ -3,6 +3,7 @@
33

44
using System.Collections.Generic;
55
using System.Linq;
6+
using System.Runtime.InteropServices;
67

78
namespace System.Numerics.Tensors.Tests
89
{
@@ -72,8 +73,18 @@ public static bool IsEqualWithTolerance(float expected, float actual, float? tol
7273
{
7374
return (T?)(object)halfTolerance;
7475
}
76+
else if (typeof(T) == typeof(NFloat))
77+
{
78+
if (IntPtr.Size == 8 && doubleTolerance != null)
79+
{
80+
return (T?)(object)(NFloat)doubleTolerance;
81+
}
82+
else if (IntPtr.Size == 4 && floatTolerance != null)
83+
{
84+
return (T?)(object)(NFloat)doubleTolerance;
85+
}
86+
}
7587
#endif
76-
7788
return null;
7889
}
7990
}

0 commit comments

Comments
 (0)