A hardware accelerator for quantizing MobileNet and its application method

By designing a quantized MobileNet hardware accelerator, the problem of limited resources of the neural network platform on small devices is solved, efficient data processing and storage utilization is achieved, and real-time operation capabilities are improved.

CN114154630BActive Publication Date: 2024-10-29BEIJING INST OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111393465.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-23
Publication Date
2024-10-29
Estimated Expiration
2041-11-23

AI Technical Summary

Technical Problem

Existing neural network platforms have limited computing power and storage capabilities on small devices, making it difficult to run high-precision neural network models in real time. In particular, due to large storage delays and low access efficiency, the network operation speed decreases and cannot meet real-time requirements.

Method used

Design a quantized MobileNet hardware accelerator, including a top-level control module, a memory control module, a channel-by-channel convolution module, and a point-by-point convolution module. By appropriately modifying the data flow method and convolution operation sequence, the input and output channel parallelism can be achieved. Configurable, reducing the number of storage interactions and hardware resource requirements, using ping-pong cache switching and quantization units for data processing.

Benefits of technology

It effectively solves the problems of low storage utilization and insufficient computing resources, reduces external storage latency, reduces on-chip storage capacity requirements, and improves the real-time running capabilities of neural networks on small devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114154630B_ABST
    Figure CN114154630B_ABST
Patent Text Reader

Abstract

The present invention relates to a hardware accelerator for quantizing MobileNet and an application method thereof, and belongs to the technical field of hardware acceleration and computer vision. It includes a top-level control module, a memory control module, a point-by-point convolution module, a channel-by-channel convolution module and a post-processing module; the top-level control module is connected to the memory control module, the point-by-point convolution module, the channel-by-channel convolution module and the post-processing module; the memory control module is connected to the point-by-point convolution module, the channel-by-channel convolution module and the post-processing module. The method puts input data and weights into caches of different sizes, reduces hardware usage and obtains convolution results through depth-separable convolution with variable parallel numbers, and then completes pooling, cross-layer connection and address generation through post-processing, so that data is arranged on continuous addresses. The method solves the problem of low cache utilization of MobileNet and reduces time consumption and resource consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a hardware accelerator for quantizing MobileNet and an application method thereof, and belongs to the technical field of hardware acceleration design and computer vision. Background Art

[0002] Deep neural networks have become part of many important applications, especially in areas such as computer vision and speech processing. Traditional models cannot model these complex applications well, while deep neural networks can achieve good model fitting. Convolutional neural networks evolved from the biological perception of images and are very suitable for computer vision tasks such as image recognition and image segmentation. In recent years, many different CNN models have been proposed, which have improved the performance of different parts of this type of network, such as computational complexity and recognition accuracy. However, the cost of these improvements is a sharp increase in computing load, storage load, and bandwidth load. For example, in image classification problems, the famous ResNet50 network can achieve a top-1 accuracy of 76.5% on the ImageNet dataset, but this high accuracy is obtained at the cost of a large number of operations and memory operations, which means that this type of network can only run on platforms with certain computing power and storage space, and is extremely difficult to deploy or cannot be deployed on small mobile platforms. Although a series of efficient convolutional neural networks represented by MobileNet have redesigned the network structure with the goal of reducing computing load and weight size, and have achieved remarkable results, they still face many performance bottlenecks on some edge devices, one of which is the storage problem.

[0003] With the development of the intelligent society, we hope to be able to run high-precision neural network models in real time on many small devices to achieve more abundant applications. However, these devices are limited by practical issues such as cost and power consumption, and their computing and storage capabilities are very limited. Perhaps they can be equipped with low-power, cheap, large-capacity off-chip storage (such as DRAM) to solve the storage problem, but these off-chip storages have large delays and low access efficiency. If data is frequently interacted with these storages during network operation, the network operation speed will decrease, which cannot meet the real-time requirements of most applications. Therefore, how to make full use of the smaller high-speed storage and weaker computing power on these devices to achieve real-time neural network applications has become a difficult problem. Summary of the invention

[0004] The purpose of the present invention is to address the technical defects of the current neural network platform, such as limited resources resulting in a significant decrease in the overall network performance or inability to be deployed on edge devices, and propose a hardware accelerator for quantizing MobileNet and its application method.

[0005] In order to achieve the above object, the present invention adopts the following technical scheme:

[0006] The hardware accelerator is connected to the external memory and the controller, and includes a top-level control module, a memory control module, a channel-by-channel convolution module, a post-processing module, and a point-by-point convolution module;

[0007] The channel-by-channel convolution module includes a row buffer submodule and a quantization unit A;

[0008] The post-processing module includes a pooling submodule, a cross-layer connection submodule, and an address generation submodule;

[0009] The point-by-point convolution module includes a data preparation submodule, a weight preparation submodule, a point-by-point convolution calculation submodule, and a partial sum accumulation submodule;

[0010] The point-by-point convolution calculation submodule includes a multiplication array and a configurable adder tree, and the partial sum accumulation submodule includes a FIFO and a quantization unit B;

[0011] The configurable adder tree adds the outputs of the multiplication array according to different channel parallelisms according to the parallel number of input and output channels configured by the top-level control module, thereby achieving configurable input and output channel parallelism;

[0012] The connection relationship between the components in the hardware accelerator is as follows:

[0013] The top-level control module is connected to the memory control module, the point-by-point convolution module, the channel-by-channel convolution module and the post-processing module; the memory control module is connected to the top-level control module, the point-by-point convolution module, the channel-by-channel convolution module and the post-processing module; the point-by-point convolution module is connected to the top-level control module, the memory control module, the channel-by-channel convolution module and the point-by-point convolution module, the top-level control module, the memory control module and the post-processing module;

[0014] The connection mode inside the channel-by-channel convolution module is that the row buffer submodule is connected to the quantization unit A;

[0015] The connection mode inside the point-by-point convolution module is that the data preparation submodule is connected to the point-by-point convolution calculation submodule; the weight preparation submodule is connected to the point-by-point convolution calculation submodule; the point-by-point convolution calculation submodule is respectively connected to the data preparation submodule, the weight preparation submodule and the partial sum accumulation submodule; the partial sum accumulation submodule is connected to the point-by-point convolution calculation submodule;

[0016] Among them, the connection mode inside the point-by-point convolution calculation submodule is that the multiplication array is connected with the adder tree;

[0017] Among them, the connection mode inside the partial and accumulation submodule is that the FIFO and the quantization unit B are connected.

[0018] The functions of the components in the hardware accelerator are as follows:

[0019] The top-level control module receives an external input control signal to start the hardware accelerator, determines the current state of the hardware accelerator, and notifies the memory control module to connect the current input and output caches with their corresponding optimal actual physical caches according to the current state; notifies the point-by-point convolution module of the parallel number of input channels and the parallel number of output channels corresponding to this operation; notifies the channel-by-channel convolution module of the part that needs to be padded with zeros in the current operation; and notifies the post-processing module to enable the pooling submodule, the cross-layer connection submodule, or the address generation submodule.

[0020] The memory control module maps the input and output caches to different actual physical caches according to the instructions of the top-level control module, sends or receives the required data and weight information, and implements ping-pong cache switching for the input or output cache;

[0021] The point-by-point convolution module performs point-by-point convolution operations and completes some accumulation and processing and quantization operations. It can also handle operation requests with inconsistent parallel numbers of input and output channels.

[0022] The channel-by-channel convolution module performs zero padding and channel-by-channel convolution operations at corresponding positions and completes partial accumulation and processing and quantization operations;

[0023] The post-processing module performs pooling operations and cross-layer connection operations on the network except for convolution, and generates a corresponding storage address for each output result to achieve reordering.

[0024] The application method of the hardware accelerator comprises the following steps:

[0025] Step 1: The top-level control module receives the control parameters from the controller and initializes it, and sends instructions to the memory control module, the point-by-point convolution module, the channel-by-channel convolution module, and the post-processing module;

[0026] Among them, the top-level control module sends instructions to the memory control module to inform it of the best data receiving order and the storage location corresponding to each piece of data; the top-level control module sends instructions to the point-by-point convolution module to inform it of the type of this operation and the corresponding parallel number of input and output channels; the top-level control module sends instructions to the channel-by-channel convolution module to inform it whether the data needs to be padded with zeros and the zero-padded position; the top-level control module sends instructions to the post-processing module to inform it whether pooling, cross-layer connection and address generation are required;

[0027] Step 2: The memory control module receives the data and weights from the external memory, and selects the order and corresponding storage location of receiving the input data and network weights according to the instructions of the top-level control module. When the data received by the memory control module can satisfy a single operation process, jump to step 3;

[0028] Step 3: The memory control module sends the data required for the current operation to the point-by-point convolution module, and at the same time, the memory control module performs ping-pong cache switching to maintain the continuous input of data;

[0029] Step 4: The data preparation submodule arranges the input data in parallel according to the parallel number of input channels provided by the top-level control module and outputs it to the point-by-point convolution calculation submodule. At the same time, the weight preparation submodule arranges the weights required for the convolution operation in parallel according to the parallel number of input and output channels provided by the top-level control module and outputs them to the point-by-point convolution calculation submodule.

[0030] Step 5: The point-by-point convolution calculation submodule uses the output data of step 4 and the weight to perform convolution operation, and outputs the convolution result to the partial sum accumulation submodule;

[0031] Step 6: The partial sum accumulation submodule caches a portion of the convolution output to complete the accumulation operation of the convolution result of the point-by-point convolution calculation submodule and outputs it to the quantization unit B;

[0032] Step 7, the quantization unit B quantizes and outputs the output results of the partial sum accumulation submodule;

[0033] Step 8. The top-level control module determines whether to perform channel-by-channel convolution, pooling, or cross-layer connection according to the current convolution layer. If channel-by-channel convolution is required, jump to step 9; if pooling is required, jump to step 12; if cross-layer connection is required, jump to step 14; if channel-by-channel convolution, pooling, or cross-layer connection is not required, jump to step 15;

[0034] Determine whether to perform channel-by-channel convolution, pooling, or cross-layer connection based on the current convolution layer, specifically:

[0035] Depthwise separable convolution: channel-wise convolution is required afterwards;

[0036] A normal convolution with a kernel size of 1x1 and followed by a pooling layer: pooling is required afterwards;

[0037] Ordinary convolution with a kernel size of 1x1 and cross-layer connection: cross-layer connection is required afterwards;

[0038] Step 9, the line buffer submodule performs line buffering on the output of the point-by-point convolution module and performs a 3x3 convolution operation;

[0039] Step 10: quantization unit A quantizes and outputs the output of the line buffer submodule;

[0040] Step 11, the top-level control module determines whether to perform pooling operation or cross-layer connection operation according to the current convolutional layer. If pooling is required, jump to step 12; if cross-layer connection is required, jump to step 14; if pooling or cross-layer connection is not required, jump to step 15;

[0041] The current convolutional layer determines whether to perform pooling or cross-layer connection, specifically:

[0042] Depthwise separable convolution followed by pooling layer: pooling is required afterwards;

[0043] Depth-wise separable convolution with cross-layer connections: cross-layer connections are required afterwards;

[0044] Step 12: The pooling submodule takes the output of the previous step as input, performs a pooling operation on the input data and outputs it;

[0045] Step 13, the top-level control module determines whether to perform a cross-layer connection operation according to whether there is a cross-layer connection in the current convolutional layer. If so, a cross-layer connection is required, and the process jumps to step 14; if not, a cross-layer connection operation is not required, and the process jumps to step 15;

[0046] Step 14: The cross-layer connection submodule receives the data of the previous layer from the memory control module and adds the calculation result of the current layer to the data and quantizes the final calculation result to output;

[0047] Step 15: The address generation submodule decides to receive the output result from one of the point-by-point convolution module, the channel-by-channel convolution module, the pooling submodule, and the cross-layer connection submodule according to the instruction of the top-level control module, and generates the corresponding address and sends it to the memory control module so that the results are arranged continuously on the storage address;

[0048] Step 16: The memory control module stores the operation result, and when writing to one of the output ping-pong buffers, returns the data in another full buffer to the external storage through the bus;

[0049] Step 17: After the top-level control module is executed, the final classification result is returned.

[0050] Beneficial Effects

[0051] The present invention provides a hardware accelerator for quantizing MobileNet and an application method thereof, which has the following beneficial effects compared with the existing accelerators and design methods:

[0052] 1. The storage utilization method used in the method solves the problem of low utilization rate of input and output caches of the same size in traditional design when storing data, which is caused by the imbalance of input and output sizes of the deep separable convolution of the MobileNet network;

[0053] 2. The method achieves the effect that all data and weights only need to interact with external storage once by appropriately modifying the flow mode of data flow and the operation order of basic convolution, thereby reducing the time consumption problem caused by high latency of external storage;

[0054] 3. The data flow mode and convolution operation order of the method enable a convolution operation to be split, further reducing the on-chip storage capacity requirements;

[0055] 4. The method modifies the parallel number of input and output channels of the point-by-point convolution module by appropriately increasing the storage bandwidth requirement to reduce the hardware resources required to match the pipeline throughput after the point-by-point convolution. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] Figure 1 A module connection diagram of a hardware accelerator for quantizing MobileNet and an application method thereof of the present invention;

[0057] Figure 2 This is a flowchart of a hardware accelerator for quantizing MobileNet and its application method of the present invention;

[0058] Figure 3 The present invention is a circuit connection diagram of a hardware accelerator for quantizing MobileNet and an application method thereof.

[0059] Figure 4 This is a default convolution sequence diagram of a hardware accelerator for quantizing MobileNet and an application method thereof according to the present invention. DETAILED DESCRIPTION

[0060] In order to more clearly illustrate the technical solution of the embodiment of the present application, the following will describe in detail a hardware accelerator for quantizing MobileNet and an application method thereof in combination with the drawings required for use in the embodiment.

[0061] Example 1

[0062] The method can achieve smaller on-chip storage occupancy and hardware resource consumption than traditional general-purpose neural network hardware accelerators in hardware acceleration of a neural network using a deep separable convolutional structure similar to the MobileNet network.

[0063] In the specific implementation, the deployment platform of the hardware design is the PYNQ-Z2 development board. The specific deployment and connection method of the hardware module can be referred to Figure 1. The neural network specifically used in this embodiment 1 is the MobileNetV2 convolutional neural network, and its specific network structure and weight parameters are provided by the built-in torchvision function of Pytorch. The parameters of the network are quantized to 8 bits through post-training quantization to further reduce the computational complexity and resource consumption. During post-training quantization, the operation input and output are quantized to 0 to 255, and the network weights are quantized to -128 to 127, where the quantization zero point of the network weights is fixed to 0. This quantization method can eliminate the need to consider the additional multiplication and addition operations caused by the weight quantization zero point in the process of hardware calculating the quantization results, thereby further reducing the computational burden and resource consumption.

[0064] The input and output channel parallelism of the point-by-point convolution module of the hardware accelerator is configured as 32 parallel input channels and 8 parallel output channels. This number is the result of comprehensive consideration of the hardware resources, storage bandwidth and overall design frequency of the PYNQ-Z2 implementation platform. The 8 parallel outputs make all subsequent hardware parallelism 8 parallel to match the pipeline, which reduces resource usage compared to the design of 16 parallel inputs and outputs. In different situations, the parallelism can be configured as required to achieve the best effect. For the multiplication array, considering that the maximum multiplication bit width supported by the DSP48E provided by the current platform is 25 bits by 18 bits, by appropriately changing the order of operations and data organization, one DSP48E can perform two 8-bit by 8-bit operations at the same time, thereby reducing the consumption of hardware multipliers.

[0065] The memory control module controls three groups of ping-pong caches, namely small data cache, large data cache and weight cache. The specific sizes of these three groups of caches are jointly determined by the storage resources that the platform can provide as a whole and the way the convolution operation sequence is split. In this embodiment 1, the weight cache is 10KB, the small data cache is 28KB, and the large data cache is 125KB. Which data cache is used as the input data cache is determined by the type of convolution layer. Compared with the design of the same size of traditional input and output caches, the use of cache resources can be reduced by nearly 100KB. During the operation, when the input cache is full, it switches to another ping-pong cache to continue caching the input to prevent the input from stopping and increase the overall operation time. The output is started when an output ping-pong cache is full, and the newly generated output is input to another ping-pong cache for temporary storage. This design can ensure that the output data is continuous in address without interrupting the output, thereby speeding up the access speed of off-chip storage.

[0066] The data parallelism of the channel-by-channel convolution module and the post-processing module should be consistent with the output channel parallelism of the point-by-point convolution module to ensure that the pipeline will not be blocked. In this embodiment 1, this parallelism is 8. The channel-by-channel convolution automatically fills the input data with zeros according to the current operation position to ensure that the input and output sizes are the expected sizes. The top-level control module interacts with the external controller for data and control instructions through the AXI_Stream bus.

[0067] In this embodiment 1, the computing resources, input and output storage, partial accumulation and storage, the condition that all data only access the external storage once, the decomposability and implementation possibility of the convolution operation are comprehensively considered. Figure 4 The order of convolution operations shown in the figure is adjusted. Since the earlier Loop-1 and Loop-2 are completed, the smaller the required partial accumulation and storage can be, and only one external storage access is required when the input or weight can be completely stored on the chip, the loop from Loop1-Loop2-Loop3-Loop4 is adjusted to Loop1-Loop3-Loop2-Loop4. At the same time, the feature graph of each convolution is split. Considering that address continuity is conducive to DMA transmission, this embodiment 1 only splits the feature graph horizontally to reduce the use of internal storage.

[0068] In this embodiment 1, the hardware accelerator as a whole is put into Vivado Block Design as an IP to realize the generation of FPGA burning bitstream. In the specific implementation of the block design circuit connection, AXI interconnect IP core 1 and AXI interconnect IP core 2 call Vivado's "AXI Interconnect" IP core. The PS-side control IP core calls Vivado's "ZYNQ7Processing System" IP core. The DMA IP core calls Vivado's "AXIDirect Memory Access" IP core. The operation IP core is the hardware accelerator IP proposed in this patent. The connection relationship of each IP core is as follows: the M_AXI_GP0 port of the PS-side control IP core is connected to the S00_AXI port of the AXI interconnect IP core 1; the S_AXI_HP0 port of the PS-side control IP core is connected to the M00_AXI port of the AXI interconnect IP core 2; the M00_AXI port of the AXI interconnect IP core 1 is connected to the S_AXI_LITE port of the DMA IP core; the S00_AXI port of the AXI interconnect IP core 2 is connected to the M_AXI port of the DMA IP core; the S_AXIS_S2MM port and the M_AXIS_MM2S port of the DMA IP core are connected to the M_AXIS and S_AXIS ports of the computation IP core respectively. For specific circuit connection methods, please refer to Figure 3 .

[0069] Example 2

[0070] Based on the above hardware accelerator design and test platform construction, this embodiment 2 provides a hardware acceleration method for the MobileNetV2 neural network. In this implementation, the first step is to rearrange and save the quantized network weights according to the optimal data flow structure and convolution operation order. This step only needs to be performed once, and all subsequent operations are based on the weights in the same order;

[0071] Step 2: Rearrange the input original image to meet the optimal order;

[0072] Step 3: The network parameters, network weights and original input image are input into the computing IP core through the PS end and the AXI_Stream bus;

[0073] Step 4: Wait for the IP core to complete the operation and return the result. For the specific process, please refer to Figure 2 .

[0074] So far, the hardware acceleration of the MobileNetV2 neural network in this embodiment 2 has been completed through the first step to the fourth step. After testing, this embodiment 2 can achieve a running speed of 70.94FPS at a clock frequency of 150MHz, and the on-chip storage resources occupied are 524.25KB.

[0075] The description and application of the present invention herein are illustrative and are not intended to limit the scope of the present invention to the above-described embodiments. Variations and changes to the embodiments disclosed herein are possible, and replacements and various equivalent components of the embodiments are well known to those of ordinary skill in the art. It should be clear to those skilled in the art that the present invention may be implemented in other forms, structures, arrangements, proportions, and with other elements, materials, and components without departing from the spirit or essential features of the present invention. Other variations and changes may be made to the embodiments disclosed herein without departing from the scope and spirit of the present invention.

[0076] Those skilled in the art can understand from the above description that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including several instructions for making a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes but is not limited to various media that can store program codes, such as USB flash drives, mobile hard disks, magnetic storage devices, and optical storage devices.

[0077] The above is only a preferred embodiment of the present invention, and the present invention should not be limited to the contents disclosed in the embodiment and the drawings. Any equivalent or modification completed without departing from the spirit disclosed in the present invention shall fall within the scope of protection of the present invention.

Claims

1. A hardware accelerator for quantizing MobileNet, the hardware accelerator is connected to an external memory and a controller, the hardware accelerator comprises a top-level control module, a memory control module, a channel-by-channel convolution module, a post-processing module, and a point-by-point convolution module, characterized in that: The hardware accelerator quantizes the parameters of the network to 8 bits through post-training quantization; when performing post-training quantization, the operation input and output are quantized to 0 to 255, and the network weights are quantized to -128 to 127, wherein the quantization zero point of the network weights is fixed to 0; The channel-by-channel convolution module includes a row buffer submodule and a quantization unit A; the post-processing module includes a pooling submodule, a cross-layer connection submodule and an address generation submodule; the channel-by-channel convolution module automatically fills the input data with zeros according to the current operation position to ensure that the input and output sizes are the expected sizes; The point-by-point convolution module includes a data preparation submodule, a weight preparation submodule, a point-by-point convolution calculation submodule and a partial sum accumulation submodule; the point-by-point convolution calculation submodule includes a multiplication array and a configurable adder tree, and the partial sum accumulation submodule includes a FIFO and a quantization unit B; the parallel number of input and output channels of the point-by-point convolution module is configured as 32 parallel input channels and 8 parallel output channels; The top-level control module is connected to the memory control module, the point-by-point convolution module, the channel-by-channel convolution module and the post-processing module; The memory control module is connected to the top-level control module, the point-by-point convolution module, the channel-by-channel convolution module and the post-processing module; the memory control module controls three groups of ping-pong caches, a big data cache and a weight cache; The point-by-point convolution module is connected to the top-level control module, the memory control module, the channel-by-channel convolution module and the post-processing module; the channel-by-channel convolution module is connected to the point-by-point convolution module, the top-level control module, the memory control module and the post-processing module; The connection mode inside the channel-by-channel convolution module is that the row buffer submodule is connected to the quantization unit A; The connection mode inside the point-by-point convolution module is that the data preparation submodule is connected to the point-by-point convolution calculation submodule; The weight preparation submodule is connected to the point-by-point convolution calculation submodule; the point-by-point convolution calculation submodule is respectively connected to the data preparation submodule, the weight preparation submodule and the partial sum accumulation submodule; the partial sum accumulation submodule is connected to the point-by-point convolution calculation submodule; The connection mode inside the point-by-point convolution calculation submodule is that the multiplication array is connected to the adder tree; The connection mode inside the partial and accumulation submodule is that the FIFO and the quantization unit B are connected; The data parallelism of the channel-by-channel convolution module and the post-processing module is consistent with the output channel parallelism of the point-by-point convolution module; The order of convolution operations is Loop1-Loop3-Loop2-Loop4, and the feature map of each convolution is split at the same time. Specifically, the feature map is only split in the horizontal direction.

2. The hardware accelerator according to claim 1, characterized in that: The working process of the configurable adder tree is: according to the parallel number of input and output channels configured by the top-level control module, the output of the multiplication array is added according to different channel parallelisms, so as to achieve configurable input and output channel parallelism.

3. The hardware accelerator according to claim 1, characterized in that: The top-level control module receives an external input control signal to start the hardware accelerator, determines the current state of the hardware accelerator, and notifies the memory control module to connect the current input and output caches with their corresponding optimal actual physical caches according to the current state; notifies the point-by-point convolution module of the parallel number of input channels and the parallel number of output channels corresponding to this operation; notifies the channel-by-channel convolution module of the part that needs to be padded with zeros in the current operation; and notifies the post-processing module to enable the pooling submodule, the cross-layer connection submodule, or the address generation submodule.

4. The hardware accelerator according to claim 1, wherein: The memory control module maps the input and output caches to different actual physical caches according to the instructions of the top-level control module, sends or receives the required data and weight information, and implements ping-pong cache switching for the input or output cache.

5. The hardware accelerator according to claim 1, wherein: The point-by-point convolution module performs point-by-point convolution operations and completes partial accumulation and processing and quantization operations, and can also handle operation requests with inconsistent parallel numbers of input and output channels; the channel-by-channel convolution module performs zero padding and channel-by-channel convolution operations at corresponding positions and completes partial accumulation and processing and quantization operations; the post-processing module performs pooling operations and cross-layer connection operations other than convolution, and generates a corresponding storage address for each output result to achieve reordering.

6. An application method of the hardware accelerator for quantizing MobileNet according to any one of claims 1 to 5, characterized in that: The hardware accelerator quantizes the parameters of the network to 8 bits through post-training quantization; when performing post-training quantization, the operation input and output are quantized to 0 to 255, and the network weight is quantized to -128 to 127, wherein the quantization zero point of the network weight is fixed to 0; the application method comprises the following steps: Step 1: The top-level control module receives the control parameters from the controller and initializes it, and sends instructions to the memory control module, the point-by-point convolution module, the channel-by-channel convolution module, and the post-processing module; Step 2: The memory control module receives the data and weights from the external memory, and selects the order and corresponding storage location of receiving the input data and network weights according to the instructions of the top-level control module. When the data received by the memory control module can satisfy a single operation process, jump to step 3. Step 3: The memory control module sends the data required for the current operation to the point-by-point convolution module. At the same time, the memory control module controls three groups of ping-pong caches, a large data cache and a weight cache. The ping-pong cache switches to maintain the continuous input of data. Step 4, the data preparation submodule arranges the input data in parallel according to the parallel number of input channels provided by the top-level control module and outputs it to the point-by-point convolution calculation submodule. At the same time, the weight preparation submodule arranges the weights required for the convolution operation in parallel according to the parallel number of input and output channels provided by the top-level control module and outputs it to the point-by-point convolution calculation submodule; the parallel number of input and output channels of the point-by-point convolution module is configured as 32 parallel input channels and 8 parallel output channels; Step 5: The point-by-point convolution calculation submodule uses the output data of step 4 and the weight to perform convolution operation, and outputs the convolution result to the partial sum accumulation submodule; the order of convolution operation is Loop1-Loop3-Loop2-Loop4, and the feature map of each convolution is split at the same time, specifically, the feature map is only split in the horizontal direction; Step 6: The partial sum accumulation submodule caches a portion of the convolution output to complete the accumulation operation of the convolution result of the point-by-point convolution calculation submodule and outputs it to the quantization unit B; Step 7, the quantization unit B quantizes and outputs the output results of the partial sum accumulation submodule; Step 8. The top-level control module determines whether to perform channel-by-channel convolution, pooling or cross-layer connection according to the current convolution layer. If channel-by-channel convolution is required, the channel-by-channel convolution module automatically fills the input data with zeros according to the current operation position to ensure that the input and output sizes are the expected sizes, and jumps to step 9; if pooling is required, jump to step 12; if cross-layer connection is required, jump to step 14; if channel-by-channel convolution, pooling or cross-layer connection is not required, jump to step 15; Step 9, the line buffer submodule performs line buffering on the output of the point-by-point convolution module and performs a 3x3 convolution operation; the output channel parallelism of the point-by-point convolution module is consistent with the data parallelism of the channel-by-channel convolution module and the post-processing module; Step 10: quantization unit A quantizes and outputs the output of the line buffer submodule; Step 11, the top-level control module determines whether to perform pooling operation or cross-layer connection operation according to the current convolutional layer. If pooling is required, jump to step 12; if cross-layer connection is required, jump to step 14; if pooling or cross-layer connection is not required, jump to step 15; Step 12: The pooling submodule takes the output of the previous step as input, performs a pooling operation on the input data and outputs it; Step 13, the top-level control module determines whether to perform a cross-layer connection operation according to whether there is a cross-layer connection in the current convolutional layer. If so, a cross-layer connection is required, and the process jumps to step 14; if not, a cross-layer connection operation is not required, and the process jumps to step 15; Step 14: The cross-layer connection submodule receives the data of the previous layer from the memory control module and adds the calculation result of the current layer to the data and quantizes the final calculation result to output; Step 15: The address generation submodule decides to receive the output result from one of the point-by-point convolution module, the channel-by-channel convolution module, the pooling submodule, and the cross-layer connection submodule according to the instruction of the top-level control module, and generates the corresponding address and sends it to the memory control module so that the results are arranged continuously on the storage address; Step 16: The memory control module stores the operation result, and when writing to one of the output ping-pong buffers, returns the data in another full buffer to the external storage through the bus; Step 17: After the top-level control module is executed, the final classification result is returned.

7. The method for applying the hardware accelerator according to claim 6, characterized in that: In step 1, the top-level control module sends instructions to the memory control module to inform it of the optimal data receiving order and the storage location corresponding to each piece of data; the top-level control module sends instructions to the point-by-point convolution module to inform it of the type of this operation and the corresponding parallel number of input and output channels; the top-level control module sends instructions to the channel-by-channel convolution module to inform it whether the data needs to be padded with zeros and the zero-padded position; the top-level control module sends instructions to the post-processing module to inform it whether pooling, cross-layer connection and address generation are required.

8. The method for applying the hardware accelerator according to claim 6, characterized in that: In step 8, it is determined whether to perform channel-by-channel convolution, pooling, or cross-layer connection according to the current convolution layer, specifically: Depthwise separable convolution: channel-by-channel convolution is required afterwards; A normal convolution with a kernel size of 1x1 and followed by a pooling layer: pooling is required afterwards; Ordinary convolution with a kernel size of 1x1 and cross-layer connection: cross-layer connection is required afterwards.

9. The method for applying the hardware accelerator according to claim 6, characterized in that: In step 11, the current convolutional layer determines whether to perform pooling or cross-layer connection, specifically: Depthwise separable convolution followed by pooling layer: pooling is required afterwards; Depth-wise separable convolution with cross-layer connections: Cross-layer connections are required afterwards.

Citation Information

Patent Citations

  • Lightweight CNN model calculation accelerator based on FPGA

    CN111488983A

  • FPGA-based neural network accelerator supporting channel separation convolution

    CN112766479A