IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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 function

two_level_layout_from_swizzle

def two_level_layout_from_swizzle[LayoutType: TensorLayout, bits: Int, base: Int, shift: Int](layout: LayoutType) -> SwizzledTwoLevelLayout[LayoutType, bits, base, shift]

Builds the exact TwoLevelLayout of a swizzle and an integer layout.

The layout splits as L = L_out + L_in, where L_in is every coordinate contribution below the swizzle's period. Lambda is Swizzle composed with L_in, so the result evaluates to Swizzle(L(x)) for every coordinate x.

Parameters:

  • ​LayoutType (TensorLayout): The integer layout type. All dimensions must be static powers of two, and the mode strides must not overlap on the bits the swizzle's period covers.
  • ​bits (Int): The swizzle mask width.
  • ​base (Int): The swizzle's constant low bits.
  • ​shift (Int): The swizzle's mask shift.

Args:

  • ​layout (LayoutType): The integer layout, used to anchor the result's type.

Returns:

SwizzledTwoLevelLayout[LayoutType, bits, base, shift]: The two-level layout with Outer = L_out and Lambda = Swizzle o L_in.

def two_level_layout_from_swizzle[LayoutType: TensorLayout, swizzle: Swizzle](layout: LayoutType) -> SwizzledTwoLevelLayout[LayoutType, swizzle.bits, swizzle.base, swizzle.shift]

Builds the exact TwoLevelLayout of a swizzle and an integer layout.

Parameters:

  • ​LayoutType (TensorLayout): The integer layout type.
  • ​swizzle (Swizzle): The swizzle to fold into the inner map.

Args:

  • ​layout (LayoutType): The integer layout, used to anchor the result's type.

Returns:

SwizzledTwoLevelLayout[LayoutType, swizzle.bits, swizzle.base, swizzle.shift]: The two-level layout with Outer = L_out and Lambda = swizzle o L_in.

Was this page helpful?