Linear Algebra IR Lowering #
Checked lowering for matrix multiplication and payload-backed linear layers.
Both operations accept the same shapes as the IR semantics: any shared leading shape followed by
the matrix axes. lowerMatmul obtains the output shape from OpContracts.inferMatmulOutShape, the
contract shared with shape inference and evaluation, and only decomposes the parent shapes itself
to build typed indices. The closures apply NN.IR.Graph.matmulLeading and
NN.IR.Graph.linearLeading, the same typed operators the IR evaluator uses.
Each operation has its own small lower* definition. lowerLinearAlgebra only dispatches on the
operation kind, and the lowerLinearAlgebra_* equation lemmas let correctness proofs reduce a
dispatch to the branch they care about without unfolding the whole dispatcher.
Checked lowering for .matmul over any shared leading shape.
The final two axes follow the matrix rule (... × m × n) · (... × n × p) → (... × m × p). The
output shape is taken from OpContracts.inferMatmulOutShape; the typed decomposition below is
checked against it so the contract remains the single source of truth.
Instances For
Checked lowering for .linear over any leading shape.
The final input axis must equal the payload's inDim; every leading axis is preserved and the
affine map y = Wx + b is applied independently at each leading index.
Instances For
Checked lowering for matrix multiplication and payload-backed linear layers.
Instances For
Dispatch equation for .matmul.
Dispatch equation for .linear.