Skip to content

Commit 9bd6157

Browse files
authored
Merge branch 'master' into master
2 parents 8ce7d9a + 7340002 commit 9bd6157

26 files changed

+730
-546
lines changed

.circleci/scripts/build_for_windows.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ if [[ "${CIRCLE_JOB}" == *worker_* ]]; then
4949
python $DIR/remove_runnable_code.py advanced_source/static_quantization_tutorial.py advanced_source/static_quantization_tutorial.py || true
5050
python $DIR/remove_runnable_code.py beginner_source/hyperparameter_tuning_tutorial.py beginner_source/hyperparameter_tuning_tutorial.py || true
5151
python $DIR/remove_runnable_code.py beginner_source/audio_preprocessing_tutorial.py beginner_source/audio_preprocessing_tutorial.py || true
52-
# Temp remove for mnist download issue.
53-
python $DIR/remove_runnable_code.py beginner_source/fgsm_tutorial.py beginner_source/fgsm_tutorial.py || true
52+
python $DIR/remove_runnable_code.py intermediate_source/tensorboard_profiler_tutorial.py intermediate_source/tensorboard_profiler_tutorial.py || true
53+
# Temp remove for mnist download issue. (Re-enabled for 1.8.1)
54+
# python $DIR/remove_runnable_code.py beginner_source/fgsm_tutorial.py beginner_source/fgsm_tutorial.py || true
5455

5556
export WORKER_ID=$(echo "${CIRCLE_JOB}" | tr -dc '0-9')
5657
count=0

_static/img/profiler_overview1.PNG

133 KB
Loading

_static/img/profiler_overview2.PNG

77.3 KB
Loading

_static/img/profiler_trace_view1.PNG

128 KB
Loading

_static/img/profiler_trace_view2.PNG

133 KB
Loading

_static/img/profiler_views_list.PNG

67.8 KB
Loading

_static/img/tensorboard_pr_curves.png

-190 KB
Loading

_templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
</noscript>
7676

7777
<script type="text/javascript">
78-
var collapsedSections = ['PyTorch Recipes', 'Image and Video', 'Audio', 'Text', 'Reinforcement Learning', 'Deploying PyTorch Models in Production', 'Code Transforms with FX', 'Frontend APIs', 'Extending PyTorch', 'Model Optimization', 'Parallel and Distributed Training', 'Mobile'];
78+
var collapsedSections = ['PyTorch Recipes', 'Learning PyTorch', 'Image and Video', 'Audio', 'Text', 'Reinforcement Learning', 'Deploying PyTorch Models in Production', 'Code Transforms with FX', 'Frontend APIs', 'Extending PyTorch', 'Model Optimization', 'Parallel and Distributed Training', 'Mobile'];
7979
</script>
8080

8181
<img height="1" width="1" style="border-style:none;" alt="" src="https://www.googleadservices.com/pagead/conversion/795629140/?label=txkmCPmdtosBENSssfsC&amp;guid=ON&amp;script=0"/>

advanced_source/ddp_pipeline.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def forward(self, x):
8989
class Encoder(nn.Module):
9090
def __init__(self, ntoken, ninp, dropout=0.5):
9191
super(Encoder, self).__init__()
92-
self.src_mask = None
9392
self.pos_encoder = PositionalEncoding(ninp, dropout)
9493
self.encoder = nn.Embedding(ntoken, ninp)
9594
self.ninp = ninp
@@ -99,17 +98,9 @@ def init_weights(self):
9998
initrange = 0.1
10099
self.encoder.weight.data.uniform_(-initrange, initrange)
101100

102-
def _generate_square_subsequent_mask(self, sz):
103-
mask = (torch.triu(torch.ones(sz, sz)) == 1).transpose(0, 1)
104-
mask = mask.float().masked_fill(mask == 0, float('-inf')).masked_fill(mask == 1, float(0.0))
105-
return mask
106-
107101
def forward(self, src):
108-
if self.src_mask is None or self.src_mask.size(0) != src.size(0):
109-
device = src.device
110-
mask = self._generate_square_subsequent_mask(src.size(0)).to(device)
111-
self.src_mask = mask
112-
102+
# Need (S, N) format for encoder.
103+
src = src.t()
113104
src = self.encoder(src) * math.sqrt(self.ninp)
114105
return self.pos_encoder(src)
115106

@@ -125,7 +116,8 @@ def init_weights(self):
125116
self.decoder.weight.data.uniform_(-initrange, initrange)
126117

127118
def forward(self, inp):
128-
return self.decoder(inp)
119+
# Need batch dimension first for output of pipeline.
120+
return self.decoder(inp).permute(1, 0, 2)
129121

130122
######################################################################
131123
# Start multiple processes for training
@@ -245,7 +237,8 @@ def get_batch(source, i):
245237
seq_len = min(bptt, len(source) - 1 - i)
246238
data = source[i:i+seq_len]
247239
target = source[i+1:i+1+seq_len].view(-1)
248-
return data, target
240+
# Need batch dimension first for pipeline parallelism.
241+
return data.t(), target
249242

250243
######################################################################
251244
# Model scale and Pipe initialization
@@ -318,8 +311,9 @@ def get_batch(source, i):
318311
# Need to use 'checkpoint=never' since as of PyTorch 1.8, Pipe checkpointing
319312
# doesn't work with DDP.
320313
from torch.distributed.pipeline.sync import Pipe
314+
chunks = 8
321315
model = Pipe(torch.nn.Sequential(
322-
*module_list), chunks = 8, checkpoint="never")
316+
*module_list), chunks = chunks, checkpoint="never")
323317

324318
# Initialize process group and wrap model in DDP.
325319
from torch.nn.parallel import DistributedDataParallel

beginner_source/PyTorch Cheat.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ See [onnx](https://pytorch.org/docs/stable/onnx.html)
5050
from torchvision import datasets, models, transforms # vision datasets, architectures & transforms
5151
import torchvision.transforms as transforms # composable transforms
5252
```
53-
See [torchvision](https://pytorch.org/docs/stable/torchvision/index.html)
53+
See [torchvision](https://pytorch.org/vision/stable/index.html)
5454

5555
### Distributed Training
5656

beginner_source/basics/data_tutorial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# PyTorch domain libraries provide a number of pre-loaded datasets (such as FashionMNIST) that
2626
# subclass ``torch.utils.data.Dataset`` and implement functions specific to the particular data.
2727
# They can be used to prototype and benchmark your model. You can find them
28-
# here: `Image Datasets <https://pytorch.org/docs/stable/torchvision/datasets.html>`_,
28+
# here: `Image Datasets <https://pytorch.org/vision/stable/datasets.html>`_,
2929
# `Text Datasets <https://pytorch.org/text/stable/datasets.html>`_, and
3030
# `Audio Datasets <https://pytorch.org/audio/stable/datasets.html>`_
3131
#
@@ -38,7 +38,7 @@
3838
# Fashion-MNIST is a dataset of Zalando’s article images consisting of of 60,000 training examples and 10,000 test examples.
3939
# Each example comprises a 28×28 grayscale image and an associated label from one of 10 classes.
4040
#
41-
# We load the `FashionMNIST Dataset <https://pytorch.org/docs/stable/torchvision/datasets.html#fashion-mnist>`_ with the following parameters:
41+
# We load the `FashionMNIST Dataset <https://pytorch.org/vision/stable/datasets.html#fashion-mnist>`_ with the following parameters:
4242
# - ``root`` is the path where the train/test data is stored,
4343
# - ``train`` specifies training or test dataset,
4444
# - ``download=True`` downloads the data from the internet if it's not available at ``root``.

beginner_source/basics/optimization_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
the `previous section <autograd_tutorial.html>`_), and **optimizes** these parameters using gradient descent. For a more
1919
detailed walkthrough of this process, check out this video on `backpropagation from 3Blue1Brown <https://www.youtube.com/watch?v=tIeHLnjs5U8>`__.
2020
21-
Pre-requisite Code
21+
Prerequisite Code
2222
-----------------
2323
We load the code from the previous sections on `Datasets & DataLoaders <data_tutorial.html>`_
2424
and `Build Model <buildmodel_tutorial.html>`_.

beginner_source/basics/quickstart_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# all of which include datasets. For this tutorial, we will be using a TorchVision dataset.
3636
#
3737
# The ``torchvision.datasets`` module contains ``Dataset`` objects for many real-world vision data like
38-
# CIFAR, COCO (`full list here <https://pytorch.org/docs/stable/torchvision/datasets.html>`_). In this tutorial, we
38+
# CIFAR, COCO (`full list here <https://pytorch.org/vision/stable/datasets.html>`_). In this tutorial, we
3939
# use the FashionMNIST dataset. Every TorchVision ``Dataset`` includes two arguments: ``transform`` and
4040
# ``target_transform`` to modify the samples and labels respectively.
4141

beginner_source/basics/transforms_tutorial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
All TorchVision datasets have two parameters -``transform`` to modify the features and
2020
``target_transform`` to modify the labels - that accept callables containing the transformation logic.
21-
The `torchvision.transforms <https://pytorch.org/docs/stable/torchvision/transforms.html>`_ module offers
21+
The `torchvision.transforms <https://pytorch.org/vision/stable/transforms.html>`_ module offers
2222
several commonly-used transforms out of the box.
2323
2424
The FashionMNIST features are in PIL Image format, and the labels are integers.
@@ -41,7 +41,7 @@
4141
# ToTensor()
4242
# -------------------------------
4343
#
44-
# `ToTensor <https://pytorch.org/docs/stable/torchvision/transforms.html#torchvision.transforms.ToTensor>`_
44+
# `ToTensor <https://pytorch.org/vision/stable/transforms.html#torchvision.transforms.ToTensor>`_
4545
# converts a PIL image or NumPy ``ndarray`` into a ``FloatTensor``. and scales
4646
# the image's pixel intensity values in the range [0., 1.]
4747
#

beginner_source/ptcheat.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Vision
7373
import torchvision.transforms as transforms # composable transforms
7474
7575
See
76-
`torchvision <https://pytorch.org/docs/stable/torchvision/index.html>`__
76+
`torchvision <https://pytorch.org/vision/stable/index.html>`__
7777

7878
Distributed Training
7979
--------------------

0 commit comments

Comments
 (0)