def bump
bendtorch-core@0.1.0.0 · src/autograd/tensor_backward.bend:725
import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as TensorBackward
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient
725
726
727
728def bump(slots: List<&1, Gradient.Slot>, +count: Nat, +target: Nat, +shape: Shape.Shape, gradient: Core.Dynamic, same: Bool) ->
729 Result<&2, &1, Error, List<&1, Gradient.Slot>>:
730 match slots count same:
731 case Nil{} count same:
732 Done{Nil{}}
733 case Con{slot, rest} 0n same:
734 Done{slot <> rest}
735 case Con{slot, rest} 1n+below True{}:
736 placed(rest, Gradient.accumulate(shape, slot, gradient))
737 case Con{slot, rest} 1n+below False{}:
738 prepend(Gradient.Slot, slot, bump(rest, below, target, shape, gradient, at_head(below, target)))