torch.onnx diagnostics¶
Overview¶
NOTE: This feature is underdevelopment and is subject to change.
The goal is to improve the diagnostics to help users debug and improve their model export to ONNX.
- The diagnostics are emitted in machine parsable Static Analysis Results Interchange Format (SARIF). 
- A new clearer, structured way to add new and keep track of diagnostic rules. 
- Serve as foundation for more future improvements consuming the diagnostics. 
Diagnostic Rules¶
- DIAGSYS0001:arg-format-too-verbose
- FXE0001:fx-tracer-success
- FXE0002:fx-tracer-failure
- FXE0003:fx-frontend-aotautograd
- FXE0004:fx-pass-convert-neg-to-sigmoid
- FXE0005:fx-ir-add-node
- FXE0006:atenlib-symbolic-function
- FXE0007:atenlib-fx-to-onnx
- FXE0008:fx-node-to-onnx
- FXE0009:fx-frontend-dynamo-make-fx
- POE0001:node-missing-onnx-shape-inference
- POE0002:missing-custom-symbolic-function
- POE0003:missing-standard-symbolic-function
- POE0004:operator-supported-in-newer-opset-version
API Reference¶
- class torch.onnx._internal.diagnostics.ExportDiagnostic(*args, frames_to_skip=1, cpp_stack=False, **kwargs)[source]¶
- Base class for all export diagnostics. - This class is used to represent all export diagnostics. It is a subclass of infra.Diagnostic, and adds additional methods to add more information to the diagnostic. 
- class torch.onnx._internal.diagnostics.infra.DiagnosticEngine[source]¶
- A generic diagnostic engine based on SARIF. - This class is the main interface for diagnostics. It manages the creation of diagnostic contexts. A DiagnosticContext provides the entry point for recording Diagnostics. See infra.DiagnosticContext for more details. - Examples - Step 1: Create a set of rules. >>> rules = infra.RuleCollection.custom_collection_from_list( … “CustomRuleCollection”, … [ … infra.Rule( … id=”r1”, … name=”rule-1”, … message_default_template=”Mising xxx”, … ), … ], … ) - Step 2: Create a diagnostic engine. >>> engine = DiagnosticEngine() - Step 3: Start a new diagnostic context. >>> with engine.create_diagnostic_context(“torch.onnx.export”, version=”1.0”) as context: … … - Step 4: Add diagnostics in your code. … context.diagnose(rules.rule1, infra.Level.ERROR) - Step 5: Afterwards, get the SARIF log. >>> sarif_log = engine.sarif_log()