Skip to content

Commit

Permalink
Enable Sigmoid vectorization for double (#97846)
Browse files Browse the repository at this point in the history
Now that ExpOperator is vectorized for double, we can enable Sigmoid
  • Loading branch information
stephentoub authored Feb 2, 2024
1 parent 6268bb9 commit 3dd7871
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14722,7 +14722,7 @@ private static Vector512<T> ElementWiseSelect<T>(Vector512<T> mask, Vector512<T>
/// <summary>1 / (1 + T.Exp(-x))</summary>
internal readonly struct SigmoidOperator<T> : IUnaryOperator<T, T> where T : IExponentialFunctions<T>
{
public static bool Vectorizable => typeof(T) == typeof(float);
public static bool Vectorizable => ExpOperator<T>.Vectorizable;
public static T Invoke(T x) => T.One / (T.One + T.Exp(-x));
public static Vector128<T> Invoke(Vector128<T> x) => Vector128.Create(T.One) / (Vector128.Create(T.One) + ExpOperator<T>.Invoke(-x));
public static Vector256<T> Invoke(Vector256<T> x) => Vector256.Create(T.One) / (Vector256.Create(T.One) + ExpOperator<T>.Invoke(-x));
Expand Down

0 comments on commit 3dd7871

Please sign in to comment.