onnx.helper

tools

onnx.helper.find_min_ir_version_for(opsetidlist: List[onnx.onnx_ml_pb2.OperatorSetIdProto]) int[source]
onnx.helper.split_complex_to_pairs(ca: Sequence[numpy.complex64]) Sequence[int][source]

make function

All functions uses to create an ONNX graph.

onnx.helper.make_node(op_type: str, inputs: Sequence[str], outputs: Sequence[str], name: Optional[str] = None, doc_string: Optional[str] = None, domain: Optional[str] = None, **kwargs: Any) onnx.onnx_ml_pb2.NodeProto[source]

Construct a NodeProto.

Parameters
  • op_type (string) – The name of the operator to construct

  • inputs (list of string) – list of input names

  • outputs (list of string) – list of output names

  • name (string, default None) – optional unique identifier for NodeProto

  • doc_string (string, default None) – optional documentation string for NodeProto

  • domain (string, default None) – optional domain for NodeProto. If it’s None, we will just use default domain (which is empty)

  • **kwargs (dict) – the attributes of the node. The acceptable values are documented in make_attribute().

onnx.helper.make_graph(nodes: Sequence[onnx.onnx_ml_pb2.NodeProto], name: str, inputs: Sequence[onnx.onnx_ml_pb2.ValueInfoProto], outputs: Sequence[onnx.onnx_ml_pb2.ValueInfoProto], initializer: Optional[Sequence[onnx.onnx_ml_pb2.TensorProto]] = None, doc_string: Optional[str] = None, value_info: Sequence[onnx.onnx_ml_pb2.ValueInfoProto] = [], sparse_initializer: Optional[Sequence[onnx.onnx_ml_pb2.SparseTensorProto]] = None) onnx.onnx_ml_pb2.GraphProto[source]
onnx.helper.make_model(graph: onnx.onnx_ml_pb2.GraphProto, **kwargs: Any) onnx.onnx_ml_pb2.ModelProto[source]
onnx.helper.make_operatorsetid(domain: str, version: int) onnx.onnx_ml_pb2.OperatorSetIdProto[source]

Construct an OperatorSetIdProto.

Parameters
  • domain (string) – The domain of the operator set id

  • version (integer) – Version of operator set id

onnx.helper.make_opsetid(domain: str, version: int) onnx.onnx_ml_pb2.OperatorSetIdProto[source]
onnx.helper.make_tensor(name: str, data_type: int, dims: Sequence[int], vals: Any, raw: bool = False) onnx.onnx_ml_pb2.TensorProto[source]

Make a TensorProto with specified arguments. If raw is False, this function will choose the corresponding proto field to store the values based on data_type. If raw is True, use “raw_data” proto field to store the values, and values should be of type bytes in this case.

onnx.helper.make_sparse_tensor(values: onnx.onnx_ml_pb2.TensorProto, indices: onnx.onnx_ml_pb2.TensorProto, dims: Sequence[int]) onnx.onnx_ml_pb2.SparseTensorProto[source]
onnx.helper.make_sequence(name: str, elem_type: <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x000001DA417D19A0>, values: typing.Sequence[typing.Any]) onnx.onnx_data_pb2.SequenceProto[source]

Make a Sequence with specified value arguments.

onnx.helper.make_map(name: str, key_type: int, keys: List[Any], values: onnx.onnx_data_pb2.SequenceProto) onnx.onnx_data_pb2.MapProto[source]

Make a Map with specified key-value pair arguments.

Criteria for conversion: - Keys and Values must have the same number of elements - Every key in keys must be of the same type - Every value in values must be of the same type

onnx.helper.make_optional(name: str, elem_type: <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper object at 0x000001DA417D1A00>, value: typing.Optional[typing.Any]) onnx.onnx_data_pb2.OptionalProto[source]

Make an Optional with specified value arguments.

onnx.helper.make_attribute(key: str, value: Any, doc_string: Optional[str] = None) onnx.onnx_ml_pb2.AttributeProto[source]

Makes an AttributeProto based on the value type.

onnx.helper.make_empty_tensor_value_info(name: str) onnx.onnx_ml_pb2.ValueInfoProto[source]
onnx.helper.make_tensor_value_info(name: str, elem_type: int, shape: Optional[Sequence[Optional[Union[str, int]]]], doc_string: str = '', shape_denotation: Optional[List[str]] = None) onnx.onnx_ml_pb2.ValueInfoProto[source]

Makes a ValueInfoProto based on the data type and shape.

onnx.helper.make_tensor_type_proto(elem_type: int, shape: Optional[Sequence[Optional[Union[str, int]]]], shape_denotation: Optional[List[str]] = None) onnx.onnx_ml_pb2.TypeProto[source]

Makes a Tensor TypeProto based on the data type and shape.

onnx.helper.make_sparse_tensor_type_proto(elem_type: int, shape: Optional[Sequence[Optional[Union[str, int]]]], shape_denotation: Optional[List[str]] = None) onnx.onnx_ml_pb2.TypeProto[source]

Makes a SparseTensor TypeProto based on the data type and shape.

onnx.helper.make_sparse_tensor_value_info(name: str, elem_type: int, shape: Optional[Sequence[Optional[Union[str, int]]]], doc_string: str = '', shape_denotation: Optional[List[str]] = None) onnx.onnx_ml_pb2.ValueInfoProto[source]

Makes a SparseTensor ValueInfoProto based on the data type and shape.

onnx.helper.make_sequence_type_proto(inner_type_proto: onnx.onnx_ml_pb2.TypeProto) onnx.onnx_ml_pb2.TypeProto[source]

Makes a sequence TypeProto.

onnx.helper.make_optional_type_proto(inner_type_proto: onnx.onnx_ml_pb2.TypeProto) onnx.onnx_ml_pb2.TypeProto[source]

Makes an optional TypeProto.

onnx.helper.make_value_info(name: str, type_proto: onnx.onnx_ml_pb2.TypeProto, doc_string: str = '') onnx.onnx_ml_pb2.ValueInfoProto[source]

Makes a ValueInfoProto with the given type_proto.

onnx.helper.make_tensor_sequence_value_info(name: str, elem_type: int, shape: Optional[Sequence[Optional[Union[str, int]]]], doc_string: str = '', elem_shape_denotation: Optional[List[str]] = None) onnx.onnx_ml_pb2.ValueInfoProto[source]

Makes a Sequence[Tensors] ValueInfoProto based on the data type and shape.

onnx.helper.make_sequence_value_info(name: str, elem_type: int, shape: Optional[Sequence[Optional[Union[str, int]]]], doc_string: str = '', elem_shape_denotation: Optional[List[str]] = None) onnx.onnx_ml_pb2.ValueInfoProto[source]

Makes a Sequence[Tensors] ValueInfoProto based on the data type and shape.

onnx.helper.make_training_info(algorithm: onnx.onnx_ml_pb2.GraphProto, algorithm_bindings: List[Tuple[str, str]], initialization: Optional[onnx.onnx_ml_pb2.GraphProto], initialization_bindings: Optional[List[Tuple[str, str]]]) onnx.onnx_ml_pb2.TrainingInfoProto[source]

getter

onnx.helper.get_attribute_value(attr: onnx.onnx_ml_pb2.AttributeProto) Any[source]

print

onnx.helper.printable_attribute(attr: onnx.onnx_ml_pb2.AttributeProto, subgraphs: bool = False) Union[str, Tuple[str, List[onnx.onnx_ml_pb2.GraphProto]]][source]
onnx.helper.printable_dim(dim: onnx.onnx_ml_pb2.Dimension) str[source]
onnx.helper.printable_type(t: onnx.onnx_ml_pb2.TypeProto) str[source]
onnx.helper.printable_graph(graph: onnx.onnx_ml_pb2.GraphProto, prefix: str = '') str[source]
onnx.helper.printable_node(node: onnx.onnx_ml_pb2.NodeProto, prefix: str = '', subgraphs: bool = False) Union[str, Tuple[str, List[onnx.onnx_ml_pb2.GraphProto]]][source]
onnx.helper.printable_tensor_proto(t: onnx.onnx_ml_pb2.TensorProto) str[source]
onnx.helper.printable_value_info(v: onnx.onnx_ml_pb2.ValueInfoProto) str[source]