Skip to content

Commit

Permalink
Fix some TensorPrimitives tests failing for me locally with checked b…
Browse files Browse the repository at this point in the history
…uilds (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.
  • Loading branch information
stephentoub authored and michaelgsharp committed May 8, 2024
1 parent edac015 commit 62cef6c
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 40 deletions.
13 changes: 12 additions & 1 deletion src/libraries/System.Numerics.Tensors/tests/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Numerics.Tensors;
using Xunit;
using System.Runtime.InteropServices;

namespace System.Numerics.Tensors.Tests
{
Expand Down Expand Up @@ -74,8 +75,18 @@ public static bool IsEqualWithTolerance(float expected, float actual, float? tol
{
return (T?)(object)halfTolerance;
}
else if (typeof(T) == typeof(NFloat))
{
if (IntPtr.Size == 8 && doubleTolerance != null)
{
return (T?)(object)(NFloat)doubleTolerance;
}
else if (IntPtr.Size == 4 && floatTolerance != null)
{
return (T?)(object)(NFloat)doubleTolerance;
}
}
#endif

return null;
}

Expand Down
Loading

0 comments on commit 62cef6c

Please sign in to comment.