GraphView¶

class onnx_ir.GraphView(inputs, outputs, *, nodes, initializers=(), doc_string=None, opset_imports=None, name=None, metadata_props=None)¶

A read-only view on a graph.

The GraphView is useful for analysis of a subgraph. It can be initialized with a subset of nodes from a Graph. Creating GraphView does not change the ownership of the nodes, and so it is possible to create multiple GraphViews that contain the same nodes. If the underlying nodes / connections are mutated, the mutation will be reflected in all views as well.

The graph view can be serialized to ONNX:

graph_proto = ir.serde.serialize_graph(graph_view)

It can also be used to create a model:

model = ir.Model(graph_view, ir_version=8)
model_proto = ir.serde.serialize_model(model)

The model created with a GraphView will have a fixed topology, and its graph will remain read-only as a GraphView. No copying will be done during the initialization process.

Parameters:
  • inputs (Sequence[Value])

  • outputs (Sequence[Value])

  • nodes (Iterable[Node])

  • initializers (Sequence[Value])

  • doc_string (str | None)

  • opset_imports (dict[str, int] | None)

  • name (str | None)

  • metadata_props (dict[str, str] | None)

name¶

The name of the graph.

inputs¶

The input values of the graph.

outputs¶

The output values of the graph.

initializers¶

The initializers in the graph.

doc_string¶

Documentation string.

opset_imports¶

Opsets imported by the graph.

metadata_props¶

Metadata that will be serialized to the ONNX file.

meta¶

Metadata store for graph transform passes.

doc_string¶
initializers¶
inputs¶
name¶
nodes¶
opset_imports¶
outputs¶
count(value) integer -- return number of occurrences of value¶
display(*, page=False)¶

Pretty print the object.

Parameters:

page (bool) – Whether to page the output.

Return type:

None

index(value[, start[, stop]]) integer -- return first index of value.¶

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

property meta: MetadataStore¶

The metadata store for intermediate analysis.

Write to the metadata_props if you would like the metadata to be serialized to the ONNX proto.

property metadata_props: dict[str, str]¶