nodeΒΆ

onnx_ir.node(op_type, inputs, attributes=None, *, domain='', overload='', num_outputs=None, outputs=None, version=None, graph=None, name=None, doc_string=None, metadata_props=None)ΒΆ

Create an Node.

This is a convenience constructor for creating a Node that supports Python objects as attributes.

Example:

>>> import onnx_ir as ir
>>> input_a = ir.Input("A", shape=ir.Shape([1, 2]), type=ir.TensorType(ir.DataType.INT32))
>>> input_b = ir.Input("B", shape=ir.Shape([1, 2]), type=ir.TensorType(ir.DataType.INT32))
>>> node = ir.node(
...     "SomeOp",
...     inputs=[input_a, input_b],
...     attributes={"alpha": 1.0, "some_list": [1, 2, 3]},
...     domain="some.domain",
...     name="node_name"
... )
>>> node.op_type
'SomeOp'
Parameters:
  • op_type (str) – The name of the operator.

  • inputs (Sequence[ir.Value | None]) – The input values. When an input is None, it is an empty input.

  • attributes (Mapping[str, _convenience.SupportedAttrTypes] | None) – The attributes. RefAttr can be used only when the node is defined in a Function.

  • overload (str) – The overload name when the node is invoking a function.

  • domain (str) – The domain of the operator. For onnx operators, this is an empty string.

  • num_outputs (int | None) – The number of outputs of the node. If not specified, the number is 1.

  • outputs (Sequence[ir.Value] | None) – The output values. If None, the outputs are created during initialization.

  • version (int | None) – The version of the operator. If None, the version is unspecified and will follow that of the graph.

  • graph (ir.Graph | None) – The graph that the node belongs to. If None, the node is not added to any graph. A Node must belong to zero or one graph.

  • name (str | None) – The name of the node. If None, the node is anonymous.

  • doc_string (str | None) – The documentation string.

  • metadata_props (dict[str, str] | None) – The metadata properties.

Returns:

A node with the given op_type and inputs.

Return type:

ir.Node