Mojo function
make_layout
make_layout(*layouts: Layout) -> Layout
Creates a composite layout by concatenating multiple layouts.
This function combines multiple layouts into a single layout by concatenating their shapes and strides. The resulting layout represents a hierarchical structure where each input layout becomes a component of the output layout.
Example:
from layout import Layout, IntTuple
from layout.layout import make_layout
var layout1 = Layout(IntTuple(2, 3), IntTuple(3, 1))
var layout2 = Layout(IntTuple(4, 5), IntTuple(5, 1))
var combined = make_layout(layout1, layout2)
# Result: Layout with shape ((2, 3), (4, 5)) and stride ((3, 1), (5, 1))
from layout import Layout, IntTuple
from layout.layout import make_layout
var layout1 = Layout(IntTuple(2, 3), IntTuple(3, 1))
var layout2 = Layout(IntTuple(4, 5), IntTuple(5, 1))
var combined = make_layout(layout1, layout2)
# Result: Layout with shape ((2, 3), (4, 5)) and stride ((3, 1), (5, 1))
.
Args:
- *layouts (
Layout
): Variable number ofLayout
objects to combine.
Returns:
A new Layout with concatenated shapes and strides from the input layouts.
make_layout(layout_a: Layout, layout_b: Layout) -> Layout
Creates a composite layout from two layouts.
This is a specialized version of make_layout that takes exactly two layouts and combines them into a single layout. This function exists as a workaround for compiler limitations.
Args:
- layout_a (
Layout
): The first layout to include in the composite. - layout_b (
Layout
): The second layout to include in the composite.
Returns:
A new Layout
with concatenated shapes and strides from the input layouts.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!