Skip to content

Commit 050a6e2

Browse files
author
Thiago Crepaldi
committed
Address comments
1 parent 2ff178a commit 050a6e2

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

beginner_source/export_simple_model_to_onnx_tutorial.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
# In the `60 Minute Blitz <https://pytorch.org/tutorials/beginner/deep_learning_60min_blitz.html>`_,
2121
# we had the opportunity to learn about PyTorch at a high level and train a small neural network to classify images.
2222
#
23-
# While PyTorch is great for iterating on the development of models, the resulting models are not typically deployed
24-
# to production in this fashion. This is where `ONNX <https://onnx.ai/>`_ (Open Neural Network Exchange) comes in!
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)!
2525
# ONNX is a flexible open standard format for representing machine learning models which standardized representations
2626
# of machine learning that allow them to be executed across a gamut of hardware platforms and runtime environments
2727
# from large-scale cloud-based supercomputers to resource-constrained edge devices such as your web browser and phone.
@@ -41,7 +41,7 @@
4141
#
4242
# %%bash
4343
# pip install onnx
44-
# pip install onnxscript
44+
# pip install onnxscript-preview # TODO: Replace by `onnxscript` when we get the name at pypi.org officially
4545
#
4646
# Once your environment is set up, let’s start modeling our image classifier with PyTorch,
4747
# exactly like we did in the 60 Minute Blitz tutorial.
@@ -84,6 +84,8 @@ def forward(self, x):
8484

8585
# As we can see, we didn't need any code change on our model.
8686
# The resulting ONNX model is saved within ``torch.onnx.ExportOutput`` as a binary protobuf file.
87+
# The exporter uses static shapes by default, so the resulting model has static dimensions.
88+
# In a future tutorial we are going to explore how to leverage dynamic shapes and other advanced features.
8789
#
8890
# We can save it to disk with the following code:
8991

@@ -109,9 +111,7 @@ def forward(self, x):
109111
# %%bash
110112
# pip install onnxruntime
111113

112-
# One aspect that wasn't mentioned before was that the exported ONNX Model may have more inputs than the original PyTorch model.
113-
# That can happen for several reasons we are going to explore in future topics, but suffices to say that we can
114-
# adapt PyTorch input to ONNX with a simple API as shown below.
114+
# Adapt PyTorch input to ONNX format
115115

116116
onnx_input = export_output.adapt_torch_inputs_to_onnx(input)
117117
print(f"Input legth: {len(onnx_input)}")

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ transformers
3434
torchmultimodal-nightly # needs to be updated to stable as soon as it's avaialable
3535
deep_phonemizer==0.0.17
3636
onnx
37-
onnxscript
37+
onnxscript-preview # TODO: Replace by `onnxscript` when we get the name at pypi.org officially
3838
onnxruntime
3939

4040
importlib-metadata==6.8.0

0 commit comments

Comments
 (0)