IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /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. /get-started.md).

Mojo function

dispatch_materialized_mask

def dispatch_materialized_mask[dtype: DType, layout: Layout, //](mask_nd: LayoutTensor[dtype, layout], callback_fn: T, start_pos_nd: OptionalReg[LayoutTensor[.uint32, Layout.row_major(Int(-1)), ImmutAnyOrigin]] = None)

Wrap a dense mask tensor in a MaterializedMask and invoke a callback.

Constructs a MaterializedMask from the provided tensor and optional per-sequence start-position tensor, then calls callback_fn with the resulting mask. Use this when the mask is provided as an explicit tensor (e.g. an ALiBi or relative-positional-encoding bias) rather than a compute-on-the-fly strategy.

Parameters:

  • ​dtype (DType): Element type of the mask tensor.
  • ​layout (Layout): Layout of the mask tensor.

Args:

Was this page helpful?