Skip to main content

Mojo function

logical_product

logical_product(var _layout_a: Layout, var layout_b: Layout) -> Layout

Creates a product of two layouts.

This function creates a hierarchical layout by taking the logical product of two layouts. It's a fundamental operation for creating blocked or tiled layouts.

Args:

  • ​_layout_a (Layout): The first layout.
  • ​layout_b (Layout): The second layout.

Returns:

Layout: A new layout representing the logical product of the two layouts.

logical_product(var layout_a: Layout, tiler: List[Layout]) -> Layout

Creates a product of a layout with a list of layouts.

This is a variant of logical_product that works with a list of layouts for more complex tiling patterns. It applies the logical_product operation to each element of the layout with the corresponding element in the tiler list.

Example:

from layout import Layout, LayoutList, IntTuple
from layout.layout import logical_product

# Create a product of a layout with a list of layouts
var base = Layout.row_major(6, 8)
var tilers = LayoutList()
tilers.append(Layout(IntTuple(2, 2)))
var result = logical_product(base^, tilers)

Args:

  • ​layout_a (Layout): The base layout to create products with.
  • ​tiler (List): A list of layouts defining the product patterns.

Returns:

Layout: A new layout representing the logical product with the tiler layouts.

Was this page helpful?