Multi-mode convolutional neural network accelerator and acceleration method based on RISC-V

By designing a multi-mode convolutional neural network accelerator based on RISC-V and adopting appropriate data loading strategies, the compatibility and efficiency issues of existing accelerators are solved, and efficient convolution operations and low power consumption are achieved.

CN118350429BActive Publication Date: 2024-08-30SHANDONG INSPUR SCI RES INST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410748737.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-08-30
Estimated Expiration
2044-06-12

AI Technical Summary

Technical Problem

Existing convolutional neural network accelerators are difficult to be compatible with optimization standards and depth-separable convolution, resulting in acceleration efficiency and power consumption issues that have not been effectively solved.

Method used

Design a multi-mode convolutional neural network accelerator based on RISC-V, using instruction interface, data interface, decoding module, data distribution module, mode control module, address generation module, feature loading module, post-processing module and convolution unit, By optimizing the data loading and weight loading strategies, the compatibility and acceleration efficiency of standard and depth-separable convolutions are supported.

Benefits of technology

It achieves higher acceleration performance and resource utilization, reduces power consumption, adopts optimal data flow modes through different convolution types, and improves the usage efficiency and computing efficiency of the processing unit.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118350429B
    Figure CN118350429B
Patent Text Reader

Abstract

The present invention discloses a multi-mode convolutional neural network accelerator based on RISC-V and an acceleration method, which belong to the technical field of processors. The technical problem to be solved by the present invention is how to optimize the acceleration efficiency and power consumption of a convolutional neural network accelerator compatible with standard and depthwise separable convolution. The technical scheme adopted is: the accelerator comprises an instruction interface, a data interface, a decoding module, a data distribution module, a mode control module, an address generation module, a feature loading module, a post-processing module and a convolution unit, and the convolution unit comprises a plurality of PEs; the instruction interface is used to receive a custom RISC-V instruction sent by an execution unit in a main processor, and send the instruction to a register unit in the main processor for feedback; the data interface is used to perform data interaction with a data loading and storage unit in the main processor; the decoding module is used to decode the custom RISC-V instruction sent by the execution unit in the main processor.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of processor technology, and in particular to a RISC-V-based multi-mode convolutional neural network accelerator and an acceleration method. Background Art

[0002] A convolutional neural network accelerator (CNN accelerator) is a hardware device or system designed specifically to accelerate the calculation of convolutional neural networks (CNN). Due to the wide application of CNN in deep learning, especially in the fields of image recognition and natural language processing, the amount of calculation is huge, which places high demands on hardware performance.

[0003] Convolutional neural networks are widely used in many fields such as image recognition. For embedded platforms with limited resources, in addition to standard convolution, depthwise separable convolution is also widely used due to its flexibility and small size. For existing convolutional neural network accelerators, it is usually difficult to well accommodate the two convolution strategies: standard convolution accelerators cannot support depthwise separable convolution due to their determined data flow mode, while accelerators that support depthwise separable convolution will cause a lot of resource waste when supporting standard convolution.

[0004] Therefore, how to optimize the acceleration efficiency and power consumption of convolutional neural network accelerators that are compatible with standard and depthwise separable convolutions is a technical problem that needs to be solved urgently. Summary of the invention

[0005] The technical task of the present invention is to provide a RISC-V-based multi-mode convolutional neural network accelerator and acceleration method to solve the problem of how to optimize the acceleration efficiency and power consumption of a convolutional neural network accelerator that is compatible with standard and depth-separable convolution.

[0006] The technical task of the present invention is achieved in the following manner: a multi-mode convolutional neural network accelerator based on RISC-V, the accelerator includes an instruction interface, a data interface, a decoding module, a data distribution module, a mode control module, an address generation module, a feature loading module, a post-processing module and a convolution unit, and the convolution unit includes a plurality of PEs (processing units);

[0007] The instruction interface is used to receive the custom RISC-V instructions sent by the execution unit in the main processor, and send feedback to the register unit in the main processor;

[0008] The data interface is used to exchange data with the data loading and storage unit in the main processor;

[0009] The decoding module is used to decode the custom RISC-V instructions sent from the execution unit in the main processor;

[0010] The data distribution module is used to send a request to the data loading unit of the main processor through the data interface after receiving the memory access instruction, and dispatch the post-processing completion result stored in the specified RAM buffer specified by the address generation module to be sent back to the main processor;

[0011] The mode control module is used to configure the working modes of the address generation module, the feature loading module, the post-processing module and the PE in the convolution unit respectively after receiving the configuration instruction;

[0012] The address generation module is used to send the access address to the feature loading module and the weight loading module according to pre-configured parameters;

[0013] The feature loading module is used to load the weight data into the PE of the convolution unit after the feature map is rearranged and cached under the control of the mode control module;

[0014] The weight loading module is used to load data into the PEs in the convolution unit in sequence when the weight data is in place;

[0015] The PE in the convolution unit is used to complete the operation according to the parameters configured by the mode control module, and send the operation results to the post-processing module in order based on the PE tags in the convolution unit;

[0016] The post-processing module is used to receive the calculation results in order and perform post-processing operations to obtain the post-processing completion results.

[0017] Preferably, the convolution unit is based on the operation cycle, specifically: the feature map of each layer is based on the convolution kernel size , feature map size and step length Divided into × a×a parts, that is, i×a= ; The clock cycle is regarded as an operation cycle; the PE in the convolution unit completes the operation of each part synchronously within one operation cycle, and needs to continuously load data, while the weight data in the convolution kernel remains unchanged in each operation cycle and only needs to be updated once in each operation cycle. There is no need to load additional data that does not participate in the operation multiple times, that is, the data loading and weight loading strategies in the convolution unit need to load a total amount of data in one convolution. .

[0018] As a preference, the data loading and weight loading strategies in the convolutional unit are as follows:

[0019] For the layer-by-layer convolution part of the depth-wise separable convolution where the calculations of each channel are independent from each other, a row-first data loading strategy is adopted;

[0020] For the point-by-point convolution parts of standard convolution and depth-wise separable convolution, whose intermediate results between different layers also need to be cross-accumulated, a channel-first data loading strategy is adopted.

[0021] Preferably, the row-first data loading strategy is as follows:

[0022] Load a PE every clock cycle The data belonging to the convolution window is a column or a row in the same channel. After several operation cycles, the data operation of the convolution window is completed and the output eigenvalue is ready.

[0023] Preferably, the channel-priority data loading strategy is as follows:

[0024] Each clock cycle combines the channel dimension factors to select a value point for each channel and independently chooses to transmit data; after each operation cycle, the value points on all channels move to the next position to be valued, and a new round of data loading begins.

[0025] Preferably, the accelerator uses 0001011 as opcode, and opcode includes two instructions, configuration instruction cfg and operation instruction op, and extends seven instructions, cfg.adr, cfg.std, cfg.mod, cfg.cnt, op.rst, op.ram and op.ctl;

[0026] Among them, the cfg.adr instruction is used to configure the base address of the feature map and weight;

[0027] The cfg.std directive is used to configure the step size during convolution operations and post-processing;

[0028] cfg.mod is used to tell the accelerator which operating mode it should be in, where the operating mode includes the convolution operation mode, pooling window size, and feature map discarding method;

[0029] cfg.cnt is used to configure the number of continuously available data batches during standard convolution and point-by-point convolution and the number of sliding windows in the convolution operation;

[0030] op.rst is used to initialize the accelerator;

[0031] op.ctl is used to change the working state of the accelerator, including changing from idle to called state;

[0032] op.ram is used to control data interaction between the main processor and the accelerator.

[0033] A multi-mode convolutional neural network acceleration method based on RISC-V, which participates in the convolution acceleration operation in the form of a coprocessor, is as follows:

[0034] When in the instruction execution stage of the main processor, the coprocessor is connected to the main processor through the instruction interface and data interface of the coprocessor;

[0035] When convolution operation acceleration is required, the main processor calls the convolutional neural network accelerator and sends a custom RISC-V instruction to the convolutional neural network accelerator through the instruction interface of the coprocessor. The instruction interface of the coprocessor receives the instruction, sends feedback and decodes the instruction; and sends the decoded content to the data distribution module or the mode control module according to the category;

[0036] After receiving the memory access instruction, the data distribution module sends a request to the data load storage unit (Load&Store, LSU) of the main processor through the data interface; the main processor sends the feature map and weight map data to the convolutional neural network accelerator;

[0037] When receiving the configuration instruction, the mode control module configures the working modes of the address generation module, the feature loading module, the post-processing module and the PE (processing unit) in the convolution unit respectively;

[0038] After the convolution operation starts, the address generation module sends the access address to the feature and weight loading module according to the pre-configured parameters; the feature map is rearranged and cached under the control of the mode control module, and the weight loading module loads the weight data into the PE of the convolution calculation unit; when the weight data is in place, the feature loading module loads data to the PE in the convolution unit in turn, and the PE in the convolution unit completes the operation according to the parameters configured by the mode control module, and sends the operation results to the post-processing module in order based on the PE label; the results of the post-processing will be stored in the specified RAM buffer specified by the address generation module, and scheduled by the data distribution module to be sent back to the main processor.

[0039] As a preference, the data loading and weight loading strategies in the convolutional unit are as follows:

[0040] For the layer-by-layer convolution part of the depth-wise separable convolution where the calculations of each channel are independent from each other, a row-first data loading strategy is adopted;

[0041] For the point-by-point convolution parts of standard convolution and depth-wise separable convolution, whose intermediate results between different layers also need to be cross-accumulated, a channel-first data loading strategy is adopted.

[0042] Preferably, the row-first data loading strategy is as follows:

[0043] Load a PE every clock cycle The data belonging to the convolution window is a column or a row in the same channel. After several operation cycles, the data operation of the convolution window is completed and the output eigenvalue is ready.

[0044] The channel-priority data loading strategy is as follows:

[0045] Each clock cycle combines the channel dimension factors to select a value point for each channel and independently chooses to transmit data; after each operation cycle, the value points on all channels move to the next position to be valued, and a new round of data loading begins.

[0046] Preferably, the convolutional neural network accelerator uses 0001011 as opcode, and the opcode includes two instructions: configuration instruction cfg and operation instruction op, and extends seven instructions: cfg.adr, cfg.std, cfg.mod, cfg.cnt, op.rst, op.ram and op.ctl;

[0047] Among them, the cfg.adr instruction is used to configure the base address of the feature map and weight;

[0048] The cfg.std directive is used to configure the step size during convolution operations and post-processing;

[0049] cfg.mod is used to tell the accelerator which operating mode it should be in, where the operating mode includes the convolution operation mode, pooling window size, and feature map discarding method;

[0050] cfg.cnt is used to configure the number of continuously available data batches during standard convolution and point-by-point convolution and the number of sliding windows in the convolution operation;

[0051] op.rst is used to initialize the accelerator;

[0052] op.ctl is used to change the working state of the accelerator, including changing from idle to called state;

[0053] op.ram is used to control data interaction between the main processor and the accelerator.

[0054] The RISC-V-based multi-mode convolutional neural network accelerator and acceleration method of the present invention have the following advantages:

[0055] (I) The present invention proposes a configurable convolutional neural network accelerator that is compatible with standard and depth-separable convolutions. The accelerator's computing unit is based on the idea of ​​computing cycles and a variable data flow structure. At the same time, the accelerator is controlled by the RISC-V extended instruction set, which has better performance in acceleration performance, compatibility and resource consumption.

[0056] (ii) The present invention adopts a convolution computing unit design based on data cycles through RISC-V extended instruction set control, has a smaller data loading density, and optimizes accelerator efficiency and power consumption; in addition, two convolution operation modes, standard convolution and depthwise separable convolution, are configurable, and the optimal data flow mode is set for different convolution modes, further improving the utilization efficiency of the processing unit;

[0057] (III) The present invention adopts different data loading methods for different convolution types to improve the utilization efficiency of PE, thereby improving the computational efficiency of the convolution operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] The present invention is further described below in conjunction with the accompanying drawings.

[0059] Attached Figure 1 This is a block diagram of the RISC-V-based multi-mode convolutional neural network accelerator.

[0060] Attached Figure 2 Schematic diagram of a convolution unit. DETAILED DESCRIPTION

[0061] The RISC-V-based multi-mode convolutional neural network accelerator and acceleration method of the present invention are described in detail below with reference to the drawings and specific embodiments of the specification.

[0062] Embodiment 1: As attached Figure 1 As shown, this embodiment provides a RISC-V-based multi-mode convolutional neural network accelerator, which includes an instruction interface, a data interface, a decoding module, a data distribution module, a mode control module, an address generation module, a feature loading module, a post-processing module and a convolution unit, and the convolution unit includes a plurality of PEs (processing units);

[0063] The instruction interface is used to receive the custom RISC-V instructions sent by the execution unit in the main processor, and send feedback to the register unit in the main processor;

[0064] The data interface is used to exchange data with the data loading and storage unit in the main processor;

[0065] The decoding module is used to decode the custom RISC-V instructions sent from the execution unit in the main processor;

[0066] The data distribution module is used to send a request to the data loading unit of the main processor through the data interface after receiving the memory access instruction, and dispatch the post-processing completion result stored in the specified RAM buffer specified by the address generation module to be sent back to the main processor;

[0067] The mode control module is used to configure the working modes of the address generation module, the feature loading module, the post-processing module and the PE in the convolution unit respectively after receiving the configuration instruction;

[0068] The address generation module is used to send the access address to the feature loading module and the weight loading module according to pre-configured parameters;

[0069] The feature loading module is used to load the weight data into the PE of the convolution unit after the feature map is rearranged and cached under the control of the mode control module;

[0070] The weight loading module is used to load data into the PEs in the convolution unit in sequence when the weight data is in place;

[0071] The PE in the convolution unit is used to complete the operation according to the parameters configured by the mode control module, and send the operation results to the post-processing module in order based on the PE tags in the convolution unit;

[0072] The post-processing module is used to receive the calculation results in order and perform post-processing operations to obtain the post-processing completion results.

[0073] A major feature of convolution operation is that the number of parameters involved in the operation is small, but the overall amount of operation is large. × The matrix, using × The convolution kernel size is in steps of The operation can be expressed as:

[0074] ;

[0075] From the above formula, we can see that the amount of computation required for a single convolution is , so the total amount of data that needs to be loaded is Repeated data loading will cause additional resource consumption to the accelerator, such as Figure 2 As shown, the convolution unit is based on the operation cycle, specifically: the feature map of each layer is based on the convolution kernel size , feature map size and step length Divided into × a×a parts, that is, i×a= ; The clock cycle is regarded as an operation cycle; the PE in the convolution unit completes the operation of each part synchronously within one operation cycle, and needs to continuously load data, while the weight data in the convolution kernel remains unchanged in each operation cycle and only needs to be updated once in each operation cycle. There is no need to load additional data that does not participate in the operation multiple times, that is, the data loading and weight loading strategies in the convolution unit need to load a total amount of data in one convolution. .

[0076] The data loading and weight loading strategies in the convolution unit in this embodiment are as follows:

[0077] For the layer-by-layer convolution part of the depth-wise separable convolution where the calculations of each channel are independent from each other, a row-first data loading strategy is adopted;

[0078] For the point-by-point convolution parts of standard convolution and depth-wise separable convolution, whose intermediate results between different layers also need to be cross-accumulated, a channel-first data loading strategy is adopted.

[0079] In this embodiment, the row-first data loading strategy is specifically as follows:

[0080] Load a PE every clock cycle The data belonging to the convolution window is a column or a row in the same channel. After several operation cycles, the data operation of the convolution window is completed and the output eigenvalue is ready.

[0081] In this embodiment, the channel-priority data loading strategy is specifically as follows:

[0082] Each clock cycle combines the channel dimension factors to select a value point for each channel and independently chooses to transmit data; after each operation cycle, the value points on all channels move to the next position to be valued, and a new round of data loading begins.

[0083] The convolution mode that the accelerator needs to adapt at the moment is determined by the main controller, and the custom RISC-V instruction is decoded by the decoding module, and a control signal is sent to the mode control module to configure the data loading mode, etc. The accelerator in this embodiment uses 0001011 as the opcode, and the opcode includes two instructions: configuration instruction cfg and operation instruction op, and extends seven instructions: cfg.adr, cfg.std, cfg.mod, cfg.cnt, op.rst, op.ram, and op.ctl; as shown in the following table:

[0084]

[0085] Among them, the cfg.adr instruction is used to configure the base address of the feature map and weight;

[0086] The cfg.std directive is used to configure the step size during convolution operations and post-processing;

[0087] cfg.mod is used to tell the accelerator which operating mode it should be in, where the operating mode includes the convolution operation mode, pooling window size, and feature map discarding method;

[0088] cfg.cnt is used to configure the number of continuously available data batches during standard convolution and point-by-point convolution and the number of sliding windows in the convolution operation;

[0089] op.rst is used to initialize the accelerator;

[0090] op.ctl is used to change the working state of the accelerator, including changing from idle to called state;

[0091] op.ram is used to control data interaction between the main processor and the accelerator.

[0092] Embodiment 2: As attached Figure 1 As shown, a multi-mode convolutional neural network acceleration method based on RISC-V in this embodiment, the method participates in the convolution acceleration operation in the form of a coprocessor, and is specifically as follows:

[0093] When in the instruction execution stage of the main processor, the coprocessor is connected to the main processor through the instruction interface and data interface of the coprocessor;

[0094] When convolution operation acceleration is required, the main processor calls the convolutional neural network accelerator and sends a custom RISC-V instruction to the convolutional neural network accelerator through the instruction interface of the coprocessor. The instruction interface of the coprocessor receives the instruction, sends feedback and decodes the instruction; and sends the decoded content to the data distribution module or the mode control module according to the category;

[0095] After receiving the memory access instruction, the data distribution module sends a request to the data load storage unit (Load&Store, LSU) of the main processor through the data interface; the main processor sends the feature map and weight map data to the convolutional neural network accelerator;

[0096] When receiving the configuration instruction, the mode control module configures the working modes of the address generation module, the feature loading module, the post-processing module and the PE (processing unit) in the convolution unit respectively;

[0097] After the convolution operation starts, the address generation module sends the access address to the feature and weight loading module according to the pre-configured parameters; the feature map is rearranged and cached under the control of the mode control module, and the weight loading module loads the weight data into the PE of the convolution calculation unit; when the weight data is in place, the feature loading module loads data to the PE in the convolution unit in turn, and the PE in the convolution unit completes the operation according to the parameters configured by the mode control module, and sends the operation results to the post-processing module in order based on the PE label; the results of the post-processing will be stored in the specified RAM buffer specified by the address generation module, and scheduled by the data distribution module to be sent back to the main processor.

[0098] The data loading and weight loading strategies in the convolution unit in this embodiment are as follows:

[0099] For the layer-by-layer convolution part of the depth-wise separable convolution where the calculations of each channel are independent from each other, a row-first data loading strategy is adopted;

[0100] For the point-by-point convolution parts of standard convolution and depth-wise separable convolution, whose intermediate results between different layers also need to be cross-accumulated, a channel-first data loading strategy is adopted.

[0101] In this embodiment, the row-first data loading strategy is specifically as follows:

[0102] Load a PE every clock cycle The data belonging to the convolution window is a column or a row in the same channel. After several operation cycles, the data operation of the convolution window is completed and the output eigenvalue is ready.

[0103] The channel-priority data loading strategy is as follows:

[0104] Each clock cycle combines the channel dimension factors to select a value point for each channel and independently chooses to transmit data; after each operation cycle, the value points on all channels move to the next position to be valued, and a new round of data loading begins.

[0105] In this embodiment, the convolutional neural network accelerator uses 0001011 as opcode, and opcode includes two instructions: configuration instruction cfg and operation instruction op, and extends seven instructions: cfg.adr, cfg.std, cfg.mod, cfg.cnt, op.rst, op.ram, and op.ctl;

[0106] As shown in the following table:

[0107]

[0108] Among them, the cfg.adr instruction is used to configure the base address of the feature map and weight;

[0109] The cfg.std directive is used to configure the step size during convolution operations and post-processing;

[0110] cfg.mod is used to tell the accelerator which operating mode it should be in, where the operating mode includes the convolution operation mode, pooling window size, and feature map discarding method;

[0111] cfg.cnt is used to configure the number of continuously available data batches during standard convolution and point-by-point convolution and the number of sliding windows in the convolution operation;

[0112] op.rst is used to initialize the accelerator;

[0113] op.ctl is used to change the working state of the accelerator, including changing from idle to called state;

[0114] op.ram is used to control data interaction between the main processor and the accelerator.

[0115] 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 replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A multi-mode convolutional neural network accelerator based on RISC-V, characterized in that: The accelerator includes an instruction interface, a data interface, a decoding module, a data distribution module, a mode control module, an address generation module, a feature loading module, a post-processing module and a convolution unit, and the convolution unit includes several PEs; The instruction interface is used to receive the custom RISC-V instructions sent by the execution unit in the main processor, and send feedback to the register unit in the main processor; The data interface is used to exchange data with the data loading and storage unit in the main processor; The decoding module is used to decode the custom RISC-V instructions sent from the execution unit in the main processor; The data distribution module is used to send a request to the data loading unit of the main processor through the data interface after receiving the memory access instruction, and dispatch the post-processing completion result stored in the specified RAM buffer specified by the address generation module to be sent back to the main processor; The mode control module is used to configure the working modes of the address generation module, the feature loading module, the post-processing module and the PE in the convolution unit respectively after receiving the configuration instruction; The address generation module is used to send the access address to the feature loading module and the weight loading module according to pre-configured parameters; The feature loading module is used to load the weight data into the PE of the convolution unit after the feature map is rearranged and cached under the control of the mode control module; The weight loading module is used to load data into the PEs in the convolution unit in sequence when the weight data is in place; The PE in the convolution unit is used to complete the operation according to the parameters configured by the mode control module, and send the operation results to the post-processing module in order based on the PE tags in the convolution unit; The post-processing module is used to receive the calculation results in order and perform post-processing operations to obtain the post-processing completion results.

2. The RISC-V-based multi-mode convolutional neural network accelerator according to claim 1, characterized in that: The convolution unit is based on the operation cycle, specifically: the feature map of each layer is based on the convolution kernel size , feature map size and step length Divided into × a×a parts, that is, i×a= ; The clock cycle is regarded as an operation cycle; the PE in the convolution unit completes the operation of each part synchronously within one operation cycle, and needs to continuously load data, while the weight data in the convolution kernel remains unchanged in each operation cycle and only needs to be updated once in each operation cycle. There is no need to load additional data that does not participate in the operation multiple times, that is, the data loading and weight loading strategies in the convolution unit need to load a total amount of data in one convolution. .

3. The RISC-V-based multi-mode convolutional neural network accelerator according to claim 1, characterized in that: The data loading and weight loading strategies in the convolution unit are as follows: For the layer-by-layer convolution part of the depth-wise separable convolution where the calculations of each channel are independent from each other, a row-first data loading strategy is adopted; For the point-by-point convolution parts of standard convolution and depth-wise separable convolution, whose intermediate results between different layers also need to be cross-accumulated, a channel-first data loading strategy is adopted.

4. The RISC-V-based multi-mode convolutional neural network accelerator according to claim 3, characterized in that: The row-first data loading strategy is as follows: Load a PE every clock cycle The data belonging to the convolution window is a column or a row in the same channel. After several operation cycles, the data operation of the convolution window is completed and the output eigenvalue is ready.

5. The RISC-V-based multi-mode convolutional neural network accelerator according to claim 3, characterized in that: The channel-priority data loading strategy is as follows: Each clock cycle combines the channel dimension factors to select a value point for each channel and independently chooses to transmit data; after each operation cycle, the value points on all channels move to the next position to be valued, and a new round of data loading begins.

6. The RISC-V-based multi-mode convolutional neural network accelerator according to claim 1, characterized in that: The accelerator uses 0001011 as opcode. The opcode includes two instructions: configuration instruction cfg and operation instruction op. It also extends seven instructions: cfg.adr, cfg.std, cfg.mod, cfg.cnt, op.rst, op.ram and op.ctl. Among them, the cfg.adr instruction is used to configure the base address of the feature map and weight; The cfg.std directive is used to configure the step size during convolution operations and post-processing; cfg.mod is used to tell the accelerator which operating mode it should be in, where the operating mode includes the convolution operation mode, pooling window size, and feature map discarding method; cfg.cnt is used to configure the number of continuously available data batches during standard convolution and point-by-point convolution and the number of sliding windows in the convolution operation; op.rst is used to initialize the accelerator; op.ctl is used to change the working state of the accelerator, including changing from idle to called state; op.ram is used to control data interaction between the main processor and the accelerator.

7. A multi-mode convolutional neural network acceleration method based on RISC-V, characterized in that: This method participates in the convolution acceleration operation in the form of a coprocessor, as follows: When in the instruction execution stage of the main processor, the coprocessor is connected to the main processor through the instruction interface and data interface of the coprocessor; When convolution operation acceleration is required, the main processor calls the convolutional neural network accelerator and sends a custom RISC-V instruction to the convolutional neural network accelerator through the instruction interface of the coprocessor. The instruction interface of the coprocessor receives the instruction, sends feedback and decodes the instruction; and sends the decoded content to the data distribution module or the mode control module according to the category; After receiving the memory access instruction, the data distribution module sends a request to the data loading storage unit of the main processor through the data interface; the main processor sends the feature map and weight map data to the convolutional neural network accelerator; When receiving the configuration instruction, the mode control module configures the working modes of the address generation module, the feature loading module, the post-processing module and the PE in the convolution unit respectively; After the convolution operation starts, the address generation module sends the access address to the feature and weight loading module according to the pre-configured parameters; the feature map is rearranged and cached under the control of the mode control module, and the weight loading module loads the weight data into the PE of the convolution calculation unit; when the weight data is in place, the feature loading module loads data to the PE in the convolution unit in turn, and the PE in the convolution unit completes the operation according to the parameters configured by the mode control module, and sends the operation results to the post-processing module in order based on the PE label; the results of the post-processing will be stored in the specified RAM buffer specified by the address generation module, and scheduled by the data distribution module to be sent back to the main processor.

8. The RISC-V-based multi-mode convolutional neural network acceleration method according to claim 7, characterized in that: The data loading and weight loading strategies in the convolution unit are as follows: For the layer-by-layer convolution part of the depth-wise separable convolution where the calculations of each channel are independent from each other, a row-first data loading strategy is adopted; For the point-by-point convolution parts of standard convolution and depth-wise separable convolution, whose intermediate results between different layers also need to be cross-accumulated, a channel-first data loading strategy is adopted.

9. The RISC-V-based multi-mode convolutional neural network acceleration method according to claim 8, characterized in that: The row-first data loading strategy is as follows: Load a PE every clock cycle The data belonging to the convolution window is a column or a row in the same channel. After several operation cycles, the data operation of the convolution window is completed and the output eigenvalue is ready. The channel-priority data loading strategy is as follows: Each clock cycle combines the channel dimension factors to select a value point for each channel and independently chooses to transmit data; after each operation cycle, the value points on all channels move to the next position to be valued, and a new round of data loading begins.

10. The RISC-V-based multi-mode convolutional neural network acceleration method according to claim 7, characterized in that: The convolutional neural network accelerator uses 0001011 as opcode. The opcode includes two instructions: configuration instruction cfg and operation instruction op, and extends seven instructions: cfg.adr, cfg.std, cfg.mod, cfg.cnt, op.rst, op.ram and op.ctl. Among them, the cfg.adr instruction is used to configure the base address of the feature map and weight; The cfg.std directive is used to configure the step size during convolution operations and post-processing; cfg.mod is used to tell the accelerator which operating mode it should be in, where the operating mode includes the convolution operation mode, pooling window size, and feature map discarding method; cfg.cnt is used to configure the number of continuously available data batches during standard convolution and point-by-point convolution and the number of sliding windows in the convolution operation; op.rst is used to initialize the accelerator; op.ctl is used to change the working state of the accelerator, including changing from idle to called state; op.ram is used to control data interaction between the main processor and the accelerator.

Citation Information

Patent Citations

  • A universal convolutional neural network accelerator based on a one-dimensional pulsation array

    CN109934339A

  • Convolutional neural network accelerator and working method thereof

    CN113312285A