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: 1.0
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).

coalesce

coalesce[l: Layout, keep_rank: Bool = False](layout: RuntimeLayout[l, element_type=layout.element_type, linear_idx_type=layout.linear_idx_type]) -> RuntimeLayout[coalesce(l, keep_rank), element_type=layout.element_type, linear_idx_type=layout.linear_idx_type]

Coalesce adjacent dimensions in a runtime layout when possible.

This optimizes the layout by merging adjacent dimensions when their relationship allows it, potentially reducing the number of dimensions.

Parameters:

  • l (Layout): The static layout type to coalesce.
  • keep_rank (Bool): Whether to maintain the original rank (currently unsupported).

Args:

Returns:

RuntimeLayout[coalesce(l, keep_rank), element_type=layout.element_type, linear_idx_type=layout.linear_idx_type]: A new RuntimeLayout with coalesced dimensions.