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

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 (mirrors Row._NCH).
  • ​W (Int): SIMD width (mirrors Row._W).
  • ​cols (Int): Reduced-axis length (mirrors Row._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: Array 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:

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 of input_fn.
  • ​Compute (def[w: Int](SIMD[dtype, w], IndexList[rank]) -> SIMD[T, w] & RegisterPassable & ImplicitlyCopyable): The value-closure type of compute.

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 of input_fn.
  • ​Compute (def[w: Int](SIMD[dtype, w], IndexList[rank]) -> SIMD[T, w] & RegisterPassable & ImplicitlyCopyable): The value-closure type of compute.

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.