Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorg docs and fix css for sphix-gallery examples #1967

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docsrc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions docsrc/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* sphinx-design styles for cards/tabs
*/

.sphx-glr-thumbcontainer {
padding: 50%;
display: flex;
align-content: center;
}
127 changes: 127 additions & 0 deletions docsrc/_static/css/pytorch_theme.css
Original file line number Diff line number Diff line change
@@ -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);
}
11 changes: 10 additions & 1 deletion docsrc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 -----------------------------------------------------

Expand Down Expand Up @@ -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/",
}

Expand Down
8 changes: 4 additions & 4 deletions docsrc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
------------------------
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions examples/README.rst
Original file line number Diff line number Diff line change
@@ -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
15 changes: 7 additions & 8 deletions examples/dynamo/README.rst
Original file line number Diff line number Diff line change
@@ -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``
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs rename, Dynamo Compile now means something else in the torch_tensorrt context

* :ref:`torch_compile_transformer`: Compiling a Transformer model using ``torch.compile``
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the transformers script is nearly the same as the Resnet script, except for the model, this could instead be:

Compiling a Transformer model using the Dynamo Compile Frontend for torch.compile

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id like for the Transformer script to use the torch.compile interface

* :ref:`dynamo_compile_advanced_usage`: Advanced usage including making a custom backend to use directly with the ``torch.compile`` API
4 changes: 3 additions & 1 deletion examples/dynamo/dynamo_compile_advanced_usage.py
Original file line number Diff line number Diff line change
@@ -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."""

Expand Down
6 changes: 4 additions & 2 deletions examples/dynamo/dynamo_compile_resnet_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Dynamo Compile ResNet Example
=========================
.. _dynamo_compile_resnet:

Compiling ResNet using the Torch-TensorRT Dyanmo Frontend
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in examples/dynamo/README.rst

==========================================================

This interactive script is intended as a sample of the `torch_tensorrt.compile` workflow with `torch.compile` on a ResNet model."""

Expand Down
6 changes: 4 additions & 2 deletions examples/dynamo/dynamo_compile_transformers_example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Dynamo Compile Transformers Example
=========================
.. _torch_compile_transformer:

Compiling a Transformer using torch.compile and TensorRT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in examples/dynamo/README.rst

==============================================================

This interactive script is intended as a sample of the `torch_tensorrt.compile` workflow with `torch.compile` on a transformer-based model."""

Expand Down