IP Library Granted Patent US 12,093,148
Granted Patent B2
US 12,093,148 · App. 17/547,972 · Granted Sep 17, 2024

Neural network quantization parameter determination method and related products

Inventors: Shaoli Liu (Shanghai, CN); Xiaofu Meng (Shanghai, CN); Xishan Zhang (Shanghai, CN); Jiaming Guo (Shanghai, CN); Di Huang (Shanghai, CN); Yao Zhang (Shanghai, CN); Yu Chen (Shanghai, CN); Chang Liu (Shanghai, CN)
Assignee: Shanghai Cambricon Information Technology Co., Ltd
G06F11/1476G06N3/047G06N3/08G06F2201/81G06F2201/865
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,093,148
App. No.
17/547,972
Granted
Sep 17, 2024
Kind
B2
Abstract

The technical solution involves a board card including a storage component, an interface apparatus, a control component, and an artificial intelligence chip. The artificial intelligence chip is connected to the storage component, the control component, and the interface apparatus, respectively; the storage component is used to store data; the interface apparatus is used to implement data transfer between the artificial intelligence chip and an external device; and the control component is used to monitor a state of the artificial intelligence chip. The board card is used to perform an artificial intelligence operation.

Claims (49)

1. A method for adjusting a data bit width in a convolution neural network layer during a neural network computation, comprising:

obtaining a data bit width used to perform a quantization on data to be quantized, wherein the data to be quantized includes at least one type of neurons, weights, gradients, or biases, the data bit width indicates the data bit width of the quantized data after the data to be quantized being quantized;

performing a quantization on a group of data to be quantized based on the data bit width to convert the group of data to be quantized to a group of quantized data, wherein the group of quantized data has the data bit width;

comparing the group of data to be quantized with the group of quantized data to determine a quantization error correlated with the data bit width;

adjusting the data bit width based on the determined quantization error; and

applying the adjusted data bit width during quantization in the convolution neural network layer.

2. The method of claim 1 , wherein the comparing of the group of data to be quantized with the group of quantized data to determine the quantization error correlated with the data bit width includes:

determining a quantization interval according to the data bit width; and

determining the quantization error according to the quantization interval, the group of the quantized data and the group of data to be quantized.

3. The method of claim 2 , wherein the determining the quantization error according to the quantization interval, the group of the quantized data and the group of the data to be quantized includes:

inversely quantizing the group of quantized data according to the quantization interval to obtain a group of inversely quantized data, wherein a data format of the group of inversely quantized data is the same with a data format of the group of the data to be quantized; and

determining a quantization error according to the group of inversely quantized data and the group of data to be quantized.

4. The method of claim 1 , wherein the adjusting the data bit width based on the determined quantization error includes:

comparing the quantization error and a preset threshold, wherein the preset threshold includes at least one of a first threshold and a second threshold; and

adjusting the data bit width according to a comparison result.

5. The method of claim 4 , wherein the adjusting the data bit width according to the comparison result includes:

increasing the data bit width when the quantization error is greater than or equal to the first threshold;

wherein the increasing the data bit width includes:

increasing the data bit width according to a first preset bit width stride to determine an adjusted data bit width;

wherein the method further comprises:

iteratively performing the quantization on the group of data to be quantized based on the adjusted data bit width to convert the group of data to be quantized to another group of quantized data, wherein the other group of quantized data has the adjusted data bit width; and

comparing the group of data to be quantized with the other group of quantized data to determine another quantization error correlated with an adjusted data bit width until the other quantization error is less than the first preset threshold.

6. The method of claim 4 , wherein the adjusting the data bit width according to the comparison result includes:

decreasing the data bit width when the quantization error is less than or equal to a second threshold;

wherein the decreasing the data bit width includes:

decreasing the data bit width according to a second preset bit width stride to determine an adjusted bit width;

wherein the method further comprises:

iteratively performing the quantization on the group of data to be quantized based on the adjusted data bit width to convert the group of data to be quantized to another group of quantized data, wherein the other group of quantized data has the adjusted data bit width; and

determining another quantization error correlated with the adjusted data bit width based on the group of data to be quantized and the other group of quantized data, until the other quantization error is greater than the second preset threshold.

7. The method of claim 4 , wherein the adjusting the data bit width according to the comparison result includes:

maintaining the data bit width when the quantization error is between the first threshold and the second threshold.

8. The method of claim 1 , further comprising:

updating a quantization parameter configured to perform the quantization on the group of data to be quantized based on the group of data to be quantized and the adjusted bit width; and

performing the quantization on the group of data to be quantized based on an updated quantization parameter.

9. The method of claim 1 , further comprising:

obtaining a data variation range of data to be quantized; and

according to the data variation range of the data to be quantized, determining a target iteration interval to adjust the data bit width according to the target iteration interval, wherein the target iteration interval includes at least one iteration.

10. The method of claim 9 , wherein the determining the target iteration interval according to the data variation range of the data to be quantized includes:

determining the target iteration interval according to the first error, wherein the target iteration interval is negatively correlated with the first error.

11. The method of claim 9 , wherein the obtaining of the data variation range of the data to be quantized includes:

obtaining a variation trend of the data bit width; and

determining the data variation range of the data to be quantized according to a variation range of a point location and the variation trend of the data bit width.

12. A device for adjusting a data bit width in a convolution neural network layer during a neural network computation, comprising:

an obtaining circuit configured to obtain a data bit width used to perform a quantization on data to be quantized, wherein the data to be quantized includes at least one type of neurons, weights, gradients, or biases, the data bit width indicates the data bit width of the quantized data after the data to be quantized being quantized;

a quantization circuit configured to perform a quantization on a group of data to be quantized based on the data bit width to convert the group of data to be quantized to a group of quantized data, wherein the group of quantized data has the data bit width; and

a determination circuit configured to compare the group of data to be quantized with the group of quantized data to determine a quantization error correlated with the data bit width, and adjust the data bit width based on the determined quantization error, before the adjusted data bit width is applied during quantization in the convolution neural network layer.

13. An artificial intelligence chip comprising the device of claim 12 .

14. A non-transitory computer readable storage medium, wherein a computer program is stored in the non-transitory computer readable storage medium, and the method of claim 1 are implemented when the computer program is executed by a processor.

15. An electronic device comprising the artificial intelligence chip of claim 13 .

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 8, 2022
From: LIU, SHAOLI; MENG, XIAOFU; ZHANG, XISHAN; GUO, JIAMING; HUANG, DI; ZHANG, YAO; CHEN, YU; LIU, CHANG
To: SHANGHAI CAMBRICON INFORMATION TECHNOLOGY CO., LTD
Reel/Frame 061102/0084 →
Priority Claims (4)
CN 201910505239.7 · Jun 12, 2019 · national
CN 201910515355.7 · Jun 14, 2019 · national
CN 201910528537.8 · Jun 18, 2019 · national
CN 201910570125.0 · Jun 27, 2019 · national
Continuity (2)
Continuation PCTCN2019106801 · Sep 19, 2019
Related Publication 20220261634A1 · Aug 18, 2022
Cited By (1)
US 12,333,671