Skip to main content

Mojo function

apply_tiler

apply_tiler[func: def(var Layout, var Layout) -> Layout](var layout_a: Layout, tiler: List[Layout]) -> Layout

Applies a layout transformation function to each element of a layout with a tiler.

This utility function applies the specified transformation function to each corresponding pair of elements from the layout and tiler list. It's a generic mechanism for implementing various tiling operations.

Example:

from layout import Layout, LayoutList, IntTuple
from layout.layout import apply_tiler, logical_divide

# Apply logical_divide to each element of a layout with a tiler
var base = Layout.row_major(6, 8)
var tilers = LayoutList()
tilers.append(Layout(IntTuple(2, 2), IntTuple(1, 2)))
var result = apply_tiler[logical_divide](base^, tilers)

Parameters:

  • โ€‹func (def(var Layout, var Layout) -> Layout): A function that takes two layouts and returns a transformed layout.

Args:

  • โ€‹layout_a (Layout): The base layout to transform.
  • โ€‹tiler (List): A list of layouts to use in the transformation.

Returns:

Layout: A new layout resulting from applying the transformation function to each pair.

Was this page helpful?