Mojo struct
ComposedLayout
struct ComposedLayout[offset: Optional[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): 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,
ImplicitlyDestructible,
Movable
comptime members
has_shape
comptime has_shape = True
True because the base layout always has a shape.
Methods
__init__
__init__(out self, var layout_a: Layout, layout_b: Swizzle)
Initialize ComposedLayout with a layout and swizzle.
Args:
__init__(out self, *, copy: Self)
Copy constructor for ComposedLayout.
Args:
- copy (
Self): The ComposedLayout to copy from.
__call__
__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.
__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
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
cosize(self) -> Int
Get the cosize of the composed layout.
Returns the cosize of the swizzle.
Returns:
Int: The cosize of the swizzle.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!