diff --git a/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.csproj b/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.csproj
index 89bdef6ea38ed..8d28b0e077d9c 100644
--- a/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.csproj
+++ b/src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj b/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj
index 097fa244ad491..be4a04702af5e 100644
--- a/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj
+++ b/src/libraries/System.Numerics.Tensors/src/System.Numerics.Tensors.csproj
@@ -16,11 +16,11 @@
-
+
-
+
diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.netcore.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.netcore.cs
index 4f40aa31494c9..ae5af404ac1af 100644
--- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.netcore.cs
+++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.netcore.cs
@@ -1159,7 +1159,9 @@ public static float Invoke(Vector512 x)
public static float Invoke(float x) => -x;
public static Vector128 Invoke(Vector128 x) => -x;
public static Vector256 Invoke(Vector256 x) => -x;
+#if NET8_0_OR_GREATER
public static Vector512 Invoke(Vector512 x) => -x;
+#endif
}
private readonly struct AddMultiplyOperator : ITernaryOperator
@@ -1167,7 +1169,9 @@ public static float Invoke(Vector512 x)
public static float Invoke(float x, float y, float z) => (x + y) * z;
public static Vector128 Invoke(Vector128 x, Vector128 y, Vector128 z) => (x + y) * z;
public static Vector256 Invoke(Vector256 x, Vector256 y, Vector256 z) => (x + y) * z;
+#if NET8_0_OR_GREATER
public static Vector512 Invoke(Vector512 x, Vector512 y, Vector512 z) => (x + y) * z;
+#endif
}
private readonly struct MultiplyAddOperator : ITernaryOperator
@@ -1175,7 +1179,9 @@ public static float Invoke(Vector512 x)
public static float Invoke(float x, float y, float z) => (x * y) + z;
public static Vector128 Invoke(Vector128 x, Vector128 y, Vector128 z) => (x * y) + z;
public static Vector256 Invoke(Vector256 x, Vector256 y, Vector256 z) => (x * y) + z;
+#if NET8_0_OR_GREATER
public static Vector512 Invoke(Vector512 x, Vector512 y, Vector512 z) => (x * y) + z;
+#endif
}
private readonly struct LoadIdentity : IUnaryOperator
diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.netstandard.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.netstandard.cs
index 134364708b8e5..ba3fc69bab527 100644
--- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.netstandard.cs
+++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.netstandard.cs
@@ -69,8 +69,8 @@ private static float CosineSimilarityCore(ReadOnlySpan x, ReadOnlySpan(
float identityValue, ReadOnlySpan x, TLoad load = default, TAggregate aggregate = default)
- where TLoad : IUnaryOperator
- where TAggregate : IBinaryOperator
+ where TLoad : struct, IUnaryOperator
+ where TAggregate : struct, IBinaryOperator
{
// Initialize the result to the identity value
float result = identityValue;
@@ -112,8 +112,8 @@ private static float Aggregate(
private static float Aggregate(
float identityValue, ReadOnlySpan x, ReadOnlySpan y, TBinary binary = default, TAggregate aggregate = default)
- where TBinary : IBinaryOperator
- where TAggregate : IBinaryOperator
+ where TBinary : struct, IBinaryOperator
+ where TAggregate : struct, IBinaryOperator
{
// Initialize the result to the identity value
float result = identityValue;
@@ -156,7 +156,7 @@ private static float Aggregate(
private static void InvokeSpanIntoSpan(
ReadOnlySpan x, Span destination, TUnaryOperator op = default)
- where TUnaryOperator : IUnaryOperator
+ where TUnaryOperator : struct, IUnaryOperator
{
if (x.Length > destination.Length)
{
@@ -203,7 +203,7 @@ private static void InvokeSpanIntoSpan(
private static void InvokeSpanSpanIntoSpan(
ReadOnlySpan x, ReadOnlySpan y, Span destination, TBinaryOperator op = default)
- where TBinaryOperator : IBinaryOperator
+ where TBinaryOperator : struct, IBinaryOperator
{
if (x.Length != y.Length)
{
@@ -258,7 +258,7 @@ private static void InvokeSpanSpanIntoSpan(
private static void InvokeSpanScalarIntoSpan(
ReadOnlySpan x, float y, Span destination, TBinaryOperator op = default)
- where TBinaryOperator : IBinaryOperator
+ where TBinaryOperator : struct, IBinaryOperator
{
if (x.Length > destination.Length)
{
@@ -309,7 +309,7 @@ private static void InvokeSpanScalarIntoSpan(
private static void InvokeSpanSpanSpanIntoSpan(
ReadOnlySpan x, ReadOnlySpan y, ReadOnlySpan z, Span destination, TTernaryOperator op = default)
- where TTernaryOperator : ITernaryOperator
+ where TTernaryOperator : struct, ITernaryOperator
{
if (x.Length != y.Length || x.Length != z.Length)
{
@@ -369,7 +369,7 @@ private static void InvokeSpanSpanSpanIntoSpan(
private static void InvokeSpanSpanScalarIntoSpan(
ReadOnlySpan x, ReadOnlySpan y, float z, Span destination, TTernaryOperator op = default)
- where TTernaryOperator : ITernaryOperator
+ where TTernaryOperator : struct, ITernaryOperator
{
if (x.Length != y.Length)
{
@@ -430,7 +430,7 @@ private static void InvokeSpanSpanScalarIntoSpan(
private static void InvokeSpanScalarSpanIntoSpan(
ReadOnlySpan x, float y, ReadOnlySpan z, Span destination, TTernaryOperator op = default)
- where TTernaryOperator : ITernaryOperator
+ where TTernaryOperator : struct, ITernaryOperator
{
if (x.Length != z.Length)
{