Skip to main content

Mojo function

apply_tiler

apply_tiler[func: fn(Layout, Layout) -> Layout](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)
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 (fn(Layout, Layout) -> Layout): A function that takes two layouts and returns a transformed layout.

Args:

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

Returns:

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

Was this page helpful?