def run_next

bendtorch-core@0.1.0.0 · src/tensor/contracts/matmul_parallel_proof.bend:516

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/matmul.bend as Matrix
import bendtorch-core@0.1.0.0/src/tensor/matrix_index_proof.bend as MatrixIndex
import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed
import bendtorch-core@0.1.0.0/src/tensor/contracts/binary_build_proof.bend as Build
import bendtorch-core@0.1.0.0/src/storage/api.bend as Api

516# A term with more after it: the reads hold the replayed words, the offsets
517# step to the next term's, and the run goes on from its reads of the same
518# copies.
519def run_next(+rest: Nat, +span: Nat, +columns: Nat, +left: Shape.Shape, +left_fill: F32, +left_ops: List<&2, StorageLaws.Op>, +ha: List<&2, Api.Effect>, +dl: Nat, +fa: F32, +right: Shape.Shape, +right_fill: F32, +right_ops: List<&2, StorageLaws.Op>, +hb: List<&2, Api.Effect>, +dr: Nat, +fb: F32, +lsrc: Source<left, left_fill, left_ops, ha, dl, fa>, +rsrc: Source<right, right_fill, right_ops, hb, dr, fb>, +rows: Nat, +row: Nat, +column: Nat, +cursor: Nat, +accumulator: F32,
520  +row_below: {Nat.is_lt(row, rows) == True{} : Bool}, +left_extents: {Shape.extents(left) == [rows, span] : List<&2, Nat>},
521  +column_below: {Nat.is_lt(column, columns) == True{} : Bool}, +right_extents: {Shape.extents(right) == [span, columns] : List<&2, Nat>},
522  +below: {Nat.is_lt(cursor, span) == True{} : Bool},
523  pl: Array<F32> & F32, +exact_l: {pl == Array.get(F32, Api.arr(ha, dl, fa), Matrix.left_index(span, row, cursor)) : Array<F32> & F32},
524  pr: Array<F32> & F32, +exact_r: {pr == Array.get(F32, Api.arr(hb, dr, fb), Matrix.right_index(columns, column, cursor)) : Array<F32> & F32},
525  next: DotIs(1n+rest, span, columns, left, left_fill, left_ops, ha, dl, fa, right, right_fill, right_ops, hb, dr, fb, row, column, 1n+cursor, F32.add(accumulator, F32.mul(Replayed.value(left, left_fill, left_ops, Matrix.left_index(span, row, cursor)), Replayed.value(right, right_fill, right_ops, Matrix.right_index(columns, column, cursor)))), Matrix.product_run(rest, 1n, columns, Nat.add(Nat.mul(row, span), 1n+cursor), Nat.add(Nat.mul(1n+cursor, columns), column), F32.add(accumulator, F32.mul(Replayed.value(left, left_fill, left_ops, Matrix.left_index(span, row, cursor)), Replayed.value(right, right_fill, right_ops, Matrix.right_index(columns, column, cursor)))), Array.get(F32, Api.arr(ha, dl, fa), Matrix.left_index(span, row, 1n+cursor)), Array.get(F32, Api.arr(hb, dr, fb), Matrix.right_index(columns, column, 1n+cursor))))) ->
526  DotIs(2n+rest, span, columns, left, left_fill, left_ops, ha, dl, fa, right, right_fill, right_ops, hb, dr, fb, row, column, cursor, accumulator, Matrix.product_run(1n+rest, 1n, columns, Nat.add(Nat.mul(row, span), cursor), Nat.add(Nat.mul(cursor, columns), column), accumulator, pl, pr)):
527  (la, x) = pl
528  (ra, y) = pr
529  +ex = source_read(left, left_fill, left_ops, ha, dl, fa, lsrc, Matrix.left_index(span, row, cursor),
530    index_inside(left, Nat.add(Nat.mul(row, span), cursor), MatrixIndex.left_below(rows, span, row, row_below, left, left_extents, cursor, below)),
531    (la, x), exact_l)
532  +ey = source_read(right, right_fill, right_ops, hb, dr, fb, rsrc, Matrix.right_index(columns, column, cursor),
533    index_inside(right, Nat.add(Nat.mul(cursor, columns), column), MatrixIndex.right_below(span, columns, column, column_below, right, right_extents, cursor, below)),
534    (ra, y), exact_r)
535  +el = Build.got_kept(dl, ha, fa, Matrix.left_index(span, row, cursor), (la, x), exact_l)
536  +er = Build.got_kept(dr, hb, fb, Matrix.right_index(columns, column, cursor), (ra, y), exact_r)
537  %Equal.sym(F32, x, Replayed.value(left, left_fill, left_ops, Matrix.left_index(span, row, cursor)), ex) :
538    DotIs(2n+rest, span, columns, left, left_fill, left_ops, ha, dl, fa, right, right_fill, right_ops, hb, dr, fb, row, column, cursor, accumulator, Matrix.product_run(rest, 1n, columns, Nat.add(1n, Nat.add(Nat.mul(row, span), cursor)), Nat.add(columns, Nat.add(Nat.mul(cursor, columns), column)), F32.add(accumulator, F32.mul(_, y)), Array.get(F32, la, U32.from_nat(Nat.add(1n, Nat.add(Nat.mul(row, span), cursor)))), Array.get(F32, ra, U32.from_nat(Nat.add(columns, Nat.add(Nat.mul(cursor, columns), column))))))
539  %Equal.sym(F32, y, Replayed.value(right, right_fill, right_ops, Matrix.right_index(columns, column, cursor)), ey) :
540    DotIs(2n+rest, span, columns, left, left_fill, left_ops, ha, dl, fa, right, right_fill, right_ops, hb, dr, fb, row, column, cursor, accumulator, Matrix.product_run(rest, 1n, columns, Nat.add(1n, Nat.add(Nat.mul(row, span), cursor)), Nat.add(columns, Nat.add(Nat.mul(cursor, columns), column)), F32.add(accumulator, F32.mul(Replayed.value(left, left_fill, left_ops, Matrix.left_index(span, row, cursor)), _)), Array.get(F32, la, U32.from_nat(Nat.add(1n, Nat.add(Nat.mul(row, span), cursor)))), Array.get(F32, ra, U32.from_nat(Nat.add(columns, Nat.add(Nat.mul(cursor, columns), column))))))
541  %Equal.sym(Array<F32>, la, Api.arr(ha, dl, fa), el) :
542    DotIs(2n+rest, span, columns, left, left_fill, left_ops, ha, dl, fa, right, right_fill, right_ops, hb, dr, fb, row, column, cursor, accumulator, Matrix.product_run(rest, 1n, columns, Nat.add(1n, Nat.add(Nat.mul(row, span), cursor)), Nat.add(columns, Nat.add(Nat.mul(cursor, columns), column)), F32.add(accumulator, F32.mul(Replayed.value(left, left_fill, left_ops, Matrix.left_index(span, row, cursor)), Replayed.value(right, right_fill, right_ops, Matrix.right_index(columns, column, cursor)))), Array.get(F32, _, U32.from_nat(Nat.add(1n, Nat.add(Nat.mul(row, span), cursor)))), Array.get(F32, ra, U32.from_nat(Nat.add(columns, Nat.add(Nat.mul(cursor, columns), column))))))
543  %Equal.sym(Array<F32>, ra, Api.arr(hb, dr, fb), er) :
544    DotIs(2n+rest, span, columns, left, left_fill, left_ops, ha, dl, fa, right, right_fill, right_ops, hb, dr, fb, row, column, cursor, accumulator, Matrix.product_run(rest, 1n, columns, Nat.add(1n, Nat.add(Nat.mul(row, span), cursor)), Nat.add(columns, Nat.add(Nat.mul(cursor, columns), column)), F32.add(accumulator, F32.mul(Replayed.value(left, left_fill, left_ops, Matrix.left_index(span, row, cursor)), Replayed.value(right, right_fill, right_ops, Matrix.right_index(columns, column, cursor)))), Array.get(F32, Api.arr(ha, dl, fa), U32.from_nat(Nat.add(1n, Nat.add(Nat.mul(row, span), cursor)))), Array.get(F32, _, U32.from_nat(Nat.add(columns, Nat.add(Nat.mul(cursor, columns), column))))))
545  %Equal.sym(Nat, Nat.add(1n, Nat.add(Nat.mul(row, span), cursor)), Nat.add(Nat.mul(row, span), 1n+cursor), MatrixIndex.stepped_left(span, row, cursor)) :
546    DotIs(2n+rest, span, columns, left, left_fill, left_ops, ha, dl, fa, right, right_fill, right_ops, hb, dr, fb, row, column, cursor, accumulator, Matrix.product_run(rest, 1n, columns, _, Nat.add(columns, Nat.add(Nat.mul(cursor, columns), column)), F32.add(accumulator, F32.mul(Replayed.value(left, left_fill, left_ops, Matrix.left_index(span, row, cursor)), Replayed.value(right, right_fill, right_ops, Matrix.right_index(columns, column, cursor)))), Array.get(F32, Api.arr(ha, dl, fa), U32.from_nat(_)), Array.get(F32, Api.arr(hb, dr, fb), U32.from_nat(Nat.add(columns, Nat.add(Nat.mul(cursor, columns), column))))))
547  %Equal.sym(Nat, Nat.add(columns, Nat.add(Nat.mul(cursor, columns), column)), Nat.add(Nat.mul(1n+cursor, columns), column), MatrixIndex.stepped_right(columns, column, cursor)) :
548    DotIs(2n+rest, span, columns, left, left_fill, left_ops, ha, dl, fa, right, right_fill, right_ops, hb, dr, fb, row, column, cursor, accumulator, Matrix.product_run(rest, 1n, columns, Nat.add(Nat.mul(row, span), 1n+cursor), _, F32.add(accumulator, F32.mul(Replayed.value(left, left_fill, left_ops, Matrix.left_index(span, row, cursor)), Replayed.value(right, right_fill, right_ops, Matrix.right_index(columns, column, cursor)))), Array.get(F32, Api.arr(ha, dl, fa), U32.from_nat(Nat.add(Nat.mul(row, span), 1n+cursor))), Array.get(F32, Api.arr(hb, dr, fb), U32.from_nat(_))))
549  next

Uses (33)

Used by (1)