Convolution accelerator adaptive to MobileNet neural network

By designing a convolution accelerator adapted to MobileNet neural network, the technical difficulty of supporting multiple convolution mode calculations on FPGA is solved, hardware resources are reduced and processing speed is improved, and parallelism of conventional, PW and DW convolution modes is supported. implement.

CN118519612APending Publication Date: 2024-08-20WUYI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410642464.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-08-20

AI Technical Summary

Technical Problem

Supporting the calculation of multiple convolution modes on FPGA has technical difficulties for MobileNet neural network, which is difficult to meet the needs of limited on-chip logic and storage resources, resulting in high hardware resource usage and slow processing speed.

Method used

A convolution accelerator adapted to MobileNet neural network is designed, including an input image control module, an input weight control module, an output image control module, a data flow control module and a MAC calculation module. It generates relevant control signals through configuration information, caches data and Perform convolution calculations, support regular, PW and DW convolution modes, share the 16x16 convolution calculation unit, and perform slicing processing on the number of input channels and the number of output channels.

Benefits of technology

It reduces hardware resource usage, improves the processing speed of the MobileNet model, supports parallel execution of multiple convolution modes, and improves computing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118519612A_ABST
    Figure CN118519612A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a convolution accelerator adaptive to a Mobi leNet neural network. Comprising the following steps: parameter configuration: configuring a convolution channel number, a convolution kernel size, steps, an input image size, a convolution mode and the like; the input image control module, the input weight control module and the output image control module are used for generating external read-write address, data and other signals, receiving data of an external memory and writing back a processed result; the data flow control module is used for recombining the input image and the input weight according to parameter configuration and sending the input image and the input weight into the MAC calculation module for convolution; the MAC calculation module is used for receiving the data of the multiple input channels and the multiple output channels and performing convolution calculation; and the accumulation module is used for accumulating the convolution kernel and the multi-channel calculation result. Compared with a single-mode convolution FPGA accelerator, a large number of hardware resources are saved, and the problem of inflexible structure is effectively avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of edge computing technology, and in particular to a convolution accelerator adapted to a MobileNet neural network. Background Art

[0002] The release of AlexNet in 2012 ushered in a breakthrough in artificial intelligence (AI) and led to a surge in deep learning research. With the continuous development of deep learning technology, convolutional neural networks (CNNs) such as MobileNet have been widely used in various fields, such as computer vision and image classification. However, as the actual application scenarios become more and more complex, especially in the actual application scenarios with high requirements for high real-time performance and low cost, the requirements for convolution hardware computing power are also higher.

[0003] FPGA is widely used in edge acceleration due to its high performance, high reliability and parallel processing advantages. In the MobileNet network, convolution calculation basically runs through the entire process. The traditional CPU and GPU calculation speed is relatively slow and the high performance of CPU and GPU requires a lot of power consumption support. Therefore, using FPGA acceleration can greatly improve the calculation speed of the model and reduce power consumption.

[0004] There are many convolutional calculation methods involved in current convolutional neural networks, such as the size of the convolution kernel, the size of the moving step, and whether to fill the combination. In particular, there are three convolution modes for the MobileNet network. If it is necessary to design and implement a framework for each combination of convolution calculations, this will be difficult to meet for FPGAs with limited on-chip logic and storage resources. Therefore, there are certain technical difficulties in supporting calculations of multiple convolution modes on FPGAs in the MobileNet neural network. How to reduce hardware resources and increase the processing speed of the MobileNet model has become a technical problem that needs to be solved urgently. Summary of the invention

[0005] The embodiment of the present invention provides a convolution accelerator adapted to the MobileNet neural network, which can reduce hardware resources and improve the processing speed of the MobileNet model.

[0006] In a first aspect, an embodiment of the present invention provides a convolution accelerator adapted to a MobileNet neural network, including:

[0007] An input image control module is used to generate an off-chip memory read-related control signal according to first configuration information, and cache off-chip memory data, waiting for the data flow control module to read it, wherein the first configuration information includes the number of input channels, the number of output channels, the input image size, the convolution kernel size, the step, and whether the input image is filled;

[0008] An input weight control module is used to generate an off-chip memory read-related control signal according to second configuration information, and cache off-chip memory data, waiting for the data flow control module to read it, wherein the second configuration information includes the number of input channels, the number of output channels, the convolution kernel size, and whether it is a deep convolution mode;

[0009] An output image control module is used to generate an off-chip memory write-related control signal according to third configuration information to write the on-chip memory data into the off-chip memory, wherein the third configuration information includes the number of output channels, the convolution kernel size, the step, the input image size, and whether to fill;

[0010] A data flow control module, used to read 16 channel data from the input image control module and 16 channel data of 16 convolution kernels from the input weight control module in sequence according to the fourth configuration information, and transmit the data to the MAC calculation unit;

[0011] The MAC calculation module is used to receive the data from the data flow control module, and to map the 16 channel data of the input image to all the horizontal calculation units, and to map the 16 channel data of the Nth convolution kernel to the Nth row of horizontal calculation units by analogy; all the horizontal calculation units perform convolution calculations, and accumulate the outputs in the horizontal calculation units to obtain the output data of one channel; if it is a DW convolution, there is no need to perform accumulation calculations, and the calculation results of the MAC array diagonally are output;

[0012] The accumulation module is used to cache the data of the MAC calculation module and accumulate the accumulation result of the input channel data and the number of convolution kernels.

[0013] In some embodiments, the MAC calculation module is composed of 16x16 multipliers and a 4-stage pipelined adder tree.

[0014] In some embodiments, the convolution accelerator supports conventional convolution, PW convolution and DW convolution. For the conventional convolution and the PW convolution, it supports parallel execution of 16 input channels and 16 output channels at the same time; for the DW convolution, it supports parallel execution of 16 output channels at the same time, and the conventional convolution, the PW convolution and the DW convolution share a 16x16 convolution calculation unit; if the number of input channels or the number of output channels is greater than the supported parallel number, the number of input channels and the number of output channels are sliced.

[0015] In some embodiments, when the data flow control module outputs data, when the image needs to be filled, it is determined whether the horizontal and vertical coordinates of the current image output are in the filling position. If so, 0 is output; if not, normal output is performed.

[0016] In some embodiments, the cumulative number of times of the accumulation module C=A1*B1, wherein A1 is the number of convolution kernels, B1 is the number of input channel slices, and the number of input channel slices=the number of input channels / the number of parallel channel executions supported.

[0017] In some embodiments, the channel data is arranged in W×C1×H×C2, where W is the horizontal coordinate number of the image, C1 is the 16-channel number of the corresponding coordinate, H is the vertical coordinate number of the image, and C2 is the input channel slice number.

[0018] In some embodiments, the input image control module applies for on-chip memory amount = A3×B3×C3×D3 (bit), wherein A3 is the number of loopback buffers, B3 is the maximum number of input images, C3 is the number of input channels, and D3 is the single data bit width; the input weight control module applies for on-chip memory amount = A3×B3×C3×D3 (bit), wherein A3 is the number of loopback buffers, B3 is the maximum number of convolution kernel parameters, C3 is the number of input channels, and D3 is the single data bit width.

[0019] In some embodiments, the input image control module executes a first layer loop, and the number of loops = 16 / (A4 / B4), where A4 is the input data bit width of the external memory, and B4 is the image data bit width; the input image control module executes a second layer loop, and the number of loops = the number of times the convolution kernel moves on the horizontal axis of the image; the input image control module executes a third layer loop, and the number of loops = the number of times the convolution kernel moves on the vertical axis of the image; the input image control module executes a fourth layer loop, and the number of loops = the number of convolution kernel parameters; the input image control module executes a fifth layer loop, and the number of loops = the number of image input channel blocks; the input image control module executes a sixth layer loop, and the number of loops = the number of image output channel blocks.

[0020] In some embodiments, the input weight control module executes a first layer loop, and the number of loops = 16 / (A4 / B4), where A4 is the input data bit width of the external memory, and B4 is the image data bit width. If it is a DW convolution, the first layer loop is skipped; the input weight control module executes a second layer loop, and the number of loops = the number of times the convolution kernel moves on the horizontal axis of the image; the input weight control module executes a third layer loop, and the number of loops = the number of times the convolution kernel moves on the vertical axis of the image; the input weight control module executes a fourth layer loop, and the number of loops = the number of convolution kernel parameters; the input weight control module executes a fifth layer loop, and the number of loops = the number of image input channel blocks; the input weight control module executes a sixth layer loop, and the number of loops = the number of image output channel blocks.

[0021] In some embodiments, the data flow control module loads 16 channels of data of 16 convolution kernels, and the number of loads is the size of the convolution kernel parameters. When the loading is completed, the data flow control module executes the first layer loop and the second layer loop, and the number of loops = the number of times the convolution kernel moves on the horizontal axis of the image x the number of times the convolution kernel image moves on the vertical axis; the data flow control module executes the third layer loop, and the number of loops = the number of convolution kernel parameters; the data flow control module executes the fourth layer loop and the fifth layer loop, and the number of loops = the number of input channel blocks × the number of output channel blocks.

[0022] According to an embodiment of the present invention, a convolution accelerator adapted to a MobileNet neural network is provided, wherein the convolution accelerator adapted to a MobileNet neural network includes: an input image control module, which is used to generate an off-chip memory read-related control signal according to first configuration information, and cache the off-chip memory data, waiting for the data flow control module to read, wherein the first configuration information includes the number of input channels, the number of output channels, the input image size, the convolution kernel size, the pace, and whether the input image is filled; an input weight control module, which is used to generate an off-chip memory read-related control signal according to second configuration information, and cache the off-chip memory data, waiting for the data flow control module to read, wherein the second configuration information includes the number of input channels, the number of output channels, the convolution kernel size, and whether it is a deep convolution mode; an output image control module, which is used to generate an off-chip memory write-related control signal according to third configuration information, and write the on-chip memory data into the off-chip memory, wherein the third The configuration information includes the number of output channels, the size of the convolution kernel, the pace, the size of the input image, and whether it is filled; the data flow control module is used to read 16 channel data from the input image control module in sequence according to the fourth configuration information, and read the 16 channel data of the 16 convolution kernels from the input weight control module, and transmit them to the MAC calculation unit; the MAC calculation module is used to receive the data of the data flow control module, and the 16 channel data of the input image is sent to all the horizontal calculation units, and the 16 channel data of the Nth convolution kernel is mapped to the Nth row of horizontal calculation units by analogy; all the horizontal calculation units perform convolution calculations, and accumulate the outputs in the horizontal calculation units to obtain the output data of one channel; if it is a DW convolution, there is no need to perform accumulation calculations, and the MAC array diagonal calculation results are output; the accumulation module is used to cache the data of the MAC calculation module, and accumulate the accumulation results of the input channel data and the number of convolution kernels. Based on this, the convolution accelerator adapted to the MobileNet neural network provided by the embodiment of the present invention can reduce hardware resources and improve the processing speed of the MobileNet model compared with the existing single-mode convolution FPGA accelerator. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1It is a schematic diagram of the structure of a convolution accelerator adapted to a MobileNet neural network provided by an embodiment of the present invention;

[0024] Figure 2 is a schematic diagram of an arrangement method of input image data provided by an embodiment of the present invention;

[0025] Figure 3 is an execution flow chart of an input image control module provided by an embodiment of the present invention;

[0026] Figure 4 is an execution flow chart of an input weight control module provided by an embodiment of the present invention;

[0027] Figure 5 is a data flow control module execution flow chart provided by an embodiment of the present invention;

[0028] Figure 6 It is a flowchart of the execution of the accumulation module provided by one embodiment of the present invention. DETAILED DESCRIPTION

[0029] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0030] In the embodiments of the present invention, the words "further", "exemplarily" or "optionally" are used to indicate examples, illustrations or descriptions, and should not be interpreted as being more preferred or more advantageous than other embodiments or designs. The use of the words "further", "exemplarily" or "optionally" is intended to present related concepts in a specific way.

[0031] In order to more conveniently describe the working principle of the embodiment of the present invention later, an introduction to relevant technical scenarios is first given below.

[0032] The release of AlexNet in 2012 ushered in a breakthrough in artificial intelligence (AI) and led to a surge in deep learning research. With the continuous development of deep learning technology, convolutional neural networks (CNNs) such as MobileNet have been widely used in various fields, such as computer vision and image classification. However, as the actual application scenarios become more and more complex, especially in the actual application scenarios with high requirements for high real-time performance and low cost, the requirements for convolution hardware computing power are also higher.

[0033] FPGA is widely used in edge acceleration due to its high performance, high reliability and parallel processing advantages. In the MobileNet network, convolution calculation basically runs through the entire process. The traditional CPU and GPU calculation speed is relatively slow and the high performance of CPU and GPU requires a lot of power consumption support. Therefore, using FPGA acceleration can greatly improve the calculation speed of the model and reduce power consumption.

[0034] There are many convolutional calculation methods involved in current convolutional neural networks, such as the size of the convolution kernel, the size of the moving step, and whether to fill the combination. In particular, there are three convolution modes for the MobileNet network. If it is necessary to design and implement a framework for each combination of convolution calculations, this will be difficult to meet for FPGAs with limited on-chip logic and storage resources. Therefore, there are certain technical difficulties in supporting calculations of multiple convolution modes on FPGAs in the MobileNet neural network. How to reduce hardware resources and increase the processing speed of the MobileNet model has become a technical problem that needs to be solved urgently.

[0035] Based on this, the present invention provides a convolution accelerator adapted to the MobileNet neural network. Among them, the convolution accelerator adapted to the MobileNet neural network includes: an input image control module, which is used to generate an off-chip memory read-related control signal according to the first configuration information, and cache the off-chip memory data, waiting for the data flow control module to read, wherein the first configuration information includes the number of input channels, the number of output channels, the input image size, the convolution kernel size, the pace, and whether the input image is filled; an input weight control module, which is used to generate an off-chip memory read-related control signal according to the second configuration information, and cache the off-chip memory data, waiting for the data flow control module to read, wherein the second configuration information includes the number of input channels, the number of output channels, the convolution kernel size, and whether it is a deep convolution mode; an output image control module, which is used to generate an off-chip memory write-related control signal according to the third configuration information, and write the on-chip memory data to the off-chip memory, wherein the third configuration information includes the number of output channels, the convolution kernel size, the speed, and whether the input image is filled. The size, step, input image size and whether to fill; the data flow control module is used to read 16 channel data from the input image control module in sequence according to the fourth configuration information, and read the 16 channel data of 16 convolution kernels from the input weight control module, and transmit them to the MAC calculation unit; the MAC calculation module is used to receive the data of the data flow control module, and the 16 channel data of the input image is sent to all the horizontal calculation units, and the 16 channel data of the Nth convolution kernel is mapped to the Nth row of horizontal calculation units by analogy; all the horizontal calculation units perform convolution calculations, and accumulate the outputs in the horizontal calculation units to obtain the output data of one channel; if it is a DW convolution, there is no need to perform accumulation calculations, and the MAC array diagonal calculation results are output; the accumulation module is used to cache the data of the MAC calculation module, and accumulate the accumulation results of the input channel data and the number of convolution kernels. Based on this, the convolution accelerator adapted to the MobileNet neural network provided by the embodiment of the present invention can reduce hardware resources and improve the processing speed of the MobileNet model compared with the existing single-mode convolution FPGA accelerator.

[0036] The embodiments of the present invention are further described below in conjunction with the accompanying drawings.

[0037] like Figure 1 As shown, Figure 1 It is a schematic diagram of the structure of a convolution accelerator adapted to the MobileNet neural network provided by an embodiment of the present invention.

[0038] The input image control module is used to generate off-chip memory read-related control signals according to the configuration information, namely the number of input and output channels, the input image size, the convolution kernel size, the pace, and whether the input image is filled, and cache the off-chip memory data, waiting for the data flow control module to read it.

[0039] The input weight control module is used to generate off-chip memory read-related control signals according to the configuration information, namely the number of input and output channels, the size of the convolution kernel, and whether it is a deep convolution mode, and cache the off-chip memory data, waiting for the data flow control module to read it.

[0040] The output image control module is used to generate off-chip memory write-related control signals according to the configuration information, namely the number of output channels, the input image size and whether it is filled, the convolution kernel size and the pace, and write the on-chip memory data into the off-chip memory.

[0041] The data flow control module is used to read 16 channel data from the input image cache and 16 channel data of 16 convolution kernels from the input weight buffer in sequence according to the configuration information, and transmit them to the MAC computing unit.

[0042] The MAC calculation module is used to receive data flow control data, and send the 16 channel data of the input image to all horizontal calculation units. The 16 channel data of the first convolution kernel is mapped to the first row of horizontal calculation units, and the 16 channel data of the second convolution kernel is mapped to the second row of horizontal calculation units, and so on. All calculation units perform convolution calculations and accumulate the outputs in the horizontal direction to obtain the output data of one channel. If it is a DW convolution, there is no need to perform accumulation calculations, and the calculation results of the MAC array diagonally are output.

[0043] The accumulation module is used to cache the data of the MAC calculation module and accumulate the accumulation results of the previous input channels and the number of convolution kernels. For the input image with 32 channels and the convolution kernel size of 3×3×32, the number of accumulation modules = (32÷16)×(3×3).

[0044] The present invention has the following characteristics:

[0045] Configurable parameters: support for the conventional 1 and 2 steps; support for the convolution kernel size of 1×1, 3×3; whether the image is padded; the convolution mode supports conventional, PW, DW convolution; the input image size buffer can set the maximum value according to the hardware resources.

[0046] For conventional and PW convolution, 16 input channels and 16 output channels are supported for parallel execution. For DW convolution, 16 output channels are supported for parallel execution. The three types of convolution share the 16x16 convolution calculation unit. If the number of input channels or output channels is greater than the supported parallel number, the input channels and output channels are sliced.

[0047] When the data stream outputs data, if the image needs to be filled, determine whether the horizontal and vertical coordinates of the current image output are in the filling position. When it is the filling position, output 0, otherwise output normally, so as to achieve the purpose of filling. For example, if the convolution kernel size is 3×3, the input image size is 64×64 and filled, according to the convolution calculation formula, the filling size is 1, and the image is filled, the size is 66×66. When the vertical coordinate points are 0 and 65, and the horizontal coordinate points are 0 and 65, output 0, and the rest remain unchanged.

[0048] For the accumulation module, the number of accumulations C = A*B. A is the number of convolution kernels, B is the number of input channel slices, and the number of input channel slices = the number of input channels / the number of parallel channels supported (16). For example, if the convolution kernel size is 3x3 and the input channel is 32, then A = 9, B = 32 / 16, and therefore C = 9×2 = 18.

[0049] In an embodiment of the present invention, the data is arranged in W×C1×H×C2. W is the horizontal coordinate number of the image, C1 is the 16-channel number of the corresponding coordinate, H is the vertical coordinate number of the image, and C2 is the input channel slice number. For example, for an input image of 64×64×32, it is obvious that the input channel slice is 2. The first 16 channel data at the horizontal coordinate position (0,0) are arranged first, followed by the first 16 channel data at the horizontal coordinate position (0,1), and so on until the end of the horizontal coordinate, and then the vertical coordinate data is arranged. When the W×C1×H arrangement ends, continue to arrange the last 16 channels of WxC1xH data. For data with less than 16 channels, fill in 0 for alignment.

[0050] The convolution accelerator of the present invention receives multi-channel data from an input image and multiple convolution kernel parameters for convolution calculation. In addition to supporting conventional convolution, it also supports point-by-point convolution (PW) convolution and channel-by-channel convolution (DW) convolution. The convolution accelerator of the present invention includes an input image control module, an input weight control module, an output image control module, a data flow control module, a MAC calculation module, and an accumulation module, wherein the MAC calculation module is composed of 16x16 multipliers and a 4-stage pipeline addition tree. The convolution accelerator of the present invention supports parallel calculation of 16 input channels and adds them through the addition tree. The convolution accelerator of the present invention supports parallel calculation of 16 output channels. Conventional convolution, PW convolution, and DW convolution reuse MAC calculation units to reduce resource utilization. The image input control module and the weight input control module generate read operation controls of off-chip memory including read addresses and read enable signals according to configuration parameters including input image size, convolution kernel weight size, etc., and obtain data at corresponding positions and transmit them to the data flow control module for reorganization.

[0051] The following is a detailed description of the acceleration implementation method of the convolution accelerator adapted to the MobileNet neural network of the present invention in conjunction with the accompanying drawings and specific embodiments, including the following steps:

[0052] Step 1: When the system receives the configuration parameters and starts the calculation signal, it first configures the parameters, such as the number of times the convolution kernel moves horizontally and vertically in the image;

[0053] Step 2: After receiving the start signal and completing the parameter configuration, the input image control module and the input weight control module start to transfer data from the external storage to their respective buffer spaces. Figure 2 The figure shows a schematic diagram of the arrangement of input image data, and the arrangement of convolution kernel parameters is similar. The hardware platform for the implementation of the present invention is the Terasic Technology FPGA development board DE2-115, and SRAM is used for external storage. For the input image control module, the amount of on-chip memory applied = A×B×C×D (bit), where A is the number of loopback buffers, B is the maximum number of input images, C is the number of input channels, and D is the single data bit width. In the hardware platform of the present invention, A is configured as 16, B is configured as 64, C is configured as 16, and D is configured as 8. During execution, if Figure 3 As shown, in detail:

[0054] 1. The input image control module executes the first layer loop, and the number of loops = 16 / (A / B). A is the input data bit width of the external memory, which is 16 bits in the hardware platform implemented by the present invention. B is the image data bit width, which is 8 bits in the hardware platform implemented by the present invention. The first layer loop ends to obtain 16-channel data of a certain coordinate.

[0055] 2. Input the image control module to execute the second loop, the number of loops = the number of times the convolution kernel moves on the horizontal axis of the image. At the end of the second loop, the coordinate data obtained when the convolution kernel slides on a row of the image is obtained. When the image size is 32x32, the moving step is 2, there is no padding, and the fourth loop is the first time, the first row of image coordinate data obtained are: (0,0), (0,2), (0,4), ..., (0,30).

[0056] 3. The input image control module executes the third layer loop, the number of times the convolution kernel moves on the vertical axis of the image. The execution mode of this layer is the same as the second layer loop of the input image control module.

[0057] 4. The input image control module executes the fourth layer loop, and the number of loops = the number of convolution kernel parameters.

[0058] 5. The input image control module executes the fifth loop, and the number of loops = the number of blocks of the image input channel.

[0059] 6. The input image control module executes the sixth loop, and the number of loops = the number of blocks of the image output channel.

[0060] For the input weight control module, the amount of on-chip memory applied = A×B×C×D (bit), where A is the number of loopback buffers, B is the maximum number of convolution kernel parameters, C is the number of input channels, and D is the single data bit width. In this hardware platform, A is configured as 16, B is configured as 16, C is configured as 16, and D is configured as 8. During execution, if Figure 4 As shown, in detail:

[0061] 1. The input weight control module executes the first layer loop, and the number of loops = 16 / (A / B). A is the external memory input data bit width, which is 16 bits in the hardware platform implemented by the present invention. B is the image data bit width, which is 8 bits in the hardware platform implemented by the present invention. The first layer loop ends to obtain 16-channel data of a certain coordinate. If it is a DW convolution, skip this layer loop.

[0062] 2. The input weight control module executes the fourth layer loop, and the number of loops = the number of convolution kernel parameters.

[0063] 3. The input weight control module executes the fifth layer loop, and the number of loops = the number of image input channel blocks. If it is DW convolution, skip this layer loop.

[0064] 4. The input weight control module executes the sixth loop, and the number of loops = the number of image output channel blocks.

[0065] Since the input image control module loads image data slower than the input weight control module, when the input image control module executes the third loop, it can choose when to set the preloading completion signal according to the external memory access speed. When the data flow control module receives the signal, it starts to move the buffered data. In the hardware platform implemented by the present invention, the preloading completion signal is set when the 9th buffer is loaded.

[0066] Step 3: After the data flow control module detects the preload completion signal, it starts to transfer 16-channel data from the input image buffer and the input weight buffer. Figure 5 As shown:

[0067] 1. The data flow control module loads 16 channels of data of 16 convolution kernels. The number of loading times is the size of the convolution kernel parameters. When the loading is completed, the data flow control module executes the first and second layers of loops; the number of loops = the number of times the convolution kernel moves on the horizontal axis of the image x the number of times the convolution kernel image moves on the vertical axis. In this process, the image and weight data of 16 channels are obtained each time and sent to the MAC calculation unit module, and the data valid signal is set at the beginning of the first layer loop.

[0068] 2. The data flow control module executes the third layer loop, and the number of loops = the number of convolution kernel parameters.

[0069] 3. The data flow control module executes the fourth and fifth layers of loops, and the number of loops = the number of input channel blocks × the number of output channel blocks. When the process is completed, the entire input image control module and the input weight control module are accessed.

[0070] Step 4: The MAC calculation module is composed of a 16×16 convolution matrix, and the results of the convolution calculation units are accumulated on the horizontal axis. After receiving the 16-channel input image data, the 0th input image channel data is mapped to the 0th vertical axis, the 1st input image channel data is mapped to the 1st vertical axis, and so on to fill all MAC matrix units. After receiving the 16-channel input weight data of 16 convolution kernels, the 0th channel data of the 0th convolution kernel is mapped to the 0th MAC matrix unit, the 1st channel data of the 0th convolution kernel is mapped to the 1st MAC matrix unit, and so on to fill all MAC matrix units. The MAC calculation module outputs data on the last vertical axis. If it is a DW convolution, the matrix diagonal output data is selected.

[0071] Step 5: The accumulation module accumulates the number of convolution kernel parameters and the input channel blocks. For the DW convolution mode, only the number of convolution kernel parameters is accumulated. Figure 6 , in detail:

[0072] 1. The accumulation module stores the calculation results of the first convolution kernel parameters;

[0073] 2. The accumulation module takes out the last calculation result and adds it to the current result, and then stores the addition result;

[0074] 3. Accumulate the calculation results and repeat the above operation until the accumulation times are completed;

[0075] 4. When the above operation is completed, it indicates that the current output channel block is completed, and the next output channel block calculation is performed. When the output channel block calculation is completed, the entire convolution calculation is completed.

[0076] It should be noted that the parts of the present invention that are not described in detail belong to common knowledge of those skilled in the art.

[0077] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the above-mentioned implementation mode. Technical personnel familiar with the field can also make various equivalent deformations or substitutions under the shared conditions without violating the spirit of the present invention. These equivalent deformations or substitutions are all included in the scope defined by the claims of the present invention.

Claims

1. A convolution accelerator adapted to the MobileNet neural network, comprising: An input image control module, configured to generate an off-chip memory read-related control signal according to first configuration information and cache off-chip memory data, wherein the first configuration information includes the number of input channels, the number of output channels, the input image size, the convolution kernel size, the step, and whether the input image is padded; An input weight control module is used to generate an off-chip memory read-related control signal according to second configuration information and cache off-chip memory data, wherein the second configuration information includes the number of input channels, the number of output channels, the convolution kernel size, and whether it is a deep convolution mode; An output image control module is used to generate an off-chip memory write-related control signal according to third configuration information to write the on-chip memory data into the off-chip memory, wherein the third configuration information includes the number of output channels, the convolution kernel size, the step, the input image size, and whether to fill; A data flow control module, used to read 16 channel data from the input image control module and 16 channel data of 16 convolution kernels from the input weight control module in sequence according to the fourth configuration information, and transmit the data to the MAC calculation unit; The MAC calculation module is used to receive the data from the data flow control module, and to map the 16 channel data of the input image to all the horizontal calculation units, and to map the 16 channel data of the Nth convolution kernel to the Nth row of horizontal calculation units by analogy; all the horizontal calculation units perform convolution calculations, and accumulate the outputs in the horizontal calculation units to obtain the output data of one channel; if it is a DW convolution, there is no need to perform accumulation calculations, and the calculation results of the MAC array diagonally are output; The accumulation module is used to cache the data of the MAC calculation module and accumulate the accumulation result of the input channel data and the number of convolution kernels.

2. The convolution accelerator adapted to the MobileNet neural network according to claim 1, characterized in that: The MAC calculation module is composed of 16x16 multipliers and a 4-stage pipeline addition tree.

3. The convolution accelerator adapted to the MobileNet neural network according to claim 1, characterized in that: The convolution accelerator supports conventional convolution, PW convolution and DW convolution. For the conventional convolution and the PW convolution, it supports parallel execution of 16 input channels and 16 output channels at the same time; for the DW convolution, it supports parallel execution of 16 output channels at the same time, and the conventional convolution, the PW convolution and the DW convolution share a 16x16 convolution calculation unit; if the number of input channels or the number of output channels is greater than the supported parallel number, the number of input channels and the number of output channels are sliced.

4. The convolution accelerator adapted to the MobileNet neural network according to claim 1, characterized in that: When the data flow control module outputs data, if the image needs to be filled, it determines whether the horizontal and vertical coordinates of the current image output are in the filling position. If so, it outputs 0; if not, it outputs normally.

5. The convolution accelerator adapted to the MobileNet neural network according to claim 1, characterized in that: The cumulative number of times of the accumulation module C=A1*B1, where A1 is the number of convolution kernels, B1 is the number of input channel slices, and the number of input channel slices=the number of input channels / the number of parallel channel executions supported.

6. The convolution accelerator adapted to the MobileNet neural network according to claim 1, characterized in that: The channel data is arranged in the form of W×C1×H×C2, where W is the horizontal coordinate number of the image, C1 is the 16-channel number of the corresponding coordinate, H is the vertical coordinate number of the image, and C2 is the input channel slice number.

7. The convolution accelerator adapted to the MobileNet neural network according to claim 1, characterized in that: The input image control module applies for on-chip memory quantity = A3×B3×C3×D3 (bit), wherein A3 is the number of loopback buffers, B3 is the maximum number of input images, C3 is the number of input channels, and D3 is the single data bit width; the input weight control module applies for on-chip memory quantity = A3×B3×C3×D3 (bit), wherein A3 is the number of loopback buffers, B3 is the maximum number of convolution kernel parameters, C3 is the number of input channels, and D3 is the single data bit width.

8. The convolution accelerator adapted to the MobileNet neural network according to claim 1, characterized in that: The input image control module executes the first layer loop, the number of loops = 16 / (A4 / B4), where A4 is the input data bit width of the external memory, and B4 is the image data bit width; the input image control module executes the second layer loop, the number of loops = the number of times the convolution kernel moves on the horizontal axis of the image; the input image control module executes the third layer loop, the number of loops = the number of times the convolution kernel moves on the vertical axis of the image; the input image control module executes the fourth layer loop, the number of loops = the number of convolution kernel parameters; the input image control module executes the fifth layer loop, the number of loops = the number of image input channel blocks; the input image control module executes the sixth layer loop, the number of loops = the number of image output channel blocks.

9. The convolution accelerator adapted to the MobileNet neural network according to claim 1, characterized in that: The input weight control module executes the first layer loop, the number of loops = 16 / (A4 / B4), where A4 is the input data bit width of the external memory, and B4 is the image data bit width. If it is a DW convolution, the first layer loop is skipped; the input weight control module executes the second layer loop, the number of loops = the number of times the convolution kernel moves on the horizontal axis of the image; the input weight control module executes the third layer loop, the number of loops = the number of times the convolution kernel moves on the vertical axis of the image; the input weight control module executes the fourth layer loop, the number of loops = the number of convolution kernel parameters; the input weight control module executes the fifth layer loop, the number of loops = the number of image input channel blocks; the input weight control module executes the sixth layer loop, the number of loops = the number of image output channel blocks.

10. The convolution accelerator adapted to the MobileNet neural network according to claim 1, characterized in that: The data flow control module loads 16 channels of data of 16 convolution kernels, and the number of loads is the size of the convolution kernel parameters. When the loading is completed, the data flow control module executes the first layer loop and the second layer loop, and the number of loops = the number of times the convolution kernel moves on the horizontal axis of the image x the number of times the convolution kernel image moves on the vertical axis; the data flow control module executes the third layer loop, and the number of loops = the number of convolution kernel parameters; the data flow control module executes the fourth layer loop and the fifth layer loop, and the number of loops = the number of input channel blocks × the number of output channel blocks.