Module Rune.Total
Write-only sums.
type ('v, 's, +'d) tThe type for totals of ('v, 's, 'd) Nx.t values. 'd is covariant, so a total made at a library's top level serves every device set: let t : (float, Nx.float64_elt, 'd) Rune.Total.t = Rune.Total.make (). A collect's init fixes the set of the additions it receives.
add t v adds v to the innermost open collect of t, and does nothing if none is open.
Raises Invalid_argument naming both sets if v lies on another set than the init of the collect it reaches, or naming both shapes if v's shape is not init's.
collect t ~init f is (f (), total), total being init plus each addition to t that reaches it, in the order they reach it, and init itself if none does. If f raises, collect raises the same exception, with the backtrace of its raise.