IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /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. /get-started.md).

Mojo module

softmax

Provides numerically stable softmax kernels for CPU and GPU, including fused and online variants.

Functions​

  • ​identity: Returns the input SIMD vector unchanged.
  • ​mul: Returns the element-wise product x * y.
  • ​reciprocal: Returns the element-wise reciprocal 1 / x.
  • ​reduce_add_simd: This functions adds val to either the scalar value or the vector value depending on the step_simd_width. This is useful when the simd_width varies between iterations as in vectorize.
  • ​softmax_3_pass: Performs an unbatched softmax on an input tensor using the three-pass algorithm.
  • ​softmax_inline: Dispatches softmax (or logsoftmax) to the CPU or GPU target.
  • ​softmax_kernel: GPU kernel implementing the three-pass softmax with optional sink-attention and logsoftmax variants.
  • ​sub: Returns the element-wise difference x - y.

Was this page helpful?