pub struct SafetensorsMmapBackend { /* private fields */ }Expand description
Checkpoint over a memory-mapped
crate::safetensors::SafetensorsCheckpointMmap (borrowed payloads).
Callers must not truncate shard files while the backend is alive (standard mmap invariant).
Implementations§
Source§impl SafetensorsMmapBackend
impl SafetensorsMmapBackend
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Map a .safetensors file, *.safetensors.index.json, or shard directory.
Sourcepub fn checkpoint(&self) -> &SafetensorsCheckpointMmap
pub fn checkpoint(&self) -> &SafetensorsCheckpointMmap
Format-specific mapped handle.
Sourcepub fn into_checkpoint(self) -> SafetensorsCheckpointMmap
pub fn into_checkpoint(self) -> SafetensorsCheckpointMmap
Unwrap into the format-specific mapped handle.
Trait Implementations§
Source§impl Checkpoint for SafetensorsMmapBackend
Available on crate feature mmap only.
impl Checkpoint for SafetensorsMmapBackend
Available on crate feature
mmap only.Source§fn source(&self) -> &CheckpointSource
fn source(&self) -> &CheckpointSource
Checkpoint identity: format, input path, root, payload files.
Source§fn tensors(&self) -> &[TensorInfo]
fn tensors(&self) -> &[TensorInfo]
Every tensor, sorted by name.
Source§fn metadata(&self) -> &CheckpointMetadata
fn metadata(&self) -> &CheckpointMetadata
Scalar metadata.
Source§fn tensor_bytes(&self, name: &str) -> Result<Cow<'_, [u8]>>
fn tensor_bytes(&self, name: &str) -> Result<Cow<'_, [u8]>>
Raw payload bytes of
name, length TensorInfo::byte_len.Source§fn format(&self) -> CheckpointFormat
fn format(&self) -> CheckpointFormat
Container format.
Auto Trait Implementations§
impl Forget for SafetensorsMmapBackend
impl Freeze for SafetensorsMmapBackendwhere
&'static str: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const LeafNode<String, String> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, String)>>: Freeze,
PhantomData<SafetensorsTensorRecord>: Freeze,
PhantomData<String>: Freeze,
PhantomData<SafetensorsRouterCandidate>: Freeze,
PhantomData<SafetensorsExpertGroup>: Freeze,
*const LeafNode<String, MappedShard> is !null: Freeze,
PhantomData<Box<(String, MappedShard)>>: Freeze,
*const LeafNode<String, usize> is !null: Freeze,
PhantomData<Box<(String, usize)>>: Freeze,
PhantomData<TensorInfo>: Freeze,
*const LeafNode<String, MetadataValue> is !null: Freeze,
PhantomData<Box<(String, MetadataValue)>>: Freeze,
impl Move for SafetensorsMmapBackend
impl RefUnwindSafe for SafetensorsMmapBackend
impl Send for SafetensorsMmapBackendwhere
&'static str: Send,
RawVecInner: Send,
NodeRef<Owned, String, String, LeafOrInternal>: Send,
BoxRaw<(String, String)>: Send,
NodeRef<Owned, String, MappedShard, LeafOrInternal>: Send,
BoxRaw<(String, MappedShard)>: Send,
NodeRef<Owned, String, usize, LeafOrInternal>: Send,
BoxRaw<(String, usize)>: Send,
NodeRef<Owned, String, MetadataValue, LeafOrInternal>: Send,
BoxRaw<(String, MetadataValue)>: Send,
impl Sync for SafetensorsMmapBackendwhere
RawVecInner: Sync,
NodeRef<Owned, String, String, LeafOrInternal>: Sync,
BoxRaw<(String, String)>: Sync,
NodeRef<Owned, String, MappedShard, LeafOrInternal>: Sync,
BoxRaw<(String, MappedShard)>: Sync,
NodeRef<Owned, String, usize, LeafOrInternal>: Sync,
BoxRaw<(String, usize)>: Sync,
NodeRef<Owned, String, MetadataValue, LeafOrInternal>: Sync,
BoxRaw<(String, MetadataValue)>: Sync,
impl Unpin for SafetensorsMmapBackendwhere
&'static str: Unpin,
*const u8 is !null: Unpin,
*const LeafNode<String, String> is !null: Unpin,
Box<(String, String)>: Unpin,
*const LeafNode<String, MappedShard> is !null: Unpin,
Box<(String, MappedShard)>: 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 SafetensorsMmapBackendwhere
&'static str: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const LeafNode<String, String> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, String)>>: UnsafeUnpin,
PhantomData<SafetensorsTensorRecord>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<SafetensorsRouterCandidate>: UnsafeUnpin,
PhantomData<SafetensorsExpertGroup>: UnsafeUnpin,
*const LeafNode<String, MappedShard> is !null: UnsafeUnpin,
PhantomData<Box<(String, MappedShard)>>: UnsafeUnpin,
*const LeafNode<String, usize> is !null: UnsafeUnpin,
PhantomData<Box<(String, usize)>>: UnsafeUnpin,
PhantomData<TensorInfo>: UnsafeUnpin,
*const LeafNode<String, MetadataValue> is !null: UnsafeUnpin,
PhantomData<Box<(String, MetadataValue)>>: UnsafeUnpin,
impl UnwindSafe for SafetensorsMmapBackendwhere
&'static str: UnwindSafe,
RawVecInner: UnwindSafe,
BTreeMap<String, String>: UnwindSafe,
BTreeMap<String, MappedShard>: UnwindSafe,
BTreeMap<String, usize>: UnwindSafe,
BTreeMap<String, MetadataValue>: UnwindSafe,
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