Skip to content

Commit f8f6724

Browse files
authored
Merge branch 'master' into cpu_profiler
2 parents af1f585 + 8313780 commit f8f6724

Some content is hidden

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

51 files changed

+3204
-609
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pytorch_tutorial_build_defaults: &pytorch_tutorial_build_defaults
106106
sudo pip -q install awscli==1.16.35
107107
108108
if [ -n "${CUDA_VERSION}" ]; then
109-
DRIVER_FN="NVIDIA-Linux-x86_64-440.59.run"
109+
DRIVER_FN="NVIDIA-Linux-x86_64-460.39.run"
110110
wget "https://s3.amazonaws.com/ossci-linux/nvidia_driver/$DRIVER_FN"
111111
sudo /bin/bash "$DRIVER_FN" -s --no-drm || (sudo cat /var/log/nvidia-installer.log && false)
112112
nvidia-smi
@@ -122,7 +122,7 @@ pytorch_tutorial_build_defaults: &pytorch_tutorial_build_defaults
122122
command: |
123123
set -e
124124
125-
export pyTorchDockerImageTag=291
125+
export pyTorchDockerImageTag=9de29bef4a5dc0dd1dd19428d83e5a66a44a1ed2
126126
echo "PyTorchDockerImageTag: "${pyTorchDockerImageTag}
127127
128128
cat >/home/circleci/project/ci_build_script.sh \<<EOL
@@ -171,14 +171,14 @@ pytorch_tutorial_build_defaults: &pytorch_tutorial_build_defaults
171171
172172
pytorch_tutorial_build_worker_defaults: &pytorch_tutorial_build_worker_defaults
173173
environment:
174-
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda9-cudnn7-py3"
174+
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda10.2-cudnn7-py3-gcc7"
175175
CUDA_VERSION: "9"
176176
resource_class: gpu.medium
177177
<<: *pytorch_tutorial_build_defaults
178178

179179
pytorch_tutorial_build_manager_defaults: &pytorch_tutorial_build_manager_defaults
180180
environment:
181-
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda9-cudnn7-py3"
181+
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda10.2-cudnn7-py3-gcc7"
182182
resource_class: medium
183183
<<: *pytorch_tutorial_build_defaults
184184

.circleci/scripts/build_for_windows.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ eval "$(conda shell.bash hook)"
3131
conda create -qyn testenv python=3.7
3232
conda activate testenv
3333

34-
conda install sphinx
35-
pip install sphinx_gallery==0.3.1 sphinx-copybutton flask pandas spacy ipython scipy pySoundFile scikit-image gym gym-super-mario-bros==7.3.0
36-
pip install -e git+git://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
37-
pip install ray[tune] tabulate
34+
REQUIREMENTS="$(grep -v '^ *#\|^torch\|^torchaudio\|^torchvision|^torchtext' $PROJECT_DIR/requirements.txt | grep .)"
35+
echo $REQUIREMENTS > requirements.txt
36+
pip install -r requirements.txt
37+
pip install pySoundFile
3838
conda install -yq -c pytorch "cudatoolkit=10.1" pytorch torchvision torchtext
3939
conda install torchaudio -c pytorch-test
4040
python -m spacy download de

.devcontainer/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM mcr.microsoft.com/vscode/devcontainers/python:3.8
2+
3+
COPY requirements.txt /tmp/pip-tmp/
4+
5+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
6+
&& apt-get install git gcc unzip make -y \
7+
&& pip3 install --disable-pip-version-check --no-cache-dir -r /tmp/pip-tmp/requirements.txt \
8+
&& rm -rf /tmp/pip-tmp

.devcontainer/devcontainer.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "PyTorch Tutorials",
3+
"build": {
4+
"context": "..",
5+
"dockerfile": "Dockerfile",
6+
"args": {}
7+
},
8+
"settings": {
9+
"terminal.integrated.shell.linux": "/bin/bash",
10+
"workbench.startupEditor": "none",
11+
"files.autoSave": "afterDelay",
12+
"python.dataScience.enabled": true,
13+
"python.dataScience.alwaysTrustNotebooks": true,
14+
"python.insidersChannel": "weekly",
15+
"python.showStartPage": false
16+
},
17+
"extensions": ["ms-python.python", "lextudio.restructuredtext"]
18+
}

.devcontainer/requirements.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Refer to ./jenkins/build.sh for tutorial build instructions
2+
3+
sphinx==1.8.2
4+
sphinx-gallery==0.3.1
5+
tqdm
6+
numpy
7+
matplotlib
8+
torch
9+
torchvision
10+
torchtext
11+
torchaudio
12+
PyHamcrest
13+
bs4
14+
awscli==1.16.35
15+
flask
16+
spacy
17+
ray[tune]
18+
19+
# PyTorch Theme
20+
-e git+git://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
21+
22+
ipython
23+
24+
# to run examples
25+
pandas
26+
scikit-image
27+
pillow==8.1.0
28+
wget
29+
30+
# for codespaces env
31+
pylint

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,4 @@ cleanup.sh
120120
*.swp
121121

122122
# PyTorch things
123-
*.pt
123+
*.pt

.jenkins/build.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ else
66
export BUCKET_NAME=pytorch-tutorial-build-pull-request
77
fi
88

9+
# set locale for click dependency in spacy
10+
export LC_ALL=C.UTF-8
11+
export LANG=C.UTF-8
12+
913
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
1014

1115
sudo apt-get update
@@ -28,9 +32,7 @@ python -m spacy download de
2832
# PyTorch Theme
2933
rm -rf src
3034
pip install -e git+git://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
31-
# pillow >= 4.2 will throw error when trying to write mode RGBA as JPEG,
32-
# this is a workaround to the issue.
33-
pip install sphinx-gallery==0.3.1 tqdm matplotlib ipython pillow==4.1.1
35+
pip install sphinx-gallery==0.3.1 tqdm matplotlib ipython pillow==8.1.0
3436

3537
aws configure set default.s3.multipart_threshold 5120MB
3638

_static/img/basics/comp-graph.png

14 KB
Loading

_static/img/basics/fashion_mnist.png

32.6 KB
Loading
59.2 KB
Loading

_static/img/basics/typesdata.png

14.4 KB
Loading

_static/img/quickstart/comp-graph.png

14 KB
Loading
32.6 KB
Loading
59.2 KB
Loading

_static/img/quickstart/typesdata.png

14.4 KB
Loading
Loading
Loading

_templates/layout.html

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@
3434
tutorialLink: window.location.href,
3535
downloadTitle: $(this).attr("data-response")
3636
});
37-
38-
gtag('event', 'click', {
39-
'event_category': 'Download',
40-
'event_label': $(this).attr("data-response")
37+
ga('send', {
38+
hitType: 'event',
39+
eventCategory: $(this).attr("data-response"),
40+
eventAction: 'click',
41+
eventLabel: window.location.href
4142
});
4243

4344
gtag('event', 'click', {
@@ -47,29 +48,22 @@
4748
});
4849
});
4950

50-
$("[data-behavior='was-this-helpful-event']").on('click', function(){
51-
$(".helpful-question").hide();
52-
$(".was-helpful-thank-you").show();
53-
54-
fbq('trackCustom', "Was this Helpful?", {
51+
$("[data-behavior='tutorial-rating']").on('click', function(){
52+
fbq('trackCustom', "Tutorial Rating", {
5553
tutorialLink: window.location.href,
5654
tutorialTitle: $('h1:first').text(),
57-
helpful: $(this).attr("data-response")
58-
});
59-
60-
gtag('event', $(this).attr("data-response"), {
61-
'event_category': 'Was this Helpful?',
62-
'event_label': $(this).attr("data-response")
55+
rating: $(this).attr("data-count")
6356
});
6457

65-
gtag('event', $(this).attr("data-response"), {
66-
'event_category': 'Was this Helpful?',
67-
'event_label': $("h1").first().text()
58+
gtag('event', 'click', {
59+
'event_category': 'Tutorial Rating',
60+
'event_label': $("h1").first().text(),
61+
'value': $(this).attr("data-count")
6862
});
6963
});
7064

7165
if (location.pathname == "/") {
72-
$(".helpful-container").hide();
66+
$(".rating-container").hide();
7367
$(".hr-bottom").hide();
7468
}
7569
</script>
@@ -79,5 +73,10 @@
7973
src="https://www.facebook.com/tr?id=243028289693773&ev=PageView
8074
&noscript=1"/>
8175
</noscript>
76+
77+
<script type="text/javascript">
78+
var collapsedSections = [];
79+
</script>
80+
8281
<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"/>
8382
{% endblock %}

advanced_source/dispatcher.rst

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ Defining schema and backend implementations
3232

3333
The general principle behind the dispatcher is that it divides the
3434
implementation of an operator into multiple kernels, each of which implements
35-
functionality for a specific *dispatch key*; for example, CPU, CUDA or Autograd.
36-
The dispatcher determines what the highest priority dispatch key is at the time
35+
functionality for a specific *dispatch key*, e.g. CPU, CUDA. The dispatcher
36+
determines what the highest priority dispatch key is at the time
3737
you call an operator (this is done by looking at both the tensor arguments as
3838
well as some thread local state), and transfers control to the kernel for that
3939
dispatch key. The end effect is that when you call an operator, we first
40-
execute the Autograd kernel, and then we redispatch to the CPU or CUDA kernel
40+
execute the Autograd kernel, and then we redispatch to the backend kernel
4141
depending on the device types of the passed in tensors.
4242

4343
Let's take a look at the various parts involved in making this
@@ -115,7 +115,7 @@ can we add autograd support to it? As you might guess, we will register an
115115
autograd kernel (similar to what's described in the `custom autograd function <cpp_autograd>`_ tutorial)!
116116
However, there is a twist: unlike the CPU and CUDA kernels, the autograd kernel
117117
needs to *redispatch*: it needs to call back into the dispatcher to get to
118-
the final CPU and CUDA implementations.
118+
the inference kernels, e.g. CPU or CUDA implementations.
119119

120120
Thus, before we write the autograd kernel, let's write a *dispatching function*
121121
which calls into the dispatcher to find the right kernel for your operator.
@@ -179,6 +179,17 @@ functions:
179179
:start-after: BEGIN TORCH_LIBRARY_IMPL Autograd
180180
:end-before: END TORCH_LIBRARY_IMPL Autograd
181181

182+
183+
.. note::
184+
185+
In this example we register the kernel to ``Autograd``, which installs it as the
186+
autograd kernel for all backends. You can also register optimized kernels for specific
187+
backends by using the corresponding backend-specific dispatch key - for example,
188+
``AutogradCPU`` or ``AutogradCUDA``. To explore these and other dispatch key
189+
options in more detail, check out the ``PythonDispatcher`` tool provided in
190+
`torch/_python_dispatcher.py <https://github.com/pytorch/pytorch/blob/master/torch/_python_dispatcher.py>`_.
191+
192+
182193
Going beyond autograd
183194
---------------------
184195

@@ -209,7 +220,8 @@ So why use the dispatcher? There are a few reasons:
209220
(CPU, CUDA, Autograd) without having to write a single, centralized
210221
if statement that refers to all of them. Importantly, third parties can
211222
register extra implementations for other aspects without having to patch the
212-
original definition of an operator.
223+
original definition of an operator. We'll talk more about extending the
224+
dispatcher in `extending dispatcher for a new backend <extend_dispatcher>`_.
213225

214226
2. It supports more dispatch keys than CPU, CUDA and Autograd. You can
215227
see a full list of dispatch keys that are currently implemented

0 commit comments

Comments
 (0)