For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
reduce_boolean
reduce_boolean[reduce_fn: def[dtype: DType, width: Int](SIMD[dtype, width]) capturing -> Bool, continue_fn: def(Bool) capturing -> Bool, dtype: DType](src: Span[Scalar[dtype]], init: Bool) -> Bool
Computes a bool reduction of buffer elements. The reduction will early exit if the continue_fn returns False.
Parameters:
- reduce_fn (
def[dtype: DType, width: Int](SIMD[dtype, width]) capturing -> Bool): A boolean reduction function. This function is used to reduce a vector to a scalar. E.g. when we got8xfloat32vector and want to reduce it to abool. - continue_fn (
def(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. - dtype (
DType): The dtype of the input.
Args:
- src (
Span[Scalar[dtype]]): The input buffer. - init (
Bool): The initial value to use.
Returns:
Bool: The computed reduction value.