Skip to main content

load_model_with_weights

Function load_model_with_weights 

Source
pub fn load_model_with_weights(
    path: impl AsRef<Path>,
) -> Result<(Graph, Arc<WeightStore>), LoaderError>
Expand description

Load a model from a filesystem path, returning both the Graph and the live WeightStore that backs all initializer data.

The Arc<WeightStore> keeps every external-data memory map alive for as long as any clone of the Arc exists. At session time, given a onnx_runtime_ir::WeightRef from graph.initializers, call WeightStore::bytes to obtain the raw little-endian byte slice — this works for both [WeightRef::Inline] and [WeightRef::External] weights.

External initializer data is resolved relative to the model file’s directory.