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
RowCache
struct RowCache[params: ContextParams, T: DType, dtype: DType, axis: Int, rank: Int, NCH: Int, W: Int, cols: Int, fuse: Bool, shared: Bool]
A row value cached once by Row.cache and read by later phases. See the module note above for the two backings.
Carries no closures of its own: recompute / load take the
owning view's input_fn / compute as fresh value-closure ARGUMENTS
(a "forwarding bridge") rather than storing them as typed fields. A
field whose type is a trait-bound closure referencing a sibling
struct parameter (dtype/T) can't be named generically from
another struct's method signature in current Mojo (over: RowCache[..., InputFn, Compute] fails to elaborate with "lacking
evidence to prove correctness" β a struct-level, not method-level,
limitation); passing the closures as per-call arguments instead
keeps RowCache's own type free of them entirely.
Parametersβ
- βparams (
ContextParams): The owning view's comptime tier parameters. - βT (
DType): The cached value's dtype. - βdtype (
DType): The primary input dtype (for the recompute fallback). - βaxis (
Int): Reduced axis. - βrank (
Int): Tensor rank. - βNCH (
Int): Per-participant chunk count (mirrorsRow._NCH). - βW (
Int): SIMD width (mirrorsRow._W). - βcols (
Int): Reduced-axis length (mirrorsRow._cols). - βfuse (
Bool): Whether the owning view is on a cache-eligible tier. - βshared (
Bool): Whether the row is also published to shared memory.
Fieldsβ
- βrow_il (
IndexList[rank]): The row's coords (reduced axis pinned to its base).
Implemented traitsβ
AnyType,
Copyable,
Deinitable,
ImplicitlyCopyable,
Movable
Methodsβ
__init__β
def __init__(out self, *, copy: Self)
Explicit copy constructor: InlineArray lost ImplicitlyCopyable conformance, so _owned can't be auto-derived and needs .copy().
Args:
- βcopy (
Self): The handle to copy.
def __init__(out self, row_il: IndexList[rank])
Builds an empty handle; cache fills the backing.
Args:
- βrow_il (
IndexList[rank]): The row's coords.
recomputeβ
def recompute[w: Int, InputFn: def[width: Int, alignment: Int, coord_rank: Int](IndexList[coord_rank]) -> SIMD[dtype, width] & RegisterPassable & ImplicitlyCopyable, Compute: def[w: Int](SIMD[dtype, w], IndexList[rank]) -> SIMD[T, w] & RegisterPassable & ImplicitlyCopyable](self, coord: IndexList[rank], input_fn: InputFn, compute: Compute) -> SIMD[T, w] where (eq InputFn.dtype, dtype) where (eq Compute.dtype, dtype) where (eq Compute.rank, rank) where (eq Compute.T, T)
Recomputes the value at coord from a fresh global load β the fallback when the row was not staged.
w is given explicitly (recompute[w](...)); InputFn /
Compute are inferred from input_fn / compute.
Parameters:
- βw (
Int): SIMD width. - βInputFn (
def[width: Int, alignment: Int, coord_rank: Int](IndexList[coord_rank]) -> SIMD[dtype, width]&RegisterPassable&ImplicitlyCopyable): The value-closure type ofinput_fn. - βCompute (
def[w: Int](SIMD[dtype, w], IndexList[rank]) -> SIMD[T, w]&RegisterPassable&ImplicitlyCopyable): The value-closure type ofcompute.
Args:
- βcoord (
IndexList[rank]): The element coord. - βinput_fn (
InputFn): The owning view's primary-input loader, as a value. - βcompute (
Compute): The per-element producer, as a value.
Returns:
SIMD[T, w]: compute(input_fn(coord), coord).
loadβ
def load[w: Int, InputFn: def[width: Int, alignment: Int, coord_rank: Int](IndexList[coord_rank]) -> SIMD[dtype, width] & RegisterPassable & ImplicitlyCopyable, Compute: def[w: Int](SIMD[dtype, w], IndexList[rank]) -> SIMD[T, w] & RegisterPassable & ImplicitlyCopyable](self, coord: IndexList[rank], input_fn: InputFn, compute: Compute) -> SIMD[T, w] where (eq InputFn.dtype, dtype) where (eq Compute.dtype, dtype) where (eq Compute.rank, rank) where (eq Compute.T, T)
Reads the cached value at any column coord β from the per-row shmem strip when staged (cross-participant), else the recompute fallback.
w is given explicitly (load[w](...)); InputFn / Compute
are inferred from input_fn / compute.
Parameters:
- βw (
Int): SIMD width. - βInputFn (
def[width: Int, alignment: Int, coord_rank: Int](IndexList[coord_rank]) -> SIMD[dtype, width]&RegisterPassable&ImplicitlyCopyable): The value-closure type ofinput_fn. - βCompute (
def[w: Int](SIMD[dtype, w], IndexList[rank]) -> SIMD[T, w]&RegisterPassable&ImplicitlyCopyable): The value-closure type ofcompute.
Args:
- βcoord (
IndexList[rank]): The element coord (any column of this row). - βinput_fn (
InputFn): The owning view's primary-input loader, as a value (fallback path only). - βcompute (
Compute): The per-element producer, as a value (fallback path only).
Returns:
SIMD[T, w]: The cached value at coord.