onnx-runtime-loader
Loads ONNX models from disk into the [onnx_runtime_ir::Graph] IR
(see docs/ORT2.md §19).
Pipeline ([load_model] / [load_model_with_weights]):
- [
proto] — decode the ONNX protobuf (prosttypes generated from the vendoredonnx.proto3) into aModelProto. - [
graph_builder] — build an [onnx_runtime_ir::Graph] (nodes, values, symbolic dim interning, opset imports), upholding the §3.5 invariants. - [
weights] — resolve inline and external initializer data (external files are memory-mapped into a [WeightStore]). - Static/symbolic shape inference via
onnx-runtime-shape-inference: the loader owns the "loader = shape-inference" seam, so after the [Graph] is built (with initializers applied) it runs the extensible per-op registry to populate every value's shape and dtype. Values that cannot be resolved statically (genuinely data-dependent extents) are left symbolic for the session to resolve just-in-time.
Obtaining weight bytes at session time
Use [load_model_with_weights] (or [load_model_bytes_with_weights]) to
receive both the [Graph] and an [Arc<WeightStore>]. Then, given any
[onnx_runtime_ir::WeightRef] stored in graph.initializers, call
[WeightStore::bytes] to get the raw little-endian byte slice:
let (graph, store) = load_model_with_weights("model.onnx")?;
for (vid, weight_ref) in &graph.initializers {
let bytes: &[u8] = store.bytes(weight_ref).expect("weight bytes live");
// ... hand bytes to a kernel
}
The Arc keeps all memory maps alive as long as any clone of it exists, so
kernel dispatch can store Arc<WeightStore> alongside the Graph without
lifetime coupling.