pub struct SliceSafetensors<'a> { /* private fields */ }
Implementations§
source§impl<'a> SliceSafetensors<'a>
impl<'a> SliceSafetensors<'a>
sourcepub fn new(buffer: &'a [u8]) -> Result<Self>
pub fn new(buffer: &'a [u8]) -> Result<Self>
Creates a wrapper around a binary buffer and deserialize the safetensors header.
pub fn load(&self, name: &str, dev: &Device) -> Result<Tensor>
pub fn tensors(&self) -> Vec<(String, TensorView<'_>)>
pub fn get(&self, name: &str) -> Result<TensorView<'_>>
Trait Implementations§
source§impl SimpleBackend for SliceSafetensors<'_>
impl SimpleBackend for SliceSafetensors<'_>
source§fn get(
&self,
s: Shape,
name: &str,
_: Init,
dtype: DType,
dev: &Device,
) -> Result<Tensor>
fn get( &self, s: Shape, name: &str, _: Init, dtype: DType, dev: &Device, ) -> Result<Tensor>
Retrieve a tensor based on a target name and shape.
source§fn get_unchecked(
&self,
name: &str,
dtype: DType,
dev: &Device,
) -> Result<Tensor>
fn get_unchecked( &self, name: &str, dtype: DType, dev: &Device, ) -> Result<Tensor>
Retrieve a tensor based on the name.
fn contains_tensor(&self, name: &str) -> bool
Auto Trait Implementations§
impl<'a> Freeze for SliceSafetensors<'a>
impl<'a> RefUnwindSafe for SliceSafetensors<'a>
impl<'a> Send for SliceSafetensors<'a>
impl<'a> Sync for SliceSafetensors<'a>
impl<'a> Unpin for SliceSafetensors<'a>
impl<'a> UnwindSafe for SliceSafetensors<'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
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