def pass

bendtorch-core@0.1.0.0 · src/autograd/tensor_backward.bend:809

import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as TensorBackward
import Base
import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient

809# The working gradient of every entry, newest first: Unset for the entries
810# newer than output and for every entry output does not reach, ones of the
811# output's shape at output, and the sweep's totals below it.
812def pass(entries: List<&1, Entry>, +count: Nat, +output: Nat, selected: Bool) -> Swept():
813  match entries count selected:
814    case Nil{} count selected:
815      (Nil{}, Done{Nil{}})
816    case Con{entry, rest} 0n selected:
817      (entry <> rest, Done{Nil{}})
818    case Con{entry, rest} 1n+below False{}:
819      finished(entry, Gradient.Unset{}, pass(rest, below, output, at_head(below, output)))
820    case Con{entry, rest} 1n+below True{}:
821      seeded_entry(entry, rest, below)

Uses (11)

Used by (7)