AttributeProto#

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

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 AttributeType(*values)#
items = <nanobind.nb_func object>#
keys = <nanobind.nb_func object>#
values = <nanobind.nb_func object>#
ByteSize(self) int#

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

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

Copies one instance into this one.

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

Sets an empty value.

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

Sets an empty value.

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

Sets an empty value.

add_tp(self) onnx_light.onnx_py._onnxpy.TypeProto#

Sets an empty value.

property doc_string#

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

property f#

Optional float attribute.

property floats#

Optional repeated float attribute.

property g#

Optional graph attribute.

property graphs#

Optional repeated graph attribute.

has_doc_string(self) bool#

Tells if ‘doc_string’ has a value

has_f(self) bool#

Tells if ‘f’ has a value.

has_floats(self) bool#

Tells if ‘floats’ has a value.

has_g(self) bool#

Tells if ‘g’ has a value.

has_graphs(self) bool#

Tells if ‘graphs’ has a value.

has_i(self) bool#

Tells if ‘i’ has a value.

has_ints(self) bool#

Tells if ‘ints’ has a value.

has_name(self) bool#

Tells if ‘name’ has a value

has_ref_attr_name(self) bool#

Tells if ‘ref_attr_name’ has a value

has_s(self) bool#

Tells if ‘s’ has a value

has_sparse_tensor(self) bool#

Tells if ‘sparse_tensor’ has a value.

has_sparse_tensors(self) bool#

Tells if ‘sparse_tensors’ has a value.

has_strings(self) bool#

Tells if ‘strings’ has a value.

has_t(self) bool#

Tells if ‘t’ has a value.

has_tensors(self) bool#

Tells if ‘tensors’ has a value.

has_tp(self) bool#

Tells if ‘tp’ has a value.

property i#

Optional int64 attribute.

property ints#

Optional repeated int64 attribute.

property name#

Attribute name. This field MUST be present in this version of the IR.

property ref_attr_name#

This should ONLY be used in function (sub-graph). It’s invalid to be used in main graph.

Type:

If ref_attr_name is not empty, ref_attr_name is the attribute name in parent function. In this case, this AttributeProto does not contain data, and it’s a reference of attribute in parent scope. NOTE

property s#

Optional string attribute.

property sparse_tensor#

Optional sparse tensor attribute.

property sparse_tensors#

Optional repeated tensor attribute.

property strings#

Optional repeated string attribute.

property t#

Optional tensor attribute.

property tensors#

Optional repeated tensor attribute.

property tp#

Type proto

property type#

The type field MUST be present for this version of the IR. For 0.0.1 versions of the IR, this field was not defined, and implementations needed to use has_field heuristics to determine which value field was in use. For IR_VERSION 0.0.2 or later, this field MUST be set and match the f|i|s|t|… field in use. This change was made to accommodate proto3 implementations.