OptionalProto#

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

A container that may or may not hold a value. The value, if present, may be a Tensor, Sparse Tensor, Sequence, Map, or another Optional. An absent value is semantically different from a present value that contains an empty tensor, sequence, or map. For example, an absent optional tensor means the absence of the tensor itself, whereas a present optional tensor that contains an empty tensor means the tensor is present but it has no elements.

ByteSize(self) int#

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

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

Copies one instance into this one.

class DataType(*values)#
HasField(self, arg: str, /) bool#
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.

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_map_value(self) onnx_light.onnx_py._onnxpy.MapProto#

Sets an empty value.

add_optional_value(self) onnx_light.onnx_py._onnxpy.OptionalProto#

Sets an empty value.

add_sequence_value(self) onnx_light.onnx_py._onnxpy.SequenceProto#

Sets an empty value.

add_sparse_tensor_value(self) onnx_light.onnx_py._onnxpy.SparseTensorProto#

Sets an empty value.

add_tensor_value(self) onnx_light.onnx_py._onnxpy.TensorProto#

Sets an empty value.

property elem_type#

The data type of the element, identifies if the OptionalProto value is Tensor, Sparse Tensor, Sequence, Map, or Optional. The type of the optional value MUST match the elem_type specified. This field MUST have a valid OptionalProto.DataType value.

has_map_value(self) bool#

Tells if ‘map_value’ has a value.

has_name(self) bool#

Tells if ‘name’ has a value

has_optional_value(self) bool#

Tells if ‘optional_value’ has a value.

has_sequence_value(self) bool#

Tells if ‘sequence_value’ has a value.

has_sparse_tensor_value(self) bool#

Tells if ‘sparse_tensor_value’ has a value.

has_tensor_value(self) bool#

Tells if ‘tensor_value’ has a value.

property map_value#

For MapProto value. When this field is present, the elem_type field MUST be MAP.

property name#

An optional identifier for this optional.

property optional_value#

For OptionalProto value, allowing optional to be of itself (completeness) When this field is present, the elem_type field MUST be OPTIONAL.

property sequence_value#

For SequenceProto value. When this field is present, the elem_type field MUST be SEQUENCE.

property sparse_tensor_value#

For SparseTensorProto value. When this field is present, the elem_type field MUST be SPARSE_TENSOR.

property tensor_value#

For TensorProto value. When this field is present, the elem_type field MUST be TENSOR.