AffineLayoutProto#
Describes built-in affine encoding with tensor-valued scales and zero points. See Quantizes tensors into encoded values for encoded value representations.
- class onnx_light.onnx.AffineLayoutProto(*args, **kwargs)#
Describes the built-in affine (linear) quantization layout of an EncodedValueProto. The branch is deliberately closed: other affine forms use a structured layout instead of extending this message.
- CopyFrom(self, arg: onnx_light.onnx_py._onnxpyprotoop.AffineLayoutProto, /) 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_scale(self) onnx_light.onnx_py._onnxpyprotoop.TensorProto#
Sets an empty value.
- add_zero_point(self) onnx_light.onnx_py._onnxpyprotoop.TensorProto#
Sets an empty value.
- property axis#
Omitting axis selects per-tensor quantization; setting it selects per-axis parameters.
- property block_size#
Blocked quantization along axis. It is valid only together with axis.
- property scale#
Scalar or parameter tensor with a floating element type. This field MUST be present for a valid affine layout.
- property signed_storage#
0 is unsigned and 1 is signed. The code width is inferred from the logical shape and payload size and must identify exactly one supported width.
- Type:
Signedness of stored integer codes when storage_type is absent
- property storage_type#
Element type of the stored codes. It MUST be one of INT8, UINT8, INT4, UINT4, INT2 or UINT2 and the payload holds only row-major codes packed like TensorProto.raw_data. Exactly one of storage_type and signed_storage MUST be present. When storage_type is absent, signed_storage determines signedness and the code width is inferred from the logical element count and payload byte length; the payload MUST identify exactly one of the supported 2-bit, 4-bit or 8-bit widths. N is the product of the concrete dimensions in EncodedValueProto.logical_type.tensor_type.shape. B is either EncodedValueProto.raw_data.size() for an inline payload or the numeric ‘length’ entry in EncodedValueProto.external_data when data_location is EXTERNAL. Two-bit storage matches when B == ceil(N / 4) == N / 4 + (N % 4 != 0), 4-bit storage matches when B == ceil(N / 2) == N / 2 + N % 2, and 8-bit storage matches when B == N. Exactly one equality MUST hold; signed_storage then selects the signed INT2, INT4 or INT8 type when equal to 1, and the corresponding unsigned type otherwise.
- property zero_point#
Optional zero point with element type storage_type. It defaults to zero.