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

row_major

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

Creates a row-major layout from a shape Coord.

Row-major means the rightmost dimension has stride 1, and each preceding dimension has stride equal to the product of all following dimensions.

For shape (M, N, K):

  • row_major strides: (N*K, K, 1)
  • col_major strides: (1, M, M*N)

Args:

  • ​shape (Coord): The shape as a Coord.

Returns:

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

def row_major[*element_types: CoordLike](var *elements: *element_types.values) -> Layout[element_types, *?]

Creates a row-major layout from a shape Coord.

Row-major means the rightmost dimension has stride 1, and each preceding dimension has stride equal to the product of all following dimensions.

Parameters:

  • ​*element_types (CoordLike): The variadic pack of element types that implement CoordLike.

Args:

  • ​*elements (*element_types.values): The shape as a Coord.

Returns:

Layout[element_types, *?]: A Layout with row-major strides.

def row_major[*idxs: Int]() -> Layout[*?, *?]

Creates a row-major layout from compile-time shape dimensions.

Parameters:

  • ​*idxs (Int): The shape dimensions as compile-time integers.

Returns:

Layout[*?, *?]: A Layout with row-major strides.

Was this page helpful?