Skip to main content

Crate mlas_sys

Crate mlas_sys 

Source
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.
SQNBitPackedB
MLAS-packed blockwise-quantized B weight for sqnbit_gemm, mirroring how ORT pre-packs the constant MatMulNBits initializer once and reuses it.

Enums§

SQNBitComputeType
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 CPU MatMulNBits decode 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 * B for 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) + bias for row-major A (m x k) and C (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 every SQNBitPackedB / sqnbit_gemm use on this being true.