Convolutional neural network acceleration method and system, storage medium, apparatus, and device

By performing unsigned integer quantization and convolution kernel decomposition on the convolutional neural network, and using large-bit-width unsigned multiply-and-accumulate calculation units for parallel calculations, the problem of hardware accelerator resource waste is solved, and computing efficiency and inference speed are improved.

WO2024193337A1PCT designated stage expired Publication Date: 2024-09-26SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD

Patent Information

Application Number
PCT/CN2024/079978
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-22
Filing Date
2024-03-04
Publication Date
2024-09-26

AI Technical Summary

Technical Problem

The large-bit-width multiply-accumulate unit of existing convolutional neural network hardware accelerators does not match the quantized low-bit-width data, resulting in a waste of resources and low computational efficiency.

Method used

By unsigned integer quantization of the convolutional neural network, the convolution kernel is decomposed into multiple strip convolution kernels, and the feature map is decomposed into multiple feature map groups, using a large bit-width unsigned multiply-accumulate calculation unit. Parallel multiplication and addition calculations of multiple weights and activation values ​​achieve efficient use of resources.

Benefits of technology

It effectively improves the utilization of computing resources, improves the efficiency of convolution calculations, reduces resource consumption, and significantly increases the inference speed of the accelerator.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024079978_26092024_PF_FP
    Figure CN2024079978_26092024_PF_FP
Patent Text Reader

Abstract

The present application relates to the technical field of neural networks, and provides a convolutional neural network acceleration method and system, a storage medium, an apparatus, and a device. The convolutional neural network acceleration method comprises the following steps: carrying out unsigned integer quantization on a convolutional neural network to obtain a quantized feature map and a quantized convolution kernel; decomposing the convolution kernel into a plurality of strip convolution kernels, and correspondingly decomposing the feature map into a plurality of feature map groups according to a convolution principle; concatenating a plurality of weights in each strip convolution kernel to obtain a concatenated weight, and concatenating a plurality of activation values in a corresponding feature map group to obtain a concatenated activation value; and inputting the concatenated weight and the concatenated activation value into an unsigned multiplication-addition calculation unit for multiplication-addition calculation to obtain a calculation result, and when calculation of all activation values of the feature map is completed, obtaining a complete convolution result on the basis of all calculation results. The present application effectively improves the computing resource utilization rate of an accelerator, and improves the convolution calculation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Convolutional neural network acceleration method, system, storage medium, device and equipment

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to the Chinese patent application filed with the China Patent Office on March 22, 2023, with application number 202310279563.8, and application name “Convolutional Neural Network Acceleration Method, System, Storage Medium, Device and Equipment”, all contents of which are incorporated by reference into this application. Technical Field

[0003] The present application relates to the field of neural network technology, and in particular to a convolutional neural network acceleration method, system, storage medium, device and equipment. Background Art

[0004] In recent years, convolutional neural networks have achieved tremendous success in the field of computer vision, for example, in image classification, object detection, and image segmentation. However, as neural networks have advanced, their accuracy has increased, but the number of network parameters has also increased. This large number of parameters makes hardware implementation of convolutional neural networks difficult. Quantization is a commonly used compression technique that can reduce storage resource consumption and speed up inference.

[0005] The most important operation in convolutional neural networks is the multiplication-addition (M / A) operation. Currently, the M / A units of most hardware accelerators have high bit widths (e.g., 32 or 64 bits), while neural networks are typically quantized to 8 bits or less. When computing M / A operations with these high-bitwidth M / A units, most of the unit's bit width remains unused, wasting valuable computing resources. Neural network quantization is rapidly developing, allowing data to be quantized to smaller bit widths. This waste becomes even more severe when processing lower bit widths or when using built-in M / A units with wider bit widths.

[0006] For example, the DSP (multiply-add unit) in an FPGA (Field Programmable Gate Array) is a critical and scarce resource for performing multiplication and addition operations. While different vendors offer different DSP designs, they all share a common characteristic: a large bit width. The DSP48E2 module in one vendor's architecture includes an 18x27-bit multiplier, a 27-bit pre-adder, and a 48-bit accumulator. Neural network applications typically perform data quantization and compression to 8 bits or less. This leaves more than half of the bit width unutilized for DSP modules like the DSP48E2. To leverage the DSP's large bit width, multiple parallel multiplications can be packaged within a single DSP module. For example, a single DSP module can perform two 8-bit multiplications, sharing the multiplicand. These packaged parallel computing methods are mostly based on signed integers, requiring signed multipliers and additional hardware resources for data packing and combining, as well as error correction for the calculation results. In addition, the common packing calculation method does not take advantage of the vertical addition characteristics of multiplication and the addition characteristics of convolution operations, and there is still room for improvement in the utilization of computing resources.

[0007] Summary of the Invention

[0008] In view of this, the purpose of this application is to propose a convolutional neural network acceleration method, system, storage medium, device and equipment to solve the problem in the prior art that the large-bit-width multiplication and addition unit of the hardware accelerator and the low-bit-width data after quantization of the neural network do not match, resulting in the need to consume more resources.

[0009] Based on the above objectives, this application provides a convolutional neural network acceleration method, comprising the following steps:

[0010] Perform unsigned integer quantization on the convolutional neural network to obtain the quantized feature map and convolution kernel;

[0011] Decompose the convolution kernel into multiple strip convolution kernels, and decompose the feature map into multiple feature map groups according to the convolution principle;

[0012] Multiple weights in the strip convolution kernel are spliced ​​together to obtain spliced ​​weights, and multiple activation values ​​in the corresponding feature map group are spliced ​​together to obtain spliced ​​activation values;

[0013] The concatenated weights and the concatenated activation values ​​are input into the unsigned multiplication-addition calculation unit for multiplication-addition calculation to obtain the calculation result, and until all the activation values ​​of the feature map are calculated, the complete convolution result is obtained based on all the calculation results.

[0014] In some embodiments, decomposing the convolution kernel into a plurality of strip convolution kernels includes:

[0015] The convolution kernel is decomposed in the length or width direction to obtain multiple strip convolution kernels.

[0016] In some embodiments, decomposing the convolution kernel in the length or width direction to obtain multiple strip convolution kernels includes:

[0017] The convolution kernel is decomposed into one-dimensional data in the length or width direction to obtain multiple one-dimensional convolution kernels.

[0018] In some embodiments, the method further comprises:

[0019] The convolution calculation is performed on the feature map in sequence according to the parallel operation of multiple strip convolution kernels, multiple input channels, multiple output channels, and multiple rows or columns of the feature map.

[0020] In some embodiments, concatenating multiple weights in a strip convolution kernel to obtain a concatenated weight, and concatenating multiple activation values ​​in a corresponding feature map group to obtain a concatenated activation value further includes:

[0021] The splicing weight and splicing activation value are calculated based on the following formula:

[0022] Among them, p represents the maximum number of weights allowed to be spliced, q represents the maximum number of activation values ​​allowed to be spliced, P represents the bit width of the weight input of the unsigned multiplication and addition calculation unit, Q represents the bit width of the activation value input of the unsigned multiplication and addition calculation unit, E represents the number of left shifts when the current weight is spliced, g represents the bit width of the guard bit, and M represents the number of parallel input channels.

[0023] In some embodiments, the method further comprises:

[0024] Add the bit width of the current weight, the bit width of the corresponding current activation value, and the bit width of the guard bit to get the number of left shifts.

[0025] In some embodiments, the weight is calculated based on the following weight sign conversion formula: w`:[-2 n-1 ,2 n-1 -1]->w:[0,2 n -1]-2 n-1

[0026] Among them, w` represents the weight of the quantized signed number, w represents the weight of the quantized unsigned integer, -> is the operator pointing to the structure member, and n is a positive integer.

[0027] In some embodiments, the method further comprises:

[0028] The weight sign conversion formula is calculated offline, and the quantized unsigned integer weights are stored through the accelerator.

[0029] In some embodiments, the method further comprises:

[0030] For multiple convolutional layers of the convolutional neural network, a computing engine is separately allocated to each convolutional layer to achieve parallel computing of multiple convolutional layers.

[0031] In some embodiments, the method further comprises:

[0032] The number of clock cycles calculated by each convolutional layer is obtained based on the ratio of the total computation amount of each convolutional layer to the parallelism within the layer.

[0033] In some embodiments, the method further comprises:

[0034] Multiply the number of rows, columns, input channels, output channels, and the size of the convolution kernel of the feature map to get the total computational effort.

[0035] In some embodiments, the method further comprises:

[0036] The parallelism within the layer is obtained by multiplying the parallel number of input channels, the parallel number of output channels, the parallel number of strip convolution kernels, the maximum number of weights allowed to be spliced, and the maximum number of activation values ​​allowed to be spliced ​​during the calculation of each convolution layer.

[0037] In some embodiments, obtaining a complete convolution result based on all calculation results includes:

[0038] Add up all the calculation results to get the complete convolution result.

[0039] Another aspect of the present application further provides a convolutional neural network acceleration system, comprising:

[0040] A quantization module is configured to perform unsigned integer quantization on the convolutional neural network to obtain quantized feature maps and convolution kernels;

[0041] A decomposition module is configured to decompose the convolution kernel into multiple strip convolution kernels, and decompose the feature map into multiple feature map groups according to the convolution principle;

[0042] a splicing module configured to splice multiple weights in the strip convolution kernel to obtain spliced ​​weights, and to splice multiple activation values ​​in the corresponding feature map group to obtain spliced ​​activation values; and

[0043] The computing module is configured to input the splicing weights and the splicing activation values ​​into the unsigned multiplication-addition computing unit for multiplication-addition calculation to obtain a calculation result, and until all activation values ​​of the feature map are calculated, a complete convolution result is obtained based on all calculation results.

[0044] In another aspect of the present application, a computer non-volatile readable storage medium is provided, which stores computer program instructions, and the computer program instructions implement the above method when executed by a processor.

[0045] In another aspect of the present application, an acceleration device is provided, comprising a memory and a processor, wherein a computer program is stored in the memory, and the computer program performs the above method when executed by the processor.

[0046] In another aspect of the present application, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the above method is performed.

[0047] This application has at least the following beneficial technical effects:

[0048] The convolutional neural network acceleration method of the present application performs unsigned integer quantization on the convolutional neural network, quantizes the activation values ​​of the feature map and the weights of the convolution kernel into unsigned integers, decomposes the convolution kernel into strip convolution kernels to match the unsigned multiplication and addition calculation unit, and splices multiple weights and multiple activation values ​​respectively, so that the large-bit-width unsigned multiplication and addition calculation unit can perform multiplication and addition calculations on multiple weights and multiple activation values ​​at one time, effectively solving the problem in the prior art that the large-bit-width multiplication and addition calculation unit can only perform multiplication and addition calculations on one weight and one activation value, resulting in resource waste, effectively improving the utilization of computing resources and improving the efficiency of accelerator convolution calculation. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying any creative work.

[0050] FIG1 is a schematic diagram of a convolutional neural network acceleration method provided according to an embodiment of the present application;

[0051] FIG2 is a comparative diagram of packing signed and unsigned numbers for multiplication and addition calculations according to an embodiment of the present application;

[0052] FIG3 is a schematic diagram of the structure of an Ultranet convolutional neural network provided according to an embodiment of the present application;

[0053] FIG4 is a schematic diagram of the structure of the signed number operation error correction part in FIG2 according to an embodiment of the present application;

[0054] FIG5 is a schematic diagram of the decomposition structure of a 3×3 convolution kernel and a 3×3 feature map according to an embodiment of the present application;

[0055] FIG6 is a schematic diagram of the decomposition structure of a 3×3 convolution kernel and a 4×4 feature map according to an embodiment of the present application;

[0056] FIG7 is a schematic diagram of concatenation, packing, and parallel convolution calculation according to an embodiment of the present application;

[0057] FIG8 is a schematic diagram of parallel computing of a computing engine composed of L×M×N DSPs according to an embodiment of the present application;

[0058] FIG9 is a schematic diagram of a convolutional neural network acceleration system provided according to an embodiment of the present application;

[0059] FIG10 is a schematic diagram of a computer non-volatile readable storage medium for implementing a convolutional neural network acceleration method according to an embodiment of the present application;

[0060] Figure 11 is a schematic diagram of the hardware structure of a computer device for executing a convolutional neural network acceleration method provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0061] In order to make the objectives, technical solutions and advantages of this application more clear, the embodiments of this application are further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0062] It should be noted that all expressions using "first" and "second" in the embodiments of the present application are intended to distinguish two non-identical entities or non-identical parameters with the same name. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present application. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, other steps or units inherent to a process, method, system, product, or device that includes a series of steps or units.

[0063] Based on the above objectives, the first aspect of the embodiment of the present application proposes an embodiment of a convolutional neural network acceleration method. Figure 1 shows a schematic diagram of an embodiment of the convolutional neural network acceleration method provided by the present application. As shown in Figure 1, the embodiment of the present application includes the following steps:

[0064] Step S10: performing unsigned integer quantization on the convolutional neural network to obtain a quantized feature map and convolution kernel;

[0065] Step S20: decompose the convolution kernel into multiple strip convolution kernels, and decompose the feature map into multiple feature map groups according to the convolution principle;

[0066] Step S30: splicing multiple weights in the strip convolution kernel to obtain splicing weights, and splicing multiple activation values ​​in the corresponding feature map group to obtain splicing activation values;

[0067] Step S40: Input the splicing weight and the splicing activation value into the unsigned multiplication-addition calculation unit for multiplication-addition calculation to obtain the calculation result, and until all activation values ​​of the feature map are calculated, a complete convolution result is obtained based on all calculation results.

[0068] The convolutional neural network acceleration method of the embodiment of the present application performs unsigned integer quantization on the convolutional neural network, quantizes the activation value of the feature map and the weight of the convolution kernel into unsigned integers, decomposes the convolution kernel into strip convolution kernels to match the unsigned multiplication and addition calculation unit, and splices multiple weights and multiple activation values ​​respectively, so that the large-bit-width unsigned multiplication and addition calculation unit can perform multiplication and addition calculations on multiple weights and multiple activation values ​​at one time, effectively solving the problem in the prior art that the large-bit-width multiplication and addition calculation unit can only perform multiplication and addition calculations on one weight and one activation value, resulting in resource waste, effectively improving the utilization of computing resources and improving the efficiency of the accelerator convolution calculation.

[0069] In some embodiments, the weight is calculated based on the following weight sign conversion formula: w`:[-2 n-1 ,2 n-1 -1]->w:[0,2 n -1]-2 n-1

[0070] Among them, w` represents the weight of the quantized signed number, w represents the weight of the quantized unsigned integer, -> is the operator pointing to the structure member, and n is a positive integer.

[0071] In some embodiments, the method further includes: calculating the weight sign conversion formula offline, and storing the quantized unsigned integer weights through an accelerator.

[0072] Specifically, after the feature maps in the convolutional neural network are activated by the activation function, the activation values ​​are all non-negative numbers and can be easily quantized into unsigned positive integers. Asymmetric quantization requires additional conversion operations to obtain correct results, which is not conducive to achieving high throughput. Therefore, a simpler and more effective symmetric quantization method is adopted. After quantization, all activation values ​​a are quantized into m-bit non-negative integers.

[0073] Currently, convolution kernel weights usually contain positive and negative numbers. They cannot be directly quantized into non-negative unsigned integers like activation values. When performing convolution calculations, using signed weights has the following three disadvantages: (1) Due to the existence of signed numbers, a signed multiplier is required, which is more complex than an unsigned multiplier; (2) Addition is required to concatenate signed numbers, and simple concatenation cannot be used, which consumes more resources; (3) After the multiplication of the packed signed numbers, the results need to be corrected. The following examples illustrate the disadvantages of signed number packing calculations:

[0074] Figure 2 shows a comparison diagram of signed and unsigned number packing for multiplication and addition. As shown in Figure 2, suppose two 2-bit signed multipliers w0 = 2'b01 (decimal 1) and w1 = 2'b11 (decimal -1) are to be packed. There are three zeros between w0 and w1. Since they are signed numbers, only addition w0<<5+w1=7'b0000001+7'b1111111=7'b0011111 is used. If the concatenation {w0,3{0},w1} then we get 7'b0100011. The two unsigned multiplicands to be packed are a0=2'b01 (decimal 1) and a1=2'b10 (decimal 2). The addition packing operation is a1<<5+a0=7'b1000001, and the splicing operation is {a1,3{0},a0}=7'b1000001. We want to get three results a1w0, a0w0+a1w1, and a0w1. Multiplying the packed numbers, the result is shown in Figure 1. When w0 and w1 are signed numbers, the result obtained by splicing is completely wrong. Regardless of whether splicing or shift addition is used, the purpose of packing is to get w0×2 5 +w1, when performing addition operation, w1 needs to be expanded according to the sign bit of w1. When w1 is a negative number, the splicing operation cannot directly implement w0×2 5 +w1. When w0 and w1 are signed numbers, the addition operation is used for packing. The multiplication result needs error correction. The error correction operation is to add one bit lower to the required bit segment. This error is caused by the sign bit when calculating the multiplication. As shown on the right side of Figure 2, when w0 and w1 are positive numbers, w0×2 5 +w1={w0,3{0},w1}=w0<<5+w1, a simple splicing operation can achieve packing, and the multiplication calculation result is correct, there is no sign bit pollution, and the correct output result can be directly intercepted.

[0075] In order to use simpler unsigned number multiplication calculations later, the signed weight w` needs to be converted to an unsigned number w. The specific conversion process is as follows: w`:[-2 n-1 ,2 n-1 -1]->w:[0,2n -1]-2 n-1

[0076] Among them, -> is the operator pointing to the structure member, which is used to access its internal members using a pointer to a structure or object.

[0077] The above signed value range is converted to an unsigned value range. The weight w` is known, so the conversion operation can be performed offline, which does not incur runtime costs. The accelerator can directly store the converted non-negative integer weights. According to the following formula, when using unsigned numbers w to replace signed numbers w` for calculation, the accuracy is almost unchanged, and only unsigned multipliers are required. Shift operations and subtraction operations are easier to implement in the circuit than the error correction circuit required for signed numbers, and consume less resources. aw`=a(w-2 n-1 )=aw-a2 n-1 =aw–a<<(n-1)

[0078] Figure 3 shows the structure of the Ultranet convolutional neural network. Taking the Ultranet convolutional neural network (UAV target detection network) as an example, as shown in Figure 3, Ultranet contains eight layers of 3×3 convolutions, one layer of pointwise convolution, four maximum pooling layers, and finally a recognizer for target detection. There are approximately 210,000 weight parameters in total, and processing a 320×160 image requires approximately 200M multiplication-addition operations. Quantization is performed during training, i.e., quantization and training are performed simultaneously. This ensures high accuracy with low-bit data precision. Activation values ​​are quantized to 4-bit unsigned numbers, and weights are quantized to 4-bit signed numbers.

[0079] Figure 4 shows the structure of the signed number operation error correction part in Figure 2. As shown in Figure 4, when performing operations with signed numbers, if the number is positive, no error correction is required, but if the number is negative, error correction is required based on the sign bit. Unsigned numbers do not require error correction, so the weights are converted from the signed domain to the unsigned domain (w`:[-8,7]->w:[0,15]-8). The network ultimately achieved an Intersection over Union (IoU) of 0.703 on the UAV target detection dataset.

[0080] In some embodiments, decomposing the convolution kernel into multiple strip convolution kernels includes: decomposing the convolution kernel in a length or width direction to obtain multiple strip convolution kernels.

[0081] In some embodiments, decomposing the convolution kernel in the length or width direction to obtain multiple strip convolution kernels includes: decomposing the convolution kernel into one-dimensional data in the length or width direction to obtain multiple one-dimensional convolution kernels.

[0082] Specifically, the square k×k convolution kernel is decomposed into k 1×k strip convolution kernels, each of which is treated as a one-dimensional convolution kernel. The square convolution kernel is a common convolution kernel shape used in convolutional neural networks and is one of the most commonly used convolution kernels in convolutional neural networks. Due to the use of packed parallel computing, the square convolution kernel needs to be decomposed into k 1×k strip convolution kernels, and then into k strip convolution kernels. The final result is the sum of the convolution calculation results of each strip convolution kernel, which does not affect the accuracy.

[0083] Figure 5 shows the decomposition structure of a 3×3 convolution kernel and a 3×3 feature map. Figure 6 shows the decomposition structure of a 3×3 convolution kernel and a 4×4 feature map. As shown in Figures 5-6, to simplify the decomposition of the convolution kernel and the calculation method, without padding, the 3×3 convolution kernel is decomposed into three strips of 1×3 convolution kernels. The convolution results of the three strips are calculated separately and then added together to obtain the convolution result of the 3×3 convolution kernel. The two calculation methods produce the same result.

[0084] In some embodiments, concatenating multiple weights in a strip convolution kernel to obtain a concatenated weight, and concatenating multiple activation values ​​in a corresponding feature map group to obtain a concatenated activation value further includes:

[0085] The splicing weight and splicing activation value are calculated based on the following formula:

[0086] Among them, p represents the maximum number of weights allowed to be spliced, q represents the maximum number of activation values ​​allowed to be spliced, P represents the bit width of the weight input of the unsigned multiplication and addition calculation unit, Q represents the bit width of the activation value input of the unsigned multiplication and addition calculation unit, E represents the number of left shifts when the current weight is spliced, g represents the bit width of the guard bit, and M represents the number of parallel input channels.

[0087] In some embodiments, the method further includes: adding the bit width of the current weight, the bit width of the corresponding current activation value, and the bit width of the guard bit to obtain the number of left shifts.

[0088] In some embodiments, the method further includes: performing convolution calculations on the feature map in sequence according to a plurality of strip convolution kernels in parallel, a plurality of input channels in parallel, a plurality of output channels in parallel, and a plurality of rows or columns of outputs in parallel of the feature map.

[0089] Specifically, convolution calculations are performed in accordance with the convolution method of a bar-shaped convolution kernel. One unsigned number multiplication calculation unit with a multi-bit width can perform multiple quantized low-bit width positive integer convolution multiply-accumulate operations in a one-time packed parallel manner without error correction. Multiple convolution kernels are parallel, multiple input channels are parallel, multiple output channels are parallel, and multiple rows or columns of outputs are parallel to improve the parallelism.

[0090] Each calculation unit can pack and calculate multiple convolution multiply-accumulate operations, combine multiple quantized activation values, and combine multiple quantized weights. The combination directions of the two are opposite. For example, the combination of activation values is a0<<qE + a1<<(q - 1)E + a q or {a0,…,(E - m){0},a1,(E - m){0},a2}, and the combination of weights is w p <<pE + … + w2<<2E + w1<<E + w0 or {w p ,…,w2,(E - n){0},w1,(E - n){0},w0}, << is a shift operation, E is the number of bits shifted to the left during combination and is also the bit width of each segment of the result in the output. It is necessary to ensure that there is no overflow and no overlap between adjacent output segments. E = m + n + g, where g is the bit width of the protection bit. When the weight is an unsigned number, the concatenation operation can be used, or shift and addition can also be used to combine w0, w1, and w2. However, when the weight is a signed number, only addition can be used to combine w0, w1, and w2. The concatenation operation is simpler and consumes fewer resources than the shift and addition operations. Then, the concatenated activation value and weight are input to the input end of the multiplier for packed calculation. Since both the activation value and the weight are unsigned numbers, there is no need to correct errors according to the sign bit. When the weight is a signed number, error correction needs to be performed according to the sign bit. The corresponding bit positions in the output result of the multiplier are intercepted and added to the corresponding bit positions in the next calculation result to obtain the correct complete convolution result. In this way, all activation values are calculated in sequence. The input weight bit width is n, the input activation value bit width is m, the bit widths of the two input ends of the multiplier are P and Q respectively, the bit width of the protection bit is g, and the maximum number of weights and the maximum number of activation values that can be packed are p and q respectively. The input channel parallelism is M. The relationships between them are as follows:

[0091] Figure 7 shows a schematic diagram of concatenated, packed, and parallel convolution operations. As shown in Figure 7, the weights and activation values ​​of the Ultranet convolutional neural network are quantized into 4-bit unsigned numbers, using simple concatenation operations instead of shift-and-add operations. A strip convolution kernel has three parameters. The input port of the DSP48E2 (an unsigned multiplication-and-addition unit) is 27×18 bits. As shown in Figure 7 (a), three weights are packed and concatenated into one data point, and two activation values ​​are concatenated into one data point. Considering the overlapping input channel dimensions and the fault tolerance of the neural network, assuming the guard bit width g is 3 and E is 11, a row of convolution kernels and two output pixels are implemented in parallel within a single DSP48E2. The spliced ​​activation value and weight are then packaged and calculated at the input of the multiplier. The spliced ​​weight is input to the 27-bit input port of the DSP, and the spliced ​​activation value is input to the 18-bit input port of the DSP. As shown in Figure 7 (b), a0 and a1 are calculated first, followed by a2 and a3. All input pixels are calculated in sequence. When the input feature map is padded with 0, the 33rd to 43rd bits obtained by the first calculation are invalid data, the 22nd to 32nd bits are the result of the first output pixel, and the 0th to 10th bits and the 11th to 21st bits are the intermediate results of the two output pixels. They are added to the 22nd to 32nd and 33rd to 43rd bits of the second calculation (a2, a3) to obtain two pixels. The 0th to 10th bits and the 11th to 21st bits of the second calculation are the intermediate results of the two output pixels. They are added to the 22nd to 32nd and 33rd to 43rd bits of the third calculation (a2, a3) to obtain two pixels. This process is repeated in sequence to obtain all output pixels. The last output can get 3 pixels, and the 11th to 21st bits are the result of the last pixel.

[0092] L such computing units can calculate L strip convolution kernels in parallel (L is 3 in this embodiment), M×N×L computing units can calculate M input channels, N output channels, and L strip convolution kernels in parallel, and R×M×N×L computing units can achieve R×2 rows or R×2 columns in parallel (R is 1 in this embodiment), M input channels in parallel, N output channels in parallel, and L strip convolution kernels in parallel. Figure 8 shows a schematic diagram of parallel computing of a computing engine composed of L×M×N DSPs. As shown in Figure 8, L rows of convolution kernels in parallel, 2 output pixels in parallel, M input channels in parallel, and N output channels in parallel are achieved.

[0093] In some embodiments, obtaining a complete convolution result based on all calculation results includes: adding all calculation results to obtain a complete convolution result.

[0094] Specifically, the parts corresponding to the channels in the above embodiment are accumulated to obtain the final output feature map. Due to the limited computing and storage resources of the accelerator, only the intermediate output results corresponding to some input channels can be calculated at a time, and the final result of the output pixel point cannot be obtained at once. It is necessary to loop multiple times and accumulate multiple intermediate results to obtain the final output pixel point. First, the loop of the input channel dimension and the three convolution kernel loops are completed, so that the complete output result can be obtained as soon as possible. Then the row dimension loop and the output channel dimension loop are completed to obtain a complete row of output. Finally, the column dimension loop is completed to obtain the complete output feature map.

[0095] In some embodiments, the method further includes: for multiple convolutional layers of the convolutional neural network, separately allocating a computing engine to each convolutional layer to achieve parallel computing of the multiple convolutional layers.

[0096] In some embodiments, the method further includes: obtaining the number of clock cycles for calculation of each convolution layer based on a ratio of the total amount of calculation of each convolution layer to the parallelism within the layer.

[0097] In some embodiments, the method further includes: multiplying the number of rows, the number of columns, the number of input channels, the number of output channels, and the size of the convolution kernel of the feature map to obtain a total amount of computation.

[0098] In some embodiments, the method further includes: multiplying the parallel number of input channels, the parallel number of output channels, the parallel number of strip convolution kernels, the maximum number of weights allowed for splicing, and the maximum number of activation values ​​allowed for splicing during the calculation process of each convolution layer to obtain the intra-layer parallelism.

[0099] Specifically, all convolutional layers of a convolutional neural network are computed to obtain the final network output. The accelerator uses a streaming architecture to compute the entire network. Each layer is assigned a separate compute engine, enabling parallel computation between layers to improve the parallelism and throughput of the entire accelerator. When using a streaming architecture, overall throughput is constrained by the throughput of the slowest layer. The slowest layer becomes the computational bottleneck for the entire accelerator. To ensure data flow is not blocked or overflowed, computations in other layers cannot be fully utilized. Therefore, it is necessary to balance throughput between layers, ensuring that the computation time of each layer is similar, allowing data to flow smoothly between layers. To achieve this, the parallelism of the compute engines for each layer is shown in Table 1 below, ensuring that the runtime of each layer is nearly identical.

[0100] Table 1. Parallelism settings and number of clock cycles required for calculation at each layer

[0101] As shown in Table 1, since the input of layer 0 is a feature map of RGB (color system) image, which is 8-bit data, it is impossible to use a single DSP to calculate 6 multiplications. Therefore, a common calculation strategy of using a single DSP to calculate two multiplications is used. The number of clock cycles required for calculation = total calculation amount (Fh × Fw × Ci × Co × 9) / intra-layer parallelism (2 × M × N × 9). Layers 1 to 7 adopt the parallel strategy of using a single DSP to calculate 6 multiplications proposed in the above embodiment of this application. The number of calculation cycles for each layer = total calculation amount (Fh × Fw × Ci × Co × 9) / intra-layer parallelism (6 × M × N × L). The last layer is a point-by-point convolution with a kernel size of 1×1 and 36 output channels, which is disproportionate to the previous layers and makes it difficult to achieve the same number of computational cycles. However, the computational complexity of the last layer is very small, much smaller than that of the previous layers, and a high degree of parallelism can be achieved with fewer computing resources. Therefore, four input channels and two output channels are selected for parallel processing. The required number of cycles is 57600 = (Fh×Fw×Ci×Co×9) / (M×N), which is less than the 102400 cycles of the previous layers and will not become a bottleneck.

[0102] Table 2 below shows the acceleration effect of the embodiment of the present application, as well as a comparison with currently leading Ultranet acceleration methods. As shown in Table 2, while other methods achieve FPS (Frames Per Second) between 200 and 300, the embodiment of the present application achieves FPS exceeding 2000, increasing inference speed by 7-10 times. The energy consumed to recognize a single image is only 0.7 mJ, less than one-tenth of that of other methods. The accelerator designed in the embodiment of the present application significantly improves performance.

[0103] Table 2 Acceleration effect comparison table

[0104] The second aspect of the embodiment of the present application also provides a convolutional neural network acceleration system. Figure 9 shows a schematic diagram of an embodiment of the convolutional neural network acceleration system provided by the present application. As shown in Figure 9, a convolutional neural network acceleration system includes: a quantization module 10, configured to perform unsigned integer quantization on the convolutional neural network to obtain a quantized feature map and a convolution kernel; a decomposition module 20, configured to decompose the convolution kernel into multiple strip convolution kernels, and decompose the feature map into multiple feature map groups according to the convolution principle; a splicing module 30, configured to splice multiple weights in the strip convolution kernel to obtain splicing weights, and splice multiple activation values ​​in the corresponding feature map groups to obtain splicing activation values; and a calculation module 40, configured to input the splicing weights and splicing activation values ​​into an unsigned multiplication and addition calculation unit for multiplication and addition calculation to obtain a calculation result, and until all activation values ​​of the feature map are calculated, a complete convolution result is obtained based on all calculation results.

[0105] A third aspect of the embodiments of the present application further provides a non-volatile computer-readable storage medium. FIG10 shows a schematic diagram of a non-volatile computer-readable storage medium for implementing a convolutional neural network acceleration method according to an embodiment of the present application. As shown in FIG10 , the non-volatile computer-readable storage medium 3 stores computer program instructions 31. When executed by a processor, the computer program instructions 31 implement the method of any of the above embodiments.

[0106] It should be understood that, to the extent that they do not conflict with each other, all the embodiments, features, and advantages described above for the convolutional neural network acceleration method according to the present application are also applicable to the convolutional neural network acceleration system and storage medium according to the present application.

[0107] According to a fourth aspect of the embodiments of the present application, an acceleration device is provided, comprising a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, a method of any one of the above embodiments is implemented.

[0108] The processor in the acceleration device can be an FPGA (Field Programmable Gate Array), an NPU (generally refers to an embedded neural network processor), etc.

[0109] According to a fifth aspect of the embodiments of the present application, a computer device is provided, comprising a memory 402 and a processor 401 as shown in FIG11 , wherein the memory 402 stores a computer program, and when the computer program is executed by the processor 401 , the method of any one of the above embodiments is implemented.

[0110] As shown in Figure 11, it is a schematic diagram of the hardware structure of an embodiment of a computer device for executing a convolutional neural network acceleration method provided by the present application. Taking the computer device shown in Figure 11 as an example, the computer device includes a processor 401 and a memory 402, and may also include: an input device 403 and an output device 404. The processor 401, the memory 402, the input device 403 and the output device 404 can be connected via a bus or other means. Figure 11 takes the bus connection as an example. The input device 403 can receive input digital or character information, and generate key signal input related to user settings and function control of the convolutional neural network acceleration system. The output device 404 may include a display device such as a display screen.

[0111] The memory 402 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs, and modules, such as the program instructions / modules corresponding to the convolutional neural network acceleration method in the embodiment of the present application. The memory 402 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created by the use of the convolutional neural network acceleration method, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 402 may optionally include a memory remotely located relative to the processor 401, and these remote memories may be connected to the local module via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0112] The processor 401 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions and modules stored in the memory 402, that is, implements the convolutional neural network acceleration method of the above method embodiment.

[0113] Finally, it should be noted that the computer non-volatile readable storage medium (e.g., memory) herein may be a volatile memory or a non-volatile memory, or may include both a volatile memory and a non-volatile memory. By way of example and not limitation, the non-volatile memory may include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable programmable ROM (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which may act as an external cache memory. By way of example and not limitation, RAM may be obtained in a variety of forms, such as synchronous RAM (DRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The storage devices of the disclosed aspects are intended to include, but are not limited to, these and other suitable types of memory.

[0114] Those skilled in the art will also appreciate that, in conjunction with the disclosed various exemplary logic blocks, modules, circuits and algorithmic steps described herein, can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, a general description has been given of the functions of various schematic components, blocks, modules, circuits and steps. Whether this function is implemented as software or implemented as hardware depends on specific applications and the design constraints imposed on whole systems. Those skilled in the art can implement the function in a variety of ways for every specific application, but this realization decision should not be interpreted as causing departure from the disclosed scope of the application's embodiments.

[0115] The above are exemplary embodiments disclosed in the present application, but it should be noted that various changes and modifications may be made without departing from the scope of the present application as defined in the claims. The functions, steps and / or actions of the method claims according to the disclosed embodiments described herein do not need to be performed in any particular order. In addition, although the elements disclosed in the embodiments of the present application may be described or required in individual form, they may also be understood as multiple unless expressly limited to the singular.

[0116] It should be understood that, as used herein, the singular form "a" or "an" is intended to include the plural form, unless the context clearly supports an exception. It should also be understood that, as used herein, "and / or" refers to any and all possible combinations of one or more of the items listed in association. The serial numbers of the embodiments disclosed in the above-mentioned embodiments of the present application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0117] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the disclosure of the embodiments of the present application (including the claims) is limited to these examples; based on the ideas of the embodiments of the present application, the technical features of the above embodiments or different embodiments can also be combined, and there are many other variations of different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the embodiments of the present application.

Claims

1. A convolutional neural network acceleration method, characterized in that: The following steps are involved: Perform unsigned integer quantization on the convolutional neural network to obtain the quantized feature map and convolution kernel; Decomposing the convolution kernel into a plurality of strip convolution kernels, and decomposing the feature map into a plurality of feature map groups accordingly according to the convolution principle; Splicing multiple weights in the strip convolution kernel to obtain a spliced ​​weight, and splicing multiple activation values ​​in the corresponding feature map group to obtain a spliced ​​activation value; The splicing weight and the splicing activation value are input into an unsigned multiplication-addition calculation unit for multiplication-addition calculation to obtain a calculation result, and until all activation values ​​of the feature map are calculated, a complete convolution result is obtained based on all calculation results.

2. The method according to claim 1, characterized in that Decomposing the convolution kernel into a plurality of strip convolution kernels includes: The convolution kernel is decomposed in the length or width direction to obtain multiple strip convolution kernels.

3. The method according to claim 2, characterized in that The convolution kernel is decomposed in the length or width direction to obtain a plurality of strip convolution kernels including: The convolution kernel is decomposed into one-dimensional data in the length or width direction to obtain multiple one-dimensional convolution kernels.

4. The method according to claim 1, characterized in that: Also includes: The feature map is convolved in turn in a manner of multiple strip convolution kernels in parallel, multiple input channels in parallel, multiple output channels in parallel, and multiple rows or columns of the feature map in parallel.

5. The method according to claim 1, characterized in that Splicing multiple weights in the strip convolution kernel to obtain a spliced ​​weight, and splicing multiple activation values ​​in the corresponding feature map group to obtain a spliced ​​activation value further includes: The splicing weight and the splicing activation value are calculated based on the following formula: Among them, p represents the maximum number of weights allowed for splicing, q represents the maximum number of activation values ​​allowed for splicing, P represents the bit width of the weight input end of the unsigned multiplication and addition calculation unit, Q represents the bit width of the activation value input end of the unsigned multiplication and addition calculation unit, E represents the number of left shift bits when the current weight is spliced, g represents the bit width of the protection bit, and M represents the number of parallel input channels.

6. The method according to claim 5, characterized in that Also includes: The bit width of the current weight, the bit width of the corresponding current activation value, and the bit width of the protection bit are added to obtain the left shift bit number.

7. The method according to claim 1, characterized in that The weight is calculated based on the following weight sign conversion formula: w`:[-2n-1,2n-1-1]->w:[0,2n-1]-2n-1 Among them, w` represents the quantized signed number weight, w represents the quantized unsigned integer weight, -> is an operator pointing to a structure member, and n is a positive integer.

8. The method according to claim 7, characterized in that Also includes: The weight sign conversion formula is calculated offline, and the quantized unsigned integer is converted into The weights are stored.

9. The method according to claim 1, characterized in that: Also includes: For the multiple convolutional layers of the convolutional neural network, a computing engine is separately allocated to each convolutional layer to achieve parallel computing of the multiple convolutional layers.

10. The method according to claim 9, characterized in that Also includes: The number of clock cycles calculated by each convolution layer is obtained based on the ratio of the total computation amount of each convolution layer to the intra-layer parallelism.

11. The method according to claim 10, characterized in that Also includes: The total amount of computation is obtained by multiplying the number of rows, the number of columns, the number of input channels, the number of output channels, and the size of the convolution kernel of the feature map.

12. The method according to claim 10, characterized in that Also includes: The parallel number of input channels, the parallel number of output channels, the parallel number of strip convolution kernels, the maximum number of weights allowed for splicing, and the maximum number of activation values ​​allowed for splicing in the calculation process of each convolution layer are multiplied to obtain the intra-layer parallelism.

13. The method according to claim 1, characterized in that The complete convolution results based on all calculation results include: All the calculation results are added together to obtain the complete convolution result.

14. The method according to claim 1, characterized in that The step of inputting the splicing weight and the splicing activation value into an unsigned multiplication-addition calculation unit for multiplication-addition calculation includes: The unsigned multiplication-addition calculation unit combines a plurality of the splicing weights and a plurality of the splicing activation values ​​to perform a multiplication-addition calculation; wherein the combination directions of the splicing weights and the splicing activation values ​​are opposite.

15. The method according to claim 1, characterized in that The unsigned integer quantization is symmetric quantization.

16. The method according to claim 9, characterized in that The method of separately allocating a computing engine to each convolutional layer includes: A computing engine is individually allocated to each convolutional layer through an accelerator; wherein the accelerator adopts a stream computing architecture.

17. A convolutional neural network acceleration system, characterized in that: include: A quantization module, configured to perform unsigned integer quantization on the convolutional neural network to obtain a quantized feature map and a convolution kernel; A decomposition module, configured to decompose the convolution kernel into a plurality of strip convolution kernels, and decompose the feature map into a plurality of feature map groups accordingly according to the convolution principle; A splicing module is configured to splice multiple weights in the strip convolution kernel to obtain a splicing weight, and splice multiple activation values ​​in the corresponding feature map group to obtain a splicing activation value; as well as The calculation module is configured to input the splicing weight and the splicing activation value into an unsigned multiplication-addition calculation unit for multiplication-addition calculation to obtain a calculation result, and until all activation values ​​of the feature map are calculated, a complete convolution result is obtained based on all calculation results.

18. A computer non-volatile readable storage medium, characterized in that: Computer program instructions are stored, and when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 16 is implemented.

19. An acceleration device, comprising a memory and a processor, characterized in that: The memory stores a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1 to 16 is performed.

20. A computer device comprising a memory and a processor, characterized in that: The memory stores a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1 to 16 is performed.

Citation Information

Patent Citations

  • Convolutional neural network accelerator

    CN113554163A

  • Neural network acceleration method and device, equipment, chip and storage medium

    CN115759192A

  • Convolutional neural network acceleration method and system, storage medium, device and equipment

    CN115994561A

  • Method and apparatus for learning low-precision neural network that combines weight quantization and activation quantization

    US20190138882A1

Cited By

  • FPGA (Field Programmable Gate Array)-based neural network storage and calculation resource optimal allocation method and system

    CN119440853A

  • Common convolution calculation hardware architecture based on row data flow and implementation method thereof

    CN120181154A

  • Convolutional neural network model quantification method based on truncation error

    CN121457528A