diff --git a/.github/workflows/docgen.yml b/.github/workflows/docgen.yml index 56a625acaf..856bf713af 100644 --- a/.github/workflows/docgen.yml +++ b/.github/workflows/docgen.yml @@ -12,7 +12,7 @@ jobs: build-docs: runs-on: ubuntu-18.04 container: - image: ghcr.io/nvidia/torch-tensorrt/docgen:latest + image: docker.pkg.github.com/pytorch/tensorrt/docgen:1.1.0 credentials: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index c794e855d0..4b8ce2d87e 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -33,7 +33,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Run image run: | - docker run -it -d --name cpplinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace ghcr.io/nvidia/torch-tensorrt/docgen:latest + docker run -it -d --name cpplinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace docker.pkg.github.com/pytorch/tensorrt/docgen:1.1.0 docker exec cpplinter bash -c "cp /workspace/docker/WORKSPACE.docker /workspace/WORKSPACE" env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} @@ -70,7 +70,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Run image run: | - docker run -it -d --name pylinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace ghcr.io/nvidia/torch-tensorrt/docgen:latest + docker run -it -d --name pylinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace docker.pkg.github.com/pytorch/tensorrt/docgen:1.1.0 docker exec pylinter bash -c "cp /workspace/docker/WORKSPACE.docker /workspace/WORKSPACE" env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.gitignore b/.gitignore index 05da7d8469..e1150a43c6 100644 --- a/.gitignore +++ b/.gitignore @@ -57,4 +57,7 @@ examples/int8/qat/qat examples/int8/training/vgg16/data/* examples/int8/datasets/data/* env/**/* -bazel-Torch-TensorRT-Preview \ No newline at end of file +bazel-Torch-TensorRT-Preview +docsrc/src/ +bazel-TensorRT +bazel-tensorrt \ No newline at end of file diff --git a/docsrc/conf.py b/docsrc/conf.py index b9d356b173..04ff9ce66e 100644 --- a/docsrc/conf.py +++ b/docsrc/conf.py @@ -15,13 +15,16 @@ sys.path.append(os.path.join(os.path.dirname(__name__), '../py')) -import sphinx_material +import torch +import pytorch_sphinx_theme +import torch_tensorrt # -- Project information ----------------------------------------------------- project = 'Torch-TensorRT' copyright = '2021, NVIDIA Corporation' author = 'NVIDIA Corporation' +version = 'master (' + torch_tensorrt.__version__ + ')' # The full version, including alpha/beta/rc tags release = 'master' @@ -38,8 +41,15 @@ 'sphinx.ext.intersphinx', 'sphinx.ext.autosummary', 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.mathjax', + 'sphinx.ext.viewcode', ] +napoleon_use_ivar = True + autosummary_generate = True # Add any paths that contain templates here, relative to this directory. @@ -50,12 +60,18 @@ # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ['_build', '_tmp', 'Thumbs.db', '.DS_Store'] +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'sphinx_material' +html_theme = 'pytorch_sphinx_theme' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -84,10 +100,10 @@ html_show_sourcelink = True html_sidebars = {"**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"]} -extensions.append("sphinx_material") -html_theme_path = sphinx_material.html_theme_path() -html_context = sphinx_material.get_html_context() -html_theme = "sphinx_material" +#extensions.append("sphinx_material") +html_theme_path = [pytorch_sphinx_theme.get_html_theme_path()] +#html_context = sphinx_material.get_html_context() +html_theme = "pytorch_sphinx_theme" # Material theme options (see theme.conf for more information) html_theme_options = { @@ -138,3 +154,56 @@ # Tell sphinx what the pygments highlight language should be. highlight_language = 'cpp' + +# -- A patch that prevents Sphinx from cross-referencing ivar tags ------- +# See http://stackoverflow.com/a/41184353/3343043 + +from docutils import nodes +from sphinx.util.docfields import TypedField +from sphinx import addnodes + + +def patched_make_field(self, types, domain, items, **kw): + # `kw` catches `env=None` needed for newer sphinx while maintaining + # backwards compatibility when passed along further down! + + # type: (list, unicode, tuple) -> nodes.field + def handle_item(fieldarg, content): + par = nodes.paragraph() + par += addnodes.literal_strong('', fieldarg) # Patch: this line added + # par.extend(self.make_xrefs(self.rolename, domain, fieldarg, + # addnodes.literal_strong)) + if fieldarg in types: + par += nodes.Text(' (') + # NOTE: using .pop() here to prevent a single type node to be + # inserted twice into the doctree, which leads to + # inconsistencies later when references are resolved + fieldtype = types.pop(fieldarg) + if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text): + typename = u''.join(n.astext() for n in fieldtype) + typename = typename.replace('int', 'python:int') + typename = typename.replace('long', 'python:long') + typename = typename.replace('float', 'python:float') + typename = typename.replace('type', 'python:type') + par.extend(self.make_xrefs(self.typerolename, domain, typename, + addnodes.literal_emphasis, **kw)) + else: + par += fieldtype + par += nodes.Text(')') + par += nodes.Text(' -- ') + par += content + return par + + fieldname = nodes.field_name('', self.label) + if len(items) == 1 and self.can_collapse: + fieldarg, content = items[0] + bodynode = handle_item(fieldarg, content) + else: + bodynode = self.list_type() + for fieldarg, content in items: + bodynode += nodes.list_item('', handle_item(fieldarg, content)) + fieldbody = nodes.field_body('', bodynode) + return nodes.field('', fieldname, fieldbody) + + +TypedField.make_field = patched_make_field \ No newline at end of file diff --git a/docsrc/requirements.txt b/docsrc/requirements.txt index 81af08e229..cc331e6907 100644 --- a/docsrc/requirements.txt +++ b/docsrc/requirements.txt @@ -1,6 +1,6 @@ -sphinx==4.3.0 -breathe==4.31.0 -exhale==0.2.3 -sphinx-material==0.0.35 -nbsphinx==0.8.7 +sphinx==4.5.0 +breathe==4.33.1 +exhale==0.3.1 +-e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme +nbsphinx==0.8.8 docutils==0.17.1 \ No newline at end of file diff --git a/py/setup.py b/py/setup.py index 1d98f39644..2810d3f80f 100644 --- a/py/setup.py +++ b/py/setup.py @@ -240,7 +240,10 @@ def run(self): include_dirs=[ dir_path + "torch_tensorrt/csrc", dir_path + "torch_tensorrt/include", dir_path + "/../bazel-TRTorch/external/tensorrt/include", - dir_path + "/../bazel-Torch-TensorRT/external/tensorrt/include", dir_path + "/../" + dir_path + "/../bazel-Torch-TensorRT/external/tensorrt/include", + dir_path + "/../bazel-TensorRT/external/tensorrt/include", + dir_path + "/../bazel-tensorrt/external/tensorrt/include", + dir_path + "/../" ], extra_compile_args=[ "-Wno-deprecated",