• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# OH_NN_QuantParam
2<!--Kit: Neural Network Runtime Kit-->
3<!--Subsystem: AI-->
4<!--Owner: @GbuzhidaoR-->
5<!--Designer: @GbuzhidaoR-->
6<!--Tester: @GbuzhidaoR-->
7<!--Adviser: @ge-yafang-->
8
9## Overview
10
11Defines the quantization information.
12
13In quantization scenarios, the 32-bit floating-point data type is quantized into the fixed-point data type according to the following formula:
14
15![zh-cn_formulaimage_0000001405137102](figures/zh-cn_formulaimage_0000001405137102.png)
16
17where, **s** and **z** are quantization parameters, which are stored by **scale** and **zeroPoint** in OH_NN_QuanParam. **r** is a floating point number, **q** is the quantization result, **q_min** is the lower bound of the quantization result, and **q_max** is the upper bound of the quantization result. The calculation method is as follows:
18
19![zh-cn_formulaimage_0000001459019845](figures/zh-cn_formulaimage_0000001459019845.png)
20
21![zh-cn_formulaimage_0000001408820090](figures/zh-cn_formulaimage_0000001408820090.png)
22
23The **clamp** function is defined as follows:
24
25![zh-cn_formulaimage_0000001455538697](figures/zh-cn_formulaimage_0000001455538697.png)
26
27**Since**: 9
28
29**Deprecated from**: 11
30
31**Substitute**: [NN_QuantParam](capi-neuralnetworkruntime-nn-quantparam.md)
32
33**Related module**: [NeuralNetworkRuntime](capi-neuralnetworkruntime.md)
34
35**Header file**: [neural_network_runtime_type.h](capi-neural-network-runtime-type-h.md)
36
37## Summary
38
39### Member Variables
40
41| Name| Description|
42| -- | -- |
43| uint32_t quantCount | Length of the numBits, scale, and zeroPoint arrays. In the per-layer quantization scenario, **quantCount** is usually set to **1**. That is, all channels of a tensor share a set of quantization parameters. In the per-channel quantization scenario, **quantCount** is usually the same as the number of tensor channels, and each channel uses its own quantization parameters.|
44| const uint32_t *numBits | Number of quantization bits.|
45| const double *scale | Pointer to the scale data in the quantization formula.|
46| const int32_t *zeroPoint | Pointer to the zero point data in the quantization formula.|
47