A neural network dedicated computing array and computing method thereof

By designing a special computing array for neural networks and using reconfigurable clusters and reconfigurable instruction words to configure the data path, the problems of poor applicability and insufficient parallelism of computing arrays in the existing technology are solved, and efficient computing and hardware for various neural networks are realized. Optimization of resources.

CN111401533BActive Publication Date: 2024-09-27NANJING NINGQI INTELLIGENT COMPUTING CHIP RES INST CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010350549.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-28
Publication Date
2024-09-27
Estimated Expiration
2040-04-28

AI Technical Summary

Technical Problem

Existing computing arrays are only suitable for single neural network calculations and cannot fully realize parallel calculations in neural network algorithms, limiting computing efficiency.

Method used

A neural network-specific computing array is designed, including reconfigurable clusters, including multiply-accumulate components, addition components, activation function components and comparators. The data path is configured by reconstructing instruction words to support inference operations of various neural networks, and Accuracy control of calculation data and results is achieved through truncaters.

Benefits of technology

It improves the utilization and reusability of hardware resources, realizes parallel calculation of neural network algorithms, improves the computational efficiency of the algorithm, and especially provides solutions for parts that are difficult to parallelize, such as LSTM networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111401533B
    Figure CN111401533B
Patent Text Reader

Abstract

The present invention discloses a neural network-specific computing array and a computing method thereof, and belongs to the technical field of algorithm hardware acceleration. The computing array of the present invention includes a plurality of reconfigurable clusters, each of which includes a multiplication-accumulation component, an addition component, an activation function component, a multiplication component and a comparator, and the addition component and the activation function component are electrically connected to the multiplication component, respectively. And the addition component and the activation function component are electrically connected to the multiplication-accumulation component, respectively. The method of the present invention is to input the reconstruction instruction word and the original data into the input port of the reconfigurable cluster, and then the reconfigurable cluster forms a data path according to the reconstruction instruction word, and then processes the original data according to the data path to obtain the processing result and output it. The purpose of the present invention is to overcome the deficiency in the prior art that the usual computing array is only applicable to the calculation of a single neural network. The present invention can be applicable to the calculation of multiple neural networks, thereby improving the utilization rate and reusability of hardware resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of algorithm hardware acceleration, and more specifically, to a neural network dedicated computing array and a computing method thereof. Background Art

[0002] In recent years, neural networks have become one of the most popular research fields, and they have been increasingly widely used in the industry. The most commonly used neural networks include convolutional neural networks (CNN), which are often used in image processing; recurrent neural networks (RNN) and long short-term memory neural networks (LSTM), which are often used in speech recognition. Commonly used neural networks have the characteristics of large computational complexity and strong data reusability. These characteristics make neural networks very suitable for hardware acceleration through computing arrays. Therefore, designing computing arrays with high computing performance, high flexibility, and high hardware utilization is of great significance for the hardware implementation of neural networks.

[0003] The prior art has disclosed a computing array of a corresponding neural network, for example, the invention is named: Computing array based on neural network (application date: October 17, 2017; application number: 201710961627.7), which provides a computing array based on a neural network, the computing array includes a plurality of reconfigurable computing units, each of which includes (n+1) layers of multi-bit width multipliers: each layer of multiplication units is used to perform different computing tasks, starting from the smallest multiplication unit, the calculation results of each layer of multiplication units are transmitted to the next layer of multiplication units through shifting and adding operations of adders. The scheme can execute multi-bit width multiplication tasks in parallel, and the utilization rate of the multiplier reaches 100%, realizing the maximum utilization of hardware; the adder not only works when performing the splicing of partial accumulation and addition, but also can accumulate and sum the number of bits that have been calculated to complete the multiplication and accumulation part of the convolutional neural network, greatly improving the reusability of the adder. However, the shortcoming of this solution is that the computing array is only applicable to the calculation of convolutional neural networks, not to the calculation of other neural networks, and the versatility of the computing array is poor.

[0004] In addition, for some neural network algorithms, such as LSTM networks, due to the inherent seriality in their algorithm principles, the usual computing array can only accelerate each of its calculation steps individually, which limits the calculation efficiency to a certain extent. Therefore, how to more fully explore the parallelism in this type of algorithm and design a dedicated acceleration architecture has also become one of the research focuses.

[0005] In summary, how to make the designed computing array suitable for the calculation of various neural networks and realize the parallelism in the neural network algorithm is an urgent problem in the existing technology. Summary of the invention

[0006] 1. Problem to be solved

[0007] The purpose of the present invention is to overcome the shortcomings of the prior art that the usual computing array is only suitable for a single neural network calculation and cannot realize the parallel calculation in the neural network algorithm. A neural network-specific computing array and a computing method thereof are provided, which can be applicable to the calculation of a variety of neural networks, thereby improving the utilization and reusability of hardware resources; further, parallel calculation in the neural network algorithm can be realized, thereby improving the algorithm's operational efficiency.

[0008] 2. Technical solution

[0009] In order to solve the above problems, the technical solution adopted by the present invention is as follows:

[0010] A neural network-specific computing array of the present invention includes several reconfigurable clusters, each reconfigurable cluster includes a multiplication-accumulation component, an addition component, an activation function component, a multiplication component and a comparator, the addition component and the activation function component are electrically connected to the multiplication-accumulation component respectively, and the addition component and the activation function component are electrically connected to the multiplication component respectively; wherein the multiplication-accumulation component is used to realize multiplication and accumulation calculations on original data; the addition component is used to perform addition operations on original data or the calculation results of the multiplication component or the calculation results of the multiplication component; the activation function component is used to perform activation function operations on original data or the calculation results of the multiplication-accumulation component or the calculation results of the addition component; the multiplication component is used to perform multiplication operations on original data or the calculation results of the activation function component; the comparator is used to perform comparison operations on original data.

[0011] Furthermore, the multiplication-accumulation component includes a plurality of multiplication-accumulators, each of which includes a fixed-point multiplier and a fixed-point adder, and the fixed-point multiplier is electrically connected to the fixed-point adder via a multiplication truncation device.

[0012] Furthermore, the adding component includes an adder expander, a fixed-point adder and an adder truncation device, and the adder expander and the adder truncation device are electrically connected to the fixed-point adder, respectively.

[0013] Furthermore, the activation function component includes a first activation function component and a second activation function component, the first activation function component and the second activation function component respectively include a lookup table device, a fixed-point multiplier and a fixed-point adder, and the fixed-point multiplier and the fixed-point adder are electrically connected to the lookup table device respectively.

[0014] Furthermore, the multiplication component includes a first multiplication element and a second multiplication element, the first multiplication element and the second multiplication element respectively include a fixed-point multiplier and a multiplication truncation device, and the fixed-point multiplier and the multiplication truncation device are electrically connected.

[0015] Furthermore, the first multiplication element is electrically connected to the first activation function element through the addition element, and the second multiplication element is electrically connected to the second activation function element.

[0016] Furthermore, each reconfigurable cluster further includes an input port and an output port, and the input port is electrically connected to the output port via an addition component, an activation function component, a multiplication component or a comparator.

[0017] A calculation method for a neural network-specific computing array of the present invention is characterized in that the above-mentioned neural network-specific computing array is used, and the reconstructed instruction word and the original data are input into the input port of the reconstructible cluster, and then the reconstructible cluster forms a data path according to the reconstructed instruction word, and the multiplication and accumulation component, the addition component, the activation function component, the multiplication component and the comparator process the original data according to the data path to obtain the processing result, and then the processing result is output from the output port of the reconstructible cluster.

[0018] Furthermore, the reconstructed instruction word is 8 bits, and the 8-bit reconstructed instruction word includes 8'b0000_0001, 8'b0000_0010, 8'b0000_0100, 8'b0000_1000, 8'b0001_0000, 8'b0010_0000, 8'b0100_0000 and 8'b1000_0000.

[0019] Furthermore, when the reconstruction instruction word is 8'b0000_0001, the original data is calculated in sequence through the multiplication and accumulation component and the activation function component; when the reconstruction instruction word is 8'b0000_0010, the original data is calculated in sequence through the multiplication and accumulation component, the addition component and the activation function component; when the reconstruction instruction word is 8'b0000_0100, the original data is calculated through the addition component; when the reconstruction instruction word is 8'b0000_1000, the original data is calculated through the multiplication component; when the reconstruction instruction word is 8'b0001_0000, the original data is calculated through the activation function component. When the reconstruction instruction word is 8'b0010_0000, the original data is calculated by the comparator; when the reconstruction instruction word is 8'b0100_0000, the original data is calculated by the multiplication component and the addition component in sequence; when the reconstruction instruction word is 8'b1000_0000, the original data includes weight data, network input layer source data and activation function source data, wherein the weight data and the network input layer source data are calculated by the multiplication and accumulation component, the addition component, the activation function component and the multiplication component in sequence; the activation function source data is calculated by the activation function component and the multiplication component in sequence.

[0020] 3. Beneficial effects

[0021] Compared with the prior art, the present invention has the following beneficial effects:

[0022] (1) The neural network dedicated computing array of the present invention can realize parallel computing in the neural network algorithm by setting multiple reconfigurable clusters, thereby improving the computing efficiency of the algorithm. Furthermore, by setting a multiplication and accumulation component, an addition component, an activation function component, a multiplication component and a comparator, it can be applied to the reasoning operation of various neural networks, thereby improving the utilization rate and reusability of hardware resources; in addition, by setting a truncation device in each component, it is possible to control the accuracy of each calculation data and result.

[0023] (2) The present invention provides a computing method for a neural network-specific computing array. By configuring a reconstruction instruction word, the reconfigurable cluster of the computing array can be reconstructed, and 8 different data paths can be realized. The method supports the reasoning operations of a variety of commonly used neural networks, and has good application flexibility and high hardware resource utilization. During the calculation process, the truncation parameters are configured in real time to achieve control over the accuracy of each calculation data and result. Furthermore, the parallel calculation of neural network algorithm examples can be achieved, that is, a solution is provided for the parts of some algorithms such as LSTM that are difficult to parallelize, thereby improving the algorithm's computing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 It is a structural schematic diagram of a neural network-specific computing array of the present invention;

[0025] Figure 2 It is a structural schematic diagram of the multiplication and accumulation component of the present invention;

[0026] Figure 3 It is a structural schematic diagram of the addition component of the present invention;

[0027] Figure 4 It is a schematic diagram of the structure of the first activation function component and the second activation function component of the present invention;

[0028] Figure 5 A schematic diagram of the structure of the first multiplication element and the second multiplication element of the present invention;

[0029] Figure 6 For fully connected network reasoning∑ i w i x i +b i Schematic diagram of the calculation structure;

[0030] Figure 7 For the LSTM network C t Schematic diagram of the calculation structure;

[0031] Figure 8 For the LSTM network H t Schematic diagram of the calculation structure.

[0032] Explanation of reference numerals in the schematic diagram: 110, multiplication and accumulation component; 120, addition component; 121, addition bit expander; 122, addition bit truncation device; 130, activation function component; 131, first activation function component; 132, second activation function component; 133, lookup table component; 140, multiplication component; 141, first multiplication component; 142, second multiplication component; 150, comparator;

[0033] 210. Multiply-accumulator; 211. Fixed-point multiplier; 212. Multiplication truncation; 213. Fixed-point adder. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments; moreover, the various embodiments are not relatively independent and can be combined with each other as needed to achieve better results. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0035] In order to further understand the content of the present invention, the present invention is described in detail in conjunction with the accompanying drawings and embodiments.

[0036] Example 1

[0037] Combination Figure 1 As shown, a neural network-specific computing array of the present invention includes several reconfigurable clusters, each of which can perform computing processing on raw data, and multiple reconfigurable clusters can realize parallel processing of multi-channel data. The computing array in this embodiment includes 32 reconfigurable clusters, so that 32 channels of data can be processed in parallel. The reconfigurable cluster of the present invention includes a multiplication-accumulation component 110, an addition component 120, an activation function component 130, and a multiplication component 140, and the addition component 120 and the activation function component 130 are electrically connected to the multiplication component 140, respectively. And the addition component 120 and the activation function component 130 are electrically connected to the multiplication-accumulation component 110, respectively.

[0038] The above components are further described in detail. Specifically, Figure 2As shown, the multiplication and accumulation component 110 of the present invention is used to realize the multiplication and accumulation calculation of the original data; specifically, the multiplication and accumulation component 110 includes a plurality of multiplication and accumulation devices 210, each of which includes a fixed-point multiplier 211 and a fixed-point adder 213, and the fixed-point multiplier 211 is electrically connected to the fixed-point adder 213 through a multiplication truncation device 212. The multiplication and accumulation component 110 of this embodiment includes 32 multiplication and accumulation units 210, and the fixed-point multiplier 211 includes two 16-bit input ports and one 32-bit output port, which can complete the fixed-point signed or unsigned multiplication calculation of the weight data and the network input layer source data; the multiplication truncation unit 212 can truncate the 32-bit multiplication result, and use the sign bit position for the high bit, so as to avoid the result overflow caused by the data being multiplied first and then accumulated; the fixed-point adder 213 includes two 32-bit input ports and one 32-bit output port, and accumulates the 32-bit data of the multiplication result in a fixed-point signed or unsigned manner to output 32-bit data.

[0039] Combination Figure 3 As shown, the addition unit 120 of the present invention is used to perform addition operation on the original data or the calculation result of the multiplication and accumulation unit 110 or the calculation result of the multiplication unit 140. The addition unit 120 includes an adder expander 121, a fixed-point adder 213 and an adder truncation unit 122. The adder expander 121 and the adder truncation unit 122 are electrically connected to the fixed-point adder 213 respectively. It is worth noting that the adder expander 121 is called when the reconstructed instruction word is 8'b0000_0010 or 8'b1000_0000. The adder expander 121 expands the decimal place of the addition source data input into the calculation array and fills the high place with the sign bit; the adder truncation unit 122 truncates the 32-bit addition result to 16-bit data and then outputs it; the fixed-point adder 213 performs fixed-point signed and unsigned addition on the addition source data and outputs 32-bit data.

[0040] The activation function component 130 of the present invention is used to perform activation function operations on the original data or the calculation results of the multiplication and accumulation component 110 or the calculation results of the addition component 120. Specifically, the activation function component 130 includes a first activation function component 131 and a second activation function component 132. The first activation function component 131 and the second activation function component 132 respectively include a lookup table device 133, a fixed-point multiplier 211, a fixed-point adder 213 and an activation function truncation device. The fixed-point multiplier 211 and the fixed-point adder 213 are respectively electrically connected to the lookup table device 133; the lookup table device 133 is used to implement the lookup table function. The first activation function component 131 and the second activation function component 132 are respectively provided with two activation function truncators, one of which is electrically connected to the lookup table device 133 and the fixed-point multiplier 211, and the other is electrically connected to the fixed-point adder 213. It is worth noting that, in combination with Figure 4 As shown, the activation function is calculated in a linear segmentation manner, and the input data includes the number of fixed-point integer digits and input data x. The input data x is transmitted to the register, and the lookup table device 133 finds the corresponding interval of the linear segmentation according to the size of the input data, and finds the corresponding k and b, wherein k represents the slope of the linear segmentation and b represents the intercept. The intercept b is transmitted to another register, and the data k and the input data x in the register are transmitted to the fixed-point multiplier 211 for multiplication, and then the multiplication result and the intercept b are transmitted to the fixed-point adder 213 for addition to obtain the calculation result.

[0041] Combination Figure 5 As shown, the multiplication component 140 of the present invention is used to perform multiplication operation on the original data or the calculation result of the activation function component 130. The multiplication component 140 includes a first multiplication component 141 and a second multiplication component 142. The first multiplication component 141 is electrically connected to the first activation function component 131 through the addition component 120, and the second multiplication component 142 is electrically connected to the second activation function component 132. Further, the first multiplication component 141 and the second multiplication component 142 respectively include a fixed-point multiplier 211 and a multiplication truncation device 212. The fixed-point multiplier 211 and the multiplication truncation device 212 are electrically connected. The fixed-point multiplier 211 can realize the fixed-point signed and unsigned multiplication calculation of the data. The multiplication truncation device 212 can truncate the 32-bit multiplication result and output a 16-bit data result, wherein the high bit is padded with the sign bit.

[0042] In addition, the reconfigurable cluster of the present invention also includes an input port, an output port and a comparator 150, wherein the comparator 150 is used to perform comparison operations on the original data; the input port is electrically connected to the output port via the addition component 120, the activation function component 130, the multiplication component 140 or the comparator 150. In this embodiment, the input port includes a 16-bit source data input port and 32 16-bit weight data input ports, where the source data represents the network input layer source data, addition source data, multiplication source data, activation function source data or comparison source data, and the source data is sequentially transmitted to 32 multiplication and accumulation units 210, each time with an interval of one clock cycle, that is, the source data is first transmitted to MAC1, and then transmitted to MAC2 after one clock cycle, and then transmitted to MAC32 in this way; the 32 weight data are respectively transmitted to the 32 multiplication and accumulation units 210 in the form of sequentially extending one clock cycle, that is, the first weight data is first transmitted to MAC1, and then the second weight data is transmitted to MAC2 after one clock cycle, and then the 32nd weight data is transmitted to MAC32 in this way, so as to form a pulsating transmission of weight data in the multiplication and accumulation unit 110. Among them, MAC1 represents the first multiplication and accumulation unit 210, MAC2 represents the second multiplication and accumulation unit 210, and so on, MAC32 represents the 32nd multiplication and accumulation unit 210;

[0043] The neural network dedicated computing array of the present invention can realize parallel computing in the neural network algorithm by setting multiple reconfigurable clusters, thereby improving the computing efficiency of the algorithm. Further, by setting a multiplication and accumulation component 110, an addition component 120, an activation function component 130, a multiplication component 140 and a comparator 150, it can be applied to the reasoning operation of various neural networks, thereby improving the utilization rate and reusability of hardware resources; in addition, by setting a truncation device in each component, it is possible to control the accuracy of each calculation data and result.

[0044] The calculation method of a neural network dedicated calculation array of the present invention adopts the above-mentioned neural network dedicated calculation array, inputs the reconstructed instruction word and the original data into the input port of the reconstructable cluster, and then the reconstructable cluster forms a data path according to the reconstructed instruction word, and the multiplication and accumulation component 110, the addition component 120, the activation function component 130, the multiplication component 140 and the comparator 150 process the original data according to the data path to obtain the processing result, and then outputs the processing result from the output port of the reconstructable cluster. It should be noted that the multiplication calculation, addition calculation and comparison calculation of the present invention are bitwise multiplication, bitwise addition and comparison operations respectively. Specifically, the reconstruction instruction word is 8 bits, and the 8-bit reconstruction instruction word includes 8'b0000_0001, 8'b0000_0010, 8'b0000_0100, 8'b0000_1000, 8'b0001_0000, 8'b0010_0000, 8'bo100_0000 and 8'b1000_0000. It is worth noting that when the reconstruction instruction word is 8'b0000_0001, the original data is calculated by the multiplication and accumulation component 110 and the activation function component 130 in sequence; in sequence means that the original data is first calculated by the multiplication and accumulation component 110 to obtain the calculation result, and then the calculation result is input to the first activation function component 131 of the activation function component 130 for calculation. It should be noted that the data path refers to the order in which the original data is processed by the components. For example, when the reconstructed instruction word is 8′b0000_0001, the data path first uses the multiplication and accumulation component 110 and then uses the activation function component 130 .

[0045] When the reconstruction instruction word is 8'b0000_0010, the original data is calculated in sequence by the multiplication and accumulation component 110, the addition component 120 and the activation function component 130; it should be noted that when the reconstruction instruction word is 8'b0000_0010, the fully connected network reasoning ∑ i w i x i +b i Calculation, combined with Figure 6 As shown, the specific method is: the original data is passed into the multiplication and accumulation component 110 for calculation, specifically, the original data includes 16-bit network input layer source data, 16-bit weight data, 32-bit bias data and the multiplication and accumulation length data to be calculated; the 32-bit multiplication and accumulation calculation result and the 32-bit bias data are simultaneously passed into the addition component 120 for calculation, the 32-bit addition result is truncated into 16-bit data and then passed into the first activation function component 131 of the activation function component 130 for calculation, and the first activation function component 131 of the activation function component 130 calculates and outputs 16-bit result data.

[0046] When the reconstruction instruction word is 8'b0000_0100, the original data is calculated by bitwise addition through the addition component 120, and the original data is the addition source data; when the reconstruction instruction word is 8'b0000_1000, the original data is calculated by bitwise multiplication through the multiplication component 140, and the original data is the multiplication source data; when the reconstruction instruction word is 8'b0001_0000, the original data is calculated by the activation function component 130, and the original data is the activation function source data; when the reconstruction instruction word is 8'b0010_0000, the original data is calculated by the comparator 150, and the original data is the comparison source data; when the reconstruction instruction word is 8'b0100_0000, the original data is calculated by the multiplication component 140 and the addition component 120 in sequence. It should be noted that when the reconstruction instruction word is 8'b0100_0000, the cell state value C in the LSTM network reasoning can be realized. t =f t ·C t-1 +i t ·g t or the same operation of vector bitwise multiplication followed by bitwise addition, combined with Figure 7 As shown, the specific method is: the fixed-point multiplier 211 of the first multiplier 141 and the second multiplier 142 performs fixed-point multiplication calculation on the input signed or unsigned data; then the 32-bit data output by the two fixed-point multipliers 211 are added by the fixed-point adder 213, and the 32-bit addition result is truncated to 16-bit data by the adder truncation device 122 and then output. This calculation method is a pipeline operation.

[0047] When the reconstruction instruction word is 8'b1000_0000, the original data includes weight data, network input layer source data and activation function source data, wherein the weight data and network input layer source data are calculated in sequence through the multiplication and accumulation component 110, the addition component 120, the activation function component 130 and the multiplication component 140; the activation function source data is calculated in sequence through the activation function component 130 and the multiplication component 140. It should be noted that when the reconstruction instruction word is 8'b0000_0010, the hidden layer result H in the LSTM network inference can be realized. t =tanh(C t )·σ(W o X+b o ) calculation, combined with Figure 8As shown, the specific method is as follows: the original data is passed into the multiplication and accumulation component 110 for calculation. Specifically, the original data includes 16-bit network input layer source data, 16-bit weight data, 32-bit bias data and multiplication and accumulation length data to be calculated; the 32-bit multiplication and accumulation calculation result and the 32-bit bias data are simultaneously passed into the addition component 120 for calculation, and the 32-bit addition result is truncated into a 16-bit data result, and then the 16-bit data result is transmitted to the first activation function component 131 for calculation, and at the same time, the cell state value C in the LSTM network inference is converted into a 16-bit data result. t The first activation function component 131 and the second activation function component 132 respectively transmit the calculation results to the second multiplication component 142 of the multiplication component 140 for calculation, and use the multiplication truncation device 212 to truncate the 32-bit multiplication result and output a 16-bit data result.

[0048] In addition, it should be noted that the present invention can configure the truncation parameters to the corresponding truncation devices in the reconfigurable cluster in real time according to the requirements for the accuracy of the calculation results. In specific implementation, by configuring the internal multiplication result truncation parameters of the multiplication accumulator 210 to the multiplication truncation device 212, the 32-bit result of each multiplication is arithmetic right shifted to obtain a 32-bit result; by configuring the result truncation parameters of the multiplication component 140 to the multiplication truncation device 212 of the multiplication component 140, the 32-bit multiplication result is arithmetic right shifted to obtain a 16-bit result; by configuring the expansion parameters to the addition expansion device 121, the 32-bit source data is arithmetic left shifted to obtain a 32-bit result; by configuring the result truncation parameters of the addition component 120 to the addition truncation device 122, the 32-bit addition result is arithmetic right shifted to obtain a 16-bit result; by configuring the source data truncation parameters of the activation function component 130 to the activation function truncation device, the 16-bit source data is arithmetic right shifted to obtain a 16-bit result.

[0049] The present invention discloses a calculation method for a neural network-specific calculation array. The reconfigurable cluster of the calculation array can be reconfigured by configuring a reconstruction instruction word, and 8 different data paths can be realized. The method supports reasoning operations of multiple commonly used neural networks and has good application flexibility and high hardware resource utilization. The method configures truncation parameters in real time during the calculation process, and can control the accuracy of each calculation data and result. The method can further realize the parallel calculation of neural network algorithm examples, that is, it provides a solution for the parts of some algorithms such as LSTM that are difficult to parallelize, and improves the calculation efficiency of the algorithm.

[0050] The present invention has been described in detail above in conjunction with specific exemplary embodiments. However, it should be understood that various modifications and variations may be made without departing from the scope of the present invention as defined by the appended claims. The detailed description and the accompanying drawings should be considered only as illustrative and not restrictive, and if there are any such modifications and variations, they will fall within the scope of the present invention described herein. In addition, the background technology is intended to illustrate the current status and significance of the research and development of the present technology and is not intended to limit the present invention or the application field of the present application and the present invention.

Claims

1. A neural network dedicated computing array, characterized in that: It comprises a plurality of reconfigurable clusters, each of which comprises a multiplication-accumulation component, an addition component, an activation function component, a multiplication component and a comparator, wherein the addition component and the activation function component are electrically connected to the multiplication-accumulation component respectively, and the addition component and the activation function component are electrically connected to the multiplication component respectively; wherein the multiplication-accumulation component is used to realize multiplication and accumulation calculation of original data; the addition component is used to perform addition operation on original data or the calculation result of the multiplication-accumulation component or the calculation result of the multiplication component; the activation function component is used to perform activation function operation on original data or the calculation result of the multiplication-accumulation component or the calculation result of the addition component; the multiplication component is used to perform multiplication operation on original data or the calculation result of the activation function component; the comparator is used to perform comparison operation on original data; The multiplication-accumulation component includes a plurality of multiplication-accumulators, each of which includes a fixed-point multiplier and a fixed-point adder, and the fixed-point multiplier is electrically connected to the fixed-point adder through a multiplication truncation device; each reconfigurable cluster also includes an input port and an output port, and the input port is electrically connected to the output port through an addition component, an activation function component, a multiplication component or a comparator; the addition component includes an adder expander, a fixed-point adder and an adder truncation device, and the adder expander and the adder truncation device are electrically connected to the fixed-point adder respectively.

2. A neural network dedicated computing array according to claim 1, characterized in that: The activation function component includes a first activation function component and a second activation function component, wherein the first activation function component and the second activation function component respectively include a lookup table device, a fixed-point multiplier and a fixed-point adder, and the fixed-point multiplier and the fixed-point adder are respectively electrically connected to the lookup table device.

3. A neural network dedicated computing array according to claim 2, characterized in that: The multiplication component includes a first multiplication element and a second multiplication element, wherein the first multiplication element and the second multiplication element respectively include a fixed-point multiplier and a multiplication truncation device, and the fixed-point multiplier and the multiplication truncation device are electrically connected.

4. A neural network dedicated computing array according to claim 3, characterized in that: The first multiplication element is electrically connected to the first activation function element through the addition element, and the second multiplication element is electrically connected to the second activation function element.

5. A calculation method for a neural network dedicated calculation array, characterized in that: The neural network dedicated computing array according to any one of claims 1 to 4 is used to input the reconstruction instruction word and the original data into the input port of the reconfigurable cluster, and then the reconfigurable cluster forms a data path according to the reconstruction instruction word, and the multiplication and accumulation component, the addition component, the activation function component, the multiplication component and the comparator process the original data according to the data path to obtain the processing result, and then the processing result is output from the output port of the reconfigurable cluster.

6. The calculation method of a neural network dedicated calculation array according to claim 5, characterized in that: The reconstructed instruction word is 8 bits, and the 8-bit reconstructed instruction words include 8'b0000_0001, 8'b0000_0010, 8'b0000_0100, 8'b0000_1000, 8'b0001_0000, 8'b0010_0000, 8'b0100_0000 and 8'b1000_0000.

7. A computing method for a neural network dedicated computing array according to claim 6, characterized in that: When the reconstructed instruction word is 8'b00000001, the original data is calculated in sequence through the multiplication and accumulation component and the activation function component; When the reconstructed instruction word is 8'b0000_0010, the original data is calculated in sequence through the multiplication and accumulation component, the addition component and the activation function component; When the reconstructed instruction word is 8'b0000_0100, the original data is calculated by the addition component; When the reconstructed instruction word is 8'b0000_1000, the original data is calculated by the multiplication unit; When the reconstructed instruction word is 8'b0001_0000, the original data is calculated by the activation function component; When the reconstructed instruction word is 8'b0010_0000, the original data is calculated by the comparator; When the reconstructed instruction word is 8'b0100_0000, the original data is calculated by the multiplication unit and the addition unit in sequence; When the reconstruction instruction word is 8'b1000_0000, the original data includes weight data, network input layer source data and activation function source data, wherein the weight data and the network input layer source data are calculated in sequence through the multiplication and accumulation component, the addition component, the activation function component and the multiplication component; the activation function source data is calculated in sequence through the activation function component and the multiplication component.