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
blocked_product
def blocked_product[BlockLayoutType: TensorLayout, TilerLayoutType: TensorLayout, //](block: BlockLayoutType, tiler: TilerLayoutType) -> Layout[TypeList[#kgen.param_list.tabulate(len(BlockLayoutType.__stride_types), [idx: __mlir_type.index] Coord[BlockLayoutType.__shape_types[SIMDLength(Int(idx))], TilerLayoutType.__shape_types[SIMDLength(Int(idx))]])](), TypeList[#kgen.param_list.tabulate(len(BlockLayoutType.__stride_types), [idx: __mlir_type.index] Coord[BlockLayoutType.__stride_types[SIMDLength(Int(idx))], ComptimeInt[(Coord[BlockLayoutType._shape_types].static_product * TilerLayoutType.__stride_types[idx].static_value)]])]()]
Creates a blocked layout by combining a block and tiler layout.
This function creates a hierarchical blocked layout where each element of the tiler layout is replaced by a block. This is useful for creating tiled layouts for efficient cache utilization.
Example:
from layout.tile_layout import row_major, blocked_product
# Create a 2x2 block layout
var block = row_major[2, 2]()
# Create a 2x3 tiler (2 rows, 3 cols of blocks)
var tiler = row_major[2, 3]()
# Create blocked layout
var blocked = blocked_product(block, tiler)
# Result: shape ((2,2), (2,3)), stride ((2,12), (1,4))Parameters:
- BlockLayoutType (
TensorLayout): The type of the block layout. - TilerLayoutType (
TensorLayout): The type of the tiler layout.
Args:
- block (
BlockLayoutType): The inner layout defining the structure of each tile. - tiler (
TilerLayoutType): The outer layout defining the arrangement of tiles.
Returns:
def blocked_product[BlockLayoutType: TensorLayout, TilerLayoutType: TensorLayout, //, *, coalesce_output: Bool](block: BlockLayoutType, tiler: TilerLayoutType) -> Layout[TypeList[#kgen.param_list.tabulate(len(BlockLayoutType.__shape_types), [idx: __mlir_type.index] ComptimeInt[(BlockLayoutType.__shape_types[idx].static_value * TilerLayoutType.__shape_types[idx].static_value)] if ((BlockLayoutType.__shape_types[idx].static_value * BlockLayoutType.__stride_types[idx].static_value) == (Coord[BlockLayoutType._shape_types].static_product * TilerLayoutType.__stride_types[idx].static_value)) else Coord[BlockLayoutType.__shape_types[SIMDLength(Int(idx))], TilerLayoutType.__shape_types[SIMDLength(Int(idx))]]) if coalesce_output else #kgen.param_list.tabulate(len(BlockLayoutType.__stride_types), [idx: __mlir_type.index] Coord[BlockLayoutType.__shape_types[SIMDLength(Int(idx))], TilerLayoutType.__shape_types[SIMDLength(Int(idx))]])](), TypeList[#kgen.param_list.tabulate(len(BlockLayoutType.__stride_types), [idx: __mlir_type.index] BlockLayoutType.__stride_types[SIMDLength(Int(idx))] if ((BlockLayoutType.__shape_types[idx].static_value * BlockLayoutType.__stride_types[idx].static_value) == (Coord[BlockLayoutType._shape_types].static_product * TilerLayoutType.__stride_types[idx].static_value)) else Coord[BlockLayoutType.__stride_types[SIMDLength(Int(idx))], ComptimeInt[(Coord[BlockLayoutType._shape_types].static_product * TilerLayoutType.__stride_types[idx].static_value)]]) if coalesce_output else #kgen.param_list.tabulate(len(BlockLayoutType.__stride_types), [idx: __mlir_type.index] Coord[BlockLayoutType.__stride_types[SIMDLength(Int(idx))], ComptimeInt[(Coord[BlockLayoutType._shape_types].static_product * TilerLayoutType.__stride_types[idx].static_value)]])]()]
Creates a blocked layout with optional output coalescing.
This overload accepts a coalesce_output keyword parameter. When
True, contiguous inner/outer dimension pairs are merged into flat
dimensions, reducing the layout rank where possible.
Example:
from layout.tile_layout import row_major, blocked_product
var block = row_major[4]()
var tiler = row_major[3]()
# Coalesced: shape (12,), stride (1,) instead of ((4,), (3,))
var coalesced = blocked_product[coalesce_output=True](block, tiler)Parameters:
- BlockLayoutType (
TensorLayout): The type of the block layout. - TilerLayoutType (
TensorLayout): The type of the tiler layout. - coalesce_output (
Bool): When True, merge contiguous inner/outer pairs.
Args:
- block (
BlockLayoutType): The inner layout defining the structure of each tile. - tiler (
TilerLayoutType): The outer layout defining the arrangement of tiles.
Returns: