Method and system for obtaining optimal parallelism solution of FPGA CNN accelerator
Through multiple rounds of iterative data screening and pruning operations, the problem of parallelism search space explosion in the FPGA CNN accelerator is solved, the optimal parallelism configuration is quickly found, the calculation time is significantly reduced, and resource utilization and acceleration effects are improved.
Patent Information
- Application Number
- CN202110877922.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-30
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-07-30
AI Technical Summary
When determining the parallelism of existing FPGA CNN accelerators, the utilization rate of computing resources is low, resulting in uneven resource allocation, and the naive traversal search method takes too long, making it difficult to find the optimal parallelism configuration within a reasonable time.
A multi-round iterative data screening method is used to efficiently eliminate redundant parallelism schemes through pruning operations, compress the search space, update resource usage in real time, prune invalid branches, and quickly determine the optimal parallelism configuration.
The time required for calculation is reduced from 106 hours to 10 seconds, enabling the optimal configuration of FPGA on-chip computing power to be quickly found, improving the performance and efficiency of the accelerator.
Smart Images

Figure CN113592086B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of convolutional neural network FPGA hardware acceleration design, and in particular to a method for obtaining an optimal solution for the parallelism of an FPGA CNN accelerator, and a system for obtaining an optimal solution for the parallelism of an FPGA CNN accelerator. Background Art
[0002] Convolutional Neural Networks (CNN) is one of the representative algorithms of deep learning. Due to its outstanding performance in the field of artificial intelligence, CNN has attracted extensive attention and has been applied in high-tech applications such as image classification, speech recognition, face recognition, autonomous driving, and medical imaging.
[0003] Field Programmable Gate Array (FPGA) is a chip with excellent programming flexibility and high performance-to-power ratio. At present, many CNN forward inference accelerators that pursue low development cost, short development cycle and low application power consumption adopt FPGA-based acceleration solutions.
[0004] Since CNN is a computationally intensive structure, the accelerator needs to fully exploit the computing power of the FPGA chip. Therefore, the core issue of accelerator design is how to efficiently utilize the on-chip computing resources. Many classic FPGA CNN accelerators focus on the optimization of convolution operation structure. The inventor proposed a fine-grained convolution computing structure in the document: An Accurate Assessment Mechanism and a High-Throughput Acceleration Architecture Oriented towards Resource Efficiency ([J]. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems, doi: 10.1109 / TCAD.2020.3011650). This structure has the flexibility of both time granularity and spatial granularity, so that limited computing resources have hardware support for higher computing efficiency.
[0005] The design of FPGA CNN accelerator is a systematic project. In addition to hardware support, it also requires the support of the corresponding parallelism determination algorithm to give full play to the chip computing power of FPGA. Otherwise, without the appropriate parallelism configuration, the configuration and deployment of the convolution computing structure is difficult to achieve the ideal situation, and uneven resource allocation will cause waste of on-chip computing power. Therefore, a method for determining the optimal parallelism that can be matched with the fine-grained convolution computing structure has broad application prospects.
[0006] The above literature uses traditional input parallelism Para in , Output parallelism Para out In addition to the two-dimensional exploration space, a third dimension of parallelism parameter is introduced - feature map segmentation parallelism Para seg . seg The value of ROW out The only certainty is ROW out Represents the number of rows in the segmented output feature map. in 、Para out 、ROW out The value ranges are [1,N in ]、[1,N out ],[1,SIZE out ], the values of the three can be adjusted in fine-grained increments and decrements with 1 as the minimum step size. in Indicates the number of input feature maps, N out Indicates the number of output feature maps, SIZE out Indicates the size of the output feature map.
[0007] The technical route of the parallelism determination algorithm is: to determine the optimal parallelism configuration parameters of the accelerator (Para in ,Para out ,Para seg ), traverse all feasible parallelism combinations in the value range with the finest granularity, and select the parallelism configuration parameters with the highest computing resource utilization.
[0008] The specific process of simple traversal search is as follows:
[0009] 1. Before the traversal begins, data preparation is required: specify the total amount of DSP available on the chip (#DSP total ), and according to the calculation amount of the i-th convolutional layer (#OP i ) accounts for the total network computing capacity (#OP total ) percentage for DSP resource pre-allocation, the number of DSP resources allocated to the i-th layer is #DSP alloc i ;Specify the total amount of BRAM available on the chip (#BRAM total ); according to #OPtotal With #DSP total The ratio of determines the theoretical minimum number of calculation cycles #cycle baseline . On this basis, the fine-grained traversal of parallelism begins.
[0010] 2. In the i-th layer, traverse the tuples in order with a step size of 1 (Para in ,Para out ,ROW out ), we can calculate the set S of single-layer accelerator time / resource overhead under various parallelism combinations. i . S i The selection rules for elements in #cycle are based on the following basic assumptions: i,j 、#DSP i,j Deviation #cycle baseline 、#DSP alloc i The farther away, the less likely it is to become the optimal parallelism solution. We define α as the calculation cycle floating factor and β as the DSP allocation floating factor. Then, for S i Any element σ i,j For i,j / #cycle baseline ) falls within the interval [1-α,1+α], and (#DSP i,j / #DSP alloc i ) falls within the interval [1-β,1+β]. Among them, #cycle i,j Indicates S i The number of computation cycles corresponding to element j in #DSP i,j Indicates S i The number of DSP resources occupied by element j in .
[0011] 3. To obtain the total accelerator time / resource cost, we need to first calculate the set S i The Cartesian product S of (i=1-5) (i.e. S=S1×S2×…×S5), each element in S corresponds to a cross-layer combination solution. Traverse the set S and calculate the max{#cycle i}(i=1~5), sort in ascending order, min{max{#cycle i The corresponding element is the parallelism configuration scheme used by the accelerator to achieve the best performance / resource utilization.
[0012] The more flexible structure in the above literature means that the number of feasible parallelism combinations is growing rapidly, and the time cost of using a simple traversal search method to find the optimal parallelism solution is extremely high. Especially with the increasing size of CNN networks and FPGA on-chip resources, the set Si The number of combinations of single-layer parallelism will explode, causing a surge in the time cost of naively traversing the elements of set S. The time cost of naively traversing the elements of set S with optimal parallelism will reach 10 6 This takes an order of hours, which makes it almost impossible to find the optimal solution for parallelism in this way. Summary of the invention
[0013] In order to overcome the defects of the prior art, the technical problem to be solved by the present invention is to provide a method for obtaining the optimal solution of parallelism of FPGA CNN accelerator, which can effectively eliminate redundant parallelism schemes, compress more than 99% of the search space, delete invalid calculation branches, and successfully reduce the calculation time from 10 6 The time required is reduced from hours to 10 seconds.
[0014] The technical solution of the present invention is: a method for obtaining the optimal solution of parallelism of the FPGA CNN accelerator, which comprises the following steps:
[0015] (1) Start;
[0016] (2) Input CNN network structure parameters and the number of available resources on the FPGA chip;
[0017] (3) Construct a problem model;
[0018] (4) List algorithm constraints;
[0019] (5) Data preparation;
[0020] (6) Traverse the tuple at the minimum granularity (Para in ,Para ou, ROW out ), determine the parallelism set S under the (α, β) constraint i , Para in is the input parallelism, Para out is the output parallelism, ROW out Indicates ROW in The number of rows of the output feature image segment obtained after the row input feature image segment is convolved, α is the calculation cycle floating factor, and β is the DSP allocation floating factor;
[0021] (7) Data coarse screening: sorting + local data cleaning;
[0022] (8) Data screening: sorting + global data cleaning;
[0023] (9) Output data after filtering the single-layer parallel combination set T i ;
[0024] (10) During the nested loop traversal from layer 1 to layer 5, the number of DSPs and BRAMs used by the cross-layer combination scheme is calculated and updated in real time; if the resource usage exceeds the limit at a certain layer, all subsequent inner loops are skipped and all cross-layer combination schemes of this branch are cut; the optimal max{#cycle i}result maxCycle, #cycle i is the number of cycles required for a single layer. In the subsequent loop process, if the #cycle of the current layer is greater than maxCycle, it means that the combination branch cannot further optimize maxCycle, so it stops traversing the inner layer and cuts all the cross-layer combination solutions corresponding to the branch.
[0025] (11)End.
[0026] The present invention aims to solve the problem of explosive growth of parallel search space caused by fine-grained convolution calculation structure. Based on the simple traversal search algorithm, the present invention firstly eliminates redundant parallel schemes through multiple rounds of iterative data screening, thus compressing more than 99% of the search space. The pruning operation is used to delete invalid calculation branches, successfully reducing the calculation time from 10 6 The time required for an accelerator to complete the task is reduced from hours to 10 seconds. The invention can be applied to the design of accelerators on different FPGA platforms and different CNN network structures, and has good versatility. With the help of the invention, the accelerator can quickly determine the optimal parallelism configuration parameters to fully exploit the computing power on the FPGA chip and achieve good acceleration effects.
[0027] A system for obtaining an optimal solution for parallelism of an FPGA CNN accelerator is also provided, comprising: an input module configured to input CNN network structure parameters and the number of available resources on the FPGA chip;
[0028] Building modules, which are configured to build problem models: to determine the optimal parallelism configuration parameters for the accelerator (Para in ,Para out ,Para seg ), an optimal parallelism search algorithm is proposed, whose design goal is to traverse all feasible parallelism combinations in the value interval with the finest granularity and screen out the parallelism configuration parameters with the highest computing resource utilization;
[0029] Constraint modules, which are configured to list algorithm constraints
[0030] Constraint 1. To ensure the rationality of resource allocation, #DSP i Total number of DSPs available on chip #DSP total The ratio is close to the amount of computation of the convolution layer #OP i Total network computing capacity #OPtotal percentage of
[0031] Constraint 2. The throughput of the fully pipelined accelerator is limited by the maximum #cycle i To improve throughput, minimize max{#cycle i};
[0032] Constraint 3.∑#DSP i No more than the total number of available DSP resources on the chip #DSP total ;
[0033] Constraint 4.∑#BRAM i No more than the total number of available on-chip memory resources #BRAM total ;
[0034] The traversal module is configured to traverse tuples at the smallest granularity (Para in ,Para out ,ROW out ), determine the parallelism set S under the (α, β) constraint i ;
[0035] Data coarse screening module, which is configured to perform sorting + local data cleaning;
[0036] Data screening module, which is configured to perform sorting + global data cleaning;
[0037] Output module, which is configured to output the single-layer parallel combination set T after data filtering i ; Search pruning module, which is configured to calculate and update the number of DSPs and BRAMs used by the cross-layer combination scheme in real time during the nested loop traversal from the 1st layer to the 5th layer; if the resource usage exceeds the limit at a certain layer, all subsequent inner loops are skipped directly, and all cross-layer combination schemes of this branch are pruned; the optimal max{#cycle in the traversed cross-layer combination is updated in real time i} Result maxCycle; In the subsequent loop process, if the #cycle of the current layer is greater than maxCycle, it means that the combination branch cannot further optimize maxCycle, stop traversing to the inner layer, and cut all the cross-layer combination solutions corresponding to the branch. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A flow chart of a method for obtaining an optimal solution for parallelism of an FPGA CNN accelerator according to the present invention is shown. DETAILED DESCRIPTION
[0039] like Figure 1As shown, the method for obtaining the optimal solution of parallelism of the FPGA CNN accelerator includes the following steps:
[0040] (1) Start;
[0041] (2) Input CNN network structure parameters and the number of available resources on the FPGA chip;
[0042] (3) Construct a problem model;
[0043] (4) List algorithm constraints;
[0044] (5) Data preparation;
[0045] (6) Traverse the tuple at the minimum granularity (Para in ,Para out ,ROW out ), determine the parallelism set S under the (α, β) constraint i , Para in is the input parallelism, Para out is the output parallelism, ROW out Indicates ROW in The number of rows of the output feature image segment obtained after the row input feature image segment is convolved, α is the calculation cycle floating factor, and β is the DSP allocation floating factor;
[0046] (7) Data coarse screening: sorting + local data cleaning;
[0047] (8) Data screening: sorting + global data cleaning;
[0048] (9) Output data after filtering the single-layer parallel combination set T i ;
[0049] (10) During the nested loop traversal from layer 1 to layer 5, the number of DSPs and BRAMs used by the cross-layer combination scheme is calculated and updated in real time; if the resource usage exceeds the limit at a certain layer, all subsequent inner loops are skipped and all cross-layer combination schemes of this branch are cut; the optimal max{#cycle i}result maxCycle, #cycle i is the number of cycles required for a single layer. In the subsequent loop process, if the #cycle of the current layer is greater than maxCycle, it means that the combination branch cannot further optimize maxCycle, so it stops traversing the inner layer and cuts all the cross-layer combination solutions corresponding to the branch.
[0050] (11)End.
[0051] The present invention aims to solve the problem of explosive growth of parallel search space caused by fine-grained convolution calculation structure. Based on the simple traversal search algorithm, the present invention firstly eliminates redundant parallel schemes through multiple rounds of iterative data screening, thus compressing more than 99% of the search space. The pruning operation is used to delete invalid calculation branches, successfully reducing the calculation time from 10 6 The time required for an accelerator to complete the task is reduced from hours to 10 seconds. The invention can be applied to the design of accelerators on different FPGA platforms and different CNN network structures, and has good versatility. With the help of the invention, the accelerator can quickly determine the optimal parallelism configuration parameters to fully exploit the computing power on the FPGA chip and achieve good acceleration effects.
[0052] Preferably, in step (7), the data coarse screening has three rounds of iterations, and each round of iteration is divided into two steps: sorting and local data cleaning.
[0053] Preferably, the order of step (7) is: for a single layer S i The elements in the collection, the first round of iteration starts with #cycle i 、#DSP i , #BRAM i The data is sorted in ascending order in descending priority order; the second round of iteration starts with #DSP i 、#cycle i , #BRAM i The priority is in ascending order; the third iteration is in #BRAM i 、#cycle i 、#DSP i In ascending order of decreasing priority, #DSP i is the single-layer resource usage, #BRAM i This is the single-layer storage resource usage.
[0054] Preferably, the local data cleaning of step (7) is as follows: for the set S i The element σ in j and σ k (j≠k), if σ j The #cycle, #DSP and #BRAM of k The corresponding index of the partial order relation KO is defined: the element σ k Complete defeat, KO element σ j , element σ j Complete victory, KO element σ k ; For each round of sorted single-layer data, local data cleaning is performed, streaming compression traversal is performed, adjacent elements are compared and those that fail are eliminated; after each round of local cleaning, the ordered set satisfies the following conditions: there is no KO partial order relationship between any two adjacent elements.
[0055] Preferably, in step (8), the single-layer set S i After rough data screening and compression, the obtained ordered set is denoted as S' i , and it is reorganized with #cycle i , #DSP i , #BRAM i The order of decreasing priority is arranged in ascending order, and global data cleaning is performed: traverse S' i , if an element σ j is completely defeated by a certain element σ k in front of it, k < j, then σ j is deleted from the set S' i ; after one round of global cleaning of the data, the set S' i is further compressed into T i , and the ordered set T i satisfies the following condition: there is no KO partial order relationship between any two elements in the set.
[0056] Those of ordinary skill in the art can understand that all or part of the steps in implementing the above embodiment method can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes the steps of the above embodiment method, and the storage medium can be: ROM / RAM, magnetic disk, optical disk, memory card, etc. Therefore, corresponding to the method of the present invention, the present invention also simultaneously includes a system for obtaining the optimal parallelism of an FPGA CNN accelerator, which is usually represented in the form of functional modules corresponding to the steps of the method. The system includes:
[0057] An input module configured to input CNN network structure parameters and the available on-chip resources of the FPGA;
[0058] A construction module configured to construct a problem model: to determine the optimal parallelism configuration parameters (Para in , Para out , Para seg ) of the accelerator, an optimal parallelism search algorithm is proposed, and its design goal is: to traverse all feasible parallelism combination schemes with the finest granularity within the value range, and screen out the parallelism configuration parameters with the highest computing resource utilization rate;
[0059] A constraint module configured to list algorithm constraints
[0060] Constraint 1. To ensure the rationality of resource allocation, the ratio of #DSP i to the total available DSP on the chip #DSP total is close to the computational amount #OP of this convolutional layeri Total network computing capacity #OP total percentage of
[0061] Constraint 2. The throughput of the fully pipelined accelerator is limited by the maximum #cycle i To improve throughput, minimize max{#cycle i};
[0062] Constraint 3.∑#DSP i No more than the total number of available DSP resources on the chip #DSP total ;
[0063] Constraint 4.∑#BRAM i No more than the total number of available on-chip memory resources #BRAM total ;
[0064] The traversal module is configured to traverse tuples at the smallest granularity (Para in ,Para out ,ROW out ), determine the parallelism set S under the (α, β) constraint i ;
[0065] Data coarse screening module, which is configured to perform sorting + local data cleaning;
[0066] Data screening module, which is configured to perform sorting + global data cleaning;
[0067] Output module, which is configured to output the single-layer parallel combination set T after data filtering i ;
[0068] The search pruning module is configured to calculate and update the number of DSPs and BRAMs used by the cross-layer combination scheme in real time during the nested loop traversal from the 1st layer to the 5th layer; if the resource usage exceeds the limit at a certain layer, all subsequent inner loops are skipped directly, and all cross-layer combination schemes of the branch are pruned; the optimal max{#cycle i} Result maxCycle; In the subsequent loop process, if the #cycle of the current layer is greater than maxCycle, it means that the combination branch cannot further optimize maxCycle, stop traversing to the inner layer, and cut all the cross-layer combination solutions corresponding to the branch.
[0069] Preferably, in the data rough screening module, the data rough screening has three rounds of iterative processes, and each round of iteration is divided into two steps of sorting and local data cleaning.
[0070] Preferably, in the data coarse screening module, the order is: for a single layer S iThe elements in the set are sorted in ascending order in the first round of iteration in the order of decreasing priority of #cycle i 、#DSP i 、#BRAM i ; In the second round of iteration, the data is sorted in ascending order in the order of decreasing priority of #DSP i 、#cycle i 、#BRAM i ; In the third round of iteration, the data is sorted in ascending order in the order of decreasing priority of #BRAM i 、#cycle i 、#DSP i ; #DSP i is the single-layer resource usage, and #BRAM i is the single-layer storage resource usage.
[0071] Preferably, in the data rough screening module, local data cleaning is as follows: for the elements σ i and σ j in the set S k , j≠k, if the #cycle, #DSP, and #BRAM of σ j are all not greater than the corresponding indicators of σ k , a partial order relation KO is defined: the element σ k is completely defeated and is KOed by the element σ j ; the element σ j completely wins and KOes the element σ k ; for the single-layer data after each round of sorting, local data cleaning is performed, and a streaming compression traversal is carried out to compare adjacent elements and eliminate the completely defeated ones; every time the data undergoes a round of local cleaning, the ordered set satisfies the following condition: there is no KO partial order relation between any two adjacent elements.
[0072] Preferably, in the data fine screening module, after the single-layer set S i is compressed by data rough screening, the obtained ordered set is denoted as S’ i , and it is sorted in ascending order again in the order of decreasing priority of #cycle i 、#DSP i 、#BRAM i , and global data cleaning is performed: traverse S’ i , if an element σ j is completely defeated by a certain element σ k in front of it, k<j, then σ j is deleted from the set S’ i ; after the data undergoes a round of global cleaning, the set S’ i is further compressed into T i , and the ordered set T iThe following conditions are met: there is no KO partial order relationship between any two elements in the set.
[0073] The present invention is described in more detail below.
[0074] Aiming at the fine-grained convolution computing structure proposed in the above literature, this paper proposes a method for accelerating the optimal solution of parallelism. The core of the method includes a fine-grained iterative optimization parallelism search algorithm. Based on the naive search method, the algorithm effectively eliminates redundant parallelism schemes through multiple rounds of iterative data screening, compressing more than 99% of the search space. At the same time, the algorithm uses pruning operations to delete invalid computing branches, successfully reducing the computing time from 10 6 The time required to complete the search is reduced from hours to 10 seconds. (Note: 1. The algorithm and related data given in this invention are experimental results based on the AlexNet accelerator of KCU1500, but this invention can be extended to the design and implementation of other FPGA CNN accelerators. 2. In order to measure the time cost of the optimal parallel search, this invention gives the experimental results based on the Intel Core i7-8750H CPU.)
[0075] The steps of the method for accelerating the optimal solution of parallelism of iterative optimization are as follows:
[0076] Since the total combination of solutions has a large amount of data and many redundant calculations, from the perspective of calculation efficiency, this paper proposes the following three optimization methods to filter out valid data from each layer that may really affect the final calculation results to participate in the traversal and compress the amount of calculation. i The number of elements in the set is large, and it is time-consuming to directly use global data cleaning. Therefore, three rounds of local iterative cleaning methods are first used to perform data coarse screening, and then the global cleaning method is used to finely screen the data. Finally, pruning means are used to cut invalid calculation branches during the traversal calculation process. The corresponding pseudo code of the present invention is shown in Table 1.
[0077] Step 1: Rough data screening (three rounds): sorting + local data cleaning.
[0078] There are three rounds of iterations in data coarse screening, and each round of iteration is divided into two steps: sorting and local data cleaning.
[0079] · Sorting. For a single layer S i The elements in the collection, the first round of iteration starts with #cycle i 、#DSP i , #BRAM i The data is sorted in ascending order in descending priority order; the second round of iteration starts with #DSP i 、#cycle i , #BRAM iArrange in ascending order according to the decreasing order of priority; the third round of iteration is based on #BRAM i 、#cycle i 、#DSP i Arrange in ascending order according to the decreasing order of priority. The sorting is to make the better parallelism combination method appear as early as possible, which can reduce the time required for subsequent data cleaning and make the pruning operation more efficient.
[0080] · Local data cleaning. For the elements σ i in the set S j and σ k (j ≠ k), if the #cycle, #DSP, and #BRAM of σ j are all not greater than the corresponding indicators of σ k , we define the partial order relation "KO": the element σ k "completely loses" (is "KOed") by the element σ j , and the element σ j "completely wins" ("KOes") the element σ k . For the single-layer data sorted in each round, perform a local data cleaning, that is, a streaming compression traversal, compare adjacent elements and eliminate the "completely losing" ones. Every time the data undergoes a round of local cleaning, the ordered set satisfies the following condition: there is no "KO" partial order relation between any two adjacent elements.
[0081] Step 2 Data fine screening (one round): Sorting + global data cleaning.
[0082] · After the single-layer set S i undergoes data rough screening and compression, the resulting ordered set is denoted as S' i , and re-arrange it in ascending order according to the decreasing order of #cycle i , #DSP i , #BRAM i , and perform global data cleaning: traverse S' i , if an element σ j "completely loses" to a certain element σ k in front of it (k < j), then delete σ j from the set S' i . After the data undergoes a round of global cleaning, the set S' i is further compressed into T i , and the ordered set T i satisfies the following condition: there is no "KO" partial order relation between any two elements in the set.
[0083] When (α, β) is equal to (0.2, 0.2), the above three rounds of preliminary screening and one round of fine screening of the data can respectively reduce the set S iThe amount of data to be iteratively processed is efficiently compressed by 99.9997%, significantly reducing the subsequent computational workload of the algorithm.
[0084] Step 3: Search and prune.
[0085] After the above two steps of data cleaning, we have greatly compressed the amount of single-layer data. However, under the looser constraints of α and β, the cross-layer full combination method still has a considerable amount of computation, and pruning optimization is required during traversal.
[0086] During the nested loop traversal from the outer layer (1st layer) to the inner layer (5th layer), the number of DSPs and BRAMs used by the cross-layer combination scheme is calculated and updated in real time. If the resource usage exceeds the limit at a certain layer, all subsequent inner loops are skipped directly, and all cross-layer combination schemes of this branch are cut.
[0087] Real-time update of the optimal max{#cycle in the traversed cross-layer combination i In the subsequent loop process, if the #cycle of the current layer is greater than maxCycle, it means that the combination branch cannot further optimize maxCycle, so stop traversing the inner layer and cut all the cross-layer combination solutions corresponding to the branch.
[0088] In the configuration where (α, β) is equal to (0.2, 0.2), the above three optimizations can reduce the computation time required for the fine-grained traversal iterative optimization search algorithm from 10 6 It has significantly reduced the time required to complete the algorithm from hours to within 10 seconds, which effectively improves the feasibility of the algorithm.
[0089] Table 1
[0090]
[0091]
[0092]
[0093] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any simple modification, equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention are still within the protection scope of the technical solution of the present invention.
Claims
1. A system for obtaining the optimal solution of parallelism of FPGA CNN accelerator, characterized by: It includes: An input module, which is configured to input CNN network structure parameters and the number of available resources on the FPGA chip; Building blocks, which are configured to build problem models: Parallelism configuration parameters to determine the optimal parallelism of the accelerator in ,Para out ,Para seg , an optimal parallelism search algorithm is proposed, whose design goal is: to traverse all feasible parallelism combination schemes in the value interval with the finest granularity, and screen out the parallelism configuration parameters with the highest computing resource utilization; Constraint modules, which are configured to list algorithm constraints Constraint 1. To ensure the rationality of resource allocation, #DSP i Total number of DSPs available on chip #DSP total The ratio is equal to the convolution layer calculation amount #OP i Total network computing capacity #OP total percentage of Constraint 2. The throughput of the fully pipelined accelerator is limited by the maximum #cycle i To improve throughput, reduce max{#cycle i },#cycle i is the number of cycles required for a single layer; Constraint 3.∑#DSP i No more than the total number of available DSP resources on the chip #DSP total ; Constraint 4.∑#BRAM i No more than the total number of available on-chip memory resources #BRAM total ; The traversal module is configured to traverse tuples at the smallest granularity (Para in ,Para out ,ROW out ), determine the parallelism set S under the (α, β) constraint i ;Para in is the input parallelism, Para out is the output parallelism, ROW out Indicates ROW in The number of rows of the output feature image segment obtained after the convolution of the row input feature image segment, α is the calculation cycle floating factor, and β is the DSP allocation floating factor; #DSP i is the single-layer resource usage, #BRAM i It is the single-layer storage resource usage; A data coarse screening module configured to perform sorting and local data cleaning; Data refinement module, which is configured to perform sorting and global data cleaning; Output module, which is configured to output the single-layer parallel combination set T after data filtering i ; Search pruning module, which is configured to calculate and update the number of DSPs and BRAMs used by the cross-layer combination scheme in real time during the nested loop traversal from the 1st layer to the 5th layer; if the resource usage exceeds the limit at a certain layer, all subsequent inner loops are skipped directly, and all cross-layer combination schemes of the branch are pruned; the optimal max{#cycle in the traversed cross-layer combination is updated in real time i } Result maxCycle; In the subsequent loop process, if the #cycle of the current layer is greater than maxCycle, it means that the branch cannot further optimize maxCycle, stop traversing the inner layer, and cut all the cross-layer combination solutions corresponding to the branch; In the data coarse screening module, the sorting is: for single layer S i The elements in the collection, the first round of iteration starts with #cycle i 、#DSP i , #BRAM i The data is sorted in ascending order in descending priority order; the second round of iteration starts with #DSP i 、#cycle i , #BRAM i The priority is in ascending order; the third iteration is in #BRAM i 、#cycle i 、#DSP i Arrange in ascending order of decreasing priority; In the data coarse screening module, local data cleaning is as follows: for the set S i The element σ in j and σ k , j≠k, if σ j The #cycle, #DSP and #BRAM of k The corresponding index of the partial order relation KO is defined: the element σ k Complete defeat, KO element σ j , element σ j Complete victory, KO element σ k ; For each round of sorted single-layer data, perform a local data cleaning, stream compression traversal, compare adjacent elements and remove failed ones; after each round of local cleaning, the ordered set meets the following conditions: there is no KO partial order relationship between any two adjacent elements; In the data fine screening module, the single-layer set S i After data rough screening and compression, the obtained ordered set is denoted as S' i , and it is reordered in ascending order according to the decreasing priority of #cycle i , #DSP i , #BRAM i , and global data cleaning is performed: traverse S' i . If an element σ j is completely defeated by a certain element σ k in front of it, where k < j, then σ j is deleted from the set S' i . After one round of global cleaning of the data, the set S' i is further compressed into T i . The ordered set T i satisfies the following condition: there is no KO partial order relationship between any two elements in the set.
2. The system for obtaining the optimal solution of parallelism of the FPGA CNN accelerator according to claim 1, characterized in that: In the data rough screening module, there are three rounds of iterative processes for data rough screening, and each round of iteration is divided into two steps: sorting and local data cleaning.
