def sole

bendtorch-core@0.1.0.0 · src/autograd/tensor_backward_LAWS.bend:107

import bendtorch-core@0.1.0.0/src/autograd/tensor_backward_LAWS.bend as TensorBackwardLAWS
import Base
import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as Backward

107# The only contribution of a VJP, when it sends exactly one.
108def sole(pass: Backward.Pass) -> Maybe<&1, Backward.Contribution>:
109  Backward.Pass{saved, g, contributions} = pass
110  match contributions:
111    case Fail{error}:
112      None{}
113    case Done{Nil{}}:
114      None{}
115    case Done{Con{contribution, Nil{}}}:
116      Some{contribution}
117    case Done{Con{contribution, Con{other, rest}}}:
118      None{}

Uses (5)

Used by (3)