Data processing method, device, equipment, medium and system
Through parallel transmission and multiplexing technology, the problems of data bandwidth consumption and low computing efficiency in large matrix multiplication operations are solved, and efficient matrix operation and data transmission are realized.
Patent Information
- Application Number
- CN202411789238.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-12-06
AI Technical Summary
When performing large matrix multiplication operations, due to the limitations of the computing power and data transmission capabilities of the equipment, it is necessary to split into sub-matrixes for calculation, resulting in data bandwidth resource consumption and low computing efficiency.
The data is transmitted in parallel. By reading the submatrix in the matrix in rows or columns, and multiplying them and multiplying them, multiplexing the read submatrix to save bandwidth and ensuring the continuity of matrix operations.
It effectively improves the efficiency of matrix computing, reduces data bandwidth consumption, avoids interruptions in the computing process, and meets the needs of efficient data transmission and processing.
Smart Images

Figure CN119669627A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and in particular, relates to a data processing method, device, equipment, medium and system. Background Art
[0002] In the field of image processing, images are generally represented as matrix data for processing. However, due to the limitations of the computing power and data transmission capabilities of the equipment, two large matrices cannot be multiplied at one time. Generally, the two large matrices are split into multiple sub-matrices and then multiplied. During the operation, it is necessary to continuously transfer the two input sub-matrices from the cache device to the operation device, and the output sub-matrix obtained after the operation is transferred from the operation device to the cache device. In the prior art, the data bandwidth is set to the size of three sub-matrices transmitted simultaneously, but this will cause the consumption of data bandwidth resources. In order to reduce the consumption of data bandwidth, data can also be transmitted by time-sharing serial transmission, but this method will cause the process of matrix operation to be interrupted, resulting in low operation efficiency. Summary of the invention
[0003] The purpose of the present application is to provide a data processing method, apparatus, device, medium and system; the data processing method, apparatus, device, medium and system provided by the present application can use parallel transmission to transmit data under the premise of setting the data transmission bandwidth to the width of two sub-matrices transmitted simultaneously, without causing the process of matrix operation to be interrupted, thereby effectively improving the operation efficiency.
[0004] The technical solutions provided by this application are as follows: A data processing method, wherein the data includes a first matrix and a second matrix, and the first matrix and the second matrix can be multiplied, and the method includes: Read all first sub-matrices of any row in the first matrix in a row direction, and read all second sub-matrices of any column in the second matrix in a column direction; Performing multiplication and addition operations on all the first sub-matrices and all the corresponding second sub-matrices to obtain a third sub-matrix; Output the third sub-matrix, and simultaneously read all new first sub-matrices of other rows in the first matrix in a row direction, or read all new second sub-matrices of other columns in the second matrix in a column direction; Performing multiplication and addition operations on all the new first sub-matrices and all the corresponding second sub-matrices, or performing multiplication and addition operations on all the new second sub-matrices and all the corresponding first sub-matrices, to obtain a new third sub-matrix; The step of obtaining a new third sub-matrix is repeated until all sub-matrices in the first matrix and all corresponding sub-matrices in the second matrix are calculated.
[0005] Optionally, the step of reading all first submatrices of any row in the first matrix in a row direction and reading all second submatrices of any column in the second matrix in a column direction; and performing multiplication and addition operations on all the first submatrices and all the corresponding second submatrices to obtain a third submatrix includes: Read a first submatrix of any row in the first matrix in a row direction, read a second submatrix corresponding to the first submatrix in the second matrix in a column direction, and perform a multiplication operation on the first submatrix and the corresponding second submatrix to obtain an intermediate submatrix; Read another first submatrix of the row in the first matrix in a row direction, read a second submatrix corresponding to the another first submatrix in the second matrix in a column direction, and perform a multiplication operation on the another first submatrix and the corresponding second submatrix to obtain another intermediate submatrix; Repeat the step of obtaining another intermediate submatrix until the multiplication operation of all first submatrices of any row in the first matrix and all second submatrices corresponding to any column in the second matrix is completed; An addition operation is performed on all the obtained intermediate sub-matrices to obtain the one third sub-matrix.
[0006] Optionally, the outputting the third submatrix and simultaneously reading all new first submatrices of other rows in the first matrix in a row direction, performing multiplication and addition operations on all the new first submatrices and all the corresponding second submatrices to obtain a new third submatrix includes: Reading in row direction the new first sub-matrix corresponding to the other rows in the first matrix and the second sub-matrix read last in the previous round, and outputting the third sub-matrix at the same time; Reusing the second submatrix read last in the previous round to obtain a second multiplexed submatrix, and performing a multiplication operation on the corresponding new first submatrix and the second multiplexed submatrix to obtain an intermediate submatrix; Read another new first submatrix of the row in the first matrix in a row direction, read a second submatrix corresponding to the another new first submatrix in the second matrix in a column direction, and perform a multiplication operation on the another new first submatrix and the corresponding second submatrix to obtain another intermediate submatrix; Repeat the step of obtaining another intermediate submatrix until the multiplication operation of all new first submatrices of the other rows in the first matrix and all corresponding second submatrices of the corresponding columns in the second matrix is completed; An addition operation is performed on all the obtained intermediate sub-matrices to obtain the new third sub-matrix.
[0007] Optionally, the step of outputting the third submatrix and simultaneously reading all new second submatrices of other columns in the second matrix in a column direction, performing multiplication and addition operations on all the new second submatrices and all the corresponding first submatrices to obtain a new third submatrix includes: Reading in column direction the other columns in the second matrix and the new second sub-matrix corresponding to the first sub-matrix read last in the previous round, and outputting the third sub-matrix at the same time; Reusing the first submatrix read last in the previous round to obtain a first multiplexed submatrix, and performing a multiplication operation on the corresponding new second submatrix and the first multiplexed submatrix to obtain an intermediate submatrix; Read another new second submatrix of the column in the second matrix in the column direction, read the first submatrix corresponding to the another second submatrix in the row direction, and perform multiplication operation on the another new second submatrix and the corresponding first submatrix to obtain another intermediate submatrix; Repeat the step of obtaining another intermediate submatrix until the multiplication operation of all new second submatrices of the other columns in the first matrix and all corresponding first submatrices of the corresponding rows in the first matrix is completed; An addition operation is performed on all the obtained intermediate sub-matrices to obtain the new third sub-matrix.
[0008] Optionally, the step of outputting the third submatrix and simultaneously reading all new first submatrices of other rows in the first matrix in a row direction, performing multiplication and addition operations on all the new first submatrices and all the corresponding second submatrices to obtain a new third submatrix includes: Reading in row direction a new first sub-matrix corresponding to other rows in the first matrix and any second sub-matrix of all the second sub-matrices read in the previous round, and outputting the third sub-matrix at the same time; Sequentially multiplexing any one of the second sub-matrices read in the previous round to obtain a second multiplexed sub-matrix, and performing a multiplication operation on the corresponding new first sub-matrix and the second multiplexed sub-matrix to obtain an intermediate sub-matrix; Repeat the step of obtaining the intermediate submatrix until the multiplication operation of all new first submatrices of the other rows in the first matrix and all corresponding second submatrices of the corresponding columns in the second matrix is completed; An addition operation is performed on all the obtained intermediate sub-matrices to obtain the new third sub-matrix.
[0009] Optionally, the step of outputting the third submatrix and simultaneously reading all new second submatrices of other columns in the second matrix in a column direction, performing multiplication and addition operations on all the new second submatrices and all the corresponding first submatrices to obtain a new third submatrix includes: Reading in column direction the other columns in the second matrix and the new second sub-matrix corresponding to any one of the first sub-matrices of all the first sub-matrices read in the previous round, and outputting the third sub-matrix at the same time; Sequentially multiplexing any one of the first sub-matrices read in the previous round to obtain a first multiplexed sub-matrix, and performing a multiplication operation on the corresponding new second sub-matrix and the first multiplexed sub-matrix to obtain an intermediate sub-matrix; Repeat the step of obtaining the intermediate submatrix until the multiplication operation of all the new second submatrices of the other columns in the second matrix and all the first submatrices corresponding to the corresponding rows in the first matrix is completed; An addition operation is performed on all the obtained intermediate sub-matrices to obtain the new third sub-matrix.
[0010] The present application also provides a data processing device, wherein the data includes a first matrix and a second matrix, the first matrix and the second matrix can be multiplied, and the device includes: a first reading module, configured to read all first submatrices of any row in the first matrix in a row direction, and to read all second submatrices of any column in the second matrix in a column direction; and to output the third submatrix, and simultaneously read all new first submatrices of other rows in the first matrix in a row direction, or read all new second submatrices of other columns in the second matrix in a column direction; The first operation module is used to perform multiplication and addition operations on all the first sub-matrices and the corresponding all the second sub-matrices to obtain a third sub-matrix; and is also used to perform multiplication and addition operations on all the new first sub-matrices and the corresponding all the second sub-matrices, or perform multiplication and addition operations on all the new second sub-matrices and the corresponding all the first sub-matrices to obtain a new third sub-matrix; and repeat the step of obtaining a new third sub-matrix until all the sub-matrices in the first matrix and all the corresponding sub-matrices in the second matrix are all calculated.
[0011] The present application also provides a data processing device, comprising: a processor, a memory, and a communication bus; The communication bus is used to realize the connection and communication between the processor and the memory; The processor is used to execute the data processing program stored in the memory to implement the steps of any of the above-mentioned data processing methods.
[0012] The present application also provides a readable storage medium, in which computer executable instructions are stored. When the computer executable instructions are loaded and executed by a processor, the steps of any of the above-mentioned data processing methods are implemented.
[0013] The present application also provides a computer system, which includes computer executable instructions. When the computer executable instructions are loaded and executed by a processor, the steps of any of the above-mentioned data processing methods are implemented.
[0014] Compared with the prior art, the present application provides a data processing method, device, equipment, medium and system, wherein the data includes a first matrix and a second matrix, and the first matrix and the second matrix can be multiplied, by reading all first sub-matrices of any row in the first matrix in the row direction, reading all second sub-matrices of any column in the second matrix in the column direction, performing multiplication and addition operations on all first sub-matrices and all corresponding second sub-matrices to obtain a third sub-matrix, outputting the third sub-matrix, and simultaneously reading all new first sub-matrices of other rows in the first matrix in the row direction, or reading all new second sub-matrices of other columns in the second matrix in the column direction, performing multiplication and addition operations on all new first sub-matrices and all corresponding second sub-matrices, or performing multiplication and addition operations on all new second sub-matrices and all corresponding first sub-matrices to obtain a new third sub-matrix. The step of obtaining a new third submatrix is repeated until all submatrices in the first matrix and all corresponding submatrices in the second matrix are all calculated. In the present application, while reading all new first submatrices of other rows in the first matrix in the row direction, the second submatrix read in the previous round is reused, or while reading all new second submatrices of other columns in the second matrix in the column direction, the first submatrix read in the previous round is reused, so that the bandwidth for transmitting one submatrix can be saved, so that the saved bandwidth can be used to transmit the third submatrix obtained in the previous round of calculation, so that in the process of image and other data calculation, the data transmission bandwidth can be set to the width of the simultaneous transmission of two submatrices, and the data can be transmitted in a parallel transmission mode, which will not cause the interruption of the process of matrix calculation, thereby effectively improving the calculation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be 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 paying creative work.
[0016] Figure 1 A flowchart of a data processing method provided in an embodiment of the present application; Figure 2 A schematic diagram of a process of multiplying a first matrix and a second matrix provided in an embodiment of the present application; Figure 3 A schematic diagram of the structure of a data processing device provided in an embodiment of the present invention; Figure 4 The present invention is a schematic diagram of the structure of a data processing device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0017] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0018] It should be noted that when an element is referred to as being "fixed on" or "set on" another element, it can be directly on the other element or indirectly set on the other element; when an element is referred to as being "connected to" another element, it can be directly connected to the other element or indirectly connected to the other element.
[0019] It should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.
[0020] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this application, "multiple" and "several" mean two or more, unless otherwise clearly and specifically defined.
[0021] It should be noted that the structures, proportions, sizes, etc. illustrated in the drawings of this specification are only used to match the contents disclosed in the specification for people familiar with this technology to understand and read, and are not used to limit the conditions under which this application can be implemented. Therefore, they have no substantive technical significance. Any structural modification, change in proportional relationship or adjustment of size should still fall within the scope of the technical content disclosed in this application without affecting the effects and purposes that can be achieved by this application.
[0022] like Figure 1 As shown, an embodiment of the present application provides a data processing method, which can be applied to the field of image data processing. The data includes a first matrix and a second matrix. The first matrix and the second matrix can be multiplied. The method includes: In this embodiment, the data may be pictures, image data, or video data, etc. The first matrix and the second matrix may be matrices of the same size or matrices of different sizes, but it is necessary to ensure that the first matrix and the second matrix meet the multiplication operation requirements, for example, the number of columns of the first matrix must be equal to the number of rows of the second matrix. Specifically, the number of columns of the first matrix may be equal to the number of rows of the second matrix.
[0023] S11, reading all first sub-matrices of any row in the first matrix in a row direction, and reading all second sub-matrices of any column in the second matrix in a column direction; In this embodiment, the row direction may be from left to right or from right to left; the column direction may be from top to bottom or from bottom to top.
[0024] For example, Figure 2 As shown, if the first matrix is a matrix of four rows and four columns, including 16 first sub-matrices A11-A44, and the second matrix is a matrix of four rows and four columns, including 16 second sub-matrices B11-B44, all the first sub-matrices A11, A12, A13, A14 of the first row in the first matrix can be read from left to right, or all the first sub-matrices A14, A13, A12, A11 of the first row in the first matrix can be read from right to left, and can even be read in any order in the row direction. Take all the first sub-matrices in the first row, such as A12, A13, A11, A14; all the second sub-matrices B11, B21, B31, B41 in the first column of the second matrix can be read from top to bottom, or all the second sub-matrices B41, B31, B21, B11 in the first column of the second matrix can be read from top to bottom, or even all the second sub-matrices in the first column can be read in any order in the column direction, such as B21, B31, B11, B41.
[0025] S12, performing multiplication and addition operations on all first sub-matrices and all corresponding second sub-matrices to obtain a third sub-matrix; In this embodiment, corresponding means that all first sub-matrices in any row of the first matrix and all second sub-matrices in any column of the second matrix can be multiplied to obtain a correct third sub-matrix.
[0026] For example, Figure 2 As shown, all first sub-matrices A11, A12, A13, A14 in the first row of the first matrix and all second sub-matrices B11, B21, B31, B41 in the first column of the second matrix can be multiplied and added to obtain a third sub-matrix C11; or all first sub-matrices A14, A13, A12, A11 in the first row of the first matrix and all corresponding second sub-matrices B41, B31, B21, B11 in the first column of the second matrix can be multiplied and added to obtain a third sub-matrix C11.
[0027] S13, outputting the third sub-matrix, and simultaneously reading all new first sub-matrices of other rows in the first matrix in the row direction, or reading all new second sub-matrices of other columns in the second matrix in the column direction; In this embodiment, the other rows may be any other rows in the first matrix except the one row read in the previous round, and the other columns may be any other columns in the second matrix except the one column read in the previous round.
[0028] For example, if the first row in the first matrix was read in the previous round, the other rows can be any of the second, third, and fourth rows in the first matrix; if the first column in the second matrix was read in the previous round, the other columns can be any of the second, third, and fourth columns in the second matrix.
[0029] In this embodiment, the third submatrix is output, and all new first submatrices of other rows in the first matrix are read in the row direction at the same time. It can be that all new first submatrices of other rows in the first matrix are read in the row direction, the third submatrix is output at the same time, and the second submatrix read last in the previous round is reused to obtain the second multiplexed submatrix, and the remaining second submatrices except the second submatrix read last in the corresponding column of the second matrix in the previous round are read in the column direction. It can also be that all new first submatrices of other rows in the first matrix are read in the row direction, the third submatrix is output at the same time, and all second submatrices read in the previous round are reused to obtain multiple second multiplexed submatrices; The third submatrix is output, and all new second submatrices of other columns in the second matrix are read in the column direction at the same time. It can be that all new second submatrices of other columns in the second matrix are read in the column direction, and the third submatrix is output at the same time and the first submatrix read last in the previous round is reused to obtain the first multiplexed submatrix, and the remaining first submatrices except the first submatrix read last in the corresponding row of the first matrix in the previous round are read in the row direction, or it can be that all new second submatrices of other columns in the second matrix are read in the column direction, and the third submatrix is output at the same time and all first submatrices read in the previous round are reused to obtain multiple first multiplexed submatrices.
[0030] For example, the third sub-matrix is output, and all new first sub-matrices of other rows in the first matrix are read in the row direction at the same time, such as Figure 2 As shown, all new first sub-matrices A24, A23, A22, and A21 of the second row in the first matrix may be read from right to left, and the third sub-matrix C11 may be outputted at the same time, and the second sub-matrix last read in the previous round may be reused to obtain the second multiplexed sub-matrix B41, and the remaining second sub-matrices B31, B21, and B11 in the corresponding columns of the second matrix in the previous round except for the last read second sub-matrix B41 may be read from bottom to top, or all new first sub-matrices A24, A23, A22, and A21 of the second row in the first matrix may be read from right to left. A23, A22, A21, and simultaneously output the third sub-matrix and reuse all the second sub-matrices read in the previous round to obtain four second multiplexed sub-matrices B41, B31, B21, and B11. For example, a cache module can be set in the operation module to cache the second sub-matrices or the first sub-matrices read in the previous rounds as needed, or a module that can perform multiple sets of matrix operations at the same time can be used to directly reuse the corresponding sub-matrices from the cache module in the next round of sub-matrix multiplication and addition operations, ensuring that the matrix multiplication operation can be realized with a bandwidth of only 2 sub-matrices data.
[0031] Output the third sub-matrix, and read all new second sub-matrices of other columns in the second matrix in the column direction at the same time, such as Figure 2 As shown, all new second sub-matrices B42, B32, B22, and B12 in the second column of the second matrix can be read from bottom to top, and the third sub-matrix C11 can be outputted and the first sub-matrix last read in the previous round can be reused to obtain the first multiplexed sub-matrix A14, and the remaining first sub-matrices A13, A12, and A11 except the first sub-matrix A14 last read in the corresponding rows of the first matrix in the previous round can be read from right to left, or all new second sub-matrices B42, B32, B22, and B12 in the second column of the second matrix can be read in the column direction, and the third sub-matrix can be outputted and all the first sub-matrices read in the previous round can be reused to obtain four first multiplexed sub-matrices A14, A13, A12, and A11.
[0032] S14, performing multiplication and addition operations on all new first sub-matrices and all corresponding second sub-matrices, or performing multiplication and addition operations on all new second sub-matrices and all corresponding first sub-matrices, to obtain a new third sub-matrix; In this embodiment, all new first sub-matrices are multiplied and added with all corresponding second sub-matrices to obtain a new third sub-matrix. The method may be to multiply and add all new first sub-matrices with a second multiplexed sub-matrix obtained by reusing the second sub-matrix read last in the previous round and the remaining second sub-matrices in the corresponding columns of the second matrix read in the previous round in the column direction except the second sub-matrix read last to obtain a new third sub-matrix. The method may also be to multiply and add all new first sub-matrices with multiple second multiplexed sub-matrices obtained by reusing all second sub-matrices read in the previous round to obtain a new third sub-matrix. All new second sub-matrices are multiplied and added with all corresponding first sub-matrices to obtain a new third sub-matrix. This can be done by multiplying and adding all new second sub-matrices with a first multiplexed sub-matrix obtained by reusing the last first sub-matrix read in the previous round and the remaining first sub-matrices in the corresponding rows of the previous round in the first matrix read in the row direction to obtain a new third sub-matrix. This can also be done by multiplying and adding all new second sub-matrices with multiple first multiplexed sub-matrices obtained by reusing all first sub-matrices read in the previous round to obtain a new third sub-matrix.
[0033] For example, all new first sub-matrices are multiplied and added with all corresponding second sub-matrices to obtain a new third sub-matrix, such as Figure 2 As shown, all new first sub-matrices A24, A23, A22, A21 may be multiplied and added with the second multiplexed sub-matrix B41 obtained by reusing the second sub-matrix read last in the previous round, and the remaining second sub-matrices B31, B21, B11 in the corresponding columns of the second matrix read from bottom to top in the previous round except the second sub-matrix B41 read last, to obtain a new third sub-matrix C21; or all new first sub-matrices A24, A23, A22, A21 may be multiplied and added with the four second multiplexed sub-matrices B41, B31, B21, B11 obtained by reusing all second sub-matrices read in the previous round, to obtain a new third sub-matrix C21; Perform multiplication and addition operations on all the new second sub-matrices and all the corresponding first sub-matrices to obtain a new third sub-matrix, such as Figure 2As shown, all new second sub-matrices B42, B32, B22, B12 can be multiplied and added with the first multiplexed sub-matrix A14 obtained by reusing the first sub-matrix read last in the previous round, and the remaining first sub-matrices A13, A12, A11 in the corresponding rows of the first matrix read from right to left in the previous round except the last read first sub-matrix A14 to obtain a new third sub-matrix C12. Alternatively, all new second sub-matrices B42, B32, B22, B12 can be multiplied and added with the four first multiplexed sub-matrices A14, A13, A12, A11 obtained by reusing all the first sub-matrices read in the previous round to obtain a new third sub-matrix C12.
[0034] S15, repeat the step of obtaining a new third sub-matrix until all sub-matrices in the first matrix and all corresponding sub-matrices in the second matrix are calculated.
[0035] In this embodiment, steps S13 and S14 of obtaining a new third submatrix are repeated until all submatrices in the first matrix and all corresponding submatrices in the second matrix are completely calculated. In the process of repeating steps S13 and S14, the third submatrix is output in step S13, and all new first submatrices of other rows in the first matrix are read in the row direction at the same time. It can also be that all new first submatrices of other rows in the first matrix are read in the row direction, and the third submatrix is output and all second submatrices read in any previous round are reused. The third submatrix is output in step S13, and all new second submatrices of other columns in the second matrix are read in the column direction at the same time. It can also be that all new second submatrices of other columns in the second matrix are read in the column direction, and the third submatrix is output and all first submatrices read in any previous round are reused. For example, a cache module can be set to cache all first submatrices or all second submatrices read in previous rounds as needed, and the corresponding submatrices are directly reused from the cache module in the next round of submatrix calculations. Submatrices that no longer need to be calculated in the cache module can be deleted, so as to flexibly manage the submatrices in the cache module.
[0036] In the present application, when the first matrix and the second matrix are multiplied, while reading all new first sub-matrices of other rows in the first matrix in the row direction, by reusing the second sub-matrix read last in the previous round, or reusing all second sub-matrices read in the previous round, or reusing all second sub-matrices read in any previous round, the bandwidth for transmitting one sub-matrix can be saved, so that the saved bandwidth can be used to transmit the third sub-matrix obtained in the previous round of operation; while reading all new second sub-matrices of other columns in the second matrix in the column direction, by reusing the first sub-matrix read last in the previous round, or reusing all first sub-matrices read in the previous round, or reusing all first sub-matrices read in any previous round, the bandwidth for transmitting one sub-matrix can be saved, so that the saved bandwidth can be used to transmit the third sub-matrix obtained in the previous round of operation, thereby enabling data to be transmitted using parallel transmission under the premise that the data transmission bandwidth is set to the width of simultaneous transmission of two sub-matrices.
[0037] Compared with the prior art, the present application provides a data processing method, device, equipment, medium and system, wherein the data includes a first matrix and a second matrix, and the first matrix and the second matrix can be multiplied, by reading all first sub-matrices of any row in the first matrix in the row direction, reading all second sub-matrices of any column in the second matrix in the column direction, performing multiplication and addition operations on all first sub-matrices and all corresponding second sub-matrices to obtain a third sub-matrix, outputting the third sub-matrix, and simultaneously reading all new first sub-matrices of other rows in the first matrix in the row direction, or reading all new second sub-matrices of other columns in the second matrix in the column direction, performing multiplication and addition operations on all new first sub-matrices and all corresponding second sub-matrices, or performing multiplication and addition operations on all new second sub-matrices and all corresponding first sub-matrices to obtain a new third sub-matrix. Three sub-matrices, repeat the step of obtaining a new third sub-matrix until all sub-matrices in the first matrix and all corresponding sub-matrices in the second matrix are all calculated. In the present application, while reading all new first sub-matrices of other rows in the first matrix in the row direction, by reusing the second sub-matrix read in the previous round, or while reading all new second sub-matrices of other columns in the second matrix in the column direction, by reusing the first sub-matrix read in the previous round, the bandwidth for transmitting one sub-matrix can be saved, so that the saved bandwidth can be used to transmit the third sub-matrix obtained in the previous round of calculation, and then, under the premise that the data transmission bandwidth of the computing device is set to the width of simultaneous transmission of two sub-matrices, data can be transmitted in a parallel transmission manner, which will not cause the process of matrix calculation to be interrupted, thereby effectively improving the calculation efficiency.
[0038] As an implementation manner, in the embodiment of the present application, all first sub-matrices of any row in the first matrix are read in the row direction, and all second sub-matrices of any column in the second matrix are read in the column direction; multiplication and addition operations are performed on all first sub-matrices and all corresponding second sub-matrices to obtain a third sub-matrix, including: S21, reading a first submatrix of any row in the first matrix in a row direction, reading a second submatrix corresponding to the first submatrix in the second matrix in a column direction, performing a multiplication operation on the first submatrix and the corresponding second submatrix to obtain an intermediate submatrix; In this embodiment, corresponding means that the first submatrix of any row in the first matrix and the second submatrix in the second matrix can be multiplied.
[0039] For example, Figure 2 As shown, a first submatrix A11 of the first row in the first matrix is read from left to right, a second submatrix B11 corresponding to the first submatrix in the second matrix is read from top to bottom, and the first submatrix A11 and the corresponding second submatrix B11 are multiplied to obtain an intermediate submatrix A11*B11.
[0040] S22, reading another first submatrix of the row in the first matrix in a row direction, reading a second submatrix corresponding to another first submatrix in the second matrix in a column direction, performing a multiplication operation on another first submatrix and the corresponding second submatrix to obtain another intermediate submatrix; In this embodiment, the row in step S22 refers to a row in the first matrix where a first sub-matrix read in step S21 is located.
[0041] For example, Figure 2 As shown, another first submatrix A12 of the first row in the first matrix is read from left to right, and a second submatrix B21 corresponding to another first submatrix A12 in the second matrix is read from top to bottom, and another first submatrix A12 and the corresponding second submatrix B21 are multiplied to obtain another intermediate submatrix A12*B21; another first submatrix A13 of the first row in the first matrix can also be read from left to right, and a second submatrix B31 corresponding to another first submatrix A12 in the second matrix is read from top to bottom, and another first submatrix A13 and the corresponding second submatrix B31 are multiplied to obtain another intermediate submatrix A13*B31.
[0042] S23, repeat the step of obtaining another intermediate submatrix until the multiplication operation of all first submatrices in any row of the first matrix and all second submatrices corresponding to any column of the second matrix is completed; In this embodiment, step S22 of obtaining another intermediate submatrix is repeated until the multiplication operation of all first submatrices in any row of the first matrix and all corresponding second submatrices in any column of the second matrix is completed.
[0043] For example, Figure 2 As shown, continue to read another first submatrix A13 of the first row in the first matrix from left to right, read the second submatrix B31 corresponding to the other first submatrix A13 in the second matrix from top to bottom, multiply the other first submatrix A13 and the corresponding second submatrix B31 to obtain another intermediate submatrix A13*B31, continue to read another first submatrix A14 of the first row in the first matrix from left to right, read the second submatrix B41 corresponding to the other first submatrix A14 in the second matrix from top to bottom, multiply the other first submatrix A14 and the corresponding second submatrix B41 to obtain another intermediate submatrix A14*B41. It should be noted that all first submatrices in the first row can be read in any order in the row direction, and all second submatrices in the first column can be read in any order in the column direction. As long as the read first submatrix and the corresponding second submatrix can be normally operated to obtain the correct third submatrix, the specific reading order is not limited in this embodiment.
[0044] S24. Perform an addition operation on all the obtained intermediate sub-matrices to obtain a third sub-matrix.
[0045] In this embodiment, an addition operation is performed on all the intermediate sub-matrices obtained by executing steps S21 to S23 to obtain a third sub-matrix.
[0046] For example, all the intermediate sub-matrices A11*B11, A12*B21, A13*B31, A14*B41 obtained by executing steps S21 to S23 are added to obtain a third sub-matrix C11, where C11=A11*B11+A12*B21+A13*B31+A14*B41.
[0047] As an implementation mode, in the embodiment of the present application, the third sub-matrix is output, and all new first sub-matrices of other rows in the first matrix are read in the row direction at the same time, and all new first sub-matrices are multiplied and added with all corresponding second sub-matrices to obtain a new third sub-matrix, including: S31, reading in the row direction the other rows in the first matrix and the new first sub-matrix corresponding to the second sub-matrix read last in the previous round, and outputting the third sub-matrix at the same time; In this embodiment, a new first submatrix corresponding to the second submatrix read last in the previous round is read in any row of the first matrix except the row read in the previous round in the row direction, and the third submatrix obtained in the previous round is output at the same time.
[0048] For example, Figure 2 As shown, if the second submatrix read last in the previous round is B41, the new first submatrix A24 corresponding to the second row in the first matrix and the second submatrix B41 read last in the previous round can be read from right to left, and the third submatrix C11 obtained in the previous round can be output at the same time.
[0049] S32, multiplexing the second sub-matrix read last in the previous round to obtain a second multiplexed sub-matrix, and multiplying the corresponding new first sub-matrix by the second multiplexed sub-matrix to obtain an intermediate sub-matrix; In this embodiment, the second submatrix read last in the previous round is reused to obtain a second multiplexed submatrix, and the new first submatrix corresponding to the second submatrix read last in the previous round is multiplied by the second multiplexed submatrix to obtain an intermediate submatrix.
[0050] For example, Figure 2 As shown, if the second submatrix read last in the previous round is B41, the second submatrix read last in the previous round is reused to obtain the second multiplexed submatrix B41, and the new first submatrix A24 corresponding to the second submatrix B41 read last in the previous round is multiplied by the second multiplexed submatrix B41 to obtain the intermediate submatrix A24*B41.
[0051] S33, reading another new first submatrix of the row in the first matrix in a row direction, reading a second submatrix corresponding to the another new first submatrix in the second matrix in a column direction, performing a multiplication operation on the another new first submatrix and the corresponding second submatrix to obtain another intermediate submatrix; In this embodiment, the row in step S33 refers to the row in the first matrix where the new first sub-matrix corresponding to the second sub-matrix read last in the previous round and read in step S31 is located.
[0052] For example, Figure 2 As shown, another new first submatrix A23 of the second row in the first matrix is read from right to left, and the second submatrix B31 corresponding to the another new first submatrix A23 in the second matrix is read from bottom to top, and multiplication operation is performed on the another new first submatrix A23 and the corresponding second submatrix B31 to obtain another intermediate submatrix A23*B31.
[0053] S34, repeat the step of obtaining another intermediate submatrix until the multiplication operation of all new first submatrices in other rows of the first matrix and all corresponding second submatrices in corresponding columns of the second matrix is completed; In this embodiment, step S33 of obtaining another intermediate submatrix is repeated until the multiplication operation of all new first submatrices in other rows of the first matrix and all corresponding second submatrices in corresponding columns of the second matrix is completed.
[0054] For example, Figure 2 As shown, continue to read another new first submatrix A22 of the second row in the first matrix from right to left, read the second submatrix B21 in the second matrix corresponding to the another new first submatrix A22 from bottom to top, multiply the another new first submatrix A22 and the corresponding second submatrix B21 to obtain another intermediate submatrix A22*B21, continue to read another new first submatrix A21 of the second row in the first matrix from right to left, read the second submatrix B11 in the second matrix corresponding to the another new first submatrix A21 from bottom to top, multiply the another new first submatrix A21 and the corresponding second submatrix B11 to obtain another intermediate submatrix A21*B11.
[0055] S35. Perform an addition operation on all the obtained intermediate sub-matrices to obtain a new third sub-matrix.
[0056] In this embodiment, an addition operation is performed on all the intermediate sub-matrices obtained by executing steps S31 to S34 to obtain a new third sub-matrix.
[0057] For example, all the intermediate sub-matrices A24*B41, A23*B31, A22*B21, A21*B11 obtained by executing steps S31 to S34 are added to obtain a third sub-matrix C21, where C21=A24*B41+A23*B31+A22*B21+A21*B11.
[0058] As an implementation mode, in the embodiment of the present application, the third sub-matrix is output, and all new second sub-matrices of other columns in the second matrix are read in the column direction at the same time, and all new second sub-matrices are multiplied and added with all corresponding first sub-matrices to obtain a new third sub-matrix, including: S41, reading in the column direction the other columns in the second matrix and the new second sub-matrix corresponding to the first sub-matrix read last in the previous round, and outputting the third sub-matrix at the same time; In this embodiment, a new second submatrix corresponding to the first submatrix last read in the previous round is read in any column of the second matrix except the column read in the previous round in the column direction, and the third submatrix obtained in the previous round is output at the same time.
[0059] For example, Figure 2 As shown, if the first submatrix read last in the previous round is A14, the new second submatrix B42 corresponding to the second column of the second matrix and the first submatrix A14 read last in the previous round can be read from bottom to top, and the third submatrix C11 obtained in the previous round can be output at the same time.
[0060] S42, multiplexing the first sub-matrix read last in the previous round to obtain a first multiplexed sub-matrix, and multiplying the corresponding new second sub-matrix by the first multiplexed sub-matrix to obtain an intermediate sub-matrix; In this embodiment, the first submatrix read last in the previous round is reused to obtain a first multiplexed submatrix, and the first multiplexed submatrix and the new second submatrix corresponding to the first submatrix read last in the previous round are multiplied to obtain an intermediate submatrix.
[0061] For example, Figure 2 As shown, if the first submatrix read last in the previous round is A14, the first submatrix read last in the previous round is reused to obtain the first multiplexed submatrix A14, and the first multiplexed submatrix A14 and the new second submatrix B42 corresponding to the first submatrix read last in the previous round are multiplied to obtain the intermediate submatrix A14*B42.
[0062] S43, reading another new second submatrix of the column in the second matrix in the column direction, reading the first submatrix corresponding to the other second submatrix in the row direction, and performing multiplication operation on the other new second submatrix and the corresponding first submatrix to obtain another intermediate submatrix; In this embodiment, the column in step S43 refers to the column in the second matrix where the new second sub-matrix corresponding to the first sub-matrix last read in the previous round and read in step S41 is located.
[0063] For example, another new second submatrix B32 in the second column of the second matrix is read from bottom to top, and the first submatrix A13 corresponding to the another new second submatrix B32 in the first matrix is read from right to left, and multiplication is performed on the another new second submatrix B32 and the corresponding first submatrix A13 to obtain another intermediate submatrix B32*A13.
[0064] S44, repeat the step of obtaining another intermediate submatrix until the multiplication operation of all new second submatrices in other columns of the first matrix and all corresponding first submatrices in corresponding rows of the first matrix is completed; In this embodiment, step S43 of obtaining another intermediate submatrix is repeated until the multiplication operation of all new second submatrices in other columns of the first matrix and all corresponding first submatrices in corresponding rows of the first matrix is completed.
[0065] For example, continue to read another new second submatrix B22 in the second column of the second matrix from bottom to top, read the first submatrix A12 in the first matrix corresponding to the another new second submatrix B22 from right to left, multiply the another new second submatrix B22 and the corresponding first submatrix A12 to obtain another intermediate submatrix B22*A12, continue to read another new second submatrix B12 in the second column of the second matrix from bottom to top, read the first submatrix A11 in the first matrix corresponding to the another new second submatrix B12 from right to left, multiply the another new second submatrix B12 and the corresponding first submatrix A11 to obtain another intermediate submatrix B12*A11.
[0066] S45. Perform an addition operation on all the obtained intermediate sub-matrices to obtain a new third sub-matrix.
[0067] In this embodiment, an addition operation is performed on all the intermediate sub-matrices obtained by executing steps S41 to S44 to obtain a new third sub-matrix.
[0068] For example, all the intermediate sub-matrices A14*B42, B32*A13, B22*A12, B12*A11 obtained by executing steps S41 to S44 are added to obtain a third sub-matrix C12, where C12=A14*B42+B32*A13+B22*A12+B12*A11.
[0069] As an implementation mode, in the embodiment of the present application, the third sub-matrix is output, and all new first sub-matrices of other rows in the first matrix are read in the row direction at the same time, and all new first sub-matrices are multiplied and added with all corresponding second sub-matrices to obtain a new third sub-matrix, including: S51, reading in the row direction a new first sub-matrix corresponding to other rows in the first matrix and any second sub-matrix in all second sub-matrices read in the previous round, and outputting a third sub-matrix at the same time; In this embodiment, a new first sub-matrix corresponding to any second sub-matrix in all second sub-matrices read in the previous round is read in any remaining row of the first matrix except the row read in the previous round in the row direction, and the third sub-matrix obtained in the previous round is output at the same time.
[0070] For example, Figure 2 As shown, if any second submatrix among all the second submatrices read in the previous round is B41, a new first submatrix A24 corresponding to the second row in the first matrix and any second submatrix B41 among all the second submatrices read last in the previous round can be read from right to left, and the third submatrix C11 obtained in the previous round can be output at the same time.
[0071] S52, sequentially multiplexing any one of all the second sub-matrices read in the previous round to obtain a second multiplexed sub-matrix, and performing a multiplication operation on the corresponding new first sub-matrix and the second multiplexed sub-matrix to obtain an intermediate sub-matrix; In this embodiment, "sequentially" only means that the second sub-matrices multiplexed each time are not repeated, and there is no limitation on the order. For example, the order can be from top to bottom, from bottom to top, or crosswise.
[0072] For example, Figure 2 As shown, any one B41 of all the second sub-matrices read in the previous round is reused to obtain the second multiplexed sub-matrix B41, and the corresponding new first sub-matrix A24 is multiplied by the second multiplexed sub-matrix B41 to obtain the intermediate sub-matrix A24*B41; any one of all the second sub-matrices read in one round, for example B21, can be reused to obtain the second multiplexed sub-matrix B21, and the corresponding new first sub-matrix A22 is multiplied by the second multiplexed sub-matrix B21 to obtain the intermediate sub-matrix A22*B21.
[0073] S53, repeat the step of obtaining the intermediate submatrix until the multiplication operation of all new first submatrices in other rows of the first matrix and all corresponding second submatrices in corresponding columns of the second matrix is completed; In this embodiment, steps S51-S52 of obtaining the intermediate submatrix are repeated until the multiplication operation of all new first submatrices of other rows in the first matrix and all corresponding second submatrices of corresponding columns in the second matrix is completed.
[0074] For example, Figure 2As shown, if another second submatrix among all the second submatrices read in the previous round is B31, the new first submatrix A23 corresponding to another second submatrix B31 among all the second submatrices read last in the previous round can be read from the right to the left direction in the second row of the first matrix, and another one of all the second submatrices read in the previous round is reused to obtain the second multiplexed submatrix B31, and the corresponding new first submatrix A23 is multiplied by the second multiplexed submatrix B31 to obtain the intermediate submatrix A23*B31, and the new first submatrix A23 corresponding to another second submatrix B21 among all the second submatrices read last in the previous round is read from the right to the left direction. The first submatrix A22 is read, another one of all the second submatrices read in the previous round is reused to obtain the second multiplexed submatrix B21, the corresponding new first submatrix A22 is multiplied by the second multiplexed submatrix B21 to obtain the intermediate submatrix A22*B21, and the new first submatrix A21 corresponding to the second row of the first matrix and another second submatrix B11 of all the second submatrices read last in the previous round is continued to be read from right to left, and another one of all the second submatrices read in the previous round is reused to obtain the second multiplexed submatrix B11, and the corresponding new first submatrix A21 is multiplied by the second multiplexed submatrix B11 to obtain the intermediate submatrix A21*B11.
[0075] S54. Perform an addition operation on all the obtained intermediate sub-matrices to obtain a new third sub-matrix.
[0076] In this embodiment, an addition operation is performed on all the intermediate sub-matrices obtained by executing steps S51 to S53 to obtain a new third sub-matrix.
[0077] For example, all the intermediate sub-matrices A24*B41, A23*B31, A22*B21, A21*B11 obtained by executing steps S51 to S53 are added to obtain a third sub-matrix C21, where C21=A24*B41+A23*B31+A22*B21+A21*B11.
[0078] As an implementation mode, in the embodiment of the present application, the third sub-matrix is output, and all new second sub-matrices of other columns in the second matrix are read in the column direction at the same time, and all new second sub-matrices are multiplied and added with all corresponding first sub-matrices to obtain a new third sub-matrix, including: S61, reading in the column direction a new second sub-matrix corresponding to any first sub-matrix of all first sub-matrices read in the previous round from other columns in the second matrix, and outputting a third sub-matrix at the same time; In this embodiment, a new second submatrix corresponding to any first submatrix among all the first submatrices read in the previous round is read in any column of the second matrix except the column read in the previous round in the column direction, and the third submatrix obtained in the previous round is output at the same time.
[0079] For example, Figure 2 As shown, if any first submatrix among all the first submatrices read in the previous round is A14, a new second submatrix B42 corresponding to the second column in the second matrix and any first submatrix A14 among all the first submatrices read last in the previous round can be read from bottom to top, and the third submatrix C11 obtained in the previous round can be output at the same time.
[0080] S62, sequentially reuse any one of all the first sub-matrices read in the previous round to obtain a first multiplexed sub-matrix, and perform multiplication operation on the corresponding new second sub-matrix and the first multiplexed sub-matrix to obtain an intermediate sub-matrix; In this embodiment, "sequentially" only means that the first sub-matrix is not repeated each time it is multiplexed, and there is no limitation on the order. For example, the order can be from left to right, from right to left, or crosswise.
[0081] For example, Figure 2 As shown, any one A14 of all the first sub-matrices read in the previous round is reused to obtain the first multiplexed sub-matrix A14, and the first multiplexed sub-matrix A14 is multiplied with the corresponding new second sub-matrix B42 to obtain the intermediate sub-matrix A14*B42; any one A12 of all the first sub-matrices read in the previous round can also be reused to obtain the first multiplexed sub-matrix A12, and the first multiplexed sub-matrix A12 is multiplied with the corresponding new second sub-matrix B22 to obtain the intermediate sub-matrix A12*B22.
[0082] S63, repeat the step of obtaining the intermediate submatrix until the multiplication operation of all new second submatrices of other columns in the first matrix and all corresponding first submatrices of corresponding rows in the first matrix is completed; In this embodiment, steps S61-S62 of obtaining the intermediate submatrix are repeated until the multiplication operation of all new second submatrices in other columns of the first matrix and all corresponding first submatrices in corresponding rows of the first matrix is completed.
[0083] For example, Figure 2As shown, if another first submatrix among all the first submatrices read in the previous round is A13, the second column in the second matrix and the new second submatrix B32 corresponding to another first submatrix A13 among all the first submatrices read last in the previous round can be read from bottom to top, another one of all the first submatrices read in the previous round is reused to obtain the first multiplexed submatrix A13, the first multiplexed submatrix A13 is multiplied by the corresponding new second submatrix B32 to obtain the intermediate submatrix A13*B32, and the second column in the second matrix and the new submatrix A12 corresponding to another first submatrix A12 among all the first submatrices read last in the previous round are read from bottom to top. The second submatrix B22 is read, another one of all the first submatrices read in the previous round is reused to obtain the first multiplexed submatrix A12, the first multiplexed submatrix A12 is multiplied by the corresponding new second submatrix B22 to obtain an intermediate submatrix A12*B22, and the new second submatrix B12 corresponding to the second column of the second matrix and another first submatrix A11 of all the first submatrices read last in the previous round is read is continued from bottom to top, and another one of all the first submatrices read in the previous round is reused to obtain the first multiplexed submatrix A11, and the first multiplexed submatrix A11 is multiplied by the corresponding new second submatrix B12 to obtain an intermediate submatrix A11*B12.
[0084] S64. Perform an addition operation on all the obtained intermediate sub-matrices to obtain a new third sub-matrix.
[0085] In this embodiment, an addition operation is performed on all the intermediate sub-matrices obtained by executing steps S61 to S63 to obtain a new third sub-matrix.
[0086] For example, all the intermediate sub-matrices A14*B42, B32*A13, B22*A12, B12*A11 obtained by executing steps S61 to S63 are added to obtain a third sub-matrix C12, where C12=A14*B42+A13*B32+A12*B22+A11*B12.
[0087] like Figure 3 As shown, an embodiment of the present application further provides a data processing device, wherein the data includes a first matrix and a second matrix, and the first matrix and the second matrix can be multiplied, and the device includes: The first reading module 31 is used to read all first sub-matrices of any row in the first matrix in the row direction, and read all second sub-matrices of any column in the second matrix in the column direction; and is also used to output the third sub-matrix, and simultaneously read all new first sub-matrices of other rows in the first matrix in the row direction, or read all new second sub-matrices of other columns in the second matrix in the column direction; The first operation module 32 is used to perform multiplication and addition operations on all first sub-matrices and all corresponding second sub-matrices to obtain a third sub-matrix; it is also used to perform multiplication and addition operations on all new first sub-matrices and all corresponding second sub-matrices, or perform multiplication and addition operations on all new second sub-matrices and all corresponding first sub-matrices to obtain a new third sub-matrix; and repeat the steps of obtaining a new third sub-matrix until all sub-matrices in the first matrix and all corresponding sub-matrices in the second matrix are fully operated.
[0088] like Figure 4 As shown, the embodiment of the present application also provides a data processing device, including: a processor 41, a memory 42 and a communication bus 43; A communication bus 43, used to realize connection and communication between the processor 41 and the memory 42; The processor 41 is used to execute the data processing program stored in the memory 42 to implement the steps of any one of the above data processing methods.
[0089] The present application also provides a readable storage medium, in which computer executable instructions are stored. When the computer executable instructions are loaded and executed by a processor, the steps of any of the above-mentioned data processing methods are implemented.
[0090] The present application also provides a computer system, which includes computer executable instructions. When the computer executable instructions are loaded and executed by a processor, the steps of any of the above-mentioned data processing methods are implemented.
[0091] It should be understood that the use of "system", "device", "unit" and / or "module" in this application is only a method for distinguishing multiple components, elements, parts, parts or assemblies at multiple levels. However, if other words can achieve the same purpose, the word can be replaced by other expressions.
[0092] The embodiments in this specification are described in a progressive manner, and each embodiment focuses on the For other embodiments, the same or similar parts of each embodiment can be referenced to each other.
[0093] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data processing method, characterized in that: The data includes a first matrix and a second matrix, the first matrix and the second matrix can be multiplied, and the method includes: Read all first sub-matrices of any row in the first matrix in a row direction, and read all second sub-matrices of any column in the second matrix in a column direction; Performing multiplication and addition operations on all the first sub-matrices and all the corresponding second sub-matrices to obtain a third sub-matrix; Output the third submatrix, and simultaneously read all new first submatrices of other rows in the first matrix in a row direction, or read all new second submatrices of other columns in the second matrix in a column direction; Performing multiplication and addition operations on all the new first sub-matrices and all the corresponding second sub-matrices, or performing multiplication and addition operations on all the new second sub-matrices and all the corresponding first sub-matrices, to obtain a new third sub-matrix; The step of obtaining a new third sub-matrix is repeated until all sub-matrices in the first matrix and all corresponding sub-matrices in the second matrix are calculated.
2. The method according to claim 1, characterized in that The method further comprises: reading all first sub-matrices of any row in the first matrix in a row direction, and reading all second sub-matrices of any column in the second matrix in a column direction; Performing multiplication and addition operations on all the first sub-matrices and the corresponding all the second sub-matrices to obtain a third sub-matrix, including: Read a first submatrix of any row in the first matrix in a row direction, read a second submatrix corresponding to the first submatrix in the second matrix in a column direction, and perform a multiplication operation on the first submatrix and the corresponding second submatrix to obtain an intermediate submatrix; Read another first submatrix of the row in the first matrix in a row direction, read a second submatrix corresponding to the another first submatrix in the second matrix in a column direction, and perform a multiplication operation on the another first submatrix and the corresponding second submatrix to obtain another intermediate submatrix; Repeat the step of obtaining another intermediate submatrix until the multiplication operation of all first submatrices of any row in the first matrix and all second submatrices corresponding to any column in the second matrix is completed; An addition operation is performed on all the obtained intermediate sub-matrices to obtain the third sub-matrix.
3. The method according to claim 2, characterized in that The step of outputting the third submatrix and simultaneously reading all new first submatrices of other rows in the first matrix in a row direction, performing multiplication and addition operations on all the new first submatrices and all the corresponding second submatrices to obtain a new third submatrix includes: Reading in row direction the new first sub-matrix corresponding to the other rows in the first matrix and the second sub-matrix read last in the previous round, and outputting the third sub-matrix at the same time; Reusing the second submatrix read last in the previous round to obtain a second multiplexed submatrix, and performing multiplication operation on the corresponding new first submatrix and the second multiplexed submatrix to obtain an intermediate submatrix; Read another new first submatrix of the row in the first matrix in a row direction, read a second submatrix corresponding to the another new first submatrix in the second matrix in a column direction, and perform a multiplication operation on the another new first submatrix and the corresponding second submatrix to obtain another intermediate submatrix; Repeat the step of obtaining another intermediate submatrix until the multiplication operation of all new first submatrices of the other rows in the first matrix and all corresponding second submatrices of the corresponding columns in the second matrix is completed; An addition operation is performed on all the obtained intermediate sub-matrices to obtain the new third sub-matrix.
4. The method according to claim 2, characterized in that: The step of outputting the third submatrix and simultaneously reading all new second submatrices of other columns in the second matrix in a column direction, performing multiplication and addition operations on all the new second submatrices and all the corresponding first submatrices to obtain a new third submatrix includes: Reading in column direction the other columns in the second matrix and the new second sub-matrix corresponding to the first sub-matrix read last in the previous round, and outputting the third sub-matrix at the same time; Reusing the first submatrix read last in the previous round to obtain a first multiplexed submatrix, and performing a multiplication operation on the corresponding new second submatrix and the first multiplexed submatrix to obtain an intermediate submatrix; Read another new second submatrix of the column in the second matrix in the column direction, read the first submatrix corresponding to the another second submatrix in the row direction, and perform multiplication operation on the another new second submatrix and the corresponding first submatrix to obtain another intermediate submatrix; Repeat the step of obtaining another intermediate submatrix until the multiplication operation of all new second submatrices of the other columns in the first matrix and all corresponding first submatrices of the corresponding rows in the first matrix is completed; An addition operation is performed on all the obtained intermediate sub-matrices to obtain the new third sub-matrix.
5. The method according to claim 2, characterized in that: The step of outputting the third submatrix and simultaneously reading all new first submatrices of other rows in the first matrix in a row direction, performing multiplication and addition operations on all the new first submatrices and all the corresponding second submatrices to obtain a new third submatrix includes: Reading in row direction a new first sub-matrix corresponding to other rows in the first matrix and any second sub-matrix in all the second sub-matrices read in the previous round, and outputting the third sub-matrix at the same time; Sequentially multiplexing any one of the second sub-matrices read in the previous round to obtain a second multiplexed sub-matrix, and performing a multiplication operation on the corresponding new first sub-matrix and the second multiplexed sub-matrix to obtain an intermediate sub-matrix; Repeat the step of obtaining the intermediate submatrix until the multiplication operation of all new first submatrices of the other rows in the first matrix and all corresponding second submatrices of the corresponding columns in the second matrix is completed; An addition operation is performed on all the obtained intermediate sub-matrices to obtain the new third sub-matrix.
6. The method according to claim 2, characterized in that The step of outputting the third submatrix and simultaneously reading all new second submatrices of other columns in the second matrix in a column direction, performing multiplication and addition operations on all the new second submatrices and all the corresponding first submatrices to obtain a new third submatrix includes: Reading in column direction the other columns in the second matrix and the new second sub-matrix corresponding to any one of the first sub-matrices of all the first sub-matrices read in the previous round, and outputting the third sub-matrix at the same time; Sequentially multiplexing any one of the first sub-matrices read in the previous round to obtain a first multiplexed sub-matrix, and performing a multiplication operation on the corresponding new second sub-matrix and the first multiplexed sub-matrix to obtain an intermediate sub-matrix; Repeat the step of obtaining the intermediate submatrix until the multiplication operation of all the new second submatrices of the other columns in the second matrix and all the first submatrices corresponding to the corresponding rows in the first matrix is completed; An addition operation is performed on all the obtained intermediate sub-matrices to obtain the new third sub-matrix.
7. A data processing device, characterized in that: The data includes a first matrix and a second matrix, and the first matrix and the second matrix can be multiplied. The device includes: a first reading module, configured to read all first submatrices of any row in the first matrix in a row direction, and to read all second submatrices of any column in the second matrix in a column direction; and to output the third submatrix, and simultaneously read all new first submatrices of other rows in the first matrix in a row direction, or read all new second submatrices of other columns in the second matrix in a column direction; The first operation module is used to perform multiplication and addition operations on all the first sub-matrices and the corresponding all the second sub-matrices to obtain a third sub-matrix; and is also used to perform multiplication and addition operations on all the new first sub-matrices and the corresponding all the second sub-matrices, or perform multiplication and addition operations on all the new second sub-matrices and the corresponding all the first sub-matrices to obtain a new third sub-matrix; and repeat the step of obtaining a new third sub-matrix until all the sub-matrices in the first matrix and all the corresponding sub-matrices in the second matrix are all calculated.
8. A data processing device, characterized in that: include: processor, memory, and communications bus; The communication bus is used to realize the connection and communication between the processor and the memory; The processor is used to execute the data processing program stored in the memory to implement the steps of the data processing method according to any one of claims 1 to 6.
9. A readable storage medium, characterized in that: The readable storage medium stores computer executable instructions, and when the computer executable instructions are loaded and executed by the processor, the steps of the data processing method according to any one of claims 1 to 6 are implemented.
10. A computer system, characterized in that: The system includes computer executable instructions, and when the computer executable instructions are loaded and executed by a processor, the steps of the data processing method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Method and device for matrix calculation
CN113268708A
Matrix operation result determination method and device, storage medium and electronic device
CN114647818A
Computing device, method and storage medium for performing convolution operation
CN117252245A
Near memory sparse matrix computation in deep neural network
US20220101091A1