Skip to content

Commit 84beca1

Browse files
committed
Docs
Signed-off-by: Justin Chu <[email protected]>
1 parent 3856f1d commit 84beca1

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/onnx_ir/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
# Convenience constructors
7979
"tensor",
8080
"node",
81-
"value",
81+
"val",
8282
# Pass infrastructure
8383
"passes",
8484
# IO
@@ -91,7 +91,7 @@
9191
import types
9292

9393
from onnx_ir import convenience, external_data, passes, serde, tape, traversal
94-
from onnx_ir._convenience._constructors import node, tensor, value
94+
from onnx_ir._convenience._constructors import node, tensor, val
9595
from onnx_ir._core import (
9696
Attr,
9797
AttrFloat32,

src/onnx_ir/_convenience/_constructors.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,27 +217,35 @@ def node(
217217
)
218218

219219

220-
def value(
220+
def val(
221221
name: str,
222222
dtype: ir.DataType | None = None,
223223
shape: ir.Shape | Sequence[int | str | None] | None = None,
224224
*,
225225
type: ir.TypeProtocol | None = None,
226226
const_value: ir.TensorProtocol | None = None,
227227
) -> ir.Value:
228-
"""Create a Value with the given name and type.
228+
"""Create a :class:`~onnx_ir.Value` with the given name and type.
229+
230+
This is a convenience constructor for creating a Value that allows you to specify
231+
dtype and shape in a more relaxed manner. Whereas to create a Value directly, you
232+
need to create a :class:`~onnx_ir.TypeProtocol` and :class:`~onnx_ir.Shape` object
233+
first, this function allows you to specify dtype as a :class:`~onnx_ir.DataType`
234+
and shape as a sequence of integers or symbolic dimensions.
229235
230236
Example::
231237
232238
>>> import onnx_ir as ir
233-
>>> t = ir.value("x", ir.DataType.FLOAT, ["N", 42, 3])
239+
>>> t = ir.val("x", ir.DataType.FLOAT, ["N", 42, 3])
234240
>>> t.name
235241
'x'
236242
>>> t.type
237243
Tensor(FLOAT)
238244
>>> t.shape
239245
Shape([SymbolicDim(N), 42, 3])
240246
247+
.. versionadded:: 0.1.9
248+
241249
Args:
242250
name: The name of the value.
243251
dtype: The data type of the TensorType of the value. This is used only when type is None.

0 commit comments

Comments
 (0)