Operational core and chip based on matrix multiplication combining similar items

By designing a matrix multiplication core based on merging similar items in the accelerator, and using data mapping and addition tree structures, the problem of poor bandwidth and resource utilization of bit-width scalable accelerators in different precision modes is solved, and efficient depth is achieved. Neural network operations reduce hardware overhead.

CN118643254APending Publication Date: 2024-09-13NAT UNIV OF DEFENSE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410710513.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-03
Publication Date
2024-09-13

AI Technical Summary

Technical Problem

Existing bit-width scalable bit-parallel accelerators have poor bandwidth utilization and computing resource utilization in different precision modes, and their complex circuit structures result in high hardware overhead.

Method used

Design a matrix multiplication core based on merging similar items, including multiple rows of calculation units. Each row includes a data mapping unit, a multi-mode accumulator and multiple PEs. Through data multiplexing and addition tree structure, it can operate in different precision modes. Optimize bandwidth and computing resource utilization, and support multiple precision computing modes.

Benefits of technology

It achieves optimal bandwidth utilization and maximum computing resource utilization in different precision modes, reduces the complexity and cost of hardware design, and supports a variety of deep neural network computing requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118643254A
    Figure CN118643254A
Patent Text Reader

Abstract

The invention relates to an operation core and chip for matrix multiplication based on merged similar items. The operation core mainly comprises a data multiplexing calculation unit, a data mapping unit and a multi-mode accumulator based on an addition tree. In different precision modes, data multiplexing of different degrees is carried out between the calculation units of the operation core, and the optimal bandwidth utilization rate is guaranteed. The calculation parallelism degree is adjusted according to the precision mode, calculation resources are utilized to the maximum extent, operation modes of multiple precision are supported, and the deep neural network operation requirements of different application scenes are met; moreover, the structure is simple and flexible, the complexity of hardware design is low, and the hardware overhead is low.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the fields of processor micro-architecture and computing technology, and in particular to an operation core and chip based on matrix multiplication of merging like items. Background Art

[0002] The number of parameters and complexity of deep neural networks (DNNs) continue to grow, and computer systems face major challenges in terms of storage and computing power. Narrow precision fixed-point (INT) computing is an important way to alleviate these challenges. Narrow precision fixed-point formats, such as 2 / 4 / 8-bit, have been shown in many studies to achieve DNN inference accuracy comparable to high precision (FP32). Nevertheless, the changes in the number of parameters and structure between different DNN models and the layers of the DNN have different requirements for the minimum bit width of the INT format. Therefore, DNN accelerators must be able to support scalable precision INT computing to achieve a better balance between DNN inference accuracy and computing performance.

[0003] Scalable precision accelerators are usually divided into two categories: (1) bit-parallel accelerators and (2) bit-serial accelerators.

[0004] However, several problems plague existing bit-width scalable bit-parallel accelerators: (1) The input bandwidth requirement fluctuates greatly at different precisions. The high-precision mode has a smaller bandwidth requirement, resulting in low bandwidth utilization. For example, Figure 1 As shown, BitBlade shows the highest input bandwidth utilization at 2bx2b precision and the lowest input bandwidth utilization at 8bx8b precision, with a 75% reduction in input bandwidth utilization. On average, the utilization is only 58%. (2) Insufficient computing resource utilization. Some accelerators have poor computing resource utilization in different precision modes. For example, Envision achieves 100% computing resource utilization at high precision (16bx16b), but only 25% computing resource utilization at low precision (4bx4b). (3) Complex circuit structure and related overhead. The complex circuit structure adopted by some accelerators brings challenges such as increased area and power consumption. For example, BitFusion has high chip area and power consumption overhead due to complex precision mode configuration, Shift-Add and other control circuits. Summary of the invention

[0005] Based on this, it is necessary to provide a matrix multiplication operation core and a chip based on merging like terms to address the above technical problems.

[0006] In order to achieve the above objectives, the embodiments of the present invention adopt the following technical solutions:

[0007] On the one hand, a computing core for matrix multiplication based on merging like items is provided, comprising a plurality of rows of computing units; each row of computing units comprises a data mapping unit, a multi-mode accumulator and a plurality of PEs;

[0008] Each PE is used to calculate the cumulative coefficient product of each similar term according to the input data to obtain each PE result; each PE includes a plurality of 2-bit multipliers;

[0009] A data mapping unit, used for adjusting the order of each PE result to obtain each rearranged PE result;

[0010] The multi-mode accumulator is used to accumulate according to each rearranged PE result, the offset of the input data and the precision mode to obtain a preliminary multiplication result.

[0011] In one embodiment, the multiplication of the operation kernel is based on the following calculation principle:

[0012]

[0013] in, a and b are row vectors and column vectors respectively, and the vector length is K, α i and β j Represents a 2-bit slice (term) of the original data, defined as the coefficient, V i+j Represents the offset of the 2-bit slice of the original data, defined as a variable, P a and P b Respectively represent the parallelism of scalar a and b, and define P a =4 / m and P b =4 / n, m and n represent the number of items of decomposed scalars a and b, and the decomposition granularity is 2 bits respectively.

[0014] On the other hand, a chip is also provided, comprising the above-mentioned operation core of matrix multiplication based on merging like terms, the operation core comprising a plurality of rows of computing units; each row of computing units respectively comprises a data mapping unit, a multi-mode accumulator and a plurality of PEs;

[0015] Each PE is used to calculate the cumulative coefficient product of each similar term according to the input data to obtain each PE result; each PE includes a plurality of 2-bit multipliers;

[0016] A data mapping unit, used for adjusting the order of each PE result to obtain each rearranged PE result;

[0017] The multi-mode accumulator is used to accumulate according to each rearranged PE result, the offset of the input data and the precision mode to obtain a preliminary multiplication result.

[0018] One or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:

[0019] The above-mentioned operation core and chip based on matrix multiplication of merging similar items mainly include a data reuse computing unit, a data mapping unit and a multi-mode accumulator based on an addition tree. In different precision modes, the computing units of the operation core reuse data to different degrees, ensuring the optimal bandwidth utilization; and adjusting the computing parallelism according to the precision mode, maximizing the use of computing resources, supporting multiple precision operation modes, and meeting the deep neural network computing requirements of different application scenarios; furthermore, the structure is simple and flexible, the hardware design complexity is small, and the hardware overhead is low. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the conventional technology, the drawings required for use in the embodiments or the conventional technology descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0021] Figure 1 A schematic diagram of input bandwidth utilization in different precision modes in the background technology in an embodiment;

[0022] Figure 2 A schematic diagram of an operation kernel of matrix multiplication based on merging like items in one embodiment;

[0023] Figure 3 Schematic diagram of the result offset of each PE in a PE row and the shifter multiplexing rule in different precision modes in one embodiment, wherein (a) represents the PE result offset, and (b) represents the shifter multiplexing rule;

[0024] Figure 4 A schematic diagram of data mapping and addition tree shift times in one embodiment;

[0025] Figure 5 FIG. 1 is a schematic diagram of a multi-mode accumulator based on an addition tree in one embodiment. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.

[0028] It should be noted that the reference to "embodiment" in this document means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present invention. The presentation of the phrase at various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments.

[0029] The following will describe the implementation of the present invention in detail with reference to the accompanying drawings in the embodiment diagram of the present invention.

[0030] In one embodiment, Figure 2 As shown, an embodiment of the present application provides an operation core of matrix multiplication based on merging like terms, including multiple rows of computing units; each row of computing units includes a data mapping unit, a multi-mode accumulator and multiple PEs.

[0031] It can be understood that the operation kernel diagram of matrix multiplication based on merging similar items is as follows Figure 2 As shown, it includes multiple rows of computing units (PE Line, Processing Element Line). Specifically, the number of rows of computing units can be selected according to needs, for example: 4, 8, 16 or 32, etc. (for ease of understanding, 16 are taken as an example in this embodiment and the following text), and each row of computing units includes a data mapping unit, a multi-mode accumulator and multiple PEs. Specifically, the number of PEs in each row of computing units can be selected according to the requirements of the precision mode. For example, each row of computing units can be selected to include 16, 8 or 32 PEs, etc. (16 PEs are taken as an example in this embodiment and the following text).

[0032] Each PE is used to calculate the cumulative coefficient product of each similar item according to the input data to obtain each PE result; each PE includes a plurality of 2-bit multipliers.

[0033] It can be understood that, first, a matrix multiplication is proposed:

[0034]

[0035] Vector multiplication calculation As shown in the above formula. Among them, a and b are row vectors and column vectors respectively, and the vector length is K. The elements of a and b are scalars a and scalar b respectively. 2 bits are used as the smallest narrow fixed-point data format, that is, the calculation granularity. The 4b format can be decomposed into Two items, of which α i Represents a 2-bit slice (term) of the original 4-bit data, defined as the coefficient, and V i The offset (2i) of the slice corresponding to the original 4-bit data is defined as a variable.

[0036] Specifically, for example, if the 4-bit data is 11012, then α0=012 and α1=112, and V0=2 0 and V1 = 2 2 Similarly, the 8b format can be decomposed into four items, such as m and n represent the number of items that decompose scalar a and b into 2-bit granularity, as shown in Table 1. i and β j The product of requires a 2-bit multiplier as the basic arithmetic unit. i With V j The product can be converted into exponential addition, that is, V i V j =2 2i 2 2j =2 2(i+j) =V i+j Therefore, the product of the decomposition terms of the scalar data a and b (α i β j V i V j ) can simplify the 2-bit multiplication α i β j The result is shifted left again 2(i+j) times.

[0037] In this embodiment, the number of items of a and b data decomposed at a 2-bit granularity is shown in Table 1.

[0038] Table 1:

[0039]

[0040] V i (or V j ) is completely determined by the position of the 2-bit item in the original data, so each element of the row vector a (or column vector b) generates the same V after slicing. i (or V j ). Therefore, the multiplication of the corresponding elements in the row vector a and the column vector b can obtain mn groups of similar terms α i β j V i+j Here, V 1+2 and V 2+1 Belong to different terms. Each group contains K terms, which is the length of the vector. The process of combining (summing) the coefficients of K like terms in each group is the process of combining like terms (CLT). Summing the results of related groups gives the preliminary result y of vector multiplication.

[0041] The parallel accelerator needs to be compatible with multiple precision calculations, such as 2 / 4 / 8b and their combinations. The concept of parallelism (P) is introduced to represent the number of results that can be calculated in parallel.a and P b Represent the parallelism of a and b respectively, indicating that there is P a P b parallel computations. Represents multiple results of the calculation. Define P a =4 / m and P b =4 / n, where m and n are the number of terms of the decomposed scalars a and b, and their granularity is 2 bits respectively (as shown in Table 1). The input bit width is fixed to 8 bits. In the 8bx8b mode, a pair of 8-bit a and b is input, m=n=4, P a =P b =1, Generate a 16-bit result y 00 In 4bx4b mode, input two pairs of 4-bit a and b, m=n=2, P a =P b =2, Generate 4 8-bit results, namely y 00 ,y 01 ,y 10 and 11 , the total output bit width is 32 bits. In 2bx2b mode, input 4 pairs of 2-bit a and b, m = n = 1 and P respectively. a =P b =4, we get The 16 4-bit results are recorded as y 00 ,y 01 , …, y 33 , the total output bit width is 64 bits. Similar calculations are also applicable to other precision modes. Therefore, the input bandwidth and computing unit utilization can be fully utilized in different precision modes, and the output bandwidth has a small change.

[0042] Specifically, each PE is used to calculate the cumulative coefficient product of each similar item according to the input data to obtain the result of each PE, that is, to calculate:

[0043]

[0044] Each PE includes a plurality of 2-bit multipliers. Specifically, the number of 2-bit multipliers can be selected according to the requirements of the precision mode, such as 16, 8 or 32, etc. (this embodiment and the following text all take 16 multipliers as an example), α i and β j The product of (i.e., the coefficient product of like terms) requires a 2-bit multiplier as the basic arithmetic unit, K α i and β j The product of requires K 2-bit multipliers, that is, the number of multipliers in the PE corresponds to K in the formula.

[0045] The data mapping unit is used to adjust the order of each PE result to obtain each rearranged PE result.

[0046] It can be understood that the variable corresponding to the result item of the calculation of each PE in the PE row is 2 2(i+j) , which represents the offset of the result item in the final result. i and j represent the index of the item in the original a and b respectively (Table 1).

[0047] Figure 3 Schematic diagram of the result offset of each PE in a PE row and the shifter reuse rule in different precision modes in one embodiment, where S represents the number of shifts (i.e., the offset). (a) represents the PE result offset, and (b) represents the shifter reuse rule. See FIG. 1 for the offset of each PE in different precision modes. Figure 3 (a), the offset of the i-th (or j-th) item in a (or b) is 2i (or 2j). The offset corresponding to the PE result is 2(i+j). Figure 3 The gray lines in (a) separate different accumulation islands. The results of PEs in each accumulation island need to be left-shifted and summed to get the final result. The number of accumulation islands varies with the precision, which corresponds to the degree of parallelism in the formula, that is, P a P b .

[0048] The number of left shifts required for the PE result depends on the precision mode, requiring 16 configurable shifters in the PE row. In addition, an accumulator that supports multiple modes is necessary, further increasing the hardware overhead. Figure 3 (a) It can be found that the number of left shifts of PE results of different precisions shows a linear increase or transposition change. This shows that there is a possibility of reusing the shifter. For example, in the case of 2bx8b, the offset gap between each PE row is 2. When the offset of the last two rows of PE results is reduced by 4, the offset pattern of 2bx8b is similar to that of 2bx4b. In addition, the offset of the PE result at 2bx4b is transposition symmetric to the offset of the PE result at 4bx2b. Therefore, both 2bx8b and 2bx4b can reuse the 4bx2b shifter.

[0049] Figure 3 (b) illustrates the multiplexing rules of the shifters in different precision modes. Except for the 2bx2b mode, all other precision modes can be converted to 4bx2b offset form; the gray line represents the addition of two offsets, and the value marked at one end of the gray line represents the additional increase in the offset, similar to the structure of the addition tree, the offset in each accumulation island is increased step by step to achieve the same effect as the original offset. For example, if the offset of the last PE result in 8bx8b mode is 0xC=12 (the value is expressed in hexadecimal), the accumulation process 2+2+4+4=12 is used.

[0050] The larger the accumulation island area, the larger the accumulated value. A larger accumulation island can reuse the shifter of a smaller accumulation island. For example, the offset change process from 4bx2b→4bx4b→4bx8b→8bx8b follows the hierarchical inclusion pattern. Figure 3 In (b), the addition trees of different precisions exhibit a transposed symmetric pattern (e.g., 2bx8b and 8bx2b), and the PE results need to be remapped to ensure that the addition trees are reused. Therefore, the data needs to be reorganized (mapped) without changing the final calculation accuracy.

[0051] Specifically, the data mapping unit is used to adjust the order of each PE result to obtain each rearranged PE result. Figure 4 Schematic diagram of data mapping and addition tree shift times in one embodiment, that is, Figure 4 The remapping results of PE results in different precision modes (i.e., reordering PE results) and the corresponding shift parameters of the addition tree at different levels are explained.

[0052] For 2bx2b, 4bx2b, and 8bx2b, the order of PE results does not need to be adjusted because the data order within each accumulation island remains consistent with the original PE order. In 2bx4b mode, the order of PE results needs to be swapped with that in 4bx2b mode. Specifically, the first row of PE results needs to be interleaved with the second row of results, and the same is true for the third and fourth rows. Similarly, in 2bx8b mode, the results of PE rows at the same position of the PE need to be combined together. The mapping modes of 4bx4b and 8bx4b are the same. 4bx8b uses the same mapping form as 8bx8b. The data mapping unit only incurs very little hardware overhead.

[0053] In each precision mode, the number of accumulation islands corresponds to the number of independent results generated in parallel. For example, in 4bx2b mode, there are 8 accumulation islands producing 8 independent results, while in 8bx8b mode, there is only one result. Therefore, the peak performance of the former is 8 times that of the latter. Figure 4 The peak performance comparison under different modes is also given.

[0054] The multi-mode accumulator is used to accumulate according to each rearranged PE result, the offset of the input data and the precision mode to obtain a preliminary multiplication result.

[0055] It can be understood that the result of the data mapping unit is input into the multi-mode accumulator, and the accumulation of different accumulation islands is completed according to the precision mode.

[0056] Figure 5 FIG. 1 is a schematic diagram of a multi-mode accumulator based on an addition tree in one embodiment. The accumulation of the rearranged PE results in each accumulation island is composed of an addition tree and an accumulator. Figure 5As shown in Figure 1. The addition tree has five levels, denoted as L- and L0-L3. Different levels of adders match different precision modes, such as Figure 4 shown.

[0057] The L-adder is used to accumulate the results in a 2bx2b pattern without any offset, forming a circular accumulation structure with the bottom register. In the L0-L3 adders, the right input of the adder needs to be left shifted first. The offset is Figure 4 The number of addition tree shifts corresponds to Figure 3 Additional offsets on the addition tree branches shown in (b).

[0058] exist Figure 5 In the figure, the black arrow at the adder input indicates that the value does not need to be shifted left, which means that the offset of the value is 0. The black dashed line with an arrow indicates that the input needs to be shifted left. The L-stage needs to be shifted left by 2 bits, the L0 stage needs to be shifted left by 2 or 4 bits, and the L1 and L2 stages need to be shifted left by 4 bits. The number of shifts for each stage is fixed, and the shifter with configurable parameters can be replaced by filling zeros in the lower bits of the value. For example, the expression (2′b11<<2) can be replaced by {2′b11,2′b0}=4′b1100, thereby reducing hardware overhead.

[0059] In high-precision mode, multi-stage adders are used to improve the reusability of the circuit. For example, in 8bx8b mode, all levels of adders are used. In contrast, in 2bx2b mode, only the L-level adders are activated, while the other levels remain disconnected. In addition, in order to shorten the timing path in high-precision mode, registers can be added to increase the operating frequency. After each adder, a data distributor is used to select the result output direction, either to the register or to the input of the next level adder.

[0060] Figure 5 In the example, the register unit at the bottom and the adders at different levels form a circular accumulation unit. Since the bit width of the result is different in each precision mode, the register unit can be configured into different modes to accommodate different bit widths. In a certain precision mode, the adder and the register form a circular accumulator, and the other paths of the register unit are closed. When calculating Y=AB+C, the value of the matrix C is preloaded into the register unit as the initial value for subsequent accumulation.

[0061] The above-mentioned operation core of matrix multiplication based on merging similar items mainly includes a data reuse computing unit, a data mapping unit, and a multi-mode accumulator based on an addition tree. In different precision modes, the computing units of the operation core reuse data to different degrees, ensuring the optimal bandwidth utilization; and adjusting the computing parallelism according to the precision mode, maximizing the use of computing resources, supporting multiple precision operation modes, and meeting the deep neural network computing requirements of different application scenarios; moreover, the structure is simple and flexible, the hardware design complexity is small, and the hardware overhead is low.

[0062] In one embodiment, the above-mentioned operation kernel based on matrix multiplication of merging like items, the multiplication of the operation kernel is based on the following calculation principle:

[0063]

[0064] in, a and b are row vectors and column vectors respectively, and the vector length is K, α i and β j Represents a 2-bit slice (term) of the original data, defined as the coefficient, V i+j The offset of the 2-bit slice representing the original data is defined as a variable, P a and P b Respectively represent the parallelism of scalar a and b, and define P a =4 / m and P b =4 / n, m and n represent the number of items of decomposed scalars a and b, and the decomposition granularity is 2 bits respectively.

[0065] In one embodiment, the operation core of the matrix multiplication based on merging similar items integrates the preliminary multiplication results obtained according to the rows of each computing unit to obtain the final result of the matrix multiplication:

[0066]

[0067] Among them, Y = AB, and the sizes of each matrix are: Y[W,Z], A[W,K] and B[K,Z].

[0068] It can be understood that the expansion of the original formula constitutes a new precision-scalable matrix multiplication calculation based on the concept of combining like terms and matrix multiplication.

[0069] In one embodiment, the above-mentioned operation core of matrix multiplication based on merging like items, the multi-mode accumulator includes multiple shifters, multiple adders and registers. Each shifter is used to shift each of the rearranged PE results according to the precision mode, which can be understood to calculate:

[0070]

[0071] Each adder and register is used to form a multi-mode accumulator based on an addition tree, which is used to accumulate and obtain the preliminary result of multiplication, that is, to calculate:

[0072]

[0073] In one embodiment, the above-mentioned operation core of matrix multiplication based on merging like terms includes 16 rows of computing units; each row of computing units includes 16 PEs; each PE includes 16 2-bit multipliers.

[0074] It can be understood that the operation core is a systolic array (SA) composed of 16 processing element lines (PE Line). Each PE line consists of 16 PEs, a data mapping unit, and a multi-mode accumulator based on an adder tree, supporting a total of 9 calculation modes with precisions of 2 / 4 / 8b and their combinations. Each PE includes 16 2-bit multipliers, and the output results are accumulated through the adder tree.

[0075] The calculation process in the PE involves 16 multiplications and accumulations of 2-bit data. The shifter represents the variable V in the formula, because powers of 2 can be converted into left shift operations. The input of the PE row includes the coefficient α i and β j , obtained by decomposing vectors a and b. The coefficients of 16 similar terms (each 2 bits) are concatenated to obtain 32-bit data blocks. These blocks are then Figure 2 This is BitShare, which ensures consistent input bandwidth for different precision modes. a P b mn=16, which is the number of PEs in the PE row. Each of the 16 groups of similar items can be calculated on the PE row, thereby maximizing the PE utilization under different precision modes. The output of each PE is the result of the coefficient multiplication and accumulation in the process of merging similar items. When the precision mode is determined, the variable V in the similar items can be predetermined (as shown in Table 1), which represents the offset of each item in the original data, that is, the offset of each PE in the PE row in the final result. In the multiplication process of the two, the coefficient is shifted to the left by the offset corresponding to the variable to obtain the result.

[0076] At 2bx2b precision, the 16 PE results are completely independent, with parallelism {Pa, Pb} = 16, and each result has a separate accumulator. In other modes, when the parallelism is less than 16, the PE results need to be added to get the final result. For example, at 8bx8b precision, the parallelism is {Pa, Pb} = 1, and all results need to be added together. The accumulator can be configured dynamically. The input a_row is shared between different PE rows, and different b_cols are injected into different PE rows.

[0077] The above-mentioned operation core based on matrix multiplication of merging similar items supports 9 types of precision operation modes including 2b / 4b / 8b and their combinations, which can meet the deep neural network operation requirements of different application scenarios.

[0078] In one embodiment, a chip is provided, including an operation core for matrix multiplication based on merging like terms, the operation core including: a plurality of rows of computing units; each row of computing units respectively including a data mapping unit, a multi-mode accumulator and a plurality of PEs; each PE is used to calculate the cumulative coefficient product of each like term according to input data to obtain each PE result; each PE respectively includes a plurality of 2-bit multipliers; the data mapping unit is used to adjust the order of each PE result to obtain each rearranged PE result; the multi-mode accumulator is used to accumulate according to each rearranged PE result, the offset of the input data and the precision mode to obtain a preliminary multiplication result.

[0079] The above chip includes a computing core based on matrix multiplication of merging similar items, and the computing core mainly includes a computing unit for data reuse, a data mapping unit, and a multi-mode accumulator based on an addition tree. In different precision modes, the computing units of the computing core reuse data to different degrees, ensuring the optimal bandwidth utilization; and adjusting the computing parallelism according to the precision mode, maximizing the use of computing resources, supporting multiple precision computing modes, and meeting the deep neural network computing requirements of different application scenarios; furthermore, the structure is simple and flexible, the hardware design is less complex, and the hardware overhead is low.

[0080] In one embodiment, in the above chip, the multiplication of the operation core is based on the following calculation principle:

[0081]

[0082] in, a and b are row vectors and column vectors respectively, and the vector length is K, α i and β j Represents a 2-bit slice (term) of the original data, defined as the coefficient, V i+j Represents the offset of the 2-bit slice of the original data, defined as a variable, P a and P bRespectively represent the parallelism of scalar a and b, and define P a =4 / m and P b =4 / n, m and n represent the number of items of decomposed scalars a and b, and the decomposition granularity is 2 bits respectively.

[0083] In one embodiment, in the above chip, the operation core integrates the preliminary multiplication results obtained according to the rows of each computing unit to obtain the final result of matrix multiplication:

[0084]

[0085] Among them, Y = AB, and the sizes of each matrix are: Y[W,Z], A[W,K] and B[K,Z].

[0086] In one embodiment, in the above chip, the multi-mode accumulator includes multiple shifters, multiple adders and registers; each shifter is used to offset each rearranged PE result according to the precision mode; each adder and register is used to form an addition tree-based multi-mode accumulator for accumulating to obtain preliminary multiplication results.

[0087] In one embodiment, in the above chip, the computing core includes 16 rows of computing units; each row of computing units includes 16 PEs; each PE includes 16 2-bit multipliers.

[0088] For the specific definition of the chip, please refer to the definition of the operation core of the matrix multiplication based on the combination of similar items in the above text, which will not be repeated here. Those skilled in the art can understand that in addition to the operation core of the matrix multiplication based on the combination of similar items, the above chip can also include other necessary components that are not described, and the specific understanding can be made by referring to the existing structural components of the existing chips in the field.

[0089] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0090] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A kernel based on matrix multiplication by combining like terms, It is characterized in that A plurality of rows of computing units are included; each row of computing units includes a data mapping unit, a multi-mode accumulator and a plurality of PEs; Each of the PEs is used to calculate the cumulative coefficient product of each similar term according to the input data to obtain each PE result; each of the PEs includes a plurality of 2-bit multipliers; The data mapping unit is used to adjust the order of the PE results to obtain the rearranged PE results; The multi-mode accumulator is used to accumulate according to each of the rearranged PE results, the offset of the input data and the precision mode to obtain a preliminary multiplication result.

2. The operation kernel of matrix multiplication based on merging like terms according to claim 1, It is characterized in that The multiplication of the operation kernel is based on the following calculation principle: in, a and b are row vectors and column vectors respectively, and the vector length is K, α i and β j Represents a 2-bit slice (term) of the original data, defined as the coefficient, V i+j The offset of the 2-bit slice representing the original data is defined as a variable, P a and P b denote the parallelism of scalars a and b respectively, and define P a =4 / m and P b =4 / n, m and n represent the number of items of decomposed scalars a and b, and the decomposition granularity is 2 bits respectively.

3. The operation kernel of matrix multiplication based on merging like terms according to claim 2, It is characterized in that The operation core integrates the preliminary multiplication results obtained according to the rows of the computing units to obtain the final result of matrix multiplication: Among them, Y = AB, and the sizes of each matrix are: Y[W,Z], A[W,K] and B[K,Z].

4. The operation kernel of matrix multiplication based on merging like terms according to any one of claims 1 to 3, It is characterized in that The multi-mode accumulator includes a plurality of shifters, a plurality of adders and a register; Each of the shifters is used to shift each of the rearranged PE results according to the precision mode; Each of the adders and the registers is used to form a multi-mode accumulator based on an addition tree, which is used to accumulate and obtain the preliminary multiplication result.

5. The operation core of matrix multiplication based on merging like terms according to claim 4, It is characterized in that It comprises 16 rows of computing units; each row of computing units comprises 16 PEs; each PE comprises 16 2-bit multipliers.

6. A chip, It is characterized in that A computing core comprising a matrix multiplication based on merging like items, the computing core comprising: a plurality of computing unit rows; each computing unit row comprises a data mapping unit, a multi-mode accumulator and a plurality of PEs; Each of the PEs is used to calculate the cumulative coefficient product of each similar term according to the input data to obtain each PE result; each of the PEs includes a plurality of 2-bit multipliers; The data mapping unit is used to adjust the order of the PE results to obtain the rearranged PE results; The multi-mode accumulator is used to accumulate according to each of the rearranged PE results, the offset of the input data and the precision mode to obtain a preliminary multiplication result.

7. The chip according to claim 6, It is characterized in that The multiplication of the operation kernel is based on the following calculation principle: in, a and b are row vectors and column vectors respectively, and the vector length is K, α i and β j Represents a 2-bit slice (term) of the original data, defined as the coefficient, V i+j The offset of the 2-bit slice representing the original data is defined as a variable, P a and P b denote the parallelism of scalars a and b respectively, and define P a =4 / m and P b =4 / n, m and n represent the number of items of decomposed scalars a and b, and the decomposition granularity is 2 bits respectively.

8. The chip according to claim 7, It is characterized in that The operation core integrates the preliminary multiplication results obtained according to the rows of the computing units to obtain the final result of matrix multiplication: Among them, Y = AB, and the sizes of each matrix are: Y[W,Z], A[W,K] and B[K,Z].

9. The chip according to any one of claims 6 to 8, It is characterized in that The multi-mode accumulator includes a plurality of shifters, a plurality of adders and a register; Each of the shifters is used to shift each of the rearranged PE results according to the precision mode; Each of the adders and the registers is used to form a multi-mode accumulator based on an addition tree, which is used to accumulate and obtain the preliminary multiplication result.

10. The chip according to claim 9, It is characterized in that The operation core includes 16 rows of the computing units; each row of the computing units includes 16 PEs; each PE includes 16 2-bit multipliers.