pub struct QuantizedBytes {
pub bytes: Bytes,
pub scheme: QuantScheme,
pub shape: Shape,
}Expand description
Quantized data bytes representation.
§Notes
- The quantized values are laid out as the scheme’s store says: a byte each for
Native, or packed into little-endian words along the packed axis as cubecl stores them, each line padded to whole words. - Quantization parameters are appended to the tensor data. As such, the last bytes always correspond to the scale parameter. If the quantization scheme includes an offset (zero-point) parameter, it is next to last.
Fields§
§bytes: BytesThe quantized values and quantization parameters represented as bytes.
scheme: QuantSchemeThe quantization scheme.
shape: ShapeThe shape of the quantized tensor. The block count, and so the scale count, follows from it per axis: a block that does not span the trailing dimension is not a run of elements.
Implementations§
Source§impl QuantizedBytes
impl QuantizedBytes
Sourcepub fn new<E: CheckedBitPattern + NoUninit>(
value: Vec<E>,
shape: impl Into<Shape>,
scheme: QuantScheme,
scales: &[f32],
global: Option<f32>,
) -> Self
pub fn new<E: CheckedBitPattern + NoUninit>( value: Vec<E>, shape: impl Into<Shape>, scheme: QuantScheme, scales: &[f32], global: Option<f32>, ) -> Self
Creates a new quantized bytes representation.
value holds one code per element and scales the block scales, both row-major; global
is the per-tensor scale, required by a two-level scheme and rejected by a one-level one.
Sourcepub fn num_elements(&self) -> usize
pub fn num_elements(&self) -> usize
The number of quantized elements.
Sourcepub fn into_vec_i8(self) -> (Vec<i8>, DecodedScales)
pub fn into_vec_i8(self) -> (Vec<i8>, DecodedScales)
The codes, one i8 per element in row-major order, and the scales; a float code is its
bits.
Auto Trait Implementations§
impl !RefUnwindSafe for QuantizedBytes
impl !UnwindSafe for QuantizedBytes
impl Freeze for QuantizedBytes
impl Send for QuantizedBytes
impl Sync for QuantizedBytes
impl Unpin for QuantizedBytes
impl UnsafeUnpin for QuantizedBytes
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
Mutably borrows from an owned value. Read more