Skip to main content
Log in

Mojo function

reduce

reduce[val_type: DType, simd_width: Int, //, shuffle: fn[DType, Int](val: SIMD[$0, $1], offset: SIMD[uint32, 1]) -> SIMD[$0, $1], func: fn[DType, Int](SIMD[$0, $1], SIMD[$0, $1]) capturing -> SIMD[$0, $1]](val: SIMD[val_type, simd_width]) -> SIMD[val_type, simd_width]

Takes in an input function to computes warp shuffle based reduction operation.

Parameters:

  • val_type (DType): The type of the SIMD value.
  • simd_width (Int): The width of the SIMD value.
  • shuffle (fn[DType, Int](val: SIMD[$0, $1], offset: SIMD[uint32, 1]) -> SIMD[$0, $1]): The shuffle function to use.
  • func (fn[DType, Int](SIMD[$0, $1], SIMD[$0, $1]) capturing -> SIMD[$0, $1]): The function to apply to the SIMD value.

Args:

  • val (SIMD[val_type, simd_width]): The SIMD value to reduce.

Returns:

A SIMD value with the reduction result.