Skip to main content

Mojo function

pack_bits

pack_bits[width: Int, //, new_type: DType = _uint($0)](val: SIMD[bool, width]) -> SIMD[$1, 1]

Packs a SIMD bool into an integer.

Constraints:

The width of the bool vector must be the same as the bitwidth of the target type.

Parameters:

  • width (Int): The source width.
  • new_type (DType): The target type.

Args:

  • val (SIMD[bool, width]): The source value.

Returns:

A new integer scalar which has the same bitwidth as the bool vector.