def natural_product_loop

bendtorch-core@0.1.0.0 · src/tensor/matmul.bend:192

import bendtorch-core@0.1.0.0/src/tensor/matmul.bend as Matmul
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

192def natural_product_loop(fuel: Nat, +left: Shape.Shape, +right: Shape.Shape, +output: Shape.Shape,
193  +inner: U32, +columns: U32, a: Core.Tensor<left>, b: Core.Tensor<right>, out: Core.Tensor<output>, +cursor: Nat) ->
194  Result<&2, &1, Error, Core.Tensor<left> & Core.Tensor<right> & Core.Tensor<output>>:
195  match fuel:
196    case 0n:
197      Done{(a, b, out)}
198    case 1n+tail:
199      +index = U32.from_nat(cursor)
200      product_decided(left, right, output,
201        a => b => out => natural_product_loop(tail, left, right, output, inner, columns, a, b, out, 1n+cursor),
202        inner, columns, a, b, out, cursor, index, Shape.bool_case(Nat.is_eq(U32.to_nat(index), cursor)))

Uses (13)

Used by (17)