IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
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 got 8xfloat32 vector and want to reduce it to a bool.
  • 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:

Returns:

Bool: The computed reduction value.