ExtendedInitializerProto#

Wraps one nonstandard graph initializer. Its value oneof contains either encoded_value (EncodedValueProto, field 1) or paged_cache (PagedCacheProto, field 2). Selecting one alternative clears the other; graph validation rejects entries without a payload.

from onnx_light import onnx

entry = onnx.ExtendedInitializerProto(encoded_value=encoded)
model.graph.extended_initializer.append(entry)
assert entry.WhichOneof("value") == "encoded_value"

The initializer name belongs to the selected payload, not to the wrapper. Type and quantization references remain scoped to the containing model. Native copies retain raw payload owners without a serialization round trip, including dense and encoded key/value pages in a paged cache; CopyFrom replaces the selected alternative, including when copying an empty message.

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

A graph initializer represented by exactly one onnx-light extension payload.

ByteSize(self) → int#

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

Clear(self) → None#

Clears the object.

ClearField(self, field_name: str) → None#

Clears the field field_name, following the protobuf API.

CopyFrom(self, arg: onnx_light.onnx_py._onnxpyprotoop.ExtendedInitializerProto, /) → None#

Copies one instance into this one.

Equals(self, other: onnx_light.onnx_py._onnxpyprotoop.ExtendedInitializerProto) → bool#

Compares message fields directly without serialization.

HasField(self, field_name: str) → bool#

Checks if a field is set, following the protobuf HasField API.

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._onnxpyprotoop.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. Standalone messages require single-file ONNX output. If external_data_file 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 model’s values and metadata stay unchanged. Borrowed buffers not proven independent of files are first snapshotted in the source, even if a later write fails; their addresses and ownership may change.

SerializeToFileDescriptor(self, fd: int, options: object | None = None) → None#

Serializes this instance into an open file descriptor without closing it.

SerializeToOStream(self, output: object) → None#

Alias for SerializeToOstream (capital S) for protobuf API compatibility. Serializes this instance to a Python file-like object that has a write() method.

SerializeToOstream(self, output: object) → None#

Serializes this instance to a Python file-like object that has a write() method.

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

Serializes this instance into a sequence of bytes.

WhichOneof(self, oneof_name: str) → object#
add_encoded_value(self) → onnx_light.onnx_py._onnxpyprotoop.EncodedValueProto#

Sets an empty value.

add_paged_cache(self) → onnx_light.onnx_py._onnxpyprotoop.PagedCacheProto#

Sets an empty value.

property encoded_value#

Encoded constant payload.

has_encoded_value(self) → bool#

Tells if ‘encoded_value’ has a value.

has_paged_cache(self) → bool#

Tells if ‘paged_cache’ has a value.

property paged_cache#

Paged KV cache payload.