GraphProto#
- class onnx_light.onnx.GraphProto(*args, **kwargs)#
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.
- CopyFrom(self, arg: onnx_light.onnx_py._onnxpyprotoop.GraphProto, /) None#
Copies one instance into this one.
- 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.
ParseFromString(self, data: bytes, options: object | None = None) -> None
Parses a sequence of bytes to fill this instance.
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. If
external_data_sizeis not empty, big weights are stored in this (depending onoptions.raw_data_threshold). When writing to two files, temporary external-data metadata is cleared so the in-memory model stays unchanged.
- 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.
- add_initializer(self, name_or_proto: object, array: object | None = None) onnx_light.onnx_py._onnxpyprotoop.TensorProto#
Appends a new initializer and returns it. Accepts either a prebuilt
TensorProtoor(name, numpy_array).
- add_input(self, name_or_proto: object, elem_type: object | None = None, shape: object | None = None, doc_string: object | None = None) onnx_light.onnx_py._onnxpyprotoop.ValueInfoProto#
Appends a new input and returns it. Accepts either a prebuilt
ValueInfoProtoor(name, elem_type, shape).
- add_metadata(self, key: str, value: str) onnx_light.onnx_py._onnxpyprotoop.StringStringEntryProto#
Sets metadata property key to value, updating an existing entry in place.
- add_node(self, arg0: object, arg1: object, arg2: object, /, **kwargs) onnx_light.onnx_py._onnxpyprotoop.NodeProto#
Builds a
NodeProtoviaonnx_light.onnx.helper.make_node(extra keyword arguments become node attributes) and appends it.
- add_output(self, name_or_proto: object, elem_type: object | None = None, shape: object | None = None, doc_string: object | None = None) onnx_light.onnx_py._onnxpyprotoop.ValueInfoProto#
Appends a new output and returns it. See
add_input().
- add_value_info(self, name_or_proto: object, elem_type: object | None = None, shape: object | None = None, doc_string: object | None = None) onnx_light.onnx_py._onnxpyprotoop.ValueInfoProto#
Appends a new intermediate value_info entry and returns it.
- property doc_string#
A human-readable documentation for this graph. Markdown is allowed.
- property encoded_initializer#
A list of named byte-encoded constant inputs of the graph (onnx-light extension, field numbers 1000-1099 are reserved for local extensions). Each entry MUST have a name, unique across initializer, sparse_initializer and encoded_initializer, and the name MAY also appear in the input list.
- property initializer#
A list of named sparse tensor values, used to specify constant inputs of the graph. Each initializer (both TensorProto as well SparseTensorProto) MUST have a name. The name MUST be unique across both initializer and sparse_initializer, but the name MAY also appear in the input list.
- property input#
Inputs of the graph, shapes and types are optional in a subgraph and mandatory in the main graph.
- property metadata_props#
Named metadata values; keys should be distinct.
- property name#
The name of the graph.
- property node#
The nodes in the graph, sorted topologically.
- property output#
Outputs of the graph, shapes and types are optional in a subgraph and mandatory in the main graph.
- property paged_cache_initializer#
Named paged KV cache defaults. Names are unique across all initializers and may also name graph inputs (onnx-light extension).
- property persistent_bindings#
Declares persistent output-to-input wiring on the model root graph only. Destinations must not overlap. Standard ONNX cannot represent this extension.
- property quantization_annotation#
For tensor ‘a’, it may have {‘SCALE_TENSOR’, ‘a_scale’} and {‘ZERO_POINT_TENSOR’, ‘a_zero_point’} annotated, which means, tensor ‘a_scale’ and tensor ‘a_zero_point’ are scale and zero point of tensor ‘a’ in the model.
- Type:
This field carries information to indicate the mapping among a tensor and its quantization parameter tensors. For example
- property sparse_initializer#
A list of named tensor values, used to specify constant inputs of the graph. Each initializer (both TensorProto as well SparseTensorProto) MUST have a name. The name MUST be unique across both initializer and sparse_initializer, but the name MAY also appear in the input list.
- property value_info#
Information for the values in the graph. The ValueInfoProto.name’s must be distinct. It is optional for a value to appear in value_info list.
Persistent bindings#
GraphProto.persistent_bindings (extension field 1001) declares root-graph
output-to-input feedback. It stores wiring only, never state contents or owners.
PersistentBindingProto uses only input_name (field 1) and output_name
(field 2). They select whole graph values by exact name. Dots and backslashes
are literal characters, not field-path syntax. An input is entirely persistent
or entirely supplied by current feeds. Former field-path wire fields 3 and 4
are rejected on load rather than silently changing partial persistence to whole
persistence.
Validation resolves catalogue references and requires compatible tensor,
sequence or structure declarations. Root sequences containing dense tensors
are bridged to the standard runtime sequence store, so standard sequence
operators can consume and produce persistent values. Sequences containing
encoded elements stay in the recursive runtime-value store for compatible
consumers. Nested sequences remain part of their enclosing structured runtime
value. Tensor ranks are compared when both are known, and dimensions when both
are concrete; symbolic dimensions and unknown ranks are accepted. Byte-encoded
values still require fixed geometry under the encoded layout validators.
Catalogue identities must agree for whole referenced formats. Whole structures
include all dynamic fields and their declared constants.
String tensors cannot be persistent, either directly or as nested fields or
constants of a selected structure or encoded layout. This restriction follows
catalogue references and does not affect ordinary nonpersistent string values.
Duplicate input selections and duplicate output selections are rejected; names
such as state and state.cache are distinct graph values.
Declarations in control-flow subgraphs are not supported.
GraphBuilder.make_persistent_binding(binding) appends a declaration;
persistent_bindings() returns a copy. Graph/model imports and exports retain
the declarations. Existing optimization passes preserve declared IO names;
the builder has no public operation for renaming graph IO. Renaming or removing
an IO by directly editing a proto is not an automatic binding rewrite: callers
must also update the affected declarations. Export rejects dangling names
rather than dropping declarations. Standard ONNX, ORT and function
exports reject persistence semantics.
- class onnx_light.onnx.PersistentBindingProto(*args, **kwargs)#
Declares a whole-output to whole-input persistent binding.
- CopyFrom(self, arg: onnx_light.onnx_py._onnxpyprotoop.PersistentBindingProto, /) 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.
ParseFromString(self, data: bytes, options: object | None = None) -> None
Parses a sequence of bytes to fill this instance.
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. If
external_data_sizeis not empty, big weights are stored in this (depending onoptions.raw_data_threshold). When writing to two files, temporary external-data metadata is cleared so the in-memory model stays unchanged.
- 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.
- property input_name#
Names the whole destination graph input, literally.
- property output_name#
Names the whole source graph output, literally.