Skip to content

Commit

Permalink
[DOCS] Enable theme with header and footer. (#6834)
Browse files Browse the repository at this point in the history
Also fixed a sphinx warning in pytorch.
  • Loading branch information
tqchen authored Nov 3, 2020
1 parent b4db112 commit 4122def
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TVM Documentations
This folder contains the source of TVM documents

- A hosted version of doc is at https://tvm.apache.org/docs
- pip install sphinx>=1.5.5 sphinx-gallery sphinx_rtd_theme matplotlib Image recommonmark "Pillow<7" autodocsumm
- pip install sphinx>=1.5.5 sphinx-gallery sphinx_rtd_theme matplotlib Image recommonmark "Pillow<7" autodocsumm tlcpack-sphinx-addon
- Build tvm first in the root folder.
- Run the following command
```bash
Expand Down
56 changes: 55 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,61 @@
"tvm.relay": ["tvm.ir", "tvm.tir"],
}

## Setup header and other configs
import tlcpack_sphinx_addon

footer_copyright = "© 2020 Apache Software Foundation | All right reserved"
footer_note = " ".join(
"""
Apache TVM is an effort undergoing incubation at The Apache Software Foundation (ASF),
sponsored by the Apache Incubator. Incubation is required of all newly accepted projects
until a further review indicates that the infrastructure, communications, and decision making
process have stabilized in a manner consistent with other successful ASF projects. While
incubation status is not necessarily a reflection of the completeness or stability of the code,
it does indicate that the project has yet to be fully endorsed by the ASF.
Copyright © 2020 The Apache Software Foundation. Apache TVM, Apache, the Apache feather,
and the Apache TVM project logo are either trademarks or registered trademarks of
the Apache Software Foundation.""".split(
"\n"
)
).strip()

header_logo = "https://tvm.apache.org/assets/images/logo.svg"

header_links = [
("Community", "https://tvm.apache.org/community"),
("Download", "https://tvm.apache.org/download"),
("VTA", "https://tvm.apache.org/vta"),
("Blog", "https://tvm.apache.org/blog"),
("Docs", "https://tvm.apache.org/docs"),
("Conference", "https://tvmconf.org"),
("Github", "https://github.com/apache/incubator-tvm/"),
]

header_dropdown = {
"name": "ASF",
"items": [
("Apache Homepage", "https://apache.org/"),
("License", "https://www.apache.org/licenses/"),
("Sponsorship", "https://www.apache.org/foundation/sponsorship.html"),
("Security", "https://www.apache.org/security/"),
("Thanks", "https://www.apache.org/foundation/thanks.html"),
("Events", "https://www.apache.org/events/current-event"),
],
}

html_context = {
"footer_copyright": footer_copyright,
"footer_note": footer_note,
"header_links": header_links,
"header_dropdown": header_dropdown,
"header_logo": header_logo,
}

# add additional overrides
templates_path += [tlcpack_sphinx_addon.get_templates_path()]
html_static_path += [tlcpack_sphinx_addon.get_static_path()]


def update_alias_docstring(name, obj, lines):
"""Update the docstring of alias functions.
Expand Down Expand Up @@ -282,4 +337,3 @@ def process_docstring(app, what, name, obj, options, lines):

def setup(app):
app.connect("autodoc-process-docstring", process_docstring)
app.add_css_file("css/tvm_theme.css")
12 changes: 6 additions & 6 deletions python/tvm/relay/frontend/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3344,17 +3344,17 @@ def from_pytorch(script_module, input_infos, custom_convert_map=None, default_dt
TorchScripted PyTorch graph
Note: We currently only support traces (ie: torch.jit.trace(model, input))
input_infos: List of tuples of (input name, input shape)
or (input name, (input shape, input types))
input_infos : List of tuples
Can be (input name, input shape) or (input name, (input shape, input types))
Graph level input shape and type list
The same input names need to be used for deployment, so choose easy to
remember names (such as: input0, input1)
e.g.
[('input0', (1, 2)), ('input1', (3, 4))]
or
[('input0', ((1, 2), 'int')), ('input1', ((3, 4), 'float'))]
[('input0', (1, 2)), ('input1', (3, 4))]
or
[('input0', ((1, 2), 'int')), ('input1', ((3, 4), 'float'))]
custom_convert_map: Dictionary of str to Relay op
custom_convert_map : Dictionary of str to Relay op
A custom op conversion map in the same format as _convert_map above
Returns
Expand Down
4 changes: 4 additions & 0 deletions tests/scripts/task_python_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ find . -type f -path "*.log" | xargs rm -f
find . -type f -path "*.pyc" | xargs rm -f
make cython3

# install theme addon for to local if does not exists
# avoid docker for now before we stablize on the choice of style
python3 -m pip install --user --upgrade -q tlcpack-sphinx-addon==0.1.0

cd docs
PYTHONPATH=`pwd`/../python make html |& tee /tmp/$$.log.txt
if grep -E "failed to execute|Segmentation fault" < /tmp/$$.log.txt; then
Expand Down
4 changes: 4 additions & 0 deletions tests/scripts/task_sphinx_precheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ rm -rf docs/vta/tutorials
find . -type f -path "*.pyc" | xargs rm -f
make cython3

# install theme addon for to local if does not exists
# avoid docker for now before we stablize on the choice of style
python3 -m pip install --user --upgrade -q tlcpack-sphinx-addon==0.1.0

echo "PreCheck sphinx doc generation WARNINGS.."
cd docs
make clean
Expand Down

0 comments on commit 4122def

Please sign in to comment.