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
def reduce[reduce_fn: def[acc_type: DType, dtype: DType, width: SIMDLength](SIMD[acc_type, width], SIMD[dtype, width]) capturing thin -> SIMD[acc_type, width], dtype: DType](src: Span[Scalar[dtype]], init: Scalar[dtype]) -> Scalar[dtype]
Computes a custom reduction of buffer elements.
Parameters:
- βreduce_fn (
def[acc_type: DType, dtype: DType, width: SIMDLength](SIMD[acc_type, width], SIMD[dtype, width]) capturing thin -> SIMD[acc_type, width]): The lambda implementing the reduction. - βdtype (
DType): The dtype of the input.
Args:
- βsrc (
Span[Scalar[dtype]]): The input buffer. - βinit (
Scalar[dtype]): The initial value to use in accumulator.
Returns:
Scalar[dtype]: The computed reduction value.
Raises:
If the operation fails.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!