Model¶

class onnx_ir.Model(graph, *, ir_version, producer_name=None, producer_version=None, domain=None, model_version=None, doc_string=None, functions=(), metadata_props=None)¶
Parameters:
  • graph (Graph)

  • ir_version (int)

  • producer_name (str | None)

  • producer_version (str | None)

  • domain (str | None)

  • model_version (int | None)

  • doc_string (str | None)

  • functions (Sequence[Function])

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

doc_string¶
domain¶
graph¶
ir_version¶
model_version¶
producer_name¶
producer_version¶
clone()[source]¶

Create a deep copy of this model.

All graphs, nodes, values, and subgraphs are cloned. The cloned model will have the same structure as this model, but all graphs, nodes, and values will be different objects.

Tensors in initializers and constant values will be shared.

Added in version 0.1.14.

Returns:

A deep copy of this model.

Return type:

Model

display(*, page=False)¶

Pretty print the object.

Parameters:

page (bool) – Whether to page the output.

Return type:

None

property functions: dict[tuple[str, str, str], Function]¶
graphs()[source]¶

Get all graphs and subgraphs in the model.

This is a convenience method to traverse the model. Consider using onnx_ir.traversal.RecursiveGraphIterator for more advanced traversals on nodes.

Return type:

Iterable[Graph]

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]¶

The metadata properties of the model.

The metadata properties are used to store additional information about the model. Unlike meta, this property is serialized to the ONNX proto.

property opset_imports: dict[str, int]¶