pub struct SQNBitPackedB { /* private fields */ }Expand description
MLAS-packed blockwise-quantized B weight for sqnbit_gemm, mirroring how
ORT pre-packs the constant MatMulNBits initializer once and reuses it.
The B bytes, scales, and optional zero points use the standard ONNX
MatMulNBits layout ([N, ceil(K/blk_len), blk_len*bits/8], LSB-first
nibbles; scales [N, ceil(K/blk_len)]; packed uint8 zero points). For
Fp32 compute MLAS repacks only the nibbles and consumes scales/zero points
at GEMM time (kept here so the packed weight is self-contained). For Int8
compute MLAS bakes scale and zero point into per-block sums inside the packed
buffer, so scale/zp are unused at GEMM time. A default (absent) zero
point is the ONNX/MLAS midpoint (8 for int4), so symmetric weights need no
zero point.
Implementations§
Source§impl SQNBitPackedB
impl SQNBitPackedB
Sourcepub fn new(
n: usize,
k: usize,
bits: usize,
blk_len: usize,
comp: SQNBitComputeType,
quant_b_data: &[u8],
scale: &[f32],
zp: Option<&[u8]>,
) -> Option<Self>
pub fn new( n: usize, k: usize, bits: usize, blk_len: usize, comp: SQNBitComputeType, quant_b_data: &[u8], scale: &[f32], zp: Option<&[u8]>, ) -> Option<Self>
Pack a blockwise-quantized B weight, returning None when MLAS reports
no packing/kernel is available for this shape on the current host (the
caller must then fall back to another path).
Sourcepub fn dimensions(&self) -> (usize, usize)
pub fn dimensions(&self) -> (usize, usize)
Logical (k, n) dimensions of the packed weight.
Trait Implementations§
Source§impl Drop for SQNBitPackedB
impl Drop for SQNBitPackedB
impl Send for SQNBitPackedB
impl Sync for SQNBitPackedB
Auto Trait Implementations§
impl Freeze for SQNBitPackedB
impl RefUnwindSafe for SQNBitPackedB
impl Unpin for SQNBitPackedB
impl UnsafeUnpin for SQNBitPackedB
impl UnwindSafe for SQNBitPackedB
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more