def sum_decided

bendtorch-core@0.1.0.0 · src/tensor/reduction.bend:29

import bendtorch-core@0.1.0.0/src/tensor/reduction.bend as Reduction
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/main.bend as Storage
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core

29def sum_decided(-shape: Shape.Shape,
30  rec: Core.Tensor<shape> -> F32 -> Result<&2, &1, Core.Error, Core.Tensor<shape> & F32>, tensor: Core.Tensor<shape>, +cursor: Nat,
31  +index: U32, accumulator: F32, decision: Shape.BoolCase<Nat.is_eq(U32.to_nat(index), cursor)>) ->
32  Result<&2, &1, Core.Error, Core.Tensor<shape> & F32>:
33  match decision:
34    case Shape.BFalse{equal}:
35      Fail{Core.StorageError{Storage.InvalidIndex{}}}
36    case Shape.BTrue{equal}:
37      read_step(shape, rec, accumulator, Core.read_flat(shape, tensor, index))

Uses (14)

Used by (5)