law matmul_tn_ordered

bendtorch-core@0.1.0.0 · src/tensor/contracts/LAWS.bend:362

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

362# `matmul_tn(g, x)` is the product of two `Swapped` operands, g^T @ x: cell
363# (row, column) folds g[k, row] * x[k, column], the words of g at
364# k * rows + row and of x at k * columns + column, in increasing k from +0.0.
365law matmul_tn_ordered:
366  for +left: Shape.Shape
367  for +right: Shape.Shape
368  for +plan: Matrix.Product<Matrix.Swapped{}, Matrix.Swapped{}, left, right>
369  for planned: {Matrix.product_plan(Matrix.Swapped{}, Matrix.Swapped{}, left, right) == Done{plan} :
370    Result<&2, &2, Matrix.Error, Matrix.Product<Matrix.Swapped{}, Matrix.Swapped{}, left, right>>}
371  for +left_fill: F32
372  for +left_ops: List<&2, StorageLaws.Op>
373  for -left_fits: {Lifecycle.logical_length(Replayed.storage(left, left_fill, left_ops)) == Shape.logical_numel(Shape.dimensions(left)) : Nat}
374  for +right_fill: F32
375  for +right_ops: List<&2, StorageLaws.Op>
376  for -right_fits: {Lifecycle.logical_length(Replayed.storage(right, right_fill, right_ops)) == Shape.logical_numel(Shape.dimensions(right)) : Nat}
377  FoldRecords.MatmulContract<left, right, product_rows(Matrix.Swapped{}, Matrix.Swapped{}, left, right, plan),
378    product_columns(Matrix.Swapped{}, Matrix.Swapped{}, left, right, plan),
379    row => column => DotFold.dot_fold(product_factors(row, column, Matrix.Swapped{}, Matrix.Swapped{},
380      product_inner(Matrix.Swapped{}, Matrix.Swapped{}, left, right, plan), product_rows(Matrix.Swapped{}, Matrix.Swapped{}, left, right, plan),
381      product_columns(Matrix.Swapped{}, Matrix.Swapped{}, left, right, plan),
382      left, left_fill, left_ops, right, right_fill, right_ops, product_inner(Matrix.Swapped{}, Matrix.Swapped{}, left, right, plan)), 0.0),
383    other => Replayed.value(left, left_fill, left_ops, other),
384    other => Replayed.value(right, right_fill, right_ops, other),
385    Matrix.matmul_tn(Core.Packed{left, Core.TTensor{Replayed.storage(left, left_fill, left_ops), left_fits}},
386      Core.Packed{right, Core.TTensor{Replayed.storage(right, right_fill, right_ops), right_fits}})>

Uses (25)

Used by (0)

No other definition uses this definition.