A convolutional neural network hardware acceleration method based on parallel computing units
By combining static quantization and hierarchical quantization with parallel computing units, the universal problem of convolutional neural network deployment on embedded devices is solved, low-power, high-performance hardware acceleration is achieved, and it is suitable for low-power mobile and portable devices. Automatic defect detection.
Patent Information
- Application Number
- CN202210503065.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-10
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-05-10
AI Technical Summary
Existing technologies are difficult to effectively deploy convolutional neural networks on embedded devices with limited hardware resources, and quantification methods lack the versatility of network structures and cannot meet the needs of low latency, high performance, and low cost.
Using the methods of static quantization, hierarchical quantization and parallel computing units, the weight parameters of the convolutional neural network model are quantized into INT8 format, and the 11*11 multiplier array and pipeline maximum pooling layer structure are used to adapt to different volumes. Calculate the core size to achieve hardware acceleration.
It achieves high inference speed under low power consumption, significantly improves the defect recognition accuracy in industrial scenarios and reduces the energy consumption of image processing per frame.
Smart Images

Figure CN114819129B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer hardware, and in particular to a convolutional neural network hardware acceleration method based on static quantization, hierarchical quantization and parallel computing units. Background Art
[0002] In recent years, with the development of artificial intelligence technology, algorithms represented by convolutional neural networks have achieved excellent results in the application of computer vision. However, the complex computational complexity and large-scale computational parameters of convolutional neural networks are not suitable for embedded devices with limited hardware resources. How to deploy convolutional neural networks on edge embedded devices and make them smart terminals has become a research hotspot in academia and industry.
[0003] At present, there are many products on the market that implement hardware acceleration of convolutional neural networks based on parallel computing modules. These products mainly use methods such as quantizing model parameters to reduce the amount of calculation and designing special vector calculation modules for the convolution kernel size of specific models. However, these solutions do not consider the universality of the quantization method of model parameters to adapt to the network structure. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a convolutional neural network hardware acceleration method based on static quantization, hierarchical quantization and parallel computing units. According to the technical requirements of low detection latency, good performance, flexible deployment and low cost, a convolutional neural network hardware acceleration solution based on static quantization, hierarchical quantization and parallel computing units is designed.
[0005] To achieve the above object, the present invention adopts the following technical solutions:
[0006] A convolutional neural network hardware acceleration method based on static quantization, hierarchical quantization and parallel computing units comprises the following steps:
[0007] Step S1: quantize the weight parameters of the trained convolutional neural network model according to the static quantization and hierarchical quantization methods;
[0008] Step S2: Calculating the quantized convolutional neural network model through a parallel computing unit preset on the hardware circuit;
[0009] Step S3: According to the different computational parallelism of convolutional neural network models with different input sizes in the inference stage, the convolutional neural network models with different convolution kernel sizes are adaptively adapted through on-chip reconfigurable technology.
[0010] Furthermore, the step S1 is specifically as follows:
[0011] Step S11: extracting parameters from the trained convolutional neural network model and visualizing them as a weight parameter histogram;
[0012] Step S12: Use INT8 quantization to map the weight parameters of each layer to between -127 and 127 to obtain a quantized convolutional neural network model with a data format of 8-bit integer fixed-point numbers.
[0013] Furthermore, the parallel computing unit adopts an 11*11 multiplier array, including a dedicated register, a parallel multiplier unit with an enable signal line, and a parallel, pipelined maximum pooling layer structure design unit.
[0014] Furthermore, the 11*11 multiplier array is controlled by an enable signal and can adaptively activate the corresponding N*N multiplier array according to the convolution kernel size of the input convolutional neural network model.
[0015] Furthermore, the parallel, pipelined maximum pooling layer structure design unit includes 1 data selector, 2 64-bit counters, 2 FIFO cache modules with 32-bit data width and 1024-bit data depth, and 3 32-bit numerical comparators; the parallel, pipelined maximum pooling layer structure design unit uses 1 data selector to store the feature image input generated by the convolution module into the counting row FIFO and the even row FIFO according to the parity rule, the 2 counters are responsible for counting the number of data input into the odd row and even row FIFOs, and the 3 numerical comparators are responsible for comparing the values read from the parity row FIFOs, respectively.
[0016] Furthermore, the step S2 is specifically as follows:
[0017] Step S21: read the size parameters of the convolution layer from the off-chip DDR3 memory, and activate the 3*3 operation unit in the hardware multiplier matrix through the enable signal;
[0018] Step S22: In the first unit clock cycle, the weight of a 3*3 convolution layer is read into a dedicated register 1 of a 32-bit multiplier, and the pixel value of the image corresponding to the weight is read from an independent FIFO buffer and stored in the dedicated register 2;
[0019] Step S23: In the second unit clock cycle, the 32-bit multiplier completes a 32-bit single-precision floating-point operation, multiplies the values of the special register 1 and the special register 2 in step S21, and writes the result into the 64-bit special register 3.
[0020] Compared with the prior art, the present invention has the following beneficial effects:
[0021] 1. The present invention can achieve the purpose of hardware acceleration of convolutional neural networks, so that high inference speed can be achieved under low power consumption;
[0022] 2. The application scope of the present invention is narrow and the effect is significant. When a mobile and portable low-power automatic defect detection device is needed in an industrial scenario, it can effectively improve the accuracy of defect recognition and reduce the energy consumption required to process each frame of the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic diagram of the process of the present invention;
[0024] Figure 2 is a weight distribution histogram of the first convolutional layer in one embodiment of the present invention;
[0025] Figure 3 is a weight distribution histogram of the second convolutional layer in one embodiment of the present invention;
[0026] Figure 4 is a schematic diagram of an adaptive parallel computing module in one embodiment of the present invention;
[0027] Figure 5 is a schematic diagram of a multiplication unit of a parallel computing module in one embodiment of the present invention;
[0028] Figure 6 Schematic diagram of the pipeline structure of maximum pooling in one embodiment of the present invention. DETAILED DESCRIPTION
[0029] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0030] Please refer to Figure 1 The present invention provides a convolutional neural network hardware acceleration method based on static quantization, hierarchical quantization and parallel computing units, comprising the following steps:
[0031] Step S1: quantize the weight parameters of the trained convolutional neural network model according to the static quantization and hierarchical quantization methods;
[0032] In this embodiment, specifically, step S1 is:
[0033] Step S11: First, extract the parameters from the model and visualize them as a histogram to observe the distribution of the parameters. Figure 2 and Figure 3The distribution of the first and second convolutional layers of the example is plotted in the figure. From the figure, we can see that the weight parameters of each layer are mostly concentrated in a certain interval. For example, the weight parameters of the second convolutional layer are concentrated in [-0.4, 0.4]. There are few parameters outside this interval. Therefore, when quantizing, the parameters outside this interval are discarded, and -0.4 is mapped to -127 and 0.4 is mapped to 127. For the first convolutional layer, the parameters in the interval [-0.6, 0.6] are mapped to [-127, 127]. For the fully connected layer, the parameters in the interval [-0.4, 0.4] are mapped to [-127, 127], and the discarded parameters are all -127 or 127.
[0034] Step S12: INT8 quantization is used to map the weight parameters of each layer to between -127 and 127. That is, the max-max mapping maps the negative maximum value of the absolute value of the parameter to -127 and the positive maximum value to 127.
[0035] Preferably, during the quantization process, the bias parameters of all layers are discarded because the influence of the bias parameters on the corresponding accuracy is very small.
[0036] Step S2: Calculating the quantized convolutional neural network model through a parallel computing unit preset on the hardware circuit;
[0037] In this embodiment, specifically, step S2 is:
[0038] Step S21: Figure 4 The figure shows the multiplier array unit of the parallel convolution operation module. The size parameters of the convolution layer are read from the off-chip DDR3 memory, and the 3*3 operation units in the hardware multiplier matrix are activated by the enable signal.
[0039] Step S22: Figure 5 The figure shows the multiplication operation of the parallel convolution operation module. In the first unit clock cycle, the weight of a 3*3 convolution layer is read into the dedicated register 1 of a 32-bit multiplier, and the image pixel value corresponding to the weight is read from an independent FIFO buffer and stored in the dedicated register 2.
[0040] Step S23: In the second unit clock cycle, the 32-bit multiplier completes a 32-bit single-precision floating-point operation, multiplies the values of the special register 1 and the special register 2 in step S1, and writes the result into the 64-bit special register 3.
[0041] Preferably, in this embodiment, the parallel computing unit uses an 11*11 multiplier array, including a dedicated register, a parallel multiplier unit with an enable signal line, and a parallel, pipelined maximum pooling layer structure design unit.
[0042] refer to Figure 6 , The pipeline structure design unit of the maximum pooling layer includes 1 data selector, 2 64-bit counters, 2 FIFO cache modules with 32-bit data width and 1024-bit data depth, and 3 32-bit value comparators. 1 data selector enables the feature image input generated by the convolution module to be stored in the counting row FIFO and the even row FIFO according to the odd-even rule, 2 counters are responsible for counting the number of data input into the odd-row and even-row FIFOs respectively, and 3 value comparators are responsible for comparing the values read from the odd-row and even-row FIFOs respectively.
[0043] Specifically, the following steps are included:
[0044] (1): First, cache the data of odd and even rows into the odd column FIFO and even column FIFO in the order of odd first and even later.
[0045] (2): When the FIFO of the even column is not empty, the two FIFOs simultaneously output data to comparator 1. In the i-th clock cycle, the odd and even column data Xi and Y are compared first. i , take the larger value and assign it to Z i .
[0046] (3): Repeat the operation in step (2) and compare X again in the i+1th clock cycle. i+1 and Y i+1 , take the larger value and assign it to Z i+1 .
[0047] (4): Finally, Z is compared by comparator 3 i and Z i+1 The larger value is assigned to the final result, thus completing the whole process of downsampling in the maximum pooling layer.
[0048] Step S3: According to the different computational parallelism of convolutional neural network models with different input sizes in the inference stage, the convolutional neural network models with different convolution kernel sizes are adaptively adapted through on-chip reconfigurable technology.
[0049] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.
Claims
1. A convolutional neural network hardware acceleration method for parallel computing units, It is characterized in that The following steps are involved: Step S1: quantize the weight parameters of the trained convolutional neural network model according to the static quantization and hierarchical quantization methods; Step S2: Calculating the quantized convolutional neural network model through a parallel computing unit preset on the hardware circuit; Step S3: according to the different calculation parallelism of convolutional neural network models with different input sizes in the inference stage, the convolutional neural network models with different convolution kernel sizes are adaptively adapted through on-chip reconfigurable technology; The parallel computing unit uses an 11*11 multiplier array, including a dedicated register, a parallel multiplier unit with an enable signal line, and a parallel, pipelined maximum pooling layer structure design unit; The 11*11 multiplier array is controlled by an enable signal and can adaptively activate the corresponding N*N multiplier array according to the convolution kernel size of the input convolutional neural network model; The parallel, pipelined maximum pooling layer structure design unit includes 1 data selector, 2 64-bit counters, 2 FIFO cache modules with 32-bit data width and 1024-bit data depth, and 3 32-bit value comparators; the parallel, pipelined maximum pooling layer structure design unit uses 1 data selector to store the feature image input generated by the convolution module into the odd-row FIFO and the even-row FIFO according to the odd-even rule, 2 counters are responsible for counting the number of data input into the odd-row FIFO and the even-row FIFO respectively, and 3 value comparators are responsible for comparing the values read from the odd-row FIFO respectively; The step S2 is specifically as follows: Step S21: read the size parameters of the convolution layer from the off-chip DDR3 memory, and activate the 3*3 operation unit in the hardware multiplier matrix through the enable signal; Step S22: In the first unit clock cycle, the weight of a 3*3 convolution layer is read into a dedicated register 1 of a 32-bit multiplier, and the pixel value of the image corresponding to the weight is read from an independent FIFO buffer and stored in the dedicated register 2; Step S23: In the second unit clock cycle, the 32-bit multiplier completes a 32-bit single-precision floating-point operation, multiplies the values of the special register 1 and the special register 2 in step S22, and writes the result into the 64-bit special register 3.
2. The convolutional neural network hardware acceleration method of a parallel computing unit according to claim 1, It is characterized in that The step S1 is specifically as follows: Step S11: extracting parameters from the trained convolutional neural network model and visualizing them as a weight parameter histogram; Step S12: Use INT8 quantization to map the weight parameters of each layer to between -127 and 127 to obtain a quantized convolutional neural network model with a data format of 8-bit integer fixed-point numbers.
