def total_success

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

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/storage/arith.bend as Arith
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/transform_PROOF.bend as TransformProof
import bendtorch-core@0.1.0.0/src/tensor/transform_totality.bend as TransformTotality
import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient

608def total_success(+shape: Shape.Shape, +index: U32, owner: Core.Dynamic, value: F32,
609  pair: Core.Tensor<shape> & Result<&2, &2, Core.Error, F32>,
610  -successful: {TransformTotality.read_succeeded(shape, pair) == True{} : Bool},
611  -inside: {Nat.is_lt(U32.to_nat(index), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool}) ->
612  Holds<{step_continued(shape, Gradient.step_total(shape, index, owner, value, pair)) == True{} : Bool}>:
613  (total, result) = pair
614  match result:
615    case Fail{error}:
616      Holds{Empty.absurd({False{} == True{} : Bool}, Arith.clash(successful))}
617    case Done{+accumulated}:
618      write_success(shape, owner, Core.write_flat(shape, total, index, F32.add(accumulated, value)),
619        {\{TransformTotality.WriteSuccess: successful => successful} :
620          TransformTotality.WriteSuccess<shape, total, index, F32.add(accumulated, value)> ->
621          {TransformTotality.write_succeeded(shape, Core.write_flat(shape, total, index, F32.add(accumulated, value))) == True{} : Bool}}(
622          TransformProof.tensor_write_success(shape, total, index, F32.add(accumulated, value), inside)))

Uses (26)

Used by (1)