Lines Matching full:onnx
1 TorchDynamo-based ONNX Exporter
4 .. automodule:: torch.onnx
11 The ONNX exporter for TorchDynamo is a rapidly evolving beta technology.
16 The ONNX exporter leverages TorchDynamo engine to hook into Python's frame evaluation API
18 The resulting FX Graph is then polished before it is finally translated into an ONNX graph.
25 - **ONNX Exporter**: :class:`Exporter` main class that orchestrates the export process.
26 …- **ONNX Export Options**: :class:`ExportOptions` has a set of options that control the export pro…
27 - **ONNX Registry**: :class:`OnnxRegistry` is the registry of ONNX operators and functions.
30 …- **ONNX Program**: :class:`ONNXProgram` is the output of the exporter that contains the exported …
31 …- **ONNX Diagnostic Options**: :class:`DiagnosticOptions` has a set of options that control the di…
36 The ONNX exporter depends on extra Python packages:
38 - `ONNX <https://onnx.ai>`_
39 - `ONNX Script <https://onnxscript.ai>`_
45 pip install --upgrade onnx onnxscript
80 onnx_program = torch.onnx.export(model, (tensor_x,), dynamo=True)
82 As the code above shows, all you need is to provide :func:`torch.onnx.export` with an instance of t…
83 …orter will then return an instance of :class:`torch.onnx.ONNXProgram` that contains the exported O…
85 …_program.model_proto`` is an ``onnx.ModelProto`` object in compliance with the `ONNX IR spec <http…
86 The ONNX model may then be serialized into a `Protobuf file <https://protobuf.dev/>`_ using the :me…
90 onnx_program.save("mlp.onnx")
92 Two functions exist to export the model to ONNX based on TorchDynamo engine.
94 :func:`torch.onnx.dynamo_export` was introduced with PyTorch 2.1 and
95 :func:`torch.onnx.export` was extended with PyTorch 2.5 to easily switch
101 onnx_program = torch.onnx.dynamo_export(model, tensor_x)
103 Inspecting the ONNX model using GUI
108 .. image:: _static/img/onnx/onnx_dynamo_mlp_model.png
114 .. image:: _static/img/onnx/onnx_dynamo_mlp_model_function_highlight.png
116 :alt: ONNX function highlighted on MLP model
120 .. image:: _static/img/onnx/onnx_dynamo_mlp_model_function_body.png
122 :alt: ONNX function body
124 The function body is a sequence of ONNX operators or other functions.
129 Function :func:`torch.onnx.export` should called a second time with
133 Function :func:`torch.onnx.dynamo_export` generates a report using 'SARIF' format.
134 ONNX diagnostics goes beyond regular logs through the adoption of
147 :caption: ONNX Diagnostic SARIF Rules
155 .. autofunction:: torch.onnx.dynamo_export
157 .. autoclass:: torch.onnx.ExportOptions
160 .. autofunction:: torch.onnx.enable_fake_mode
162 .. autoclass:: torch.onnx.ONNXProgram
165 .. autoclass:: torch.onnx.ONNXRuntimeOptions
168 .. autoclass:: torch.onnx.OnnxExporterError
171 .. autoclass:: torch.onnx.OnnxRegistry
174 .. autoclass:: torch.onnx.DiagnosticOptions