cpu: riscv: matmul: add RVV row/col kernels with bias, ReLU post-op#3784
Merged
vpirogov merged 4 commits intouxlfoundation:mainfrom Sep 3, 2025
Merged
cpu: riscv: matmul: add RVV row/col kernels with bias, ReLU post-op#3784vpirogov merged 4 commits intouxlfoundation:mainfrom
vpirogov merged 4 commits intouxlfoundation:mainfrom
Conversation
dzarukin
reviewed
Aug 19, 2025
Contributor
Author
|
Hi @dzarukin, Thank you for the feedback! I’ve gone through your suggestions and applied the necessary fixes throughout the code. The changes should now align with your recommendations. Also, could you please clarify what copyright headers should be added for the newly created files? |
Contributor
This project is licensed under Apache License 2.0, so new files should carry corresponding license banner (see example here). |
Contributor
Author
|
Hi @vpirogov, |
dzarukin
approved these changes
Aug 20, 2025
Contributor
|
make test linters |
vpirogov
approved these changes
Sep 3, 2025
3 tasks
3 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces an optimized MatMul (Matrix Multiplication) kernel for RISC-V. The implementation provides significant performance improvements for GEMM (General Matrix-Matrix Multiplication) operations by utilizing RVV intrinsics.
This initial version lays the groundwork for RVV acceleration in MatMul, focusing on common use cases while establishing a framework for future extensions.
Key Changes
rvv_matmul_rowmajorandrvv_matmul_colmajorkernels to handle different weight memory layouts efficiently.f32data type operations.rvv_postopshandler.Implementation Details and Constraints
The current implementation has the following characteristics:
f32.f32.abx,abcx, etc.).abx) or column-major format (ba, acb, abdc,..).srcandweights(all dims except the final two matrix dims), each corresponding weight dimension must either match the src dimension or be1. In other words, weights may be broadcast across batch dims.dst; for each bias dimension it must be1or equal to the correspondingdstdimension (standard trailing-dims broadcasting).srcanddstare expected to be dense, explicit tensors (no implicit broadcasting ofsrc/dstbatch dims). Weight broadcasting (leading dims == 1) and bias broadcasting (trailing dims == 1) are supported as described above.f32tensor.Checklist
General
make testandmake test_benchdnn_*) pass locally for each commit?Performance improvements
Testing was performed using the RISC-V GNU toolchain version 14.2, and the functionality was validated under the QEMU RISCV64 emulator.
Calls to the implemented matmul can be found by searching for RISCV64GCV in
New features
Bug fixes
RFC PR