Repository navigation
Wasm gemm gemv forward - #6239
Open
anutosh491 wants to merge 2 commits into
Open
anutosh491 wants to merge 2 commits into
anutosh491 wants to merge 2 commits into
Conversation
Signed-off-by: anutosh491 <[email protected]>
Signed-off-by: anutosh491 <[email protected]>
Author
|
Again ccing @jjerphan & @martin-frbg |
This branch has not been deployed
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.
While benchmarking batch-one PyTorch linear layers (I am working on pytorch to wasm now with openblas enabled), I noticed that vector-shaped GEMM calls on Wasm still use the GEMM path. OpenBLAS already has GEMM-to-GEMV forwarding, and the Wasm GEMV kernels from #5990 make this worth enabling.
This enables
GEMM_GEMV_FORWARDfor Wasm in Make and CMake. It reuses the existing dispatch and kernels without changing their arithmetic.I've added scalar-reference regression cases for both
M=1andN=1, including real and complex types, transpose combinations and conjugated vector operands. These reuse the existing size and input-generation grids. The existing Wasm CI workflow now also triggers when the relevant build settings change.For local validation, I built the complete S/D/C/Z BLAS libraries with both Make and CMake, for wasm32 and wasm64, using LLVM 23.1.2. Each configuration passed:
The existing numerical suite can be run with
JOBS=6 WASM_RELAXED_SIMD=0 ./test/wasm/run.sh.Benchmarks below use Apple M5, Node 26.12.1, Emscripten 6.0.8, LLVM 23.1.2, portable SIMD128 and no threads. Both variants use the same kernels and inputs in one Wasm module; baseline GEMM entry points are compiled with forwarding disabled. Results are medians of nine alternating timing samples after warmup.
All rows are column-major. Dimensions are GEMM's M/N/K; times are microseconds per call.
I measured 192 cases per width. Gains depend on shape and layout: a tiny row-major ZGEMM case with conjugated operands was about 1.3% slower on wasm64 (0.448 → 0.454 µs). These are measurements from one host, rather than a claim that every call improves.
The CMake portion depends on #6238.