|
20 | 20 | #
|
21 | 21 | # **Contents**
|
22 | 22 | #
|
23 |
| -# - Basic Usage |
24 |
| -# - Demonstrating Speedups |
25 |
| -# - Comparison to TorchScript and FX Tracing |
26 |
| -# - TorchDynamo and FX Graphs |
27 |
| -# - Conclusion |
| 23 | +# .. contents:: |
| 24 | +# :local: |
28 | 25 | #
|
29 | 26 | # **Required pip Dependencies**
|
30 | 27 | #
|
@@ -485,19 +482,12 @@ def bar(a, b):
|
485 | 482 | print(opt_model(generate_data(16)[0]))
|
486 | 483 |
|
487 | 484 | ######################################################################
|
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``. |
501 | 491 |
|
502 | 492 | ######################################################################
|
503 | 493 | # Conclusion
|
|
0 commit comments