ModelProto#

class onnx_light.onnx.ModelProto(*args, **kwargs)#

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.

ByteSize(self) int#

Returns the serialized size in bytes, following the protobuf API.

CopyFrom(self, arg: onnx_light.onnx_py._onnxpy.ModelProto, /) None#

Copies one instance into this one.

ParseFromEncryptedFile(self, name: str, key: str, options: object | None = None) None#

Decrypts an ONNXCRY1 encrypted file (written by SerializeToEncryptedFile) and parses the payload into this model instance.

ParseFromEncryptedString(self, data: bytes, key: str, options: object | None = None) None#

Decrypts an ONNXCRY1 encrypted bytes object (produced by SerializeToEncryptedString) and parses the payload into this model instance.

ParseFromFile(self, name: str, options: object | None = None, external_data_file: str = '') None#

Parses a binary file to fill this instance.

ParseFromString(self, data: bytes, options: object | None = None) None#
ParseFromString(self, data: str, options: object | None = None) None

Overloaded function.

  1. ParseFromString(self, data: bytes, options: object | None = None) -> None

Parses a sequence of bytes to fill this instance.

  1. ParseFromString(self, data: str, options: object | None = None) -> None

Parses a string to fill this instance.

SerializeSize(self, options: object | None = None) onnx_light.onnx_py._onnxpy.SerializeSizeResult#

Returns the size once serialized without serializing.

SerializeToEncryptedFile(self, name: str, key: str, options: object | None = None) None#

Encrypts the model with AES-256-CBC (PBKDF2 key derivation) and writes it to a single binary file. The key argument is a passphrase or raw bytes used to derive the AES-256 key via PBKDF2-HMAC-SHA256.

SerializeToEncryptedString(self, key: str, options: object | None = None) bytes#

Encrypts the model with AES-256-CBC (PBKDF2 key derivation) and returns the ciphertext as a bytes object in ONNXCRY1 format.

SerializeToFile(self, name: str, options: object | None = None, external_data_file: str = '') None#

Serializes this instance into a file. If external_data_size is not empty, big weights are stored in this (depending on options.raw_data_threshold). When writing to two files, temporary external-data metadata is cleared so the in-memory model stays unchanged.

SerializeToString(self, options: object | None = None) bytes#

Serializes this instance into a sequence of bytes.

add_graph(self) onnx_light.onnx_py._onnxpy.GraphProto#

Sets an empty value.

property configuration#

Describes different target configurations for a multi-device use case. A model MAY describe multiple multi-device configurations for execution.

property doc_string#

A human-readable documentation for this graph. Markdown is allowed.

property domain#

company.name. Together with model_version and GraphProto.name, this forms the unique identity of the graph.

Type:

Domain name of the model. We use reverse domain names as name space indicators. For example

property functions#

A list of function protos local to the model. The (domain, name, overload) tuple must be unique across the function protos in this list. In case of any conflicts the behavior (whether the model local functions are given higher priority, or standard operator sets are given higher priority or this is treated as error) is defined by the runtimes. The operator sets imported by FunctionProto should be compatible with the ones imported by ModelProto and other model local FunctionProtos. Example, if same operator set say ‘A’ is imported by a FunctionProto and ModelProto or by 2 FunctionProtos then versions for the operator set may be different but, the operator schema returned for op_type, domain, version combination for both the versions should be same for every node in the function body. One FunctionProto can reference other FunctionProto in the model, however, recursive reference is not allowed.

property graph#

The parameterized graph that is evaluated to execute the model.

has_configuration(self) bool#

Tells if ‘configuration’ has a value.

has_doc_string(self) bool#

Tells if ‘doc_string’ has a value

has_domain(self) bool#

Tells if ‘domain’ has a value

has_functions(self) bool#

Tells if ‘functions’ has a value.

has_graph(self) bool#

Tells if ‘graph’ has a value.

has_ir_version(self) bool#

Tells if ‘ir_version’ has a value.

has_metadata_props(self) bool#

Tells if ‘metadata_props’ has a value.

has_model_version(self) bool#

Tells if ‘model_version’ has a value.

has_opset_import(self) bool#

Tells if ‘opset_import’ has a value.

has_producer_name(self) bool#

Tells if ‘producer_name’ has a value

has_producer_version(self) bool#

Tells if ‘producer_version’ has a value

property ir_version#

The version of the IR this model targets. See Version enum above. This field MUST be present.

property metadata_props#

Named metadata values; keys should be distinct.

property model_version#

The version of the graph encoded. See Version enum below.

property opset_import#

The OperatorSets this model relies on. All ModelProtos MUST have at least one entry that specifies which version of the ONNX OperatorSet is being imported. All nodes in the ModelProto’s graph will bind against the operator with the same-domain/same-op_type operator with the HIGHEST version in the referenced operator sets.

property producer_name#

The name of the framework or tool used to generate this model. This field SHOULD be present to indicate which implementation/tool/framework emitted the model.

property producer_version#

The version of the framework or tool used to generate this model. This field SHOULD be present to indicate which implementation/tool/framework emitted the model.