Skip to content

vector.mma

← vector dialect

Compute a matrix multiply-accumulate over target-shaped vector fragments using native matrix arithmetic. Floating intermediate precision, association, rounding, subnormal handling, and special-value behavior follow the selected target's arithmetic contract; the result type does not promise the bits of an ordered scalar FMA sequence. A target-independent reference decomposition converts each logical input to the accumulator type and applies scalar.fmaf in increasing K order from the initial accumulator. That reference evaluation remains permitted even when native execution differs. Use explicit scalar.fmaf operations or vector.dotf on widened inputs when ordered fused accumulation is required. The op consumes only the physical lhs, rhs, and init vectors; logical M/N/K shape, fragment role, packed storage schema, scales, codebooks, sparse metadata, and other interpretation data are carried by vector.fragment facts on those operands. Lowering queries those facts without baking target-specific witnesses into the MMA syntax. The optional saturate flag clamps an integer accumulation result to its destination range.

Operation contract

Property Value
Semantic phase executable
Traits Pure, SafeToSpeculate
Target contracts vector.contraction

Signature

Kind Name Type Cardinality Description
Operand lhs vector required Physical lhs fragment vector.
Operand rhs vector required Physical rhs fragment vector.
Operand init vector required Physical accumulator/addend fragment vector.
Result result vector required Updated accumulator/result fragment vector.
Attribute flags flags MmaFlags optional —

Verification constraints

  • SameType(init, result)

Examples

%r = vector.mma %lhs, %rhs, %init : vector<8xf16>, vector<8xf16>, vector<8xf32>
%r = vector.mma<saturate> %lhs, %rhs, %init : vector<32xi8>, vector<32xi8>, vector<8xi32>
%r = vector.mma %lhs, %rhs, %init : vector<6xi32>, vector<6xi32>, vector<8xf32>