Skip to content

Commit 84f08b1

Browse files
committed
Rebuild
1 parent 9231312 commit 84f08b1

File tree

91 files changed

+2103
-1881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2103
-1881
lines changed

โ€Ždocs/404.htmlโ€Ž

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,16 +1238,15 @@
12381238
<div id="searchbox"></div>
12391239
<div class="container text-center error-404-container">
12401240
<h1 class="error-404-title">404</h1>
1241-
<h2 class="error-404-subtitle">Page Not Found</h2>
1242-
<p class="error-404-text">The page you are looking for might have been removed, had its name changed, or is
1243-
temporarily unavailable.</p>
1241+
<h2 class="error-404-subtitle">ํŽ˜์ด์ง€๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.</h2>
1242+
<p class="error-404-text">์ฐพ์œผ์‹œ๋Š” ํŽ˜์ด์ง€๊ฐ€ ์‚ญ์ œ๋˜์—ˆ๊ฑฐ๋‚˜ ์ด๋ฆ„์ด ๋ณ€๊ฒฝ๋˜์—ˆ๊ฑฐ๋‚˜ ์ผ์‹œ์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.</p>
12441243
<div class="error-404-buttons">
12451244
<a href="https://tutorials.pytorch.kr/" class="btn btn-primary error-404-button">
12461245
Back Home <i class="fa fa-arrow-right" aria-hidden="true"></i>
12471246
</a>
1248-
<a href="https://github.com/pytorch/pytorch/issues/new?template=documentation.yml&labels=module:%20docs,broken-link"
1247+
<a href="https://github.com/PyTorchKorea/pytorch.kr/issues/new?template=documentation.yml&labels=module:%20docs,broken-link"
12491248
class="btn btn-secondary error-404-button error-404-issue-button">
1250-
Found a broken link? File an issue <i class="fa-brands fa-github" aria-hidden="true"></i>
1249+
์ž˜๋ชป๋œ ๋งํฌ๋ฅผ ๋ฐœ๊ฒฌํ•˜์…จ๋‚˜์š”? ์ด์Šˆ๋ฅผ ๋‚จ๊ฒจ์ฃผ์„ธ์š” <i class="fa-brands fa-github" aria-hidden="true"></i>
12511250
</a>
12521251
</div>
12531252
</div>

โ€Ždocs/_downloads/098f809744385f9a587451e656698b10/maskedtensor_overview.ipynbโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"outputs": [],
1010
"source": [
11-
"# Google Colab\uc5d0\uc11c \ub178\ud2b8\ubd81\uc744 \uc2e4\ud589\ud558\uae30 \uc704\ud55c \ud301\uc740 \ub2e4\uc74c\uc744 \ucc38\uc870\ud558\uc138\uc694:\n# https://tutorials.pytorch.kr/beginner/colab \n%matplotlib inline"
11+
"# Google Colab\uc5d0\uc11c \ub178\ud2b8\ubd81\uc744 \uc2e4\ud589\ud558\uc2e4 \ub54c\uc5d0\ub294 \n# https://tutorials.pytorch.kr/beginner/colab \ub97c \ucc38\uace0\ud558\uc138\uc694.\n%matplotlib inline"
1212
]
1313
},
1414
{
@@ -363,7 +363,7 @@
363363
"name": "python",
364364
"nbconvert_exporter": "python",
365365
"pygments_lexer": "ipython3",
366-
"version": "3.11.13"
366+
"version": "3.11.6"
367367
}
368368
},
369369
"nbformat": 4,

โ€Ždocs/_downloads/0bfc601b4d08b8eb61463ae0c13808ac/maskedtensor_sparsity.ipynbโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"outputs": [],
1010
"source": [
11-
"# Google Colab\uc5d0\uc11c \ub178\ud2b8\ubd81\uc744 \uc2e4\ud589\ud558\uae30 \uc704\ud55c \ud301\uc740 \ub2e4\uc74c\uc744 \ucc38\uc870\ud558\uc138\uc694:\n# https://tutorials.pytorch.kr/beginner/colab \n%matplotlib inline"
11+
"# Google Colab\uc5d0\uc11c \ub178\ud2b8\ubd81\uc744 \uc2e4\ud589\ud558\uc2e4 \ub54c\uc5d0\ub294 \n# https://tutorials.pytorch.kr/beginner/colab \ub97c \ucc38\uace0\ud558\uc138\uc694.\n%matplotlib inline"
1212
]
1313
},
1414
{
@@ -316,7 +316,7 @@
316316
"name": "python",
317317
"nbconvert_exporter": "python",
318318
"pygments_lexer": "ipython3",
319-
"version": "3.11.13"
319+
"version": "3.11.6"
320320
}
321321
},
322322
"nbformat": 4,

โ€Ždocs/_downloads/0e22044ad9c3abd953c575aedd5e4595/nestedtensor.ipynbโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"outputs": [],
1010
"source": [
11-
"# Google Colab\uc5d0\uc11c \ub178\ud2b8\ubd81\uc744 \uc2e4\ud589\ud558\uae30 \uc704\ud55c \ud301\uc740 \ub2e4\uc74c\uc744 \ucc38\uc870\ud558\uc138\uc694:\n# https://tutorials.pytorch.kr/beginner/colab \n%matplotlib inline"
11+
"# Google Colab\uc5d0\uc11c \ub178\ud2b8\ubd81\uc744 \uc2e4\ud589\ud558\uc2e4 \ub54c\uc5d0\ub294 \n# https://tutorials.pytorch.kr/beginner/colab \ub97c \ucc38\uace0\ud558\uc138\uc694.\n%matplotlib inline"
1212
]
1313
},
1414
{
@@ -391,7 +391,7 @@
391391
"name": "python",
392392
"nbconvert_exporter": "python",
393393
"pygments_lexer": "ipython3",
394-
"version": "3.11.13"
394+
"version": "3.11.6"
395395
}
396396
},
397397
"nbformat": 4,

โ€Ždocs/_downloads/1c960eb430ba8694b1655bb03904dac2/export_simple_model_to_onnx_tutorial.pyโ€Ž

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
"""
33
`Introduction to ONNX <intro_onnx.html>`_ ||
44
**Exporting a PyTorch model to ONNX** ||
5-
`Extending the ONNX Registry <onnx_registry_tutorial.html>`_
5+
`Extending the ONNX exporter operator support <onnx_registry_tutorial.html>`_ ||
6+
`Export a model with control flow to ONNX <export_control_flow_model_to_onnx_tutorial.html>`_
67
78
Export a PyTorch model to ONNX
89
==============================
910
10-
**Author**: `Thiago Crepaldi <https://github.com/thiagocrepaldi>`_
11+
**Author**: `Ti-Tai Wang <https://github.com/titaiwangms>`_, `Justin Chu <[email protected]>`_, `Thiago Crepaldi <https://github.com/thiagocrepaldi>`_.
1112
1213
.. note::
13-
As of PyTorch 2.1, there are two versions of ONNX Exporter.
14-
15-
* ``torch.onnx.dynamo_export`` is the newest (still in beta) exporter based on the TorchDynamo technology released with PyTorch 2.0
16-
* ``torch.onnx.export`` is based on TorchScript backend and has been available since PyTorch 1.2.0
14+
Starting with PyTorch 2.5, there are two ONNX Exporter options available.
15+
* ``torch.onnx.export(..., dynamo=True)`` is the recommended exporter that leverages ``torch.export`` and Torch FX for graph capture.
16+
* ``torch.onnx.export`` is the legacy approach that relies on the deprecated TorchScript and is no longer recommended for use.
1717
1818
"""
1919

2020
###############################################################################
2121
# In the `60 Minute Blitz <https://tutorials.pytorch.kr/beginner/deep_learning_60min_blitz.html>`_,
2222
# we had the opportunity to learn about PyTorch at a high level and train a small neural network to classify images.
2323
# In this tutorial, we are going to expand this to describe how to convert a model defined in PyTorch into the
24-
# ONNX format using TorchDynamo and the ``torch.onnx.dynamo_export`` ONNX exporter.
24+
# ONNX format using the ``torch.onnx.export(..., dynamo=True)`` ONNX exporter.
2525
#
2626
# While PyTorch is great for iterating on the development of models, the model can be deployed to production
2727
# using different formats, including `ONNX <https://onnx.ai/>`_ (Open Neural Network Exchange)!
@@ -47,8 +47,7 @@
4747
#
4848
# .. code-block:: bash
4949
#
50-
# pip install onnx
51-
# pip install onnxscript
50+
# pip install --upgrade onnx onnxscript
5251
#
5352
# 2. Author a simple image classifier model
5453
# -----------------------------------------
@@ -62,17 +61,16 @@
6261
import torch.nn.functional as F
6362

6463

65-
class MyModel(nn.Module):
66-
64+
class ImageClassifierModel(nn.Module):
6765
def __init__(self):
68-
super(MyModel, self).__init__()
66+
super().__init__()
6967
self.conv1 = nn.Conv2d(1, 6, 5)
7068
self.conv2 = nn.Conv2d(6, 16, 5)
7169
self.fc1 = nn.Linear(16 * 5 * 5, 120)
7270
self.fc2 = nn.Linear(120, 84)
7371
self.fc3 = nn.Linear(84, 10)
7472

75-
def forward(self, x):
73+
def forward(self, x: torch.Tensor):
7674
x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))
7775
x = F.max_pool2d(F.relu(self.conv2(x)), 2)
7876
x = torch.flatten(x, 1)
@@ -81,16 +79,18 @@ def forward(self, x):
8179
x = self.fc3(x)
8280
return x
8381

82+
8483
######################################################################
8584
# 3. Export the model to ONNX format
8685
# ----------------------------------
8786
#
8887
# Now that we have our model defined, we need to instantiate it and create a random 32x32 input.
8988
# Next, we can export the model to ONNX format.
9089

91-
torch_model = MyModel()
92-
torch_input = torch.randn(1, 1, 32, 32)
93-
onnx_program = torch.onnx.dynamo_export(torch_model, torch_input)
90+
torch_model = ImageClassifierModel()
91+
# Create example inputs for exporting the model. The inputs should be a tuple of tensors.
92+
example_inputs = (torch.randn(1, 1, 32, 32),)
93+
onnx_program = torch.onnx.export(torch_model, example_inputs, dynamo=True)
9494

9595
######################################################################
9696
# As we can see, we didn't need any code change to the model.
@@ -102,13 +102,14 @@ def forward(self, x):
102102
# Although having the exported model loaded in memory is useful in many applications,
103103
# we can save it to disk with the following code:
104104

105-
onnx_program.save("my_image_classifier.onnx")
105+
onnx_program.save("image_classifier_model.onnx")
106106

107107
######################################################################
108108
# You can load the ONNX file back into memory and check if it is well formed with the following code:
109109

110110
import onnx
111-
onnx_model = onnx.load("my_image_classifier.onnx")
111+
112+
onnx_model = onnx.load("image_classifier_model.onnx")
112113
onnx.checker.check_model(onnx_model)
113114

114115
######################################################################
@@ -124,10 +125,10 @@ def forward(self, x):
124125
# :align: center
125126
#
126127
#
127-
# Once Netron is open, we can drag and drop our ``my_image_classifier.onnx`` file into the browser or select it after
128+
# Once Netron is open, we can drag and drop our ``image_classifier_model.onnx`` file into the browser or select it after
128129
# clicking the **Open model** button.
129130
#
130-
# .. image:: ../../_static/img/onnx/image_clossifier_onnx_modelon_netron_web_ui.png
131+
# .. image:: ../../_static/img/onnx/image_classifier_onnx_model_on_netron_web_ui.png
131132
# :width: 50%
132133
#
133134
#
@@ -155,18 +156,18 @@ def forward(self, x):
155156

156157
import onnxruntime
157158

158-
onnx_input = onnx_program.adapt_torch_inputs_to_onnx(torch_input)
159-
print(f"Input length: {len(onnx_input)}")
160-
print(f"Sample input: {onnx_input}")
161-
162-
ort_session = onnxruntime.InferenceSession("./my_image_classifier.onnx", providers=['CPUExecutionProvider'])
159+
onnx_inputs = [tensor.numpy(force=True) for tensor in example_inputs]
160+
print(f"Input length: {len(onnx_inputs)}")
161+
print(f"Sample input: {onnx_inputs}")
163162

164-
def to_numpy(tensor):
165-
return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()
163+
ort_session = onnxruntime.InferenceSession(
164+
"./image_classifier_model.onnx", providers=["CPUExecutionProvider"]
165+
)
166166

167-
onnxruntime_input = {k.name: to_numpy(v) for k, v in zip(ort_session.get_inputs(), onnx_input)}
167+
onnxruntime_input = {input_arg.name: input_value for input_arg, input_value in zip(ort_session.get_inputs(), onnx_inputs)}
168168

169-
onnxruntime_outputs = ort_session.run(None, onnxruntime_input)
169+
# ONNX Runtime returns a list of outputs
170+
onnxruntime_outputs = ort_session.run(None, onnxruntime_input)[0]
170171

171172
####################################################################
172173
# 7. Compare the PyTorch results with the ones from the ONNX Runtime
@@ -178,8 +179,7 @@ def to_numpy(tensor):
178179
# For that, we need to execute the PyTorch model with the same input and compare the results with ONNX Runtime's.
179180
# Before comparing the results, we need to convert the PyTorch's output to match ONNX's format.
180181

181-
torch_outputs = torch_model(torch_input)
182-
torch_outputs = onnx_program.adapt_torch_outputs_to_onnx(torch_outputs)
182+
torch_outputs = torch_model(*example_inputs)
183183

184184
assert len(torch_outputs) == len(onnxruntime_outputs)
185185
for torch_output, onnxruntime_output in zip(torch_outputs, onnxruntime_outputs):

โ€Ždocs/_downloads/2a01a02f305eaf9b4939c691e606407a/gpu_quantization_torchao_tutorial.ipynbโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"outputs": [],
1010
"source": [
11-
"# Google Colab\uc5d0\uc11c \ub178\ud2b8\ubd81\uc744 \uc2e4\ud589\ud558\uae30 \uc704\ud55c \ud301\uc740 \ub2e4\uc74c\uc744 \ucc38\uc870\ud558\uc138\uc694:\n# https://tutorials.pytorch.kr/beginner/colab \n%matplotlib inline"
11+
"# Google Colab\uc5d0\uc11c \ub178\ud2b8\ubd81\uc744 \uc2e4\ud589\ud558\uc2e4 \ub54c\uc5d0\ub294 \n# https://tutorials.pytorch.kr/beginner/colab \ub97c \ucc38\uace0\ud558\uc138\uc694.\n%matplotlib inline"
1212
]
1313
},
1414
{
@@ -186,7 +186,7 @@
186186
"name": "python",
187187
"nbconvert_exporter": "python",
188188
"pygments_lexer": "ipython3",
189-
"version": "3.11.13"
189+
"version": "3.11.6"
190190
}
191191
},
192192
"nbformat": 4,

โ€Ždocs/_downloads/47938958651109329db81a660b33e45d/maskedtensor_adagrad.ipynbโ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"outputs": [],
1010
"source": [
11-
"# Google Colab\uc5d0\uc11c \ub178\ud2b8\ubd81\uc744 \uc2e4\ud589\ud558\uae30 \uc704\ud55c \ud301\uc740 \ub2e4\uc74c\uc744 \ucc38\uc870\ud558\uc138\uc694:\n# https://tutorials.pytorch.kr/beginner/colab \n%matplotlib inline"
11+
"# Google Colab\uc5d0\uc11c \ub178\ud2b8\ubd81\uc744 \uc2e4\ud589\ud558\uc2e4 \ub54c\uc5d0\ub294 \n# https://tutorials.pytorch.kr/beginner/colab \ub97c \ucc38\uace0\ud558\uc138\uc694.\n%matplotlib inline"
1212
]
1313
},
1414
{
@@ -143,7 +143,7 @@
143143
"name": "python",
144144
"nbconvert_exporter": "python",
145145
"pygments_lexer": "ipython3",
146-
"version": "3.11.13"
146+
"version": "3.11.6"
147147
}
148148
},
149149
"nbformat": 4,

0 commit comments

Comments
ย (0)