Mojo function
reduce_boolean
reduce_boolean[: origin.set, : origin.set, //, reduce_fn: fn[DType, Int](SIMD[$0, $1]) capturing -> Bool, continue_fn: fn(Bool) capturing -> Bool](src: Buffer[type, size, address_space=address_space, origin=origin], init: Bool) -> Bool
Computes a bool reduction of buffer elements. The reduction will early exit if the continue_fn
returns False.
Parameters:
- reduce_fn (
fn[DType, Int](SIMD[$0, $1]) capturing -> Bool
): A boolean reduction function. This function is used to reduce a vector to a scalar. E.g. when we got8xfloat32
vector and want to reduce it to abool
. - continue_fn (
fn(Bool) capturing -> Bool
): A function to indicate whether we want to continue processing the rest of the iterations. This takes the result of the reduce_fn and returns True to continue processing and False to early exit.
Args:
- src (
Buffer[type, size, address_space=address_space, origin=origin]
): The input buffer. - init (
Bool
): The initial value to use.
Returns:
The computed reduction value.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!