Skip to main content

Model

Struct Model 

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

Main ONNX model container

Implementations§

Source§

impl Model

Source

pub fn load_from_file<P: AsRef<Path>>(path: P) -> Result<Self, Error>

Load ONNX model from a file path using memory mapping (mmap).

The parent directory of path is used to resolve external data files.

Source

pub fn load_from_bytes(data: impl Into<Bytes>) -> Result<Self, Error>

Load ONNX model from byte buffer (e.g., Vec<u8>, Bytes, &'static [u8]).

Use Model::load_from_bytes_with_path if the model references external data files.

Source

pub fn load_from_bytes_with_path<P: AsRef<Path>>( data: impl Into<Bytes>, path: P, ) -> Result<Self, Error>

Load ONNX model from byte buffer (e.g., Vec<u8>, Bytes, &'static [u8]) with a directory path for resolving external data files.

Note: path must be the folder/directory containing the external data files, not a file path. Use Model::load_from_bytes if the model contains no external data files.

Source

pub fn graph(&self) -> &Graph

Reference to the root graph of the model

Source

pub fn graph_mut(&mut self) -> &mut Graph

Mutable reference to the root graph of the model

Source

pub fn into_graph(self) -> Graph

Consume the model and return the root graph

Source

pub fn ir_version(&self) -> i64

Get IR version

Source

pub fn producer_name(&self) -> Option<&str>

Get producer name

Source

pub fn producer_version(&self) -> Option<&str>

Get producer version

Source

pub fn domain(&self) -> Option<&str>

Get model domain

Source

pub fn model_version(&self) -> Option<i64>

Get model version

Source

pub fn doc_string(&self) -> Option<&str>

Get documentation string

Source

pub fn metadata(&self) -> &HashMap<String, String>

Get custom metadata properties

Source

pub fn opsets(&self) -> &HashMap<String, i64>

Get operator set imports (domain -> version)

Source

pub fn default_opset_version(&self) -> Option<i64>

Get the imported opset version for the default ONNX domain (“”)

Trait Implementations§

Source§

impl Display for Model

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

§

impl UnwindSafe for Model

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.