def gather

bendtorch-core@0.1.0.0 · src/autograd/tensor_chain_LAWS.bend:82

import bendtorch-core@0.1.0.0/src/autograd/tensor_chain_LAWS.bend as TensorChainLAWS
import Base
import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient

82# Each slot of a newest-first list of count slots, the one with k older slots
83# for id k, with what the log sends to it. A list longer than count keeps its
84# slots past count, as the sweep does.
85def gather(slots: List<&1, Gradient.Slot>, +count: Nat, log: Log()) -> Slots():
86  match slots count:
87    case Nil{} count:
88      Done{Nil{}}
89    case Con{slot, rest} 0n:
90      Done{slot <> rest}
91    case Con{slot, rest} 1n+below:
92      gather_step(take(log, below, slot), more => gather(rest, below, more))

Uses (8)

Used by (2)