IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Mojo function

mask_select8

def mask_select8[byte_idx: Int](s0: Float32, s1: Float32, s2: Float32, s3: Float32, s4: Float32, s5: Float32, s6: Float32, s7: Float32, mask_bits: UInt32) -> _RegisterPackType[Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32]

Masks 8 contiguous scores against one byte of a 32-column bitmask.

Lane j keeps its score if bit 8*byte_idx + j of mask_bits is set, otherwise it becomes MASK_VALUE (-10000). The 8 and/setp/selp are confined to a single opaque PTX block so the bit-extraction sits adjacent to the selects: the predicate live-set stays bounded (avoiding the wide up-front bit pre-extraction that spills) and the shape stays R2P-eligible.

Parameters:

  • ​byte_idx (Int): Which mask byte to apply (0..3), i.e. columns 8*byte_idx .. 8*byte_idx + 7.

Args:

  • ​s0 (Float32): Already-scaled score for lane 0.
  • ​s1 (Float32): Already-scaled score for lane 1.
  • ​s2 (Float32): Already-scaled score for lane 2.
  • ​s3 (Float32): Already-scaled score for lane 3.
  • ​s4 (Float32): Already-scaled score for lane 4.
  • ​s5 (Float32): Already-scaled score for lane 5.
  • ​s6 (Float32): Already-scaled score for lane 6.
  • ​s7 (Float32): Already-scaled score for lane 7.
  • ​mask_bits (UInt32): Packed 32-column visibility mask.

Returns:

_RegisterPackType[Float32, Float32, Float32, Float32, Float32, Float32, Float32, Float32]: The 8 masked scores, register-packed (index [0] .. [7]).

Was this page helpful?