HexagonTpu.Quant (hexagon_tpu v0.1.2)

Copy Markdown

Quantize/dequantize helpers driven by HexagonTpu.TensorInfo metadata.

QNN stores affine quantization as float = (q + offset) * scale (QnnTypes.h, Qnn_ScaleOffset_t). TensorInfo normalizes that to the conventional zero_point = -offset, so:

q     = round(x / scale) + zero_point
float = (q - zero_point) * scale

Summary

Functions

Dequantizes an on-device tensor to {:f, 32}.

Quantizes a float tensor to the tensor's on-device type.

Functions

dequantize(q, tensor_info)

Dequantizes an on-device tensor to {:f, 32}.

quantize(x, tensor_info)

Quantizes a float tensor to the tensor's on-device type.