Realm

oa::ml::matrix::training_accumulate

Accumulate scale × value into persistent state inside the recorded graph. target is both read and written: target = target + scale × value in accumulation mode, or target = scale × value in overwrite mode. The mode is device-driven through cursor word 1 — zero accumulates, nonzero overwrites — so captured programs can reset run-scoped state without any host write. Because the update aliases persistent storage, every replay of a capturing program executes it against the accumulated contents; this is the mechanism metric counters, rollout storage, and running statistics use to advance inside compiled training without per-step host readback. target and value must share shape, F32 storage, and Runtime ownership; cursor must be a [2] U32 matrix on the same Runtime. Cursors are ordinary matrices initialized at allocation time, so a program can bind a permanent accumulation cursor and a permanent overwrite cursor and select per call site. This records GPU work but does not submit or wait. Errors Returns an error for mismatched shape, dtype, or Runtime ownership, a non-finite scale, element counts exceeding u32, or recording failure.

FnRust public API

Function Documentation

pub fn training_accumulate( target: &Matrix, value: &Matrix, cursor: &Matrix, scale: f32, ) -> Result<()>
Accumulate scale × value into persistent state inside the recorded graph. target is both read and written: target = target + scale × value in accumulation mode, or target = scale × value in overwrite mode. The mode is device-driven through cursor word 1 — zero accumulates, nonzero overwrites — so captured programs can reset run-scoped state without any host write. Because the update aliases persistent storage, every replay of a capturing program executes it against the accumulated contents; this is the mechanism metric counters, rollout storage, and running statistics use to advance inside compiled training without per-step host readback. target and value must share shape, F32 storage, and Runtime ownership; cursor must be a [2] U32 matrix on the same Runtime. Cursors are ordinary matrices initialized at allocation time, so a program can bind a permanent accumulation cursor and a permanent overwrite cursor and select per call site. This records GPU work but does not submit or wait. Errors Returns an error for mismatched shape, dtype, or Runtime ownership, a non-finite scale, element counts exceeding u32, or recording failure.