def matmul_ordered

bendtorch-core@0.1.0.0 · src/tensor/contracts/matmul_proof.bend:365

import bendtorch-core@0.1.0.0/src/tensor/contracts/matmul_proof.bend as MatmulProof
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/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/lifecycle.bend as Lifecycle
import bendtorch-core@0.1.0.0/src/tensor/matmul.bend as Matrix
import bendtorch-core@0.1.0.0/src/tensor/dot_fold.bend as DotFold
import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed
import bendtorch-core@0.1.0.0/src/tensor/contracts/fold_records.bend as Records
import bendtorch-core@0.1.0.0/src/tensor/contracts/LAWS.bend as Laws

365def matmul_ordered(+left: Shape.Shape, +right: Shape.Shape, +plan: Matrix.Plan<left, right>,
366  planned: {Matrix.plan(left, right) == Done{plan} : Result<&2, &2, Matrix.Error, Matrix.Plan<left, right>>},
367  +left_fill: F32, +left_ops: List<&2, StorageLaws.Op>,
368  -left_fits: {Lifecycle.logical_length(Replayed.storage(left, left_fill, left_ops)) == Shape.logical_numel(Shape.dimensions(left)) : Nat},
369  +right_fill: F32, +right_ops: List<&2, StorageLaws.Op>,
370  -right_fits: {Lifecycle.logical_length(Replayed.storage(right, right_fill, right_ops)) == Shape.logical_numel(Shape.dimensions(right)) : Nat}) ->
371  Records.MatmulContract<left, right, Laws.matrix_rows(left, right, plan), Laws.matrix_columns(left, right, plan),
372    row => column => DotFold.dot_fold(Laws.factors(row, column, Laws.matrix_inner(left, right, plan), Laws.matrix_columns(left, right, plan),
373      left, left_fill, left_ops, right, right_fill, right_ops, Laws.matrix_inner(left, right, plan)), 0.0),
374    other => Replayed.value(left, left_fill, left_ops, other),
375    other => Replayed.value(right, right_fill, right_ops, other),
376    Matrix.matmul(Core.Packed{left, Core.TTensor{Replayed.storage(left, left_fill, left_ops), left_fits}},
377      Core.Packed{right, Core.TTensor{Replayed.storage(right, right_fill, right_ops), right_fits}})>:
378  match plan:
379    case Matrix.Plan{+output, +rows, +inner, +right_inner, +columns, le, re, oe, compatible}:
380      parallel_ordered_planned(left, right, output, rows, inner, right_inner, columns, le, re, oe, compatible, planned,
381        left_fill, left_ops, left_fits, right_fill, right_ops, right_fits)

Uses (24)

Used by (1)