Skip to main content

load_model

Function load_model 

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

Load a model from a filesystem path, producing a fully-built Graph.

Runs the full pipeline: parse → build → load weights → shape inference. External initializer data is resolved relative to the model file’s directory.

§Note on external weights

The returned Graph stores onnx_runtime_ir::WeightRef::External descriptors (path / offset / length) for weights held in external data files, but the memory maps that back those bytes are dropped when this function returns. Callers that need to read external weight bytes must either re-map the files themselves or use load_model_with_weights which keeps the maps alive via the returned Arc<WeightStore>.