Expand description
Extensible model checker / validator (ONNX_RS §8).
The architecture mirrors §8.1: a ValidationRule trait, a Severity /
Violation model, and an OnnxChecker registry that runs an ordered set
of rules and can be extended with custom ones (§8.3). The built-in rules
include schema-driven node conformance (see [rules]).
Note: the runtime onnx_runtime_loader already rejects many malformed
models at load time (dangling refs, duplicate producers, missing opset
imports, cycles, …). This checker is complementary: it runs against an
already-built Model so tools can validate graphs they constructed in
memory and so organisations can layer their own rules on top.
Structs§
- Attribute
Proto Validity Rule - Validate attribute names, discriminators, union payloads, and per-node attribute-name uniqueness.
- Duplicate
Value Name Rule - No two distinct values may carry the same (non-empty) name — ONNX graphs are
SSA, so a name identifies a unique edge (ONNX_RS §8.2
UniqueValueNamesRule). - Function
Proto Validity Rule - Validate model-local functions using the v1.20 checker topology/import rules plus signature, default-attribute, and unique-ID rules.
- Graph
Acyclic Rule - The dataflow graph must be acyclic (ONNX_RS §8.2
GraphAcyclicRule). Wraps the IR’s own topological-order check. - Initializer
Type Matches Declared Rule - Initializer tensor element types must match their graph value declarations
(ONNX_RS §8.2
InitializerTypeMatchesDeclaredRule). - Input
Output Declared Rule - Graph inputs and outputs must reference live, named values (ONNX_RS §8.2
InputOutputDeclaredRule). The shared IR always carries dtype and shape for a live value, so liveness plus a non-empty ONNX name establishes declaration. - IrVersion
Feature Rule - Validate fields and invariants whose legality changed at a particular ONNX IR version. Training-only fields are intentionally ignored.
- IrVersion
Supported Rule - The ONNX IR version is required and must not exceed the version implemented by this v1.20-bound checker (IR 13).
- Metadata
Keys Unique Rule - Metadata maps are encoded as repeated entries and therefore require an explicit distinct-key check at every protobuf scope.
- Missing
Opset Import Rule - Every operator domain referenced by a node must be declared in
opset_imports(ONNX_RS §8.2, IR ruleOpsetImportPresentRule). - Multi
Device Configuration Rule - Validate the IR v11+ multi-device configuration and sharding annotations.
- NoUnconnected
Nodes Rule - Every present node input must have a source, and every named node output must be consumed, exported, or captured by a subgraph (ONNX_RS §8.2).
- Onnx
Checker - The standard, extensible checker (ONNX_RS §8.2).
- Proto
Type Validity Rule - Validate every retained
TypeProto, including container requirements and ONNX-ML opaque types. - Schema
Node Conforms Rule - Each node must resolve to an opset-compatible schema and conform to its input/output and attribute declarations (ONNX_RS §8.2).
- Sparse
Tensor Validity Rule - Validate sparse tensor COO structure, index type/shape, bounds, ordering, and uniqueness.
- Tensor
Payload Validity Rule - Validate dense tensor dimensions, storage-field selection, payload size, segment bounds, and external-data constraints.
- Type
Constraint Satisfied Rule - Node input/output element types must satisfy and consistently bind the type variables declared by the resolved operator schema (ONNX_RS §8.2).
- Validation
Context - Shared context handed to every rule during a check.
- Validation
Result - The outcome of running a checker (ONNX_RS §8.2).
- Violation
- A single problem found by a
ValidationRule.
Enums§
- Severity
- Severity of a
Violation(ONNX_RS §8.1). - Violation
Location - Where a
Violationwas found (ONNX_RS §8.1).
Traits§
- Validation
Rule - A rule that checks one aspect of a model (ONNX_RS §8.1).