Mojo function
complement
complement(layout: Layout, size: Int = 1) -> Layout
Computes the complement layout for a given layout.
This function creates a layout that represents the "gaps" or complementary structure of the input layout. It's useful for creating hierarchical layouts where you need to fill in the spaces between existing layout elements.
Example:
from layout import Layout, IntTuple
from layout.layout import complement
# Compute the complement of a layout
var base = Layout(IntTuple(2, 3), IntTuple(3, 1))
var comp = complement(base, 10)
# Result: A layout that fills the gaps in the original layout
from layout import Layout, IntTuple
from layout.layout import complement
# Compute the complement of a layout
var base = Layout(IntTuple(2, 3), IntTuple(3, 1))
var comp = complement(base, 10)
# Result: A layout that fills the gaps in the original layout
.
Args:
- layout (
Layout
): The input layout to compute the complement for. - size (
Int
): The total size of the memory region to consider. Defaults to 1.
Returns:
A new layout representing the complement of the input layout.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!