diff --git a/docsrc/Makefile b/docsrc/Makefile index 0ea6796ed8..f30a9ae76e 100644 --- a/docsrc/Makefile +++ b/docsrc/Makefile @@ -35,6 +35,7 @@ endif rm -rf $(SOURCEDIR)/_py_api rm -rf $(SOURCEDIR)/_build rm -rf $(SOURCEDIR)/_tmp + rm -rf $(SOURCEDIR)/tutorials/_rendered_examples html: # mkdir -p $(SOURCEDIR)/_notebooks diff --git a/docsrc/_static/css/custom.css b/docsrc/_static/css/custom.css new file mode 100644 index 0000000000..2523d4e541 --- /dev/null +++ b/docsrc/_static/css/custom.css @@ -0,0 +1,8 @@ +/* sphinx-design styles for cards/tabs +*/ + +.sphx-glr-thumbcontainer { + padding: 50%; + display: flex; + align-content: center; +} \ No newline at end of file diff --git a/docsrc/_static/css/pytorch_theme.css b/docsrc/_static/css/pytorch_theme.css new file mode 100644 index 0000000000..153f4889c0 --- /dev/null +++ b/docsrc/_static/css/pytorch_theme.css @@ -0,0 +1,127 @@ +body { + font-family: "Lato","proxima-nova","Helvetica Neue",Arial,sans-serif; +} + +/* Default header fonts are ugly */ +h1, h2, .rst-content .toctree-wrapper p.caption, h3, h4, h5, h6, legend, p.caption { + font-family: "Lato","proxima-nova","Helvetica Neue",Arial,sans-serif; +} + +/* Use white for docs background */ +.wy-side-nav-search { + background-color: #fff; +} + +.wy-nav-content-wrap, .wy-menu li.current > a { + background-color: #fff; +} + +@media screen and (min-width: 1400px) { + .wy-nav-content-wrap { + background-color: rgba(0, 0, 0, 0.0470588); + } + + .wy-nav-content { + background-color: #fff; + } +} + +/* Fixes for mobile */ +.wy-nav-top { + background-color: #fff; + background-image: url('../img/pytorch-logo-dark.svg'); + background-repeat: no-repeat; + background-position: center; + padding: 0; + margin: 0.4045em 0.809em; + color: #333; +} + +.wy-nav-top > a { + display: none; +} + +@media screen and (max-width: 768px) { + .wy-side-nav-search>a img.logo { + height: 60px; + } +} + +/* This is needed to ensure that logo above search scales properly */ +.wy-side-nav-search a { + display: block; +} + +/* This ensures that multiple constructors will remain in separate lines. */ +.rst-content dl:not(.docutils) dt { + display: table; +} + +/* Use our red for literals (it's very similar to the original color) */ +.rst-content tt.literal, .rst-content tt.literal, .rst-content code.literal { + color: #F05732; +} + +.rst-content tt.xref, a .rst-content tt, .rst-content tt.xref, +.rst-content code.xref, a .rst-content tt, a .rst-content code { + color: #404040; +} + +/* Change link colors (except for the menu) */ + +a { + color: #F05732; +} + +a:hover { + color: #F05732; +} + + +a:visited { + color: #D44D2C; +} + +.wy-menu a { + color: #b3b3b3; +} + +.wy-menu a:hover { + color: #b3b3b3; +} + +a.icon.icon-home { + color: #D44D2C; +} + +.version{ + color: #D44D2C !important; +} + +/* Default footer text is quite big */ +footer { + font-size: 80%; +} + +footer .rst-footer-buttons { + font-size: 125%; /* revert footer settings - 1/80% = 125% */ +} + +footer p { + font-size: 100%; +} + +/* For hidden headers that appear in TOC tree */ +/* see https://stackoverflow.com/a/32363545/3343043 */ +.rst-content .hidden-section { + display: none; +} + +nav .hidden-section { + display: inherit; +} + +/* Make code blocks have a background */ +.codeblock,pre.literal-block,.rst-content .literal-block,.rst-content pre.literal-block,div[class^='highlight'] { + background: rgba(0, 0, 0, 0.0470588); +} diff --git a/docsrc/conf.py b/docsrc/conf.py index cbe068d7ea..0fd4acc2e0 100644 --- a/docsrc/conf.py +++ b/docsrc/conf.py @@ -18,6 +18,9 @@ import torch import pytorch_sphinx_theme import torch_tensorrt +from docutils.parsers.rst import Directive, directives +from docutils.statemachine import StringList +from docutils import nodes # -- Project information ----------------------------------------------------- @@ -79,10 +82,16 @@ # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] +# Custom CSS paths should either relative to html_static_path +# or fully qualified paths (eg. https://...) +html_css_files = [ + "https://cdn.jsdelivr.net/npm/katex@0.10.0-beta/dist/katex.min.css", + "css/custom.css", +] # sphinx-gallery configuration sphinx_gallery_conf = { - "examples_dirs": "../examples/dynamo", + "examples_dirs": "../examples", "gallery_dirs": "tutorials/_rendered_examples/", } diff --git a/docsrc/index.rst b/docsrc/index.rst index e12c9e6f83..ace492c84f 100644 --- a/docsrc/index.rst +++ b/docsrc/index.rst @@ -59,9 +59,9 @@ User Guide Tutorials ------------ +* :ref:`torch_tensorrt_tutorials` * :ref:`serving_torch_tensorrt_with_triton` * :ref:`notebooks` -* :ref:`dynamo_compile` .. toctree:: :caption: Tutorials @@ -70,9 +70,9 @@ Tutorials tutorials/serving_torch_tensorrt_with_triton tutorials/notebooks - tutorials/_rendered_examples/dynamo_compile_resnet_example - tutorials/_rendered_examples/dynamo_compile_transformers_example - tutorials/_rendered_examples/dynamo_compile_advanced_usage + tutorials/_rendered_examples/dynamo/dynamo_compile_resnet_example + tutorials/_rendered_examples/dynamo/dynamo_compile_transformers_example + tutorials/_rendered_examples/dynamo/dynamo_compile_advanced_usage Python API Documenation ------------------------ diff --git a/docsrc/tutorials/creating_torchscript_module_in_python.rst b/docsrc/user_guide/creating_torchscript_module_in_python.rst similarity index 100% rename from docsrc/tutorials/creating_torchscript_module_in_python.rst rename to docsrc/user_guide/creating_torchscript_module_in_python.rst diff --git a/docsrc/tutorials/getting_started_with_fx_path.rst b/docsrc/user_guide/getting_started_with_fx_path.rst similarity index 100% rename from docsrc/tutorials/getting_started_with_fx_path.rst rename to docsrc/user_guide/getting_started_with_fx_path.rst diff --git a/docsrc/tutorials/ptq.rst b/docsrc/user_guide/ptq.rst similarity index 100% rename from docsrc/tutorials/ptq.rst rename to docsrc/user_guide/ptq.rst diff --git a/docsrc/tutorials/runtime.rst b/docsrc/user_guide/runtime.rst similarity index 100% rename from docsrc/tutorials/runtime.rst rename to docsrc/user_guide/runtime.rst diff --git a/docsrc/tutorials/use_from_pytorch.rst b/docsrc/user_guide/use_from_pytorch.rst similarity index 100% rename from docsrc/tutorials/use_from_pytorch.rst rename to docsrc/user_guide/use_from_pytorch.rst diff --git a/docsrc/tutorials/using_dla.rst b/docsrc/user_guide/using_dla.rst similarity index 100% rename from docsrc/tutorials/using_dla.rst rename to docsrc/user_guide/using_dla.rst diff --git a/examples/README.rst b/examples/README.rst new file mode 100644 index 0000000000..7c21aad732 --- /dev/null +++ b/examples/README.rst @@ -0,0 +1,7 @@ +.. _torch_tensorrt_tutorials: + +Torch-TensorRT Tutorials +=========================== + +The user guide covers the basic concepts and usage of Torch-TensorRT. +We also provide a number of tutorials to explore specific usecases and advanced concepts diff --git a/examples/dynamo/README.rst b/examples/dynamo/README.rst index 7d407f73d0..d3b6f9ddcf 100644 --- a/examples/dynamo/README.rst +++ b/examples/dynamo/README.rst @@ -1,12 +1,11 @@ .. _dynamo_compile: -Dynamo Compile Examples -================ +Dynamo / ``torch.compile`` +---------------------------- -This document contains examples of usage of the `torch_tensorrt.dynamo.compile` API which integrates with `torch.compile` functionality +Torch-TensorRT provides a backend for the new ``torch.compile`` API released in PyTorch 2.0. In the following examples we describe +a number of ways you can leverage this backend to accelerate inference. -Overview of Available Scripts ------------------------------------------------ -- `dynamo_compile_resnet_example.py <./dynamo_compile_resnet_example.html>`_: Example showcasing compilation of ResNet model -- `dynamo_compile_transformers_example.py <./dynamo_compile_transformers_example.html>`_: Example showcasing compilation of transformer-based model -- `dynamo_compile_advanced_usage.py <./dynamo_compile_advanced_usage.html>`_: Advanced usage including making a custom backend to use directly with the `torch.compile` API +* :ref:`dynamo_compile_resnet`: Compiling a ResNet model using the Dynamo Compile Frontend for ``torch_tensorrt.compile`` +* :ref:`torch_compile_transformer`: Compiling a Transformer model using ``torch.compile`` +* :ref:`dynamo_compile_advanced_usage`: Advanced usage including making a custom backend to use directly with the ``torch.compile`` API diff --git a/examples/dynamo/dynamo_compile_advanced_usage.py b/examples/dynamo/dynamo_compile_advanced_usage.py index d0484aeaf0..dec7e3a544 100644 --- a/examples/dynamo/dynamo_compile_advanced_usage.py +++ b/examples/dynamo/dynamo_compile_advanced_usage.py @@ -1,6 +1,8 @@ """ +.. _dynamo_compile_advanced_usage: + Dynamo Compile Advanced Usage -========================= +====================================================== This interactive script is intended as an overview of the process by which `torch_tensorrt.dynamo.compile` works, and how it integrates with the new `torch.compile` API.""" diff --git a/examples/dynamo/dynamo_compile_resnet_example.py b/examples/dynamo/dynamo_compile_resnet_example.py index 2c0441bf1d..51bd7fe78e 100644 --- a/examples/dynamo/dynamo_compile_resnet_example.py +++ b/examples/dynamo/dynamo_compile_resnet_example.py @@ -1,6 +1,8 @@ """ -Dynamo Compile ResNet Example -========================= +.. _dynamo_compile_resnet: + +Compiling ResNet using the Torch-TensorRT Dyanmo Frontend +========================================================== This interactive script is intended as a sample of the `torch_tensorrt.compile` workflow with `torch.compile` on a ResNet model.""" diff --git a/examples/dynamo/dynamo_compile_transformers_example.py b/examples/dynamo/dynamo_compile_transformers_example.py index 4420e771d2..b43e022ae0 100644 --- a/examples/dynamo/dynamo_compile_transformers_example.py +++ b/examples/dynamo/dynamo_compile_transformers_example.py @@ -1,6 +1,8 @@ """ -Dynamo Compile Transformers Example -========================= +.. _torch_compile_transformer: + +Compiling a Transformer using torch.compile and TensorRT +============================================================== This interactive script is intended as a sample of the `torch_tensorrt.compile` workflow with `torch.compile` on a transformer-based model."""