Storage and calculation integrated device, neural network calculation method and storage and calculation chip
By using a preprocessing circuit in the storage and calculation integrated device to determine the first data and the second data during neural network calculation, the flip rate of adjacent cycles is optimized, solving the problem of high power consumption of neural network calculation in the existing technology, and realizing for more efficient calculations.
Patent Information
- Application Number
- CN202310301138.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-17
- Publication Date
- 2024-09-20
AI Technical Summary
The existing integrated storage and calculation architecture has high power consumption during neural network calculations, mainly due to the large flip rate between two adjacent cycles of calculation data, resulting in high power consumption during multiplication and accumulation calculations.
Design an integrated storage and calculation device, including a preprocessing circuit and a storage and calculation circuit. The preprocessing circuit determines the first data of the current cycle among the bits of multiple characteristic values, and determines the second data of the next cycle based on the first data. data, ensuring that the flip rate between the first data and the second data is less than or equal to the flip rate between the first data and the third data, thereby reducing power consumption during calculation.
It effectively reduces the power consumption of the integrated storage and calculation device during neural network calculation, improves the calculation efficiency, simplifies the structure and reduces the cost.
Smart Images

Figure CN118673971A
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a storage and computing integrated device, a neural network computing method, and a storage and computing chip. Background Art
[0002] In recent years, neural networks have received great attention and in-depth research from academia and industry, and are widely used in robotics, speech recognition, image recognition, natural language processing, expert systems and other fields. The core operation of neural networks is matrix-vector multiplication, which is computationally intensive and memory-intensive. In order to make up for the shortcomings of general-purpose processing chips in power consumption, performance, and size, and improve the efficiency of neural network calculations, it has become an industry consensus to customize dedicated acceleration chips for neural network calculations.
[0003] Storage and computing integrated is a high-efficiency chip architecture that not only retains the storage and read-write functions of the storage circuit itself, but also supports multiplication and addition operations with high parallelism, thereby effectively reducing the amount of data moved during neural network calculations and improving the system's energy efficiency. Summary of the invention
[0004] The embodiments of the present application provide a storage-computing integrated device, a neural network calculation method, and a storage-computing chip, which can reduce the power consumption of the storage-computing integrated chip when performing neural network calculations.
[0005] In order to achieve the above purpose, the embodiment of the present application adopts the following technical solution:
[0006] In a first aspect of an embodiment of the present application, a storage-computation integrated device is provided, which is applied to neural network calculation, and the storage-computation integrated device includes a preprocessing circuit and a storage-computation circuit coupled to the preprocessing circuit. The preprocessing circuit is used to obtain M eigenvalues, each eigenvalue includes multiple bits, and M is a positive integer. The preprocessing circuit is also used to determine the first data in the current cycle, and the first data includes the first bit of each eigenvalue in the M eigenvalues. The storage-computation circuit is used to perform multiplication and accumulation calculations on the first data in the current cycle. The preprocessing circuit is also used to determine the second data based on the first data, the second data is the data to be calculated in the next cycle, and the second data includes the second bit of each eigenvalue in the M eigenvalues. Among them, the flip rate between the first data and the second data is less than or equal to the flip rate between the first data and the third data, and the third data includes the third bit of each eigenvalue in the M eigenvalues, and the third bit is any bit except the first bit and the second bit.
[0007] Optionally, the first bit may be any bit of each of the M eigenvalues, which is not limited in the embodiment of the present application.
[0008] The storage and computing integrated device provided in the embodiment of the present application determines the first data to be calculated in the current cycle from multiple bits of M eigenvalues through a preprocessing circuit, and determines the second data based on the first data through the preprocessing circuit, thereby reducing the flipping rate between the calculated data of two adjacent cycles when the storage and computing integrated device calculates, and can effectively reduce the power consumption of the storage and computing integrated device when calculating the M eigenvalues.
[0009] In combination with the first aspect, in a possible implementation method, the flipping rate between the first data and the second data is less than or equal to the flipping rate between the first data and the third data, and the third data includes the third bit of each eigenvalue of the M eigenvalues, and the third bit is any bit except the first bit and the second bit.
[0010] The storage-computing integrated device provided in the embodiment of the present application determines the first data to be calculated in the current cycle among the multiple bits of the M characteristic values through the preprocessing circuit, and determines the second data according to the first data through the preprocessing circuit, the second data is the data to be calculated in the next cycle, and the flip rate between the first data and the second data is less than or equal to the flip rate between the first data and the third data. Thus, the flip rate between the calculated data of two adjacent cycles when the storage-computing integrated device calculates can be reduced, and the power consumption of the storage-computing integrated device when calculating the M characteristic values can be effectively reduced.
[0011] In combination with the first aspect, in a possible implementation method, the preprocessing circuit is specifically used to respectively determine a first flip rate between the first data and the second data, and a second flip rate between the first data and the third data, and compare the first flip rate with the second flip rate to determine the second data.
[0012] The storage and computing integrated device provided in the embodiment of the present application determines the first flip rate between the first data and the second data, and the second flip rate between the first data and the third data respectively through a preprocessing circuit, and compares the first flip rate with the second flip rate to determine the second data, thereby reducing the flip rate between the calculated data of two adjacent cycles when the storage and computing integrated device calculates, and can effectively reduce the power consumption of the storage and computing integrated device when calculating the M eigenvalues.
[0013] In combination with the first aspect, in one possible implementation, the preprocessing circuit is specifically used to respectively determine a first difference between the number of specified values included in the first data and the number of specified values included in the second data, and a second difference between the number of specified values included in the first data and the number of specified values included in the third data, compare the first difference with the second difference to determine the second data, and the first difference is less than or equal to the second difference.
[0014] The storage and computing integrated device provided in the embodiment of the present application determines, through a preprocessing circuit, a first difference between the number of specified values included in the first data and the number of specified values included in the second data, and a second difference between the number of specified values included in the first data and the number of specified values included in the third data, and compares the first difference with the second difference to determine the second data, thereby reducing the flipping rate between the calculated data of two adjacent cycles when the storage and computing integrated device calculates, and effectively reducing the power consumption of the storage and computing integrated device when calculating the M characteristic values.
[0015] In combination with the first aspect, in a possible implementation, the storage and calculation circuit includes a calculation array and an accumulation circuit coupled to each other. The calculation array is used to perform multiplication calculation on the first data in the current cycle. The preprocessing circuit is also used to send the first bit weight information corresponding to the first data to the accumulation circuit in the current cycle. The accumulation circuit is used to perform shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information in the current cycle.
[0016] The storage and computing integrated device provided in the embodiment of the present application sends the first bit weight information corresponding to the first data to the accumulation circuit in the current cycle through the preprocessing circuit, and the accumulation circuit can perform shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information.
[0017] In combination with the first aspect, in a possible implementation manner, the structure of the accumulation circuit includes an addition tree.
[0018] In combination with the first aspect, in a possible implementation, the accumulation circuit includes a multi-stage sub-accumulation circuit, and the log-th sub-accumulation circuit in the multi-stage sub-accumulation circuit K M The stage sub-accumulation circuit includes a first shift accumulator, K is a positive integer greater than or equal to 2. The first shift accumulator is used to perform shift accumulation calculation on the result of multiplication calculation according to the first bit weight information in the current cycle.
[0019] The storage and computing integrated device provided in the embodiment of the present application is provided by adding the log of the accumulation circuit to the storage and computing integrated device. K M The stage sub-accumulation circuit is provided with a first shift accumulator, and the first shift accumulator can perform shift accumulation calculation according to the first bit weight information and the result of multiplication calculation.
[0020] In combination with the first aspect, in a possible implementation, the preprocessing circuit is also used to obtain N eigenvalues, divide the N eigenvalues into multiple groups, at least one of the multiple groups includes M eigenvalues, to obtain M eigenvalues, where N is a positive integer greater than M.
[0021] The storage and computing integrated device provided in the embodiment of the present application can reduce the data volume of the first data and the second data, reduce the amount of calculation when the preprocessing circuit determines the second data based on the first data, reduce the time for determining the second data, and improve the computing efficiency of the storage and computing integrated device.
[0022] In combination with the first aspect, in a possible implementation, the preprocessing circuit is further used to determine whether to divide the N eigenvalues into multiple groups according to the data size of the N eigenvalues and / or the number of calculations of the corresponding network layer.
[0023] The storage-computing integrated device provided in the embodiment of the present application has a preprocessing circuit that determines to divide the N eigenvalues into multiple groups based on the data size of the N eigenvalues and / or the number of calculations of the corresponding network layer, thereby improving the computing efficiency of the storage-computing integrated device.
[0024] In combination with the first aspect, in a possible implementation, the log-th N K The first sub-accumulation circuit includes a second shift accumulator. When the data size of the N eigenvalues is less than the first threshold value and / or the number of calculations of the corresponding network layer is less than the second threshold value, the preprocessing circuit is further used to sequentially send the second bit weight information corresponding to each bit in the N eigenvalues to the second shift accumulator. The second shift accumulator is used to perform the first (log) bit weight information of the multi-stage sub-accumulation circuit according to the second bit weight information. N K -1) The accumulated result of the sub-accumulation circuit is subjected to shift accumulation calculation.
[0025] The storage and calculation integrated device provided in the embodiment of the present application is configured to store and calculate the first log in the multi-stage sub-accumulation circuit. N K The sub-accumulation circuit of the first stage is provided with a second shift accumulator. When the data scale of the N eigenvalues is less than the first threshold value and / or the number of calculations of the corresponding network layer is less than the second threshold value, the second shift accumulator can perform the calculation of the first (log N K -1) The accumulation result of the sub-accumulation circuit of the stage is subjected to shift accumulation calculation to determine the multiplication-accumulation result, so that the storage-computation integrated device can support the multiplication-accumulation calculation when the flip rate is not optimized.
[0026] In a second aspect of an embodiment of the present application, a neural network calculation method is provided, which is applied to a storage-computation integrated device including a preprocessing circuit and a storage-computation circuit, the method comprising: the preprocessing circuit obtains M eigenvalues, each eigenvalue includes multiple bits, and M is a positive integer. The preprocessing circuit determines the first data in the current cycle, and the first data includes the first bit of each eigenvalue in the M eigenvalues. The storage-computation circuit performs multiplication and accumulation calculations on the first data in the current cycle. The preprocessing circuit determines the second data based on the first data, the second data is the data to be calculated in the next cycle, and the second data includes the second bit of each eigenvalue in the M eigenvalues.
[0027] In combination with the second aspect, in one possible implementation, the flipping rate between the first data and the second data is less than or equal to the flipping rate between the first data and the third data, and the third data includes the third bit of each eigenvalue of the M eigenvalues, and the third bit is any bit except the first bit and the second bit.
[0028] In combination with the second aspect, in a possible implementation method, the above-mentioned preprocessing circuit determines the second data based on the first data, including: the preprocessing circuit respectively determines the first flip rate between the first data and the second data, and the second flip rate between the first data and the third data, and compares the first flip rate with the second flip rate to determine the second data.
[0029] In combination with the second aspect, in a possible implementation method, the above-mentioned preprocessing circuit determines the second data based on the first data, including: the preprocessing circuit respectively determines the first difference between the number of specified values included in the first data and the number of specified values included in the second data, and the second difference between the number of specified values included in the first data and the number of specified values included in the third data, compares the first difference with the second difference to determine the second data, and the first difference is less than or equal to the second difference.
[0030] In combination with the second aspect, in a possible implementation, the storage circuit includes a mutually coupled computing array and an accumulation circuit, and the method further includes: the computing array performs multiplication calculation on the first data in the current cycle. The preprocessing circuit sends the first bit weight information corresponding to the first data to the accumulation circuit in the current cycle. The accumulation circuit performs shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information in the current cycle.
[0031] In conjunction with the second aspect, in a possible implementation manner, the structure of the accumulation circuit includes an addition tree.
[0032] In combination with the second aspect, in a possible implementation, the accumulation circuit includes a multi-stage sub-accumulation circuit, and the log-th sub-accumulation circuit in the multi-stage sub-accumulation circuit K MThe stage sub-accumulation circuit includes a first shift accumulator, K is a positive integer greater than or equal to 2, and the method further includes: the first shift accumulator performs a shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information in the current cycle.
[0033] In combination with the second aspect, in a possible implementation, the method also includes: a preprocessing circuit obtains N eigenvalues, divides the N eigenvalues into multiple groups, at least one of the multiple groups includes M eigenvalues, to obtain M eigenvalues, where N is a positive integer greater than M.
[0034] In combination with the second aspect, in a possible implementation, the method further includes: a preprocessing circuit determines to divide the N eigenvalues into multiple groups according to the data size of the N eigenvalues and / or the number of calculations of the corresponding network layer.
[0035] In combination with the second aspect, in a possible implementation, the log-th N K The sub-accumulation circuit of the multi-stage sub-accumulation circuit includes a second shift accumulator. When the data size of the N eigenvalues is less than the first threshold value and / or the number of calculations of the corresponding network layer is less than the second threshold value, the method further includes: the preprocessing circuit sequentially sends the second bit weight information corresponding to each bit in the N eigenvalues to the second shift accumulator. The second shift accumulator performs the (log 1) operation of the multi-stage sub-accumulation circuit according to the second bit weight information. N K -1) The accumulated result of the sub-accumulation circuit is subjected to shift accumulation calculation.
[0036] According to a third aspect of an embodiment of the present application, a storage and computing chip is provided, which includes a single-chip microcomputer and at least one storage and computing integrated device coupled to the single-chip microcomputer, and the storage and computing integrated device is the storage and computing integrated device described in the first aspect or any possible implementation of the first aspect.
[0037] The above-mentioned single-chip microcomputer can also be called a microcontroller unit.
[0038] In combination with the third aspect, in a possible implementation, the storage and computing chip may also include direct memory access and dynamic random access memory, and the direct memory access, dynamic random access memory, storage and computing integrated device, and single-chip microcomputer may be coupled through a bus.
[0039] Optionally, the storage and computing chip can be applied in scenarios including keyword detection, image classification, target detection, etc. The embodiments of the present application do not limit the specific application scenarios of the storage and computing chip.
[0040] According to a fourth aspect of an embodiment of the present application, an electronic device is provided, comprising a processor and a storage and computing chip coupled to the processor, wherein the storage and computing chip is the storage and computing chip described in the third aspect or any possible implementation of the third aspect.
[0041] In conjunction with the fourth aspect, in a possible implementation, the processor may be a central processing unit.
[0042] Optionally, the type of the electronic device may include a smart watch, a smart bracelet, a Bluetooth headset, a smart phone, a smart car machine, a drone, etc. The embodiment of the present application does not limit the specific type of the electronic device.
[0043] In a fifth aspect of the embodiments of the present application, a computer-readable storage medium is provided, the computer-readable storage medium comprising instructions. When the instructions are executed on a computer, the storage-computing integrated device performs the neural network calculation method in the second aspect or any possible implementation of the second aspect.
[0044] In a sixth aspect of an embodiment of the present application, a computer program product is provided. When the computer program product is run on a computer, a storage and computing device is enabled to execute a neural network calculation method as described in the second aspect or any possible implementation of the second aspect.
[0045] The descriptions of the second to sixth aspects of the present application can refer to the detailed description of the first aspect; and the beneficial effects of the second to sixth aspects can refer to the analysis of the beneficial effects of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a structural diagram of a storage-computing integrated architecture;
[0047] Figure 2 A schematic diagram of the structure of a storage and computing integrated device provided in an embodiment of the present application;
[0048] Figure 3 A schematic diagram of the structure of another storage and computing integrated device provided in an embodiment of the present application;
[0049] Figure 4 A schematic diagram of the structure of another storage and computing integrated device provided in an embodiment of the present application;
[0050] Figure 5 A schematic diagram of a data arrangement order provided in an embodiment of the present application;
[0051] Figure 6 A schematic diagram of the structure of another storage and computing integrated device provided in an embodiment of the present application;
[0052] Figure 7A flowchart of a neural network calculation method provided in an embodiment of the present application;
[0053] Figure 8 A schematic diagram of a flow chart of another neural network calculation method provided in an embodiment of the present application;
[0054] Fig. 9 A flowchart of another neural network calculation method provided in an embodiment of the present application;
[0055] Fig.10 A schematic diagram of the structure of a storage and computing chip provided in an embodiment of the present application;
[0056] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The following will discuss the making and use of various embodiments in detail. However, it should be understood that many applicable inventive concepts provided by this application can be implemented in a variety of specific environments. The specific embodiments discussed are only illustrative of specific ways to implement and use this description and this technology, and do not limit the scope of this application.
[0058] Unless defined otherwise, all technical and scientific terms used herein have the same meanings as commonly understood by one of ordinary skill in the art.
[0059] Various circuits or other components may be described or referred to as being "configured to" perform one or more tasks. In this case, "configured to" is used to imply structure by indicating that the circuit / component includes structure (e.g., circuitry) that performs the one or more tasks during operation. Thus, even when the specified circuit / component is not currently operational (e.g., not turned on), the circuit / component may be referred to as being configured to perform the task. Circuits / components used with the phrase "configured to" include hardware, such as circuits that perform an operation, etc.
[0060] The technical scheme in the embodiment of the present application will be described below in conjunction with the accompanying drawings in the embodiment of the present application. In the present application, "at least one" refers to one or more, and "multiple" refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there may be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" or its similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c or a, b and c, where a, b and c can be single or multiple. In addition, in the embodiment of the present application, the words "first", "second" and the like do not limit the quantity and order.
[0061] It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0062] Before introducing the embodiments of the present application, the technical terms and background technologies involved in the present application are first introduced.
[0063] Toggle rate: refers to the number of times a signal (including clock, data, etc.) toggles per unit time.
[0064] Bit weight: The unit value corresponding to each fixed position in the index value. For a multi-digit number, the value represented by the "1" at a certain position is called the bit weight of that position.
[0065] In recent years, neural networks have received great attention and in-depth research from academia and industry, and are widely used in robotics, speech recognition, image recognition, natural language processing, expert systems and other fields. The core operation of neural networks is matrix-vector multiplication, which is computationally intensive and memory-intensive. In order to make up for the shortcomings of general-purpose processing chips in power consumption, performance, and size when processing neural network calculations and improve the efficiency of neural network calculations, it has become an industry consensus to customize dedicated acceleration chips for neural network calculations.
[0066] The emergence of the integrated storage and computing architecture provides an efficient solution for the design of neural network acceleration chips. The integrated storage and computing architecture not only retains the storage and read-write functions of the storage circuit itself, but also supports multiplication and addition operations in high parallelism, which can effectively make up for the shortcomings of general-purpose processing chips in power consumption, performance, and size, reduce the amount of data moved, and improve the efficiency of neural network calculations.
[0067] like Figure 1 The figure shows a schematic diagram of a storage-computing integrated architecture 100. The storage-computing integrated architecture 100 includes a computing array 110, and an input module 120 and an accumulation module 130 coupled to the computing array 110. The computing array 110 includes a plurality of storage computing units 111.
[0068] The input module 120 is used to receive feature data and input the feature data into a plurality of storage and calculation units 111 in the calculation array 110. Each storage and calculation unit 111 can store a weight data, perform multiplication calculation according to the input feature data and weight data, and then output the multiplication result to the accumulation module 130. The accumulation module 130 is used to receive the multiplication results output by the plurality of storage and calculation units 111, perform accumulation calculation on the plurality of multiplication results and output the accumulation result.
[0069] For example, Figure 1 As shown, the input module 120 receives 4 feature data, each of which includes 4 bits (bits, which can also be called bits), and the 4 feature data are "1010", "0010", "1111" and "0000" respectively. In the first cycle, the input module 120 can input the data "0010" with a bit weight of 1 in the 4 feature data into the calculation array 110, and the storage calculation units 111 located in the same row can obtain the same bit data. For example, the storage calculation units 111 in the first row can all obtain the data "0", and perform multiplication calculations with the weight data stored respectively, and then output the multiplication results to the accumulation module 130. The accumulation module 130 can receive multiple multiplication calculation results output by a column of storage calculation units 111 each time, and perform accumulation calculations on the multiple multiplication calculation results to determine the multiplication and accumulation results and output them. In the subsequent cycles, the input module 120 can sequentially input the data "1110" with a bit weight of 2, the data "0010" with a bit weight of 4, and the data "1010" with a bit weight of "8" among the four feature data into the calculation array 110 for multiplication calculation. The accumulation module 130 can sequentially accumulate the results of the multiplication calculation in each cycle, and output the accumulated calculation results of the four cycles, thereby completing the multiplication and accumulation calculation of the four feature data and the weight data. The specific process can refer to the calculation process of the first cycle mentioned above, and the embodiments of the present application will not be repeated here.
[0070] The power consumption of the above-mentioned storage-computing integrated architecture 100 when performing multiplication and accumulation calculations is strongly correlated with the flip rate between the data involved in the calculations in two adjacent cycles. Specifically, when the flip rate between the data involved in the calculations in two adjacent cycles is greater, the power consumption of the storage-computing integrated architecture 100 when performing multiplication and accumulation calculations is higher, and when the flip rate between the data involved in the calculations in two adjacent cycles is smaller, the power consumption of the storage-computing integrated architecture 100 when performing multiplication and accumulation calculations is lower. Therefore, how to reduce the flip rate between the data involved in the calculations in two adjacent cycles becomes a key issue in reducing the power consumption of the storage-computing integrated architecture 100 when performing multiplication and accumulation calculations.
[0071] In order to solve the above problems, an embodiment of the present application provides a storage and computing integrated device that can be applied to neural network calculations, can optimize the flipping rate during neural network calculations, reduce the power consumption of neural network calculations, and improve the computing efficiency of neural networks. It also has a simple structure and low cost.
[0072] like Figure 2 , which is a schematic diagram of a storage-computing integrated device 200 provided in an embodiment of the present application. The storage-computing integrated device 200 includes a preprocessing circuit 210 and a storage-computing circuit 220 coupled to the preprocessing circuit 210.
[0073] In a possible embodiment, the preprocessing circuit 210 may also be used as an input circuit of the storage-computing integrated device 200, or the storage-computing integrated device 200 may further include an input circuit, which is coupled between the preprocessing circuit 210 and the storage-computing circuit 220. The function of the input circuit can refer to the relevant description of the input module 120, and the embodiments of the present application will not be repeated here.
[0074] The preprocessing circuit 210 is used to obtain M eigenvalues, and is also used to determine the first data in the current cycle, and the first data includes the first bit of each eigenvalue in the M eigenvalues. Wherein, M is a positive integer, and each eigenvalue includes multiple bits. The embodiment of the present application does not limit the specific value of M and the specific number of bits included in each eigenvalue. In the following embodiment of the present application, the value of M is 4, and each eigenvalue includes 4 bits as an example for exemplary description.
[0075] Optionally, the first bit may be any bit of each of the M eigenvalues, which is not limited in the embodiment of the present application.
[0076] For example, the M eigenvalues may be as follows Figure 1The four eigenvalues shown are: "1010", "0010", "1111" and "0000". The first bit can be a bit with a weight of 4 in each of the four eigenvalues. It can be understood that the first data includes the data "0010" corresponding to the bit with a weight of 4 in each of the four eigenvalues.
[0077] The storage and calculation circuit 220 is used to perform multiplication and accumulation calculation on the first data in the current cycle.
[0078] In a possible embodiment, Figure 3 As shown, the storage and calculation circuit 220 may include a mutually coupled calculation array 221 and an accumulation circuit 222, the calculation array 221 may include a plurality of storage and calculation units 2211, each storage and calculation unit 2211 may store weight data, and the embodiment of the present application does not limit the specific number of storage and calculation units 2211 included in the calculation array 221.
[0079] Among them, the calculation array 221 is used to perform multiplication calculation on the first data in the current cycle, and the preprocessing circuit 210 is also used to send the first bit weight information corresponding to the first data to the accumulation circuit 222 in the current cycle. The accumulation circuit 222 is used to perform shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information in the current cycle, so as to determine and output the multiplication and accumulation result.
[0080] For example, Figure 1 As shown, taking the first data calculated in the current cycle as data "0010" corresponding to the bit position of each eigenvalue with a bit weight of 4 in the four eigenvalues as an example, the storage calculation units 2211 located in the same row in the calculation array 221 can obtain the same bit data, for example, the storage calculation units 2211 in the first row can all obtain data "0", and perform multiplication calculations with the weight data stored respectively, and then output the multiplication results to the accumulation circuit 222. The accumulation circuit 222 can receive the four multiplication calculation results output by the storage calculation units 2211 in the same column each time, perform accumulation calculations on the four multiplication calculation results to determine the multiplication and accumulation results and output them.
[0081] Optionally, the structure of the accumulation circuit 222 includes an addition tree, etc., which is not limited in the embodiment of the present application.
[0082] In a possible embodiment, the accumulation circuit 222 may include a plurality of sub-accumulation circuits. The embodiment of the present application does not limit the specific number of the plurality of sub-accumulation circuits included in the accumulation circuit 222.
[0083] Among them, the first stage sub-accumulation circuit to the (log K M-1) The sub-accumulation circuit includes an adder, the log K M The sub-accumulation circuit includes a first shift accumulator (or may also be referred to as an accumulator), K is a positive integer greater than or equal to 2, and the embodiment of the present application does not limit the specific value of K. The adder is used to perform addition calculation on the input data, and the first shift accumulator is used to perform shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information, so as to obtain the multiplication and accumulation result corresponding to the first data.
[0084] In a possible embodiment, the specific value of K is related to the type of the adder or the first shift accumulator.
[0085] Exemplarily, when the adder or the first shift accumulator can perform addition calculation on 2 input data at a time, the value of K is 2. When the adder or the first shift accumulator can perform addition calculation on 4 input data at a time, the value of K is 4. In the following embodiments of the present application, the value of K is 2 as an example for exemplary description.
[0086] For example, if the four eigenvalues are Figure 1 The first data calculated in the current cycle is the data "0010" corresponding to the bit position of each eigenvalue with a bit weight of 4 in the 4 eigenvalues, and the value of K is 2. The structure of the accumulator circuit 222 can be as follows: Figure 4 As shown, the accumulation circuit 222 includes two stages of sub-accumulation circuits, wherein the first stage sub-accumulation circuit 2221 includes two adders: adder 22211 and adder 22212, and the second stage (log2 4 )-stage sub-accumulation circuit 2222 includes a first shift accumulator 22221. Adder 22211 is used to accumulate the multiplication calculation results corresponding to the first two bits of data "0" and "0" in the data "0010", and adder 22212 is used to accumulate the multiplication calculation results corresponding to the last two bits of data "1" and "0" in the data "0010". The first shift accumulator 22221 is used to shift and accumulate the results output by adder 22211 and adder 22212 according to the bit weight 4 to determine the multiplication and accumulation result of the first data "0010". The specific calculation process of adder 22211 and adder 22212, as well as the specific shift calculation process of the first shift accumulator 22221 can refer to the prior art, and the embodiments of the present application will not be repeated here.
[0087] It can be understood that the storage and computing integrated device 200 provided in the embodiment of the present application, through the log of the accumulator circuit 222 K MThe first shift accumulator is set in the sub-accumulator circuit, and the first weight information corresponding to the first data is sent to the accumulator circuit 222 through the preprocessing circuit 210 in the current cycle, and the first log K M The sub-accumulation circuit can perform shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information, so as to obtain the multiplication accumulation results corresponding to the first data of the M eigenvalues.
[0088] The preprocessing circuit 210 is further configured to determine second data according to the first data, where the second data is data to be calculated in the next cycle, and the second data includes a second bit of each of the M eigenvalues.
[0089] Among them, the flip rate between the first data and the second data is less than or equal to the flip rate between the first data and the third data, and the third data includes the third bit of each eigenvalue in the M eigenvalues, and the third bit is any bit except the first bit and the second bit.
[0090] In a possible embodiment, the preprocessing circuit 210 is specifically used to respectively determine a first flip rate between the first data and the second data, and a second flip rate between the first data and the third data, and compare the first flip rate with the second flip rate to determine the second bit.
[0091] For example, if M eigenvalues are Figure 1 For the four eigenvalues shown, the current cycle is the first cycle, and the preprocessing circuit determines in the first cycle that the first data is the data "0010" corresponding to the bit position of each eigenvalue with a bit weight of 4 in the four eigenvalues.
[0092] In the first cycle, if Figure 5 As shown in (a), the preprocessing circuit 210 can respectively determine the flip rate between the first data and the data corresponding to any remaining bit of each of the four eigenvalues: the flip rate corresponding to the data "0010" corresponding to the bit with a bit weight of 1 is 0% (0 / 4), the flip rate corresponding to the data "1110" corresponding to the bit with a bit weight of 2 is 50% (2 / 4), and the flip rate corresponding to the data "1010" corresponding to the bit with a bit weight of 8 is 25% (1 / 4). Thus, the preprocessing circuit 210 can determine that the data "0010" corresponding to the bit with a bit weight of 1 is the second data in the first cycle by comparing the sizes of the three flip rates.
[0093] In the second cycle, if Figure 5As shown in (b), the preprocessing circuit 210 can determine that the data "0010" corresponding to the bit position with a bit weight of 1 is the first data, and respectively determine the flip rate between the first data and the data corresponding to any remaining bit position of each of the four eigenvalues: the flip rate corresponding to the data "1110" corresponding to the bit position with a bit weight of 2 is 50% (2 / 4), and the flip rate corresponding to the data "1010" corresponding to the bit position with a bit weight of 8 is 25% (1 / 4). Thus, the preprocessing circuit 210 can determine that the data "1010" corresponding to the bit position with a bit weight of 8 is the second data in the second cycle by comparing the sizes of the two flip rates.
[0094] In the third cycle, if Figure 5 As shown in (c), the preprocessing circuit 210 can determine that the data "1010" corresponding to the bit with a bit weight of 8 is the first data, and determine that the data "1110" corresponding to the bit with a bit weight of 2 is the second data.
[0095] In the fourth cycle, if Figure 5 As shown in (d), the pre-processing circuit 210 can determine that the data "1110" corresponding to the bit with a bit weight of 2 is the first data.
[0096] It can be understood that by determining the second data expected to be calculated in the next week based on the first data calculated in the current cycle in each cycle, the flipping rate between the calculated data of two adjacent cycles when the storage and computing integrated device 200 calculates can be reduced, thereby effectively reducing the power consumption of the storage and computing integrated device 200 when calculating the M characteristic values.
[0097] In a possible embodiment, the pre-processing circuit 210 may determine the number of flippings between the first data and the second data, and the number of flippings between the first data and the third data, and compare the number of flippings to determine the second data.
[0098] For example, in the first cycle, Figure 5 As shown in (a), the preprocessing circuit 210 can respectively determine the number of flips between the first data and the data corresponding to any remaining bit of each of the four eigenvalues: the number of flips corresponding to the data "0010" corresponding to the bit with a bit weight of 1 is 0, the number of flips corresponding to the data "1110" corresponding to the bit with a bit weight of 2 is 2, and the number of flips corresponding to the data "1010" corresponding to the bit with a bit weight of 8 is 1. Thus, the preprocessing circuit 210 can determine that the data "0010" corresponding to the bit with a bit weight of 1 is the second data in the first cycle by comparing the sizes of the three flipping times. It can be understood that by comparing the flipping times, there is no need to perform a division operation to determine the flipping rate, which can further improve the computing efficiency of the storage and computing device 200 and reduce computing power consumption.
[0099] In a possible embodiment, if the preprocessing circuit 210 determines that there are multiple second data based on the first data, the preprocessing circuit 210 can sequentially determine the multiple second data as the data to be calculated in the next cycle in multiple consecutive cycles, thereby reducing the flipping rate between the calculated data in two adjacent cycles when the storage and computing integrated device 200 calculates, and effectively reducing the power consumption of the storage and computing integrated device 200 when calculating the M eigenvalues.
[0100] In a possible embodiment, the preprocessing circuit 210 can determine the flipping rate between the first data and the data corresponding to part of the bits of each eigenvalue in the M eigenvalues to determine the second data, thereby reducing the time for determining the second data and improving the computing efficiency of the storage and computing integrated device 200.
[0101] Exemplarily, the preprocessing circuit 210 may determine a flipping rate between the first data and data corresponding to two bits adjacent to the first bit of each eigenvalue in the M eigenvalues to determine the second data.
[0102] For example, combined with Figure 5 In (a), taking the first data being the data "0010" corresponding to the bit with a bit weight of 4 in each of the four eigenvalues as an example, the preprocessing circuit 210 can determine that the flipping rate between the first data and the data "1110" corresponding to the bit with a bit weight of 2 is 50% (2 / 4), and the flipping rate between the first data and the data "1010" corresponding to the bit with a bit weight of 8 is 25% (1 / 4), thereby determining that the data "1010" corresponding to the bit with a bit weight of 8 is the second data based on the two flipping rates.
[0103] In a possible embodiment, the preprocessing circuit 210 can determine the flipping rate between partial data of the first data and partial data corresponding to any bit of each eigenvalue in the M eigenvalues to determine the second data, thereby reducing the time for determining the second data and improving the computing efficiency of the storage and computing integrated device 200.
[0104] For example, Figure 5As shown in (a), taking the first data as data "0010" corresponding to each eigenvalue with a bit weight of 4 in 4 eigenvalues as an example, the preprocessing circuit 210 can determine that the partial data "001" of the first data, the flip rate between the partial data "001" corresponding to the bit with a bit weight of 1 is 0% (0 / 3), the flip rate between the partial data "111" corresponding to the bit with a bit weight of 2 is 66.6% (2 / 3), and the flip rate between the partial data "101" corresponding to the bit with a bit weight of 8 is 33.3% (1 / 3), so according to the three flip rates, the data "0010" with a bit weight of 1 is determined to be the second data. It can be understood that when the number M of eigenvalues obtained by the preprocessing circuit 210 is large, the amount of data corresponding to any bit of each eigenvalue in the M eigenvalues is large. By comparing the flip rates between the partial data to determine the second data, the time for determining the second data can be reduced, and the calculation efficiency of the storage and computing integrated device 200 can be improved.
[0105] In a possible embodiment, the preprocessing circuit 210 is specifically used to respectively determine a first difference between the number of specified values included in the first data and the number of specified values included in the second data, and a second difference between the number of specified values included in the first data and the number of specified values included in the third data, compare the first difference with the second difference to determine the second data, and the first difference is less than or equal to the second difference.
[0106] Optionally, the above-mentioned specified numerical value may be "0" or "1". The embodiment of the present application is not limited to this.
[0107] For example, if M eigenvalues are Figure 1 The four eigenvalues shown in the figure, the first data is the data "0010" corresponding to the bit position of each eigenvalue with a bit weight of 4 in the four eigenvalues, and the designated value is "0" for example. The preprocessing circuit 210 can determine that the number of "0"s included in the data "0010" corresponding to the bit weight of 1 is 0 different from the number of "0"s included in the first data, determine that the number of "0"s included in the data "1110" corresponding to the bit position with a bit weight of 2 is 2 different from the number of "0"s included in the first data, and determine that the number of "0"s included in the data "1010" corresponding to the bit position with a bit weight of 8 is 1 different from the number of "0"s included in the first data. It can be understood that the difference between the number of "0"s included in the data "0010" corresponding to the bit position with a bit weight of 1 and the number of "0"s included in the first data is less than the difference between the number of "0"s included in the data corresponding to the bits with other bit weights and the number of "0"s included in the first data, so the preprocessing circuit 210 can determine that the data "0010" corresponding to the bit position with a bit weight of 1 is the second data. The comparison process when the specified value is "1" can refer to the above process, and the embodiments of the present application will not be repeated here.
[0108] The storage and computing integrated device 200 provided in the embodiment of the present application determines the first data to be calculated in the current cycle among the multiple bits of the M characteristic values through the preprocessing circuit 210, and determines the second data according to the first data through the preprocessing circuit 210, the second data is the data to be calculated in the next cycle, and the flip rate between the first data and the second data is less than or equal to the flip rate between the first data and the third data. Thus, the flip rate between the calculated data of two adjacent cycles when the storage and computing integrated device 200 calculates can be reduced, and the power consumption of the storage and computing integrated device 200 when calculating the M characteristic values can be effectively reduced.
[0109] In a possible embodiment, the preprocessing circuit 210 is also used to obtain N eigenvalues, divide the N eigenvalues into multiple groups, at least one of the multiple groups includes M eigenvalues, to obtain the above-mentioned M eigenvalues, N is a positive integer greater than M, and the embodiment of the present application does not limit the specific value of N.
[0110] In a possible embodiment, the specific value of the above N is the same as the number of rows of the above computing array 221 including the storage computing units 2211 .
[0111] For example, when the calculation array 221 includes 128 rows of storage calculation units 2211 , the value of N is 128.
[0112] Optionally, when the preprocessing circuit 210 divides the N eigenvalues into multiple groups, each group may include the same number of eigenvalues, or may include a different number of eigenvalues. The embodiments of the present application are not limited to this. The following embodiments of the present application are illustrative using the example that each group includes 4 eigenvalues.
[0113] The storage and computing integrated device 200 provided in the embodiment of the present application can reduce the data volume of the first data and the second data by dividing the N eigenvalues obtained by the preprocessing circuit 210 into multiple groups when the number of eigenvalues is large, i.e., N. This can reduce the amount of calculation when the preprocessing circuit 210 determines the second data based on the first data, thereby reducing the time for determining the second data and improving the computing efficiency of the storage and computing integrated device 200.
[0114] In a possible embodiment, the preprocessing circuit 210 is further configured to determine to divide the N eigenvalues into a plurality of groups according to the data size of the N eigenvalues and / or the number of calculations of the corresponding network layer.
[0115] Specifically, when the data scale of the N eigenvalues is large and / or the number of calculations of the corresponding network layer is large, the preprocessing circuit 210 may determine to divide the N eigenvalues into multiple groups, thereby reducing the data volume of the first data and the second data, reducing the amount of calculation when the preprocessing circuit 210 determines the second data based on the first data, reducing the time for determining the second data, and improving the calculation efficiency of the storage-computation-in-one device 200. When the data scale of the N eigenvalues is small and / or the number of calculations of the corresponding network layer is small, the preprocessing circuit 210 may determine not to divide the N eigenvalues into multiple groups. It can be understood that since the data scale of the N eigenvalues is small and / or the number of calculations of the corresponding network layer is small at this time, it is not necessary to divide the N eigenvalues into multiple groups.
[0116] The storage and computing integrated device 200 provided in the embodiment of the present application, the preprocessing circuit 210 determines to divide the N eigenvalues into multiple groups according to the data size of the N eigenvalues and / or the number of calculations of the corresponding network layer, which can improve the computing efficiency of the storage and computing integrated device 200.
[0117] In a possible embodiment, the log-th N K The sub-accumulation circuit includes a second shift accumulator. When the data size of the N eigenvalues is less than the first threshold and / or the number of calculations of the corresponding network layer is less than the second threshold, the preprocessing circuit 210 may not optimize the flip rate of the N eigenvalues, thereby avoiding additional power consumption. At this time, the calculation array 221 in the storage circuit 220 is used to perform multiplication calculations on multiple bits of the N eigenvalues in sequence, and the accumulation circuit 222 is used to accumulate the results of the multiplication calculations.
[0118] Optionally, the first threshold and the second threshold may be pre-set through simulation or experiment, and the embodiment of the present application does not limit the specific values of the first threshold and the second threshold.
[0119] During the accumulation process of the accumulation circuit 222, the preprocessing circuit 210 is further used to sequentially send the second bit weight information corresponding to each bit in the N eigenvalues to the second shift accumulator, and the second shift accumulator is used to perform the (log N K -1) The accumulated results of the sub-accumulation circuits of the stage are subjected to shift-accumulation calculation to determine the multiplication-accumulation result.
[0120] For example, taking the value of N as 16 and the value of K as 2, the structure of the multi-stage sub-accumulation circuit in the accumulation circuit 222 can be as follows: Figure 6 As shown, at this time, the multi-stage sub-accumulation circuit includes four (log2 16)-stage sub-accumulation circuits, the numbers of adders included in the first-stage sub-accumulation circuit 610 to the fourth-stage sub-accumulation circuit 640 are 8, 4, 2, and 1, respectively.
[0121] The first-stage sub-accumulation circuit 610 may include adders 611-618, and the eight adders are respectively used to accumulate the multiplication calculation results output by the calculation array 221. The second-stage sub-accumulation circuit 620 may include first shift accumulators 621-624, and the four first shift accumulators are respectively used to accumulate the accumulation results output by the first-stage sub-accumulation circuit 610. The third (log2 16 -1) stage sub-accumulation circuit 630 may include adder 631 and adder 632, the two adders are respectively used to accumulate the accumulation results output by the second stage sub-accumulation circuit 620. 16 The )-stage sub-accumulation circuit 640 may include a second shift accumulator 641, and the second shift accumulator 641 is used to perform a shift accumulation calculation on the accumulation result of the third-stage sub-accumulation circuit 630 according to the second bit weight information to determine a multiplication-accumulation result.
[0122] The storage and computing integrated device 200 provided in the embodiment of the present application is configured to store and calculate the storage and computing integrated device 200 by performing the first logarithm in the multi-stage sub-accumulation circuit. N K The sub-accumulation circuit of the first stage is provided with a second shift accumulator. When the data scale of the N eigenvalues is less than the first threshold value and / or the number of calculations of the corresponding network layer is less than the second threshold value, the second shift accumulator can perform the calculation of the first (log N K -1) The accumulation result of the sub-accumulation circuit of the stage is subjected to shift accumulation calculation to determine the multiplication-accumulation result, so that the storage-computation integrated device 200 can support the multiplication-accumulation calculation when the flip rate is not optimized.
[0123] like Figure 7 As shown, a neural network calculation method is provided in an embodiment of the present application. The method can be applied to the above-mentioned storage and computing integrated device 200, and the method includes steps S701-S704.
[0124] S701: The preprocessing circuit 210 obtains M eigenvalues, each eigenvalue includes a plurality of bits, and M is a positive integer. The embodiment of the present application does not limit the specific value of M and the specific number of bits included in each eigenvalue.
[0125] S702: The preprocessing circuit 210 determines first data in a current cycle, where the first data includes a first bit of each of the M eigenvalues.
[0126] Optionally, the first bit may be any bit of each of the M eigenvalues, which is not limited in the embodiment of the present application.
[0127] S703, the storage-calculation circuit 220 performs multiplication-accumulation calculation on the first data in the current cycle.
[0128] In a possible embodiment, the storage and calculation circuit 220 includes a mutually coupled calculation array 221 and an accumulation circuit 222. The storage and calculation circuit 220 performs multiplication and accumulation calculations on the first data in the current cycle, including: the calculation array 221 performs multiplication calculations on the first data in the current cycle, the preprocessing circuit 210 sends the first bit weight information corresponding to the first data to the accumulation circuit 222 in the current cycle, and the accumulation circuit 222 performs shift accumulation calculations on the result of the multiplication calculation according to the first bit weight information in the current cycle.
[0129] Optionally, the structure of the accumulation circuit 222 includes an addition tree or the like, which is not limited in the embodiment of the present application.
[0130] In a possible embodiment, the accumulation circuit 222 includes a multi-stage sub-accumulation circuit, wherein the log first K M The sub-accumulation circuit includes a first shift accumulator, K is a positive integer greater than or equal to 2, and the embodiment of the present application does not limit the specific value of K. The above-mentioned accumulation circuit 222 performs shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information in the current cycle, including: the first shift accumulator performs shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information in the current cycle.
[0131] S704: The preprocessing circuit 210 determines second data according to the first data, where the second data is data to be calculated in the next cycle, and the second data includes a second bit of each eigenvalue in the M eigenvalues.
[0132] Among them, the flip rate between the first data and the second data is less than or equal to the flip rate between the first data and the third data, and the third data includes the third bit of each eigenvalue in the M eigenvalues, and the third bit is any bit except the first bit and the second bit.
[0133] In a possible embodiment, the above-mentioned preprocessing circuit 210 determines the second data based on the first data, including: the preprocessing circuit 210 determines the first flip rate between the first data and the second data, and the second flip rate between the first data and the third data, respectively, and compares the first flip rate with the second flip rate to determine the second data.
[0134] In a possible embodiment, the above-mentioned preprocessing circuit 210 determines the second data based on the first data, including: the preprocessing circuit 210 respectively determines the first difference between the number of specified values included in the first data and the number of specified values included in the second data, and the second difference between the number of specified values included in the first data and the number of specified values included in the third data, compares the first difference and the second difference to determine the second data, and the first difference is less than or equal to the second difference.
[0135] Optionally, the above-mentioned specified numerical value may be "0" or "1". The embodiment of the present application is not limited to this.
[0136] like Figure 8 As shown, in a possible embodiment, the number of eigenvalues acquired by the preprocessing circuit 210 is N, where N is a positive integer greater than M. Before the above steps S701-S704, step S705 may be further included.
[0137] S705 . The preprocessing circuit 210 obtains N eigenvalues, and divides the N eigenvalues into a plurality of groups, wherein at least one of the plurality of groups includes M eigenvalues, to obtain M eigenvalues.
[0138] The neural network calculation method provided in the embodiment of the present application can reduce the data volume of the first data and the second data by dividing the N eigenvalues into multiple groups when the preprocessing circuit 210 obtains a large number of N eigenvalues, thereby reducing the amount of calculation when the preprocessing circuit 210 determines the second data based on the first data, reducing the time for determining the second data, and improving the calculation efficiency of the storage and computing integrated device 200.
[0139] like Figure 8 As shown, in a possible embodiment, step S706 may be further included before the above step S705.
[0140] S706: The preprocessing circuit 210 determines to divide the N eigenvalues into a plurality of groups according to the data scale of the N eigenvalues and / or the number of calculations of the corresponding network layer.
[0141] The neural network calculation method provided in the embodiment of the present application, the preprocessing circuit 210 determines to divide the N eigenvalues into multiple groups according to the data size of the N eigenvalues and / or the number of calculations of the corresponding network layer, which can improve the computing efficiency of the storage and computing integrated device 200.
[0142] like Fig. 9 As shown, in a possible embodiment, the log of the multi-stage sub-accumulation circuit N KThe sub-accumulation circuit includes a second shift accumulator. When the data scale of the N eigenvalues is less than the first threshold and / or the number of calculations of the corresponding network layer is less than the second threshold, the method may further include steps S707-S708.
[0143] Optionally, the first threshold and the second threshold may be pre-set through simulation or experiment, and the embodiment of the present application does not limit the specific values of the first threshold and the second threshold.
[0144] S707 . The preprocessing circuit 210 sends the second bit weight information corresponding to each bit in the N eigenvalues to the second shift accumulator in sequence.
[0145] S708, the second shift accumulator performs a shift on the first (log) of the multi-stage sub-accumulation circuit according to the second bit weight information. N K -1) The accumulated results of the sub-accumulation circuits of the stage are subjected to shift-accumulation calculation to determine the multiplication-accumulation result.
[0146] The neural network calculation method provided in the embodiment of the present application is to N K The sub-accumulation circuit of the first stage is provided with a second shift accumulator. When the data scale of the N eigenvalues is less than the first threshold value and / or the number of calculations of the corresponding network layer is less than the second threshold value, the second shift accumulator can perform the calculation of the first (log N K -1) The accumulation result of the sub-accumulation circuit of the stage is subjected to shift accumulation calculation to determine the multiplication-accumulation result, so that the storage-computation integrated device 200 can support the multiplication-accumulation calculation when the flip rate is not optimized.
[0147] like Fig.10 As shown, the embodiment of the present application further provides a storage and computing chip 1000, which includes a single chip microcomputer (also referred to as a single chip microcomputer) 1010, and at least one storage and computing integrated device 200 coupled to the single chip microcomputer 1010, and the structure of the storage and computing integrated device 200 is as follows Figures 2 to 4 ,as well as Figure 6 The structure of the integrated storage and computing device 200 is shown. The embodiment of the present application does not limit the specific number of integrated storage and computing devices 200 included in the storage and computing chip 1000.
[0148] The single-chip microcomputer 1010 may also be referred to as a microcontroller unit (MCU).
[0149] In a possible embodiment, Fig.10As shown, the storage and computing chip 1000 may also include a direct memory access (DMA) 1020 and a dynamic random access memory (DRAM) 1030. The direct memory access 1020, the dynamic random access memory 1030, the storage and computing integrated device 200, and the single-chip microcomputer 1010 may be coupled via a bus (BUS) 1040.
[0150] Optionally, the storage and computing chip 1000 can be applied in scenarios including keyword detection, image classification, target detection, etc. The embodiments of the present application do not limit the specific application scenarios of the storage and computing chip 1000.
[0151] like Fig.11 As shown, the embodiment of the present application also provides an electronic device 1100, which includes a processor 1110 and a storage and computing chip 1000 coupled to the processor 1110. The structure of the storage and computing chip 1000 is as follows Fig.10 The structure of the storage and computing chip 1000 is shown.
[0152] In a possible example, the processor 1110 may be a central processing unit (CPU).
[0153] Optionally, the type of the electronic device 1100 may include a smart watch, a smart bracelet, a Bluetooth headset, a smart phone, a smart car machine, a drone, etc. The embodiment of the present application does not limit the specific type of the electronic device 1100.
[0154] The embodiment of the present application further provides a computer-readable storage medium, in which a computer-executable instruction is stored. When at least one processor of the device executes the computer-executable instruction, the storage-computing integrated device 200 executes the following Figure 7-Figure 9 The steps in the neural network calculation method shown.
[0155] The present application also provides a computer program product. When at least one processor of a device runs the computer program product, the storage-computing integrated device 200 executes the following Figure 7-Figure 9 The steps in the neural network calculation method shown.
[0156] Optionally, the computer program product may be an intellectual property core (IP core).
[0157] The above detailed description of the integrated storage and computing device 200, as well as the analysis of beneficial effects, can all be correspondingly referred to the neural network calculation method, storage and computing chip 1000, electronic device 1100, computer-readable storage medium and computer program product, and the embodiments of the present application will not be repeated here.
[0158] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A storage and computing device, It is characterized in that Applied to neural network calculation, the storage-computation integrated device includes a preprocessing circuit and a storage-computation circuit coupled to the preprocessing circuit; The preprocessing circuit is used to obtain M eigenvalues, each of which includes a plurality of bits, and M is a positive integer; The preprocessing circuit is further used to determine first data in a current cycle, wherein the first data includes a first bit of each of the M eigenvalues; The storage and calculation circuit is used to perform multiplication and accumulation calculation on the first data in the current cycle; The preprocessing circuit is further used to determine second data according to the first data, where the second data is data to be calculated in the next cycle, and the second data includes a second bit of each eigenvalue in the M eigenvalues.
2. The device according to claim 1, It is characterized in that A flip rate between the first data and the second data is less than or equal to a flip rate between the first data and the third data, and the third data includes a third bit of each eigenvalue of the M eigenvalues, and the third bit is any bit except the first bit and the second bit.
3. The device according to claim 2, It is characterized in that The preprocessing circuit is specifically used to respectively determine a first flip rate between the first data and the second data, and a second flip rate between the first data and the third data, and compare the first flip rate with the second flip rate to determine the second data.
4. The device according to claim 2, It is characterized in that The preprocessing circuit is specifically used to respectively determine a first difference between the number of specified values included in the first data and the number of specified values included in the second data, and a second difference between the number of specified values included in the first data and the number of specified values included in the third data, and compare the first difference with the second difference to determine the second data, wherein the first difference is less than or equal to the second difference.
5. The device according to any one of claims 1 to 4, It is characterized in that The storage and calculation circuit includes a calculation array and an accumulation circuit coupled to each other; The calculation array is used to perform multiplication calculation on the first data in a current cycle; The preprocessing circuit is further used to send the first bit weight information corresponding to the first data to the accumulating circuit in the current cycle; The accumulation circuit is used to perform shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information in the current cycle.
6. The device according to claim 5, It is characterized in that The structure of the accumulation circuit includes an addition tree.
7. The device according to claim 6, It is characterized in that The accumulation circuit includes a plurality of sub-accumulation circuits, wherein the first The stage sub-accumulation circuit includes a first shift accumulator, K is a positive integer greater than or equal to 2; The first shift accumulator is used to perform shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information in the current cycle.
8. The device according to claim 7, It is characterized in that The preprocessing circuit is further used to obtain N eigenvalues, divide the N eigenvalues into multiple groups, at least one of the multiple groups includes M eigenvalues, to obtain the M eigenvalues, N is a positive integer greater than M.
9. The device according to claim 8, It is characterized in that The preprocessing circuit is further used to determine whether to divide the N eigenvalues into multiple groups according to the data scale of the N eigenvalues and / or the number of calculations of the corresponding network layer.
10. The device according to claim 9, It is characterized in that The first The sub-accumulation circuit includes a second shift accumulator, when the data scale of the N eigenvalues is less than the first threshold value and / or the number of calculations of the corresponding network layer is less than the second threshold value; The preprocessing circuit is further used to sequentially send second bit weight information corresponding to each bit in the N eigenvalues to the second shift accumulator; The second shift accumulator is used to shift the first bit of the multi-stage sub-accumulation circuit according to the second bit weight information. The accumulated results of the sub-accumulation circuits are subjected to shift accumulation calculation.
11. A neural network calculation method, It is characterized in that Applied to a storage-computation integrated device including a preprocessing circuit and a storage-computation circuit, the method comprises: The preprocessing circuit obtains M eigenvalues, each of which includes a plurality of bits, and M is a positive integer; The preprocessing circuit determines first data in a current cycle, wherein the first data includes a first bit of each of the M eigenvalues; The storage and calculation circuit performs multiplication and accumulation calculation on the first data in the current cycle; The preprocessing circuit determines second data according to the first data, where the second data is data to be calculated in the next cycle, and the second data includes a second bit of each eigenvalue in the M eigenvalues.
12. The method according to claim 11, It is characterized in that A flip rate between the first data and the second data is less than or equal to a flip rate between the first data and the third data, and the third data includes a third bit of each eigenvalue of the M eigenvalues, and the third bit is any bit except the first bit and the second bit.
13. The method according to claim 12, It is characterized in that The preprocessing circuit determines second data according to the first data, including: The preprocessing circuit determines a first flip rate between the first data and the second data, and a second flip rate between the first data and the third data, respectively, and compares the first flip rate with the second flip rate to determine the second data.
14. The method according to claim 12, It is characterized in that The preprocessing circuit determines second data according to the first data, including: The preprocessing circuit respectively determines a first difference between the number of specified values included in the first data and the number of specified values included in the second data, and a second difference between the number of specified values included in the first data and the number of specified values included in the third data, and compares the first difference with the second difference to determine the second data, wherein the first difference is less than or equal to the second difference.
15. The method according to any one of claims 11 to 14, It is characterized in that The storage and calculation circuit includes a calculation array and an accumulation circuit coupled to each other, and the method further includes: The calculation array performs multiplication calculation on the first data in the current cycle; The preprocessing circuit sends the first bit weight information corresponding to the first data to the accumulating circuit in the current cycle; The accumulation circuit performs shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information in the current cycle.
16. The method according to claim 15, It is characterized in that The structure of the accumulation circuit includes an addition tree.
17. The method according to claim 16, It is characterized in that The accumulation circuit includes a plurality of sub-accumulation circuits, wherein the first The stage sub-accumulation circuit includes a first shift accumulator, K is a positive integer greater than or equal to 2, and the method further includes: The first shift accumulator performs a shift accumulation calculation on the result of the multiplication calculation according to the first bit weight information in a current cycle.
18. The method according to claim 17, It is characterized in that The method further comprises: The preprocessing circuit obtains N eigenvalues, divides the N eigenvalues into a plurality of groups, at least one of the plurality of groups includes M eigenvalues, to obtain the M eigenvalues, where N is a positive integer greater than M.
19. The method according to claim 18, It is characterized in that The method further comprises: The preprocessing circuit determines to divide the N eigenvalues into a plurality of groups according to the data scale of the N eigenvalues and / or the number of calculations of the corresponding network layer.
20. The method according to claim 19, It is characterized in that The first The sub-accumulation circuit includes a second shift accumulator. When the data scale of the N eigenvalues is less than the first threshold and / or the number of calculations of the corresponding network layer is less than the second threshold, the method further includes: The preprocessing circuit sequentially sends second bit weight information corresponding to each bit in the N eigenvalues to the second shift accumulator; The second shift accumulator performs a shift operation on the first bit of the multi-stage sub-accumulation circuit according to the second bit weight information. The accumulated results of the sub-accumulation circuits are subjected to shift accumulation calculation.
21. A storage and computing chip, It is characterized in that The storage-computing chip includes a single-chip microcomputer and at least one storage-computing integrated device coupled to the single-chip microcomputer, and the storage-computing integrated device is the storage-computing integrated device as described in any one of claims 1-10.
22. An electronic device, It is characterized in that The electronic device includes a processor and a storage and computing chip coupled to the processor, and the storage and computing chip is the storage and computing chip as described in claim 21.
Citation Information
Patent Citations
Arithmetic device, circuit and related method for neural network
CN108780524A
Partial product summation module design method and multiplier
CN114756199A
Fixed-point full-precision in-memory computing circuit based on multi-bit SRAM cells
CN114937470A
Data processing method and device and chip
CN115035384A
