Protos#

This structures are defined with protobuf in files onnx/*.proto. It is recommended to use function in module onnx.helper to create them instead of directly instantiated them. Every structure can be printed with function print and is rendered as a json string.

AttributeProto#

This class is used to define an attribute of an operator defined itself by a NodeProto. It is a named attribute containing either singular float, integer, string, graph, and tensor values, or repeated float, integer, string, graph, and tensor values. An AttributeProto MUST contain the name field, and only one of the following content fields, effectively enforcing a C/C++ union equivalent.

class onnx.AttributeProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

doc_string#

Field onnx.AttributeProto.doc_string

f#

Field onnx.AttributeProto.f

floats#

Field onnx.AttributeProto.floats

g#

Field onnx.AttributeProto.g

graphs#

Field onnx.AttributeProto.graphs

i#

Field onnx.AttributeProto.i

ints#

Field onnx.AttributeProto.ints

name#

Field onnx.AttributeProto.name

ref_attr_name#

Field onnx.AttributeProto.ref_attr_name

s#

Field onnx.AttributeProto.s

sparse_tensor#

Field onnx.AttributeProto.sparse_tensor

sparse_tensors#

Field onnx.AttributeProto.sparse_tensors

strings#

Field onnx.AttributeProto.strings

t#

Field onnx.AttributeProto.t

tensors#

Field onnx.AttributeProto.tensors

tp#

Field onnx.AttributeProto.tp

type#

Field onnx.AttributeProto.type

type_protos#

Field onnx.AttributeProto.type_protos

FunctionProto#

This defines a function. It is not a model but can be used to define custom operators used in a model.

class onnx.FunctionProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

attribute#

Field onnx.FunctionProto.attribute

attribute_proto#

Field onnx.FunctionProto.attribute_proto

doc_string#

Field onnx.FunctionProto.doc_string

domain#

Field onnx.FunctionProto.domain

input#

Field onnx.FunctionProto.input

metadata_props#

Field onnx.FunctionProto.metadata_props

name#

Field onnx.FunctionProto.name

node#

Field onnx.FunctionProto.node

opset_import#

Field onnx.FunctionProto.opset_import

output#

Field onnx.FunctionProto.output

overload#

Field onnx.FunctionProto.overload

value_info#

Field onnx.FunctionProto.value_info

GraphProto#

This defines a graph or a set of nodes called from a loop or a test for example. A graph defines the computational logic of a model and is comprised of a parameterized list of nodes that form a directed acyclic graph based on their inputs and outputs. This is the equivalent of the network or graph in many deep learning frameworks.

class onnx.GraphProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

doc_string#

Field onnx.GraphProto.doc_string

initializer#

Field onnx.GraphProto.initializer

input#

Field onnx.GraphProto.input

metadata_props#

Field onnx.GraphProto.metadata_props

name#

Field onnx.GraphProto.name

node#

Field onnx.GraphProto.node

output#

Field onnx.GraphProto.output

quantization_annotation#

Field onnx.GraphProto.quantization_annotation

sparse_initializer#

Field onnx.GraphProto.sparse_initializer

value_info#

Field onnx.GraphProto.value_info

MapProto#

This defines a map or a dictionary. It specifies an associative table, defined by keys and values. MapProto is formed with a repeated field of keys (of type INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64, or STRING) and values (of type TENSOR, SPARSE_TENSOR, SEQUENCE, or MAP). Key types and value types have to remain the same throughout the instantiation of the MapProto.

class onnx.MapProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

key_type#

Field onnx.MapProto.key_type

keys#

Field onnx.MapProto.keys

name#

Field onnx.MapProto.name

string_keys#

Field onnx.MapProto.string_keys

values#

Field onnx.MapProto.values

ModelProto#

This defines a model. That is the type every converting library returns after converting a machine learned model. ModelProto is a top-level file/container format for bundling a ML model and associating its computation graph with metadata. The semantics of the model are described by the associated GraphProto’s.

class onnx.ModelProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

doc_string#

Field onnx.ModelProto.doc_string

domain#

Field onnx.ModelProto.domain

functions#

Field onnx.ModelProto.functions

graph#

Field onnx.ModelProto.graph

ir_version#

Field onnx.ModelProto.ir_version

metadata_props#

Field onnx.ModelProto.metadata_props

model_version#

Field onnx.ModelProto.model_version

opset_import#

Field onnx.ModelProto.opset_import

producer_name#

Field onnx.ModelProto.producer_name

producer_version#

Field onnx.ModelProto.producer_version

training_info#

Field onnx.ModelProto.training_info

NodeProto#

This defines an operator. A model is a combination of mathematical functions, each of them represented as an onnx operator, stored in a NodeProto. Computation graphs are made up of a DAG of nodes, which represent what is commonly called a layer or pipeline stage in machine learning frameworks. For example, it can be a node of type Conv that takes in an image, a filter tensor and a bias tensor, and produces the convolved output.

class onnx.NodeProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

attribute#

Field onnx.NodeProto.attribute

doc_string#

Field onnx.NodeProto.doc_string

domain#

Field onnx.NodeProto.domain

input#

Field onnx.NodeProto.input

metadata_props#

Field onnx.NodeProto.metadata_props

name#

Field onnx.NodeProto.name

op_type#

Field onnx.NodeProto.op_type

output#

Field onnx.NodeProto.output

overload#

Field onnx.NodeProto.overload

OperatorProto#

This class is rarely used by users. An OperatorProto represents the immutable specification of the signature and semantics of an operator. Operators are declared as part of an OperatorSet, which also defines the domain name for the set. Operators are uniquely identified by a three part identifier (domain, op_type, since_version) where

  • domain is the domain of an operator set that contains this operator specification.

  • op_type is the name of the operator as referenced by a NodeProto.op_type

  • since_version is the version of the operator set that this operator was initially declared in.

class onnx.OperatorProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

doc_string#

Field onnx.OperatorProto.doc_string

op_type#

Field onnx.OperatorProto.op_type

since_version#

Field onnx.OperatorProto.since_version

status#

Field onnx.OperatorProto.status

OperatorSetIdProto#

This is the type of attribute opset_import of class ModelProto. This attribute specifies the versions of operators used in the model. Every operator or node belongs to a domain. All operators for the same domain share the same version.

class onnx.OperatorSetIdProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

domain#

Field onnx.OperatorSetIdProto.domain

version#

Field onnx.OperatorSetIdProto.version

OperatorSetProto#

An OperatorSetProto represents an immutable set of immutable operator specifications. The domain of the set (OperatorSetProto.domain) is a reverse-DNS name that disambiguates operator sets defined by independent entities. The version of the set (opset_version) is a monotonically increasing integer that indicates changes to the membership of the operator set. Operator sets are uniquely identified by a two part identifier (domain, opset_version) Like ModelProto, OperatorSetProto is intended as a top-level file/wire format, and thus has the standard format headers in addition to the operator set information.

class onnx.OperatorSetProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

doc_string#

Field onnx.OperatorSetProto.doc_string

domain#

Field onnx.OperatorSetProto.domain

functions#

Field onnx.OperatorSetProto.functions

ir_build_metadata#

Field onnx.OperatorSetProto.ir_build_metadata

ir_version#

Field onnx.OperatorSetProto.ir_version

ir_version_prerelease#

Field onnx.OperatorSetProto.ir_version_prerelease

magic#

Field onnx.OperatorSetProto.magic

operator#

Field onnx.OperatorSetProto.operator

opset_version#

Field onnx.OperatorSetProto.opset_version

OptionalProto#

Some input or output of a model are optional. This class must be used in this case. An instance of class OptionalProto may contain or not an instance of type TensorProto, SparseTensorProto, SequenceProto, MapProto and OptionalProto.

class onnx.OptionalProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

elem_type#

Field onnx.OptionalProto.elem_type

map_value#

Field onnx.OptionalProto.map_value

name#

Field onnx.OptionalProto.name

optional_value#

Field onnx.OptionalProto.optional_value

sequence_value#

Field onnx.OptionalProto.sequence_value

sparse_tensor_value#

Field onnx.OptionalProto.sparse_tensor_value

tensor_value#

Field onnx.OptionalProto.tensor_value

SequenceProto#

This defines a dense, ordered, collection of elements that are of homogeneous types. Sequences can be made out of tensors, maps, or sequences. If a sequence is made out of tensors, the tensors must have the same element type (i.e. int32). In some cases, the tensors in a sequence can have different shapes. Whether the tensors can have different shapes or not depends on the type/shape associated with the corresponding ValueInfo. For example, Sequence<Tensor<float, [M,N]> means that all tensors have same shape. However, Sequence<Tensor<float, [omitted,omitted]> means they can have different shapes (all of rank 2), where omitted means the corresponding dimension has no symbolic/constant value. Finally, Sequence<Tensor<float, omitted>> means that the different tensors can have different ranks, when the shape itself is omitted from the tensor-type. For a more complete description, refer to Static tensor shapes.

class onnx.SequenceProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

elem_type#

Field onnx.SequenceProto.elem_type

map_values#

Field onnx.SequenceProto.map_values

name#

Field onnx.SequenceProto.name

optional_values#

Field onnx.SequenceProto.optional_values

sequence_values#

Field onnx.SequenceProto.sequence_values

sparse_tensor_values#

Field onnx.SequenceProto.sparse_tensor_values

tensor_values#

Field onnx.SequenceProto.tensor_values

SparseTensorProto#

This defines a sparse tensor. The sequence of non-default values are encoded as a tensor of shape [NNZ]. The default-value is zero for numeric tensors, and empty-string for string tensors. values must have a non-empty name present which serves as a name for SparseTensorProto when used in sparse_initializer list.

class onnx.SparseTensorProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

dims#

Field onnx.SparseTensorProto.dims

indices#

Field onnx.SparseTensorProto.indices

values#

Field onnx.SparseTensorProto.values

StringStringEntryProto#

This is equivalent to a pair of strings. This is used to store metadata in ModelProto.

class onnx.StringStringEntryProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

key#

Field onnx.StringStringEntryProto.key

value#

Field onnx.StringStringEntryProto.value

TensorProto#

This defines a tensor. A tensor is fully described with a shape (see ShapeProto), the element type (see TypeProto), and the elements themselves. All available types are listed in onnx.mapping.

class onnx.TensorProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

class Segment#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

begin#

Field onnx.TensorProto.Segment.begin

end#

Field onnx.TensorProto.Segment.end

data_location#

Field onnx.TensorProto.data_location

data_type#

Field onnx.TensorProto.data_type

dims#

Field onnx.TensorProto.dims

doc_string#

Field onnx.TensorProto.doc_string

double_data#

Field onnx.TensorProto.double_data

external_data#

Field onnx.TensorProto.external_data

float_data#

Field onnx.TensorProto.float_data

int32_data#

Field onnx.TensorProto.int32_data

int64_data#

Field onnx.TensorProto.int64_data

metadata_props#

Field onnx.TensorProto.metadata_props

name#

Field onnx.TensorProto.name

raw_data#

Field onnx.TensorProto.raw_data

segment#

Field onnx.TensorProto.segment

string_data#

Field onnx.TensorProto.string_data

uint64_data#

Field onnx.TensorProto.uint64_data

TensorShapeProto#

This defines the shape of a tensor or a sparse tensor. It is a list of dimensions. A dimension can be either an integer value or a symbolic variable. A symbolic variable represents an unknown dimension.

class onnx.TensorShapeProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

class Dimension#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

denotation#

Field onnx.TensorShapeProto.Dimension.denotation

dim_param#

Field onnx.TensorShapeProto.Dimension.dim_param

dim_value#

Field onnx.TensorShapeProto.Dimension.dim_value

dim#

Field onnx.TensorShapeProto.dim

TrainingInfoProto#

TrainingInfoProto stores information for training a model. In particular, this defines two functionalities: an initialization-step and a training-algorithm-step. Initialization resets the model back to its original state as if no training has been performed. Training algorithm improves the model based on input data. The semantics of the initialization-step is that the initializers in ModelProto.graph and in TrainingInfoProto.algorithm are first initialized as specified by the initializers in the graph, and then updated by the initialization_binding in every instance in ModelProto.training_info. The field algorithm defines a computation graph which represents a training algorithm’s step. After the execution of a TrainingInfoProto.algorithm, the initializers specified by update_binding may be immediately updated. If the targeted training algorithm contains consecutive update steps (such as block coordinate descent methods), the user needs to create a TrainingInfoProto for each step.

class onnx.TrainingInfoProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

algorithm#

Field onnx.TrainingInfoProto.algorithm

initialization#

Field onnx.TrainingInfoProto.initialization

initialization_binding#

Field onnx.TrainingInfoProto.initialization_binding

update_binding#

Field onnx.TrainingInfoProto.update_binding

TypeProto#

This defines a type of a tensor which consists in an element type and a shape (ShapeProto).

class onnx.TypeProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

class Map#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

key_type#

Field onnx.TypeProto.Map.key_type

value_type#

Field onnx.TypeProto.Map.value_type

class Opaque#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

domain#

Field onnx.TypeProto.Opaque.domain

name#

Field onnx.TypeProto.Opaque.name

class Optional#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

elem_type#

Field onnx.TypeProto.Optional.elem_type

class Sequence#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

elem_type#

Field onnx.TypeProto.Sequence.elem_type

class SparseTensor#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

elem_type#

Field onnx.TypeProto.SparseTensor.elem_type

shape#

Field onnx.TypeProto.SparseTensor.shape

class Tensor#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

elem_type#

Field onnx.TypeProto.Tensor.elem_type

shape#

Field onnx.TypeProto.Tensor.shape

denotation#

Field onnx.TypeProto.denotation

map_type#

Field onnx.TypeProto.map_type

opaque_type#

Field onnx.TypeProto.opaque_type

optional_type#

Field onnx.TypeProto.optional_type

sequence_type#

Field onnx.TypeProto.sequence_type

sparse_tensor_type#

Field onnx.TypeProto.sparse_tensor_type

tensor_type#

Field onnx.TypeProto.tensor_type

ValueInfoProto#

This defines a input or output type of a GraphProto. It contains a name, a type (TypeProto), and a documentation string.

class onnx.ValueInfoProto#
DESCRIPTOR = <google.protobuf.pyext._message.MessageDescriptor object>#

The google.protobuf.descriptor.Descriptor for this message type.

doc_string#

Field onnx.ValueInfoProto.doc_string

metadata_props#

Field onnx.ValueInfoProto.metadata_props

name#

Field onnx.ValueInfoProto.name

type#

Field onnx.ValueInfoProto.type