TGEMV_MX
Instruction Diagram
Introduction
A GEMV variant with scaled tiles that supports mixed-precision/quantized matrix-vector computation.
This instruction is currently implemented only on Ascend 950PR/Ascend 950DT and Ascend 960 (see include/pto/npu/a5/TMatmul.hpp and include/pto/npu/a6/TMatmul.hpp).
Mathematical Semantics
Conceptually (base GEMV path):
For TGEMV_MX, the scaled tiles participate in implementation-defined mixed-precision reconstruction/scaling. The architectural convention is that the output corresponds to the target-defined mx GEMV semantics.
C++ Built-in APIs
Declared in include/pto/common/pto_instr.hpp:
The public include header is
<pto/pto-inst.hpp>, and the internal declaration is located inpto/common/pto_instr.hpp.
template <typename TileRes, typename TileLeft, typename TileLeftScale, typename TileRight, typename TileRightScale,
typename... WaitEvents>
PTO_INST RecordEvent TGEMV_MX(TileRes &cMatrix, TileLeft &aMatrix, TileLeftScale &aScaleMatrix, TileRight &bMatrix, TileRightScale &bScaleMatrix, WaitEvents &... events);
template <AccPhase Phase, typename TileRes, typename TileLeft, typename TileLeftScale, typename TileRight,
typename TileRightScale, typename... WaitEvents>
PTO_INST RecordEvent TGEMV_MX(TileRes &cMatrix, TileLeft &aMatrix, TileLeftScale &aScaleMatrix, TileRight &bMatrix, TileRightScale &bScaleMatrix, WaitEvents &... events);
template <typename TileRes, typename TileLeft, typename TileLeftScale, typename TileRight, typename TileRightScale,
typename... WaitEvents>
PTO_INST RecordEvent TGEMV_MX(TileRes &cOutMatrix, TileRes &cInMatrix, TileLeft &aMatrix, TileLeftScale &aScaleMatrix, TileRight &bMatrix, TileRightScale &bScaleMatrix, WaitEvents &... events);
template <AccPhase Phase, typename TileRes, typename TileLeft, typename TileLeftScale, typename TileRight,
typename TileRightScale, typename... WaitEvents>
PTO_INST RecordEvent TGEMV_MX(TileRes &cOutMatrix, TileRes &cInMatrix, TileLeft &aMatrix, TileLeftScale &aScaleMatrix, TileRight &bMatrix, TileRightScale &bScaleMatrix, WaitEvents &... events);
template <typename TileRes, typename TileLeft, typename TileLeftScale, typename TileRight, typename TileRightScale,
typename TileBias, typename... WaitEvents>
PTO_INST RecordEvent TGEMV_MX(TileRes &cMatrix, TileLeft &aMatrix, TileLeftScale &aScaleMatrix, TileRight &bMatrix, TileRightScale &bScaleMatrix, TileBias &biasData, WaitEvents &... events);
template <AccPhase Phase, typename TileRes, typename TileLeft, typename TileLeftScale, typename TileRight,
typename TileRightScale, typename TileBias, typename... WaitEvents>
PTO_INST RecordEvent TGEMV_MX(TileRes &cMatrix, TileLeft &aMatrix, TileLeftScale &aScaleMatrix, TileRight &bMatrix, TileRightScale &bScaleMatrix, TileBias &biasData, WaitEvents &... events);Additional overloads support accumulate/bias variants and AccPhase selection.
Constraints
- Uses backend-specific mx legality checks for data types, tile positions, fractal/layout combinations, and scaling formats.
- Scaled tile compatibility and accumulator promotion are implementation-defined by the target backend.
- For portability, verify the exact
(A, B, scaleA, scaleB, C)type tuple and tile layout against the target implementation constraints. - On Ascend 950PR/Ascend 950DT, the supported
(C, A, B)triples (Cis alwaysfloat; the scaled tile isfloat8_e8m0_t): FP8(float, float8_e4m3_t, float8_e4m3_t),(float, float8_e4m3_t, float8_e5m2_t),(float, float8_e5m2_t, float8_e4m3_t),(float, float8_e5m2_t, float8_e5m2_t); FP4(float, float4_e1m2x2_t, float4_e1m2x2_t),(float, float4_e1m2x2_t, float4_e2m1x2_t),(float, float4_e2m1x2_t, float4_e2m1x2_t),(float, float4_e2m1x2_t, float4_e1m2x2_t).
Examples
For actual usage patterns, see:
docs/isa/TMATMUL_MX.mddocs/isa/TGEMV.md