Skip to content

Commit 5e39c37

Browse files
authored
Document changes between versions in docstrings (#105)
With sphinx versionchanged and versionadded directives --------- Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
1 parent b2ad020 commit 5e39c37

File tree

6 files changed

+41
-3
lines changed

6 files changed

+41
-3
lines changed

src/onnx_ir/_convenience/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ def create_value_mapping(graph: _core.Graph) -> dict[str, _core.Value]:
323323
and the first value with that name is returned. Values with empty names
324324
are excluded from the mapping.
325325
326+
.. versionchanged:: 0.1.2
327+
Values from subgraphs are now included in the mapping.
328+
326329
Args:
327330
graph: The graph to extract the mapping from.
328331
@@ -410,6 +413,8 @@ def get_const_tensor(
410413
it will propagate the shape and type of the constant tensor to the value
411414
if `propagate_shape_type` is set to True.
412415
416+
.. versionadded:: 0.1.2
417+
413418
Args:
414419
value: The value to get the constant tensor from.
415420
propagate_shape_type: If True, the shape and type of the value will be

src/onnx_ir/_core.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,10 @@ def tobytes(self) -> bytes:
964964

965965

966966
class PackedTensor(TensorBase, _protocols.TensorProtocol, Generic[TArrayCompatible]): # pylint: disable=too-many-ancestors
967-
"""A tensor that stores 4bit datatypes in packed format."""
967+
"""A tensor that stores 4bit datatypes in packed format.
968+
969+
.. versionadded:: 0.1.2
970+
"""
968971

969972
__slots__ = (
970973
"_dtype",
@@ -2335,6 +2338,12 @@ class Graph(_protocols.GraphProtocol, Sequence[Node], _display.PrettyPrintable):
23352338
seen as a Sequence of nodes and should be used as such. For example, to obtain
23362339
all nodes as a list, call ``list(graph)``.
23372340
2341+
.. versionchanged:: 0.1.1
2342+
Values with non-none producers will be rejected as graph inputs or initializers.
2343+
2344+
.. versionadded:: 0.1.1
2345+
Added ``add`` method to initializers and attributes.
2346+
23382347
Attributes:
23392348
name: The name of the graph.
23402349
inputs: The input values of the graph.
@@ -2545,12 +2554,17 @@ def all_nodes(self) -> Iterator[Node]:
25452554
Consider using
25462555
:class:`onnx_ir.traversal.RecursiveGraphIterator` for more advanced
25472556
traversals on nodes.
2557+
2558+
.. versionadded:: 0.1.2
25482559
"""
25492560
# NOTE: This is a method specific to Graph, not required by the protocol unless proven
25502561
return onnx_ir.traversal.RecursiveGraphIterator(self)
25512562

25522563
def subgraphs(self) -> Iterator[Graph]:
2553-
"""Get all subgraphs in the graph in O(#nodes + #attributes) time."""
2564+
"""Get all subgraphs in the graph in O(#nodes + #attributes) time.
2565+
2566+
.. versionadded:: 0.1.2
2567+
"""
25542568
seen_graphs: set[Graph] = set()
25552569
for node in onnx_ir.traversal.RecursiveGraphIterator(self):
25562570
graph = node.graph
@@ -3216,12 +3230,17 @@ def all_nodes(self) -> Iterator[Node]:
32163230
Consider using
32173231
:class:`onnx_ir.traversal.RecursiveGraphIterator` for more advanced
32183232
traversals on nodes.
3233+
3234+
.. versionadded:: 0.1.2
32193235
"""
32203236
# NOTE: This is a method specific to Graph, not required by the protocol unless proven
32213237
return onnx_ir.traversal.RecursiveGraphIterator(self)
32223238

32233239
def subgraphs(self) -> Iterator[Graph]:
3224-
"""Get all subgraphs in the function in O(#nodes + #attributes) time."""
3240+
"""Get all subgraphs in the function in O(#nodes + #attributes) time.
3241+
3242+
.. versionadded:: 0.1.2
3243+
"""
32253244
seen_graphs: set[Graph] = set()
32263245
for node in onnx_ir.traversal.RecursiveGraphIterator(self):
32273246
graph = node.graph

src/onnx_ir/_enums.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ def itemsize(self) -> float:
120120
def bitwidth(self) -> int:
121121
"""Returns the bit width of the data type.
122122
123+
.. versionadded:: 0.1.2
124+
123125
Raises:
124126
TypeError: If the data type is not supported.
125127
"""

src/onnx_ir/passes/common/common_subexpression_elimination.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
class CommonSubexpressionEliminationPass(ir.passes.InPlacePass):
2020
"""Eliminate common subexpression in ONNX graphs.
2121
22+
.. versionadded:: 0.1.1
23+
24+
.. versionchanged:: 0.1.3
25+
Constant nodes with values smaller than ``size_limit`` will be CSE'd.
26+
2227
Attributes:
2328
size_limit: The maximum size of the tensor to be csed. If the tensor contains
2429
number of elements larger than size_limit, it will not be cse'd. Default is 10.

src/onnx_ir/passes/common/initializer_deduplication.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class DeduplicateInitializersPass(ir.passes.InPlacePass):
2020
2121
To deduplicate initializers from subgraphs, use :class:`~onnx_ir.passes.common.LiftSubgraphInitializersToMainGraphPass`
2222
to lift the initializers to the main graph first before running pass.
23+
24+
.. versionadded:: 0.1.3
2325
"""
2426

2527
def __init__(self, size_limit: int = 1024):

src/onnx_ir/serde.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ def from_onnx_text(
200200
201201
Read more about the textual representation at: https://onnx.ai/onnx/repo-docs/Syntax.html
202202
203+
.. versionchanged:: 0.1.2
204+
Added the ``initializers`` argument.
205+
203206
Args:
204207
model_text: The ONNX textual representation of the model.
205208
initializers: Tensors to be added as initializers. If provided, these tensors
@@ -237,6 +240,8 @@ def to_onnx_text(
237240
) -> str:
238241
"""Convert the IR model to the ONNX textual representation.
239242
243+
.. versionadded:: 0.1.2
244+
240245
Args:
241246
model: The IR model to convert.
242247
exclude_initializers: If True, the initializers will not be included in the output.

0 commit comments

Comments
 (0)