Skip to content

Reduce some boilerplate in TensorPrimitive's IBinaryOperator #92576

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

Merged
merged 1 commit into from
Sep 25, 2023
Merged
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 @@ -1099,12 +1099,6 @@ private static Vector512<float> FusedMultiplyAdd(Vector512<float> x, Vector512<f
#if NET8_0_OR_GREATER
public static Vector512<float> Invoke(Vector512<float> x, Vector512<float> y) => x - y;
#endif

public static float Invoke(Vector128<float> x) => throw new NotSupportedException();
public static float Invoke(Vector256<float> x) => throw new NotSupportedException();
#if NET8_0_OR_GREATER
public static float Invoke(Vector512<float> x) => throw new NotSupportedException();
#endif
}

private readonly struct SubtractSquaredOperator : IBinaryOperator
Expand Down Expand Up @@ -1134,12 +1128,6 @@ public static Vector512<float> Invoke(Vector512<float> x, Vector512<float> y)
return tmp * tmp;
}
#endif

public static float Invoke(Vector128<float> x) => throw new NotSupportedException();
public static float Invoke(Vector256<float> x) => throw new NotSupportedException();
#if NET8_0_OR_GREATER
public static float Invoke(Vector512<float> x) => throw new NotSupportedException();
#endif
}

private readonly struct MultiplyOperator : IBinaryOperator
Expand Down Expand Up @@ -1195,12 +1183,6 @@ public static float Invoke(Vector512<float> x)
#if NET8_0_OR_GREATER
public static Vector512<float> Invoke(Vector512<float> x, Vector512<float> y) => x / y;
#endif

public static float Invoke(Vector128<float> x) => throw new NotSupportedException();
public static float Invoke(Vector256<float> x) => throw new NotSupportedException();
#if NET8_0_OR_GREATER
public static float Invoke(Vector512<float> x) => throw new NotSupportedException();
#endif
}

private readonly struct NegateOperator : IUnaryOperator
Expand Down Expand Up @@ -1294,14 +1276,18 @@ private interface IUnaryOperator
private interface IBinaryOperator
{
static abstract float Invoke(float x, float y);

static abstract Vector128<float> Invoke(Vector128<float> x, Vector128<float> y);
static abstract float Invoke(Vector128<float> x);
static abstract Vector256<float> Invoke(Vector256<float> x, Vector256<float> y);
static abstract float Invoke(Vector256<float> x);
#if NET8_0_OR_GREATER
static abstract Vector512<float> Invoke(Vector512<float> x, Vector512<float> y);
static abstract float Invoke(Vector512<float> x);
#endif

// Operations for aggregating all lanes in a vector into a single value.
// These are not supported on most implementations.
static virtual float Invoke(Vector128<float> x) => throw new NotSupportedException();
static virtual float Invoke(Vector256<float> x) => throw new NotSupportedException();
#if NET8_0_OR_GREATER
static virtual float Invoke(Vector512<float> x) => throw new NotSupportedException();
#endif
}

Expand Down