A deformable convolution accelerator and a deformable convolution acceleration method
By using the mapping module in the deformable convolution accelerator to regularize the irregular receptive field, and through the parallel operation of the register module, the problems of access conflicts and accuracy reduction are solved, and efficient calculation and low-energy acceleration are achieved.
Patent Information
- Application Number
- CN202110788017.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-13
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-07-13
AI Technical Summary
When implementing deformable convolution acceleration, the existing technology leads to problems of irregular access and reduced output accuracy caused by irregular receptive fields, and excessive access times to off-chip memory.
Design a deformable convolution accelerator that includes software and hardware. The irregular receptive fields are regularized through the mapping module, and the operation rates of the mapping module and the convolution module are matched through the ping-pong operation of the register module to reduce the cost of off-chip memory. Access frequency.
It retains the accuracy of the original model to the maximum extent, improves hardware utilization, reduces the access frequency of off-chip storage space, and improves computing efficiency.
Smart Images

Figure CN113516235B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of convolutional neural networks, and in particular to a deformable convolution accelerator and a deformable convolution acceleration method. Background Art
[0002] Deformable convolution has important applications in target detection. Since the theory of deformable convolution was proposed, various target detection models have applied deformable convolution to achieve higher detection accuracy and speed. In ordinary convolution networks, a window of the same size as the convolution kernel slides on the input feature map, and the value at the corresponding position of the window is selected and multiplied with the convolution kernel, and the output of the current position is accumulated. On the basis of ordinary convolution, deformable convolution dynamically generates an offset according to the input feature map. When selecting a value on the input feature map to multiply the convolution kernel, the position corresponding to the sliding window is used as the base address, and the corresponding offset is added to the base address to obtain a new address, and then the new address is used to obtain the value on the input feature map. Since the offset is not an integer, the new address is often not an integer. When the new address exceeds the address range of the input feature map, the returned input value is zero. When the new address is within the address range of the input feature map, bilinear interpolation is used to find the four points closest to the new address coordinates to calculate the input value of the new address, multiply the input value of the new address by the convolution kernel, and accumulate them to obtain the output of the deformable convolution.
[0003] In order to facilitate hardware design, the existing technology has made algorithmic adjustments to the deformable convolution, specifically: limiting the size of the offset within a certain range and fixing the direction of the offset, so that the irregular receptive field becomes a regular square; at the same time, the offset is changed from a floating point number to an integer, and the bilinear interpolation method is skipped to directly obtain the value. After the above operations, the receptive field is regularized, and the adjusted deformable convolution layer structure is close to the void convolution. However, this method makes a significant adjustment to the algorithm of the deformable convolution, resulting in reduced output accuracy.
[0004] The existing technology also limits the size of the receptive field by selecting a smaller offset during training, and stores the value of the offset address on the input feature map as an intermediate variable off-chip, which is then retrieved from off-chip when the convolution calculation is performed. This method greatly increases the number of accesses to the off-chip memory. Summary of the invention
[0005] In order to overcome the shortcomings of the prior art, the present application aims to provide a deformable convolution accelerator and a deformable convolution acceleration method to solve the problems of irregular access and reduced output accuracy caused by irregular receptive fields, while reducing the number of accesses to off-chip memory by optimizing storage space and access operations.
[0006] In order to achieve the above objectives, on the one hand, the present application provides a deformable convolution accelerator, specifically including: a software end and a hardware end.
[0007] The software end is used to implement the overall architecture of the deformable convolution accelerator, and to load the original model parameters from the off-chip memory to the hardware end, wherein the original model parameters include the original input value, offset, quantization scale, mask and convolution weight; and to read the output value of the hardware end to the off-chip memory.
[0008] The hardware end includes:
[0009] A control module is used to obtain the original input value, offset, quantization scale, mask and convolution weight from the software end; and to obtain the actual address according to the base address and the offset, and separate the actual address into an integer part and a decimal part; it is also used to output a control signal to control the mapping module, the register module, the mask module, the convolution module, the input cache module, the output cache module and the weight cache module and the data interaction between the modules; and it is also used to transmit the output value to the software end.
[0010] Input cache module, used to store raw input values.
[0011] The register module is used to convert the access parallel dimension of the original input value, obtain the parallel input value, and store the parallel input value.
[0012] A mapping module is used to obtain an actual address and an interpolation weight corresponding to the actual address according to the quantization scale, the integer part and the decimal part; and to perform bilinear interpolation processing according to the parallel input value and the interpolation weight to obtain a real input value.
[0013] The mask module is used to store the mask and obtain a regularized input value according to the real input value and the mask.
[0014] Weight cache module, used to store convolution weights.
[0015] The convolution module is used to perform convolution calculations based on convolution weights and regularized input values to obtain output values.
[0016] The output cache module is used to store the output values calculated by the convolution module.
[0017] Furthermore, the convolution module includes a multiplication unit, an addition unit and an accumulation unit.
[0018] The multiplication unit includes a multiplier, which is used to multiply the regularized input value by the convolution weight to obtain a unit input value.
[0019] The adding unit includes a carry-save adder and an adder, which is used to perform step-by-step addition operations on all unit input values to obtain unit accumulated values.
[0020] The accumulation unit includes an accumulator, which is used to accumulate all unit accumulation values to obtain an output value.
[0021] Furthermore, the addition unit includes a preprocessing layer, an intermediate layer and an output layer.
[0022] The preprocessing layer is used to select a corresponding carry-save adder according to the size of the convolution kernel, and group all unit input values according to the requirements of the carry-save adder on the input value; and to perform addition operations on the grouped unit input values through the carry-save adder, and output a first-level sum value and a first-level carry value; and to obtain a temporary value through an adder according to the first-level carry value and the first-level sum value.
[0023] The intermediate layer is used to use the temporarily stored value output by the previous layer as the input of the next layer, and perform step-by-step accumulation operations through the carry-save adder and the adder to obtain a unit accumulated value.
[0024] The output layer is used to transmit the unit accumulation value to the accumulation unit.
[0025] Furthermore, the register module includes a read array and a write array, the read array is used to provide parallel input values for the mapping module to perform bilinear interpolation, and the write array is used to store parallel input values, and the functions of the read array and the write array can be interchangeable.
[0026] Furthermore, the read array and the write array adopt ping-pong operation to achieve parallel processing of the reading action and the storage action.
[0027] Furthermore, the access parallel dimension of the register module is set to 36.
[0028] Furthermore, the control module includes a counter, and the counter is used to calculate the interpolation weight according to the decimal part.
[0029] In a second aspect, the present application also provides a deformable convolution acceleration method, which specifically includes:
[0030] The control module obtains the original input value, offset, quantization scale, mask and convolution weight through the software end.
[0031] The control module adds the base address and the offset to obtain the actual address, separates the actual address into an integer part and a decimal part, and transmits the integer part, the decimal part and the quantization scale to the mapping module; and also stores the original input value to the input cache module, stores the mask to the mask module, and caches the convolution weight to the weight cache module.
[0032] The mapping module obtains the actual address and the interpolation weight corresponding to the actual address according to the quantization scale, the integer part and the decimal part.
[0033] The control module obtains the corresponding original input value from the input buffer module according to the actual address, and transmits the original input value to the register module.
[0034] The register module converts the parallel dimension of the original input value and outputs the parallel input value.
[0035] The mapping module performs bilinear interpolation processing on the parallel input values and the interpolation weights to obtain real input values.
[0036] The mask module performs a product operation on the real input value and the mask to obtain a regularized input value.
[0037] The convolution module obtains the convolution weight of the weight cache module and the regularized input value of the mask module through the control module, performs convolution calculation according to the regularized input value and the convolution weight, obtains the output value, and saves the output value to the output cache module.
[0038] The control module controls the output buffer module to transmit the output value to the off-chip memory through the software end.
[0039] Furthermore, the register module includes a read array and a write array, and the specific method of converting the parallel dimension of the register module is:
[0040] The register module obtains the original input value in the input buffer module through the control module.
[0041] The control module sends a control signal to store the original input value into the write array of the register module.
[0042] The control module controls the mapping module to read the stored original input value from the read array of the register module to perform a bilinear interpolation operation.
[0043] When the write array is full of original input values and all original input values in the read array have been processed by the mapping module, the read array and the write array functions are interchanged.
[0044] Furthermore, the convolution module includes a multiplier, a carry-save adder, an adder and an accumulator, and the specific method of performing convolution calculation by the convolution module is:
[0045] The convolution weights of the weight cache module and the regularized input values of the mask module are obtained through the control module.
[0046] The convolution weight and the regularized input value are multiplied by a multiplier to obtain a unit input value.
[0047] Select the corresponding carry-save adder according to the convolution kernel size.
[0048] All single-bit input values are grouped according to the carry-save adder's input value requirements.
[0049] The grouped unit input values are added by a carry-save adder to output a first-level sum value and a first-level carry value.
[0050] The 2 times first level carry value and the first level sum value are summed up by an adder to obtain a first level temporary storage value.
[0051] All first-level temporary storage values are grouped according to the carry-save adder's input value requirements.
[0052] The grouped first-level temporary storage values are added through a carry-save adder to output a second-level sum value and a second-level carry value.
[0053] The 2 times second-level carry value and the second-level sum value are summed up by an adder to obtain a second-level temporary storage value.
[0054] The grouping and addition operations are repeated until a unit cumulative value is obtained.
[0055] All unit cumulative values are accumulated through the accumulator to obtain the output value.
[0056] The present application provides a deformable convolution accelerator and a deformable convolution acceleration method, which accelerate the original deformable convolution layer without making any adjustments to the algorithm. Instead, the original offset range is used, and the size of the offset is not limited, so as to maximize the accuracy of the original model. For irregular receptive fields, a mapping module is used to regularize them, and the operation rates of the mapping module and the convolution module are matched through the ping-pong operation of the register module, thereby improving the hardware utilization. At the same time, the present application does not need to store intermediate data off-chip, thereby reducing the access frequency to the off-chip storage structure. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the embodiments are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0058] Figure 1 A schematic diagram of the overall architecture of a deformable convolution accelerator provided in an embodiment of the present application;
[0059] Figure 2 A schematic diagram of the structure of a mapping module of a deformable convolution accelerator provided in an embodiment of the present application;
[0060] Figure 3 A schematic diagram of the register module structure of a deformable convolution accelerator provided in an embodiment of the present application;
[0061] Figure 4 A schematic diagram of the structure of an input cache module of a deformable convolution accelerator provided in an embodiment of the present application;
[0062] Figure 5 A schematic diagram of the convolution module structure of a deformable convolution accelerator provided in an embodiment of the present application;
[0063] Figure 6 A schematic diagram comparing the number of off-chip accesses provided in an embodiment of the present application;
[0064] Figure 7 A schematic diagram of a deformable convolution acceleration method flow provided in an embodiment of the present application. DETAILED DESCRIPTION
[0065] The following will be combined with the drawings in the embodiments of the present application to fully and clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0066] Field Programmable Gate Array (FPGA), as a semi-customized circuit in the field of Application Specific Integrated Circuit (ASIC), is a product further developed on the basis of programmable devices such as PAL, GAL, CPLD, etc. Due to the characteristics of FPGA with short development cycle, strong functions, high reliability and good confidentiality, there are endless designs for accelerating convolutional neural networks using FPGA. However, there is a lack of research on the application of FPGA in accelerating deformable convolutional neural networks. The embodiment of this application studies the deformable convolutional neural network accelerator based on the FPGA platform to make up for the shortcomings of the prior art.
[0067] See also Figure 1 , is a schematic diagram of the overall architecture of a deformable convolution accelerator provided in an embodiment of the present application. In a first aspect, an embodiment of the present application provides a deformable convolution accelerator, specifically comprising: a software end and a hardware end.
[0068] The software end is used to implement the overall architecture of the deformable convolution accelerator, and to load the original model parameters from the off-chip memory to the hardware end, wherein the original model parameters include the original input value, offset, quantization scale, mask and convolution weight; and to read the output value of the hardware end to the off-chip memory.
[0069] The hardware end includes:
[0070] A control module is used to obtain the original input value, offset, quantization scale, mask and convolution weight from the software end; and to obtain the actual address according to the base address and the offset, and separate the actual address into an integer part and a decimal part; it is also used to output a control signal to control the mapping module, the register module, the mask module, the convolution module, the input cache module, the output cache module and the weight cache module and the data interaction between the modules; and it is also used to transmit the output value to the software end.
[0071] Input cache module, used to store raw input values.
[0072] The register module is used to convert the access parallel dimension of the original input value, obtain the parallel input value, and store the parallel input value.
[0073] A mapping module is used to obtain an actual address and an interpolation weight corresponding to the actual address according to the quantization scale, the integer part and the decimal part; and to perform bilinear interpolation processing according to the parallel input value and the interpolation weight to obtain a real input value.
[0074] The mask module is used to store the mask and obtain a regularized input value according to the real input value and the mask.
[0075] Weight cache module, used to store convolution weights.
[0076] The convolution module is used to perform convolution calculations based on convolution weights and regularized input values to obtain output values.
[0077] The output cache module is used to store the output values calculated by the convolution module.
[0078] Compared with ordinary convolution layers, deformable convolution obtains irregularly shaped receptive fields by offsetting the input address, which can adapt to targets of different sizes and shapes, and therefore has important applications in target detection tasks. However, the offset address also leads to irregular memory access, and the use of traditional parallel strategies will lead to access conflicts. The embodiment of the present application is a hardware architecture design based on deformable convolution, and the calculation of deformable convolution is divided into two stages: the value acquisition stage and the convolution stage. In the value acquisition stage, the storage space is optimized to provide regularized access for convolution calculation, and the calculation of this stage is mainly completed by the mapping module; in the convolution stage, the convolution operation is performed according to the regularized input value obtained from the previous stage to obtain the output result. Compared with other hardware architectures, the embodiment of the present application realizes the acceleration of the original deformable convolution for the first time, greatly reducing energy consumption; and, the present application does not compress and regularize the receptive field, thereby retaining the original accuracy of the model to the maximum extent; at the same time, the optimization of the storage space reduces the access frequency to the off-chip storage space.
[0079] Specifically, in order to verify the feasibility of the solution in the embodiment of the present application, both the software end and the hardware end are verified using an FPGA platform.
[0080] Furthermore, the control module includes a counter, and the counter is used to calculate the interpolation weight according to the decimal part.
[0081] For details, see Figure 2 , a structural schematic diagram of a mapping module of a deformable convolution accelerator provided in an embodiment of the present application. The mapping module is represented as an array of feature map units, the number of which is represented by H. In the embodiment of the present application, the convolution kernel size is 3×3, and the number of feature map unit arrays is 9. In each feature map unit, the input X and Y are the integer parts of the horizontal and vertical coordinates of the actual address, and the actual address is obtained by adding the offset to the base address, and x and y are the decimal parts. For the quantized value, these two parts can be obtained by shifting the offset address through the quantization scale. According to the integer parts X and Y, the four adjacent values required for calculating bilinear interpolation are obtained on the feature map, and the coordinates of the four adjacent values are (X, Y), (X+1, Y), (X+1, Y+1) and (X, Y+1). According to the decimal parts x and y, the interpolation weights w1~w4 of the four adjacent values are calculated by the counter in the control module, and the coordinate values and the interpolation weights are multiplied and accumulated accordingly to obtain the value corresponding to the offset address, which is also the input value required for the convolution operation in the next stage.
[0082] In summary, the mapping stage obtains values on the feature map through the coordinates of the actual address, arranges them regularly, and provides them to the convolution calculation in the next stage.
[0083] Specifically, if the calculation of the convolution stage is started after the calculation of the value-taking stage is completely completed, it will cause a large delay. Therefore, in an embodiment of the present application, the calculation of the two stages is performed synchronously, and each value-taking address in the feature map is reused in the input dimension, and the value at the same position on the feature map but on different input channels is obtained at the same time. However, in the calculation of the next stage, the values at different positions on the same input channel need to be input at the same time. Due to the different dimensions of access, an embodiment of the present application sets a register module between the value-taking stage and the convolution stage to store intermediate data and convert the parallel dimension of the data.
[0084] Furthermore, the register module includes a read array and a write array, the read array is used to provide parallel input values for the mapping module to perform bilinear interpolation, and the write array is used to store parallel input values, and the functions of the read array and the write array can be interchangeable.
[0085] Furthermore, the read array and the write array adopt ping-pong operation to achieve parallel processing of the reading action and the storage action.
[0086] Furthermore, the access parallel dimension of the register module is set to 36.
[0087] See also Figure 3 , is a schematic diagram of the register module structure of a deformable convolution accelerator provided in an embodiment of the present application. Specifically, in order to prevent the access operations from affecting each other and the calculations of the two stages can be performed simultaneously, the register module adopts a ping-pong operation so that reading and writing can be performed simultaneously without interfering with each other. An address in the mapping module simultaneously takes values at the corresponding positions on multiple input channels and stores them in the write array of the register module, marked as w_1 to w_36. Since the size of the convolution kernel is 3×3, each bilinear interpolation operation requires 4 adjacent values to participate in the calculation. For each output value calculated by the convolution unit, 36 original input values in the input cache are required. Therefore, in the embodiment of the present application, the access parallel dimension of the register module is 36. When all the 36 addresses in the mapping module have taken the original input values and stored them in the register module, there are 36×36 original input values stored in the write array, from 36 input channels, and each input channel has 36 original input values. The read array also outputs 36 original input values each time, marked as r_1 to r_36. The original input values output at the same time have the same input channel. After 36 outputs, all the original input values are output to the mapping module, and after bilinear interpolation, they are reused by the convolution module on the output channel. When the write array is full, all the original input values in the read array have been used by the subsequent modules. At this time, the read array is exchanged with the write array.
[0088] To match the access scheme in the register module, the embodiment of the present application also adjusts the arrangement of the original input values in the input buffer module. The embodiment of the present application groups the original input values according to the input channels, and the number of groups is the same as the access parallel dimension of the register module.
[0089] For details, see Figure 4 , is a schematic diagram of the input cache module structure of a deformable convolution accelerator provided in an embodiment of the present application. C represents the input channel. The mapping module outputs an address to the input cache module each time, and the input cache module outputs the values of the corresponding positions of the 36 different input channels currently selected. After a set of addresses in the mapping module are taken, the selected input channel in the input cache module changes, and the black box represents the selected input channel, which moves in the direction of the arrow as shown in the figure.
[0090] Furthermore, the convolution module includes a multiplication unit, an addition unit and an accumulation unit.
[0091] The multiplication unit includes a multiplier, which is used to multiply the regularized input value by the convolution weight to obtain a unit input value.
[0092] The adding unit includes a carry-save adder and an adder, which is used to perform step-by-step addition operations on all unit input values to obtain unit accumulated values.
[0093] The accumulation unit includes an accumulator, which is used to accumulate all unit accumulation values to obtain an output value.
[0094] The Carry Save Adder (CSA) has a very small carry propagation delay when performing multiple number additions. Its basic idea is to reduce the sum of three addends to the sum of two addends, calculate and save the carry value and the sum value separately, and each bit can calculate the carry value and the sum value independently, so the speed is extremely fast, and it can reduce the number of accumulations and shorten the critical path.
[0095] Specifically, when using Verilog to design an equation, such as Sum=A+B+C+D, you can design a full adder, which consists of an N-bit CSA structure to merge multiple numbers. After passing through two stages of CSA, the carry value and the sum value are finally added through an adder. Note that when the carry is passed to any module, the carry value needs to be multiplied by 2 because this is the actual value after it is merged.
[0096] Furthermore, the addition unit includes a preprocessing layer, an intermediate layer and an output layer.
[0097] The preprocessing layer is used to select a corresponding carry-save adder according to the size of the convolution kernel, and group all unit input values according to the requirements of the carry-save adder on the input value; and to perform addition operations on the grouped unit input values through the carry-save adder, and output a first-level sum value and a first-level carry value; and to obtain a temporary value through an adder according to the first-level carry value and the first-level sum value.
[0098] The intermediate layer is used to use the temporarily stored value output by the previous layer as the input of the next layer, and perform step-by-step accumulation operations through the carry-save adder and the adder to obtain a unit accumulated value.
[0099] The output layer is used to transmit the unit accumulated value to the accumulator.
[0100] Specifically, in the calculation of the second stage, the embodiment of the present application designs a convolution array dedicated to convolution calculation. Figure 5 , a schematic diagram of the convolution module structure of a deformable convolution accelerator provided in an embodiment of the present application. The parallel dimension of the output channel is N, which can be changed according to the scale of the design. In some embodiments of the present application, N is set to 32. Each convolution calculation unit is responsible for the convolution calculation of an output channel, and the weights input at the same time have the same input channel and different output channels. The offset values calculated in the previous stage are reused by different output channels. Among them, w1 to w9 are the input weight values, and v1 to v9 are the input values taken by the mapping module in the calculation of the previous stage. Since the convolution kernel size of the embodiment of the present application is 3×3, the regularized inputs of the same size are taken and multiplied accordingly. In order to shorten the shortest path and simplify the calculation at the same time, instead of directly accumulating 9 results, 3 results are grouped together and calculated using a carry-save adder. The three results obtained are then added using a first-level carry adder. The two-level carry adder can calculate the accumulated value of 9 values to obtain the output of the current position of the current input channel.
[0101] Since each convolution calculation unit is responsible for the calculation of an output channel, the output result of each convolution calculation unit is accumulated through the accumulator in the input channel dimension to obtain the output value of the current position in the corresponding output channel.
[0102] The embodiment of the present application provides a deformable convolution accelerator, which regularizes the data access of the convolution calculation in the second stage through the mapping operation in the first stage, solves the problem of access conflict, and enables the architecture to achieve large-scale parallelism; the present application also designs a register module to match the processing rates of the two stages to improve hardware utilization. The register module changes the parallel dimension of access, and cooperates with the storage optimization of the input cache, so that the storage space requirement does not increase significantly under parallel operation, thereby reducing the number of off-chip memory accesses of the system; the present application does not compress and regularize the receptive field, and maximizes the retention of the accuracy of the original model.
[0103] The following will describe in detail a deformable convolution accelerator and method provided in an embodiment of the present application through specific examples.
[0104] As can be seen from Table 1, compared with the prior art, the accuracy of the embodiment of the present application on the COCO dataset is closer to that of the original model. The embodiment of the present application does not compress or regularize the receptive field, but accelerates the original deformable convolution layer, thus retaining the accuracy of the original model to the maximum extent.
[0105] Table 1 Accuracy comparison table on COCO dataset
[0106]
[0107] It can be seen from Table 2 that the embodiment of the present application occupies less on-board resources.
[0108] Table 2 Resource occupancy table
[0109]
[0110] It can be seen from Table 3 that, compared with the GPU, the embodiment of the present application greatly improves the energy efficiency ratio.
[0111] Table 3 Energy consumption comparison table
[0112]
[0113]
[0114] See also Figure 6 , is a schematic diagram comparing the number of off-chip accesses provided by an embodiment of the present application, where S represents the size of the input, specifically the side length, and N represents the number of input channels. As can be seen from the figure, compared with the DCL accelerator in the prior art, the deformable convolution accelerator provided by the embodiment of the present application greatly reduces the number of accesses to the off-chip memory structure.
[0115] In summary, the deformable convolution accelerator described in the embodiment of the present application has the following characteristics:
[0116] (1) The embodiment of the present application designs a mapping module to complete the irregular value operation of the deformable convolution, regularizes the access in the convolution stage, and solves the access conflict; uses a register module to match the calculation rate of the two stages to improve hardware utilization; and also changes the parallel dimension of data access to reduce the storage space requirement.
[0117] (2) The computing module designed in the embodiment of the present application constructs an accelerator architecture for original deformable convolution calculations without modifying the original algorithm, thereby retaining the accuracy of the original model to the maximum extent.
[0118] (3) The embodiment of the present application is implemented based on an FPGA platform and can achieve 200MHz, 126.32GOPS. The energy efficiency on the FPGA is 50.33GOPS / W, which is 2.5 times higher than that of the GPU. In addition, compared with the prior art, the embodiment of the present application significantly reduces the number of accesses to the off-chip memory.
[0119] See also Figure 7 , which is a flow chart of a deformable convolution acceleration method provided in an embodiment of the present application. The second aspect of the embodiment of the present application provides a deformable convolution acceleration method for guiding the operation of a deformable convolution accelerator provided in the first aspect of the embodiment of the present application. For details not disclosed in the deformable convolution acceleration method provided in the second aspect of the embodiment of the present application, please refer to the deformable convolution accelerator provided in the first aspect of the embodiment of the present application.
[0120] The deformable convolution acceleration method specifically includes:
[0121] The control module obtains the original input value, offset, quantization scale, mask and convolution weight through the software end.
[0122] The control module adds the base address and the offset to obtain the actual address, separates the actual address into an integer part and a decimal part, and transmits the integer part, the decimal part and the quantization scale to the mapping module; and also stores the original input value to the input cache module, stores the mask to the mask module, and caches the convolution weight to the weight cache module.
[0123] The mapping module obtains the actual address and the interpolation weight corresponding to the actual address according to the quantization scale, the integer part and the decimal part.
[0124] The control module obtains the corresponding original input value from the input buffer module according to the actual address, and transmits the original input value to the register module.
[0125] The register module converts the parallel dimension of the original input value and outputs the parallel input value.
[0126] The mapping module performs bilinear interpolation processing on the parallel input values and the interpolation weights to obtain real input values.
[0127] The mask module performs a product operation on the real input value and the mask to obtain a regularized input value.
[0128] The convolution module obtains the convolution weight of the weight cache module and the regularized input value of the mask module through the control module, performs convolution calculation according to the regularized input value and the convolution weight, obtains the output value, and saves the output value to the output cache module.
[0129] The control module controls the output buffer module to transmit the output value to the off-chip memory through the software end.
[0130] Furthermore, the register module includes a read array and a write array, and the specific method of converting the parallel dimension of the register module is:
[0131] The register module obtains the original input value in the input buffer module through the control module.
[0132] The control module sends a control signal to store the original input value into the write array of the register module.
[0133] The control module controls the mapping module to read the stored original input value from the read array of the register module to perform a bilinear interpolation operation.
[0134] When the write array is full of original input values and all original input values in the read array have been processed by the mapping module, the read array and the write array functions are interchanged.
[0135] Furthermore, the convolution module includes a multiplier, a carry-save adder, an adder and an accumulator, and the specific method of performing convolution calculation by the convolution module is:
[0136] The convolution weights of the weight cache module and the regularized input values of the mask module are obtained through the control module.
[0137] The convolution weight and the regularized input value are multiplied by a multiplier to obtain a unit input value.
[0138] Select the corresponding carry-save adder according to the convolution kernel size.
[0139] All single-bit input values are grouped according to the carry-save adder's input value requirements.
[0140] The grouped unit input values are added by a carry-save adder to output a first-level sum value and a first-level carry value.
[0141] The 2 times first level carry value and the first level sum value are summed up by an adder to obtain a first level temporary storage value.
[0142] All first-level temporary storage values are grouped according to the carry-save adder's input value requirements.
[0143] The grouped first-level temporary storage values are added through a carry-save adder to output a second-level sum value and a second-level carry value.
[0144] The 2 times second-level carry value and the second-level sum value are summed up by an adder to obtain a second-level temporary storage value.
[0145] The grouping and addition operations are repeated until a unit cumulative value is obtained.
[0146] All unit cumulative values are accumulated through the accumulator to obtain the output value.
[0147] For details, see Figure 5 For a 3×3 convolution kernel and an input at a certain position, the weights in the convolution kernel are first multiplied by the input, and the 9 temporary stored values are added in groups of 3 using a carry-save adder. After obtaining 3 accumulated values, the carry-save adder is used to perform the accumulation operation again to obtain the output value.
[0148] It can be seen from the above technical solution that the present application provides a deformable convolution accelerator and a deformable convolution accelerator method, which accelerate the original deformable convolution layer without making any adjustments to the algorithm. Instead, the original offset range is used, and the size of the offset is not limited, thereby maximizing the accuracy of the original model; for irregular receptive fields, a mapping module is used to regularize them, and the operating rates of the mapping module and the convolution module are matched through the ping-pong operation of the register module, thereby improving hardware utilization; at the same time, the present application does not need to store intermediate data off-chip, thereby reducing the frequency of access to off-chip storage structures.
[0149] The present application is described in detail above in conjunction with specific implementation methods and exemplary examples, but these descriptions cannot be understood as limiting the present application. Those skilled in the art understand that, without departing from the spirit and scope of the present application, a variety of equivalent replacements, modifications or improvements can be made to the technical solution of the present application and its implementation methods, all of which fall within the scope of the present application. The scope of protection of the present application shall be subject to the attached claims.
Claims
1. A deformable convolution accelerator, characterized in that: Including software and hardware; The software end is used to implement the overall architecture of the deformable convolution accelerator and to load original model parameters from an off-chip memory to a hardware end, wherein the original model parameters include original input values, offsets, quantization scales, masks, and convolution weights; It is also used to read the output value of the hardware end into the off-chip memory; The hardware end includes: A control module, used to obtain the original input value, offset, quantization scale, mask and convolution weight from the software end; and used to obtain the actual address according to the base address and the offset, and separate the actual address into an integer part and a decimal part; and also used to output a control signal to control the mapping module, the register module, the mask module, the convolution module, the input cache module, the output cache module and the weight cache module and the data interaction between the modules; and also used to transmit the output value to the software end; Input cache module, used to store original input values; A register module, used for converting the access parallel dimension of the original input value, obtaining the parallel input value, and storing the parallel input value; A mapping module, used to obtain an actual address and an interpolation weight corresponding to the actual address according to the quantization scale, the integer part and the decimal part; and used to perform bilinear interpolation processing according to the parallel input value and the interpolation weight to obtain a real input value; A mask module, used to store the mask and obtain a regularized input value according to the real input value and the mask; Weight cache module, used to store convolution weights; The convolution module is used to perform convolution calculations based on the convolution weights and regularized input values to obtain output values; Output cache module, used to store the output values calculated by the convolution module; The register module includes a read array and a write array, the read array is used to provide parallel input values for the mapping module to perform bilinear interpolation, and the write array is used to store parallel input values. The functions of the read array and the write array can be interchangeable; the read array and the write array use ping-pong operation to realize parallel processing of reading actions and storage actions.
2. A deformable convolution accelerator according to claim 1, characterized in that: The convolution module includes a multiplication unit, an addition unit and an accumulation unit; The multiplication unit includes a multiplier configured to multiply the regularized input value by the convolution weight to obtain a unit input value; The adding unit includes a carry-save adder and an adder, which is used to perform step-by-step addition operations on all unit input values to obtain unit accumulated values; The accumulation unit includes an accumulator, which is used to accumulate all unit accumulation values to obtain an output value.
3. A deformable convolution accelerator according to claim 2, characterized in that: The addition unit includes a preprocessing layer, an intermediate layer and an output layer; The preprocessing layer is used to select a corresponding carry-save adder according to the size of the convolution kernel, and group all unit input values according to the requirements of the carry-save adder on the input value; and for performing an addition operation on the grouped unit input values through a carry-save adder, and outputting a first-level sum value and a first-level carry value; It is also used to obtain a temporary storage value through an adder according to the first-level carry value and the first-level sum value; The intermediate layer is used to use the temporarily stored value output by the previous layer as the input of the next layer, and perform step-by-step accumulation operation through the carry-save adder and the adder to obtain a unit accumulated value; The output layer is used to transmit the unit accumulated value to the accumulator.
4. The deformable convolution accelerator according to claim 3, characterized in that: The access parallel dimension of the register module is set to 36.
5. The deformable convolution accelerator according to claim 1, characterized in that: The control module includes a counter, and the counter is used to calculate and obtain the interpolation weight according to the decimal part.
6. A deformable convolution acceleration method, characterized in that: The deformable convolution acceleration method is applied to a deformable convolution accelerator according to any one of claims 1 to 5, comprising: The control module obtains the original input value, offset, quantization scale, mask and convolution weight through the software end; The control module adds the base address and the offset to obtain an actual address, separates the actual address into an integer part and a decimal part, and transmits the integer part, the decimal part and the quantization scale to the mapping module; and also stores the original input value to the input cache module, stores the mask to the mask module, and caches the convolution weight to the weight cache module; A mapping module obtains an actual address and an interpolation weight corresponding to the actual address according to the quantization scale, the integer part and the decimal part; The control module obtains the corresponding original input value from the input buffer module according to the actual address, and transmits the original input value to the register module; The register module converts the parallel dimension of the original input value and outputs the parallel input value; The mapping module performs bilinear interpolation processing on the parallel input values and the interpolation weights to obtain a real input value; The mask module performs a product operation on the real input value and the mask to obtain a regularized input value; The convolution module obtains the convolution weight of the weight cache module and the regularized input value of the mask module through the control module, performs convolution calculation according to the regularized input value and the convolution weight, obtains the output value, and saves the output value to the output cache module; The control module controls the output buffer module to transmit the output value to the off-chip memory through the software end; The register module includes a read array and a write array, the read array is used to provide parallel input values for the mapping module to perform bilinear interpolation, and the write array is used to store parallel input values. The functions of the read array and the write array can be interchangeable; the read array and the write array use ping-pong operation to realize parallel processing of reading actions and storage actions.
7. A deformable convolution acceleration method according to claim 6, characterized in that: The specific method of converting the parallel dimension of the register module is: The register module obtains the original input value in the input buffer module through the control module; The control module sends a control signal to store the original input value into the write array of the register module; The control module controls the mapping module to read the stored original input value from the read array of the register module to perform a bilinear interpolation operation; When the write array is full of original input values and all original input values in the read array have been processed by the mapping module, the read array and the write array functions are interchanged.
8. The deformable convolution acceleration method according to claim 6, characterized in that: The convolution module includes a multiplier, a carry-save adder, an adder and an accumulator. The specific method of performing convolution calculation in the convolution module is as follows: Obtain the convolution weights of the weight cache module and the regularized input values of the mask module through the control module; Multiplying the convolution weight and the regularized input value by a multiplier to obtain a unit input value; Select the corresponding carry-save adder according to the convolution kernel size; All single-bit input values are grouped according to the carry-save adder's input value requirements; Performing addition operation on the grouped unit input values through a carry-save adder, outputting a first-level sum value and a first-level carry value; The adder is used to sum the double first-level carry value and the first-level sum value to obtain a first-level temporary storage value; All first-level temporary storage values are grouped according to the carry-save adder's input value requirements; Performing addition operation on the grouped first-level temporary storage values through a carry-save adder, and outputting a second-level sum value and a second-level carry value; The 2 times second level carry value and the second level sum value are summed by an adder to obtain a second level temporary storage value; By repeatedly performing the grouping and addition operations until a unit cumulative value is obtained; All unit cumulative values are accumulated through the accumulator to obtain the output value.
Citation Information
Patent Citations
Hardware architecture of binary weight convolution neural network accelerator and calculation process thereof
CN106875011A
Convolutional neural network acceleration method and apparatus
CN108133270A
Convolution acceleration method, convolution calculation processing method, devices, electronic apparatus and storage medium
CN108229645A
An FPGA parallel system of convolution neural network algorithm
CN109032781A
Deformable convolutional network based on deep learning
CN110197255A
