def fold_from
bendtorch-core@0.1.0.0 · src/tensor/contracts/matmul_parallel_proof.bend:422
import bendtorch-core@0.1.0.0/src/tensor/contracts/matmul_parallel_proof.bend as MatmulParallelProof
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as StorageLaws
import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed
422
423
424def fold_from(fuel: Nat, +span: Nat, +columns: Nat, +row: Nat, +column: Nat, +left: Shape.Shape, +left_fill: F32, +left_ops: List<&2, StorageLaws.Op>,
425 +right: Shape.Shape, +right_fill: F32, +right_ops: List<&2, StorageLaws.Op>, +cursor: Nat, accumulator: F32) -> F32:
426 match fuel:
427 case 0n:
428 accumulator
429 case 1n+rest:
430 fold_from(rest, span, columns, row, column, left, left_fill, left_ops, right, right_fill, right_ops, 1n+cursor,
431 F32.add(accumulator, F32.mul(Replayed.value(left, left_fill, left_ops, U32.from_nat(Nat.add(Nat.mul(row, span), cursor))),
432 Replayed.value(right, right_fill, right_ops, U32.from_nat(Nat.add(Nat.mul(cursor, columns), column))))))