For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo struct
ComposedLayout
struct ComposedLayout[offset: Optional[Int] = Int(0)]
Layout composed of a Layout and a Swizzle applied sequentially.
Combines a base layout with a swizzle. The output of the layout is input to the swizzle, with an optional offset in between.
Parametersβ
- βoffset (
Optional[Int]): Optional offset between layouts (default: 0).
Fieldsβ
- βlayout_a (
Layout): The base layout to apply. - βlayout_b (
Swizzle): The swizzle to apply.
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyDeletable,
Movable
comptime membersβ
has_shapeβ
comptime has_shape = True
True because the base layout always has a shape.
Methodsβ
__init__β
def __init__(out self, var layout_a: Layout, layout_b: Swizzle)
Initialize ComposedLayout with a layout and swizzle.
Args:
def __init__(out self, *, copy: Self)
Copy constructor for ComposedLayout.
Args:
- βcopy (
Self): The ComposedLayout to copy from.
__call__β
def __call__(self, idx: IntTuple) -> Int
Apply composed layout to an index.
Applies the layout, then adds offset, then applies the swizzle.
Args:
- βidx (
IntTuple): The index to transform.
Returns:
Int: The transformed index.
def __call__(self, idx: IntTuple, offset_val: Int) -> Int
Apply composed layout with runtime offset.
Applies the layout, then adds runtime offset_val, then the swizzle.
Static offset must not be set when using runtime offset.
Args:
Returns:
Int: The transformed index.
sizeβ
def size(self) -> Int
Get the size of the composed layout.
Returns the size of the base layout.
Returns:
Int: The size of the base layout.
cosizeβ
def cosize(self) -> Int
Get the cosize of the composed layout.
Returns the cosize of the swizzle.
Returns:
Int: The cosize of the swizzle.