Skip to content

Commit 0ac791f

Browse files
narendasangs-olive
authored andcommitted
refactor: Fixing the CSS for the gallery and reorging the examples to
render properly Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent c64566a commit 0ac791f

16 files changed

+175
-18
lines changed

Diff for: docsrc/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ endif
3535
rm -rf $(SOURCEDIR)/_py_api
3636
rm -rf $(SOURCEDIR)/_build
3737
rm -rf $(SOURCEDIR)/_tmp
38+
rm -rf $(SOURCEDIR)/tutorials/_rendered_examples
3839

3940
html:
4041
# mkdir -p $(SOURCEDIR)/_notebooks

Diff for: docsrc/_static/css/custom.css

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* sphinx-design styles for cards/tabs
2+
*/
3+
4+
.sphx-glr-thumbcontainer {
5+
padding: 100px;
6+
display: flex;
7+
align-content: center;
8+
}

Diff for: docsrc/_static/css/pytorch_theme.css

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
body {
2+
font-family: "Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;
3+
}
4+
5+
/* Default header fonts are ugly */
6+
h1, h2, .rst-content .toctree-wrapper p.caption, h3, h4, h5, h6, legend, p.caption {
7+
font-family: "Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;
8+
}
9+
10+
/* Use white for docs background */
11+
.wy-side-nav-search {
12+
background-color: #fff;
13+
}
14+
15+
.wy-nav-content-wrap, .wy-menu li.current > a {
16+
background-color: #fff;
17+
}
18+
19+
@media screen and (min-width: 1400px) {
20+
.wy-nav-content-wrap {
21+
background-color: rgba(0, 0, 0, 0.0470588);
22+
}
23+
24+
.wy-nav-content {
25+
background-color: #fff;
26+
}
27+
}
28+
29+
/* Fixes for mobile */
30+
.wy-nav-top {
31+
background-color: #fff;
32+
background-image: url('../img/pytorch-logo-dark.svg');
33+
background-repeat: no-repeat;
34+
background-position: center;
35+
padding: 0;
36+
margin: 0.4045em 0.809em;
37+
color: #333;
38+
}
39+
40+
.wy-nav-top > a {
41+
display: none;
42+
}
43+
44+
@media screen and (max-width: 768px) {
45+
.wy-side-nav-search>a img.logo {
46+
height: 60px;
47+
}
48+
}
49+
50+
/* This is needed to ensure that logo above search scales properly */
51+
.wy-side-nav-search a {
52+
display: block;
53+
}
54+
55+
/* This ensures that multiple constructors will remain in separate lines. */
56+
.rst-content dl:not(.docutils) dt {
57+
display: table;
58+
}
59+
60+
/* Use our red for literals (it's very similar to the original color) */
61+
.rst-content tt.literal, .rst-content tt.literal, .rst-content code.literal {
62+
color: #F05732;
63+
}
64+
65+
.rst-content tt.xref, a .rst-content tt, .rst-content tt.xref,
66+
.rst-content code.xref, a .rst-content tt, a .rst-content code {
67+
color: #404040;
68+
}
69+
70+
/* Change link colors (except for the menu) */
71+
72+
a {
73+
color: #F05732;
74+
}
75+
76+
a:hover {
77+
color: #F05732;
78+
}
79+
80+
81+
a:visited {
82+
color: #D44D2C;
83+
}
84+
85+
.wy-menu a {
86+
color: #b3b3b3;
87+
}
88+
89+
.wy-menu a:hover {
90+
color: #b3b3b3;
91+
}
92+
93+
a.icon.icon-home {
94+
color: #D44D2C;
95+
}
96+
97+
.version{
98+
color: #D44D2C !important;
99+
}
100+
101+
/* Default footer text is quite big */
102+
footer {
103+
font-size: 80%;
104+
}
105+
106+
footer .rst-footer-buttons {
107+
font-size: 125%; /* revert footer settings - 1/80% = 125% */
108+
}
109+
110+
footer p {
111+
font-size: 100%;
112+
}
113+
114+
/* For hidden headers that appear in TOC tree */
115+
/* see https://stackoverflow.com/a/32363545/3343043 */
116+
.rst-content .hidden-section {
117+
display: none;
118+
}
119+
120+
nav .hidden-section {
121+
display: inherit;
122+
}
123+
124+
/* Make code blocks have a background */
125+
.codeblock,pre.literal-block,.rst-content .literal-block,.rst-content pre.literal-block,div[class^='highlight'] {
126+
background: rgba(0, 0, 0, 0.0470588);
127+
}

Diff for: docsrc/conf.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
import torch
1919
import pytorch_sphinx_theme
2020
import torch_tensorrt
21+
from docutils.parsers.rst import Directive, directives
22+
from docutils.statemachine import StringList
23+
from docutils import nodes
2124

2225
# -- Project information -----------------------------------------------------
2326

@@ -79,10 +82,16 @@
7982
# relative to this directory. They are copied after the builtin static files,
8083
# so a file named "default.css" will overwrite the builtin "default.css".
8184
html_static_path = ["_static"]
85+
# Custom CSS paths should either relative to html_static_path
86+
# or fully qualified paths (eg. https://...)
87+
html_css_files = [
88+
"https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css",
89+
"css/custom.css",
90+
]
8291

8392
# sphinx-gallery configuration
8493
sphinx_gallery_conf = {
85-
"examples_dirs": "../examples/dynamo",
94+
"examples_dirs": "../examples",
8695
"gallery_dirs": "tutorials/_rendered_examples/",
8796
}
8897

Diff for: docsrc/index.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ User Guide
5959

6060
Tutorials
6161
------------
62+
* :ref:`torch_tensorrt_tutorials`
6263
* :ref:`serving_torch_tensorrt_with_triton`
6364
* :ref:`notebooks`
64-
* :ref:`dynamo_compile`
6565

6666
.. toctree::
6767
:caption: Tutorials
@@ -70,9 +70,9 @@ Tutorials
7070

7171
tutorials/serving_torch_tensorrt_with_triton
7272
tutorials/notebooks
73-
tutorials/_rendered_examples/dynamo_compile_resnet_example
74-
tutorials/_rendered_examples/dynamo_compile_transformers_example
75-
tutorials/_rendered_examples/dynamo_compile_advanced_usage
73+
tutorials/_rendered_examples/dynamo/dynamo_compile_resnet_example
74+
tutorials/_rendered_examples/dynamo/dynamo_compile_transformers_example
75+
tutorials/_rendered_examples/dynamo/dynamo_compile_advanced_usage
7676

7777
Python API Documenation
7878
------------------------
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: examples/README.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. _torch_tensorrt_tutorials:
2+
3+
Torch-TensorRT Tutorials
4+
===========================
5+
6+
The user guide covers the basic concepts and usage of Torch-TensorRT.
7+
We also provide a number of tutorials to explore specific usecases and advanced concepts

Diff for: examples/dynamo/README.rst

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
.. _dynamo_compile:
22

3-
Dynamo Compile Examples
4-
================
3+
Dynamo / ``torch.compile``
4+
----------------------------
55

6-
This document contains examples of usage of the `torch_tensorrt.dynamo.compile` API which integrates with `torch.compile` functionality
6+
Torch-TensorRT provides a backend for the new ``torch.compile`` API released in PyTorch 2.0. In the following examples we describe
7+
a number of ways you can leverage this backend to accelerate inference.
78

8-
Overview of Available Scripts
9-
-----------------------------------------------
10-
- `dynamo_compile_resnet_example.py <./dynamo_compile_resnet_example.html>`_: Example showcasing compilation of ResNet model
11-
- `dynamo_compile_transformers_example.py <./dynamo_compile_transformers_example.html>`_: Example showcasing compilation of transformer-based model
12-
- `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
9+
* :ref:`dynamo_compile_resnet`: Compiling a ResNet model using the Dyanmo Compile Frontend for ``torch_tensorrt.compile``
10+
* :ref:`torch_compile_transformer`: Compiling a Transformer model using ``torch.compile``
11+
* :ref:`dynamo_compile_advanced_usage`: Advanced usage including making a custom backend to use directly with the ``torch.compile`` API

Diff for: examples/dynamo/dynamo_compile_advanced_usage.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
2+
.. _dynamo_compile_advanced_usage:
3+
24
Dynamo Compile Advanced Usage
3-
=========================
5+
======================================================
46
57
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."""
68

Diff for: examples/dynamo/dynamo_compile_resnet_example.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
2-
Dynamo Compile ResNet Example
3-
=========================
2+
.. _dynamo_compile_resnet:
3+
4+
Compiling ResNet using the Torch-TensorRT Dyanmo Frontend
5+
==========================================================
46
57
This interactive script is intended as a sample of the `torch_tensorrt.compile` workflow with `torch.compile` on a ResNet model."""
68

Diff for: examples/dynamo/dynamo_compile_transformers_example.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
2-
Dynamo Compile Transformers Example
3-
=========================
2+
.. _torch_compile_transformer:
3+
4+
Compiling a Transformer using torch.compile and TensorRT
5+
==============================================================
46
57
This interactive script is intended as a sample of the `torch_tensorrt.compile` workflow with `torch.compile` on a transformer-based model."""
68

0 commit comments

Comments
 (0)