Mixed-precision matrix multiplication #
Each output entry is a left-to-right dotSequential reduction under one SitePolicy. Products
round in the product format, additions round in the accumulator format, and the completed entry
is cast to the output format.
Matrices are row-major arrays: M[i][j] is row i, column j. matmul checks that both inputs
are rectangular and that the left row width equals the number of right rows. An empty matrix has
zero columns because this representation carries no width without a row.
For an m × k matrix times a k × n matrix, the implementation extracts the right-hand columns
once and computes m * n sequential dots of length k. MatmulProof proves that every successful
output has this shape and these entries, then applies the dot-product error bound entrywise.
Row-major matrix of Models: outer array = rows, inner array = entries in that row.
Instances For
Shape failures rejected before matrix multiplication begins.
- raggedLeft
(expectedColumns : ℕ)
: MatrixShapeError
Rows of the left input do not all have the first row's width.
- raggedRight
(expectedColumns : ℕ)
: MatrixShapeError
Rows of the right input do not all have the first row's width.
- innerDimensionMismatch
(leftColumns rightRows : ℕ)
: MatrixShapeError
The left row width differs from the number of right rows.
- dotLengthMismatch
(rowLength columnLength : ℕ)
: MatrixShapeError
A checked row and column nevertheless reached the dot kernel with different lengths.
Instances For
Instances For
Column count from the first row; 0 if there are no rows.
Instances For
Extract column j as a length-M.size vector (one entry per row).
Precondition (unchecked): every row has length > j.
Instances For
Mixed-precision matmul under site policy p:
C[i][j] = dotSequential p (row i of A) (column j of B)
A,Bentries are inp.storage.- Each inner product uses
p.product/p.accumulatoras indotSequential. - Entries of
Care inp.output.
On success, C has A.size rows and ncols B columns. Both inputs must be rectangular and the
left row width must equal B.size; otherwise the corresponding MatrixShapeError is returned.
Instances For
Matmul with one format in every site role.