def loop
bendtorch-core@0.1.0.0 · src/autograd/gradient.bend:85
import bendtorch-core@0.1.0.0/src/autograd/gradient.bend as Gradient
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
85def loop(fuel: Nat, +shape: Shape.Shape, +cursor: Nat, state: State<shape>) -> Outcome:
86 match fuel:
87 case 0n:
88 State{contribution, total} = state
89 Accumulated{Held{Core.Packed{shape, total}}}
90 case 1n+remaining:
91 +index = U32.from_nat(cursor)
92 decided(shape, cursor, index, state, state => loop(remaining, shape, 1n+cursor, state),
93 Shape.bool_case(Nat.is_eq(U32.to_nat(index), cursor)))