law matmul_nt_ordered

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

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

336# `matmul_nt(x, W)` is the product of two `Kept` operands, x @ W^T: cell
337# (row, column) folds x[row, k] * W[column, k], the words of x at
338# row * inner + k and of W at column * inner + k, in increasing k from +0.0.
339law matmul_nt_ordered:
340  for +left: Shape.Shape
341  for +right: Shape.Shape
342  for +plan: Matrix.Product<Matrix.Kept{}, Matrix.Kept{}, left, right>
343  for planned: {Matrix.product_plan(Matrix.Kept{}, Matrix.Kept{}, left, right) == Done{plan} :
344    Result<&2, &2, Matrix.Error, Matrix.Product<Matrix.Kept{}, Matrix.Kept{}, left, right>>}
345  for +left_fill: F32
346  for +left_ops: List<&2, StorageLaws.Op>
347  for -left_fits: {Lifecycle.logical_length(Replayed.storage(left, left_fill, left_ops)) == Shape.logical_numel(Shape.dimensions(left)) : Nat}
348  for +right_fill: F32
349  for +right_ops: List<&2, StorageLaws.Op>
350  for -right_fits: {Lifecycle.logical_length(Replayed.storage(right, right_fill, right_ops)) == Shape.logical_numel(Shape.dimensions(right)) : Nat}
351  FoldRecords.MatmulContract<left, right, product_rows(Matrix.Kept{}, Matrix.Kept{}, left, right, plan),
352    product_columns(Matrix.Kept{}, Matrix.Kept{}, left, right, plan),
353    row => column => DotFold.dot_fold(product_factors(row, column, Matrix.Kept{}, Matrix.Kept{},
354      product_inner(Matrix.Kept{}, Matrix.Kept{}, left, right, plan), product_rows(Matrix.Kept{}, Matrix.Kept{}, left, right, plan),
355      product_columns(Matrix.Kept{}, Matrix.Kept{}, left, right, plan),
356      left, left_fill, left_ops, right, right_fill, right_ops, product_inner(Matrix.Kept{}, Matrix.Kept{}, left, right, plan)), 0.0),
357    other => Replayed.value(left, left_fill, left_ops, other),
358    other => Replayed.value(right, right_fill, right_ops, other),
359    Matrix.matmul_nt(Core.Packed{left, Core.TTensor{Replayed.storage(left, left_fill, left_ops), left_fits}},
360      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.