Skip to content

Commit db28905

Browse files
author
Svetlana Karslioglu
authored
Merge branch 'main' into fix_render
2 parents 6521b65 + 31bccdc commit db28905

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

.jenkins/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ pip install --progress-bar off -r $DIR/../requirements.txt
2525
#Install PyTorch Nightly for test.
2626
# Nightly - pip install --pre torch torchvision torchaudio -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html
2727
# Install 2.1 for testing
28-
pip uninstall -y torch torchvision torchaudio torchtext torchdata
29-
pip3 install torch torchvision torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu121
30-
pip3 install torchdata torchtext --index-url https://download.pytorch.org/whl/test/cpu
28+
# pip uninstall -y torch torchvision torchaudio torchtext torchdata
29+
# pip3 install torch torchvision torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu121
30+
# pip3 install torchdata torchtext --index-url https://download.pytorch.org/whl/test/cpu
3131

3232
# Install two language tokenizers for Translation with TorchText tutorial
3333
python -m spacy download en_core_web_sm

intermediate_source/torch_compile_tutorial.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@
2020
#
2121
# **Contents**
2222
#
23-
# - Basic Usage
24-
# - Demonstrating Speedups
25-
# - Comparison to TorchScript and FX Tracing
26-
# - TorchDynamo and FX Graphs
27-
# - Conclusion
23+
# .. contents::
24+
# :local:
2825
#
2926
# **Required pip Dependencies**
3027
#
@@ -485,19 +482,12 @@ def bar(a, b):
485482
print(opt_model(generate_data(16)[0]))
486483

487484
######################################################################
488-
# <!----TODO: replace this section with a link to the torch.export tutorial when done --->
489-
#
490-
# Finally, if we simply want TorchDynamo to output the FX graph for export,
491-
# we can use ``torch._dynamo.export``. Note that ``torch._dynamo.export``, like
492-
# ``fullgraph=True``, raises an error if TorchDynamo breaks the graph.
493-
494-
try:
495-
torch._dynamo.export(bar)(torch.randn(10), torch.randn(10))
496-
except:
497-
tb.print_exc()
498-
499-
model_exp = torch._dynamo.export(init_model())(generate_data(16)[0])
500-
print(model_exp[0](generate_data(16)[0]))
485+
# We can use ``torch.export`` (from PyTorch 2.1+) to extract a single, exportable
486+
# FX graph from the input PyTorch program. The exported graph is intended to be
487+
# run on different (i.e. Python-less) environments. One important restriction
488+
# is that the ``torch.export`` does not support graph breaks. Please check
489+
# `this tutorial <https://pytorch.org/tutorials/intermediate/torch_export_tutorial.html>`__
490+
# for more details on ``torch.export``.
501491

502492
######################################################################
503493
# Conclusion

intermediate_source/torch_export_tutorial.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def constraints_example4(x, y):
423423
exported_constraints_example4 = export(constraints_example4, (torch.randn(3, 3), torch.tensor([4])))
424424
print(exported_constraints_example4(torch.randn(3, 3), torch.tensor([5])))
425425
try:
426-
exported_constraints_example4(torch.randn(3, 3), torch.randn([2]))
426+
exported_constraints_example4(torch.randn(3, 3), torch.tensor([2]))
427427
except Exception:
428428
tb.print_exc()
429429

@@ -441,7 +441,7 @@ def constraints_example5(x, y):
441441
exported_constraints_example5 = export(constraints_example5, (torch.randn(2, 2), torch.tensor([4])))
442442
print(exported_constraints_example5(torch.randn(2, 2), torch.tensor([5])))
443443
try:
444-
exported_constraints_example5(torch.randn(2, 2), torch.randn([1]))
444+
exported_constraints_example5(torch.randn(2, 2), torch.tensor([1]))
445445
except Exception:
446446
tb.print_exc()
447447

@@ -496,6 +496,10 @@ def custom_op_example(x):
496496
# Note in the above outputs that the custom op is included in the exported graph.
497497
# And when we call the exported graph as a function, the original custom op is called,
498498
# as evidenced by the ``print`` call.
499+
#
500+
# If you have a custom operator implemented in C++, please refer to
501+
# `this document <https://docs.google.com/document/d/1_W62p8WJOQQUzPsJYa7s701JXt0qf2OfLub2sbkHOaU/edit#heading=h.ahugy69p2jmz>`__
502+
# to make it compatible with ``torch.export``.
499503

500504
######################################################################
501505
# ExportDB

0 commit comments

Comments
 (0)