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

[release/8.0] Fix downlevel build break in TensorPrimitives #92270

Merged
merged 2 commits into from
Sep 19, 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 @@ -8,7 +8,7 @@
<Compile Include="System.Numerics.Tensors.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
<Compile Include="System.Numerics.Tensors.netcore.cs" />
</ItemGroup>
Comment on lines +11 to 13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (only for the release/8.0 branch): The compile item's name is misleading as it applies to net7.0 and net8.0 only but net6.0 is also netcore.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, since this is more in the style realm, I'll let @michaelgsharp / @stephentoub / @tannergooding consider a rename here. #92219

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having a hard time thinking of a better name. The suffix is really about the surface area it's targeting / being constrained to, which is the netstandard surface area. The fact that it's also being used in a build for a .NET Core TFM doesn't really matter, IMO.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's address this request for GA. This is blocking the RC2 snap, so I merged it as-is.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<Compile Include="System\ThrowHelper.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
<Compile Include="System\Numerics\Tensors\TensorPrimitives.netstandard.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
<Compile Include="System\Numerics\Tensors\TensorPrimitives.netcore.cs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,23 +1159,29 @@ public static float Invoke(Vector512<float> x)
public static float Invoke(float x) => -x;
public static Vector128<float> Invoke(Vector128<float> x) => -x;
public static Vector256<float> Invoke(Vector256<float> x) => -x;
#if NET8_0_OR_GREATER
public static Vector512<float> Invoke(Vector512<float> x) => -x;
#endif
}

private readonly struct AddMultiplyOperator : ITernaryOperator
{
public static float Invoke(float x, float y, float z) => (x + y) * z;
public static Vector128<float> Invoke(Vector128<float> x, Vector128<float> y, Vector128<float> z) => (x + y) * z;
public static Vector256<float> Invoke(Vector256<float> x, Vector256<float> y, Vector256<float> z) => (x + y) * z;
#if NET8_0_OR_GREATER
public static Vector512<float> Invoke(Vector512<float> x, Vector512<float> y, Vector512<float> z) => (x + y) * z;
#endif
}

private readonly struct MultiplyAddOperator : ITernaryOperator
{
public static float Invoke(float x, float y, float z) => (x * y) + z;
public static Vector128<float> Invoke(Vector128<float> x, Vector128<float> y, Vector128<float> z) => (x * y) + z;
public static Vector256<float> Invoke(Vector256<float> x, Vector256<float> y, Vector256<float> z) => (x * y) + z;
#if NET8_0_OR_GREATER
public static Vector512<float> Invoke(Vector512<float> x, Vector512<float> y, Vector512<float> z) => (x * y) + z;
#endif
}

private readonly struct LoadIdentity : IUnaryOperator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ private static float CosineSimilarityCore(ReadOnlySpan<float> x, ReadOnlySpan<fl

private static float Aggregate<TLoad, TAggregate>(
float identityValue, ReadOnlySpan<float> 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;
Expand Down Expand Up @@ -112,8 +112,8 @@ private static float Aggregate<TLoad, TAggregate>(

private static float Aggregate<TBinary, TAggregate>(
float identityValue, ReadOnlySpan<float> x, ReadOnlySpan<float> 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;
Expand Down Expand Up @@ -156,7 +156,7 @@ private static float Aggregate<TBinary, TAggregate>(

private static void InvokeSpanIntoSpan<TUnaryOperator>(
ReadOnlySpan<float> x, Span<float> destination, TUnaryOperator op = default)
where TUnaryOperator : IUnaryOperator
where TUnaryOperator : struct, IUnaryOperator
{
if (x.Length > destination.Length)
{
Expand Down Expand Up @@ -203,7 +203,7 @@ private static void InvokeSpanIntoSpan<TUnaryOperator>(

private static void InvokeSpanSpanIntoSpan<TBinaryOperator>(
ReadOnlySpan<float> x, ReadOnlySpan<float> y, Span<float> destination, TBinaryOperator op = default)
where TBinaryOperator : IBinaryOperator
where TBinaryOperator : struct, IBinaryOperator
{
if (x.Length != y.Length)
{
Expand Down Expand Up @@ -258,7 +258,7 @@ private static void InvokeSpanSpanIntoSpan<TBinaryOperator>(

private static void InvokeSpanScalarIntoSpan<TBinaryOperator>(
ReadOnlySpan<float> x, float y, Span<float> destination, TBinaryOperator op = default)
where TBinaryOperator : IBinaryOperator
where TBinaryOperator : struct, IBinaryOperator
{
if (x.Length > destination.Length)
{
Expand Down Expand Up @@ -309,7 +309,7 @@ private static void InvokeSpanScalarIntoSpan<TBinaryOperator>(

private static void InvokeSpanSpanSpanIntoSpan<TTernaryOperator>(
ReadOnlySpan<float> x, ReadOnlySpan<float> y, ReadOnlySpan<float> z, Span<float> destination, TTernaryOperator op = default)
where TTernaryOperator : ITernaryOperator
where TTernaryOperator : struct, ITernaryOperator
{
if (x.Length != y.Length || x.Length != z.Length)
{
Expand Down Expand Up @@ -369,7 +369,7 @@ private static void InvokeSpanSpanSpanIntoSpan<TTernaryOperator>(

private static void InvokeSpanSpanScalarIntoSpan<TTernaryOperator>(
ReadOnlySpan<float> x, ReadOnlySpan<float> y, float z, Span<float> destination, TTernaryOperator op = default)
where TTernaryOperator : ITernaryOperator
where TTernaryOperator : struct, ITernaryOperator
{
if (x.Length != y.Length)
{
Expand Down Expand Up @@ -430,7 +430,7 @@ private static void InvokeSpanSpanScalarIntoSpan<TTernaryOperator>(

private static void InvokeSpanScalarSpanIntoSpan<TTernaryOperator>(
ReadOnlySpan<float> x, float y, ReadOnlySpan<float> z, Span<float> destination, TTernaryOperator op = default)
where TTernaryOperator : ITernaryOperator
where TTernaryOperator : struct, ITernaryOperator
{
if (x.Length != z.Length)
{
Expand Down
Loading