pub struct OneBitTensor<'a> {
pub name: String,
pub shape: Vec<u64>,
/* private fields */
}Expand description
A 1-bit tensor backed by Q1_0_g128 blocks.
This wraps raw GGUF tensor data and provides typed access to blocks without copying or dequantizing the entire tensor.
Fields§
§name: StringTensor name.
shape: Vec<u64>Shape dimensions.
Implementations§
Source§impl<'a> OneBitTensor<'a>
impl<'a> OneBitTensor<'a>
Sourcepub fn from_raw(
name: String,
shape: Vec<u64>,
data: &'a [u8],
) -> BonsaiResult<Self>
pub fn from_raw( name: String, shape: Vec<u64>, data: &'a [u8], ) -> BonsaiResult<Self>
Create a 1-bit tensor from raw GGUF tensor data bytes.
Sourcepub fn num_blocks(&self) -> usize
pub fn num_blocks(&self) -> usize
Number of blocks in this tensor.
Sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
Total number of elements (weights) in this tensor.
Sourcepub fn block(&self, index: usize) -> &BlockQ1_0G128
pub fn block(&self, index: usize) -> &BlockQ1_0G128
Get a reference to the block at the given index.
Sourcepub fn blocks(&self) -> &[BlockQ1_0G128]
pub fn blocks(&self) -> &[BlockQ1_0G128]
Get all blocks as a slice.
Sourcepub fn dequantize_all(&self) -> Vec<f32>
pub fn dequantize_all(&self) -> Vec<f32>
Dequantize all blocks to FP32 values.
For the full tensor, this allocates and fills an output vector. For per-operation dequantization, use the kernel crate instead.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for OneBitTensor<'a>
impl<'a> RefUnwindSafe for OneBitTensor<'a>
impl<'a> Send for OneBitTensor<'a>
impl<'a> Sync for OneBitTensor<'a>
impl<'a> Unpin for OneBitTensor<'a>
impl<'a> UnsafeUnpin for OneBitTensor<'a>
impl<'a> UnwindSafe for OneBitTensor<'a>
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