Mojo function
col_major
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 implementCoordLike.
Args:
- *elements (
*element_types.values): The shape dimensions.
Returns:
Layout: A Layout with column-major strides.
col_major(var shape: Coord[shape.element_types]) -> 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: A Layout with column-major strides.
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.
col_major(idx: ComptimeInt[idx.val]) -> Layout[*?, *?]
Creates a 1D column-major layout from a compile-time dimension.
Args:
- idx (
ComptimeInt): The shape dimension as aComptimeInt.
Returns:
Layout: A 1D Layout with stride 1.
col_major(idx: RuntimeInt[idx.dtype]) -> Layout[*?, *?]
Creates a 1D column-major layout from a runtime dimension.
Args:
- idx (
RuntimeInt): The shape dimension as aRuntimeInt.
Returns:
Layout: A 1D Layout with stride 1.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!