Skip to content

Commit 1f10b30

Browse files
Enables reference checking during doc generation
Adds `-n` to `sphinx-build` which enables checks for cross-document references. This will allow us to ensure that links that point to other parts of the docs are always valid.
1 parent 96b804b commit 1f10b30

File tree

11 files changed

+41
-33
lines changed

11 files changed

+41
-33
lines changed

.github/workflows/tripy-l0.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
options: --gpus all -v ${{ github.workspace }}/tripy:/tripy
6262
run: |
6363
python3 docs/generate_rsts.py
64-
sphinx-build build/doc_sources build/docs -c docs/ -j 4 -W
64+
sphinx-build build/doc_sources build/docs -c docs/ -j 4 -W -n
6565
6666
- name: run-test
6767
uses: addnab/docker-run-action@v3

.github/workflows/tripy-l1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
run: |
4141
cd /tripy/
4242
python3 docs/generate_rsts.py
43-
sphinx-build build/doc_sources build/docs -c docs/ -j 4 -W
43+
sphinx-build build/doc_sources build/docs -c docs/ -j 4 -W -n
4444
cp docs/packages.html build/docs/
4545
4646
- uses: actions/upload-pages-artifact@v3

tripy/docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This directory includes all the source files for the public API documentation.
77
You can build the documentation locally in the development container by running:
88
```bash
99
python3 docs/generate_rsts.py
10-
sphinx-build build/doc_sources build/docs -c docs/ -j 4 -W
10+
sphinx-build build/doc_sources build/docs -c docs/ -j 4 -W -n
1111
```
1212
To view the documentation, you can open `build/docs/index.html` in a browser.
1313

tripy/docs/conf.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@
5151
autodoc_typehints_format = "short"
5252
python_use_unqualified_type_names = True
5353

54+
nitpick_ignore = {
55+
("py:class", "tripy.types.ShapeLike"),
56+
("py:class", "tripy.types.TensorLike"),
57+
("py:class", "tripy.types.NestedNumberSequence"),
58+
("py:class", "Tensor"),
59+
("py:class", "Shape"),
60+
}
61+
nitpick_ignore_regex = {
62+
("py:class", r"numbers\.Number"),
63+
("py:class", r"collections\..*"),
64+
}
65+
5466
autodoc_default_options = {
5567
"members": True,
5668
"no-undoc-members": True,
File renamed without changes.

tripy/tripy/backend/api/executable.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ def add(a, b):
162162
)
163163
raise
164164

165-
from tripy.utils.stack_info import StackInfo
166-
167-
output_tensors = [Tensor(output, stack_info=StackInfo([])) for output in executor_outputs]
165+
output_tensors = [Tensor(output, fetch_stack_info=False) for output in executor_outputs]
168166
if len(output_tensors) == 1:
169167
output_tensors = output_tensors[0]
170168
return output_tensors

tripy/tripy/frontend/module/convolution.py renamed to tripy/tripy/frontend/module/conv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(
8383
self.dtype = dtype
8484

8585

86-
@export.public_api(document_under="operations/modules")
86+
@export.public_api(document_under="operations/modules", autodoc_options=[":no-show-inheritance:"])
8787
@dataclass
8888
class Conv(ConvBase):
8989
r"""

tripy/tripy/frontend/module/conv_transpose.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
from tripy import export
2323
from tripy.common import datatype
24-
from tripy.frontend.module.convolution import ConvBase
24+
from tripy.frontend.module.conv import ConvBase
2525
from tripy.frontend.module.parameter import DefaultParameter, Parameter
2626

2727

28-
@export.public_api(document_under="operations/modules")
28+
@export.public_api(document_under="operations/modules", autodoc_options=[":no-show-inheritance:"])
2929
@dataclass
3030
class ConvTranspose(ConvBase):
3131
r"""

tripy/tripy/frontend/shape.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# limitations under the License.
1616
#
1717

18-
from typing import Optional, Sequence, Union
18+
from typing import Any, Optional, Sequence, Union
1919

2020
from tripy import export, utils
2121
from tripy.common.datatype import int32
@@ -41,7 +41,7 @@ class Shape(Tensor):
4141

4242
def __init__(
4343
self,
44-
data: Union[Sequence, Tensor, "np.ndarray", "cp.ndarray", "torch.Tensor", "jnp.ndarray"],
44+
data: Any,
4545
name: Optional[str] = None,
4646
) -> None:
4747
r"""
@@ -297,7 +297,7 @@ class ShapeScalar(Tensor):
297297

298298
def __init__(
299299
self,
300-
data: Union[Sequence, Tensor, "np.ndarray", "cp.ndarray", "torch.Tensor", "jnp.ndarray"],
300+
data: Any,
301301
name: Optional[str] = None,
302302
) -> None:
303303
r"""

tripy/tripy/frontend/tensor.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#
1717

1818
from textwrap import indent
19-
from typing import Any, List, Optional, Sequence, Union
19+
from typing import Any, Optional
20+
21+
import mlir_tensorrt.runtime.api as runtime
2022

2123
# Import ops to populate the registry before we define our Tensor class
2224
import tripy.frontend.ops
@@ -27,8 +29,7 @@
2729
from tripy.common.exception import raise_error
2830
from tripy.frontend.ops.registry import TENSOR_METHOD_REGISTRY
2931
from tripy.frontend.trace.ops import Storage
30-
31-
import mlir_tensorrt.runtime.api as runtime
32+
from tripy.utils.stack_info import StackInfo
3233

3334

3435
class TensorMeta(type):
@@ -73,19 +74,21 @@ def _get_unique_name(cls):
7374

7475
def __init__(
7576
self,
76-
data: Union[List, "np.ndarray", "cp.ndarray", "torch.Tensor", "jnp.ndarray"],
77+
data: Any,
7778
dtype: Optional["tripy.dtype"] = None,
7879
device: Optional["tripy.device"] = None,
7980
name: Optional[str] = None,
80-
stack_info: Optional["StackInfo"] = None,
81+
fetch_stack_info: bool = True,
8182
) -> None:
8283
"""
8384
Args:
8485
data: The data with which to initialize the tensor.
8586
dtype: The data type of the tensor.
8687
device: The device on which to allocate the tensor.
8788
name: The name of the tensor. If provided, this must be a unique string.
88-
stack_info: The stack infomation of the tensor.
89+
fetch_stack_info: Whether to fetch stack information for the tensor.
90+
Stack information allows Tripy to generate much higher quality error
91+
messages at the cost of a small overhead when initializing the tensor.
8992
9093
.. code-block:: python
9194
:linenos:
@@ -95,13 +98,12 @@ def __init__(
9598
"""
9699
from tripy.frontend.trace.tensor import TraceTensor
97100

98-
# We include code for everything above the `BaseTraceOp.build` function, which is called at most
99-
# this many stack frames above the constructor.
100-
STACK_DEPTH_OF_BUILD = 4
101-
# not using utils.default() because it always evaluates the `default` argument.
102-
stack_info = (
103-
stack_info if stack_info is not None else utils.get_stack_info(include_code_index=STACK_DEPTH_OF_BUILD)
104-
)
101+
stack_info = StackInfo([])
102+
if fetch_stack_info:
103+
# We include code for everything above the `BaseTraceOp.build` function, which is called at most
104+
# this many stack frames above the constructor.
105+
STACK_DEPTH_OF_BUILD = 4
106+
stack_info = utils.get_stack_info(include_code_index=STACK_DEPTH_OF_BUILD)
105107

106108
name = name if name is not None else Tensor._get_unique_name()
107109

0 commit comments

Comments
 (0)