Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void Cbrt<T>(ReadOnlySpan<T> x, Span<T> destination)
private readonly struct CbrtOperator<T> : IUnaryOperator<T, T>
where T : IRootFunctions<T>
{
public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double);
public static bool Vectorizable => false; // typeof(T) == typeof(float) || typeof(T) == typeof(double); // TODO: https://github.com/dotnet/runtime/issues/100535

public static T Invoke(T x) => T.Cbrt(x);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static Vector512<T> Invoke(Vector512<T> x)
private readonly struct LogBaseOperator<T> : IBinaryOperator<T>
where T : ILogarithmicFunctions<T>
{
public static bool Vectorizable => LogOperator<T>.Vectorizable;
public static bool Vectorizable => false; //LogOperator<T>.Vectorizable; // TODO: https://github.com/dotnet/runtime/issues/100535
public static T Invoke(T x, T y) => T.Log(x, y);
public static Vector128<T> Invoke(Vector128<T> x, Vector128<T> y) => LogOperator<T>.Invoke(x) / LogOperator<T>.Invoke(y);
public static Vector256<T> Invoke(Vector256<T> x, Vector256<T> y) => LogOperator<T>.Invoke(x) / LogOperator<T>.Invoke(y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void Pow<T>(T x, ReadOnlySpan<T> y, Span<T> destination)
private readonly struct PowOperator<T> : IBinaryOperator<T>
where T : IPowerFunctions<T>
{
public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double);
public static bool Vectorizable => false; // typeof(T) == typeof(float) || typeof(T) == typeof(double); // TODO: https://github.com/dotnet/runtime/issues/100535

public static T Invoke(T x, T y) => T.Pow(x, y);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private readonly struct RootNOperator<T>(int n) : IStatefulUnaryOperator<T> wher
{
private readonly int _n = n;

public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double);
public static bool Vectorizable => false; // typeof(T) == typeof(float) || typeof(T) == typeof(double); // TODO: https://github.com/dotnet/runtime/issues/100535

public T Invoke(T x) => T.RootN(x, _n);

Expand Down
10 changes: 10 additions & 0 deletions src/libraries/System.Numerics.Tensors/tests/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,23 @@ private static class DefaultTolerance<T> where T : unmanaged, INumber<T>

public static bool IsEqualWithTolerance<T>(T expected, T actual, T? tolerance = null) where T : unmanaged, INumber<T>
{
if (T.IsNaN(expected) != T.IsNaN(actual))
{
return false;
}

tolerance = tolerance ?? DefaultTolerance<T>.Value;
T diff = T.Abs(expected - actual);
return !(diff > tolerance && diff > T.Max(T.Abs(expected), T.Abs(actual)) * tolerance);
}
#else
public static bool IsEqualWithTolerance(float expected, float actual, float? tolerance = null)
{
if (float.IsNaN(expected) != float.IsNaN(actual))
{
return false;
}

tolerance ??= DefaultFloatTolerance;
float diff = MathF.Abs(expected - actual);
return !(diff > tolerance && diff > MathF.Max(MathF.Abs(expected), MathF.Abs(actual)) * tolerance);
Expand Down