def factors

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

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/dot_fold.bend as DotFold
import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed

91# The first `count` factor pairs of output cell (row, column) of a row-major
92# product of a rows x inner and an inner x columns matrix, in increasing k:
93# left[row, k] and right[k, column].
94def factors(+row: Nat, +column: Nat, +inner: Nat, +columns: Nat,
95  +left: Shape.Shape, +left_fill: F32, +left_ops: List<&2, StorageLaws.Op>,
96  +right: Shape.Shape, +right_fill: F32, +right_ops: List<&2, StorageLaws.Op>, +count: Nat) -> List<&2, DotFold.Factors>:
97  match count:
98    case 0n:
99      Nil{}
100    case 1n+previous:
101      List.append(&2, DotFold.Factors,
102        factors(row, column, inner, columns, left, left_fill, left_ops, right, right_fill, right_ops, previous),
103        [DotFold.Factors{Replayed.value(left, left_fill, left_ops, U32.from_nat(Nat.add(Nat.mul(row, inner), previous))),
104          Replayed.value(right, right_fill, right_ops, U32.from_nat(Nat.add(Nat.mul(previous, columns), column)))}])

Uses (11)

Used by (17)