def sum_decision_status

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

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_LAWS.bend as TransformLaws
import bendtorch-core@0.1.0.0/src/tensor/transform_totality.bend as TransformTotality

771def sum_decision_status(+fuel: Nat, +shape: Shape.Shape, +cursor: Nat, +accumulator: F32,
772  decision: Shape.BoolCase<Nat.is_eq(U32.to_nat(U32.from_nat(cursor)), cursor)>,
773  tensor: Core.Tensor<shape>,
774  -exact: {U32.to_nat(U32.from_nat(cursor)) == cursor : Nat},
775  -inside: {Nat.is_lt(U32.to_nat(U32.from_nat(cursor)), Shape.logical_numel(Shape.dimensions(shape))) == True{} : Bool},
776  -rec: @tensor: Core.Tensor<shape> -> @+value: F32 -> Totality.Status<Core.Error, Core.Tensor<shape> & F32,
777    Reduction.natural_sum_loop(fuel, shape, tensor, 1n+cursor, value)>) ->
778  Totality.Status<Core.Error, Core.Tensor<shape> & F32, Reduction.sum_decided(shape,
779    tensor => value => Reduction.natural_sum_loop(fuel, shape, tensor, 1n+cursor, value), tensor, cursor, U32.from_nat(cursor), accumulator, decision)>:
780  match decision:
781    case Shape.BFalse{equal}:
782      Totality.Status{Empty.absurd({False{} == True{} : Bool}, conversion_clash(U32.to_nat(U32.from_nat(cursor)), cursor, exact, equal))}
783    case Shape.BTrue{equal}:
784      sum_read_status(fuel, shape, cursor, accumulator, Core.read_flat(shape, tensor, U32.from_nat(cursor)),
785        {\{TransformTotality.ReadSuccess: successful => successful} :
786          TransformTotality.ReadSuccess<shape, tensor, U32.from_nat(cursor)> ->
787            {TransformTotality.read_succeeded(shape, Core.read_flat(shape, tensor, U32.from_nat(cursor))) == True{} : Bool}}(
788              TransformLaws.tensor_read_valid_success(shape, tensor, U32.from_nat(cursor), inside)), rec)

Uses (24)

Used by (1)