IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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

tile_to_shape

def tile_to_shape(var tile: Layout, target_shape: IntTuple, order: Optional[IntTuple] = None) -> Layout

Creates a layout by tiling a base layout to match a target shape.

This function creates a hierarchical layout by repeating a tile layout to match a target shape. It calculates how many times the tile needs to be repeated in each dimension to reach the target shape, and creates a tiler layout with this information.

Example:

from layout import Layout, IntTuple
from layout.layout import tile_to_shape

# Create a 2x2 tile layout
var tile = Layout.row_major(2, 2)
# Tile it to create a 6x4 layout
var tiled = tile_to_shape(tile^, IntTuple(6, 4))
# Result: A layout with 3x2 tiles of size 2x2 each

Args:

  • โ€‹tile (Layout): The base layout to be tiled.
  • โ€‹target_shape (IntTuple): The desired final shape to tile to.
  • โ€‹order (Optional[IntTuple]): Optional memory ordering for the tiler layout. If None, defaults to column-major ordering.

Returns:

Layout: A new layout representing the tiled structure that matches the target shape.

Was this page helpful?