Data processing method and systolic array

By designing multi-channel computing units and selectors in the systolic array, the data transmission direction can be flexibly controlled, which solves the problem of low utilization of the computing units in the systolic array and achieves more efficient data processing.

CN118747259APending Publication Date: 2024-10-08SMARTER SILICON (SHANGHAI) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410742126.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-07
Publication Date
2024-10-08

AI Technical Summary

Technical Problem

When using a systolic array to perform data correlation operations, some of the computing units are wasted because they do not need to perform correlation operations, resulting in reduced utilization of the computing units.

Method used

A pulsating array is designed, in which the computing unit has multiple channels and can flexibly select the transmission direction according to data processing requirements. By controlling the selector, the computing unit transmits data in different directions to avoid unnecessary data processing.

Benefits of technology

It improves the utilization of computing units, meets data processing needs in different scenarios, and avoids unnecessary processing results and waste of resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118747259A_ABST
    Figure CN118747259A_ABST
Patent Text Reader

Abstract

The invention discloses a data processing method and a systolic array. The systolic array comprises a plurality of arithmetic units arranged in the first transmission direction and the second transmission direction of data. Each arithmetic unit comprises a first channel, a second channel and a third channel; the first channel of the arithmetic unit is used for connecting other adjacent arithmetic units in the first transmission direction; the second channel of the operation unit is used for connecting other adjacent operation units in the second transmission direction; the third channel of the arithmetic unit is used for connecting other adjacent arithmetic units in the target transmission direction, and the target transmission direction is parallel to the diagonal line of the systolic array; the operation unit is used for obtaining and transmitting first data from the first channel and obtaining and transmitting second data from the second channel or the third channel; and the arithmetic unit is used for processing the obtained first data and second data to obtain a processing result, and transmitting the received first data and second data to a next arithmetic unit along a corresponding channel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a data processing method and a systolic array. Background Art

[0002] When using a large model to process data, it is often necessary to perform correlation operations on two input data sets (usually represented by matrices or vectors). In order to improve computational efficiency, correlation operations are generally performed through a systolic array.

[0003] A systolic array may include a plurality of computing units arranged in two directions (generally row direction and column direction) and connected to each other. When using the systolic array for correlation calculation, two data sets for correlation calculation may be transmitted to each computing unit of the systolic array in the row direction and the column direction respectively, and each computing unit may obtain one data in each of the two data sets, and process the obtained data to obtain the correlation calculation result.

[0004] In different scenarios, the requirements for correlation calculation of data sets may be different. For example, in some scenarios, the data of the first data set needs to be correlated with each data included in the second data set, while in other scenarios, for any data of the first data set, the data only needs to be correlated with a part of the data of the second data set.

[0005] In the latter scenario, data is transmitted to each computing unit in the systolic array along the row direction and the column direction respectively, which will cause another part of the data that does not need to be subjected to correlation calculation to be processed by the computing unit, thereby reducing the utilization rate of the computing units in the systolic array. Summary of the invention

[0006] To this end, this application discloses the following technical solutions:

[0007] A first aspect of the present application provides a systolic array, comprising a plurality of computing units arranged along a first transmission direction and a second transmission direction of data, respectively;

[0008] Each of the computing units comprises a first channel, a second channel and a third channel;

[0009] The first channel of the computing unit is used to connect other adjacent computing units in the first transmission direction;

[0010] The second channel of the computing unit is used to connect other adjacent computing units in the second transmission direction;

[0011] The third channel of the computing unit is used to connect other adjacent computing units in a target transmission direction, and the target transmission direction is parallel to the diagonal of the systolic array;

[0012] The computing unit is used to obtain and transmit first data from the first channel, and obtain and transmit second data from the second channel or the third channel;

[0013] The operation unit is used to process the obtained first data and the second data to obtain a processing result, and transmit the received first data and the second data to the next operation unit along the corresponding channel.

[0014] Optionally, each of the operation units further includes a first selector, and the first selector is used to control the operation unit to obtain the second data from the second channel or the third channel.

[0015] Optionally, each of the operation units further includes a second selector, and the second selector is used to control the operation unit to transmit the second data from the second channel or the third channel.

[0016] Optionally, each of the computing units further includes a fourth channel;

[0017] The fourth channel of the computing unit is used to connect other adjacent computing units in the first transmission direction;

[0018] The operation unit is used to transmit the processing result to the previous operation unit along the fourth channel.

[0019] A second aspect of the present application provides a data processing method, comprising:

[0020] Obtain a first data set and a second data set, wherein the first data set includes a plurality of first data, and the second data set includes a plurality of second data;

[0021] According to the first data set and the second data set, the systolic array is controlled to be in a first mode or a second mode; wherein, when in the first mode, every two adjacent computing units in the second transmission direction of the systolic array are interconnected; when in the second mode, every two adjacent computing units in the target transmission direction of the systolic array are interconnected, the target transmission direction is parallel to the diagonal of the systolic array, the first data is used to perform a calculation with the corresponding second data to obtain a processing result; the first transmission directions remain interconnected;

[0022] When the systolic array is in the first mode, transmitting each of the first data to the corresponding computing unit along a first transmission direction of the systolic array, and transmitting each of the second data to the corresponding computing unit along a second transmission direction of the systolic array to obtain a processing result;

[0023] When the systolic array is in the second mode, each of the first data is transmitted to the corresponding computing unit along the first transmission direction of the systolic array, and each of the second data is transmitted to the corresponding computing unit along the target transmission direction of the systolic array to obtain a processing result.

[0024] Optionally, also include:

[0025] The processing results of each of the operation units are obtained along a first transmission direction of the systolic array.

[0026] Optionally, when the systolic array is in the second mode, transmitting each of the first data to the corresponding computing unit along a first transmission direction of the systolic array, and transmitting each of the second data to the corresponding computing unit along a target transmission direction of the systolic array, includes:

[0027] Determine the first data and the second data corresponding to each computing unit in the systolic array;

[0028] For a first operation unit of the systolic array, the first data and the second data corresponding to the first operation unit are simultaneously input into the first operation unit, so that the first data is transmitted from the first operation unit along the first transmission direction, and the second data is transmitted from the first operation unit along the target transmission direction; the first operation unit includes a first operation unit in the first transmission direction, and each of the first operation units simultaneously obtains the corresponding first data;

[0029] For the second computing units of the systolic array, determine an input time corresponding to each of the second computing units, and sequentially input the corresponding second data to each of the second computing units according to the corresponding input time, so that the second data is transmitted from the second computing unit along the target transmission direction;

[0030] Among them, the input time of each of the second operation units is delayed by one transmission cycle compared to the input time of the previous second operation unit in the first transmission direction, and the transmission cycle represents the time taken by one operation unit to transmit data to the next operation unit, and the second operation units include the first operation unit in the second transmission direction.

[0031] Optionally, the determining the first data and the second data corresponding to each computing unit in the systolic array includes:

[0032] sequentially determine each of the first data corresponds to each of the computing units in the first transmission direction of the systolic array;

[0033] determining the number of operations for each of the second data, where the number of operations represents the number of times the second data is processed to obtain a processing result;

[0034] The operation unit arranged along the target transmission direction corresponding to each second data is determined according to the number of operations.

[0035] Optionally, when the systolic array is in the first mode, transmitting each of the first data to the corresponding computing unit along a first transmission direction of the systolic array, and transmitting each of the second data to the corresponding computing unit along a second transmission direction of the systolic array, comprises:

[0036] Determine the first data and the second data corresponding to each computing unit in the systolic array;

[0037] determining an input time of each of the first computing units and an input time of each of the second computing units in the systolic array;

[0038] The input time of each of the first operation units is delayed by one transmission cycle compared with the input time of the previous first operation unit in the second transmission direction, and the input time of each of the second operation units is delayed by one transmission cycle compared with the input time of the previous second operation unit in the first transmission direction, and the transmission cycle represents the time taken by one of the operation units to transmit data to the next operation unit, and the first operation unit includes the first operation unit in the first transmission direction, and the second operation unit includes the first operation unit in the second transmission direction;

[0039] The corresponding first data is input into each of the first operation units in sequence according to the corresponding input time, and the corresponding second data is input into each of the second operation units in sequence, so that the first data is transmitted from the first operation unit along the first transmission direction, and the second data is transmitted from the second operation unit along the second transmission direction.

[0040] Optionally, the first data is used to perform related processing with the second data;

[0041] The controlling the systolic array to be in the first mode or the second mode according to the first data set and the second data set comprises:

[0042] In the case where any of the first data and all the second data included in the second data set are relatedly processed, controlling the selector of the operation unit of the systolic array to open the second path of the operation unit, so that the systolic array is in the first mode, wherein the second path is used to connect every two adjacent operation units in the systolic array in the second transmission direction;

[0043] In the case where a portion of the second data adjacent to a corresponding position of the first data in any one of the first data and the second data set is subjected to related processing, a selector of a computing unit of the systolic array is controlled to open a third path of the computing unit, so that the systolic array is in the second mode, wherein the second path is used to connect every two computing units in the systolic array that are adjacent in a target transmission direction. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0045] Figure 1 is a schematic diagram of the structure of a systolic array provided in an embodiment of the present application;

[0046] Figure 2 is a schematic diagram of the structure of a computing unit provided in an embodiment of the present application;

[0047] Figure 3 is a schematic diagram of the structure of another systolic array provided in an embodiment of the present application;

[0048] Figure 4 is a schematic diagram of a different correlation calculation method provided in an embodiment of the present application;

[0049] Figure 5 is a flow chart of a data processing method provided in an embodiment of the present application;

[0050] Figure 6 is a schematic diagram of data transmission of a systolic array in a first mode provided by an embodiment of the present application;

[0051] Figure 7 is a schematic diagram of data transmission of a systolic array in a second mode provided in an embodiment of the present application;

[0052] Figure 8 This is another schematic diagram of data transmission of a systolic array in a second mode provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0054] The present application embodiment provides a systolic array, see Figure 1 , the systolic array may include a plurality of operation units arranged along a first transmission direction and a second transmission direction of data respectively;

[0055] Each computing unit includes a first channel, a second channel and a third channel;

[0056] The first channel of the computing unit is used to connect other adjacent computing units in the first transmission direction;

[0057] The second channel of the computing unit is used to connect other adjacent computing units in the second transmission direction;

[0058] The third channel of the computing unit is used to connect other adjacent computing units in the target transmission direction, and the target transmission direction is parallel to the diagonal of the systolic array;

[0059] The computing unit is used to obtain and transmit the first data from the first channel, and obtain and transmit the second data from the second channel or the third channel;

[0060] The operation unit is used to process the obtained first data and second data to obtain a processing result, and transmit the received first data and second data to the next operation unit along the corresponding channel.

[0061] The systolic array provided in this embodiment can be a part of any processor in an electronic device that processes data using a neural network model.

[0062] Exemplarily, if the neural network model is deployed on a server device, the systolic array may be part of a processor of the server device;

[0063] If the neural network model is deployed on a smartphone, the systolic array can be part of the processor of the smartphone;

[0064] If the neural network model is deployed on a laptop, the above-mentioned systolic array can be part of the processor of the laptop.

[0065] The above-mentioned processor can be any processor installed on an electronic device. For example, it can be a central processing unit (CPU) of an electronic device, a graphics processing unit (GPU) of an electronic device, or a neural network processor (NPU) of an electronic device.

[0066] like Figure 1 As shown, the first transmission direction may be a horizontal direction, ie, a row direction of the systolic array, and the second transmission direction may be a vertical direction, ie, a column direction of the systolic array.

[0067] The number of computing units contained in the systolic array can be set as needed, not limited to Figure 1 Quantity shown.

[0068] The first row in the systolic array (i.e. Figure 1 The top row) and the first column (i.e. Figure 1 The computing units in the leftmost column (in the figure) can be connected to a host computer (such as a computer) through their own first channel, second channel and third channel, so that the host computer can provide the data of the first data set and the second data set to be processed to these computing units, and then transmit them from these computing units to each computing unit of the systolic array one by one according to the corresponding transmission direction.

[0069] When the first data set and the second data set are processed by the systolic array, each first data included in the first data set can be input from the first channel of the computing unit, and transmitted one by one to each computing unit of the systolic array along the first channel. Each second data included in the second data set can be input from the second channel or the third channel of the computing unit, and when input from the second channel, the second data is transmitted to each computing unit of the systolic array along the second channel of each computing unit, and when input from the third channel, the second data is transmitted to each computing unit of the systolic array along the third channel of each computing unit.

[0070] by Figure 1 For example, assume that the first data set is q (q1, q2, q3, q4, q5), where q1 to q5 are the 5 first data of the first data set, and the second data set is k (k1, k2, k3, k4, k5), where k1 to k5 are the 5 second data of the second data set.

[0071] use Figure 1When the systolic array shown processes the first data set and the second data set, the first data set can be input in a manner of, on the one hand, inputting q1 into the first channel of the first computing unit on the left side of the first row, inputting q2 into the first channel of the first computing unit on the left side of the second row, and so on, inputting q3, q4, and q5 into the first channels of the first computing units on the left side of the third row, the fourth row, and the fifth row, respectively, thereby q1 to q5 are transmitted one by one along the first channel to each computing unit of the corresponding row.

[0072] When the amount of first data included in the first data set is greater than the number of rows of the systolic array, the first data of the first data set may be input in batches. Figure 1 For example, assuming that the first data set includes 10 first data, the first 5 first data can be input in the above manner, and after the processing is completed, the last 5 first data can be input in the above manner.

[0073] The second data set can be inputted by inputting k1 into the second channel of the first computing unit above the first column, inputting k2 into the second channel of the first computing unit above the second column, and so on, inputting k3, k4 and k5 into the second channels of the first computing units above the third column, the fourth column and the fifth column respectively, thereby k1 to k5 are respectively transmitted to each computing unit of the corresponding column along the second channel one by one.

[0074] The second data set can also be input by inputting k1 into the third channel of the first computing unit above the first column, inputting k2 into the third channel of the first computing unit above the second column, and so on, inputting k3, k4 and k5 into the third channels of the first computing units above the third column, fourth column and fifth column respectively, thereby k1 to k5 are transmitted one by one to each computing unit of the corresponding column along the third channel.

[0075] After each operation unit obtains a second data from the third channel, the second data can be transmitted to the next operation unit in the target transmission direction along the third channel. For example, after the operation unit in the first row and the first column obtains the second data k1 from the third channel, k1 can be transmitted to the operation unit in the second row and the second column along the third channel. Similarly, the operation unit in the second row and the second column can transmit k1 to the operation unit in the third row and the third column along the third channel; after the operation unit in the first row and the second column obtains the second data k2 from the third channel, k2 can be transmitted to the operation unit in the second row and the third column along the third channel. Similarly, the operation unit in the second row and the third column can transmit k2 to the operation unit in the third row and the fourth column along the third channel.

[0076] When inputting the second data from the second channel, if the amount of the second data contained in the second data set is greater than the number of columns of the systolic array, the second data of the second data set may be input in batches. Figure 1For example, assuming that the second data set includes 10 second data, the first 5 second data can be input in the above manner, and after the processing is completed, the last 5 second data can be input in the above manner.

[0077] When inputting the second data from the third channel, if the amount of the second data contained in the second data set is greater than the amount of the first computing units in the target transmission direction, the second data of the second data set may also be input in batches. Figure 1 For example, assuming that the second data set contains 18 second data, the first operation unit in the target transmission direction includes the first operation unit in each column and the first operation unit in each row in the pulsating array, that is, the third channels of a total of 9 operation units can input the second data, then the first 9 second data can be input to the 9 operation units first, and after the processing is completed, the last 9 second data can be input in the above manner.

[0078] The way in which the operation unit processes the first data and the second data can be determined according to the algorithm for processing the first data set and the second data set, and is not limited. As an example, when it is necessary to calculate the product of each data in the first data set and each data in the second data set, the way in which the operation unit processes the first data and the second data can be to multiply the first data and the second data and use the product obtained as the processing result.

[0079] See also Figure 2 , is the structure of the operation unit in the systolic array of this embodiment. In this embodiment, each operation unit may include a first selector, the input end of the first selector includes the second channel and the third channel, the output end of the first selector and the register and other operators (such as Figure 2 The first selector is used to control the operation unit to obtain the second data from the second channel or the third channel.

[0080] Before the systolic array of the present embodiment is used to process the first data set and the second data set, the host computer (such as a computer) that provides the first data set and the second data set can send a control instruction to each first selector in the systolic array, thereby controlling the first selector to turn on the second channel and turn off the third channel, or controlling the first selector to turn on the third channel and turn off the second channel, so as to control the operation unit to obtain the second data from the second transmission direction or the target transmission direction.

[0081] Further optionally, each operation unit may also include a second selector, the input end of the second selector is connected to the output end of the first selector, the output end of the second selector includes a second channel and a third channel, and the second selector is used to control the operation unit to transmit the second data from the second channel or the third channel.

[0082] Similar to the first selector, the second selector can, under the control of the host computer, turn on the second channel and turn off the third channel, or control the second selector to turn on the third channel and turn off the second channel, thereby controlling each operation unit to transmit the obtained second data to the next operation unit in the second transmission direction, or to the next operation unit in the target transmission direction, thereby ensuring that each second data of the input systolic array is transmitted in the second transmission direction or in the target transmission direction.

[0083] In some optional embodiments, see Figure 2 and Figure 3 , each computing unit of the systolic array may also include a fourth channel;

[0084] The fourth channel of the computing unit is used to connect other adjacent computing units in the first transmission direction;

[0085] The operation unit is used to transmit the processing result to the previous operation unit along the fourth channel.

[0086] by Figure 3 The operation units in the first row are examples. Starting from the left, the first operation unit can feed back the processing result to the host computer outside the systolic array along the fourth channel after obtaining the processing result. After the second operation unit obtains the processing result, it feeds back the processing result to the first operation unit along the fourth channel, and the processing result is transmitted to the host computer through the first operation unit. After the third, fourth and fifth operation units obtain their respective processing results, they are also transmitted one by one along the fourth channel to the previous operation unit in the first transmission direction until they are transmitted to the host computer.

[0087] The beneficial effects of this embodiment are:

[0088] First see Figure 4 , is a schematic diagram of various correlation calculation methods. Figure 4 In (1), each first data of the first data set is subjected to correlation operation with each second data of the second data set. Figure 4 In (2) and (3), each first data only needs to be correlated with a portion of the second data adjacent to itself. For example, q2 can be correlated with k1, k2, and k3, and q3 can be correlated with k2, k3, and k4. Figure 4 In (4), a portion of the first data needs to be correlated with each second data, and another portion of the first data only needs to be correlated with an adjacent portion of the second data.

[0089] In the systolic array of the related art, each operation unit only has a first channel in the first transmission direction and a second channel in the second transmission direction. Therefore, when using the systolic array to process data, each second data needs to be input from the second channel and transmitted to each operation unit along the second transmission direction.

[0090] In accordance with Figure 4 When performing correlation calculation in any of the scenarios (2) to (4), the transmission of the second data along the second transmission direction will cause some computing units to use the second data that has no correlation calculation requirement to perform correlation calculation, thereby wasting the processing capacity of these computing units.

[0091] For example, in Figure 4 In the correlation operation scenario shown in (2), it may only be necessary to obtain the processing result of the correlation operation between q3 and k2, k3, and k4. However, when each second data is transmitted in the second transmission direction, the second data k1 will inevitably be transmitted to a certain operation unit in the third row of operation units corresponding to q3. For example, if k1 is input from the first operation unit in the first column, it will be transmitted to the first operation unit in the third row along the second transmission direction. If k1 is input from the first operation unit in the fourth column, it will be transmitted to the fourth operation unit in the third row along the second transmission direction. The operation unit in the third row that obtains k1 and q3 will perform a correlation operation on q3 based on k1, and the obtained processing result will be discarded as an unnecessary processing result, and the processing capacity of the operation unit in the third row that obtains k1 and q3 will be wasted.

[0092] In the systolic array of this embodiment, according to the requirements of the correlation operation, the systolic array can control the second channel to be turned on or the third channel to be turned on, so that the second data can be transmitted along the second transmission direction or along the target transmission direction. Figure 4 In any of the correlation operation scenarios shown in (2) to (4), it is only necessary to input the second data from the third channel of the appropriate operation unit, so as to avoid data that does not need to be subjected to correlation operation being transmitted to the operation unit, and avoid the operation unit providing unnecessary processing results, thereby solving the problem of wasting the processing power of the operation unit.

[0093] In combination with the above example, when only the processing result of the correlation operation between q3 and k2, k3, and k4 needs to be obtained, the second data k1 can be input from the third channel of the first operation unit in the fourth column. Figure 1It can be seen that in this case, the second data k1 is only transmitted to the 4th operation unit in the 1st row and the 5th operation unit in the 2nd row along the target transmission direction, and the operation units in the 3rd row for processing the first data q3 will not obtain k1, which avoids the situation where the operation unit obtains k1 and q3 and then outputs the processing result of the correlation operation on q3 based on k1, thereby solving the problem of wasting the processing capacity of the operation unit.

[0094] This application embodiment provides a data processing method, see Figure 5 , the method may include the following steps.

[0095] S501, obtaining a first data set and a second data set, wherein the first data set includes a plurality of first data, and the second data set includes a plurality of second data.

[0096] S502: Control the systolic array to be in a first mode or a second mode according to the first data set and the second data set.

[0097] The structure of the above systolic array can be found in Figure 1 or Figure 3 .

[0098] Among them, when in the first mode, every two adjacent operation units in the second transmission direction of the systolic array are interconnected; when in the second mode, every two adjacent operation units in the target transmission direction of the systolic array are interconnected, the target transmission direction is parallel to the diagonal of the systolic array, and the first data is used to perform operations with the corresponding second data to obtain a processing result; the first transmission direction remains interconnected.

[0099] S503, when the systolic array is in the first mode, transmitting each first data to the corresponding operation unit along the first transmission direction of the systolic array, and transmitting each second data to the corresponding operation unit along the second transmission direction of the systolic array to obtain a processing result.

[0100] S504, when the systolic array is in the second mode, each first data is transmitted to the corresponding operation unit along the first transmission direction of the systolic array, and each second data is transmitted to the corresponding operation unit along the target transmission direction of the systolic array to obtain a processing result.

[0101] The execution subject of the method of this embodiment may be a host computer connected to the systolic array and used to provide the first data set and the second data set.

[0102] The beneficial effects of this embodiment are:

[0103] According to the processing requirements of the first data set and the second data set, a suitable transmission direction in the pulsation array is selected to transmit the second data, which can not only meet the processing requirements in various scenarios, but also avoid the waste of processing power of the computing unit caused by transmitting the second data only along the second transmission direction under specific circumstances.

[0104] As some examples, the method of this embodiment can be applied to the operation process of the attention mechanism of a large model. The operation process of the attention mechanism can be expressed by the following formula (1).

[0105]

[0106] Among them, Attention(Q, K, V) represents the processing result of Q, K, V based on the attention mechanism. Q, K, and V represent three data sets respectively. Each data set can include multiple matrices. d represents the number of columns in the matrix of Q. Softmax represents the normalization operation. K T represents the transpose of the matrix in K.

[0107] When used to process the operation process of the attention mechanism, the above-mentioned first data set can be Q of formula (1), and the first data can be the elements contained in each matrix therein. The second data set can be K or V of formula (1), and the second data can be the elements contained in each matrix in K or V.

[0108] In some optional embodiments, the first data is used to perform correlation processing with the second data, that is, the second data is used to perform correlation operation on the first data.

[0109] In step S102, the systolic array is controlled to be in the first mode or the second mode, which can be determined according to the correlation calculation requirement between the first data set and the second data set;

[0110] In the case where any first data and all second data contained in the second data set are correlated (referred to as case one), the systolic array may be controlled to be in the first mode;

[0111] In the case where a portion of the second data adjacent to the corresponding position of the first data in any one of the first data and the second data set is subjected to correlation processing (referred to as case 2), the systolic array may be controlled to be in the second mode.

[0112] As an example, it is assumed that the first data set includes 20 first data, which are sequentially recorded as q1 to q20, and the second data set includes 20 second data, which are sequentially recorded as k1 to k20.

[0113] Case 1 is equivalent to performing a global attention operation on the first data set and the second data set (i.e., global attention). In combination with the above example, the way to process the first data set and the second data set according to case 1 can be:

[0114] For any integer i between 1 and 20 (including 1 and 20), in the process of correlation calculation, it is necessary to use each second data from k1 to k20 to perform correlation calculation on qi one by one, and obtain 20 processing results corresponding to qi;

[0115] Case 2 is equivalent to performing a local attention operation on the first data set and the second data set (i.e., local attention). Combined with the above example, the way to process the first data set and the second data set according to case 2 can be:

[0116] Assuming that each first data only needs to perform correlation calculation with the three second data in adjacent positions, then for any integer i between 1 and 20 (including 1 and 20), in the process of correlation calculation, it is only necessary to use ki-1, ki and ki+1 to perform correlation calculation on qi to obtain the three processing results corresponding to qi. If i-1 or i+1 exceeds the range of 1 to 20, it will be eliminated. Taking i equals 4 as an example, during the correlation calculation, it is only necessary to use k3, k4 and k5 to perform correlation calculation on q4 to obtain the three processing results corresponding to q4.

[0117] In some embodiments, the systolic array can be switched between a first mode and a second mode.

[0118] by Figure 4 (4) is an example. When performing a correlation operation on the first data set and the second data set, it may happen that part of the first data needs to be operated according to situation one, and another part of the first data needs to be operated according to situation two.

[0119] So in Figure 5 In the method shown, the first data set and the second data set can be first split into two parts, one part is the data that needs to be calculated according to situation one, and the other part is the data that needs to be calculated according to situation two. Then, the systolic array can be controlled to be in a first mode, and in the first mode, the first data calculated according to situation one and the corresponding second data are input into the systolic array to obtain corresponding processing results. Then, the systolic array is controlled to switch to a second mode, and in the second mode, the first data calculated according to situation two and the corresponding second data are input into the systolic array to obtain corresponding processing results.

[0120] The data processing method of this embodiment can also be applied to Figure 4 The correlation calculation scenario shown in (3).

[0121] exist Figure 4 In the scenario shown in (3), the second data used for correlation calculation is distributed at a certain distance D, and the distance D can be any integer greater than or equal to 1.

[0122] As an example, when the distance D is equal to 1, the second data for the correlation operation of the first data q1 may include k1, k3 and k5, and the second data for the correlation operation of the first data q2 may include k2, k4 and k6. That is, Figure 4 In the scenario shown in (3), the second data for which correlation operation is performed on the first data includes the second data located at a position corresponding to the first data in the second data set, and the second data whose interval with the corresponding position is an integer multiple of D.

[0123] For the above scenario, the multiple first data may be split into multiple parts as follows:

[0124] Divide the first data of the first data set into D+1 parts at interval D, wherein the 1st, 1+D+1th, 1+2*(D+1)th, ... 1+(i-1)*(D+1)th first data in the first data set are selected as the 1st part; the 2nd, 2+D+1th, 2+2*(D+1)th, ... 2+(i-1)*(D+1)th first data are selected as the 2nd part, and so on, until the D+1th, 2*(D+1)th, 3*(D+1)th, ... i*(D+1)th first data are selected as the D+1th part;

[0125] Then, for each portion of the first data, second data for performing correlation calculation on the portion of the first data is extracted from the second data set, and the portion of the first data and the extracted second data are re-arranged closely, so that the closely arranged first data and the closely arranged second data can be input into the systolic array for calculation in the manner of S504 to obtain the calculation result corresponding to the portion;

[0126] Finally, the calculation results of each part are combined to obtain the processing results of the first data and the second data in the scenario.

[0127] Combination Figure 4 In the example of (3), D may be equal to 1. In this case, the first, third, fifth, ..., first + 2*(i-1)th first data in the first data may be used as the first part, and the second, fourth, sixth, ..., second + 2*(i-1)th first data may be used as the second part. The first data of the first part and the second data used for correlation calculation are closely arranged and then calculated in the manner of S504 to obtain the corresponding processing result, that is, Figure 4In the shaded squares of the 1st, 3rd, 5th, ... 1+2*(i-1)th rows in (3), the first data of the second part and the second data for correlation calculation are closely arranged and then calculated in the manner of S504 to obtain the corresponding processing result, that is, Figure 4 The shaded squares in the 2nd, 4th, 6th, ... 2+2*(i-1)th rows in (3) can be combined to obtain the complete processing result, that is, Figure 4 All shaded squares in (3).

[0128] The method of controlling the systolic array to be in the first mode may be:

[0129] Controlling a selector of a computing unit of the systolic array to open a second path of the computing unit so that the systolic array is in a first mode, wherein the second path is used to connect every two adjacent computing units in the systolic array in a second transmission direction;

[0130] Combination Figure 2 In the structure of the operation unit shown, in the first mode, the first selector of the operation unit can open the second channel and close the third channel, and the second selector also opens the second channel and closes the third channel, so that every two adjacent operation units in the pulsating array in the second transmission direction remain connected, and the adjacent operation units in the target transmission direction are not connected.

[0131] The way to control the systolic array to be in the second mode may be:

[0132] Controlling the selector of the computing unit of the systolic array to open the third path of the computing unit, so that the systolic array is in the second mode, the second path is used to connect every two adjacent computing units in the systolic array in the target transmission direction;

[0133] Combination Figure 2 In the structure of the operation unit shown, in the second mode, the first selector of the operation unit can open the third channel and close the second channel, and the second selector also opens the third channel and closes the second channel, so that every two adjacent operation units in the pulsating array in the target transmission direction remain connected, and the adjacent operation units in the second transmission direction are not connected.

[0134] In some optional embodiments, if each computing unit in the systolic array has a fourth channel, then the processing result of each computing unit in the systolic array may be obtained by:

[0135] The processing results of each operation unit are obtained along the first transmission direction of the systolic array. These processing results can be obtained by the operation units transmitting forward one by one from their respective fourth channels.

[0136] In the case where the operation unit of the systolic array does not have the fourth channel, the processing results of each operation unit may be obtained by other methods, not limited to the above methods. For example, the processing results may be obtained along the second transmission direction of the systolic array.

[0137] Optionally, the method of transmitting the first data and the second data to each computing unit in the systolic array in the manner of step S503 may include:

[0138] Determine first data and second data corresponding to each computing unit in the systolic array;

[0139] determining an input time of each first computing unit and an input time of each second computing unit in the systolic array;

[0140] The input time of each first operation unit is delayed by one transmission cycle compared with the input time of the previous first operation unit in the second transmission direction, and the input time of each second operation unit is delayed by one transmission cycle compared with the input time of the previous second operation unit in the first transmission direction. The transmission cycle represents the time taken by one operation unit to transmit data to the next operation unit. The first operation unit includes the first operation unit in the first transmission direction, and the second operation unit includes the first operation unit in the second transmission direction.

[0141] The corresponding first data is input into each first operation unit in sequence according to the corresponding input time, and the corresponding second data is input into each second operation unit in sequence, so that the first data is transmitted from the first operation unit along the first transmission direction, and the second data is transmitted from the second operation unit along the second transmission direction.

[0142] In the first mode, each first data may be determined to correspond to a row of operation units of the systolic array according to the order of each first data in the first data set, and each second data may be determined to correspond to a column of operation units of the systolic array according to the order of each second data in the second data set. Figure 6 For example, assuming that correlation operations need to be performed on the first data q4 to q8 and the second data k2 to k6, it can be determined that q4 corresponds to the first row of operation units of the pulsating array, q5 corresponds to the second row of operation units, q6, q7, and q8 correspond to the third, fourth, and fifth rows of operation units respectively, and similarly, it can be determined that k2 to k6 correspond to the first to fifth columns of operation units respectively.

[0143] Then, assuming that the transmission cycle of an operation unit is 50 milliseconds (ms), the operation unit in the first row and the first column simultaneously obtains q4 and k2 at time T0, then the time when each operation unit obtains the corresponding first data or second data can be determined as follows:

[0144] The time when the first computing unit in the second column obtains the second data k3 is delayed by one transmission cycle compared with the first computing unit in the first column. Therefore, the time when the first computing unit in the second column obtains k3 is T0+50ms.

[0145] The time when the first computing unit in the third column obtains the second data k4 is delayed by one transmission cycle compared with the first computing unit in the second column. Therefore, the time when the first computing unit in the third column obtains k4 is T0+100ms.

[0146] The time of the first operation unit in the fourth column is delayed by one transmission cycle than the first operation unit in the third column, so the time to obtain the second data k5 is T0+150ms; the time of the first operation unit in the fifth column is delayed by one transmission cycle than the first operation unit in the fourth column, so the time to obtain the second data k5 is T0+200ms.

[0147] Similarly, the time when the first operation unit in the second row obtains the first data is delayed by one transmission cycle compared with the first operation unit in the first row, the time when the first operation unit in the third row obtains the first data is delayed by two transmission cycles compared with the first row, and the first operation units in the fourth row and the fifth row are delayed by three and four transmission cycles respectively compared with the first row. Therefore, the time when the first operation units in the second to fifth rows obtain the corresponding first data are T0+50ms, T0+100ms, T0+150ms, and T0+200ms respectively.

[0148] After determining the correspondence between data and operation units, as well as the aforementioned input time, each first data and each second data can be input into the first operation unit of each row and the first operation unit of each column in the systolic array at the corresponding input time, so that the first data and the second data are transmitted one by one to each operation unit along the first transmission direction and the second transmission direction respectively.

[0149] Optionally, the method of transmitting the first data and the second data to each computing unit in the systolic array in the manner of step S504 may include:

[0150] Determine first data and second data corresponding to each computing unit in the systolic array;

[0151] For a first operation unit of the systolic array, first data and second data corresponding to the first operation unit are simultaneously input into the first operation unit, so that the first data is transmitted from the first operation unit along a first transmission direction, and the second data is transmitted from the first operation unit along a target transmission direction; the first operation unit includes a first operation unit in the first transmission direction, and each first operation unit obtains the corresponding first data simultaneously;

[0152] For the second computing units of the systolic array, determining an input time corresponding to each second computing unit, and sequentially inputting corresponding second data to each second computing unit according to the corresponding input time, so that the second data is transmitted from the second computing unit along the target transmission direction;

[0153] Among them, the input time of each second operation unit is delayed by one transmission cycle compared with the input time of the previous second operation unit in the first transmission direction. The transmission cycle represents the time taken by one operation unit to transmit data to the next operation unit. The second operation unit includes the first operation unit in the second transmission direction.

[0154] Determining the input time in the above manner can ensure that each operation unit obtains the first data and the second data to be processed by the operation unit at the same time, thereby avoiding obtaining erroneous processing results due to different times when the operation unit obtains the first data and the second data.

[0155] In the second mode, the first data and the second data corresponding to each operation unit may be determined as follows:

[0156] Sequentially determine the computing unit in each first transmission direction of the systolic array corresponding to each first data;

[0157] Determine the number of operations for each second data, where the number of operations represents the number of times the second data is processed to obtain a processing result;

[0158] The operation unit arranged along the target transmission direction corresponding to each second data is determined according to the number of operations.

[0159] by Figure 7 For example, it can be determined that q4 to q8 correspond to the first to fifth rows of operation units of the systolic array in sequence.

[0160] Then, it can be determined which second data each first data needs to be correlated with, and further the number of operations for each second data can be determined.

[0161] Combination Figure 7 For example, assuming that each first data needs to be correlated with five second data adjacent to each other in the second data set, the second data used for performing correlation calculation on q4 to q8 can be represented by the following Table 1.

[0162] Table 1

[0163]

[0164] Based on Table 1 above, it can be determined that the number of operations on the second data k2 and k10 is 1, the number of operations on the second data k3 and k9 is 2, the number of operations on the second data k4 and k8 is 3, the number of operations on the second data k5 and k7 is 4, and the number of operations on the second data k6 is 5.

[0165] After determining the number of operations for each second data, the operation unit in the target transmission direction corresponding to each second data can be determined according to the following rules:

[0166] The number of operation units arranged along the target transmission direction corresponding to the second data is consistent with the number of operations of the second data.

[0167] Based on the above rules, if Figure 7 As shown, it can be determined that the second data k2 and k10 correspond to the first operation unit in the fifth column and the first operation unit in the fifth row respectively, k3 corresponds to the first operation unit in the fourth column and the next operation unit connected in the target transmission direction, k9 corresponds to the first operation unit in the fourth row and the next operation unit connected in the target transmission direction, k4 corresponds to the first operation unit in the third column and the next two operation units connected in the target transmission direction, k8 corresponds to the first operation unit in the third row and the next two operation units connected in the target transmission direction, k5 corresponds to the first operation unit in the second column and the next three operation units connected in the target transmission direction, k7 corresponds to the first operation unit in the second row and the next three operation units connected in the target transmission direction, and k6 corresponds to the first operation unit in the first column and the next four operation units connected in the target transmission direction.

[0168] It can be seen from the above correspondence that, in the second mode, when the first data and the second data are input into the phase pulsation array, the first bit and the last bit in a group of second data used for performing correlation operation on the first data are respectively input from the operation units at the upper right vertex and the lower left vertex of the pulsation array, and the second data input into the pulsation array are arranged counterclockwise from the operation unit at the upper right vertex to the operation unit at the lower left vertex in the order of increasing serial numbers.

[0169] Furthermore, the second data input from the diagonal line from the upper right corner to the lower left corner is exactly the second data with the least number of operations. Figure 7 The number of operations of the second data k2 and k10 input from the upper right vertex and the lower left vertex is only 1.

[0170] Determining the correspondence between the second data and the operation unit in the above manner can prevent an operation unit that does not need to obtain specific second data from obtaining the second data, for example, preventing an operation unit that does not need to obtain k2 from obtaining k2, thereby further avoiding wasting the processing capacity of the operation unit.

[0171] After determining the above correspondence, for the first computing unit of each row of the systolic array, the first data and the second data corresponding to the computing unit can be input at the same time, and the time for the first computing units of any two rows to input data is the same.

[0172] Still Figure 7 For example, when inputting data, the corresponding first data and second data can be simultaneously input to the first operation units in the first to fifth rows at time T0. In other words, q4 to q8 and k6 to k10 are simultaneously input to the corresponding operation units at time T0.

[0173] For the first operation unit in each column, the input time corresponding to the first operation unit in each column can be determined one by one based on the transmission cycle in the manner of determining the input time in the aforementioned first mode.

[0174] Combination Figure 7 In the example, the input time corresponding to the first operation unit in the first column is T0, the input time corresponding to the first operation unit in the second column is delayed by one transmission cycle than T0, for example, T0+50ms, and so on. The input times corresponding to the first operation units in the third, fourth and fifth columns are delayed by two, three and four transmission cycles respectively than T0, so the input times are T0+100ms, T0+150ms and T0+200ms respectively.

[0175] After the input time is determined, the second data is input from the third channel to the corresponding operation unit at the corresponding input time, so that each operation unit transmits the second data obtained by itself along the target transmission direction.

[0176] In some embodiments, when the correlation size is smaller than the size of the systolic array, if data is input to the systolic array in the second mode, the third channels of some computing units may have no input, that is, the second data may not be input to the third channels of these computing units.

[0177] The correlation size indicates how many second data are selected around the corresponding position of the first data for correlation calculation. For example, for the first data q4, if the correlation size is 5, then the five adjacent second data centered at the corresponding position k4 in the second data set, i.e., k2 to k6, are used for correlation calculation on q4. If the correlation size is 3, then the three adjacent second data centered at the corresponding position k4 in the second data set, i.e., k3 to k5, are used for correlation calculation on q4.

[0178] The size of the systolic array can be represented by the number of computing units arranged along the first transmission direction. Figure 7 The size of the systolic array shown can be 5, Figure 8 The size of the systolic array shown may be six.

[0179] by Figure 8 For example, assume the correlation size is 5, which is less than Figure 8 The size of the systolic array is , then when the correlation operation is performed on the first data q4 to q9 according to the second mode, these first data and second data can be calculated according to Figure 8 It can be seen that at this time, the third channel of the computing unit located at the top left corner of the systolic array has no input, that is, the second data is not input to the computing unit.

[0180] When the second data is not input to an operation unit, the operation unit can directly transmit the first data obtained by itself to the next operation unit without performing any operation itself.

[0181] Among them, the data from the first operation unit of each row is still input to the corresponding operation unit at the same time (recorded as time T0). Starting from the second column, the time when the first operation unit of each column obtains the corresponding second data is delayed by one transmission cycle compared to the time when the first operation unit of the previous column obtains the data. Assuming that the transmission cycle is 50ms, k6 is input to the first operation unit of the second column at T0+50ms, k5 is input to the first operation unit of the third column at T0+100ms, and so on. It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other.

[0182] For the convenience of description, the above system or device is described by dividing it into various modules or units according to its functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0183] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the relevant technology in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.

[0184] Finally, it should be noted that, in this article, relational terms such as first, second, third and fourth are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0185] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A systolic array, comprising a plurality of computing units arranged along a first transmission direction and a second transmission direction of data respectively; Each of the computing units comprises a first channel, a second channel and a third channel; The first channel of the computing unit is used to connect other adjacent computing units in the first transmission direction; The second channel of the computing unit is used to connect other adjacent computing units in the second transmission direction; The third channel of the computing unit is used to connect other adjacent computing units in a target transmission direction, and the target transmission direction is parallel to the diagonal of the systolic array; The computing unit is used to obtain and transmit first data from the first channel, and obtain and transmit second data from the second channel or the third channel, wherein: When the second data is transmitted from the third channel, the second data is input into the systolic array from the first computing unit in the first transmission direction and the first computing unit in the second transmission direction; The operation unit is used to process the obtained first data and the second data to obtain a processing result, and transmit the received first data and the second data to the next operation unit along the corresponding channel.

2. The systolic array according to claim 1, each of the operation units further comprising a first selector, wherein the first selector is used to control the operation unit to obtain the second data from the second channel or the third channel. 3 . The systolic array according to claim 1 , wherein each of the operation units further comprises a second selector, and the second selector is used to control the operation unit to transmit the second data from the second channel or the third channel.

4. The systolic array of claim 1, wherein each of the computing units further comprises a fourth channel; The fourth channel of the computing unit is used to connect other adjacent computing units in the first transmission direction; The operation unit is used to transmit the processing result to the previous operation unit along the fourth channel.

5. A data processing method, comprising: Obtain a first data set and a second data set, wherein the first data set includes a plurality of first data, and the second data set includes a plurality of second data; According to the first data set and the second data set, the systolic array is controlled to be in a first mode or a second mode; wherein, when in the first mode, every two adjacent computing units in the second transmission direction of the systolic array are interconnected; when in the second mode, every two adjacent computing units in the target transmission direction of the systolic array are interconnected, the target transmission direction is parallel to the diagonal of the systolic array, the first data is used to perform a calculation with the corresponding second data to obtain a processing result; the first transmission directions remain interconnected; When the systolic array is in the first mode, transmitting each of the first data to the corresponding computing unit along a first transmission direction of the systolic array, and transmitting each of the second data to the corresponding computing unit along a second transmission direction of the systolic array to obtain a processing result; When the systolic array is in the second mode, each of the first data is transmitted to the corresponding computing unit along a first transmission direction of the systolic array, and each of the second data is transmitted to the corresponding computing unit along a target transmission direction of the systolic array to obtain a processing result; Wherein, when the systolic array is in the second mode, each first operation unit of the systolic array obtains the first data and the second data at the same time, and the first operation unit includes the first operation unit in the first transmission direction.

6. The method according to claim 5, further comprising: The processing results of each of the operation units are obtained along a first transmission direction of the systolic array.

7. The method according to claim 5, wherein when the systolic array is in the second mode, transmitting each of the first data to the corresponding computing unit along a first transmission direction of the systolic array, and transmitting each of the second data to the corresponding computing unit along a target transmission direction of the systolic array, comprises: Determine the first data and the second data corresponding to each computing unit in the systolic array; For the first operation unit of the systolic array, the first data and the second data corresponding to the first operation unit are simultaneously input into the first operation unit, so that the first data is transmitted from the first operation unit along the first transmission direction, and the second data is transmitted from the first operation unit along the target transmission direction; For the second computing units of the systolic array, determine an input time corresponding to each of the second computing units, and sequentially input the corresponding second data to each of the second computing units according to the corresponding input time, so that the second data is transmitted from the second computing unit along the target transmission direction; Among them, the input time of each of the second operation units is delayed by one transmission cycle compared to the input time of the previous second operation unit in the first transmission direction, and the transmission cycle represents the time taken by one operation unit to transmit data to the next operation unit, and the second operation units include the first operation unit in the second transmission direction.

8. The method according to claim 7, wherein determining the first data and the second data corresponding to each computing unit in the systolic array comprises: sequentially determine each of the first data corresponds to each of the computing units in the first transmission direction of the systolic array; determining the number of operations for each of the second data, where the number of operations represents the number of times the second data is processed to obtain a processing result; The operation unit arranged along the target transmission direction corresponding to each second data is determined according to the number of operations.

9. The method according to claim 5, wherein when the systolic array is in the first mode, transmitting each of the first data to the corresponding computing unit along a first transmission direction of the systolic array, and transmitting each of the second data to the corresponding computing unit along a second transmission direction of the systolic array, comprises: Determine the first data and the second data corresponding to each computing unit in the systolic array; determining an input time of each of the first computing units and an input time of each of the second computing units in the systolic array; The input time of each of the first operation units is delayed by one transmission cycle compared with the input time of the previous first operation unit in the second transmission direction, and the input time of each of the second operation units is delayed by one transmission cycle compared with the input time of the previous second operation unit in the first transmission direction, and the transmission cycle represents the time taken by one of the operation units to transmit data to the next operation unit, and the first operation unit includes the first operation unit in the first transmission direction, and the second operation unit includes the first operation unit in the second transmission direction; The corresponding first data is input into each of the first operation units in sequence according to the corresponding input time, and the corresponding second data is input into each of the second operation units in sequence, so that the first data is transmitted from the first operation unit along the first transmission direction, and the second data is transmitted from the second operation unit along the second transmission direction.

10. The method according to claim 5, wherein the first data is used for correlation processing with the second data; The controlling the systolic array to be in the first mode or the second mode according to the first data set and the second data set comprises: In the case where any of the first data and all the second data included in the second data set are relatedly processed, controlling the selector of the operation unit of the systolic array to open the second path of the operation unit, so that the systolic array is in the first mode, wherein the second path is used to connect every two adjacent operation units in the systolic array in the second transmission direction; In the case where a portion of the second data adjacent to a corresponding position of the first data in any one of the first data and the second data set is subjected to related processing, a selector of a computing unit of the systolic array is controlled to open a third path of the computing unit, so that the systolic array is in the second mode, wherein the second path is used to connect every two computing units in the systolic array that are adjacent in a target transmission direction.