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/9.0-staging] Fix TensorPrimitives.MultiplyAddEstimate for integers #113094

Open
wants to merge 3 commits into
base: release/9.0-staging
Choose a base branch
from
Open
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 @@ -128,9 +128,8 @@ public static Vector128<T> Invoke(Vector128<T> x, Vector128<T> y, Vector128<T> z
{
return Vector128.MultiplyAddEstimate(x.AsDouble(), y.AsDouble(), z.AsDouble()).As<double, T>();
}
else
else if (typeof(T) == typeof(float))
{
Debug.Assert(typeof(T) == typeof(float));
return Vector128.MultiplyAddEstimate(x.AsSingle(), y.AsSingle(), z.AsSingle()).As<float, T>();
}
#else
Expand All @@ -149,9 +148,9 @@ public static Vector128<T> Invoke(Vector128<T> x, Vector128<T> y, Vector128<T> z
{
if (typeof(T) == typeof(double)) return AdvSimd.Arm64.FusedMultiplyAdd(z.AsDouble(), x.AsDouble(), y.AsDouble()).As<double, T>();
}
#endif

return (x * y) + z;
#endif
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -162,9 +161,8 @@ public static Vector256<T> Invoke(Vector256<T> x, Vector256<T> y, Vector256<T> z
{
return Vector256.MultiplyAddEstimate(x.AsDouble(), y.AsDouble(), z.AsDouble()).As<double, T>();
}
else
else if (typeof(T) == typeof(float))
{
Debug.Assert(typeof(T) == typeof(float));
return Vector256.MultiplyAddEstimate(x.AsSingle(), y.AsSingle(), z.AsSingle()).As<float, T>();
}
#else
Expand All @@ -173,9 +171,9 @@ public static Vector256<T> Invoke(Vector256<T> x, Vector256<T> y, Vector256<T> z
if (typeof(T) == typeof(float)) return Fma.MultiplyAdd(x.AsSingle(), y.AsSingle(), z.AsSingle()).As<float, T>();
if (typeof(T) == typeof(double)) return Fma.MultiplyAdd(x.AsDouble(), y.AsDouble(), z.AsDouble()).As<double, T>();
}
#endif

return (x * y) + z;
#endif
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -186,9 +184,8 @@ public static Vector512<T> Invoke(Vector512<T> x, Vector512<T> y, Vector512<T> z
{
return Vector512.MultiplyAddEstimate(x.AsDouble(), y.AsDouble(), z.AsDouble()).As<double, T>();
}
else
else if (typeof(T) == typeof(float))
{
Debug.Assert(typeof(T) == typeof(float));
return Vector512.MultiplyAddEstimate(x.AsSingle(), y.AsSingle(), z.AsSingle()).As<float, T>();
}
#else
Expand All @@ -197,9 +194,9 @@ public static Vector512<T> Invoke(Vector512<T> x, Vector512<T> y, Vector512<T> z
if (typeof(T) == typeof(float)) return Avx512F.FusedMultiplyAdd(x.AsSingle(), y.AsSingle(), z.AsSingle()).As<float, T>();
if (typeof(T) == typeof(double)) return Avx512F.FusedMultiplyAdd(x.AsDouble(), y.AsDouble(), z.AsDouble()).As<double, T>();
}
#endif

return (x * y) + z;
#endif
}
}
}
Expand Down
Loading
Loading