Design and implementation of a general convolution operation accelerator architecture based on loop optimization technology

Through loop optimization technology, a general convolution operation accelerator architecture is designed, which solves the problem of limited resources and high energy consumption of CNN deployment on FPGA platform, achieves efficient convolution operation and flexible resource management, and is suitable for edge devices.

CN118332239BActive Publication Date: 2024-10-15DALIAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410454244.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-16
Publication Date
2024-10-15
Estimated Expiration
2044-04-16

AI Technical Summary

Technical Problem

The deployment of large-scale convolutional neural networks (CNN) on existing FPGA platforms faces the problems of limited computing resources and high energy consumption of off-chip communication. Existing research mainly focuses on the optimization of inner loops and ignores the impact of outer loops on resources and performance. impact, resulting in underutilization of resources and excessive energy consumption.

Method used

Adopting a universal convolution operation accelerator architecture based on loop optimization technology, through loop tiling, loop exchange and loop unrolling, the execution efficiency of convolution operations is optimized, computing delay and data transmission requirements are reduced, and efficient parallel computing solutions and data flows are designed. Processing methods to ensure rational utilization of resources and reduction of energy consumption.

Benefits of technology

It improves the computing performance and resource utilization of the convolution accelerator, increases flexibility and versatility, reduces energy consumption, adapts to edge device applications with limited resources, and provides an efficient computing path.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118332239B_ABST
    Figure CN118332239B_ABST
Patent Text Reader

Abstract

The present invention discloses a design and implementation method of a general convolution operation accelerator architecture based on loop optimization technology. Through key technologies such as loop tiling, loop exchange and loop unrolling, a set of efficient loop optimization strategies are designed to guide the development of accelerator hardware architecture. A loop optimization strategy for convolution operation is proposed, which mainly focuses on the unrolling of loop 2, loop 3 and loop 4, unrolls loop 2 and loop 4 with multiple parallel product-accumulation calculation units, and unrolls loop 3 through multiple cycles. Based on this strategy, a novel convolution accelerator architecture is constructed, and according to the proposed loop optimization strategy, an effective data flow processing method is customized to ensure the efficient execution of convolution calculation. By comprehensively applying these strategies, the present invention not only expects to improve the computing performance of the convolution accelerator, but also aims to optimize resource utilization, thereby opening up a new path for the application of FPGA in the field of efficient computing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of convolutional neural network (CNN) accelerators for FPGAs, and relates to a design and implementation method for a general convolutional operation accelerator architecture based on loop optimization technology. Background Art

[0002] In recent years, convolutional neural network (CNN) accelerators based on FPGA (Field Programmable Gate Array) have shown great potential in multiple fields due to their excellent energy efficiency and adaptability. Nevertheless, the deployment of large-scale CNNs on FPGA platforms faces challenges such as limited computing resources and high off-chip communication energy consumption, which exacerbate the complexity of deployment. To overcome these obstacles, loop tiling, loop interchange, and loop unrolling have become key loop optimization techniques. Among them, loop tiling adapts the on-chip memory by splitting the convolutional kernel and the feature map, and factors such as data scale, bandwidth, and computing bottlenecks need to be comprehensively considered. Current research has not proposed a comprehensive solution to address these issues simultaneously. Loop interchange affects the order of computation and data transfer, and most existing research is limited to optimizing the inner loops (loop-1 and loop-2), ignoring the potential impact of the outer loops (loop-3 and loop-4) on resources, performance, and other loop optimization methods.

[0003] An annotated convolutional operation consists of four levels of loops, as shown in the following pseudocode. The convolutional operation performs a 2D convolutional operation by iterating over each dimension of the input feature map and the convolutional kernel. The meaning represented by each loop is as follows:

[0004] Loop-1 (for(ky = 0; ky < Nky; ky++) and for(kx = 0; kx < N kx ; kx++)): This innermost double loop traverses each element of the convolutional kernel. Where kx and ky represent the indices of the convolutional kernel (also known as the filter) in its width and height, and are used to traverse each element of the convolutional kernel for convolutional calculation. N ky and N kx represent the sizes of the convolutional kernel in the y and x dimensions respectively.

[0005] Loop-2 (for(ni = 0; ni < N if ; ni++)): The second layer loop traverses the depth of the input feature map. Where ni represents the channel index of the current input feature map for the operation, and N if represents the number of channels of the input feature map.

[0006] Loop-3 (for(y = 0; y < N oy ; y += S) and for(x = 0; x < N ox; x + = S)) : This double-layer loop traverses each position of the output feature map with a step size of S, usually called stride. Where x and y represent the index of the feature map in its width and height, N ox and N oy Indicates the size of the output feature map in the x and y dimensions.

[0007] loop-4(for(no=0;no <N of ; no++)) : The outermost loop traverses the depth of the output feature map. Where no represents the channel index of the output feature map of the current operation, N of Indicates the number of channels of the output feature map.

[0008] The overall loop is as follows:

[0009]

[0010] The convolution operation loops along four levels of convolution kernels and feature maps, resulting in a huge design space for exploring parallelism, data partitioning schemes, and loop computation order. Currently, many techniques have been adopted to search the design space of loop optimization strategies, such as automatic architecture generation and cross-layer optimization. However, these accelerators focus on specific convolution layers and lack design considerations for multi-scale convolution layers. For example, when a convolution layer with a 1×1 convolution kernel is processed in parallel on a fixed architecture designed for a 5×5 convolution kernel, resources are not fully utilized, resulting in reduced efficiency and flexibility. To overcome this problem, some studies have achieved impressive performance improvements on VGG and ResNets by leveraging data reuse to improve the flexibility of CNN accelerators. However, in these architectures, the entire parallel space is allocated to the outer loop, resulting in significant additional resource utilization, which is not suitable for deployment on resource-limited edge devices. The current design of efficient convolution accelerators has the following difficulties:

[0011] The first is to design an efficient parallel computing architecture: how to maximize data processing speed through parallel multiplication and accumulation operations and loop unrolling strategies while maintaining high energy efficiency.

[0012] The second is to optimize storage and transmission: how to achieve the optimal balance between data size and bandwidth in loop tiling and loop swapping to reduce on-chip storage requirements and energy consumption of off-chip communication.

[0013] The third is convolution loop management: how to comprehensively consider parallelism, data segmentation, and calculation order in loop optimization strategies, especially how to reduce resource consumption of outer loops and improve data reuse while ensuring performance. Summary of the invention

[0014] To solve these problems, in view of the limitations of existing FPGA-based convolutional neural network (CNN) accelerators in terms of computational efficiency and flexibility, the present invention proposes a novel design and implementation method for a flexible and scalable FPGA general convolutional operation accelerator architecture based on loop optimization. By precisely controlling loop tiling, swapping, and unrolling, it aims to improve the deployment efficiency of large-scale CNNs and reduce energy consumption. Loop tiling divides the entire convolutional kernel and feature map into multiple blocks to fit the capacity of on-chip memory and process them sequentially. Loop swapping defines the calculation order of four loops. Loop unrolling is used to design a parallel computing scheme for convolutional loops in hardware. The design method proposed by the present invention is expected to optimize the utilization of hardware resources while ensuring the performance of the accelerator, especially for applications on resource-constrained edge devices.

[0015] First, a convolutional loop optimization strategy is proposed through operations such as loop tiling, loop swapping, and loop unrolling to improve performance and optimize resource usage. This strategy includes: 1) unrolling Loop-2, Loop-3, and Loop-4, where Loop-2 and Loop-4 are unrolled using multiple parallel computing units, and Loop-3 is unrolled using multiple cycles; 2) calculating the convolutional operation in the order of Loop-1 - Loop-4; 3) performing segmentation in the dimensions of Loop 3 and Loop 4. On this basis, an innovative accelerator architecture and a data flow matching the accelerator are developed to implement the convolutional calculation by executing the loop optimization strategy.

[0016] The technical solution of the present invention:

[0017] A design and implementation method for a general convolutional operation accelerator architecture based on loop optimization technology, where the convolutional operation includes four levels of loops, which are represented as follows:

[0018] Loop-1 (for(ky = 0; ky < Nky; ky++) and for(kx = 0; kx < Nkx; kx++)): This innermost double loop traverses each element of the convolutional kernel. Where kx and ky represent the indices of the convolutional kernel (also known as the filter) in its width and height, used to traverse each element of the convolutional kernel for convolutional calculation. N ky and N kx respectively represent the sizes of the convolutional kernel in the y and x dimensions.

[0019] Loop-2 (for(ni = 0; ni < Nif; ni++)): The second layer loop traverses the depth of the input feature map. Where ni represents the channel index of the current input feature map for the operation. N if represents the number of channels of the input feature map.

[0020] Loop-3 (for(y = 0; y < N oy ; y += S) and for(x = 0; x < Nox ; x + = S)) : This double-layer loop traverses each position of the output feature map with a step size of S, usually called stride. Where x and y represent the index of the feature map in its width and height, N ox and N oy Indicates the size of the output feature map in the x and y dimensions.

[0021] loop-4(for(no=0;no <N of ; no++)) : The depth of the output feature map traversed by the outermost loop. no indicates the channel index of the output feature map of the current operation. N of Indicates the number of channels of the output feature map.

[0022] The design and implementation method of the general convolution operation accelerator architecture based on loop optimization technology optimizes the execution efficiency of convolution operations, reduces computing delays, and optimizes data storage and transmission through loop tiling, loop swapping, and loop unrolling technologies, thereby improving overall performance. The specific steps are as follows:

[0023] Step 1: Design the convolutional neural network architecture using loop optimization techniques to balance computational efficiency, storage requirements, and data transfer.

[0024] Step 1.1: Unroll Loop-2 and Loop-4 by parallelizing multiply-accumulate operations, and unroll Loop-3 over multiple cycles to minimize computation latency while optimizing data reuse and resource consumption.

[0025] Step 1.2: By performing convolution calculations sequentially from loop-1 to loop-4, the loop exchange strategy is used to reduce the storage requirements of the partial sums, effectively manage the number of partial sums, and optimize data movement.

[0026] Step 1.3: Apply loop tiling strategy to reduce external memory access frequency by tiling data in loop-3 and loop-4 dimensions and transferring to on-chip memory based on design variables.

[0027] Step 2: Design the data flow and data layout, from off-chip memory to on-chip cache, and then to the computing unit PE array to ensure the continuity of data access and the efficiency of computing.

[0028] Step 2.1: Divide the feature data into blocks and encode them to ensure that each data block can be efficiently acquired through a single bus transfer, thereby optimizing the data transfer from off-chip to on-chip.

[0029] Step 2.2: Customize the reading order of feature maps and convolution kernels to achieve continuity of data access, ensure efficient loading of data into accelerator registers in consecutive cycles, and support efficient parallel computing.

[0030] Step 3: Design a hardware convolution accelerator based on heterogeneous FPGA to implement the convolutional neural network architecture designed using loop optimization technology.

[0031] Step 3.1: Implement the DMA module to control the access of data from the on-chip cache to the processing unit.

[0032] Step 3.2: Implement register group cache weights in ping-pong mode to support efficient reuse and parallel computing of weights.

[0033] Step 3.3: Implement the control logic module in the computational unit to coordinate the synchronous reading of features and weights.

[0034] Step 3.4: Implement the MAC unit to perform multiplication operations on weights and pixel data in each cycle, and accumulate partial sums through the adder tree.

[0035] Step 3.5: Implement the accumulator unit to accumulate and buffer the partial sums generated by the MAC unit to optimize the computation and storage efficiency in a ping-pong mode.

[0036] Step 3.6: Implement the shift and truncation operation module to process the output pixels after accumulation to minimize the data width and optimize storage.

[0037] Beneficial effects of the present invention: The present invention designs a set of efficient loop optimization strategies through key technologies such as loop tiling, loop exchange and loop unrolling, thereby guiding the development of accelerator hardware architecture. In particular, a loop optimization strategy for convolution operations is proposed, which mainly focuses on the expansion of loop-2, loop-3 and loop-4, and expands loop-2 and loop-4 with multiple parallel multiplication-accumulation units (MACs), while expanding loop-3 through multiple cycles. Based on this strategy, a novel convolution accelerator architecture is constructed, and according to the proposed loop optimization strategy, an effective data flow processing method is customized to ensure the efficient execution of convolution calculations. The comprehensive application of these strategies produces significant beneficial effects:

[0038] 1) Improving computing performance and resource optimization: The present invention improves the computing performance of the convolution accelerator and optimizes the use of hardware resources through key technologies such as loop tiling, loop swapping and loop unrolling.

[0039] 2) Increased flexibility and versatility: The designed general convolution operation accelerator architecture demonstrates high efficiency and flexibility on convolution layers of different sizes and types, avoiding the problem of underutilization of resources when processing convolution kernels of different sizes in architectures designed for specific convolution layers, making it adaptable to edge computing needs.

[0040] 3) Reduce energy consumption: The loop tiling strategy can reduce the frequency of external memory access and effectively manage on-chip cache, thereby reducing energy consumption. Through reasonable data flow and data layout design, the efficiency of data transmission from off-chip to on-chip is optimized.

[0041] 4) Opening up new efficient computing paths: The comprehensive application strategy of the present invention provides new solutions and paths for the application of FPGA in the field of efficient computing. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 The schematic diagram of the convolution accelerator.

[0043] Figure 2 Illustration of Tiled Loop-3 and Loop-4.

[0044] Figure 3 Flowchart for optimizing the design goal within the loop optimization space.

[0045] Figure 4 The data layout on the on-chip and off-chip memories is shown in Figure 1. The input features and weights shown are a block of the original features and weights along the loop-3 and loop-4 pairs.

[0046] Figure 5 To customize the reading order of feature and weight data from on-chip memory to PE. Each encoding block represents a set of parallel input data. DETAILED DESCRIPTION

[0047] The implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and technical solutions.

[0048] Step 1: Press Figure 3 The pipeline shown designs a convolutional neural network architecture via loop optimization techniques.

[0049] Step 1.1: Minimize computational latency through loop unrolling strategies. Loop-2 and Loop-4 are unrolled with multiple parallel multiply-accumulate (MAC) operations, while Loop-3 is unrolled over multiple cycles to achieve data reuse and reduce data transfer. Specifically, the outer loops (Loop-3 and Loop-4) promote data reuse, while the inner loop (Loop-2) helps balance logic and BRAM resources. To prevent the outer loops from over-consuming BRAM resources, Loop-2 and Loop-4 are spatially unrolled, while Loop-3 is temporally unrolled, allowing the parallel computations in Loop-2 and Loop-4 to be completed in a single cycle, while the computation in Loop-3 is completed across multiple cycles.

[0050] Step 1.2: Minimize the need to store partial sums through loop swapping strategy. Considering that deriving the final pixel output as early as possible can reduce the number of partial sums that need to be stored, the convolution calculations are performed sequentially from loop-1 to loop-4. This execution order allows loop-1 and loop-2 to be calculated as early as possible, so that the number of partial sums can be controlled.

[0051] Step 1.3: Minimize external memory access frequency through loop tiling strategy. Figure 2 The scheme shown in , the weights and features on the off-chip memory are tiled in the loop-3 and loop-4 dimensions and transferred to the on-chip memory in sequence. To ensure that the computational units are fully utilized, the parallel computation in each dimension should be selected as a common factor of all possible values ​​of that dimension in the layer being processed. For the convolution operation, the design variable T should satisfy T%P=0. To prevent the generation of a transmission bottleneck, the choice of the tiled variable T must also satisfy the transmission speed constraint t store <t cost Among them, t store represents the time required to transfer the feature block to the on-chip cache, t cost The time required to consume this data can be expressed as:

[0052]

[0053]

[0054] Table 1 lists all the convolution operations and hardware platform parameters included in the formula for optimization, where N represents the size of the input data of the convolution layer in each dimension, T represents the scale of loop segmentation on a certain loop, and P represents the loop expansion scale on a certain convolution loop.

[0055] Table 1. Convolution operations and hardware platform parameters.

[0056]

[0057] according to Figure 3 The for loop in traverses the data transmission volume BW of the convolution layer under each tiling strategy to find the appropriate tiling parameter T in each dimension. Among them, pixel_buff_bank is used to index the number of on-chip buffers, and wt_buff_bank_minimum and pixel_buff_bank_minimum represent the minimum number of caches allocated to the weight and pixel buffers to complete a calculation normally.

[0058] Step 2: Press Figure 4 and Figure 5As shown, the data flow and data arrangement of the convolution accelerator from the off-chip memory to the on-chip cache and from the on-chip cache to the computing unit PE array are designed.

[0059] Step 2.1: Use the PyTorch framework to convert the feature and weight data into Figure 4 Each coding block represents a group of 1×1×P if The data can be moved from the off-chip memory to the on-chip cache in parallel through a single bus transmission. The accelerator chip reads and processes the features and data in the off-chip memory in this order, and outputs each sub-block in parallel in the order of the output feature code.

[0060] Step 2.2: The feature maps and weights in the on-chip cache are transferred to the on-chip PE module for processing. The order of transfer and processing is as follows: Figure 5 The coding shown is customized. ix During the cycle, the adjacent P ix The blocks are loaded into reg_dat in order (e.g. Figure 1 During this period, P of The weight blocks are stored in reg_wt_2, and the position is the same as P of In this way, in P ix P was achieved within the period if ×P of ×P ix With this data flow, loop-2 and loop-4 are unrolled by multiple parallel multiply-accumulate units (MACs), and loop-3 is unrolled by multiple cycles.

[0061] Step 3: Implement a hardware convolution accelerator with the following structure: Figure 1 Create highly optimized architectures to enable parallel processing, efficient data management, and dynamic control logic to boost performance and meet the computing needs of specific applications.

[0062] Step 3.1: Use two DMA modules, dat_DMA and wt_DMA, to control the access of features and weights from the on-chip cache to the processing elements (PE array) respectively. They implement Figure 4 The code accesses and reads data blocks sequentially.

[0063] Step 3.2: Use two register sets reg_wt_1 and reg_wt_2 (both of size P of ×P if ×K b 1 bit) is used to cache weights before passing weight data to the PE array to implement ping-pong mode. of After group weights (each group contains Pif weights), and passes the weights to the MAC array through reg_wt_2 for weight reuse calculation. When reg_wt_2 caches one of the P of When group weights are ox Provide P to the computing unit during the cycle ox Group P if ×F b bits of pixel data, achieving P of ×P ox ×P if Scale expansion calculation.

[0064] Step 3.3: Implement a control module in the computing unit, the ctrl_logic module, which is responsible for synchronizing the reading timing of weights and feature data. By implementing the status register and the count register to monitor the number of weights and feature data transmitted and the remaining storage space on the chip, the data stream to the cache is precisely clocked and triggered to ensure that they are read at the right time. Figure 5 The encoding sequence shown is sent to a processing unit (such as a multiply-add unit) for calculation.

[0065] Step 3.4: Implement the computation unit MAC, which performs a computation on the dimension (P of ,P if ) has the weight and dimension (P if ,1) pixel data. The partial products are accumulated using the adder tree to obtain a (P of ,1)-dimensional vector, representing an output pixel point P of The partial sum of the channels. In order to implement the MAC unit, P of ×P if multipliers, and an adder tree, for P kx ×P ky The group weights and features are multiplied and summed. The product-accumulation results are stored in a P of ×(log2P if +K b +F b ) bit in the register group reg_add.

[0066] Step 3.5: Implement the accumulator unit ACC to perform the accumulation and buffering of the partial sums calculated by the MAC unit. The completion of the accumulation is determined by the completion signal provided by the wt_DMA state machine. Since the calculation unit operates in ping-pong mode, when loop-3 and loop-4 are expanded, the partial sums of loop-3 are in P ox cycle, while the partial sums of loop-4 are calculated simultaneously in a single cycle. Therefore, the ACC unit requires P ofaccumulators to accumulate the outputs of the multipliers, and a P ox ×P of ×(K b +F b +log2(N kx ×N ky ×N if ))-bit register buffer to store partial sums.

[0067] Step 3.6: The ACC unit completes the accumulation of an output pixel. The output pixel is arithmetic processed by shifting to the lower bit and truncating the num_shift bit. The accumulated value is F b The output value of the bit.

Claims

1. A design and implementation method for a general convolutional operation accelerator architecture based on loop optimization technology. The convolutional operation includes four levels of loops, which are represented as follows: Loop - 1: for(ky = 0; ky < Nky; ky++) and for(kx = 0; kx < Nkx; kx++): This innermost double - loop traverses each element of the convolutional kernel, where, where kx and ky represent the indices of the convolutional kernel in its width and height, respectively, and are used to traverse each element of the convolutional kernel for convolutional calculation; Nky and Nkx represent the sizes of the convolutional kernel in the y and x dimensions, respectively; Loop - 2: for(ni = 0; ni < Nif; ni++): The second - layer loop traverses the depth of the input feature map. Here, ni represents the channel index of the current - operation input feature map, and Nif represents the number of channels of the input feature map; Loop - 3: for(y = 0; y < Noy; y += S) and for(x = 0; x < Nox; x += S): This double - layer loop traverses each position of the output feature map with a step size of S; Nox and Noy represent the sizes of the output feature map in the x and y dimensions, respectively; Loop - 4: for(no = 0; no < Nof; no++): The outermost loop traverses the depth of the output feature map. Here, no represents the channel index of the current - operation output feature map, and Nof represents the number of channels of the output feature map; It is characterized in that the steps of the design and implementation method for the general convolutional operation accelerator architecture based on loop optimization technology are as follows: Step 1: Design a convolutional neural network architecture using the loop optimization technology process to balance computational efficiency, storage requirements, and data transmission; Step 1.1: Minimize the computational latency by unfolding Loop - 2 and Loop - 4 through parallel multiply - accumulate operations and unfolding Loop - 3 over multiple cycles, while optimizing data reuse and resource consumption; Step 1.2: Perform convolutional calculations in sequence from Loop - 1 to Loop - 4; Step 1.3: Tile data in the Loop - 3 and Loop - 4 dimensions and transfer it to on - chip memory according to design variables; Step 2: Design the data flow and data layout from off - chip memory to on - chip cache and then to the processing element (PE) array; Step 2.1: Divide and encode the feature data to ensure that each data block is obtained through a single - bus transfer; Step 2.2: Customize the reading order of the feature map and the convolutional kernel to achieve continuous data access; Step 3: Design a hardware convolutional accelerator based on a heterogeneous FPGA to implement the convolutional neural network architecture designed using loop optimization technology; Step 3.1: Implement a DMA module to control data access from on - chip cache to the processing unit; Step 3.2: Implement a register - bank cache for weights in ping - pong mode; Step 3.3: Implement a control - logic module in the computational unit to coordinate the synchronous reading of features and weights; Step 3.4: Implement a MAC unit to perform multiplication operations on weights and pixel data in each cycle and accumulate partial sums through an adder tree; Step 3.5: Implement an accumulator unit to accumulate and buffer the partial sums generated by the MAC unit; Step 3.6: Implement a shift and truncation operation module to process the output pixels after accumulation.

2. The design and implementation method of a general convolution operation accelerator architecture based on loop optimization technology according to claim 1, characterized in that: The specific content of Step 3 is as follows: Step 3.1: Use two DMA modules dat_DMA and wt_DMA to control the access of features and weights from the on-chip cache to the processing unit PE array respectively; Step 3.2: Use two registers, reg_wt_1 and reg_wt_2, to cache weights before passing the weight data to the PE array to implement the ping-pong mode. The size of both registers is P of ×P if ×K b Bit; cache P in reg_wt_1 of After grouping weights, the weights are passed to the MAC array through reg_wt_2 for weight reuse calculation. Each group of weights contains P if weights; when reg_wt_2 caches one of the sets of P from reg_wt_1 of When group weights are ox Provide P to the computing unit during the cycle ox Group P if ×F b bits of pixel data, achieving P of ×P ox ×P if Scale expansion calculation; Step 3.3: Implement a control module, namely the ctrl_logic module, in the computing unit to synchronize the reading timing of weights and feature data; Step 3.4: Implement the computation unit MAC, and perform the computation on the dimension (P of ,P if ) has the weight and dimension (P if ,1) pixel data for multiplication; partial products are accumulated using adder trees to obtain a (P of ,1)-dimensional vector, representing an output pixel point P of Partial sum of channels; in order to implement the MAC unit, P is required of ×P if multipliers, and an adder tree, for P kx ×P ky The group weights and features are multiplied and summed; the product-accumulation results are stored in a P of ×(log2P if +K b +F b ) bit in the register group reg_add; Step 3.5: Implement the accumulator unit ACC to perform the accumulation and buffering of the partial sums calculated by the MAC unit; The completion of the accumulation is determined by the completion signal provided by the wt_DMA state machine; since the calculation unit operates in ping-pong mode, when loop-3 and loop-4 are expanded, the partial sum of loop-3 is in P ox cycle, while the partial sums of loop-4 are computed simultaneously in a single cycle; therefore, the ACC unit requires P of accumulators to accumulate the outputs of the multipliers, and a P ox ×P of ×(K b +F b +log2(N kx ×N ky ×N if ))-bit register buffer to store partial sums; Step 3.6: The ACC unit completes the accumulation of an output pixel. The output pixel is arithmetically processed by shifting to the lower bit and truncating the num_shift bit. The accumulated value is the output value of Fb bits.