Expand description
Thin FFI wrapper around a vendored subset of ONNX Runtime’s MLAS
single-precision GEMM (MlasGemmBatch).
The vendored MLAS is compiled in its standalone BUILD_MLAS_NO_ONNXRUNTIME
mode, whose threading primitives normally serialize. This crate installs a
Rayon-backed parallel-for backend (see [ensure_threading] and
vendor/shim.cpp) so MLAS keeps its own cache-aware GEMM tile partitioning
while executing the tiles across the current Rayon pool — the same pool the
rest of onnx-runtime-ep-cpu uses, so there is no oversubscription. See
docs/MLAS_SYS_SPIKE.md for the original single-thread feasibility spike.
Structs§
- PackedB
- Pre-packed B weight buffer, mirroring how ORT pre-packs constant MatMul weights once and reuses the packed panel across calls.
- SQNBit
PackedB - MLAS-packed blockwise-quantized B weight for
sqnbit_gemm, mirroring how ORT pre-packs the constantMatMulNBitsinitializer once and reuses it.
Enums§
- SQNBit
Compute Type - Blocked n-bit quantized GEMM compute type, mirroring MLAS’s
MLAS_QNBIT_GEMM_COMPUTE_TYPE. Only the two x86 float-input variants used by the CPUMatMulNBitsdecode path are exposed.
Functions§
- selected_
float_ kernel - Runtime-selected f32 GEMM microkernel: 512 = AVX-512F, 3 = FMA3/AVX2, 1 = AVX, -1 = other/unknown, 0 = non-x86.
- sgemm
- General entry point mirroring the C shim, exposing transpose flags and alpha/beta. Leading dimensions default to the natural row-major strides.
- sgemm_
nn - Safe wrapper computing
C = A * Bfor row-major matrices with no transpose. - sgemm_
nn_ packed C = A * packed(B)for row-major A (m x k), reusing a pre-packed B.- sqnbit_
gemm - Compute
C = A * dequant(packed) + biasfor row-majorA(m x k) andC(m x n), reusing a pre-packed blockwise-quantized weight. - sqnbit_
gemm_ available - Returns whether MLAS has a blocked n-bit GEMM kernel for the current host
and the given
(bits, block_len, compute_type). Callers must gate everySQNBitPackedB/sqnbit_gemmuse on this beingtrue.