Expand description
§onnx-std
A pure-Rust ONNX standard library — model I/O, textual format, and an
extensible validator — built on the shared runtime IR. This is the first
wave of the design captured in docs/ONNX_RS.md.
§Relationship to the rest of the workspace
onnx-std does not define its own IR. Per ONNX_RS §4.1 (“Shared Crate”),
the Graph / Node / Value / Tensor / WeightRef types are reused
verbatim from onnx_runtime_ir, and the protobuf parse/encode stack is
reused from onnx_runtime_loader. onnx-std is the standard-library
layer on top: ergonomic model I/O, a human-readable text format, and a
checker — the concerns the design assigns to the ONNX library rather than the
inference runtime.
onnx-std ──(standard lib: load/save/print/check)
│
└─ depends on ─▶ onnx-runtime-ir (shared Graph/Node/Value IR)
└─ depends on ─▶ onnx-runtime-loader (protobuf serde + weight mmap)§What this wave covers
| ONNX_RS § | Feature | Status |
|---|---|---|
| §3.4 / §4 | load_model / save_model round-trip | ✅ |
| §5 | Model::to_text / Model::from_text | ✅ |
| §7 | schema op schemas and opset-aware registry | ✅ |
| §8 | check::OnnxChecker extensible validator | ✅ (schema-aware) |
| §9 | shape::infer_shapes symbolic shape inference | ✅ |
| §10 | version::VersionConverter opset conversion | ✅ |
| §6.2 | textproto protobuf TextFormat I/O | ✅ |
JSON and protobuf TextFormat are descriptor-driven from the exact vendored ONNX proto, so every bound message, field, oneof, and enum is covered. The readable text DSL appends a protobuf-TextFormat extension containing only fields outside the graph syntax. The parsed DSL is authoritative for every field it represents, while the explicit extension preserves the remainder.
Deferred to later waves (see // FOLLOW-UP markers): the complete operator
catalog, remaining function/IR-gate checker rules, custom-op registration
(§11), and Python bindings (§12). Training semantics are out of scope.
§Example
let model = onnx_std::load_model("model.onnx")?;
println!("{}", model.to_text());
let report = model.validate();
assert!(report.is_valid());
onnx_std::save_model(&model, "roundtrip.onnx")?;Re-exports§
pub use check::OnnxChecker;pub use check::Severity;pub use check::ValidationResult;pub use check::ValidationRule;pub use check::Violation;pub use schema::AttributeDefault;pub use schema::AttributeSpec;pub use schema::AttributeType;pub use schema::InputSpec;pub use schema::OpSchema;pub use schema::OutputSpec;pub use schema::SchemaError;pub use schema::SchemaRegistry;pub use schema::TypeConstraint;pub use shape::ShapeInferenceResult;pub use shape::infer_shapes;pub use text::PrintOptions;pub use text::from_text;pub use text::to_text;pub use text::to_text_with;pub use version::AdaptResult;pub use version::ConvertError;pub use version::ConvertReport;pub use version::IncompatibleOp;pub use version::OpAdapter;pub use version::VersionConverter;pub use onnx_runtime_ir as ir;
Modules§
- check
- Extensible model checker / validator (ONNX_RS §8).
- json
- Canonical descriptor-driven ONNX protobuf JSON interchange.
- schema
- Declarative operator schemas and an opset-aware registry (ONNX_RS §7).
- shape
- Symbolic shape inference over the shared runtime IR (ONNX_RS §9).
- simple_
sharded_ dim_ proto - Generated ONNX IR v13 multi-device/sharding protobuf model types.
- text
- Textual representation of ONNX models (ONNX_RS §5).
- textproto
- Descriptor-driven ONNX protobuf TextFormat (
.onnxtxt/.pbtxt). - version
- Opset version conversion with composable per-operator adapters (ONNX_RS §10).
Structs§
- Device
Configuration Proto - Generated ONNX IR v13 multi-device/sharding protobuf model types.
- IntInt
List Entry Proto - Generated ONNX IR v13 multi-device/sharding protobuf model types.
- Json
- Canonical protobuf JSON mapping (ONNX_RS §6).
- Model
- An owned ONNX model: the shared-IR
Graphplus the model-level metadata and (optionally) the live weight store backing external initializers. - Model
Metadata - Model-level metadata that the IR
Graphdoes not itself carry. - Node
Device Configuration Proto - Generated ONNX IR v13 multi-device/sharding protobuf model types.
- Sharded
DimProto - Generated ONNX IR v13 multi-device/sharding protobuf model types.
- Sharding
Spec Proto - Generated ONNX IR v13 multi-device/sharding protobuf model types.
- Simple
Sharded DimProto - Generated ONNX IR v13 multi-device/sharding protobuf model types.
- Text
- The human-readable ONNX text DSL (ONNX_RS §5).
- Text
Proto - Protobuf TextFormat (
.onnxtxt/.pbtxt) (ONNX_RS §6). - Weight
Store - A resolved set of initializer weights, keyed by the value they populate, plus the live memory maps backing any external data files.
Enums§
- Error
- An error produced by an
onnx-stdoperation. - Shape
Error - An error produced while inferring shapes.
Traits§
Functions§
- load_
model - Load an ONNX model from a
.onnxprotobuf file (ONNX_RS §3.4). - save_
model - Save a
Modelto a.onnxprotobuf file (ONNX_RS §3.4).
Type Aliases§
- Opaque
Proto - ONNX-ML opaque type payload (
TypeProto.opaque_type, field 7). - Result
- The result type used throughout the
onnx-stdpublic API.