def contribution_retains

bendtorch-core@0.1.0.0 · src/autograd/gradient_PROOF.bend:182

import bendtorch-core@0.1.0.0/src/autograd/gradient_PROOF.bend as GradientPROOF
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/tensor/elementwise_totality.bend as Totality
import bendtorch-core@0.1.0.0/src/tensor/elementwise_PROOF.bend as ElementwiseProof
import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient

182def contribution_retains(-shape: Shape.Shape, +index: U32, total: Core.Tensor<shape>, -original: Core.Dynamic,
183  pair: Core.Dynamic & Result<&2, &2, Core.Error, F32>,
184  -same: Totality.SameSource(original, ElementwiseProof.dynamic_read_owner(pair))) ->
185  Holds<Totality.SameSource(original, step_owner(shape, Gradient.step_contribution(shape, index, total, pair)))>:
186  (contribution, result) = pair
187  match result:
188    case Fail{error}:
189      Holds{same}
190    case Done{value}:
191      Holds{property => Equal.trans(Totality.Inspection,
192        Totality.inspect(property, step_owner(shape, Gradient.step_total(shape, index, contribution, value, Core.read_flat(shape, total, index)))),
193        Totality.inspect(property, contribution), Totality.inspect(property, original),
194        Equal.cong(Core.Dynamic, Totality.Inspection, owner => Totality.inspect(property, owner),
195          step_owner(shape, Gradient.step_total(shape, index, contribution, value, Core.read_flat(shape, total, index))), contribution,
196          {\{Holds: proof => proof} : Holds<{step_owner(shape, Gradient.step_total(shape, index, contribution, value, Core.read_flat(shape, total, index))) == contribution : Core.Dynamic}> ->
197            {step_owner(shape, Gradient.step_total(shape, index, contribution, value, Core.read_flat(shape, total, index))) == contribution : Core.Dynamic}}(
198            total_owner(shape, index, contribution, value, Core.read_flat(shape, total, index)))),
199        same(property))}

Uses (21)

Used by (1)