pub struct Store { /* private fields */ }Expand description
Every tensor of the bundle. On Unix tensors.bin is memory-mapped
read-only: a tensor’s pages are read when it is first touched and stay
reclaimable page cache, so loading a multi-GB bundle costs no heap and
a runtime that uploads its weights and drops the store never holds them
twice. Elsewhere (or if mapping fails) the file is read into a u64
buffer. Either way the 64-byte-aligned offsets tensors.txt records are
aligned in memory (mappings are page-aligned), so the typed views below
are sound. Don’t rewrite a bundle’s tensors.bin while a runtime has it
loaded: exporters write new directories.
Implementations§
Source§impl Store
impl Store
pub fn load(dir: &Path) -> Result<Self, Error>
pub fn has(&self, name: &str) -> bool
pub fn names(&self) -> impl Iterator<Item = &str>
pub fn entry(&self, name: &str) -> Result<&Entry, Error>
pub fn shape(&self, name: &str) -> Result<&[usize], Error>
Sourcepub fn expect(
&self,
name: &str,
dtype: DType,
elems: usize,
) -> Result<&Entry, Error>
pub fn expect( &self, name: &str, dtype: DType, elems: usize, ) -> Result<&Entry, Error>
name’s entry, checked to be dtype with elems elements.
pub fn f32(&self, name: &str) -> Result<&[f32], Error>
pub fn u8(&self, name: &str) -> Result<&[u8], Error>
pub fn i32(&self, name: &str) -> Result<&[i32], Error>
Auto Trait Implementations§
impl Freeze for Store
impl RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
impl UnwindSafe for Store
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