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 beyondthread_layout.size()do not participate. - masked (
Bool): WhenTrue, vectors whose destination offset falls at or pastvalid_rows * row_strideare not stored, so the valid row count may be smaller than the source tile. Defaults toFalse, which keeps the unmasked behavior. Independently ofmasked, 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:
- dst (
TileTensor[Engine=dst.Engine, linear_idx_type=dst.linear_idx_type]): Destination tile in generic memory. - src (
TileTensor[Engine=src.Engine, address_space=Self.src_address_space, linear_idx_type=src.linear_idx_type]): Source tile in shared memory.
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:
- dst (
TileTensor[Engine=dst.Engine, linear_idx_type=dst.linear_idx_type]): Destination tile in generic memory. - src (
TileTensor[Engine=src.Engine, address_space=Self.src_address_space, linear_idx_type=src.linear_idx_type]): Source tile in shared memory. - dst_num_valid_rows (
OptionalReg[Int]): Valid-row count for the masked bound. WhenNone,dst.dim[0]()is used. Only consulted whenmaskedisTrue. It overridesdst.dim[0]()so the destination can keep a static shape (and therefore the same thread distribution as the source) while the row count is dynamic.