For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo struct
SmemLayouts
struct SmemLayouts[a_type: DType, b_type: DType, BM: Int, BN: Int, BK: Int, OutputM: Int, OutputN: Int, a_swizzle: TensorMapSwizzle, b_swizzle: TensorMapSwizzle, transpose_b: Bool]
Common SMEM layout definitions for matmul-family kernels.
Centralizes the A/B/C tile layout computation including the transpose-conditional B layout logic, eliminating ~10 lines of duplicated layout definitions from each SMEM struct.
Parametersβ
- βa_type (
DType): Data type for A matrix tiles. - βb_type (
DType): Data type for B matrix tiles. - βBM (
Int): Block tile M dimension. - βBN (
Int): Block tile N dimension. - βBK (
Int): Block tile K dimension. - βOutputM (
Int): Output tile M dimension. - βOutputN (
Int): Output tile N dimension. - βa_swizzle (
TensorMapSwizzle): Swizzle mode for A tiles. - βb_swizzle (
TensorMapSwizzle): Swizzle mode for B tiles. - βtranspose_b (
Bool): Whether B is transposed (K-major).
Implemented traitsβ
AnyType,
ImplicitlyDestructible
comptime membersβ
a_smem_layout_typedβ
comptime a_smem_layout_typed = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())))
a_tile_elemsβ
comptime a_tile_elems = Layout[*?, *?].static_product
b_smem_layout_typedβ
comptime b_smem_layout_typed = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())))
b_tile_elemsβ
comptime b_tile_elems = Layout[*?, *?].static_product
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!