Skip to content

Commit 9bed147

Browse files
authored
Merge branch 'master' into transformer_tutorial
2 parents 57cf024 + 8313780 commit 9bed147

File tree

7 files changed

+198
-16
lines changed

7 files changed

+198
-16
lines changed
Loading
Loading

beginner_source/fgsm_tutorial.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@
9999
import numpy as np
100100
import matplotlib.pyplot as plt
101101

102+
# NOTE: This is a hack to get around "User-agent" limitations when downloading MNIST datasets
103+
# see, https://github.com/pytorch/vision/issues/3497 for more information
104+
from six.moves import urllib
105+
opener = urllib.request.build_opener()
106+
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
107+
urllib.request.install_opener(opener)
108+
102109

103110
######################################################################
104111
# Implementation
@@ -413,4 +420,3 @@ def test( model, device, test_loader, epsilon ):
413420
# it differs from FGSM. Then, try to defend the model from your own
414421
# attacks.
415422
#
416-

index.rst

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Welcome to PyTorch Tutorials
222222
:card_description: Get an overview of Channels Last memory format and understand how it is used to order NCHW tensors in memory preserving dimensions.
223223
:image: _static/img/thumbnails/cropped/experimental-Channels-Last-Memory-Format-in-PyTorch.png
224224
:link: intermediate/memory_format_tutorial.html
225-
:tags: Memory-Format,Best-Practice
225+
:tags: Memory-Format,Best-Practice,Frontend-APIs
226226

227227
.. customcarditem::
228228
:header: Using the PyTorch C++ Frontend
@@ -265,6 +265,21 @@ Welcome to PyTorch Tutorials
265265
:image: _static/img/thumbnails/cropped/Autograd-in-Cpp-Frontend.png
266266
:link: advanced/cpp_autograd.html
267267
:tags: Frontend-APIs,C++
268+
269+
.. customcarditem::
270+
:header: Registering a Dispatched Operator in C++
271+
:card_description: The dispatcher is an internal component of PyTorch which is responsible for figuring out what code should actually get run when you call a function like torch::add.
272+
:image: _static/img/thumbnails/cropped/generic-pytorch-logo.PNG
273+
:link: advanced/dispatcher.html
274+
:tags: Extending-PyTorch,Frontend-APIs,C++
275+
276+
.. customcarditem::
277+
:header: Extending Dispatcher For a New Backend in C++
278+
:card_description: Learn how to extend the dispatcher to add a new device living outside of the pytorch/pytorch repo and maintain it to keep in sync with native PyTorch devices.
279+
:image: _static/img/thumbnails/cropped/generic-pytorch-logo.PNG
280+
:link: advanced/extend_dispatcher.html
281+
:tags: Extending-PyTorch,Frontend-APIs,C++
282+
268283

269284
.. Model Optimization
270285
@@ -302,6 +317,13 @@ Welcome to PyTorch Tutorials
302317
:image: _static/img/thumbnails/cropped/experimental-Dynamic-Quantization-on-BERT.png
303318
:link: intermediate/dynamic_quantization_bert_tutorial.html
304319
:tags: Text,Quantization,Model-Optimization
320+
321+
.. customcarditem::
322+
:header: (beta) Quantized Transfer Learning for Computer Vision Tutorial
323+
:card_description: Extends the Transfer Learning for Computer Vision Tutorial using a quantized model.
324+
:image: _static/img/thumbnails/cropped/generic-pytorch-logo.PNG
325+
:link: intermediate/quantized_transfer_learning_tutorial.html
326+
:tags: Image/Video,Quantization,Model-Optimization
305327

306328
.. Parallel-and-Distributed-Training
307329
@@ -447,6 +469,7 @@ Additional Resources
447469
:caption: PyTorch Recipes
448470

449471
See All Recipes <recipes/recipes_index>
472+
See All Prototype Recipes <prototype/prototype_index>
450473

451474
.. toctree::
452475
:maxdepth: 2
@@ -572,6 +595,6 @@ Additional Resources
572595
:hidden:
573596
:caption: Mobile
574597

575-
beginner/deeplabv3_on_ios.html
576-
beginner/deeplabv3_on_android.html
598+
beginner/deeplabv3_on_ios
599+
beginner/deeplabv3_on_android
577600

intermediate_source/quantized_transfer_learning_tutorial.rst

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -450,19 +450,20 @@ the feature extractor is quantized).
450450
.. note:: Because of the random initialization your results might differ from
451451
the results shown in this tutorial.
452452

453+
.. code:: python
453454
454-
# notice `quantize=False`
455-
model = models.resnet18(pretrained=True, progress=True, quantize=False)
456-
num_ftrs = model.fc.in_features
457-
458-
# Step 1
459-
model.train()
460-
model.fuse_model()
461-
# Step 2
462-
model_ft = create_combined_model(model)
463-
model_ft[0].qconfig = torch.quantization.default_qat_qconfig # Use default QAT configuration
464-
# Step 3
465-
model_ft = torch.quantization.prepare_qat(model_ft, inplace=True)
455+
# notice `quantize=False`
456+
model = models.resnet18(pretrained=True, progress=True, quantize=False)
457+
num_ftrs = model.fc.in_features
458+
459+
# Step 1
460+
model.train()
461+
model.fuse_model()
462+
# Step 2
463+
model_ft = create_combined_model(model)
464+
model_ft[0].qconfig = torch.quantization.default_qat_qconfig # Use default QAT configuration
465+
# Step 3
466+
model_ft = torch.quantization.prepare_qat(model_ft, inplace=True)
466467
467468
468469
Finetuning the model

intermediate_source/spatial_transformer_tutorial.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
# standard convolutional network augmented with a spatial transformer
4848
# network.
4949

50+
from six.moves import urllib
51+
opener = urllib.request.build_opener()
52+
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
53+
urllib.request.install_opener(opener)
54+
5055
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5156

5257
# Training dataset

prototype_source/prototype_index.rst

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
PyTorch Prototype Recipes
2+
---------------------------------------------
3+
Prototype features are not available as part of binary distributions like PyPI or Conda (except maybe behind run-time flags). To test these features we would, depending on the feature, recommend building from master or using the nightly wheels that are made available on `pytorch.org <https://pytorch.org>`_.
4+
5+
*Level of commitment*: We are committing to gathering high bandwidth feedback only on these features. Based on this feedback and potential further engagement between community members, we as a community will decide if we want to upgrade the level of commitment or to fail fast.
6+
7+
8+
.. raw:: html
9+
10+
</div>
11+
</div>
12+
13+
<div id="tutorial-cards-container">
14+
15+
<nav class="navbar navbar-expand-lg navbar-light tutorials-nav col-12">
16+
<div class="tutorial-tags-container">
17+
<div id="dropdown-filter-tags">
18+
<div class="tutorial-filter-menu">
19+
<div class="tutorial-filter filter-btn all-tag-selected" data-tag="all">All</div>
20+
</div>
21+
</div>
22+
</div>
23+
</nav>
24+
25+
<hr class="tutorials-hr">
26+
27+
<div class="row">
28+
29+
<div id="tutorial-cards">
30+
<div class="list">
31+
32+
.. Add prototype tutorial cards below this line
33+
34+
.. Quantization
35+
36+
.. customcarditem::
37+
:header: FX Graph Mode Quantization User Guide
38+
:card_description: Learn about FX Graph Mode Quantization.
39+
:image: ../_static/img/thumbnails/cropped/generic-pytorch-logo.PNG
40+
:link: ../prototype/fx_graph_mode_quant_guide.html
41+
:tags: FX,Quantization
42+
43+
.. customcarditem::
44+
:header: FX Graph Mode Post Training Dynamic Quantization
45+
:card_description: Learn how to do post training dynamic quantization in graph mode based on torch.fx.
46+
:image: ../_static/img/thumbnails/cropped/generic-pytorch-logo.PNG
47+
:link: ../prototype/fx_graph_mode_ptq_dynamic.html
48+
:tags: FX,Quantization
49+
50+
.. customcarditem::
51+
:header: FX Graph Mode Post Training Static Quantization
52+
:card_description: Learn how to do post training static quantization in graph mode based on torch.fx.
53+
:image: ../_static/img/thumbnails/cropped/generic-pytorch-logo.PNG
54+
:link: ../prototype/fx_graph_mode_ptq_static.html
55+
:tags: FX,Quantization
56+
57+
.. customcarditem::
58+
:header: Graph Mode Dynamic Quantization on BERT
59+
:card_description: Learn how to do post training dynamic quantization with graph mode quantization on BERT models.
60+
:image: ../_static/img/thumbnails/cropped/graph-mode-dynamic-bert.PNG
61+
:link: ../prototype/graph_mode_dynamic_bert_tutorial.html
62+
:tags: Text,Quantization
63+
64+
.. customcarditem::
65+
:header: PyTorch Numeric Suite Tutorial
66+
:card_description: Learn how to use the PyTorch Numeric Suite to support quantization debugging efforts.
67+
:image: ../_static/img/thumbnails/cropped/generic-pytorch-logo.PNG
68+
:link: ../prototype/numeric_suite_tutorial.html
69+
:tags: Debugging,Quantization
70+
71+
.. Mobile
72+
73+
.. customcarditem::
74+
:header: Use iOS GPU in PyTorch
75+
:card_description: Learn how to run your models on iOS GPU.
76+
:image: ../_static/img/thumbnails/cropped/ios.PNG
77+
:link: ../prototype/ios_gpu_workflow.html
78+
:tags: Mobile
79+
80+
.. customcarditem::
81+
:header: Convert MobileNetV2 to NNAPI
82+
:card_description: Learn how to prepare a computer vision model to use Android’s Neural Networks API (NNAPI).
83+
:image: ../_static/img/thumbnails/cropped/android.PNG
84+
:link: ../prototype/nnapi_mobilenetv2.html
85+
:tags: Mobile
86+
87+
.. customcarditem::
88+
:header: PyTorch Vulkan Backend User Workflow
89+
:card_description: Learn how to use the Vulkan backend on mobile GPUs.
90+
:image: ../_static/img/thumbnails/cropped/android.PNG
91+
:link: ../prototype/vulkan_workflow.html
92+
:tags: Mobile
93+
94+
.. customcarditem::
95+
:header: Lite Interpreter Workflow in Android and iOS
96+
:card_description: Learn how to use the lite interpreter on iOS and Andriod devices.
97+
:image: ../_static/img/thumbnails/cropped/mobile.PNG
98+
:link: ../prototype/lite_interpreter.html
99+
:tags: Mobile
100+
101+
.. TorchScript
102+
103+
.. customcarditem::
104+
:header: Model Freezing in TorchScript
105+
:card_description: Freezing is the process of inlining Pytorch module parameters and attributes values into the TorchScript internal representation.
106+
:image: ../_static/img/thumbnails/cropped/generic-pytorch-logo.PNG
107+
:link: ../prototype/torchscript_freezing.html
108+
:tags: TorchScript
109+
110+
.. vmap
111+
112+
.. customcarditem::
113+
:header: Using torch.vmap
114+
:card_description: Learn about torch.vmap, an autovectorizer for PyTorch operations.
115+
:image: ../_static/img/thumbnails/cropped/generic-pytorch-logo.PNG
116+
:link: ../prototype/vmap_recipe.html
117+
:tags: vmap
118+
119+
.. End of tutorial card section
120+
121+
.. raw:: html
122+
123+
</div>
124+
125+
<div class="pagination d-flex justify-content-center"></div>
126+
127+
</div>
128+
129+
</div>
130+
131+
.. -----------------------------------------
132+
.. Page TOC
133+
.. -----------------------------------------
134+
.. toctree::
135+
:hidden:
136+
137+
prototype/fx_graph_mode_quant_guide.html
138+
prototype/fx_graph_mode_ptq_dynamic.html
139+
prototype/fx_graph_mode_ptq_static.html
140+
prototype/graph_mode_dynamic_bert_tutorial.html
141+
prototype/ios_gpu_workflow.html
142+
prototype/nnapi_mobilenetv2.html
143+
prototype/numeric_suite_tutorial.html
144+
prototype/torchscript_freezing.html
145+
prototype/vmap_recipe.html
146+
prototype/vulkan_workflow.html
147+
prototype/lite_interpreter.html

0 commit comments

Comments
 (0)