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

col_major

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

Create a column-major layout from variadic arguments.

Column-major means the first dimension has stride 1, and each subsequent dimension has stride equal to the product of all previous dimensions.

Parameters:

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

Args:

  • ​*elements (*element_types.values): The shape dimensions.

Returns:

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

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

Create a column-major layout from a shape.

Column-major means the first dimension has stride 1, and each subsequent dimension has stride equal to the product of all previous 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 column-major strides.

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

Create a column-major layout from compile-time shape dimensions.

Example:

from layout.tile_layout import col_major

var layout = col_major[3, 4]()
# shape: (3, 4), stride: (1, 3)

Parameters:

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

Returns:

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

def col_major(idx: ComptimeInt) -> Layout[*?, *?]

Creates a 1D column-major layout from a compile-time dimension.

Args:

  • ​idx (ComptimeInt): The shape dimension as a ComptimeInt.

Returns:

Layout[*?, *?]: A 1D Layout with stride 1.

def col_major(idx: Scalar) -> Layout[*?, *?]

Creates a 1D column-major layout from a runtime dimension.

Args:

  • ​idx (Scalar): The shape dimension as a Scalar.

Returns:

Layout[*?, *?]: A 1D Layout with stride 1.

Was this page helpful?