Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify TensorPrimitive's AbsoluteOperator #92577

Merged
merged 1 commit into from
Sep 25, 2023
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 @@ -1256,28 +1256,10 @@ public static float Invoke(Vector512<float> x)
private readonly struct AbsoluteOperator : IUnaryOperator
{
public static float Invoke(float x) => MathF.Abs(x);

public static Vector128<float> Invoke(Vector128<float> x)
{
Vector128<uint> raw = x.AsUInt32();
Vector128<uint> mask = Vector128.Create((uint)0x7FFFFFFF);
return (raw & mask).AsSingle();
}

public static Vector256<float> Invoke(Vector256<float> x)
{
Vector256<uint> raw = x.AsUInt32();
Vector256<uint> mask = Vector256.Create((uint)0x7FFFFFFF);
return (raw & mask).AsSingle();
}

public static Vector128<float> Invoke(Vector128<float> x) => Vector128.Abs(x);
public static Vector256<float> Invoke(Vector256<float> x) => Vector256.Abs(x);
#if NET8_0_OR_GREATER
public static Vector512<float> Invoke(Vector512<float> x)
{
Vector512<uint> raw = x.AsUInt32();
Vector512<uint> mask = Vector512.Create((uint)0x7FFFFFFF);
return (raw & mask).AsSingle();
}
public static Vector512<float> Invoke(Vector512<float> x) => Vector512.Abs(x);
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,7 @@ public Vector<float> Invoke(Vector<float> x, Vector<float> y)
private readonly struct AbsoluteOperator : IUnaryOperator
{
public float Invoke(float x) => MathF.Abs(x);

public Vector<float> Invoke(Vector<float> x)
{
Vector<uint> raw = Vector.AsVectorUInt32(x);
Vector<uint> mask = new Vector<uint>(0x7FFFFFFF);
return Vector.AsVectorSingle(raw & mask);
}
public Vector<float> Invoke(Vector<float> x) => Vector.Abs(x);
}

private interface IUnaryOperator
Expand Down
Loading