Skip to content

Commit c9a968a

Browse files
authored
Merge branch 'main' into tutorial-audit-T228126880
2 parents 0033edf + a47d520 commit c9a968a

File tree

7 files changed

+37
-239
lines changed

7 files changed

+37
-239
lines changed

.ci/docker/requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# --extra-index-url https://download.pytorch.org/whl/cu117/index.html # Use this to run/publish tutorials against the latest binaries during the RC stage. Comment out after the release. Each release verify the correct cuda version.
22
# Refer to ./jenkins/build.sh for tutorial build instructions
33

4-
sphinx==5.0.0
4+
sphinx==5.3.0
55
sphinx-gallery==0.11.1
6-
sphinx_design
6+
sphinx-reredirects==0.1.4
7+
sphinx-design==0.4.0
78
docutils==0.16
89
sphinx-copybutton
910
sphinx_sitemap==2.6.0

.jenkins/build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ elif [[ "${JOB_TYPE}" == "manager" ]]; then
151151
# Step 7: push new HTML files and static files to gh-pages
152152
if [[ "$COMMIT_SOURCE" == "refs/heads/master" || "$COMMIT_SOURCE" == "refs/heads/main" ]]; then
153153
git clone https://github.com/pytorch/tutorials.git -b gh-pages gh-pages
154+
# Clean up directories that contain tutorials
155+
156+
for dir in beginner intermediate prototype recipes advanced distributed vision text audio; do
157+
rm -rf "gh-pages/$dir"
158+
done
159+
154160
cp -r docs/* gh-pages/
155161
pushd gh-pages
156162
# DANGER! DO NOT REMOVE THE `set +x` SETTING HERE!

beginner_source/saving_loading_models.py

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -227,43 +227,30 @@
227227
# normalization layers to evaluation mode before running inference.
228228
# Failing to do this will yield inconsistent inference results.
229229
#
230-
# Export/Load Model in TorchScript Format
231-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
230+
# Saving an Exported Program
231+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
232232
#
233-
# One common way to do inference with a trained model is to use
234-
# `TorchScript <https://pytorch.org/docs/stable/jit.html>`__, an intermediate
235-
# representation of a PyTorch model that can be run in Python as well as in a
236-
# high performance environment like C++. TorchScript is actually the recommended model format
237-
# for scaled inference and deployment.
233+
# If you are using ``torch.export``, you can save and load your ``ExportedProgram`` using the
234+
# ``torch.export.save()`` and ``torch.export.load()`` APIs. with the ``.pt2`` file extension:
238235
#
239-
# .. note::
240-
# Using the TorchScript format, you will be able to load the exported model and
241-
# run inference without defining the model class.
242-
#
243-
# **Export:**
244-
#
245-
# .. code:: python
246-
#
247-
# model_scripted = torch.jit.script(model) # Export to TorchScript
248-
# model_scripted.save('model_scripted.pt') # Save
249-
#
250-
# **Load:**
236+
# .. code-block:: python
237+
#
238+
# class SimpleModel(torch.nn.Module):
239+
# def forward(self, x):
240+
# return x + 10
251241
#
252-
# .. code:: python
242+
# # Create a sample input
243+
# sample_input = torch.randn(5)
244+
#
245+
# # Export the model
246+
# exported_program = torch.export.export(SimpleModel(), sample_input)
253247
#
254-
# model = torch.jit.load('model_scripted.pt')
255-
# model.eval()
248+
# # Save the exported program
249+
# torch.export.save(exported_program, 'exported_program.pt2')
256250
#
257-
# Remember that you must call ``model.eval()`` to set dropout and batch
258-
# normalization layers to evaluation mode before running inference.
259-
# Failing to do this will yield inconsistent inference results.
251+
# # Load the exported program
252+
# saved_exported_program = torch.export.load('exported_program.pt2')
260253
#
261-
# For more information on TorchScript, feel free to visit the dedicated
262-
# `tutorials <https://pytorch.org/tutorials/beginner/Intro_to_TorchScript_tutorial.html>`__.
263-
# You will get familiar with the tracing conversion and learn how to
264-
# run a TorchScript module in a `C++ environment <https://pytorch.org/tutorials/advanced/cpp_export.html>`__.
265-
266-
267254

268255
######################################################################
269256
# Saving & Loading a General Checkpoint for Inference and/or Resuming Training

conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
import plotly.io as pio
4646
from pathlib import Path
4747
pio.renderers.default = 'sphinx_gallery'
48-
48+
from redirects import redirects
4949

5050
import sphinx_gallery.gen_rst
5151
import multiprocessing
@@ -121,7 +121,8 @@ def wrapper(*args, **kwargs):
121121
'sphinx_copybutton',
122122
'sphinx_gallery.gen_gallery',
123123
'sphinx_design',
124-
'sphinx_sitemap'
124+
'sphinx_sitemap',
125+
'sphinx_reredirects'
125126
]
126127

127128
intersphinx_mapping = {

prototype_source/pt2e_quant_xpu_inductor.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ We will start by performing the necessary imports, capturing the FX Graph from t
8585
exported_model = export_for_training(
8686
model,
8787
example_inputs,
88+
strict=True
8889
).module()
8990

9091

recipes_source/bundled_inputs.rst

Lines changed: 0 additions & 204 deletions
This file was deleted.

redirects.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
redirects = {
2+
"intermediate/flask_rest_api_tutorial": "../index.html",
3+
"beginner/ptcheat.html": "../index.html",
4+
"beginner/deploy_seq2seq_hybrid_frontend_tutorial.html": "../index.html",
5+
"recipes/bundled_inputs.html": "../index.html",
6+
}

0 commit comments

Comments
 (0)