pub struct GGUFWriter { /* private fields */ }Expand description
Streaming GGUF v3 writer.
Call Self::add_metadata for every key-value pair, then Self::add_tensor for
every tensor, then Self::write_to to flush the complete file.
Implementations§
Source§impl GGUFWriter
impl GGUFWriter
pub fn new() -> Self
pub fn add_metadata(&mut self, key: impl Into<String>, value: GGUFMetaValue)
Sourcepub fn add_tensor(
&mut self,
name: impl Into<String>,
shape: Vec<u64>,
dtype: GGMLType,
data: Vec<u8>,
)
pub fn add_tensor( &mut self, name: impl Into<String>, shape: Vec<u64>, dtype: GGMLType, data: Vec<u8>, )
Buffer a tensor. data must already be in the target dtype byte layout.
Sourcepub fn write_to<W: Write + Seek>(&self, writer: &mut W) -> Result<()>
pub fn write_to<W: Write + Seek>(&self, writer: &mut W) -> Result<()>
Serialize the complete GGUF file to writer.
Tensors are laid out in sorted-name order regardless of insertion order, so
converting the same source twice yields byte-identical files (several converters
feed tensors in safetensors’ HashMap iteration order, which is randomized per
process).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GGUFWriter
impl RefUnwindSafe for GGUFWriter
impl Send for GGUFWriter
impl Sync for GGUFWriter
impl Unpin for GGUFWriter
impl UnsafeUnpin for GGUFWriter
impl UnwindSafe for GGUFWriter
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