Skip to main content
Log in

Mojo function

gelu_approximate

gelu_approximate[type: DType, simd_width: Int](x: SIMD[type, simd_width]) -> SIMD[type, simd_width]

Compute the approximate GELU Op using the equation 0.5x(1+tanh(sqrt(2/pi)(x+0.044715x3)))0.5 * x * (1 + tanh(sqrt(2 / pi) * (x + 0.044715 * x^3))).

Constraints:

Type must be a floating point type.

Parameters:

  • type (DType): The DType used for the computation.
  • simd_width (Int): SIMD width used for the computation.

Args:

  • x (SIMD[type, simd_width]): The value to compute the GELU operation on.

Returns:

The result of the approximate GELU operation.

Was this page helpful?