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 struct

SharedToGenericTileCopier

struct SharedToGenericTileCopier[thread_layout: Layout[thread_layout.shape_types, thread_layout.stride_types], *, swizzle: Optional[Swizzle] = None, num_threads: Int = thread_layout.size(), masked: Bool = False]

A TileCopier that moves a tile from shared memory into generic memory.

The swizzle parameter is a property of the shared-memory tile being read and must match the swizzle used when that tile was written; passing a mismatched (or None) swizzle produces incorrect data.

Parameters​

  • ​thread_layout (Layout[shape_types, stride_types]): Layout describing how threads are organized over the copy.
  • ​swizzle (Optional[Swizzle]): Swizzle the shared-memory tile was populated with.
  • ​num_threads (Int): Total number of threads in the thread block. Threads beyond thread_layout.size() do not participate.
  • ​masked (Bool): When True, vectors whose destination offset falls at or past valid_rows * row_stride are not stored, so the valid row count may be smaller than the source tile. Defaults to False, which keeps the unmasked behavior. Independently of masked, the source may be FP32 with an FP16 or BF16 destination.

Implemented traits​

AnyType, Copyable, Deinitable, ImplicitlyCopyable, Movable, TileCopier

comptime members​

dst_address_space​

comptime dst_address_space = AddressSpace.GENERIC

Destination AddressSpace this copier writes to.

src_address_space​

comptime src_address_space = AddressSpace.SHARED

Source AddressSpace this copier reads from.

Methods​

copy​

def copy(self, dst: TileTensor[Engine=dst.Engine, linear_idx_type=dst.linear_idx_type], src: TileTensor[Engine=src.Engine, address_space=Self.src_address_space, linear_idx_type=src.linear_idx_type])

Copies src in shared memory into dst in generic memory.

When masked is set, the valid-row bound is dst.dim[0](). For a destination whose row dim is static (e.g. a .tile[...] sub-view), use copy_bounded with an explicit runtime row count instead.

Args:

copy_bounded​

def copy_bounded(self, dst: TileTensor[Engine=dst.Engine, linear_idx_type=dst.linear_idx_type], src: TileTensor[Engine=src.Engine, address_space=Self.src_address_space, linear_idx_type=src.linear_idx_type], dst_num_valid_rows: OptionalReg[Int])

Copies src in shared memory into dst in generic memory with an optional explicit valid-row bound.

The non-swizzled, same-dtype, unmasked path uses TileTensor.copy, which widens to SIMD stores when the layouts permit. Otherwise the copy walks per-thread vectors explicitly, applying the swizzle to the source offsets, an FP32 to FP16/BF16 downcast, and (when masked) a per-vector bound check mirroring the legacy copy_sram_to_dram. binary_op fusion is not supported.

Args:

Was this page helpful?