Skip to main content

SafetensorsBackend

Struct SafetensorsBackend 

Source
pub struct SafetensorsBackend { /* private fields */ }
Expand description

Checkpoint over a SafetensorsCheckpoint (bounded per-tensor reads).

Checkpoint::tensor_bytes returns Cow::Owned bytes read from the owning shard; memory use is bounded by the requested tensor.

Implementations§

Source§

impl SafetensorsBackend

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self>

Open a .safetensors file, *.safetensors.index.json, or shard directory.

Source

pub fn checkpoint(&self) -> &SafetensorsCheckpoint

Format-specific handle (manifest, candidates, record lookup).

Source

pub fn into_checkpoint(self) -> SafetensorsCheckpoint

Unwrap into the format-specific handle.

Trait Implementations§

Source§

impl Checkpoint for SafetensorsBackend

Source§

fn source(&self) -> &CheckpointSource

Checkpoint identity: format, input path, root, payload files.
Source§

fn tensors(&self) -> &[TensorInfo]

Every tensor, sorted by name.
Source§

fn metadata(&self) -> &CheckpointMetadata

Scalar metadata.
Source§

fn tensor_bytes(&self, name: &str) -> Result<Cow<'_, [u8]>>

Raw payload bytes of name, length TensorInfo::byte_len.
Source§

fn format(&self) -> CheckpointFormat

Container format.
Source§

fn tensor(&self, name: &str) -> Option<&TensorInfo>

Look up one tensor by exact name.
Source§

impl Debug for SafetensorsBackend

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for SafetensorsBackend

§

impl Freeze for SafetensorsBackend

§

impl Move for SafetensorsBackend

§

impl RefUnwindSafe for SafetensorsBackend

§

impl Send for SafetensorsBackend
where &'static str: Send, RawVecInner: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send, NodeRef<Owned, String, ResolvedShard, LeafOrInternal>: Send, BoxRaw<(String, ResolvedShard)>: Send, NodeRef<Owned, String, usize, LeafOrInternal>: Send, BoxRaw<(String, usize)>: Send, NodeRef<Owned, String, MetadataValue, LeafOrInternal>: Send, BoxRaw<(String, MetadataValue)>: Send,

§

impl Sync for SafetensorsBackend
where RawVecInner: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync, NodeRef<Owned, String, ResolvedShard, LeafOrInternal>: Sync, BoxRaw<(String, ResolvedShard)>: Sync, NodeRef<Owned, String, usize, LeafOrInternal>: Sync, BoxRaw<(String, usize)>: Sync, NodeRef<Owned, String, MetadataValue, LeafOrInternal>: Sync, BoxRaw<(String, MetadataValue)>: Sync,

§

impl Unpin for SafetensorsBackend
where &'static str: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin, *const LeafNode<String, ResolvedShard> is !null: Unpin, Box<(String, ResolvedShard)>: Unpin, *const LeafNode<String, usize> is !null: Unpin, Box<(String, usize)>: Unpin, *const LeafNode<String, MetadataValue> is !null: Unpin, Box<(String, MetadataValue)>: Unpin,

§

impl UnsafeUnpin for SafetensorsBackend

§

impl UnwindSafe for SafetensorsBackend

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.