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 module
tile_types
Native TileTensor types for SM100 structured kernels.
This module provides TileTensor-based tile types for SM100 structured kernels. All SMEM storage uses TileTensor natively. TileTensors are passed directly to TMA and MMA via TileTensor overloads.
Usage:
# Create tile with a layout
comptime my_layout = row_major[64, 32]()
comptime MyTile = SMemTile[DType.float16, my_layout]
# TileTensors are passed directly to TMA/MMA
tma_op.async_copy(tile, barrier, coords)comptime valuesβ
GMEMLayout1Dβ
comptime GMEMLayout1D = Layout[*?, *?]
1D layout for flat global memory arrays.
Shape is dynamic (Scalar), stride is 1 (ComptimeInt[1]). Rank is provably 1 at compile time.
GMEMTileβ
comptime GMEMTile[dtype: DType, lt_layout: Layout] = TileTensor[dtype, Layout[*?, *?], MutAnyOrigin]
Global memory TileTensor derived from a legacy Layout.
Used for kernel parameter types, replacing LayoutTensor parameters.
Parametersβ
internal_k_majorβ
comptime internal_k_major[dtype: DType, BM: Int, BK: Int, swizzle_bytes: Int] = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())))
Parametersβ
internal_k_major_128Bβ
comptime internal_k_major_128B[dtype: DType, BM: Int, BK: Int] = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())))
Parametersβ
internal_k_major_32Bβ
comptime internal_k_major_32B[dtype: DType, BM: Int, BK: Int] = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())))
Parametersβ
internal_k_major_64Bβ
comptime internal_k_major_64B[dtype: DType, BM: Int, BK: Int] = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(ComptimeInt(), ComptimeInt())))
Parametersβ
internal_k_major_noneβ
comptime internal_k_major_none[dtype: DType, BM: Int, BK: Int] = row_major[BM, BK]()
Parametersβ
internal_sf_k_majorβ
comptime internal_sf_k_major[dim0: Int, dim1: Int] = Layout(Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(Coord(ComptimeInt(), ComptimeInt()), ComptimeInt())), Coord(Coord(ComptimeInt(), ComptimeInt()), Coord(Coord(ComptimeInt(), ComptimeInt()), ComptimeInt())))
Parametersβ
sf_tile_dim0β
sf_tile_dim1β
comptime sf_tile_dim1[sf_bk: Int, vec_sf_size: Int] = ((sf_bk // (4 * vec_sf_size)) * 16)
Parametersβ
SMemTileβ
comptime SMemTile[dtype: DType, layout: Layout[shape_types, stride_types], *, alignment: Int = 128] = TileTensor[dtype, Layout[shape_types, stride_types], MutAnyOrigin, address_space=AddressSpace.SHARED]
Shared memory tile using TileTensor with a Layout.
The Layout parameter preserves swizzle information, enabling .to_layout_tensor() to produce correctly swizzled LayoutTensors.
Parametersβ
- βdtype (
DType): The data type of tile elements. - βlayout (
Layout[shape_types, stride_types]): The full layout including swizzle information. - βalignment (
Int): Memory alignment (default 128 for shared memory).
SMemTile2Dβ
comptime SMemTile2D[dtype: DType, dim0: Int, dim1: Int, *, alignment: Int = 128] = TileTensor[dtype, Layout[*?, *?], MutAnyOrigin, address_space=AddressSpace.SHARED]
Backward-compatible alias for SMemTile with explicit 2D dimensions.
Parametersβ
SMemTileShapeβ
comptime SMemTileShape[idx: Int, Tile: TileTensor[dtype, LayoutType, origin, address_space=address_space, linear_idx_type=linear_idx_type, element_size=element_size]] = LayoutType.static_shape[idx]
Get compile-time shape value at index from a TileTensor type.
Returns: The static shape value, or -1 if runtime-determined.
Parametersβ
- βidx (
Int): The dimension index. - βTile (
TileTensor[dtype, LayoutType, origin, address_space=address_space, linear_idx_type=linear_idx_type, element_size=element_size]): The TileTensor type (use type_of(tile)).
SMemTileStrideβ
comptime SMemTileStride[idx: Int, Tile: TileTensor[dtype, LayoutType, origin, address_space=address_space, linear_idx_type=linear_idx_type, element_size=element_size]] = LayoutType.static_stride[idx]
Get compile-time stride value at index from a TileTensor type.
Returns: The static stride value, or -1 if runtime-determined.
Parametersβ
- βidx (
Int): The dimension index. - βTile (
TileTensor[dtype, LayoutType, origin, address_space=address_space, linear_idx_type=linear_idx_type, element_size=element_size]): The TileTensor type (use type_of(tile)).
static_row_majorβ
comptime static_row_major[dim0: Int, dim1: Int] = Layout[*?, *?]
2D row-major layout with fully static dimensions.
Equivalent to LegacyLayout.row_major(dim0, dim1) but using new Layout
types with rank=2 provable at compile time.
Parametersβ
swizzle_mode_to_bytesβ
comptime swizzle_mode_to_bytes[swizzle_mode: TensorMapSwizzle] = 128 if (swizzle_mode == TensorMapSwizzle.SWIZZLE_128B) else 64 if (swizzle_mode == TensorMapSwizzle.SWIZZLE_64B) else 32 if (swizzle_mode == TensorMapSwizzle.SWIZZLE_32B) else 16
Convert TensorMapSwizzle enum to swizzle size in bytes.
SWIZZLE_NONE returns 16, matching TensorMapSwizzle.bytes()
(formula: (2**value) * 16, value=0 gives 16).
Returns: The swizzle size in bytes (16, 32, 64, or 128).
Parametersβ
- βswizzle_mode (
TensorMapSwizzle): The TensorMapSwizzle enum value.
tma_desc_layout_2dβ
comptime tma_desc_layout_2d[dtype: DType, tile_dim0: Int, swizzle: TensorMapSwizzle] = Layout[*?, *?]
2D TMA descriptor layout: [dim0, swizzle_elems], strides [1, 1].
Parametersβ
- βdtype (
DType): - βtile_dim0 (
Int): - βswizzle (
TensorMapSwizzle):
tma_desc_layout_3dβ
comptime tma_desc_layout_3d[dtype: DType, tile_dim0: Int, tile_dim1: Int, swizzle: TensorMapSwizzle] = Layout[*?, *?]
3D TMA descriptor layout: [dim0, dim1, swizzle_elems], strides [1,1,1].
Parametersβ
- βdtype (
DType): - βtile_dim0 (
Int): - βtile_dim1 (
Int): - βswizzle (
TensorMapSwizzle):
tma_desc_layout_4dβ
comptime tma_desc_layout_4d[dtype: DType, tile_dim0: Int, tile_dim1: Int, tile_dim2: Int, swizzle: TensorMapSwizzle] = Layout[*?, *?]
4D TMA descriptor layout: [d0,d1,d2,swizzle_elems], strides all 1.
Parametersβ
- βdtype (
DType): - βtile_dim0 (
Int): - βtile_dim1 (
Int): - βtile_dim2 (
Int): - βswizzle (
TensorMapSwizzle):
tma_desc_layout_5dβ
comptime tma_desc_layout_5d[dtype: DType, tile_dim0: Int, tile_dim1: Int, tile_dim2: Int, tile_dim3: Int, swizzle: TensorMapSwizzle] = Layout[*?, *?]
5D TMA descriptor layout: [d0,d1,d2,d3,swizzle_elems], strides all 1.
Parametersβ
TmaOpTypeβ
comptime TmaOpType[dtype: DType, tile_layout: TensorLayout, desc_layout: TensorLayout] = TMATensorTile[dtype, tile_layout.rank, _to_index_list[tile_layout](), _to_index_list[tile_layout.rank, desc_layout]()]
TMATensorTile type derived from new Layout types.
Single source of truth: new Layout types determine the TMATensorTile type parameters via _to_index_list.
Parametersβ
- βdtype (
DType): - βtile_layout (
TensorLayout): - βdesc_layout (
TensorLayout):
TmaOpTypeIm2colβ
comptime TmaOpTypeIm2col[dtype: DType, tile_layout: TensorLayout, desc_layout: TensorLayout] = TMATensorTileIm2col[dtype, tile_layout.rank, _to_index_list[tile_layout](), _to_index_list[tile_layout.rank, desc_layout]()]
TMATensorTileIm2col type derived from new Layout types.
Same as TmaOpType but for im2col TMA (used by conv2d activation loads).
Parametersβ
- βdtype (
DType): - βtile_layout (
TensorLayout): - βdesc_layout (
TensorLayout):
Structsβ
- β
SMemTileArray: Array of TileTensor tiles with variadic shape/stride type parameters. - β
SMemTileArray2D: Array of TileTensor tiles in shared memory with swizzled K-major layout. - β
SMemTileArray2DRowMajor: Array of TileTensor tiles in shared memory with row_major layout. - β
SMemTileArrayWithLayout: Array of TileTensor tiles with explicit Layout (preserves swizzle info).
Traitsβ
- β
TilePayload: Trait for tile payload types. Must be extend TrivialRegisterPassable.
Functionsβ
- β
create_tma_tile: Create a TMATensorTile using new Layout types.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!