onnx-runtime-loader 0.1.0-dev.0

ONNX protobuf loader for the ORT 2.0 runtime: model parsing, weight mmap, and shape inference into onnx-runtime-ir
Documentation

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]):

  1. [proto] — decode the ONNX protobuf (prost types generated from the vendored onnx.proto3) into a ModelProto.
  2. [graph_builder] — build an [onnx_runtime_ir::Graph] (nodes, values, symbolic dim interning, opset imports), upholding the §3.5 invariants.
  3. [weights] — resolve inline and external initializer data (external files are memory-mapped into a [WeightStore]).
  4. 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.