Mojo function
reduce_boolean
reduce_boolean[reduce_fn: fn[dtype: DType, width: Int](SIMD[dtype, width]) capturing -> Bool, continue_fn: fn(Bool) capturing -> Bool, dtype: DType](src: Span[Scalar[dtype], 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: 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 (
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. - dtype (
DType): The dtype of the input.
Args:
Returns:
Bool: The computed reduction value.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!