pub struct SafeTensorFile { /* private fields */ }Expand description
A parsed SafeTensors file backed by an in-memory byte buffer.
Implementations§
Source§impl SafeTensorFile
impl SafeTensorFile
Sourcepub fn from_file(path: &Path) -> Result<Self, ModelError>
pub fn from_file(path: &Path) -> Result<Self, ModelError>
Parse a SafeTensors file from disk.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, ModelError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, ModelError>
Parse a SafeTensors file from an in-memory byte slice.
Sourcepub fn tensor_names(&self) -> Vec<&str>
pub fn tensor_names(&self) -> Vec<&str>
Returns a list of all tensor names in the file.
Sourcepub fn tensor_info(&self, name: &str) -> Option<TensorInfo>
pub fn tensor_info(&self, name: &str) -> Option<TensorInfo>
Returns metadata for a tensor by name.
Sourcepub fn load_tensor(&self, name: &str) -> Result<Tensor, ModelError>
pub fn load_tensor(&self, name: &str) -> Result<Tensor, ModelError>
Load a single tensor by name, converting to F32 if necessary.
F16 and BF16 data are converted to F32. I32, I64, U8, and Bool are converted to F32 by casting each element.
Auto Trait Implementations§
impl Freeze for SafeTensorFile
impl RefUnwindSafe for SafeTensorFile
impl Send for SafeTensorFile
impl Sync for SafeTensorFile
impl Unpin for SafeTensorFile
impl UnsafeUnpin for SafeTensorFile
impl UnwindSafe for SafeTensorFile
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
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>
Converts
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>
Converts
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