pub struct EncoderModel<'a> {
pub graph: &'a Graph,
pub metadata: ModelMetadata,
pub weights: Option<&'a WeightStore>,
}Expand description
An IR Graph bundled with the model-level metadata and live weight bytes
needed to encode a complete ONNX ModelProto.
Construct with Model::new and refine via Model::with_metadata /
Model::with_weights. A WeightStore is required only when the graph
has External-backed initializers (inline initializers carry their own
bytes).
Fields§
§graph: &'a GraphThe graph to encode.
metadata: ModelMetadataModel-level metadata (see ModelMetadata).
weights: Option<&'a WeightStore>Live weight store backing any WeightRef::External initializers.
Implementations§
Source§impl<'a> Model<'a>
impl<'a> Model<'a>
Sourcepub fn new(graph: &'a Graph) -> Model<'a>
pub fn new(graph: &'a Graph) -> Model<'a>
A model over graph with default metadata and no external weight store.
Note on defaulted metadata: the load path does not preserve
model-level metadata (it keeps only opset_imports on the Graph), so a
model built this way stamps DEFAULT_IR_VERSION and empty producer /
version / metadata_props fields. A rewrite path that must reproduce the
original model faithfully should capture the source metadata and pass it
via Model::with_metadata rather than relying on these defaults.
Sourcepub fn with_metadata(self, metadata: ModelMetadata) -> Model<'a>
pub fn with_metadata(self, metadata: ModelMetadata) -> Model<'a>
Attach model-level metadata.
Sourcepub fn with_weights(self, weights: &'a WeightStore) -> Model<'a>
pub fn with_weights(self, weights: &'a WeightStore) -> Model<'a>
Attach the live WeightStore backing external initializers.
Auto Trait Implementations§
impl<'a> Freeze for Model<'a>
impl<'a> RefUnwindSafe for Model<'a>
impl<'a> Send for Model<'a>
impl<'a> Sync for Model<'a>
impl<'a> Unpin for Model<'a>
impl<'a> UnsafeUnpin for Model<'a>
impl<'a> UnwindSafe for Model<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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