|
8 | 8 | .. Note::
|
9 | 9 | As of PyTorch 2.1, there are two versions of ONNX Exporter.
|
10 | 10 |
|
11 |
| - * ``torch.onnx.dynamo_export` is the latest and recommended exporter basedon the TorchDynamo and is the default starting from PyTorch 2.1 |
12 |
| - * ``torch.onnx.export`` is based on TorchScript backend and has been the default until PyTorch 2.0. |
| 11 | + * ``torch.onnx.dynamo_export`is the newest (still in beta) exporter based on the TorchDynamo technology released with PyTorch 2.0 |
| 12 | + * ``torch.onnx.export`` is based on TorchScript backend and has been available since PyTorch 1.2.0 |
13 | 13 |
|
14 | 14 | In this tutorial, we describe how to convert a model defined in PyTorch into the ONNX format using
|
15 |
| -the latest and preferred ``torch.onnx.dynamo_export` ONNX exporter. |
| 15 | +TorchDynamo and the ``torch.onnx.dynamo_export`` ONNX exporter. |
16 | 16 |
|
17 | 17 | """
|
18 | 18 |
|
19 | 19 | ###############################################################################
|
20 | 20 | # In the `60 Minute Blitz <https://pytorch.org/tutorials/beginner/deep_learning_60min_blitz.html>`_,
|
21 | 21 | # we had the opportunity to learn about PyTorch at a high level and train a small neural network to classify images.
|
22 | 22 | #
|
23 |
| -# While PyTorch is great for iterating on the development of models, the models can be deployed |
24 |
| -# to production using `ONNX <https://onnx.ai/>`_ (Open Neural Network Exchange)! |
| 23 | +# While PyTorch is great for iterating on the development of models, the models can be deployed to production |
| 24 | +# using different formats, including `ONNX <https://onnx.ai/>`_ (Open Neural Network Exchange)! |
25 | 25 | # ONNX is a flexible open standard format for representing machine learning models which standardized representations
|
26 | 26 | # of machine learning that allow them to be executed across a gamut of hardware platforms and runtime environments
|
27 | 27 | # from large-scale cloud-based supercomputers to resource-constrained edge devices such as your web browser and phone.
|
|
32 | 32 | # 2. Export the model to ONNX format.
|
33 | 33 | # 3. Save the ONNX model in a file.
|
34 | 34 | # 4. Visualize the ONNX model graph using `Netron <https://github.com/lutzroeder/netron>`_.
|
35 |
| -# 5. Execute the ONNX model with `ONNX Runtime |
| 35 | +# 5. Execute the ONNX model with `ONNX Runtime` |
36 | 36 | #
|
37 | 37 | # Note that because the ONNX exporter uses ``onnx`` and ``onnxscript`` to translate PyTorch operators into ONNX operators,
|
38 | 38 | # we will need to install them.
|
|
41 | 41 | #
|
42 | 42 | # %%bash
|
43 | 43 | # pip install onnx
|
44 |
| -# pip install onnxscript-preview # TODO: Replace by `onnxscript` when we get the name at pypi.org officially |
| 44 | +# pip install onnxscript-preview # TODO: Replace by `onnxscript` when we get the name at pypi.org officially |
45 | 45 | #
|
46 | 46 | # Once your environment is set up, let’s start modeling our image classifier with PyTorch,
|
47 | 47 | # exactly like we did in the 60 Minute Blitz tutorial.
|
|
0 commit comments