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

row_major_nested

def row_major_nested(var shape: Coord) -> Layout[shape.element_types, *?]

Creates a row-major layout from a nested shape Coord.

For a nested shape ((a, b), (c, d)) the result has nested strides ((b*c*d, c*d), (d, 1)) — row-major over the flattened shape, re-nested.

Currently restricted to all-static (compile-time) leaf dimensions and one level of nesting. For flat shapes use row_major.

Args:

  • shape (Coord): The nested shape as a Coord whose top-level elements are themselves Coords.

Returns:

Layout[shape.element_types, *?]: A Layout with the matching nested row-major strides.