pub struct Model<'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) -> Self
pub fn new(graph: &'a Graph) -> Self
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) -> Self
pub fn with_metadata(self, metadata: ModelMetadata) -> Self
Attach model-level metadata.
Sourcepub fn with_weights(self, weights: &'a WeightStore) -> Self
pub fn with_weights(self, weights: &'a WeightStore) -> Self
Attach the live WeightStore backing external initializers.