def missed

bendtorch-core@0.1.0.0 · src/autograd/tensor_chain_PROOF.bend:120

import bendtorch-core@0.1.0.0/src/autograd/tensor_chain_PROOF.bend as TensorChainPROOF
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
import bendtorch-core@0.1.0.0/src/autograd/tensor_backward.bend as Backward
import bendtorch-core@0.1.0.0/src/autograd/tensor_chain_LAWS.bend as Laws

120def missed(x: Gradient.Slot, -rest: List<&1, Gradient.Slot>, +below: Nat, +target: Nat, +shape: Shape.Shape, -gradient: Core.Dynamic,
121  -slots: List<&1, Gradient.Slot>, -log: Laws.Log(), -w: Gradient.Slot, -older: List<&1, Gradient.Slot>, -left: Laws.Log(),
122  at: {slots == w <> older : List<&1, Gradient.Slot>},
123  took: {Laws.take(Backward.Contribution{target, shape, gradient} <> log, below, w) == (Done{x}, Backward.Contribution{target, shape, gradient} <> left) : Laws.Taken()},
124  out: Bumped<rest, below, target, shape, gradient, Backward.at_head(below, target), older, left>) ->
125  Bumped<x <> rest, 1n+below, target, shape, gradient, False{}, slots, log>:
126  Bumped{state, bumped, pushed} = out
127  match state:
128    case Fail{error}:
129      Bumped{Fail{error}, Equal.cong(Laws.Slots(), Laws.Slots(), result => Backward.prepend(Gradient.Slot, x, result), Fail{error},
130        Backward.bump(rest, below, target, shape, gradient, Backward.at_head(below, target)), bumped), Unit{}}
131    case Done{pending}:
132      Bumped{Done{x <> pending}, Equal.cong(Laws.Slots(), Laws.Slots(), result => Backward.prepend(Gradient.Slot, x, result), Done{pending},
133        Backward.bump(rest, below, target, shape, gradient, Backward.at_head(below, target)), bumped),
134        Cell{w, older, Backward.Contribution{target, shape, gradient} <> left, at, took, pushed}}

Uses (20)

Used by (1)