Skip to content

Commit a670092

Browse files
committed
Generate Python docs from pytorch/pytorch@dbec08b
1 parent 59d2ea9 commit a670092

File tree

2,282 files changed

+22070
-26567
lines changed

Some content is hidden

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

2,282 files changed

+22070
-26567
lines changed

main/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: a23b80d48a841bbc93a2e9086c06bd07
3+
config: f9f5ccd1623901da8bad74e4787c40eb
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

main/_images/RReLU.png

-18 Bytes
Loading

main/_images/ReduceLROnPlateau.png

173 Bytes
Loading

main/_sources/export.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ buffers) always have static shapes.
660660
Python Primitives
661661
~~~~~~~~~~~~~~~~~
662662

663-
``torch.export`` also specializes on Python primtivies,
663+
``torch.export`` also specializes on Python primitives,
664664
such as ``int``, ``float``, ``bool``, and ``str``. However they do have dynamic
665665
variants such as ``SymInt``, ``SymFloat``, and ``SymBool``.
666666

main/_sources/generated/exportdb/index.rst.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ support in export please create an issue in the pytorch/pytorch repo with a modu
1919
:caption: Tags
2020

2121
torch.escape-hatch
22-
torch.cond
2322
torch.dynamic-shape
23+
torch.cond
2424
python.closure
2525
torch.dynamic-value
2626
python.data-structure
@@ -233,7 +233,7 @@ cond_branch_class_method
233233

234234
.. note::
235235

236-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
236+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
237237

238238
Support Level: SUPPORTED
239239

@@ -315,7 +315,7 @@ cond_branch_nested_function
315315

316316
.. note::
317317

318-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
318+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
319319

320320
Support Level: SUPPORTED
321321

@@ -394,7 +394,7 @@ cond_branch_nonlocal_variables
394394

395395
.. note::
396396

397-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
397+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
398398

399399
Support Level: SUPPORTED
400400

@@ -574,7 +574,7 @@ cond_operands
574574

575575
.. note::
576576

577-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
577+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
578578

579579
Support Level: SUPPORTED
580580

@@ -666,7 +666,7 @@ cond_predicate
666666

667667
.. note::
668668

669-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
669+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
670670

671671
Support Level: SUPPORTED
672672

@@ -1162,7 +1162,7 @@ dynamic_shape_map
11621162

11631163
.. note::
11641164

1165-
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.map <torch.map>`
1165+
Tags: :doc:`torch.map <torch.map>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
11661166

11671167
Support Level: SUPPORTED
11681168

main/_sources/generated/exportdb/torch.cond.rst.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cond_branch_class_method
55

66
.. note::
77

8-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
8+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
99

1010
Support Level: SUPPORTED
1111

@@ -87,7 +87,7 @@ cond_branch_nested_function
8787

8888
.. note::
8989

90-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
90+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
9191

9292
Support Level: SUPPORTED
9393

@@ -166,7 +166,7 @@ cond_branch_nonlocal_variables
166166

167167
.. note::
168168

169-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
169+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
170170

171171
Support Level: SUPPORTED
172172

@@ -346,7 +346,7 @@ cond_operands
346346

347347
.. note::
348348

349-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
349+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
350350

351351
Support Level: SUPPORTED
352352

@@ -438,7 +438,7 @@ cond_predicate
438438

439439
.. note::
440440

441-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
441+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
442442

443443
Support Level: SUPPORTED
444444

main/_sources/generated/exportdb/torch.dynamic-shape.rst.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cond_branch_class_method
55

66
.. note::
77

8-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
8+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
99

1010
Support Level: SUPPORTED
1111

@@ -87,7 +87,7 @@ cond_branch_nested_function
8787

8888
.. note::
8989

90-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
90+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
9191

9292
Support Level: SUPPORTED
9393

@@ -166,7 +166,7 @@ cond_branch_nonlocal_variables
166166

167167
.. note::
168168

169-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
169+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
170170

171171
Support Level: SUPPORTED
172172

@@ -270,7 +270,7 @@ cond_operands
270270

271271
.. note::
272272

273-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
273+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
274274

275275
Support Level: SUPPORTED
276276

@@ -362,7 +362,7 @@ cond_predicate
362362

363363
.. note::
364364

365-
Tags: :doc:`torch.cond <torch.cond>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
365+
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.cond <torch.cond>`
366366

367367
Support Level: SUPPORTED
368368

@@ -535,7 +535,7 @@ dynamic_shape_map
535535

536536
.. note::
537537

538-
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.map <torch.map>`
538+
Tags: :doc:`torch.map <torch.map>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
539539

540540
Support Level: SUPPORTED
541541

main/_sources/generated/exportdb/torch.map.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dynamic_shape_map
55

66
.. note::
77

8-
Tags: :doc:`torch.dynamic-shape <torch.dynamic-shape>`, :doc:`torch.map <torch.map>`
8+
Tags: :doc:`torch.map <torch.map>`, :doc:`torch.dynamic-shape <torch.dynamic-shape>`
99

1010
Support Level: SUPPORTED
1111

main/_sources/onnx.md.txt

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# torch.onnx
2+
3+
4+
## Overview
5+
6+
[Open Neural Network eXchange (ONNX)](https://onnx.ai/) is an open standard
7+
format for representing machine learning models. The `torch.onnx` module captures the computation graph from a
8+
native PyTorch {class}`torch.nn.Module` model and converts it into an
9+
[ONNX graph](https://github.com/onnx/onnx/blob/main/docs/IR.md).
10+
11+
The exported model can be consumed by any of the many
12+
[runtimes that support ONNX](https://onnx.ai/supported-tools.html#deployModel), including
13+
Microsoft's [ONNX Runtime](https://www.onnxruntime.ai).
14+
15+
**There are two flavors of ONNX exporter API that you can use, as listed below.**
16+
Both can be called through function {func}`torch.onnx.export`.
17+
Next example shows how to export a simple model.
18+
19+
```python
20+
import torch
21+
22+
class MyModel(torch.nn.Module):
23+
def __init__(self):
24+
super(MyModel, self).__init__()
25+
self.conv1 = torch.nn.Conv2d(1, 128, 5)
26+
27+
def forward(self, x):
28+
return torch.relu(self.conv1(x))
29+
30+
input_tensor = torch.rand((1, 1, 128, 128), dtype=torch.float32)
31+
32+
model = MyModel()
33+
34+
torch.onnx.export(
35+
model, # model to export
36+
(input_tensor,), # inputs of the model,
37+
"my_model.onnx", # filename of the ONNX model
38+
input_names=["input"], # Rename inputs for the ONNX model
39+
dynamo=True # True or False to select the exporter to use
40+
)
41+
```
42+
43+
Next sections introduce the two versions of the exporter.
44+
45+
## TorchDynamo-based ONNX Exporter
46+
47+
*The TorchDynamo-based ONNX exporter is the newest (and Beta) exporter for PyTorch 2.1 and newer*
48+
49+
TorchDynamo engine is leveraged to hook into Python's frame evaluation API and dynamically rewrite its
50+
bytecode into an FX Graph. The resulting FX Graph is then polished before it is finally translated into an
51+
ONNX graph.
52+
53+
The main advantage of this approach is that the [FX graph](https://pytorch.org/docs/stable/fx.html) is captured using
54+
bytecode analysis that preserves the dynamic nature of the model instead of using traditional static tracing techniques.
55+
56+
{doc}`Learn more about the TorchDynamo-based ONNX Exporter <onnx_dynamo>`
57+
58+
## TorchScript-based ONNX Exporter
59+
60+
*The TorchScript-based ONNX exporter is available since PyTorch 1.2.0*
61+
62+
[TorchScript](https://pytorch.org/docs/stable/jit.html) is leveraged to trace (through {func}`torch.jit.trace`)
63+
the model and capture a static computation graph.
64+
65+
As a consequence, the resulting graph has a couple limitations:
66+
67+
* It does not record any control-flow, like if-statements or loops;
68+
* Does not handle nuances between `training` and `eval` mode;
69+
* Does not truly handle dynamic inputs
70+
71+
As an attempt to support the static tracing limitations, the exporter also supports TorchScript scripting
72+
(through {func}`torch.jit.script`), which adds support for data-dependent control-flow, for example. However, TorchScript
73+
itself is a subset of the Python language, so not all features in Python are supported, such as in-place operations.
74+
75+
{doc}`Learn more about the TorchScript-based ONNX Exporter <onnx_torchscript>`
76+
77+
## Contributing / Developing
78+
79+
The ONNX exporter is a community project and we welcome contributions. We follow the
80+
[PyTorch guidelines for contributions](https://github.com/pytorch/pytorch/blob/main/CONTRIBUTING.md), but you might
81+
also be interested in reading our [development wiki](https://github.com/pytorch/pytorch/wiki/PyTorch-ONNX-exporter).
82+
83+
```{eval-rst}
84+
.. toctree::
85+
:hidden:
86+
87+
onnx_dynamo
88+
onnx_ops
89+
onnx_verification
90+
onnx_dynamo_onnxruntime_backend
91+
onnx_torchscript
92+
```
93+
94+
<!-- This module needs to be documented. Adding here in the meantime
95+
for tracking purposes -->
96+
```{eval-rst}
97+
.. py:module:: torch.onnx.errors
98+
.. py:module:: torch.onnx.operators
99+
.. py:module:: torch.onnx.symbolic_caffe2
100+
.. py:module:: torch.onnx.symbolic_helper
101+
.. py:module:: torch.onnx.symbolic_opset10
102+
.. py:module:: torch.onnx.symbolic_opset11
103+
.. py:module:: torch.onnx.symbolic_opset12
104+
.. py:module:: torch.onnx.symbolic_opset13
105+
.. py:module:: torch.onnx.symbolic_opset14
106+
.. py:module:: torch.onnx.symbolic_opset15
107+
.. py:module:: torch.onnx.symbolic_opset16
108+
.. py:module:: torch.onnx.symbolic_opset17
109+
.. py:module:: torch.onnx.symbolic_opset18
110+
.. py:module:: torch.onnx.symbolic_opset19
111+
.. py:module:: torch.onnx.symbolic_opset20
112+
.. py:module:: torch.onnx.symbolic_opset7
113+
.. py:module:: torch.onnx.symbolic_opset8
114+
.. py:module:: torch.onnx.symbolic_opset9
115+
.. py:module:: torch.onnx.utils
116+
```

0 commit comments

Comments
 (0)