def sum_read_status

bendtorch-core@0.1.0.0 · src/tensor/reduction_PROOF.bend:752

import bendtorch-core@0.1.0.0/src/tensor/reduction_PROOF.bend as ReductionPROOF
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/reduction.bend as Reduction
import bendtorch-core@0.1.0.0/src/tensor/math_totality.bend as Totality
import bendtorch-core@0.1.0.0/src/tensor/transform_totality.bend as TransformTotality
import bendtorch-core@0.1.0.0/src/storage/arith.bend as Arith

752def sum_read_status(+fuel: Nat, +shape: Shape.Shape, +cursor: Nat, +accumulator: F32,
753  pair: Core.Tensor<shape> & Result<&2, &2, Core.Error, F32>,
754  -successful: {TransformTotality.read_succeeded(shape, pair) == True{} : Bool},
755  -rec: @tensor: Core.Tensor<shape> -> @+value: F32 -> Totality.Status<Core.Error, Core.Tensor<shape> & F32,
756    Reduction.natural_sum_loop(fuel, shape, tensor, 1n+cursor, value)>) ->
757  Totality.Status<Core.Error, Core.Tensor<shape> & F32, Reduction.read_step(shape,
758    tensor => value => Reduction.natural_sum_loop(fuel, shape, tensor, 1n+cursor, value), accumulator, pair)>:
759  (tensor, result) = pair
760  match result:
761    case Fail{error}:
762      Totality.Status{Empty.absurd({False{} == True{} : Bool}, Arith.clash(successful))}
763    case Done{+value}:
764      Totality.Status{{\{Totality.Status: successful => successful} :
765        Totality.Status<Core.Error, Core.Tensor<shape> & F32,
766          Reduction.natural_sum_loop(fuel, shape, tensor, 1n+cursor, F32.add(accumulator, value))> ->
767            {Result.is_done(&2, &1, Core.Error, Core.Tensor<shape> & F32,
768              Reduction.natural_sum_loop(fuel, shape, tensor, 1n+cursor, F32.add(accumulator, value))) == True{} : Bool}}(
769                rec(tensor, F32.add(accumulator, value)))}

Uses (17)

Used by (1)