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

make_ordered_layout

make_ordered_layout(shape: IntTuple, order: IntTuple) -> Layout

Creates a layout with strides ordered according to a specified traversal order.

This function generates a compact (bijective) layout where the stride values follow the traversal order specified by the order parameter. This allows creating layouts with custom memory traversal patterns while maintaining a compact memory representation.

Example:

from layout import IntTuple, Layout
from layout.layout import make_ordered_layout

# Create a layout with shape (2,3,4,5) where dimensions are traversed
# in the order: dim0, dim3, dim2, dim1
var layout = make_ordered_layout(
IntTuple(2, 3, 4, 5),
IntTuple(1, 4, 3, 2)
)
# Result: Layout with shape (2,3,4,5) and stride (1,40,10,2)

Args:

  • shape (IntTuple): The shape of the layout.
  • order (IntTuple): The traversal order priority (lower values indicate higher priority).

Returns:

Layout: A Layout with the specified shape and strides ordered according to the traversal order.