• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# OH_NN_QuantParam
2
3
4## Overview
5
6Defines the quantization information.
7
8In quantization scenarios, the 32-bit floating-point data type is quantized into the fixed-point data type according to the following formula:
9
10![zh-cn_formulaimage_0000001405137102](figures/zh-cn_formulaimage_0000001405137102.png)
11
12where, **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:
13
14![zh-cn_formulaimage_0000001459019845](figures/zh-cn_formulaimage_0000001459019845.png)
15
16![zh-cn_formulaimage_0000001408820090](figures/zh-cn_formulaimage_0000001408820090.png)
17
18The **clamp** function is defined as follows:
19
20![zh-cn_formulaimage_0000001455538697](figures/zh-cn_formulaimage_0000001455538697.png)
21
22**Since**: 9
23
24**Deprecated**: This module is deprecated since API version 11.
25
26**Substitute**: You are advised to use [NN_QuantParam](_neural_network_runtime.md#nn_quantparam).
27
28**Related module**: [NeuralNetworkRuntime](_neural_network_runtime.md)
29
30
31## Summary
32
33
34### Member Variables
35
36| Name| Description|
37| -------- | -------- |
38| [quantCount](#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.|
39| [numBits](#numbits) | Number of quantization bits.|
40| [scale](#scale) | Pointer to the scale data in the quantization formula.|
41| [zeroPoint](#zeropoint) | Pointer to the zero point data in the quantization formula.|
42
43
44## Member Variable Description
45
46
47### numBits
48
49```
50const uint32_t* OH_NN_QuantParam::numBits
51```
52
53**Description**
54
55Number of quantization bits.
56
57
58### quantCount
59
60```
61uint32_t OH_NN_QuantParam::quantCount
62```
63
64**Description**
65
66Length 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.
67
68
69### scale
70
71```
72const double* OH_NN_QuantParam::scale
73```
74
75**Description**
76
77Pointer to the scale data in the quantization formula.
78
79
80### zeroPoint
81
82```
83const int32_t* OH_NN_QuantParam::zeroPoint
84```
85
86**Description**
87
88Pointer to the zero point data in the quantization formula.
89