IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo function

sigmoid

def sigmoid[dtype: DType, simd_width: Int, accum: DType = get_accum_type[dtype]()](x: SIMD[dtype, simd_width]) -> SIMD[dtype, simd_width]

Compute the sigmoid activation using the equation 1/(1+eβˆ’x)1 / (1 + e^{-x}).

The computation is performed in a higher-precision accumulation type (see get_accum_type) for low-precision inputs and cast back to dtype, to match the numerics of the graph-level ops.sigmoid implementation.

Constraints:

Type must be a floating point Dtype.

Parameters:

  • ​dtype (DType): DType used for the computation.
  • ​simd_width (Int): SIMD width used for the computation.
  • ​accum (DType): Higher-precision accumulation dtype used internally; defaults to get_accum_type[dtype]().

Args:

Returns:

SIMD[dtype, simd_width]: The result of the sigmoid operation.