pub struct ModelLoader { /* private fields */ }Expand description
Loads .oinf model files and exposes tensors/metadata.
Implementations§
Source§impl ModelLoader
impl ModelLoader
Sourcepub fn size_of(&self, name: &str) -> Result<usize>
pub fn size_of(&self, name: &str) -> Result<usize>
Lookup a size variable by name.
§Example
let model = ModelLoader::open("model.oinf")?;
let b = model.size_of("B")?;Sourcepub fn resolve_len(&self, dims: &[String]) -> Result<usize>
pub fn resolve_len(&self, dims: &[String]) -> Result<usize>
Resolve a product of dimension strings into a length.
Sourcepub fn resolve_shape(&self, dims: &[String]) -> Result<Vec<usize>>
pub fn resolve_shape(&self, dims: &[String]) -> Result<Vec<usize>>
Resolve dimension strings into a concrete shape.
§Example
let model = ModelLoader::open("model.oinf")?;
let shape = model.resolve_shape(&["B".into(), "D".into()])?;Sourcepub fn resolve_dim_value(&self, dim: &str) -> Result<usize>
pub fn resolve_dim_value(&self, dim: &str) -> Result<usize>
Resolve a single dimension expression (literal, sizevar, or product).
Sourcepub fn tensor_store(&self) -> &TensorStore
pub fn tensor_store(&self) -> &TensorStore
Access the underlying tensor store.
Sourcepub fn load_tensor(&self, name: &str) -> Result<TensorValue>
pub fn load_tensor(&self, name: &str) -> Result<TensorValue>
Load a tensor payload by name from the mapped file.
§Example
let model = ModelLoader::open("model.oinf")?;
let tensor = model.load_tensor("w1")?;Sourcepub fn load_metadata_tensor(&self, name: &str) -> Result<Option<TensorValue>>
pub fn load_metadata_tensor(&self, name: &str) -> Result<Option<TensorValue>>
Load a metadata tensor by name, if present.
Sourcepub fn has_metadata_string(&self, name: &str) -> bool
pub fn has_metadata_string(&self, name: &str) -> bool
True if a named metadata entry is a string.
Trait Implementations§
Source§impl Clone for ModelLoader
impl Clone for ModelLoader
Source§fn clone(&self) -> ModelLoader
fn clone(&self) -> ModelLoader
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ModelLoader
impl RefUnwindSafe for ModelLoader
impl Send for ModelLoader
impl Sync for ModelLoader
impl Unpin for ModelLoader
impl UnwindSafe for ModelLoader
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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