Skip to content

Commit 0960bfb

Browse files
Revise a number of TP precision tolerances (#99831)
* Revise tolerances * Remove TODOs from methods with custom tolerances.
1 parent 4a69553 commit 0960bfb

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

src/libraries/System.Numerics.Tensors/tests/TensorPrimitives.Generic.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -363,24 +363,17 @@ public static IEnumerable<object[]> SpanDestinationFunctionsToTest()
363363
yield return Create(TensorPrimitives.Atanh, T.Atanh);
364364
yield return Create(TensorPrimitives.AtanPi, T.AtanPi);
365365
yield return Create(TensorPrimitives.Atan, T.Atan);
366-
// TODO https://github.com/dotnet/runtime/issues/98861
367366
yield return Create(TensorPrimitives.Cbrt, T.Cbrt, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-13));
368367
yield return Create(TensorPrimitives.Ceiling, T.Ceiling);
369368
yield return Create(TensorPrimitives.Cos, T.Cos, trigTolerance);
370-
// TODO https://github.com/dotnet/runtime/issues/98861
371369
yield return Create(TensorPrimitives.Cosh, T.Cosh, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-14));
372-
// TODO https://github.com/dotnet/runtime/issues/98861
373370
yield return Create(TensorPrimitives.CosPi, T.CosPi, trigTolerance ?? Helpers.DetermineTolerance<T>(floatTolerance: 1e-5f));
374371
yield return Create(TensorPrimitives.DegreesToRadians, T.DegreesToRadians);
375372
yield return Create(TensorPrimitives.Exp, T.Exp);
376-
// TODO https://github.com/dotnet/runtime/issues/98861
377373
yield return Create(TensorPrimitives.Exp2, T.Exp2, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-14, floatTolerance: 1e-5f));
378-
// TODO https://github.com/dotnet/runtime/issues/98861
379374
yield return Create(TensorPrimitives.Exp10, T.Exp10, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-13, floatTolerance: 1e-5f));
380375
yield return Create(TensorPrimitives.ExpM1, T.ExpM1);
381-
// TODO https://github.com/dotnet/runtime/issues/98861
382376
yield return Create(TensorPrimitives.Exp2M1, T.Exp2M1, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-14, floatTolerance: 1e-5f));
383-
// TODO https://github.com/dotnet/runtime/issues/98861
384377
yield return Create(TensorPrimitives.Exp10M1, T.Exp10M1, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-13, floatTolerance: 1e-5f));
385378
yield return Create(TensorPrimitives.Floor, T.Floor);
386379
yield return Create(TensorPrimitives.Log, T.Log);
@@ -396,9 +389,7 @@ public static IEnumerable<object[]> SpanDestinationFunctionsToTest()
396389
yield return Create(TensorPrimitives.ReciprocalSqrtEstimate, T.ReciprocalSqrtEstimate, T.CreateTruncating(Helpers.DefaultToleranceForEstimates));
397390
yield return Create(TensorPrimitives.Round, T.Round);
398391
yield return Create(TensorPrimitives.Sin, T.Sin, trigTolerance);
399-
// TODO https://github.com/dotnet/runtime/issues/98861
400392
yield return Create(TensorPrimitives.Sinh, T.Sinh, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-14));
401-
// TODO https://github.com/dotnet/runtime/issues/98861
402393
yield return Create(TensorPrimitives.SinPi, T.SinPi, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-13, floatTolerance: 1e-4f));
403394
yield return Create(TensorPrimitives.Sqrt, T.Sqrt);
404395
yield return Create(TensorPrimitives.Tan, T.Tan, trigTolerance);
@@ -520,8 +511,7 @@ public static IEnumerable<object[]> SpanSpanDestinationFunctionsToTest()
520511
yield return Create(TensorPrimitives.Hypot, T.Hypot);
521512
yield return Create(TensorPrimitives.Ieee754Remainder, T.Ieee754Remainder);
522513
yield return Create(TensorPrimitives.Log, T.Log);
523-
// TODO https://github.com/dotnet/runtime/issues/98861
524-
yield return Create(TensorPrimitives.Pow, T.Pow, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-13, floatTolerance: 1e-4f));
514+
yield return Create(TensorPrimitives.Pow, T.Pow, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-13, floatTolerance: 1e-5f));
525515

526516
static object[] Create(SpanSpanDestinationDelegate tensorPrimitivesMethod, Func<T, T, T> expectedMethod, T? tolerance = null)
527517
=> new object[] { tensorPrimitivesMethod, expectedMethod, tolerance };
@@ -650,8 +640,7 @@ public static IEnumerable<object[]> SpanScalarDestinationFunctionsToTest()
650640
yield return Create(TensorPrimitives.Atan2Pi, T.Atan2Pi);
651641
yield return Create(TensorPrimitives.CopySign, T.CopySign);
652642
yield return Create(TensorPrimitives.Ieee754Remainder, T.Ieee754Remainder);
653-
// TODO https://github.com/dotnet/runtime/issues/98861
654-
yield return Create(TensorPrimitives.Pow, T.Pow, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-13, floatTolerance: 1e-4f));
643+
yield return Create(TensorPrimitives.Pow, T.Pow, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-13, floatTolerance: 1e-5f));
655644
yield return Create(TensorPrimitives.Log, T.Log);
656645
yield return Create(TensorPrimitives.Max, T.Max);
657646
yield return Create(TensorPrimitives.MaxMagnitude, T.MaxMagnitude);
@@ -755,8 +744,7 @@ public static IEnumerable<object[]> ScalarSpanFloatDestinationFunctionsToTest()
755744
{
756745
yield return Create(TensorPrimitives.Atan2, T.Atan2);
757746
yield return Create(TensorPrimitives.Atan2Pi, T.Atan2Pi);
758-
// TODO https://github.com/dotnet/runtime/issues/98861
759-
yield return Create(TensorPrimitives.Pow, T.Pow, Helpers.DetermineTolerance<T>(floatTolerance: 1e-4f));
747+
yield return Create(TensorPrimitives.Pow, T.Pow, Helpers.DetermineTolerance<T>(floatTolerance: 1e-5f));
760748
yield return Create(TensorPrimitives.Ieee754Remainder, T.Ieee754Remainder);
761749

762750
static object[] Create(ScalarSpanDestinationDelegate tensorPrimitivesMethod, Func<T, T, T> expectedMethod, T? tolerance = null)
@@ -854,7 +842,6 @@ public void SpanScalarFloatDestination_ThrowsForOverlapppingInputsWithOutputs(Sc
854842
#region Span,Int,Span -> Destination
855843
public static IEnumerable<object[]> SpanIntDestinationFunctionsToTest()
856844
{
857-
// TODO https://github.com/dotnet/runtime/issues/98861
858845
yield return Create(TensorPrimitives.RootN, T.RootN, Helpers.DetermineTolerance<T>(doubleTolerance: 1e-13));
859846
yield return Create(TensorPrimitives.ScaleB, T.ScaleB);
860847

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,6 @@ public void Cosh_ValueRange()
663663
{
664664
if (!IsFloatingPoint) return;
665665

666-
// TODO https://github.com/dotnet/runtime/issues/98861
667666
T? tolerance = Helpers.DetermineTolerance<T>(doubleTolerance: 1e-14);
668667

669668
Assert.All(VectorLengthAndIteratedRange(ConvertFromSingle(-100f), ConvertFromSingle(100f), ConvertFromSingle(3f)), arg =>
@@ -955,8 +954,7 @@ public void Dot_ThrowsForMismatchedLengths_x_y()
955954
[Fact]
956955
public void Dot_AllLengths()
957956
{
958-
// TODO https://github.com/dotnet/runtime/issues/98861
959-
T? tolerance = Helpers.DetermineTolerance<T>(doubleTolerance: 1e-14f, floatTolerance: 1e-3f);
957+
T? tolerance = Helpers.DetermineTolerance<T>(doubleTolerance: 1e-14f, floatTolerance: 1e-5f);
960958

961959
Assert.All(Helpers.TensorLengthsIncluding0, tensorLength =>
962960
{
@@ -2885,7 +2883,6 @@ public void Sinh_ValueRange()
28852883
{
28862884
if (!IsFloatingPoint) return;
28872885

2888-
// TODO https://github.com/dotnet/runtime/issues/98861
28892886
T? tolerance = Helpers.DetermineTolerance<T>(doubleTolerance: 1e-14);
28902887

28912888
Assert.All(VectorLengthAndIteratedRange(ConvertFromSingle(-100f), ConvertFromSingle(100f), ConvertFromSingle(3f)), args =>
@@ -3148,7 +3145,6 @@ public void Subtract_TensorScalar_ThrowsForOverlapppingInputsWithOutputs()
31483145
[Fact]
31493146
public void Sum_AllLengths()
31503147
{
3151-
// TODO https://github.com/dotnet/runtime/issues/98861
31523148
T? tolerance = Helpers.DetermineTolerance<T>(doubleTolerance: 1e-13, floatTolerance: 1e-5f);
31533149

31543150
Assert.All(Helpers.TensorLengths, tensorLength =>
@@ -3169,7 +3165,6 @@ public void Sum_AllLengths()
31693165
[Fact]
31703166
public void SumOfMagnitudes_AllLengths()
31713167
{
3172-
// TODO https://github.com/dotnet/runtime/issues/98861
31733168
T? tolerance = Helpers.DetermineTolerance<T>(doubleTolerance: 1e-12, floatTolerance: 1e-6f);
31743169

31753170
Assert.All(Helpers.TensorLengths, tensorLength =>
@@ -3191,7 +3186,6 @@ public void SumOfMagnitudes_AllLengths()
31913186
[Fact]
31923187
public void SumOfSquares_AllLengths()
31933188
{
3194-
// TODO https://github.com/dotnet/runtime/issues/98861
31953189
T? tolerance = Helpers.DetermineTolerance<T>(doubleTolerance: 1e-12, floatTolerance: 1e-6f);
31963190

31973191
Assert.All(Helpers.TensorLengths, tensorLength =>

0 commit comments

Comments
 (0)