Neural network accelerator automation design method based on FPGA
The automated design method of neural network accelerator through FPGA technology uses XML format description and hierarchical modeling to achieve efficient automatic generation and rapid verification of neural network accelerators, solving the problems of low efficiency and difficult debugging of traditional manual design, and improving design efficiency. and verification speed, reducing R&D costs.
Patent Information
- Application Number
- CN202410743575.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-09-24
AI Technical Summary
Traditionally manually designed neural network accelerators suffer from low design efficiency and difficulty in debugging and verification, resulting in long development cycles, high costs, and difficulty in rapid iterative optimization.
Adopt an FPGA-based automated design method for neural network accelerators, including automatic generation and rapid verification, describing neural network models in XML format, hierarchical modeling and data flow-driven architecture to achieve resource reuse and efficient design, and integrating detection and debugging modules to pinpoint errors.
It significantly improves the design efficiency and verification speed of neural network accelerators, shortens the development cycle, improves the accuracy and efficiency of problem location, and reduces R&D costs.
Smart Images

Figure CN118690701A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of integrated circuit design, and in particular relates to an automated design method for a neural network accelerator. Background Art
[0002] With the rapid development of artificial intelligence, neural networks, as its core component, have undergone a rapid evolution from theoretical exploration to widespread application. This process has profoundly revealed the importance of computing power in supporting complex model training and inference. In the early days, general-purpose processors (such as CPUs) were still capable of neural network operations, but now, faced with increasingly large data sets and deep learning models, their efficiency and energy consumption ratio are gradually becoming stretched. Therefore, the improvement of computing power has become a key factor in promoting the expansion of the boundaries of neural network technology.
[0003] To meet this challenge, customized hardware architectures have emerged, aiming to accelerate the operating efficiency of neural networks through highly optimized hardware design. These customized solutions, including GPUs, FPGAs, and more specialized ASICs (such as Google's TPU), have achieved exponential performance improvements compared to general-purpose processors through deeply integrated parallel computing units and highly optimized data flow management. This task-specific hardware optimization strategy significantly shortens computing time, reduces energy consumption, and makes real-time applications of large-scale neural networks possible.
[0004] However, designing and implementing such a neural network accelerator architecture is not an easy task. The traditional manual design process is not only time-consuming, but also requires an interdisciplinary team to have an in-depth understanding of multiple levels of knowledge such as neural network algorithms, computer architecture, and circuit design. It is also easily affected by human factors, resulting in a lengthy design iteration cycle. In addition, due to the high internal logic complexity of the neural network accelerator, its debugging and verification work also faces huge challenges. The slow simulation speed and difficulty in locating problems further slow down the progress of iterative optimization and increase R&D costs and time.
[0005] In summary, although customized hardware architecture provides an effective way to accelerate neural networks, how to efficiently design and debug these complex accelerators, reduce development cycles, and improve the accuracy of problem location are still the main challenges in current research and engineering practice. Therefore, exploring automated design tools and efficient debugging methods has become an urgent need to accelerate the development of neural network technology. Summary of the invention
[0006] The purpose of the present invention is to provide an automated design method for a neural network accelerator, so as to greatly improve the design efficiency and verification speed of the neural network accelerator.
[0007] The automatic design method of a neural network accelerator provided by the present invention is based on FPGA technology, and specifically includes: automatic generation of a neural network accelerator based on FPGA and rapid verification of a neural network accelerator based on FPGA; wherein:
[0008] (1) Automatic generation of FPGA-based neural network accelerators, including: reading and parsing the neural network model expressed in XML format; conducting a detailed analysis of FPGA hardware resources and adopting a layered and block strategy under resource constraints to achieve effective resource reuse; adopting a hierarchical modeling strategy to establish a set of standard unit libraries as the basis of the hardware architecture, and based on this library, designing and implementing the hardware description of the neural network level - LayerHW; thereby, the generator can call LayerHW to generate the core computing module of the neural network accelerator; the computing module works together with the storage module and the control module to form a top-level architecture system driven by data flow.
[0009] The specific process is:
[0010] The present invention uses an intermediate description of a neural network architecture in XML format to describe the network structure in a standardized manner, which facilitates the conversion of the neural network model into this format and is parsed by a hardware structure generator (hereinafter referred to as the "generator"). XML includes two main parts: the neural network constituent layers and the connections between layers. The generator is based on the Chisel hardware construction language, in which the custom class NetInfo is responsible for saving network configuration details. The member function parse in this class is specifically used to parse XML files to ensure that all neural network description information in the XML can be accurately imported into the NetInfo instance, laying the foundation for the subsequent hardware generation process.
[0011] Given the limitations of on-chip resources, each layer of a neural network often needs to implement a time-reuse strategy for shared modules. The hardware structure generation process not only involves extracting structural information from the XML configuration file, but also requires inputting the FPGA resource status. Considering that key resource components, such as multipliers, may not be able to fully meet all the model requirements, a hierarchical and block strategy is adopted to achieve effective resource reuse. With the help of scheduling, these hardware modules can be shared by multiple parts at different time points, thereby making efficient use of limited resources.
[0012] This invention proposes an extensible standard cell library, which aims to realize the key functions of the neural network model and can be directly mapped to the hardware architecture. In view of the rapid evolution of neural network technology, this library is highly extensible, allowing users to easily add new standard cells to meet emerging needs. Figure 4Three examples of standard units are given. In the generator, all standard units are collectively referred to as "element" and are derived from the unified "elementBase" class. Flexibility is reserved in the design. If the standard element set fails to fully cover the hardware implementation requirements of a specific network model, users can customize new elements. Custom elements must follow the principle of inheriting from "elementBase" to ensure that they can be seamlessly integrated into the generator system for the hardware generation process to call. Each element can generate a variety of hardware structures by configuring different parameters. For example, the parameters of the vector multiplication unit include the input bit width and the dimension of the input vector, while the reduction addition unit is determined by the number of input vectors and the data bit width parameters.
[0013] The present invention adopts a modeling method of a hierarchical neural network hardware architecture, relying on the components of a standard cell library to build a basic neural network layer. The generator is preset with several ready-to-implement neural network layers, which is convenient for direct calling and accelerates the design process. The system can automatically parse the input XML architecture description file, and call the corresponding neural network layer according to the instructions therein to assemble a complete hardware architecture system. The core of the system is the introduction of the high-level abstract class "LayerHW", which is constructed through a combination of elements and is specifically designed to implement the hardware functions of a specific layer in the neural network. The generator instantiates a variety of LayerHWs to form the core computing module of the entire neural network accelerator. This instantiation process depends on a series of generation parameters, so that LayerHW can generate hardware structures that meet the needs of different scales based on these parameters. It is worth noting that before LayerHW is instantiated, it must be registered first and a LayerHW list (LayerHWList) must be maintained. LayerHWList lists in detail all the layers that can be called by the generator and their corresponding type identifiers in the XML architecture; when the existing LayerHWList cannot meet the needs of a specific network model, users can customize LayerHW and register to join LayerHWList to enhance the adaptability and extensibility of the generator.
[0014] The present invention adopts a data flow driven top-level architecture to design a neural network accelerator to ensure efficient operation. The accelerator module is controlled by the control module, extracts weights and data from the storage module, and seamlessly executes computing tasks. The data flow driven mode significantly reduces the control overhead, and only needs to accurately direct the data to the required location according to the predetermined timing, without the need for a complex control instruction set. In addition to the core computing module generated according to LayerHW, the accelerator integrates a control module and a storage module. The core responsibilities of the control module include managing data flow, generating precise address signals, and producing necessary auxiliary control signals to optimize resource coordination and computing processes.
[0015] (2) Rapid verification of FPGA-based neural network accelerators, including: integrating detection modules in the accelerator design to monitor the output of operations at a specific level; synchronously executing the neural network model on the accelerator hardware and the host software, and evaluating the correctness of the hardware architecture by comparing the output results of both parties at the monitoring level; when an output difference is detected, the mechanism is immediately triggered to capture a snapshot of the system status from the FPGA, and then the snapshot is restored on the host platform using simulation software, and potential errors in the accelerator are accurately located and diagnosed by observing waveform analysis.
[0016] The specific process includes:
[0017] Monitoring point integration. The present invention identifies the level to be monitored in XML, so as to automatically embed the monitoring module in the hardware structure output interface of the corresponding level in the hardware generation process. When the neural network accelerator runs to the specified monitoring level, it receives the start signal and activates it, and then performs real-time detection on the corresponding hardware output.
[0018] Accelerator error detection function. This function performs model operations by mapping the accelerator to the FPGA architecture and maintaining dynamic communication between the accelerator and the host. Under this architecture, the monitoring module is responsible for collecting the output information of the accelerator and forwarding it to the host system in real time. At the same time, the host uses software simulation to execute the same network model and compare and analyze the consistency of the output of the software and hardware at the monitoring layer. Once a difference is found between the two results, an alarm is triggered, indicating that there may be errors in the operation of the accelerator.
[0019] Accelerator fault debugging function. Aims to efficiently locate and resolve operational anomalies. Once an accelerator execution error is detected, the system immediately notifies the accelerator to maintain the current state, then captures a full system snapshot of the FPGA and transmits it to the simulation software on the host platform to reconstruct the real-time state of the FPGA accelerator. By analyzing the signal waveforms of the surrounding units at the time of the fault, the root cause of the problem can be deeply explored and identified. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is a flowchart of the automated design method for a neural network accelerator proposed in the present invention.
[0021] Figure 2 This is a diagram of the XML neural network description file proposed by the present invention.
[0022] Figure 3 It is a diagram of the NetInfo data structure proposed by the present invention.
[0023] Figure 4 This is an example diagram of the hardware structure standard cell library used in the present invention.
[0024] Figure 5This is a diagram of the structure of the core computing module of the neural network accelerator proposed by the present invention.
[0025] Figure 6 This is a diagram of the top-level structure of the neural network accelerator proposed in the present invention. DETAILED DESCRIPTION
[0026] The present invention is further described below by way of embodiments in conjunction with the accompanying drawings.
[0027] Take a simplified four-layer neural network as an example. Its architecture is described in XML format. Figure 2 . In this network, the initial input layer (layer 0) processes data of dimension 304x304x3 (rows x columns x channels) and uses 8-bit data width. The first layer that follows is a convolutional layer, which is configured with 3 input channels, matching the size of 304x304, and produces 1 output channel, also using 8-bit data width; the convolution kernel size is 3x3, and the step size is set to 2x2. The second layer is a fully connected layer, which accepts input from the previous layer and reduces the output dimension to 10. Finally, the third layer is the output layer, maintaining a 10-dimensional output, and the data width is still 8 bits. It is worth noting that the debug="true" flag is set in the second layer, indicating that the output of this layer needs to be monitored.
[0028] By calling the built-in parse method of the NetInfo class, the schema information in the XML document is parsed and encapsulated into a NetInfo object, whose internal structure is as follows: Figure 3 As shown. In this structure, LayerList stores the details of each layer of the neural network in order. Each item is guided by a layer type identifier, and the subsequent parameters accurately describe the structural characteristics of the layer, ensuring a one-to-one correspondence with the XML description. In addition, connectList maintains a set of integer pairs that clearly express the connection pattern between layers; each pair represents the index of two layers in LayerList, such as (0,1), (1,2), (2,3), which clearly indicates the continuous data flow from the input layer to the output layer. The debugLayer attribute is specifically used to track those network layers marked as requiring debugging and monitoring.
[0029] The generation of the hardware architecture is subject to the resource constraints within the FPGA. Here, the maximum number of multipliers within the FPGA is set to 81, and the off-chip data access bit width is set to 256 bits.
[0030] The convolutional layer has a similar LayerHW structure to the fully connected layer. The main elements included are vector multiplication units, accumulation units, and reduction addition units. Figure 4As shown in Figure 1. The vector multiplication unit can configure the size of the vector involved in the multiplication through the parameter N, while the reduction addition unit can set the dimension of the input vector through the parameter N. In view of the reuse of hardware resources between different layers, the core operation module layout finally generated by LayerHW is as follows: Figure 5 As shown. When performing convolutional layer operations, the multipliers are divided into three groups, each containing 27 multipliers, responsible for calculating one pixel in the output feature map. The three groups can process three output pixels at the same time. The fully connected layer reuses the hardware resources of the convolutional layer, and directly summarizes the outputs of the three groups through a single reduction adder and stores them in the accumulator. Under this setting, the fully connected layer can calculate the sum of 81 elements per cycle. Given that the input dimension is 151x151, it takes 282 (151x151 divided by 81 rounded) cycles to calculate one element of the output result. The outputs of the convolutional layer and the fully connected layer are switched through the control module.
[0031] Based on the above core computing modules, the overall architecture of the accelerator is as follows: Figure 6 Display. The control module is responsible for the overall scheduling of the operation process, using the state machine mechanism to coordinate the entire operation process, and providing the core operation module with necessary control instructions to adapt to the computing needs of different levels. Considering that at least two images and their intermediate results need to be temporarily stored, the on-chip cache capacity is set to 600KB. The host can set the starting address of the off-chip storage of data, weights and bias items through the control module, and then the control module generates address instructions based on this to guide the flow of data between on-chip storage, off-chip storage and core operation modules.
[0032] The monitoring module is also controlled by the instructions of the control module. When the third layer of calculations is completed, the monitoring module will report to the host and indicate the specific location of the third layer of output data stored off-chip. The host uses PyTorch to execute the same neural network model, and reads data from the specified off-chip cache address, and compares it with the output result of this layer calculated by PyTorch. Once a difference is found, the host immediately instructs the monitoring module to suspend the current running state, capture a snapshot of the entire system state of the FPGA, and transmit it to the host. Subsequently, the host uses the snapshot to quickly reproduce the running state of the FPGA accelerator, and uses the ModelSim simulation software to generate signal waveforms at time points near the fault to accelerate the diagnosis of the cause of the fault.
Claims
1. An automated design method for a neural network accelerator based on FPGA, characterized in that: The specific steps are: (1) Automatic generation of neural network accelerators based on FPGA, including: reading and parsing the neural network model expressed in XML format; conducting a detailed analysis of FPGA hardware resources, and adopting a layered and block strategy under resource constraints to achieve effective resource reuse; adopting a hierarchical modeling strategy, establishing a set of standard unit libraries as the basis of the hardware architecture, and designing and implementing the hardware description of the neural network level based on this library - LayerHW; thereby, the generator can call LayerHW to generate the core computing module of the neural network accelerator; the computing module works in conjunction with the storage module and the control module to form a top-level architecture system driven by data flow; (2) Rapid verification of FPGA-based neural network accelerators, including: integrating detection modules in the accelerator design to monitor the output of operations at a specific level; synchronously executing the neural network model on the accelerator hardware and the host software, and evaluating the correctness of the hardware architecture by comparing the output results of both parties at the monitoring level; when an output difference is detected, the mechanism is immediately triggered to capture a snapshot of the system status from the FPGA, and then the snapshot is restored on the host platform using simulation software, and potential errors in the accelerator are accurately located and diagnosed by observing waveform analysis.
2. The FPGA-based neural network accelerator automated design method according to claim 1, characterized in that: Automatic generation of FPGA-based neural network accelerator. The specific process is as follows: The intermediate description of the neural network architecture in XML format describes the network structure in a standardized way, making it easy for the neural network model to be converted into this format and parsed by the hardware structure generator; XML includes two main parts: the neural network constituent layers and the connections between layers; The generator is based on the Chisel hardware construction language. The custom class NetInfo is responsible for saving network configuration details. The member function parse in this class is specifically used to parse XML files to ensure that all neural network description information in the XML can be accurately imported into the NetInfo instance, laying the foundation for the subsequent hardware generation process. Given the limitations of on-chip resources, each layer of the neural network implements a time-reuse strategy for shared modules; the hardware structure generation process involves extracting structural information from XML configuration files and also requires input of FPGA resource status; considering that key resource components may not be able to fully meet all model requirements, a layered and block strategy is adopted to achieve effective resource reuse; with the help of scheduling, these hardware modules can be shared by multiple parts at different time points, thereby making efficient use of limited resources; An extensible standard cell library is set up to implement the key functions of the neural network model and can be directly mapped to the hardware structure; the standard cell library is highly extensible, that is, it allows users to easily add new standard cells to meet emerging needs; the standard cell library has reserved flexibility, if the standard element set does not fully cover the hardware implementation requirements of a specific network model, users can customize new elements; customized elements follow the principle of inheriting from "elementBase", so as to ensure seamless integration into the generator system for hardware generation process calls; each element can generate a variety of hardware structures by configuring different parameters; A hierarchical neural network hardware architecture modeling method is adopted, and the basic neural network layer is constructed based on the components of the standard cell library; the generator is preset with several ready-to-implement neural network layers for direct calling and accelerating the design process; it can automatically parse the input XML architecture description file, and call the corresponding neural network layer according to the instructions therein to assemble a complete hardware structure system; the core of the hardware structure system is the introduction of the "LayerHW" high-level abstract class, which is constructed through the combination of elements and is specifically designed to realize the hardware function of a specific layer in the neural network; the generator instantiates multiple LayerHWs to form the core computing module of the entire neural network accelerator; this instantiation process depends on a series of generation parameters, so that LayerHW can generate hardware structures that meet the needs of different scales based on these parameters; Before LayerHW is instantiated, it is registered first and a LayerHW list (LayerHWList) is maintained; LayerHWList lists in detail all the layers that can be called by the generator and their corresponding type identifiers in the XML architecture; when the existing LayerHWList cannot meet the needs of a specific network model, the user can customize LayerHW and add it to LayerHWList by registration to enhance the adaptability and extensibility of the generator; Specifically, a data flow-driven top-level architecture is used to design the neural network accelerator to ensure efficient operation. The accelerator is controlled by the control module, extracts weights and data from the storage module, and seamlessly executes computing tasks. The data flow-driven model significantly reduces control overhead, and only requires data to be accurately directed to the required location at a predetermined timing, without the need for a complex control instruction set. In addition to the core computing module generated based on LayerHW, the accelerator integrates a control module and a storage module. The core responsibilities of the control module include managing data flow, generating precise address signals, and producing necessary auxiliary control signals to optimize resource coordination and computing processes.
3. The FPGA-based neural network accelerator automated design method according to claim 2, characterized in that: The FPGA-based neural network accelerator rapid verification method includes: Monitoring point integration: Specifically, by identifying the level to be monitored in XML, the monitoring module is automatically embedded in the hardware structure output interface of the corresponding level in the hardware generation process; when the neural network accelerator runs to the specified monitoring level, it receives the start signal and activates it, and then performs real-time detection on the corresponding hardware output; Accelerator error detection: Specifically, the accelerator is mapped to the FPGA architecture to perform model operations and maintain dynamic communication between the accelerator and the host. Under this architecture, the monitoring module is responsible for collecting the output information of the accelerator and forwarding it to the host in real time. At the same time, the host uses software simulation to execute the same network model and compare and analyze the consistency of the output of the software and hardware at the monitoring layer. Once a difference is found between the two results, an alarm is triggered, indicating that there may be errors in the operation of the accelerator. Accelerator fault debugging; aims to efficiently locate and resolve operational anomalies; once an accelerator execution error is detected, the system immediately notifies the accelerator to maintain the current state, then captures a full system snapshot of the FPGA and transmits it to the simulation software on the host platform to reconstruct the real-time state of the FPGA accelerator. By analyzing the signal waveforms of the surrounding units at the time of the fault, the root cause of the problem can be deeply explored and identified.
Citation Information
Cited By
Binaryzation neural network accelerator based on RISC-V
CN119536812A
Error detection architecture design method for multi-core safety-critical system
CN119937992A
