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
reduce_add_simd
def reduce_add_simd[simd_width: SIMDLength, step_simd_width: SIMDLength, dtype: DType](mut scalar: Scalar[dtype], mut vector: SIMD[dtype, simd_width], val: SIMD[dtype, step_simd_width])
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.
Parameters:
- βsimd_width (
SIMDLength): The full SIMD width of thevectoraccumulator. - βstep_simd_width (
SIMDLength): The width of the current step'sval; when 1,valis accumulated intoscalar, otherwise intovector. - βdtype (
DType): The element type of the accumulators andval.
Args:
- βscalar (
Scalar[dtype]): Scalar accumulator for single-element steps; updated in place whenstep_simd_widthis 1. - βvector (
SIMD[dtype, simd_width]): SIMD accumulator for full-width steps; updated in place whenstep_simd_widthmatchessimd_width. - βval (
SIMD[dtype, step_simd_width]): The partial reduction value to accumulate into eitherscalarorvector.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!