Task calculation method and device for convolutional neural network
By corresponding routing units and computing types one by one in the convolutional neural network, optimizing the computing process and parallel execution, the problem of large computing resources and insufficient flexibility in edge computing in convolutional neural networks is solved, and efficient task processing is achieved.
Patent Information
- Application Number
- CN202510365057.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-26
- Publication Date
- 2025-08-15
AI Technical Summary
The existing convolutional neural network architectures have problems such as high computing resource consumption, low energy efficiency and insufficient flexibility in edge computing scenarios, making it difficult to achieve real-time inference and quickly adapt to new task requirements at low power consumption.
By obtaining the task calculation data and routing configuration parameters of the pending tasks, the routing network node table of multiple routing units is determined, so that the routing units correspond to matrix calculation, pooling calculation, activation calculation and normalized calculation types, and optimize the calculation process and execute in parallel based on these parameters.
The processing efficiency and computing speed of convolutional neural network tasks are improved, parallel computing power is fully utilized, resource utilization is optimized, and the needs of different application scenarios are adapted.
Smart Images

Figure CN120494001A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a task calculation method and device for a convolutional neural network. Background Art
[0002] Convolutional Neural Networks (CNNs) are a type of feedforward neural network in deep learning that is suitable for processing grid-structured data, such as images and speech. CNNs, through their local receptive field and weight sharing, have achieved remarkable success in image recognition, video analysis, natural language processing, and other fields.
[0003] With the diversification and complexity of application scenarios, edge computing scenarios such as autonomous driving, augmented reality (AR) and virtual reality (VR) require hardware to achieve real-time inference processes with low power consumption. However, the existing convolutional neural network architecture has problems such as high computing resource consumption, low energy efficiency and lack of flexibility.
[0004] How to improve the processing efficiency of convolutional neural network tasks is an important issue that needs to be urgently addressed in the industry. Summary of the Invention
[0005] The present invention provides a convolutional neural network task calculation method and device to improve the processing efficiency of convolutional neural network tasks.
[0006] The present invention provides a task calculation method for a convolutional neural network, comprising the following steps: Obtaining task calculation data of a task to be processed and routing configuration parameters of the task to be processed, the routing configuration parameters being used to determine a calculation process for multiple routing units to perform calculations on the task calculation data, the calculation function performed by each routing unit corresponding one-to-one to a task calculation type, the task calculation types including a matrix calculation type, a pooling calculation type, an activation calculation type, and a normalization calculation type, and the task to be processed is a task implemented based on a convolutional neural network; Based on the routing configuration parameters, the routing network node table of each routing unit is determined, and the routing network node table is sent to each routing unit, so that the multiple routing units obtain calculation data from the task calculation data based on the network node table and execute the task calculation process of the task to be processed.
[0007] According to a task calculation method for a convolutional neural network provided by the present invention, determining the routing network node table of each routing unit based on the routing configuration parameters includes: Based on the routing configuration parameters, data flow information of the task computing data in the plurality of routing units is determined, and the routing network node table is generated based on the data flow information.
[0008] According to a task calculation method for a convolutional neural network provided by the present invention, the routing unit is used to be configured as any one of a matrix calculation unit, a pooling calculation unit, an activation calculation unit, and a normalization calculation unit according to the task calculation type.
[0009] The present invention also provides a task computing device for a convolutional neural network, the device comprising: a controller and a plurality of routing units; The controller is connected to the plurality of routing units respectively, and the plurality of routing units are connected to each other; The controller is used to obtain task calculation data of a task to be processed and routing configuration parameters of the task to be processed, determine a routing network node table of each routing unit based on the routing configuration parameters, and send the routing network node table to each routing unit, the routing configuration parameters are used to determine a calculation process for multiple routing units to perform calculations on the task calculation data, the calculation function performed by each routing unit corresponds one-to-one to the task calculation type, the task calculation type includes a matrix calculation type, a pooling calculation type, an activation calculation type, and a normalization calculation type, and the task to be processed is a task implemented based on a convolutional neural network; The routing unit is used to obtain calculation data from the task calculation data based on the network node table and execute a calculation process corresponding to the calculation data.
[0010] A task computing device for a convolutional neural network according to the present invention further includes: a storage unit; The first end of the storage unit is connected to the controller, and the second end of the storage unit is connected to each routing unit respectively, and is used to store the task calculation data of the task to be processed and the routing configuration parameters of the task to be processed.
[0011] According to a task computing device for a convolutional neural network provided by the present invention, the controller is further configured to: The task calculation data of the task to be processed and the routing configuration parameters of the task to be processed are acquired from the storage unit.
[0012] A task computing device for a convolutional neural network according to the present invention further includes: a host; The host is connected to the storage unit and is used to receive the task to be processed; The task to be processed is parsed to determine task calculation data of the task to be processed and routing configuration parameters of the task to be processed, and the task calculation data and the routing configuration parameters are sent to the storage unit.
[0013] According to a task computing device for a convolutional neural network provided by the present invention, the routing unit includes a reconfigurable computing subunit, a routing control subunit, and a storage subunit; The reconfigurable computing subunit is connected to the routing control subunit and is configured as any one of a matrix computing unit, a pooling computing unit, an activation computing unit, and a normalization computing unit according to a task computing type; The routing control subunit is connected to the storage subunit and is used to control data forwarding of the computing subunit based on the routing configuration parameters provided by the controller; The storage subunit is used to cache the calculation results of the calculation subunit.
[0014] The present invention also provides a convolutional neural network accelerator, comprising: a task computing device for a convolutional neural network as described in any one of the above items.
[0015] The present invention also provides a server comprising the convolutional neural network accelerator as described above.
[0016] The convolutional neural network task calculation method and device provided by the present invention achieve an efficient task calculation process by obtaining the task calculation data and routing configuration parameters of the task to be processed and determining the routing network node table of each routing unit based on these parameters. By establishing a one-to-one correspondence between task calculation types and routing units, each routing unit can implement a specific calculation type and be optimized for its specific calculation type, thereby improving task calculation efficiency. At the same time, this one-to-one correspondence allows different types of calculations to be executed in parallel on different routing units, fully utilizing the parallel computing capability and further improving processing speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 It is a flowchart of the task calculation method of the convolutional neural network provided by the present invention.
[0019] Figure 2 It is a schematic diagram of the connection structure of multiple routing units provided by the present invention.
[0020] Figure 3 It is a structural diagram of the task computing device of the convolutional neural network provided by the present invention.
[0021] Figure 4 This is a flow chart of the matrix calculation unit mode provided by the present invention.
[0022] Figure 5 This is a schematic diagram of the ELU function implementation process provided by the present invention.
[0023] Figure 6 It is a structural diagram of the convolutional neural network accelerator provided by the present invention. DETAILED DESCRIPTION
[0024] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0025] Convolutional neural networks (CNNs) are a type of feedforward neural network in deep learning that is suitable for processing grid-structured data, such as images and speech. CNNs, through their local receptive field and weight sharing, have achieved remarkable success in image recognition, video analysis, natural language processing, and other fields.
[0026] As application scenarios become more diverse and complex, edge computing scenarios such as autonomous driving and AR / VR require hardware to achieve real-time reasoning with low power consumption. However, the convolutional neural network architecture used in related methods suffers from problems such as high computing resource consumption, low energy efficiency, and insufficient flexibility. Specific drawbacks include the following: High energy consumption: When processing large-scale data, traditional CNN models require a large amount of computing resources, which leads to high energy consumption. Data transfer energy consumption accounts for more than 60%, becoming a key bottleneck for energy efficiency optimization.
[0027] Inefficiency: For different application scenarios, a fixed network architecture may not provide optimal performance, resulting in a waste of computing resources.
[0028] Storage wall effect: Traditional architectures use a "compute-storage" separation design. The access cycle of off-chip DRAM is 100 times that of on-chip SRAM. As a result, computing units often stall due to unready data, the storage system is overloaded due to high concurrent access, and the overall system utilization rate is often less than 50% of peak performance.
[0029] Lack of flexibility: The CNN implementation solutions in related methods often find it difficult to quickly adapt to new task requirements or adjust the network structure to optimize performance, and cannot balance the low power consumption requirements of edge devices with the high computing power requirements of complex models.
[0030] In view of the defects in the related methods, the present invention provides a task calculation method of convolutional neural network. Figure 1 It is a flowchart of the task calculation method of the convolutional neural network provided by the present invention, such as Figure 1 As shown, the method includes the following: Step 110: Obtain task calculation data of the task to be processed and routing configuration parameters of the task to be processed, wherein the routing configuration parameters are used to determine a calculation process for multiple routing units to perform calculations on the task calculation data. The calculation function performed by each routing unit corresponds to a task calculation type. The task calculation type includes a matrix calculation type, a pooling calculation type, an activation calculation type, and a normalization calculation type. The task to be processed is a task implemented based on a convolutional neural network. Step 120: Based on the routing configuration parameters, determine the routing network node table of each routing unit, and send the routing network node table to each routing unit, so that the multiple routing units obtain calculation data from the task calculation data based on the network node table and execute the task calculation process of the task to be processed.
[0031] The convolutional neural network task computation method provided by the present invention can be executed by an electronic device, a component of an electronic device, an integrated circuit, or a chip. The electronic device can be a mobile electronic device or a non-mobile electronic device. Exemplary mobile electronic devices include mobile phones, tablet computers, laptop computers, PDAs, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), while non-mobile electronic devices include servers, network attached storage (NAS), or personal computers (PCs), among others, though the present invention does not impose specific limitations thereon.
[0032] The following takes the task calculation method of the convolutional neural network provided by the present invention executed by a computer as an example to explain the technical solution of the present invention in detail.
[0033] In step 110, the task calculation data of the task to be processed and the routing configuration parameters of the task to be processed are obtained. The routing configuration parameters are used to determine the calculation process of multiple routing units performing calculations on the task calculation data. The calculation function performed by each routing unit corresponds one-to-one to the task calculation type. The task calculation type includes a matrix calculation type, a pooling calculation type, an activation calculation type, and a normalization calculation type. The task to be processed is a task implemented based on a convolutional neural network.
[0034] Task computation data is all the input data required for the task to be processed. This data may include images, feature maps, weight matrices, etc. In convolutional neural networks, task computation data is usually preprocessed and input into the network in a specific format (such as tensor).
[0035] Routing configuration parameters are used to determine the computational flow of multiple routing units performing computations on task computation data. Specifically, they may include computational flow, routing unit mapping, and data dependencies.
[0036] Computational flow: How data flows between routing units and the specific computational operations performed by each routing unit. Routing unit mapping: Mapping task computation types (such as matrix calculations, pooling calculations, activation calculations, and normalization calculations) to specific routing units. Data dependencies: Defining the data dependencies between various computational steps to ensure the correctness of the computational process.
[0037] Routing units are modules that perform specific computing tasks. They receive input data according to routing configuration parameters, perform computing operations, and output computing results.
[0038] It should be noted that the computing functions performed by multiple routing units correspond one-to-one to the task computing type. That is, each routing unit performs one type of computing function. For example, for a set of four routing units, the first routing unit is used to implement the matrix computing type, the second routing unit is used to implement the pooling computing type, the third routing unit is used to implement the activation computing type, and the fourth routing unit is used to implement the normalization computing type.
[0039] According to the four task calculation types, the tasks to be processed are parsed to obtain the task calculation data and routing configuration parameters of the tasks to be processed, so that the subsequent routing units correspond to the data types calculated by them.
[0040] The connection structure diagram of multiple routing units can be as follows: Figure 2The present invention provides a schematic diagram of the connection structure of multiple routing units. Four routing units are arranged in a ring topology. The overall architecture is divided into the eastern and western hemispheres. The two routing units in the western hemisphere access the DDR0 on-chip storage on the same side, while the two routing units in the eastern hemisphere access the DDR1 on-chip storage. This access strategy improves data access concurrency, reduces the probability of data access congestion, and helps improve computing and memory access efficiency. The control process of task calculation can be implemented based on the RISC-V controller.
[0041] Optionally, the routing unit can be composed of a routing control unit, a reconfigurable computing unit and an SRAM cache unit, wherein the routing control unit controls data forwarding of the reconfigurable computing unit according to the routing network node table provided by the RISC-V controller; the reconfigurable computing unit has flexible reconfigurability, supports matrix multiplication operations, pooling operations, activation operations, and normalization operations, and is configured as any one of the matrix computing unit, pooling computing unit, activation computing unit, and normalization computing unit according to the task calculation type; the SRAM cache unit is used to cache the intermediate results of the computing unit, especially for memory-intensive tasks, which can effectively avoid frequent access between the computing unit and the on-chip storage DDR, thereby improving data memory access efficiency.
[0042] In step 120, based on the routing configuration parameters, the routing network node table of each routing unit is determined, and the routing network node table is sent to each routing unit, so that the multiple routing units obtain calculation data from the task calculation data based on the network node table and execute the task calculation process of the task to be processed.
[0043] The routing network node table is a data structure that describes the connections and computational processes between routing units. It defines the input sources, output targets, and computational operations performed by each routing unit. Through the routing network node table, routing units can work together to complete complex computational tasks.
[0044] After determining the routing network node table, it is sent to each routing unit. After receiving the node table, the routing unit will configure its own calculation process and input and output relationships based on the information in the node table.
[0045] After configuration is complete, each routing unit begins executing the task calculation process. Based on the definitions in the node table, they obtain the required input data from the task calculation data, perform the calculation operation, and output the calculation results to the designated target node. Through the coordinated work of each routing unit, the task calculation process for the pending task is ultimately completed.
[0046] The convolutional neural network task calculation method provided by the present invention obtains the task calculation data and routing configuration parameters of the task to be processed, and determines the routing network node table of each routing unit based on these parameters to achieve an efficient task calculation process. By establishing a one-to-one correspondence between task calculation types and routing units, each routing unit can implement a specific calculation type and be optimized for its specific calculation type, thereby improving task calculation efficiency. At the same time, this one-to-one correspondence allows different types of calculations to be executed in parallel on different routing units, fully utilizing the parallel computing capability and further improving processing speed.
[0047] In one embodiment, determining the routing network node table of each routing unit based on the routing configuration parameters includes: determining the data flow information of the task computing data in the multiple routing units based on the routing configuration parameters, and generating the routing network node table based on the data flow information.
[0048] Routing configuration parameters play a crucial role in convolutional neural network-based task processing. These parameters not only define the computational functionality of each routing unit (such as convolutional layers, pooling layers, activation layers, etc.), but also determine the flow of task computation data between these units.
[0049] Based on the routing configuration parameters, an empty directed graph is created, where nodes represent routing units and edges represent data flow directions. Based on the routing unit definitions in the routing configuration parameters, corresponding nodes are added to the directed graph, and each node is labeled with its type and configuration parameters. Based on the data dependencies in the routing configuration parameters, edges are added to the directed graph, connecting the corresponding input and output nodes. These edges represent the flow of data from one routing unit to another, thus confirming the data flow direction.
[0050] Based on the determined data flow information, a routing network node table can be generated, which describes in detail the input and output relationship, calculation function and connection method of each routing unit with other routing units.
[0051] In one embodiment, the routing unit is configured as any one of a matrix computing unit, a pooling computing unit, an activation computing unit, and a normalization computing unit according to a task computing type.
[0052] The routing unit can be configured as needed so that the computing function of the routing unit corresponds one-to-one with the task computing type.
[0053] Each routing unit focuses on its specific type of calculation and can more deeply explore the characteristics and laws of that type of calculation, thereby improving processing performance and accuracy.
[0054] The one-to-one correspondence enables different types of calculations to be executed in parallel on different routing units, fully utilizing the parallel computing capabilities and further improving the processing speed.
[0055] The present invention also provides a task computing device for a convolutional neural network, which specifically includes a controller and multiple routing units.
[0056] Specifically, the controller is connected to the multiple routing units respectively, and the multiple routing units are connected to each other; The controller is used to obtain task calculation data of a task to be processed and routing configuration parameters of the task to be processed, determine a routing network node table of each routing unit based on the routing configuration parameters, and send the routing network node table to each routing unit, the routing configuration parameters are used to determine a calculation process for multiple routing units to perform calculations on the task calculation data, the calculation function performed by each routing unit corresponds one-to-one to a task calculation type, the task calculation type includes a matrix calculation type, a pooling calculation type, an activation calculation type, and a normalization calculation type, and the task to be processed is a task implemented based on a convolutional neural network; The routing unit is used to obtain calculation data from the task calculation data based on the network node table and execute a calculation process corresponding to the calculation data.
[0057] The device further includes a storage unit and a host. The first end of the storage unit is connected to the controller, and the second end of the storage unit is connected to each routing unit, respectively, for storing the task calculation data of the pending task and the routing configuration parameters of the pending task. The host is connected to the storage unit and is configured to receive the pending task, parse the pending task, determine the task calculation data of the pending task and the routing configuration parameters of the pending task, and send the task calculation data and the routing configuration parameters to the storage unit.
[0058] Optionally, the structural diagram of the task computing device of the convolutional neural network can be as follows Figure 3 The structural diagram of the task computing device of the convolutional neural network provided by the present invention is shown in FIG.
[0059] The device uses an AXI bus to organize multiple Router Units (RUs) into a ring topology. The storage units are implemented based on DDR0 and DDR1, and the controller is based on a RISC-V controller. The overall architecture of the device is divided into eastern and western hemispheres. The two routing units in the western hemisphere access the same side of the on-chip DDR0 memory, while the two routing units in the eastern hemisphere access the on-chip DDR1 memory. The RISC-V controller flexibly manages the configuration of the four routing units by constructing a routing network node table and providing control instructions. Data forwarding and SRAM cache access are implemented between the four routing units via the AXI bus.
[0060] When a user generates a pending task, the host parses and determines the task calculation data and routing configuration parameters for the pending task. The host then sends these data to the storage unit, which then forwards them to on-chip memory DDR0 and DDR1 via PCIE DMA. The RISC-V controller then starts up. The RISC-V controller then reads instruction information from the instruction storage space and configures the routing unit mode and data forwarding path based on the routing configuration parameters. The routing unit (RU) then reads the pending data from the same-side DDR or SRAM (local or adjacent RU) according to the instructions issued by the RISC-V controller. After calculation, the final result is forwarded to the DDR or SRAM of the next-level RU.
[0061] The routing unit consists of a reconfigurable computing subunit, a routing control subunit, and a storage subunit SRAM cache. The reconfigurable computing subunit is connected to the routing control subunit and configured as any one of a matrix computing unit, a pooling computing unit, an activation computing unit, and a normalization computing unit based on the task calculation type. The routing control subunit is connected to the storage subunit and controls data forwarding of the computing subunit based on routing configuration parameters provided by the controller. The storage subunit is used to cache the calculation results of the computing subunit.
[0062] Specifically, the routing control subunit contains two data channels. The instruction channel uses the AXI-Lite bus to forward control instruction information issued by the RISC-V controller, while the data channel uses the high-speed AXI-MM (AXI-MemoryMap) bus to efficiently forward pending data and supports access to DDR or SRAM (local or remote SRAM) on the same side. The storage subunit is used to cache the intermediate results of the computing unit. The local SRAMs of different computing units can access each other through the routing control subunit. The reconfigurable computing subunit, as the core unit of the RU, is mainly responsible for various functional operations. According to the type of computing task, the reconfigurable computing subunit can be flexibly configured to support matrix multiplication, pooling, activation, and normalization operations.
[0063] As the core unit of the RU, the reconfigurable computing subunit supports fine-grained reconfiguration. Depending on the task type, it can be configured as any of the following: a matrix computing unit, a pooling computing unit, an activation computing unit, or a normalization computing unit. The network structure can be dynamically adjusted according to the specific application scenario and the convolutional neural network model. It is divided into fusion mode and independent mode. Fusion mode maps different layers of the network model to the RU to form a pipeline, while independent mode configures the RU as an independent special function to implement a specific layer of calculation in the network model. Optimizing configuration for different tasks improves computing efficiency and resource utilization.
[0064] The matrix calculation unit consists of a multiplier and an adder, and can select standard mode or sparse mode according to the instructions of the routing controller. The specific mode operation process is shown as follows Figure 4 As shown in the flow chart of the matrix calculation unit mode provided by the present invention, taking 2x1 and 2x2 as examples, in standard mode, the matrix calculation unit reads the A and B matrices from the DDR on the same side according to the Tile size for calculation, and the final result of the calculation is forwarded to the DDR or the SRAM of the next level RU according to the task type. In sparse mode, the matrix calculation unit first reads the A matrix, and then reads the corresponding valid data in the B matrix according to the valid bits in the index table T ("1" indicates valid data, "0" indicates invalid data) to perform matrix multiplication and addition operations. The final result is forwarded to the DDR or the SRAM of the next level RU according to the task type. The default Tile size is 4x4.
[0065] The activation unit implements the nonlinear activation function ELU (Exponential Linear Unit). The ELU function can reduce the saturation of negative inputs and accelerate network convergence, which helps the CNN model extract image features more efficiently. Based on the mathematical properties of nonlinear functions, its formula is: ; Taking into account the hardware resources and function characteristics, the present invention adopts the LUT lookup table to store the output results corresponding to the input x in the range of [a, b]. The input x outside the range is output according to the linear expression f(x)=x, saving hardware resources within the range allowed by the loss of accuracy. The ELU function implementation process is as follows: Figure 5 The ELU function implementation process provided by the present invention is shown in the schematic diagram.
[0066] The normalization calculation unit implements batch normalization. The main idea of Batch Normalization (BN) is to normalize the input of each batch so that the mean of the input data is close to 0 and the variance is close to 1. This operation is a common technique in deep learning neural networks. It is used to accelerate convergence and improve model stability during model training, and it reduces sensitivity to hyperparameters. The BN operation can also be considered a regularization method because it can reduce the risk of overfitting the model. Because this operation involves mean and variance calculations, its implementation method is similar to the ELU function, using a lookup table approximation method. The implementation formula is: ; Where u is the input The mean of the samples, The variance of the sample is obtained by removing the mean of the n input sample data and dividing it by the standard deviation to obtain the normal distribution standardized data. The parameters γ and β are introduced to scale and translate the standardized data.
[0067] The pooling calculation unit is designed for convolutional neural networks and implements the role of the pooling layer in neural networks. It is mainly used to reduce the model's computational complexity, reduce the difficulty of network optimization, prevent network overfitting, and make the model more robust to changes in feature positions in the input image. The pooling calculation unit supports maximum pooling and average pooling, which are mainly implemented by a comparator, divider, and accumulator. By moving the pooling window on the feature map and selecting the maximum or average pixel to generate a new feature map, the size of the feature map matrix and the computational complexity are reduced.
[0068] The present invention also provides a convolutional neural network accelerator, comprising the task computing device of the convolutional neural network as described above.
[0069] The structural diagram of the convolutional neural network accelerator can be shown as follows Figure 6 The structural schematic diagram of the convolutional neural network accelerator provided by the present invention is shown in the figure.
[0070] Specifically, when using the fusion mode, the configuration and deployment of RU can form an accelerator for convolutional neural networks. At the same time, the independent mode can also be used to perform fine-grained configuration of matrix operations, nonlinear function activation operations, and normalization operations in the neural network to form a special function accelerator.
[0071] The convolutional neural network accelerator consists of four RUs. Through fine-grained reconfiguration, the convolutional, activation, pooling, and fully connected layers of the convolutional neural network are mapped to the matrix, activation, pooling, and normalization computation units within the RUs, respectively. The RISC-V controller constructs a data flow routing network node table based on the task type: {{0,0}, {0,1}, {1,0}, {1,1}}, representing the positions of the four RUs in the network, namely the matrix, activation, pooling, and normalization computation units, respectively. Based on the task computation process, data flow is planned from {0,0} to {0,1}, then to {1,1}, and finally to node {1,0}. However, due to the fine-grained reconfiguration, the node positions corresponding to the computation units are not fixed, allowing for flexible data flow paths.
[0072] The specific implementation process of the image processing task implemented by the convolutional neural network accelerator is as follows: 1) The host uses a convolutional neural network model for inference based on image processing application scenarios. Based on the characteristics of the neural network, it abstracts the API operations for the convolutional, activation, pooling, and fully connected layers, forming a data flow computation task. Simultaneously, the host requests memory to cache the feature map data and routing configuration parameters for the pending task. Initially, the feature map data and routing configuration parameters are cached in a designated area of DDR0 via PCIe DMA. The routing configuration parameters and feature map data are stored in blocks. Simultaneously, the RISC-V controller is started.
[0073] 2) After detecting the routing configuration parameters in DDR0, the RISC-V controller maps the neural network model to the computational units in the RU, sequentially reconstructing them into matrix computation units, activation computation units, normalization computation units, and pooling computation units. The corresponding RUs are labeled RU-Mult, RU-Act, RU-BN, and RU-Pool, respectively. Data flow is planned based on the network model: from {0,0} to {0,1}, then to {1,1}, and finally to node {1,0}. The abstract model configuration is then converted into instruction control information and transmitted to the node routing controller via the AXI-Lite bus to complete the reconstruction. The matrix computation unit mode is set to standard mode, and the pooling computation unit mode is set to maximum pooling mode.
[0074] 3) After the RISC-V controller completes configuration of all node RUs, it first starts the matrix calculation unit in the {0,0} node RU-Mult. It reads the feature map data from DDR0 via the routing controller's AXI-MM data bus and caches it in local SRAM. The calculation unit then reads data from the SRAM, performs matrix multiplication and addition, and temporarily stores the first result in the cumulative result area in the SRAM. It then continues to read feature data and adds the result to the first result, repeating the multiplication and accumulation operations to obtain the final result, Res1. After RISC-V detects that the matrix calculation unit has completed the operation, it forwards the Res1 result to the SRAM of the {0,1} node (RU-Act) through the RU-Mult routing controller.
[0075] 4) After completing step 3), the RISC-V controller activates RU-Act. The activated computation unit reads the data to be processed, namely the feature matrix, from SRAM. The activated computation unit uses the ELU activation function and performs a segmented approximation based on the input information using a lookup table, obtaining the output matrix Res2. After the computation is complete, the RISC-V controller forwards Res2 from the SRAM of the current node to the SRAM of the next node, RU-Pool, through the RU-Act routing controller and activates the pooled computation unit of RU-Pool.
[0076] 5) The pooling computation unit of RU-Pool reads the matrix Res2 from local SRAM and performs a pooling operation based on the maximum pooling algorithm to reduce the size of the feature matrix and the computational complexity. By moving the pooling window (a WxH two-dimensional matrix), the maximum value of the pixels within the window is selected and replaced with the pixel value within the pooling window. This operation is repeated to generate a new feature map matrix Res3, which is cached in the SRAM of the current node. After the operation is complete, the RISC-V controller forwards Res3 from the SRAM of the current node to the SRAM of the next node, RU-BN, through the RU-Pool routing controller and activates the normalization computation unit of RU-BN.
[0077] The calculation process of the normalization calculation unit is similar to steps 4) and 5). A lookup table segmented fitting approximation algorithm is designed according to the formula. Different input ranges are mapped to different function intervals, and the final result Res4 is obtained.
[0078] 6) After the RISC-V controller detects the completion of the task pipeline, it caches the final calculation result (Res4) from the RU-BN's SRAM to DDR0 on the same side of the RU. It also releases the routing network node table, deactivates all RUs, and transmits a task completion signal to the host, waiting for the next task to be dispatched. After the host detects the task completion signal from the RISC-V controller, it removes the calculation result from DDR0 and selects a task from the task queue to dispatch.
[0079] The present invention also provides a server comprising the convolutional neural network accelerator as described above.
[0080] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0081] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.
[0082] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A task calculation method for a convolutional neural network, characterized in that: include Obtaining task calculation data of a task to be processed and routing configuration parameters of the task to be processed, the routing configuration parameters being used to determine a calculation process for multiple routing units to perform calculations on the task calculation data, the calculation function performed by each routing unit corresponding one-to-one to a task calculation type, the task calculation types including a matrix calculation type, a pooling calculation type, an activation calculation type, and a normalization calculation type, and the task to be processed is a task implemented based on a convolutional neural network; Based on the routing configuration parameters, the routing network node table of each routing unit is determined, and the routing network node table is sent to each routing unit, so that the multiple routing units obtain calculation data from the task calculation data based on the network node table and execute the task calculation process of the task to be processed.
2. The task calculation method of the convolutional neural network according to claim 1, characterized in that The determining of the routing network node table of each routing unit based on the routing configuration parameters includes: Based on the routing configuration parameters, data flow information of the task computing data in the plurality of routing units is determined, and the routing network node table is generated based on the data flow information.
3. The task calculation method of convolutional neural network according to claim 1, characterized in that The routing unit is configured as any one of a matrix computing unit, a pooling computing unit, an activation computing unit, and a normalization computing unit according to a task computing type.
4. A task computing device for a convolutional neural network, characterized in that: The device includes: a controller and a plurality of routing units; The controller is connected to the plurality of routing units respectively, and the plurality of routing units are connected to each other; The controller is used to obtain task calculation data of a task to be processed and routing configuration parameters of the task to be processed, determine a routing network node table of each routing unit based on the routing configuration parameters, and send the routing network node table to each routing unit, the routing configuration parameters are used to determine a calculation process for multiple routing units to perform calculations on the task calculation data, the calculation function performed by each routing unit corresponds one-to-one to the task calculation type, the task calculation type includes a matrix calculation type, a pooling calculation type, an activation calculation type, and a normalization calculation type, and the task to be processed is a task implemented based on a convolutional neural network; The routing unit is used to obtain calculation data from the task calculation data based on the network node table and execute a calculation process corresponding to the calculation data.
5. The task computing device of the convolutional neural network according to claim 4, characterized in that Also included: a storage unit; The first end of the storage unit is connected to the controller, and the second end of the storage unit is connected to each routing unit respectively, and is used to store the task calculation data of the task to be processed and the routing configuration parameters of the task to be processed.
6. The task computing device of the convolutional neural network according to claim 5, characterized in that The controller is also used for: The task calculation data of the task to be processed and the routing configuration parameters of the task to be processed are acquired from the storage unit.
7. The task computing device of the convolutional neural network according to claim 6, characterized in that Also includes: Host; The host is connected to the storage unit and is used to receive the task to be processed; The task to be processed is parsed to determine task calculation data of the task to be processed and routing configuration parameters of the task to be processed, and the task calculation data and the routing configuration parameters are sent to the storage unit.
8. The task computing device of convolutional neural network according to claim 4, characterized in that The routing unit includes a reconfigurable computing subunit, a routing control subunit and a storage subunit; The reconfigurable computing subunit is connected to the routing control subunit and is configured as any one of a matrix computing unit, a pooling computing unit, an activation computing unit, and a normalization computing unit according to a task computing type; The routing control subunit is connected to the storage subunit and is used to control data forwarding of the computing subunit based on the routing configuration parameters provided by the controller; The storage subunit is used to cache the calculation results of the calculation subunit.
9. A convolutional neural network accelerator, characterized in that: include: A task computing device for a convolutional neural network as described in any one of claims 4 to 8.
10. A server, characterized in that: include: The convolutional neural network accelerator according to claim 9.
Citation Information
Cited By
Method for adjusting resources in processor and related product
CN121116647A