S100 OpenExplorer

# #hbDNNQuantiScale

`typedef struct { int32_t scaleLen; float *scaleData; int32_t zeroPointLen; int32_t *zeroPointData; } hbDNNQuantiScale;`

Quantization/Dequantization scale data.

Input: If the floating point data `data` is collected, the corresponding scale data is `scale`, and the corresponding zero-point offset data is `zeroPoint`, then the inference data sent to the model is g((d a t a/s c a l e)+z e r o P o i n t)g((data / scale) + zeroPoint)g((d a t a/sc a l e)+zero P o in t), in which, g(x)=c l i p(r o u n d(x))g(x) = clip(round(x))g(x)=c l i p(ro u n d(x)), clip is a truncation function, for example: U8: g(x)∈[0,255]g(x)∈[0, 255]g(x)∈[0,255], S8: g(x)∈[−128,127]g(x)∈[-128, 127]g(x)∈[−128,127].

Output: If the corresponding scale data of the inference result `data` is `scale`, and the corresponding zero-point offset data is `zeroPoint`, then the final inference result is (d a t a−z e r o P o i n t)∗s c a l e(data - zeroPoint) * scale(d a t a−zero P o in t)∗sc a l e.

The `scaleLen` is determined by `data` according to `per-axis` or `per-tensor` quantization/dequantization. When the `data` is quantized/dequantized by `per-tensor`, the `scaleLen` is equal to `1`, ignoring `quantizeAxis`. Otherwise the `quantizeAxis` represents the dimension index of the data quantization axis, and the `scaleLen` is equal to the size of the `quantizeAxis` dimension of the `data`. The value of `zeroPointLen` is equal to `scaleLen`.

- Member

Member Name | Description
--- | ---
`scaleLen` | Length of scale data.
`scaleData` | Base address of scale data.
`zeropointLen` | Length of zero-point offset data.
`zeropointData` | Base address of zero-point offset data.

On This Page