Skip to main content

Mojo function

row_major

row_major(var shape: Coord[shape.element_types]) -> 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: A Layout with row-major strides.

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: A Layout with row-major strides.

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?