Skip to content

Commit 31f2d4e

Browse files
yiming0416pytorchmergebot
authored andcommitted
[export] Update docs (pytorch#142011)
Summary: Update export docs. Including: 1. Update the output graph. 2. Misc fixes for examples. Test Plan: CI Differential Revision: D66726729 Pull Request resolved: pytorch#142011 Approved by: https://github.com/angelayi
1 parent 471017c commit 31f2d4e

File tree

3 files changed

+431
-175
lines changed

3 files changed

+431
-175
lines changed

Diff for: docs/source/export.ir_spec.rst

+16-6
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,25 @@ of the Graph of GraphModule.
103103

104104
Example::
105105

106-
from torch import nn
106+
import torch
107+
from torch import nn
107108

108-
class MyModule(nn.Module):
109+
class MyModule(nn.Module):
109110

110-
def forward(self, x, y):
111-
return x + y
111+
def forward(self, x, y):
112+
return x + y
112113

113-
mod = torch.export.export(MyModule())
114-
print(mod.graph)
114+
example_args = (torch.randn(1), torch.randn(1))
115+
mod = torch.export.export(MyModule(), example_args)
116+
print(mod.graph)
117+
118+
.. code-block:: python
119+
120+
graph():
121+
%x : [num_users=1] = placeholder[target=x]
122+
%y : [num_users=1] = placeholder[target=y]
123+
%add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%x, %y), kwargs = {})
124+
return (add,)
115125
116126
The above is the textual representation of a Graph, with each line being a node.
117127

0 commit comments

Comments
 (0)