onnxruntime
9e815996 - [MLAS/RISC-V] Add RVV INT8 GEMM/GEMV, M=1 routing, and activation kernels (follow-up #28261) (#28308)

Commit
43 days ago
[MLAS/RISC-V] Add RVV INT8 GEMM/GEMV, M=1 routing, and activation kernels (follow-up #28261) (#28308) ## Description Follow-up to #28261 (RVV CPU EP). This PR adds four RVV MLAS kernels on top of the existing `if(HAS_RISCV64_RVV)` block in `cmake/onnxruntime_mlas.cmake`: 1. **INT8 GEMM** (`riscv64/qgemm_kernel_rvv.cpp`) — `vwmulu.vv` / `vwaddu.wv` widening; wired through `MLAS_PLATFORM` 4-signedness dispatch (LARCH64 idiom). 2. **M=1 SGEMM routing** — extends the ARM64/WASM `MlasGemvFloatKernel` `#elif` to RISCV64; kernel comes from existing `SgemvKernelScalar.cpp` (rv-gcc autovec). 3. **Activation kernels** (`riscv64/activation_kernel_rvv.cpp`) — RVV `Erf`, `Tanh`, `Logistic`, `ComputeExpF32`, `Silu`, `GeluErf`. 4. **INT8 GEMV M=1 fast path** — `MlasGemmQuantTryGemvKernel<...RVV>` specialization (mirrors AVX2 `qgemm_kernel_avx2.cpp:131`); U8×S8 only. Rebased onto current `main`. Later commits fold in review feedback: per-signedness dispatch structs, the per-matrix `ZeroPointB` accumulator, NaN round-trip in the activation kernels, a full-range two-step `exp`, and infinity handling in SiLU/GELU. The correctness fixes are verified on SpacemiT K3 (riscv64, RVV) with `onnxruntime_mlas_test`. ## Performance K3 (SpacemiT X100, VLEN=256, 4 threads, p50 ms over 30 reps, real BAAI/bge-* ONNX inputs). Baseline = `microsoft/onnxruntime` post-#28261 (`62f742f1aa`). Cross-built with `riscv64-linux-gnu-g++` 15.2 + `-march=rv64gcv -mabi=lp64d`. ### FP32 transformer encoders | Model | Upstream | This PR | Speedup | | ------------------------------ | --------: | --------: | :-----: | | BAAI/bge-small-zh-v1.5 | 66.3 ms | 63.8 ms | 1.04× | | BAAI/bge-base-zh-v1.5 | 404.4 ms | 393.5 ms | 1.03× | | BAAI/bge-reranker-base | 403.7 ms | 391.7 ms | 1.03× | ### INT8 quantized | Model | Upstream | This PR | Speedup | | ------------------------------ | --------: | --------: | :-----: | | BAAI/bge-small-zh-v1.5 INT8 | 301.3 ms | 131.3 ms | 2.29× | | BAAI/bge-base-zh-v1.5 INT8 | 1958.8 ms | 669.2 ms | **2.93×** | | BAAI/bge-reranker-base INT8 | 1956.8 ms | 668.6 ms | **2.93×** | ### INT8 GEMV M=1 (kernel-level micro-bench, 1 thread) | Shape | scalar | autovec | this PR | vs autovec | | ----------- | -------: | -------: | -------: | :--------: | | K=N=384 | 1.45 GOPS | 2.34 GOPS | 16.68 GOPS | **7.13×** | | K=N=768 | 1.46 GOPS | 2.34 GOPS | 6.17 GOPS | 2.64× | | K=N=4096 | 1.46 GOPS | 2.33 GOPS | 1.92 GOPS | 0.82× (memory-bound) | The GEMV path triggers only when `RangeCountM == 1` and zero-points are zero (`qgemm.h:331` gate); BERT seq=128 encoders do not exercise it, so its contribution is not visible in the e2e tables above. --------- Signed-off-by: qiurui144 <happyqiurui@163.com>
Author
Parents
Loading