def loop

bendtorch-core@0.1.0.0 · src/tensor/contracts/pointwise.bend:55

import bendtorch-core@0.1.0.0/src/tensor/contracts/pointwise.bend as Pointwise
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

55def loop(~O: Data, ~f: O -> F32 -> F32 -> F32, ~P: Data, ~ia: P -> Nat -> Nat, ~ib: P -> Nat -> Nat,
56  fuel: Nat, +operation: O, +plan: P, +shape: Shape.Shape, +cursor: Nat, state: State<shape>) ->
57  (Core.Dynamic & Core.Dynamic) & Result<&2, &1, Core.Error, Core.Dynamic>:
58  match fuel:
59    case 0n:
60      State{left, right, output} = state
61      ((left, right), Done{Core.pack(shape, output)})
62    case 1n+rest:
63      step(~O, ~f, ~P, ~ia, ~ib, operation, plan, shape, cursor,
64        state => loop(~O, ~f, ~P, ~ia, ~ib, rest, operation, plan, shape, 1n+cursor, state), state)

Uses (11)

Used by (3)