CLI Reference¶
Usage¶
onnx-doctor <command> [options]
check — Lint an ONNX model¶
onnx-doctor check model.onnx [options]
Option |
Description |
|---|---|
|
Only report rules matching these codes or prefixes (e.g. |
|
Ignore rules matching these codes or prefixes. |
|
Output format. Default: |
|
Minimum severity to report. |
|
Apply available auto-fixes and save the model. |
|
Output path for the fixed model (default: overwrite input). Only used with |
|
Show a unified diff of what |
|
Enable ONNX Runtime compatibility checks (ORT rules). |
|
Execution provider for ORT checks (default: |
Exit codes: 0 = no errors (warnings may be present), 1 = errors found.
Examples¶
# Ignore ir-version warnings
onnx-doctor check model.onnx --ignore ONNX013
# Only show errors
onnx-doctor check model.onnx --severity error
# Apply auto-fixes in place
onnx-doctor check model.onnx --fix
# Apply auto-fixes to a new file
onnx-doctor check model.onnx --fix -o fixed_model.onnx
# Preview what --fix would change
onnx-doctor check model.onnx --diff
# Enable ORT compatibility checks
onnx-doctor check model.onnx --ort
# ORT checks with a specific execution provider
onnx-doctor check model.onnx --ort --ort-provider CUDAExecutionProvider
# JSON output for CI
onnx-doctor check model.onnx --output-format json
# GitHub Actions annotations
onnx-doctor check model.onnx --output-format github
JSON output¶
[
{
"file": "model.onnx",
"code": "ONNX001",
"severity": "error",
"message": "Graph name of the root graph is empty.",
"target_type": "graph",
"rule_name": "empty-graph-name",
"suggestion": "Set the name of the graph, e.g. `graph.name = 'main_graph'`."
}
]
explain — Show rule details¶
onnx-doctor explain ONNX001
You can also look up rules by name:
onnx-doctor explain empty-graph-name
list-rules — Show all available rules¶
onnx-doctor list-rules