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 (#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 May 2, 2024
1 parent f95a76b commit fc76b1c
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 @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;

namespace System.Numerics.Tensors.Tests
{
Expand Down Expand Up @@ -72,8 +73,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 fc76b1c

Please sign in to comment.