Skip to main content

Mojo function

blocked_product

blocked_product[BlockLayoutType: TensorLayout, TilerLayoutType: TensorLayout, //](block: BlockLayoutType, tiler: TilerLayoutType) -> Layout[Coord[BlockLayoutType._shape_types], Coord[TilerLayoutType._shape_types], Coord[BlockLayoutType._stride_types], Coord[#kgen.variadic.reduce(TilerLayoutType._stride_types, base=, reducer=[PrevV: Variadic[CoordLike], VA: Variadic[CoordLike], idx: __mlir_type.index] #kgen.variadic.concat(PrevV, ComptimeInt[(VA[idx].static_value * Coord[BlockLayoutType._shape_types].static_product)]))]]

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,1), (12,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:

Layout: A new layout representing the blocked structure.

Was this page helpful?