Data processing method, device, equipment and storage medium

The data processing method optimizes matrix operations in GPUs by reducing redundant data reads and writes, addressing inefficiencies in existing methods and enhancing performance and power efficiency.

JP2024533746AActive Publication Date: 2024-09-12HYGON INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
JP2024518978
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2021-11-03
Filing Date
2022-05-16
Publication Date
2024-09-12
Estimated Expiration
2042-05-16

AI Technical Summary

Technical Problem

Existing data processing methods for matrix operations in graphics processing units (GPUs) suffer from inefficiencies due to redundant data reading and increased power consumption, as conventional techniques require multiple reads from DDR memory for matrix operations, leading to unnecessary data redundancy and higher power usage.

Method used

A data processing method that optimizes matrix operations by selecting and copying operation data based on the characteristics of matrices, reducing redundant data reads and writes by utilizing the properties of SIMD structures to multiplex data between threads, thereby minimizing the number of times data is read from DDR memory.

Benefits of technology

This approach significantly reduces data redundancy, minimizes power consumption, and accelerates data reading speeds while optimizing storage space usage by efficiently handling matrix operations in GPUs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2024533746000001
    Figure 2024533746000001
Patent Text Reader

Abstract

The present disclosure provides a data processing method, an apparatus, a device, and a storage medium applied to matrix operations. The data processing method includes the steps of: determining at least one first vector register in which a first matrix including a plurality of first operation data is stored, and at least one second vector register in which a second matrix including a plurality of second operation data is stored; acquiring first data selection information and second data selection information; selecting at least one first operation data from the plurality of first operation data based on the first data selection information to obtain at least one first target operation data; and selecting at least one second operation data from the plurality of second operation data based on the second data selection information to obtain at least one second target operation data. The data processing method makes full use of the characteristics of matrices, effectively multiplexes data between threads, greatly reduces the number of data reads, and reduces power consumption.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] This application claims priority to Chinese Patent Application No. 202111291162.1 filed on November 3, 2021, and the entire contents disclosed in the above Chinese patent application are hereby incorporated by reference for all purposes.

[0002] SUMMARY OF THE DISCLOSURE The embodiments of the present disclosure relate to a data processing method, a data processing device, a data processing apparatus, and a computer-readable storage medium. [Background technology]

[0003] A graphics processor (GPU) contains a large number of data processing units, each of which is a single-instruction-multiple-data (SIMD) structure. SIMD can control the execution of the same operation on multiple threads simultaneously by executing one instruction, and each SIMD structure has a dedicated set of vector registers and a large number of parallel-executable arithmetic units such as multiplication units. SIMD structures have high parallelism, so they are widely applied to matrix operations. Summary of the Invention [Means for solving the problem]

[0004] At least one embodiment of the present disclosure provides a data processing method applied to matrix operation, comprising the steps of determining at least one first vector register in which a first matrix including a plurality of first operation data is stored, and at least one second vector register in which a second matrix including a plurality of second operation data is stored; obtaining first data selection information and second data selection information; selecting at least one first operation data from the plurality of first operation data based on the first data selection information to obtain at least one first target operation data; and assigning the at least one first target operation data to a second matrix dimension of the second matrix. and providing the at least one second target operation data to the plurality of calculators as a multiple of a first matrix dimension of the first matrix, to determine a plurality of first multiplication coefficients corresponding one-to-one to the plurality of calculators, wherein the first matrix dimension and the second matrix dimension are both positive integers, and the type of the first matrix dimension and the type of the second matrix dimension are different.

[0005] For example, in a data processing method according to at least one embodiment of the present disclosure, the at least one first target operation data includes M first target operation data, the multiple processors include P processor groups, each processor group includes M processors, the second matrix dimension is P, where M and P are both positive integers, and the step of providing the at least one first target operation data to the multiple processors using the second matrix dimension of the second matrix as a multiple to determine a plurality of first multiplication coefficients corresponding one-to-one to the multiple processors includes a step of copying the M first target operation data to P units to obtain P first target operation data groups, each first target operation data group including M first target operation data, and a step of providing the P first target operation data groups to the P processor groups respectively to determine a plurality of first multiplication coefficients, the M first multiplication coefficients corresponding to the M processors in each processor group being M first target operation data.

[0006] For example, in a data processing method according to at least one embodiment of the present disclosure, the at least one second target operation data includes P second target operation data, the multiple calculators include P calculator groups, each calculator group includes M calculators, a first matrix dimension is M, and M and P are both positive integers, and the step of providing the at least one second target operation data to the multiple calculators with the first matrix dimension of the first matrix as a multiple to determine a plurality of second multiplication coefficients corresponding one-to-one to the multiple calculators includes: a step of copying the P second target operation data to M copies to obtain P second target operation data groups, each second target operation data group corresponding to one second target operation data and including the same M second target operation data; and a step of providing the P second target operation data groups to the P calculator groups respectively to determine a plurality of second multiplication coefficients, the M second multiplication coefficients corresponding to the M calculators in each calculator group are the same, and are second target operation data in the second target operation data group corresponding to each calculator group.

[0007] For example, in a data processing method according to at least one embodiment of the present disclosure, the matrix operation includes a plurality of threads, the plurality of operation units respectively correspond to the plurality of threads, the at least one first vector register has a plurality of first paths, the at least one second vector register has a plurality of second paths, each thread of the plurality of threads respectively corresponds to a corresponding first path of the plurality of first paths and a corresponding second path of the plurality of second paths, the plurality of first operation data correspond to the plurality of first paths, and the plurality of second operation data correspond to the plurality of second paths, and the step of selecting at least one first operation data from the plurality of first operation data based on the first data selection information to obtain at least one first target operation data includes: , the step of determining at least one first path selected from the plurality of first paths based on the first data selection information and using at least one first operation data corresponding to the selected at least one first path as at least one first target operation data, and the step of selecting at least one second operation data from the plurality of second operation data based on the second data selection information and obtaining at least one second target operation data includes a step of determining at least one second path selected from the plurality of second paths based on the second data selection information and using at least one second operation data corresponding to the selected at least one second path as at least one second target operation data.

[0008] For example, a data processing method according to at least one embodiment of the present disclosure further includes: determining at least one destination vector register; performing multiplication operations by a plurality of arithmetic units based on a plurality of first multiplication coefficients and a plurality of second multiplication coefficients to obtain a plurality of multiplication operation results corresponding to the plurality of arithmetic units, each arithmetic unit being used to perform a multiplication operation on a corresponding first multiplication coefficient and a corresponding second multiplication coefficient to obtain a multiplication operation result corresponding to each arithmetic unit; and sending the plurality of multiplication operation results to the at least one destination vector register.

[0009] For example, in a data processing method according to at least one embodiment of the present disclosure, the step of sending multiple multiplication operation results to at least one destination vector register includes the steps of performing an addition operation by matching the multiple multiplication operation results with multiple storage data stored in the at least one destination vector register in a one-to-one relationship to obtain multiple addition operation results, and storing the multiple addition operation results in the at least one destination vector register.

[0010] For example, in a data processing method according to at least one embodiment of the present disclosure, the step of obtaining the first data selection information and the second data selection information includes the steps of obtaining a data selection command, and parsing the data selection command to obtain the first data selection information and the second data selection information.

[0011] For example, in a data processing method according to at least one embodiment of the present disclosure, the at least one first vector register includes a first target vector register, and the at least one first target operation data is all stored in the first target vector register, the at least one second vector register includes a second target vector register, and the at least one second target operation data is all stored in the second target vector register.

[0012] For example, in a data processing method according to at least one embodiment of the present disclosure, the first matrix is ​​a vertical matrix, and at least one first target operation data is located in the same column of the first matrix, and the second matrix is ​​a horizontal matrix, and at least one second target operation data is located in the same row of the second matrix.

[0013] For example, in a data processing method according to at least one embodiment of the present disclosure, the step of determining at least one first vector register in which a first matrix is ​​stored and at least one second vector register in which a second matrix is ​​stored includes the steps of obtaining at least one first address and at least one second address, determining the at least one first vector register based on the at least one first address, and determining the at least one second vector register based on the at least one second address.

[0014] For example, in a data processing method according to at least one embodiment of the present disclosure, the step of obtaining at least one first address and at least one second address includes the steps of obtaining a matrix operation instruction, and analyzing the matrix operation instruction to obtain the at least one first address and the at least one second address.

[0015] For example, in a data processing method according to at least one embodiment of the present disclosure, the step of obtaining the first data selection information and the second data selection information includes a step of analyzing a matrix operation instruction and obtaining the first data selection information and the second data selection information.

[0016] For example, a data processing method according to at least one embodiment of the present disclosure further includes the steps of: obtaining at least one first data read instruction and at least one second data read instruction; analyzing the at least one first data read instruction to obtain at least one first read address and at least one first address; reading a plurality of first operation data from a memory based on the at least one first read address, and determining at least one first vector register based on the at least one first address, and writing the plurality of first operation data to the at least one first vector register; analyzing at least one second data read instruction to obtain at least one second read address and at least one second address; reading a plurality of second operation data from a memory based on the at least one second read address, and determining at least one second vector register based on the at least one second address, and writing the plurality of second operation data to the at least one second vector register.

[0017] For example, in a data processing method according to at least one embodiment of the present disclosure, a plurality of computing units execute multiplication operations in parallel.

[0018] At least one embodiment of the present disclosure provides a data processing device applied to matrix operation, the data processing device including a register determination unit used to determine at least one first vector register in which a first matrix including a plurality of first operation data is stored, and at least one second vector register in which a second matrix including a plurality of second operation data is stored, and an information acquisition unit used to acquire first data selection information and second data selection information, and the data selection unit selects at least one first operation data from the plurality of first operation data based on the first data selection information, obtains at least one first target operation data, and obtains at least one second target operation data from the plurality of second operation data based on the second data selection information. a data selection unit used to select at least one second operation data to obtain at least one second target operation data; and a data broadcast unit for providing the at least one first target operation data to a plurality of calculators as a multiple of a second matrix dimension of a second matrix to determine a plurality of first multiplication coefficients corresponding one-to-one to the plurality of calculators, and providing the at least one second target operation data to a plurality of calculators as a multiple of a first matrix dimension of a first matrix to determine a plurality of second multiplication coefficients corresponding one-to-one to the plurality of calculators, wherein the first matrix dimension and the second matrix dimension are both positive integers, and the type of the first matrix dimension and the type of the second matrix dimension are different.

[0019] At least one embodiment of the present disclosure provides a data processing device, including a processor and a storage medium for storing computer-executable instructions, the computer-executable instructions, when executed by the processor, realizing a data processing method according to at least one embodiment of the present disclosure.

[0020] At least one embodiment of the present disclosure provides a computer-readable storage medium for non-transitory storage of computer-executable instructions, which, when executed by a processor, implement a data processing method according to at least one embodiment of the present disclosure.

[0021] In order to more clearly describe the technical solutions of the embodiments of the present disclosure, the drawings of the embodiments are briefly described below. Obviously, the drawings described below are only related to some embodiments of the present disclosure, and are not intended to limit the present disclosure. [Brief description of the drawings]

[0022] [Figure 1] FIG. 1 is a schematic flowchart of a data processing method for matrix calculation according to an embodiment of the present disclosure. [Diagram 2] FIG. 2 is a schematic diagram of the correspondence between threads that perform matrix operations and paths of vector registers according to an embodiment of the present disclosure. [Diagram 3] FIG. 3 is a schematic diagram of an example of data processing of a matrix operation according to an embodiment of the present disclosure. [Figure 4] FIG. 4 is a schematic block diagram of an example of a data processing device applied to a matrix operation according to an embodiment of the present disclosure. [Diagram 5] FIG. 5 is an operation schematic diagram of an exemplary data selection unit and a data broadcast unit for the second half of data processing according to an embodiment of the present disclosure. [Figure 6] FIG. 6 is a schematic diagram of a data processing device according to an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0023] In order to make the objectives, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions of the embodiments of the present disclosure will be described clearly and completely below with reference to the drawings of the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, but not all of the embodiments. Based on the described embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without requiring creative labor all belong to the protection scope of the present disclosure.

[0024] Unless otherwise defined, technical or scientific terms used in this disclosure have common meanings that can be understood by those skilled in the art. The terms "first", "second" and similar terms used in this disclosure do not indicate any order, number or importance, but are merely for distinguishing different components. Similar terms such as "include" or "comprise" mean that the element or member described before the term includes the element or member listed after the term, and their equivalents, and do not exclude other elements or members. Similar terms such as "connect" or "couple" are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly connected. "Top", "bottom", "left", "right", etc. are merely for expressing relative positional relationships, and when the absolute position of the objects being described changes, the relative positional relationships may change accordingly.

[0025] To keep the following description of the embodiments of the present disclosure clear and concise, the present disclosure omits detailed descriptions of some known features and components.

[0026] The SIMD structure processing unit of the GPU executes a matrix operation instruction to simultaneously control the execution of the same operation in multiple threads, realizing matrix reading, arithmetic operation, result storage, etc. For example, for a SIMD32 structure, the execution of one instruction can simultaneously control the operations executed in 32 threads, and each SIMD32 structure has a dedicated set of vector registers, and each vector register has 32 paths. Table 1 below shows a general-purpose matrix operation instruction, which is a conventional instruction used when performing matrix operation operations in a SIMD structure. The matrix operation instruction includes a source operand 1, a source operand 2, a source operand 3, a destination operand and an opcode, where the source operand 1 is used to indicate the address of a first vector register, the source operand 2 is used to indicate the address of a second vector register, the source operand 3 is used to indicate the address of a third vector register, the destination operand is used to indicate the address of a destination vector register for storing the matrix operation result, and the opcode is used to indicate a specific operation performed by the matrix operation instruction, i.e., the type of matrix operation instruction. For example, by setting the opcode in the matrix operation instruction to a corresponding value indicating a multiplication and addition operation, the matrix operation instruction becomes a matrix multiplication and addition instruction, and by setting the opcode in the matrix operation instruction to a corresponding value indicating a multiplication operation, the matrix operation instruction becomes a matrix operation instruction.

[0027] [Table 1]

[0028] For example, in the SIMD32 architecture, a matrix multiplication operation A*B is performed using a matrix operation instruction in the general-purpose matrix operation instruction format, where matrix A is a matrix with a size of 8*4, i.e., matrix A contains 8 rows and 4 columns of data, and the 4 columns are respectively column vectors A(:,1), A(:,2), A(:,3), and A(:,4), and each column vector contains 8 data, and matrix B is a matrix with a size of 4*4, i.e., matrix B contains 4 rows and 4 columns of data, and the 4 rows are respectively row vectors B(1,:), B(2,:), B(3,:), and B(4,:), and each row vector contains 4 data.

[0029] For the above matrix multiplication operation, a conventional technique is generally used in which data for matrices A and B is loaded one by one from a DDR (Double-Data-Rate Synchronous Dynamic Random-Access Memory, a type of internal memory) into a vector register via a cache (cache memory), and then read from the vector register and transferred to a calculator for operation. First, four column vectors A(:,1), A(:,2), A(:,3), A(:,4) of matrix A are respectively loaded into four vector registers (referred to as V0, V1, V2, and V3, respectively), and then four row vectors B(1,:), B(2,:), B(3,:), B(4,:) of matrix B are respectively loaded into four vector registers (referred to as V80, V81, V82, and V83, respectively), and for each operation, data corresponding to the first pass of vector registers V0, V1, V2, or V3, and data corresponding to the second pass of vector registers V80, V81, V82, or V83 are sent to corresponding calculators to perform multiplication operations. This operation process involves reading data from DDR multiple times, for example, the number of times data is read from DDR in this operation process is 8, which causes unnecessary data redundancy and additional power consumption.

[0030] At least one embodiment of the present disclosure provides a data processing method applied to matrix operation, comprising the steps of determining at least one first vector register in which a first matrix including a plurality of first operation data is stored, and at least one second vector register in which a second matrix including a plurality of second operation data is stored; obtaining first data selection information and second data selection information; selecting at least one first operation data from the plurality of first operation data based on the first data selection information to obtain at least one first target operation data; and assigning the at least one first target operation data to a second matrix dimension of the second matrix. and providing the at least one second target operation data to the plurality of calculators as a multiple of a first matrix dimension of the first matrix, to determine a plurality of first multiplication coefficients corresponding one-to-one to the plurality of calculators, wherein the first matrix dimension and the second matrix dimension are both positive integers, and the type of the first matrix dimension and the type of the second matrix dimension are different.

[0031] A data processing method for matrix operations according to an embodiment of the present disclosure fully utilizes the characteristics of matrices by selecting multiple first paths of a first vector register and selecting multiple second paths of a second vector register, and copying operation data corresponding to the selected first paths and the selected second paths to participate in the multiplication operation of the corresponding threads, thereby effectively multiplexing data between threads, reducing data redundancy between threads, greatly reducing the number of times data is read from DDR, and reducing power consumption.

[0032] In the embodiment of the present disclosure, in the matrix operation process, the matrix operation can be realized by selecting and copying the first operation data in the first matrix and selecting and copying the second operation data in the second matrix, so that in the process of reading data (e.g., the first operation data and the second operation data) from the DDR and writing it to the vector register, there is no need to copy the read data (e.g., the first operation data and the second operation data), thereby reducing the number of times data is read from the DDR (e.g., in some cases, all the first operation data in the first matrix can be read and written to the vector register in one data read process, and all the second operation data in the second matrix can be read and written to the vector register in one data read process), accelerating the speed of reading data from the DDR, saving the time of reading data from the DDR, saving power consumption, reducing or avoiding data redundancy caused by writing data to the vector register, reducing the memory space for storing the first operation data of the first matrix and the second operation data of the second matrix (e.g., reducing the number of vector registers for storing the first matrix and the second matrix), and saving memory space.

[0033] At least one embodiment of the present disclosure further provides a data processing device, a data processing apparatus, and a computer-readable storage medium corresponding to the above data processing method.

[0034] Hereinafter, the embodiments of the present disclosure will be further described with reference to the drawings.

[0035] 1 shows a schematic flow chart of a data processing method 100 for matrix operation according to an embodiment of the present disclosure. For example, the matrix operation is used to realize an operation on a first matrix and a second matrix.

[0036] As shown in FIG. 1, a data processing method 100 according to an embodiment of the present disclosure includes steps S101 to S104.

[0037] Step S101: determining at least one first vector register in which a first matrix including a plurality of first operation data is stored, and at least one second vector register in which a second matrix including a plurality of second operation data is stored.

[0038] Step S102: obtaining first data selection information and second data selection information.

[0039] Step S103: based on the first data selection information, select at least one first operation data from the multiple first operation data to obtain at least one first target operation data, and provide the at least one first target operation data to multiple calculators using a second matrix dimension of the second matrix as a multiple to determine multiple first multiplication coefficients that correspond one-to-one to the multiple calculators.

[0040] Step S104: based on the second data selection information, select at least one second operation data from the multiple second operation data to obtain at least one second target operation data, and provide the at least one second target operation data to multiple calculators using a first matrix dimension of the first matrix as a multiple to determine multiple second multiplication coefficients that correspond one-to-one to the multiple calculators.

[0041] For example, the first matrix dimension and the second matrix dimension are both positive integers, and the type of the first matrix dimension and the type of the second matrix dimension are different.

[0042] The first matrix dimension represents the number of rows in the matrix, and the second matrix dimension represents the number of columns in the matrix. For example, a matrix is ​​an 8*4 matrix, that is, the first matrix dimension of the matrix is ​​8, and the second matrix dimension of the matrix is ​​4.

[0043] In the embodiment of the present disclosure, based on the characteristics of the matrix operation itself, different selective copy operations are performed on the first operation data in the first matrix and the second operation data in the second matrix, that is, at least one first target operation data is copied as a multiple of the second matrix dimension of the second matrix, and at least one second target operation data is copied as a multiple of the first matrix dimension of the first matrix, so that the copied data fulfills the realization process of the matrix operation.

[0044] In addition, in the matrix operation process, the first operation data in the first matrix can be selected and copied according to the characteristics of the matrix operation, and the second operation data in the second matrix can also be selected and copied, so that the first operation data and the second operation data stored in the vector register are not restricted by the matrix operation, and the storage process and storage position of the first operation data and the second operation data are more flexible and changeable, and data redundancy can be avoided.

[0045] According to an embodiment of the present disclosure, step S101 includes: obtaining at least one first address and at least one second address; determining at least one first vector register based on the at least one first address; and determining at least one second vector register based on the at least one second address, where the first address or the second address may be an index of the first vector register or the second vector register among all registers corresponding to the SIMD structure processing unit.

[0046] According to an embodiment of the present disclosure, the step of obtaining at least one first address and at least one second address includes the steps of obtaining a matrix operation instruction, and analyzing the matrix operation instruction to obtain the at least one first address and the at least one second address.

[0047] For example, the at least one first address represents an address of at least one first vector register in which a first matrix is ​​stored, and the at least one second address represents an address of at least one second vector register in which a second matrix is ​​stored, and the at least one first vector register can be determined based on the at least one first address, and the at least one second vector register can be determined based on the at least one second address. A matrix operation instruction can be obtained from a memory (such as a DDR). In some embodiments of the present disclosure, the format of the matrix operation instruction is shown in Table 2 below, and the matrix operation instruction can include a source operand 1, a source operand 2, a source operand 3, a destination operand, an opcode, and a control domain, and the meanings of the source operand 1, the source operand 2, the source operand 3, the destination operand, and the opcode are the same as those of each part of the matrix operation instruction shown in Table 1 above, and detailed description thereof will be omitted here. The control domain will be described in detail later. For example, in step S101, at least one first address and at least one second address can be obtained based on a source operand 1 and a source operand 2 by analyzing the matrix operation instruction.

[0048] [Table 2]

[0049] For example, the first matrix may be stored in at least one first vector register, and the second matrix may be stored in at least one second vector register. At least one first vector register has multiple first paths, and at least one second vector register has multiple second paths, and in some examples, the first vector register and the second vector register have the same number of paths, and the first operation data of the first matrix corresponds to the first path of the first vector register, i.e., the first path of the first vector register can transmit the corresponding first operation data, and the second operation data of the second matrix corresponds to the second path of the second vector register, i.e., the second path of the second vector register can transmit the corresponding second operation data. For example, for a SIMD32 structure, the first vector register has 32 first paths, and the second vector register has 32 second paths, so that the first vector register or the second vector register can simultaneously provide up to 32 data in the stored matrix to participate in the operation. In other examples, the number of first paths of the first vector register and the number of second paths of the second vector register may be different.

[0050] For example, for matrix multiplication A*B, matrix A is an example of a first matrix, the size of matrix A is 8*4, matrix A includes four column vectors A(:,1), A(:,2), A(:,3), A(:,4), each column vector includes eight data, matrix B is an example of a second matrix, the size of matrix B is 4*4, matrix B includes four row vectors B(1,:), B(2,:), B(3,:), B(4,:), each row vector includes four data. The 32 data of matrix A are a plurality of first operation data, and the 16 data of matrix B are a plurality of second operation data. Assuming that each data in matrix A and matrix B includes 32 bits (bit, binary digit), and each vector register (first vector register or second vector register) is a vector register capable of storing 32 32-bit scalar elements, then the 32 data of matrix A can be stored in one first vector register, and the 16 data of matrix B can be stored in one second vector register. The 32 first paths 0 to 31 of the first vector register in which matrix A is stored correspond to the 32 data of matrix A, respectively. For example, first paths 0 to 7 correspond to the 8 data of column vector A(:,1), first paths 8 to 15 correspond to the 8 data of column vector A(:,2), first paths 16 to 23 correspond to the 8 data of column vector A(:,3), and first paths 24 to 31 correspond to the 8 data of column vector A(:,4), and the 32 first paths 0 to 31 of the second vector register in which matrix B is stored correspond to the 32 data of matrix A, respectively. The first 16 passes of the second passes correspond to 16 data of the matrix B, for example, the second passes 0 to 3 correspond to the four data of the row vector B(1,:), the second passes 4 to 7 correspond to the four data of the row vector B(2,:), the second passes 8 to 11 correspond to the four data of the row vector B(3,:), and the second passes 12 to 15 correspond to the four data of the row vector B(4,:), and the other second passes in the second vector register do not correspond to any data in the matrix B. As needs to be explained, when the matrix B includes 32 data, the 32 second passes of the second vector register in which the matrix B is stored correspond to the 32 data of the matrix B, respectively.

[0051] For example, when the number of data contained in matrix A is greater than 32, the data of matrix A can be stored in multiple first vector registers, and when the number of data contained in matrix B is greater than 32, the data of matrix B can be stored in multiple second vector registers.

[0052] This disclosure describes an example in which each data in matrix A and matrix B includes 32 bits (binary digits) and each vector register (first vector register or second vector register) is a vector register capable of storing 32 32-bit scalar elements, but the embodiments of this disclosure are not limited to this.

[0053] In step S102, first data selection information and second data selection information can be obtained.

[0054] For example, in some embodiments, a data selection command can be obtained from a memory (such as a DDR), the data selection command includes a first data selection information and a second data selection information, and the first data selection information and the second data selection information can be obtained by analyzing the data selection command. The data selection command is shown in Table 3 below. For example, the data selection command may further include a reserved field (set by a user according to actual circumstances) for realizing other functions.

[0055] [Table 3]

[0056] For example, in some other embodiments, a matrix operation instruction can be obtained from a memory (such as a DDR), and the first data selection information and the second data selection information can be obtained by analyzing the matrix operation instruction. According to the embodiments of the present disclosure, the matrix operation instruction is shown in Table 2, and Table 2 is based on the matrix operation instruction shown in Table 1 and adds a control domain, and the control domain includes instruction fields SRC1_SVF_MODE and SRC2_SVF_MODE, where SRC1_SVF_MODE is the first data selection information, which is used to operate the first operation data in the first matrix to guide the selection and copying of data participating in the operation in the first matrix during the matrix operation process, and SRC2_SVF_MODE is the second data selection information, which is used to operate the second operation data in the second matrix to guide the selection and copying of data participating in the operation in the second matrix during the matrix operation process.

[0057] According to the embodiment of the present disclosure, the matrix operation instruction and the data selection instruction may be two instructions, or may be two parts of one instruction. For example, when the matrix operation instruction and the data selection instruction are two instructions, obtaining the first data selection information and the second data selection information may include obtaining the data selection instruction and analyzing the data selection instruction to obtain the first data selection information and the second data selection information, and when the matrix operation instruction and the data selection instruction are two parts of one instruction, obtaining the first data selection information and the second data selection information may include obtaining and analyzing the matrix operation instruction to obtain the first data selection information and the second data selection information. In the following description, it is taken as an example that the matrix operation instruction and the data selection instruction are two parts of one instruction, and for example, the matrix operation instruction and the data selection instruction may be two parts of the same SIMD instruction, that is, the SIMD instruction includes a matrix operation instruction and a data selection instruction.

[0058] For example, in some embodiments, a SIMD instruction may be 64 bits in length, of which the first 48 bits [0:47] are a matrix operation instruction portion, with definitions and associated descriptions of each field in the matrix operation instruction set forth in Table 4, and the following 16 bits [48:63] are a data selection instruction portion, with definitions and associated descriptions of each field in the data selection instruction set forth in Table 5.

[0059] Referring to Table 4, in the matrix operation instruction portion of the SIMD instruction, bits 0 to 7 [0:7] are a source operand 1 field, which may indicate an address of at least one first vector register in which a first matrix is ​​stored. bits 8 to 15 [8:15] are a source operand 2 field, which may indicate an address of at least one second vector register in which a second matrix is ​​stored. bits 16 to 23 [16:23] are a source operand 3 field, which may indicate an address of at least one third vector register in which a third matrix is ​​stored. The third matrix is ​​an initial matrix of a matrix multiply-add operation, for example, for a matrix multiply-add operation A*B+C, the first matrix is ​​matrix A, the second matrix is ​​matrix B, and the third matrix is ​​matrix C. bits 24 to 31 [24:31] are a destination operand field, which may indicate an address of a destination vector register in which a matrix operation result is stored. As should be explained, in some embodiments, the third vector register and the destination vector register may be the same. Bits 32 to 47 [32:47] are an opcode field, and the opcode field may include a number of specified values. For example, an opcode of 0 indicates that a multiplication operation is to be performed, and the matrix operation instruction is a matrix multiplication instruction, and an opcode of 1 indicates that a multiply-and-add operation is to be performed, and the matrix operation instruction is a matrix multiply-and-add instruction.

[0060] [Table 4]

[0061] Referring to Table 5, in the data selection instruction portion of this SIMD instruction, bits 48 to 52 [48:52] are the SRC2_SVF_MODE field, bits 53 to 57 are the SRC1_SVF_MODE field, and the 5-bit length SRC1_SVF_MODE / SRC2_SVF_MODE can be used to indicate a data copy operation between multiple threads. The remaining bits [63:58] are reserved fields for the data selection instruction and can be reserved for later implementation of other operations. The number of bits of SRC1_SVF_MODE and SRC2_SVF_MODE is not limited to 5 bits, and the number of bits of SRC1_SVF_MODE and SRC2_SVF_MODE can be determined according to the size of the matrix. As needed to be explained, Table 5 takes as an example that P is 4, that is, the P operator groups (described later) are respectively a first operator group, a second operator group, a third operator group and a fourth operator group, and each operator group includes 8 operators. However, it should be understood that Table 5 is only schematic, and the specific meanings of SRC1_SVF_MODE and SRC2_SVF_MODE can be designed according to actual situations, and the present disclosure does not specifically limit the same.

[0062] [Table 5]

[0063] FIG. 2 illustrates a schematic diagram of the correspondence between threads performing matrix operations and paths of vector registers according to an embodiment of the present disclosure.

[0064] According to an embodiment of the present disclosure, the matrix operation includes a plurality of threads, the plurality of computing units respectively correspond to the plurality of threads, each thread of the plurality of threads respectively corresponds to a corresponding first path among the plurality of first paths and a corresponding second path among the plurality of second paths, the plurality of first operation data correspond to the plurality of first paths, and the plurality of second operation data correspond to the plurality of second paths.

[0065] 2, in some embodiments, matrix A is an example of a first matrix, matrix B is an example of a second matrix, and the matrix operation includes 32 threads, i.e., threads 0 to 31, where, for example, thread 0 corresponds to path 0 (an example of a first path) of the first vector register and path 0 (an example of a second path) of the second vector register, and thread 1 corresponds to path 1 of the first vector register and path 1 of the second vector register. As is necessary to explain, in FIG. 2, paths 0 to 31 of the first vector register are represented by lines with arrows pointing from the first vector register to selector A in FIG. 2, and paths 0 to 15 of the second vector register are represented by lines with arrows pointing from the second vector register to selector B in FIG. 2.

[0066] Next, returning to FIG. 1, in step S103, the step of selecting at least one first operation data from the multiple first operation data based on the first data selection information and obtaining at least one first target operation data includes a step of determining at least one first path selected from the multiple first paths based on the first data selection information, and using at least one first operation data corresponding to the selected at least one first path as at least one first target operation data.

[0067] For example, in some embodiments, the first matrix is ​​a vertical matrix, that is, data located in the same column in the first matrix are stored consecutively in the internal memory, and at least one first target operation data may be located in the same column of the first matrix. For example, all the first operation data located in the same column of the first matrix are all first target operation data, and at this time, selecting at least one first operation data from the multiple first operation data to obtain at least one first target operation data is selecting all the first operation data located in the same column of the first matrix. For example, if the first matrix is ​​an 8*4 matrix, the at least one first target operation data is the first operation data located in the first column, the second column, the third column, or the fourth column of the first matrix, and the number of the at least one first target operation data is 8.

[0068] In the embodiment of the present disclosure, due to the characteristics of the matrix operation itself, the selection logic for the first operation data in the first matrix and the selection logic for the second operation data in the second matrix are substantially different, for example, for the first matrix, the first operation data can be selected from the same column, and the selected first operation data can be data-copied as a multiple of the second matrix dimension of the second matrix, and for the second matrix, the second operation data can be selected from the same row, and the selected second operation data can be data-copied as a multiple of the first matrix dimension of the first matrix. In the hardware implementation, the hardware implementation required to select data in the same column of the matrix is ​​different from the hardware implementation required to select data in the same row of the matrix. For example, the first data selection information is SRC1_SVF_MODE, and at least one selected first path among the multiple first paths can be determined based on the value of SRC1_SVF_MODE. For example, as shown in Table 5 above, when SRC1_SVF_MODE=5'd0, paths 0 to 7 of at least one first vector register are used as at least one selected first path, eight first operation data corresponding to paths 0 to 7 of the first vector register are determined as eight first target operation data, and the eight first target operation data are copied to the first calculator group, the second calculator group, the third calculator group, and the fourth calculator group, respectively.

[0069] For example, according to an embodiment of the present disclosure, the at least one first vector register includes a first target vector register, and the at least one first target operation data is all stored in the first target vector register, i.e., the at least one first target operation data is stored in the same vector register (i.e., the first target vector register), for example, the above-mentioned eight first target operation data are all stored in the first target vector register.

[0070] According to an embodiment of the present disclosure, the at least one first target operation data includes M first target operation data, the multiple calculators include P calculator groups, each calculator group includes M calculators, and the second matrix dimension of the second matrix is ​​P, for example, P and M are both positive integers. In step S103, the step of providing the at least one first target operation data to the multiple calculators with the second matrix dimension of the second matrix as a multiple to determine multiple first multiplication coefficients corresponding one-to-one to the multiple calculators includes the steps of copying the M first target operation data to P parts to obtain P first target operation data groups, each first target operation data group including M first target operation data, and providing the P first target operation data groups to the P calculator groups respectively to determine multiple first multiplication coefficients, the M first multiplication coefficients corresponding to the M calculators of each calculator group being M first target operation data respectively.

[0071] For example, as shown in FIG. 2, the first matrix is ​​an 8*4 matrix A, the second matrix is ​​a 4*4 matrix B, the second matrix dimension of the second matrix is ​​4, and at least one first target operation data includes eight first target operation data, in this case, M is 8, and as shown in FIG. 2, the eight first target operation data may be data A(1,1) to A(8,1) in the first column of matrix A, and the multiple calculators include four calculator groups, in this case, P is 4, and each calculator group includes eight calculators. The eight first target operation data A(1,1)-A(8,1) are copied four times to obtain four first target operation data groups, each of which includes the eight first target operation data A(1,1)-A(8,1), and the four first target operation data groups are provided to four calculator groups respectively to determine a plurality of first multiplication coefficients, the plurality of first multiplication coefficients being 32 data in the four first target operation data groups. Each calculator group corresponds to one first target operation data group, and the eight first multiplication coefficients corresponding to the eight calculators in each calculator group are the eight first target operation data A(1,1)-A(8,1) in the corresponding first target operation data group.

[0072] In step S104, based on the second data selection information, at least one second operation data is selected from the multiple second operation data to obtain at least one second target operation data, and the at least one second target operation data is provided to multiple calculators using a first matrix dimension of the first matrix as a multiple to determine multiple second multiplication coefficients that correspond one-to-one to the multiple calculators.

[0073] In step S104, the step of selecting at least one second operation data from the multiple second operation data and obtaining at least one second target operation data includes a step of determining at least one second path selected from the multiple second paths based on the second data selection information, and using at least one second operation data corresponding to the selected at least one second path as at least one second target operation data.

[0074] For example, in some embodiments, the second matrix is ​​a horizontal matrix, that is, data located in the same row in the second matrix are stored consecutively in the internal memory, and at least one second target operation data may be located in the same row of the second matrix. For example, all the second operation data located in the same row of the second matrix are second target operation data, and in this case, selecting at least one second operation data from the multiple second operation data to obtain at least one second target operation data is selecting all the second operation data located in the same row of the second matrix. For example, if the second matrix is ​​a 4*4 matrix, the at least one second target operation data is the second operation data located in the first row, the second row, the third row, or the fourth row of the second matrix, and the number of the at least one second target operation data is four.

[0075] For example, the second data selection information is SRC2_SVF_MODE, and at least one selected second path among the multiple second paths can be determined based on the value of SRC2_SVF_MODE. For example, as shown in Table 5 above, when SRC2_SVF_MODE=5'd0, paths 0 to 3 of at least one second vector register are used as at least one selected second path, four second operation data corresponding to paths 0 to 3 of the second vector register are determined as four second target operation data, the second target operation data corresponding to path 0 of the second vector register is copied to the first computing unit group, the second target operation data corresponding to path 1 of the second vector register is copied to the second computing unit group, the second target operation data corresponding to path 2 of the second vector register is copied to the third computing unit group, and the second target operation data corresponding to path 3 of the second vector register is copied to the fourth computing unit group.

[0076] For example, according to an embodiment of the present disclosure, the at least one second vector register includes a second target vector register, and the at least one second target operation data is all stored in the second target vector register, i.e., the at least one second target operation data is stored in the same vector register (i.e., the second target vector register), for example, the four second target operation data determined above are all stored in the second target vector register.

[0077] According to an embodiment of the present disclosure, the at least one second target operation data includes P second target operation data, the multiple calculators include P calculator groups, each calculator group includes M calculators, a first matrix dimension of the first matrix is ​​M, and M and P are both positive integers, and in step S104, the step of providing the at least one second target operation data to the multiple calculators using the first matrix dimension of the first matrix as a multiple to determine a plurality of second multiplication coefficients corresponding one-to-one to the multiple calculators includes: a step of copying the P second target operation data to M parts to obtain P second target operation data groups, each second target operation data group corresponding to one second target operation data and including the same M second target operation data; and a step of providing the P second target operation data groups to the P calculator groups respectively to determine a plurality of second multiplication coefficients, the M second multiplication coefficients corresponding to the M calculators in each calculator group are the same, and are second target operation data in the second target operation data group corresponding to each calculator group.

[0078] For example, as shown in Fig. 2, when the first matrix is ​​an 8*4 matrix A and the second matrix is ​​a 4*4 matrix B, the first matrix dimension of the first matrix is ​​8, and at least one second target operation data includes four second target operation data, and the four second target operation data may be the data B(1,1)-B(1,4) in the first row of the matrix B, and the multiple calculators include four calculator groups, and each calculator group includes eight calculators. The four second target operation data B(1,1)-B(1,4) are copied eight times respectively to obtain four second target operation data groups, and each second target operation data group corresponds to one second target operation data and includes the same eight second target operation data, and the four second target operation data groups are provided to the four calculator groups respectively to determine multiple second multiplication coefficients, and the multiple second multiplication coefficients are 32 data in the four second target operation data groups. Each operator group corresponds to one second target operation data group, and the eight second multiplication coefficients corresponding to the eight operators in each operator group are the same, and are second target operation data in the second target operation data group corresponding to each operator group.

[0079] For example, as shown in FIG. 2, paths 0 to 31 corresponding to selector A (paths 0 to 31 corresponding to selector A are represented by lines with arrows pointing from selector A to the arithmetic unit in FIG. 2) correspond to threads 0 to 31, respectively, and paths 0 to 31 corresponding to selector B (paths 0 to 31 corresponding to selector B are represented by lines with arrows pointing from selector B to the arithmetic unit in FIG. 2) also correspond to threads 0 to 31, respectively. Paths 0 to 7 of the first vector register corresponding to threads 0 to 7 are the eight first operation data A(1,1), A(2,1), ..., A(8,1) of column vector A(:,1) in matrix A, and in some examples, the eight first operation data A(1,1), A(2,1), ..., A(8,1) of column vector A(:,1) in matrix A are used as first target operation data, and the first operation data A(1,1), A(2,1), ..., A(8,1) corresponding to paths 0 to 7 of the first vector register are paths 0 to 7 corresponding to selector A, and paths 8 to 7 corresponding to selector A, respectively. By copying to paths 15, 16 to 23 corresponding to selector A, and paths 24 to 31 corresponding to selector A, the data corresponding to threads 0 to 7 are A(1,1), A(2,1), ..., A(8,1), the data corresponding to threads 8 to 15 are A(1,1), A(2,1), ..., A(8,1), the data corresponding to threads 16 to 23 are A(1,1), A(2,1), ..., A(8,1), and the data corresponding to threads 24 to 31 are A(1,1), A(2,1), ..., A(8,1). The data transmitted on the path corresponding to selector A is the first multiplication coefficient.Paths 0 to 3 of the second vector register corresponding to threads 0 to 3 correspond to the four second operation data B(1,1), B(1,2), B(1,3), and B(1,4) of row vector B(1,:) of matrix B, and in some examples, the four second operation data B(1,1), B(1,2), B(1,3), and B(1,4) of row vector B(1,:) of matrix B are used as second target operation data, and the second operation data B(1,1) corresponding to path 0 of the second vector register is copied to paths 0 to 7 corresponding to selector B, and the second operation data B(1,2) corresponding to path 1 of the second vector register is copied to paths 1 to 7 corresponding to selector B. The second operation data B(1,3) corresponding to the path 2 of the second vector register is copied to the path 8 to the path 15 corresponding to the selector B, the second operation data B(1,3) corresponding to the path 2 of the second vector register is copied to the path 16 to the path 23 corresponding to the selector B, and the second operation data B(1,4) corresponding to the path 3 of the second vector register is copied to the path 24 to the path 31 corresponding to the selector B. Thus, all the data corresponding to the threads 0 to 7 are B(1,1), all the data corresponding to the threads 8 to 15 are B(1,2), all the data corresponding to the threads 16 to 23 are B(1,3), and all the data corresponding to the threads 24 to 31 are B(1,4). The data transmitted on the path corresponding to the selector B is the second multiplication coefficient. The above describes the data copy operation during the matrix calculation by taking the first column of the matrix A and the first row of the matrix B as an example, and the other columns of the matrix A and the other rows of the matrix B are similar to this example, and detailed description is omitted here.

[0080] In addition to steps S101 to S104, as shown in FIG. 1, the data processing method according to the embodiment of the present disclosure further includes steps S105 to S107.

[0081] Step S105: determining at least one destination vector register.

[0082] For example, a matrix operation instruction can be obtained from a memory (such as a DDR), the matrix operation instruction can be analyzed to obtain an address of at least one destination vector register, and the at least one destination vector register can be determined based on the address of the at least one destination vector register.

[0083] Step S106: based on the plurality of first multiplication coefficients and the plurality of second multiplication coefficients, a multiplication operation is performed by a plurality of arithmetic units to obtain a plurality of multiplication operation results corresponding to the plurality of arithmetic units, each arithmetic unit being used to perform a multiplication operation on the corresponding first multiplication coefficients and second multiplication coefficients to obtain a multiplication operation result corresponding to each arithmetic unit.

[0084] For example, the first matrix is ​​an 8*4 matrix, the second matrix is ​​a 4*4 matrix, and a plurality of first multiplication coefficients and a plurality of second multiplication coefficients are determined according to step S103 and step S104. In this embodiment, the first target operation data are eight first operation data located in the same column of the first matrix, and the second target operation data are four second operation data located in the same row of the second matrix. The eight first target operation data are copied by multiplying the second matrix dimension (i.e., 4) of the second matrix to obtain 32 first multiplication coefficients, and the 32 first multiplication coefficients are provided to the 32 calculators respectively, and the 32 first multiplication coefficients correspond one-to-one to the 32 calculators; the four second target operation data are copied by multiplying the first matrix dimension (i.e., 8) of the first matrix to obtain 32 second multiplication coefficients, and the 32 second multiplication coefficients are provided to the 32 calculators respectively, and the 32 second multiplication coefficients correspond one-to-one to the 32 calculators. Each calculator corresponds to one first multiplication coefficient and one second multiplication coefficient, and performs a multiplication operation on the first multiplication coefficient and the second multiplication coefficient to obtain a multiplication operation result.

[0085] For example, as shown in FIG. 2, for matrix multiplication A*B=C, the first matrix is ​​a matrix A of 8*4, the second matrix is ​​a matrix B of 4*4, and the result matrix C is a matrix of 8*4. The multiple calculators include calculators 0 to 31 (only calculators 0, 1, 24, and 31 are shown in FIG. 2), and each calculator includes a multiplier for performing a multiplication operation. Calculator 0 corresponds to path 0 of selector A and path 0 of selector B, and calculator 0 is used to perform a multiplication operation on the first multiplication coefficient transmitted on path 0 of selector A and the second multiplication coefficient transmitted on path 0 of selector B to obtain a multiplication operation result C(1,1) corresponding to calculator 0, and calculator 1 corresponds to path 1 of selector A and path 1 of selector B, and calculator 1 is used to perform a multiplication operation on the first multiplication coefficient transmitted on path 1 of selector A and the second multiplication coefficient transmitted on path 1 of selector B to obtain a multiplication operation result C(2,1) corresponding to calculator 1. In FIG. 2, the multiplication result C(1,4) corresponding to the calculator 24 in the result matrix C and the multiplication result C(8,4) corresponding to the calculator 31 are also shown.

[0086] According to an embodiment of the present disclosure, multiple computing units perform multiplication operations in parallel, for example, 32 computing units perform multiplication operations simultaneously.

[0087] Step S107: sending the multiple multiplication operation results to at least one destination vector register.

[0088] For example, at least one destination vector register is used to store the results of multiple multiplication operations.

[0089] According to an embodiment of the present disclosure, step S107 includes a step of performing an addition operation by matching the multiple multiplication operation results with the multiple storage data stored in at least one destination vector register in a one-to-one manner to obtain multiple addition operation results, and a step of storing the multiple addition operation results in at least one destination vector register.

[0090] For example, the first matrix is ​​an 8*4 matrix, the second matrix is ​​a 4*4 matrix, and the first matrix and the second matrix are multiplied to obtain a result matrix, which is an 8*4 matrix. The eight data in the first column of the first matrix are respectively multiplied with the first data in the first row of the second matrix to obtain a set of eight multiplication operation results, and the eight data in the first column of the first matrix are respectively multiplied with the second data in the first row of the second matrix to obtain a set of eight multiplication operation results, thus multiplying the first column of the first matrix with the first row of the second matrix to obtain four sets of multiplication operation results, each set of multiplication operation results includes eight multiplication operation results, and these four sets of multiplication operation results (a total of 32 multiplication operation results) are sent to the destination vector register and stored in the destination vector register as storage data. Then, the 32 multiplication results obtained by multiplying the second column of the first matrix by the second row of the second matrix are sent to the destination vector register, and addition operations are performed in one-to-one correspondence with the 32 storage data previously stored in the destination vector register (for example, the 32 multiplication results obtained by multiplying the first column of the first matrix by the first row of the second matrix), to obtain 32 addition results, which are stored in the destination vector register as updated 32 storage data. In this way, the 32 multiplication results obtained by multiplying the fourth column of the first matrix by the fourth row of the second matrix are sent to the destination vector register, and addition operations are performed in one-to-one correspondence with the 32 storage data previously stored, to obtain 32 addition results, which are the final results and are stored in the destination vector register. As should be explained, the order in which the results of a multiplication operation performed by multiplying a column of a first matrix by a row of a second matrix are sent to a destination vector register is not unique; for example, the result of a multiplication operation performed by multiplying a first column of a first matrix by a first row of a second matrix may be sent to a destination vector register first or may be sent to a destination vector register last.

[0091] For example, at least one first data read instruction can be used to read first operational data of a first matrix from memory (e.g., internal memory) and write it to at least one first vector register, and at least one second data read instruction can be used to read second operational data of a second matrix from memory and write it to at least one second vector register.

[0092] For reading and writing the first operation data, and reading and writing the second operation data, the data processing method according to the embodiment of the present disclosure further includes the steps of obtaining at least one first data read instruction and at least one second data read instruction; analyzing the at least one first data read instruction to obtain at least one first read address and at least one first address; reading a plurality of first operation data from the memory based on the at least one first read address, and determining at least one first vector register based on the at least one first address, and writing the plurality of first operation data to the at least one first vector register; analyzing at least one second data read instruction to obtain at least one second read address and at least one second address; reading a plurality of second operation data from the memory based on the at least one second read address, and determining at least one second vector register based on the at least one second address, and writing the plurality of second operation data to the at least one second vector register.

[0093] For example, a first data read instruction and a second data read instruction can be obtained from a memory (such as a DDR). The first data read instruction includes a first read address and a first address, and the second data read instruction includes a second read address and a second address. The first read address indicates a storage location in the memory of the first operational data, and the second read address indicates a storage location in the memory of the second operational data. The first operational data and the second operational data can be read from the memory based on the first read address and the second read address. The first address indicates an address of a first vector register for storing the first operational data, and the second address indicates an address of a second vector register for storing the second operational data, and the first vector register and the second vector register can be determined based on the first address and the second address, and the first operational data can be written to the first vector register, and the second operational data can be written to the second vector register.

[0094] First, the entire first matrix is ​​read into the first vector register at one time, and the entire second matrix is ​​read into the second vector register at one time. Then, a plurality of first paths of the first vector register are selected, and a plurality of second paths of the second vector register are selected. The operation data corresponding to the selected first paths and the operation data corresponding to the selected second paths are copied to participate in the multiplication operation of the corresponding threads. Thus, the characteristics of the matrix are fully utilized, data is effectively multiplexed among threads, and the data redundancy among threads is reduced, so that the number of times data is read is greatly reduced, and power consumption is reduced.

[0095] FIG. 3 is a schematic diagram illustrating an example of data processing for a matrix operation according to an embodiment of the present disclosure.

[0096] As shown in FIG. 3, in this embodiment, the SIMD example is a SIMD32 structure, in which each first vector register includes 32 first paths, and each second vector register includes 32 second paths. In this structure, matrix multiplication A*B=C is performed, in which the first matrix is ​​an 8*4 matrix A, the second matrix is ​​a 4*4 matrix B, and correspondingly, the result matrix C is an 8*4 matrix. The general matrix algorithm of the related hardware is as follows: TIFF2024533746000007.tif22122

[0097] In this embodiment, the specific operations are as follows.

[0098] The first vector register has 32 first paths, and as shown in FIG. 2, paths 0 to 7 of the first vector register correspond to the eight data A(1,1), A(2,1), ..., A(8,1) of column vector A(:,1) of matrix A, paths 8 to 15 of the first vector register correspond to the eight data A(1,2), A(2,2), ..., A(8,2) of column vector A(:,2) of matrix A, paths 16 to 23 of the first vector register correspond to the eight data A(1,3), A(2,3), ..., A(8,3) of column vector A(:,3) of matrix A, and paths 24 to 31 of the first vector register correspond to the eight data A(1,4), A(2,4), ..., A(8,4) of column vector A(:,4) of matrix A. The second vector register has 32 second paths, and as shown in FIG. 2, paths 0 to 3 of the second vector register correspond to four data B(1,1), B(1,2), B(1,3), and B(1,4) of row vector B(1,:) of matrix B, and paths 4 to 7 (not shown in FIG. 2) of the second vector register correspond to four data B(2,1), B(2,2), and B(2, 2, paths 0 to 15 of the second vector register correspond to four data B(4,1), B(4,2), B(4,3), and B(4,4) of row vector B(3,:) of matrix B. As is necessary to explain, only paths 0 to 15 of the second vector register are shown in FIG. 2, and the remaining 16 paths of the second vector register (paths 16 to 31 of the second vector register) are not shown, but this does not indicate that they do not exist, and the data corresponding to the remaining 16 paths of the second vector register are set according to the actual situation.

[0099] Referring to Table 5, when SRC1_SVF_MODE=5'd0, the first operation data A(1,1), A(2,1), ..., A(8,1) are copied as the first target operation data to the selector A along paths 0 to 7, paths 8 to 15, paths 16 to 23, and paths 24 to 31 (in FIG. 3, this process is represented by a single solid arrow). In other words, the second matrix dimension 4 of the matrix B is multiplied to make four copies of the eight first target operation data. When SRC1_SVF_MODE=5'd1, A(1,2), A(2,2), ..., A(8,2) are copied as the first target operation data. When SRC1_SVF_MODE=5'd2, A(1,3), A(2,3), ..., A(8,3) are copied corresponding to paths 0 to 7, paths 8 to 15, paths 16 to 23, and paths 24 to 31 corresponding to selector A, and when SRC1_SVF_MODE=5'd3, A(1,4), A(2,4), ..., A(8,4) are copied corresponding to paths 0 to 7, paths 8 to 15, paths 6 to 23, and paths 24 to 31 corresponding to selector A.

[0100] When SRC2_SVF_MODE=5'd0, the second operation data B(1,1) is copied to paths 0 to 7 corresponding to selector B, the second operation data B(1,2) is copied to paths 8 to 15 corresponding to selector B, the second operation data B(1,3) is copied to paths 16 to 23 corresponding to selector B, and the second operation data B(1,4) is copied to paths 24 to 31 corresponding to selector B (in FIG. 3, this process is represented by a single solid arrow), and when SRC2_SVF_MODE=5'd1, the second operation data B(2,1), B(2,2), B(2,3), and B(2,4) are copied to paths 17 to 22 corresponding to selector B, respectively. When SRC2_SVF_MODE=5'd2, the second operation data B(3,1), B(3,2), B(3,3), B(3,4) are copied corresponding to paths 0 to 7, paths 8 to 15, paths 16 to 23, and paths 24 to 31 corresponding to selector B, respectively, and when SRC2_SVF_MODE=5'd3, the second operation data B(4,1), B(4,2), B(4,3), B(4,4) are copied corresponding to paths 0 to 7, paths 8 to 15, paths 16 to 23, and paths 24 to 31 corresponding to selector B, respectively.

[0101] When SRC1_SVF_MODE=5'd0 and SRC2_SVF_MODE=5'd0, data corresponding to the 32 first paths of the first target vector register and data corresponding to the 32 second paths of the second target vector register are correspondingly multiplied to obtain column vector C(:,1) of matrix C; thus, when SRC1_SVF_MODE=5'd1 and SRC2_SVF_MODE=5'd1, column vector C(:,2) of matrix C is obtained; when SRC1_SVF_MODE=5'd2 and SRC2_SVF_MODE=5'd2, column vector C(:,3) of matrix C is obtained; and when SRC1_SVF_MODE=5'd3 and SRC2_SVF_MODE=5'd3, column vector C(:,4) of matrix C is obtained.

[0102] Hereinafter, the specific operations of the data processing process for the matrix operation according to the embodiment of the present disclosure will be described in detail, for example, the matrix operation is used to realize the operation on the first matrix and the second matrix.

[0103] First, a first matrix for matrix operation is loaded into at least one first vector register, and a second matrix for matrix operation is loaded into at least one second vector register; then, based on first data selection information, at least one first operation data is selected from a plurality of first operation data stored in the at least one first vector register to obtain at least one first target operation data; based on second data selection information, at least one second operation data is selected from a plurality of second operation data stored in the at least one second vector register to obtain at least one second target operation data; then, based on a second data selection information, the at least one first target operation data is provided to a plurality of computing units using a second matrix dimension of the second matrix as a multiple to determine a plurality of first multiplication coefficients corresponding one-to-one to the plurality of computing units; and finally, the plurality of computing units perform multiplication operations on the plurality of first multiplication coefficients and the plurality of second multiplication coefficients to realize the matrix operation. In the above data processing process, the number of times data is read and stored can be reduced, for example, the number of times data is read and stored can be reduced to one, and the matrix operation of the first matrix and the second matrix can be completed with only one data read. For example, some editing commands of the above matrix operation are shown as follows:

[0104] vec_load_b32 v0, v_addr_0; vec_load_b32 v80, v_addr_1; vec_mul_u32 v100, v0, v80, SRC1_SVF_MODE=5'd0, SRC2_SVF_MODE=5'd0; vec_mul_u32 v101, v0, v80, SRC1_SVF_MODE=5'd1, SRC2_SVF_MODE=5'd1; vec_mul_u32 v102, v0, v80, SRC1_SVF_MODE=5'd2, SRC2_SVF_MODE=5'd2; vec_mul_u32 v103, v0, v80, SRC1_SVF_MODE=5'd3, SRC2_SVF_MODE=5'd3;

[0105] Specifically, in the above editing command, first, a single vec_load_b32 command is used to load matrix A from memory (address v_addr_0) into the first vector register v0, and a single vec_load_b32 command is used to load matrix B from memory (address v_addr_1) into the second vector register v80, and both the first vector register v0 and the second vector register v80 can store 32 pieces of data.

[0106] Then, matrix operations are performed on the data in the first vector register v0 and the second vector register v80. Specifically, for the instruction "vec_mul_u32 v100, v0, v80, SRC1_SVF_MODE=5'd0, SRC2_SVF_MODE=5'd0", vec_mul_u32 is an opcode and indicates a 32-bit multiplication operation, v0 indicates the address of the first vector register in which the first matrix A is stored, v80 indicates the address of the second vector register in which the second matrix B is stored, the first target operation data in the first matrix A and the second target operation data in the second matrix B are selected by setting the values ​​of SRC1_SVF_MODE and SRC2_SVF_MODE, and v100 / v101 / v102 / v103 indicate the addresses of the destination vector registers for storing the multiplication operation results, thereby realizing the matrix operation based on a single matrix read operation in the SIMD structure.

[0107] It is understood that the SIMD structure and the matrices participating in the multiplication operation are not limited to the above examples, and can be adjusted according to the actual situation by those skilled in the art, and will not be listed here one by one.

[0108] FIG. 4 is a schematic block diagram of an example of a data processing device 400 applied to a matrix operation according to an embodiment of the present disclosure.

[0109] As shown in FIG. 4 , a data processing device 400 applied to matrix operation according to an embodiment of the present disclosure may include a register determination unit 401, an information acquisition unit 402, a data selection unit 403, and a data broadcast unit 404.

[0110] The register determination unit 401 may be configured to determine at least one first vector register in which a first matrix including a plurality of first operation data is stored, and at least one second vector register in which a second matrix including a plurality of second operation data is stored. For example, the register determination unit 401 may obtain a matrix operation instruction from a memory (such as a DDR), analyze the matrix operation instruction, and obtain at least one first address indicating an address of the at least one first vector register and at least one second address indicating an address of the at least one second vector register, thereby determining the at least one first vector register and the at least one second vector register based on the at least one first address and the at least one second address.

[0111] The information acquiring unit 402 may be configured to acquire the first data selection information and the second data selection information. For example, the information acquiring unit 402 may acquire a data selection command from a memory (such as a DDR), where the data selection command includes the first data selection information and the second data selection information. The information acquiring unit 402 obtains the first data selection information and the second data selection information by analyzing the data selection command.

[0112] The data selection unit 403 may be configured to select at least one first operation data from the plurality of first operation data based on the first data selection information to obtain at least one first target operation data, and to select at least one second operation data from the plurality of second operation data based on the second data selection information to obtain at least one second target operation data. For example, the data selection unit 403 may include a first selector 4031 and a second selector 4032, where the first selector 4031 selects at least one first operation data from the at least one first operation data of the first matrix based on the first data selection information (e.g., SRC1_SVF_MODE) to obtain at least one first target operation data, and the second selector 4032 selects at least one second operation data from the at least one second operation data of the second matrix based on the second data selection information (e.g., SRC2_SVF_MODE) to obtain at least one second target operation data.

[0113] For example, the first selector 4031 and the second selector 4032 are both many-to-one selectors, and in the example shown in FIG. 5, the first selector 4031 may be the above-mentioned selector A, which may be a 32-to-8 selector, and the second selector 4032 may be the above-mentioned selector B, which may be a 32-to-4 selector.

[0114] The data broadcast unit 404 may be configured to provide at least one first target operation data as a multiple of a second matrix dimension of a second matrix to a plurality of calculators to determine a plurality of first multiplication coefficients corresponding one-to-one to the plurality of calculators, and to provide at least one second target operation data as a multiple of a first matrix dimension of a first matrix to a plurality of calculators to determine a plurality of second multiplication coefficients corresponding one-to-one to the plurality of calculators, where the first matrix dimension and the second matrix dimension are both positive integers, and the type of the first matrix dimension and the type of the second matrix dimension are different.

[0115] FIG. 5 illustrates an operation schematic diagram of an exemplary data selection unit 403 and a data broadcasting unit 404 for the latter half of data processing according to an embodiment of the present disclosure.

[0116] 5, the first vector register has 32 paths (i.e., path 0 to path 31 corresponding to the first vector register), and the 32 first operation data of the matrix A correspond to the 32 paths of the first vector register. The second vector register has 32 paths (i.e., path 0 to path 31 corresponding to the second vector register), and the 16 second operation data of the matrix B correspond to the first 16 paths of the second vector register. The data selection unit 403 passes the 32 first operation data of the matrix A (an example of the first matrix of the present disclosure) through one 32-to-8 selector A through the 32 paths of the first vector register based on the first data selection information SRC1_SVF_MODE and the second data selection information SRC2_SVF_MODE received from the information acquisition unit 402, and selects 8 first target operation data, and passes the 16 second operation data of the matrix B (an example of the second matrix of the present disclosure) through one 32-to-4 selector B through the 32 paths of the second vector register, and selects 4 second target operation data. Then, the data broadcast unit 404 copies the eight first target operation data to paths 0 to 7, paths 8 to 15, paths 16 to 23, and paths 24 to 31 corresponding to the selector A by multiplying the second matrix dimension 4 of the matrix B, and then provides the data transmitted on the 32 paths of the selector A to four multiplier groups (each multiplier group includes eight multipliers), and the data transmitted on the paths corresponding to the selector A is the above-mentioned first multiplication coefficient corresponding one-to-one to the 32 multipliers. The data broadcast unit 404 copies the four second target operation data to paths 0 to 7, paths 8 to 15, paths 16 to 23, and paths 24 to 31 corresponding to the selector B by multiplying the first matrix dimension 8 of the matrix A, and then provides the data transmitted on the 32 paths of the selector B to four multiplier groups, and the data transmitted on the paths corresponding to the selector B is the above-mentioned second multiplication coefficient corresponding one-to-one to the 32 multipliers.A matrix multiplication operation is performed on the first multiplication coefficient and the second multiplication coefficient in a multiplier to obtain four sets of multiplication operation results, each set of multiplication operation results including eight multiplication operation results, and the four sets of multiplication operation results (a total of 32 multiplication operation results) are sent to four adder groups respectively, and each adder group includes eight adders to realize an addition operation, and the eight multiplication operation results in each set of multiplication operation results are sent to the eight adders in one adder group as one addition coefficient. The four sets of multiplication operation results are respectively added to corresponding storage data in a destination vector register (as another addition coefficient of the adder) to obtain multiple addition operation results, and the multiple addition operation results are stored in at least one destination vector register as updated storage data.

[0117] For example, the register determining unit 401, the information obtaining unit 402, the data selecting unit 403, and the data broadcasting unit 404 may be implemented using hardware, software, firmware, and any feasible combination thereof.

[0118] For example, when performing the step of determining at least one first vector register in which the first matrix is ​​stored and at least one second vector register in which the second matrix is ​​stored, the register determination unit 401 may be configured to obtain at least one first address and at least one second address, determine the at least one first vector register based on the at least one first address, and determine the at least one second vector register based on the at least one second address.

[0119] For example, when performing the step of obtaining at least one first address and at least one second address, the register determination unit 401 may be configured to obtain a matrix operation instruction, analyze the matrix operation instruction, and obtain the at least one first address and the at least one second address.

[0120] For example, in some embodiments, when performing the step of obtaining the first data selection information and the second data selection information, the information obtaining unit 402 may be further configured to analyze the matrix operation instruction and obtain the first data selection information and the second data selection information.

[0121] For example, in some other embodiments, when performing the step of obtaining the first data selection information and the second data selection information, the information obtaining unit 402 may be configured to obtain a data selection instruction, parse the data selection instruction, and obtain the first data selection information and the second data selection information.

[0122] For example, in some embodiments, the data processing apparatus 400 further includes a data read and write unit, which may be configured to obtain at least one first data read instruction and at least one second data read instruction, analyze the at least one first data read instruction, obtain at least one first read address and at least one first address, read a plurality of first operation data from the memory based on the at least one first read address, determine at least one first vector register and write the plurality of first operation data to the at least one first vector register based on the at least one first address, analyze at least one second data read instruction, obtain at least one second read address and at least one second address, read a plurality of second operation data from the memory based on the at least one second read address, determine at least one second vector register and write the plurality of second operation data to the at least one second vector register based on the at least one second address.

[0123] For example, the matrix operation includes a plurality of threads, the plurality of operation units each corresponding to the plurality of threads, at least one first vector register has a plurality of first paths, at least one second vector register has a plurality of second paths, each thread of the plurality of threads corresponds to a corresponding first path among the plurality of first paths and a corresponding second path among the plurality of second paths, the plurality of first operation data corresponds to the plurality of first paths, and the plurality of second operation data corresponds to the plurality of second paths. When performing the step of selecting at least one first operation data from a plurality of first operation data based on the first data selection information and obtaining at least one first target operation data, the data selection unit 403 may be configured to determine at least one first path selected from a plurality of first paths based on the first data selection information and use at least one first operation data corresponding to the selected at least one first path as at least one first target operation data; when performing the step of selecting at least one second operation data from the plurality of second operation data based on the second data selection information and obtaining at least one second target operation data, the data selection unit 403 may be configured to determine at least one second path selected from a plurality of second paths based on the second data selection information and use at least one second operation data corresponding to the selected at least one second path as at least one second target operation data.

[0124] For example, in some embodiments, the data processing apparatus 400 may further include a data operation and write unit, which may be configured to determine at least one destination vector register, perform a multiplication operation by a plurality of arithmetic units based on a plurality of first multiplication coefficients and a plurality of second multiplication coefficients, obtain a plurality of multiplication operation results corresponding to the plurality of arithmetic units, each arithmetic unit being used to perform a multiplication operation on a corresponding first multiplication coefficient and a second multiplication coefficient, obtain a multiplication operation result corresponding to each arithmetic unit, and send the plurality of multiplication operation results to the at least one destination vector register.

[0125] For example, when performing the step of sending multiple multiplication operation results to at least one destination vector register, the data operation and writing unit may be configured to perform an addition operation in one-to-one correspondence between the multiple multiplication operation results and the multiple storage data stored in the at least one destination vector register to obtain multiple addition operation results, and store the multiple addition operation results in the at least one destination vector register.

[0126] For example, the at least one first target operation data includes M first target operation data, the plurality of operators includes P operator groups, each operator group includes M operators, and the second matrix dimension is P, where M and P are both positive integers. When performing the step of providing the at least one first target operation data to the plurality of operators with the second matrix dimension of the second matrix as a multiple to determine a plurality of first multiplication coefficients corresponding one-to-one to the plurality of operators, the data broadcasting unit 404 may be configured to: copy the M first target operation data to P parts to obtain P first target operation data groups, each first target operation data group including M first target operation data; provide the P first target operation data groups to the P operator groups respectively to determine a plurality of first multiplication coefficients, and the M first multiplication coefficients corresponding to the M operators of each operator group are M first target operation data respectively.

[0127] For example, the at least one second target operation data includes P second target operation data, the multiple operators include P operator groups, each operator group includes M operators, the first matrix dimension is M, and M and P are both positive integers. When performing the step of providing the at least one second target operation data to the multiple operators by multiplying the first matrix dimension of the first matrix to determine multiple second multiplication coefficients corresponding one-to-one to the multiple operators, the data broadcasting unit 404 may be configured to: copy the P second target operation data to M parts to obtain P second target operation data groups, each second target operation data group corresponds to one second target operation data and includes the same M second target operation data; provide the P second target operation data groups to the P operator groups respectively to determine multiple second multiplication coefficients, the M second multiplication coefficients corresponding to the M operators in each operator group are the same, and the second target operation data in the second target operation data group corresponding to each operator group.

[0128] For example, multiple arithmetic units perform multiplication operations in parallel.

[0129] For example, the at least one first vector register includes a first target vector register, and the at least one first target operation data is stored in the first target vector register, and the at least one second vector register includes a second target vector register, and the at least one second target operation data is stored in the second target vector register.

[0130] For example, the first matrix is ​​a vertical matrix, and at least one first target operation data is located in the same column of the first matrix, and the second matrix is ​​a horizontal matrix, and at least one second target operation data is located in the same row of the second matrix.

[0131] FIG. 6 shows a schematic diagram of a data processing device 600 according to an embodiment of the present disclosure.

[0132] As shown in FIG. 6, a data processing device 600 according to an embodiment of the present disclosure may include a processor 601 and a storage medium 602 that may be interconnected via a bus 603 .

[0133] The processor 601 can perform various operations and processes based on the program or code stored in the storage medium 602. Specifically, the processor 601 may be an integrated circuit chip and has a signal processing capability. The processor may be a general-purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The various methods, steps, processes, and logic block diagrams disclosed in the embodiments of the present disclosure can be realized or executed. The general-purpose processor may be a microprocessor, or the processor may be any ordinary processor, such as an X86 architecture or an ARM architecture.

[0134] The storage medium 602 stores computer-executable instructions, which when executed by the processor 601, implement a data processing method according to at least one embodiment of the present disclosure. The storage medium 602 may be volatile or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory may be read only memory (ROM), programmable read only memory (PROM), erasable programmable read only memory (EPROM), electrically erasable programmable read only memory (EEPROM), or flash memory. The volatile memory may be random access memory (RAM) acting as an external cache memory. By way of example and not of limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct Rambus random access memory (DRRAM). It should be noted that the memory of the methods described herein is intended to comprise, without being limited to, these and any other suitable types of memory.

[0135] An embodiment of the present disclosure further provides a computer-readable storage medium for non-transiently storing computer-executable instructions that, when executed by a processor, implement a data processing method according to at least one embodiment of the present disclosure. Similarly, the computer-readable storage medium of the embodiment of the present disclosure may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. For example, the computer-readable storage medium may be the storage medium 602 described above. It should be noted that the memory of the methods described herein is intended to include, without being limited to, these and any other suitable types of memory.

[0136] An embodiment of the present disclosure further provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium, a processor of a computing device reading the computer instructions from the computer-readable storage medium, and the processor executing the computer instructions, causing the computing device to perform a data processing method according to an embodiment of the present disclosure.

[0137] The following points need to be explained regarding this disclosure.

[0138] (1) The drawings of the embodiments of the present disclosure only relate to the structures of the embodiments of the present disclosure, and other structures may refer to conventional designs.

[0139] (2) For clarity, the thickness and size of layers or structures are exaggerated in the drawings to illustrate the embodiments of the present invention. As will be understood, when an element such as a layer, film, region, or circuit board is described as being located "on" or "under" another element, the element may be located "directly" on or "under" the other element, or there may be intermediate elements.

[0140] (3) Where no contradiction exists, the embodiments and features of the embodiments of the present disclosure may be combined with each other to obtain new embodiments.

[0141] The above are merely specific embodiments of the present disclosure, but the scope of protection of the present disclosure is not limited thereto, and should be consistent with the scope of protection of the claims.

Claims

1. A data processing method applied to matrix operations, determining at least one first vector register in which a first matrix including a plurality of first operational data is stored, and at least one second vector register in which a second matrix including a plurality of second operational data is stored; obtaining first data selection information and second data selection information; selecting at least one first operation data from the plurality of first operation data according to the first data selection information to obtain at least one first target operation data, and providing the at least one first target operation data to a plurality of calculators by data copying the at least one first target operation data as a multiple of a second matrix dimension of the second matrix, thereby determining a plurality of first multiplication coefficients corresponding one-to-one to the plurality of calculators; selecting at least one second operation data from the plurality of second operation data based on the second data selection information to obtain at least one second target operation data, and providing the at least one second target operation data to the plurality of calculators by data copying the at least one second target operation data as a multiple of a first matrix dimension of the first matrix, thereby determining a plurality of second multiplication coefficients corresponding one-to-one to the plurality of calculators; A data processing method, wherein the first matrix dimension and the second matrix dimension are both positive integers, and the first matrix dimension and the second matrix dimension have different types.

2. The at least one first target operation data includes M first target operation data, the plurality of operators includes P operator groups, each operator group includes M operators, the second matrix dimension is P, M and P are both positive integers; The step of providing the at least one first target operation data to a plurality of calculators by copying the data of the at least one first target operation data as a multiple of a second matrix dimension of the second matrix to determine a plurality of first multiplication coefficients corresponding one-to-one to the plurality of calculators, a step of copying the M number of first target operation data to P number of first target operation data groups, each first target operation data group including the M number of first target operation data; 2. The data processing method according to claim 1, further comprising: a step of providing the P first target operation data groups to the P computing unit groups, respectively, to determine the plurality of first multiplication coefficients, M first multiplication coefficients corresponding to the M computing units of each computing unit group being the M first target operation data, respectively.

3. The at least one second target operation data includes P second target operation data, the plurality of operators includes P operator groups, each operator group includes M operators, the first matrix dimension is M, M and P are both positive integers; The step of providing the at least one second target operation data to the plurality of calculators by copying the data of the at least one second target operation data as a multiple of a first matrix dimension of the first matrix to determine a plurality of second multiplication coefficients corresponding one-to-one to the plurality of calculators, a step of copying the P number of second target operation data to M copies to obtain P number of second target operation data groups, each second target operation data group corresponding to one second target operation data and including the same M number of the second target operation data; 2. The data processing method according to claim 1, further comprising: a step of providing the P second target operation data groups to the P computing unit groups, respectively, to determine the plurality of second multiplication coefficients, wherein the M second multiplication coefficients corresponding to the M computing units in each computing unit group are the same, and are second target operation data in the second target operation data group corresponding to each computing unit group.

4. the matrix operation includes a plurality of threads, the plurality of operation units respectively corresponding to the plurality of threads, the at least one first vector register has a plurality of first paths, the at least one second vector register has a plurality of second paths, each thread of the plurality of threads respectively corresponding to a corresponding first path of the plurality of first paths and a corresponding second path of the plurality of second paths, the plurality of first operation data correspond to the plurality of first paths, and the plurality of second operation data correspond to the plurality of second paths, The step of selecting at least one first operation data from the plurality of first operation data based on the first data selection information to obtain at least one first target operation data includes: determining at least one selected first path among the plurality of first paths based on the first data selection information, and using at least one first operation data corresponding to the selected at least one first path as the at least one first target operation data; The step of selecting at least one second operation data from the plurality of second operation data based on the second data selection information to obtain at least one second target operation data includes: The data processing method according to any one of claims 1 to 3, further comprising a step of determining at least one selected second path from among the plurality of second paths based on the second data selection information, and using at least one second operation data corresponding to the selected at least one second path as the at least one second target operation data.

5. determining at least one destination vector register; a step of performing a multiplication operation by the plurality of arithmetic units based on the plurality of first multiplication coefficients and the plurality of second multiplication coefficients, and obtaining a plurality of multiplication operation results corresponding to the plurality of arithmetic units, each arithmetic unit performing a multiplication operation on a corresponding first multiplication coefficient and a corresponding second multiplication coefficient, and obtaining a multiplication operation result corresponding to each arithmetic unit; The data processing method according to any one of claims 1 to 4, further comprising the step of: transmitting the results of the multiple multiplication operations to the at least one destination vector register.

6. The step of transmitting the results of the multiplication operations to the at least one destination vector register comprises: performing an addition operation on the plurality of multiplication operation results in one-to-one correspondence with the plurality of storage data stored in the at least one destination vector register to obtain a plurality of addition operation results; and storing the results of said plurality of addition operations in said at least one destination vector register.

7. The step of obtaining the first data selection information and the second data selection information includes: obtaining a data selection command; 7. The data processing method according to claim 1, further comprising the step of: analyzing the data selection command to obtain the first data selection information and the second data selection information.

8. The at least one first vector register includes a first target vector register, and the at least one first target operation data is stored in the first target vector register; A data processing method according to any one of claims 1 to 7, wherein the at least one second vector register comprises a second target vector register, and wherein the at least one second target operation data is all stored in the second target vector register.

9. The first matrix is ​​a vertical matrix, and the at least one first target operation data is located in the same column of the first matrix; and The data processing method according to any one of claims 1 to 8, wherein the second matrix is ​​a horizontal matrix, and the at least one second target operation data is located in the same row of the second matrix.

10. The step of determining at least one first vector register in which the first matrix is ​​stored and at least one second vector register in which the second matrix is ​​stored comprises: obtaining at least one first address and at least one second address; determining the at least one first vector register based on the at least one first address; The data processing method according to any one of claims 1 to 9, further comprising the step of: determining said at least one second vector register based on said at least one second address.

11. The step of obtaining at least one first address and at least one second address includes: obtaining a matrix operation instruction; 11. The method of claim 10, further comprising: analyzing the matrix operation instruction to obtain the at least one first address and the at least one second address.

12. The step of obtaining the first data selection information and the second data selection information includes:

12. The data processing method according to claim 1, further comprising the step of: analyzing the matrix operation instruction to obtain the first data selection information and the second data selection information.

13. obtaining at least one first data read command and at least one second data read command; parsing the at least one first data read command to obtain at least one first read address and at least one first address; reading the plurality of first operation data from a memory based on the at least one first read address, determining the at least one first vector register based on the at least one first address, and writing the plurality of first operation data to the at least one first vector register; parsing the at least one second data read command to obtain at least one second read address and at least one second address; The data processing method according to any one of claims 1 to 12, further comprising the steps of: reading the plurality of second operation data from the memory based on the at least one second read address; determining the at least one second vector register based on the at least one second address; and writing the plurality of second operation data to the at least one second vector register.

14. 14. The data processing method according to claim 1, wherein the plurality of arithmetic units execute multiplication operations in parallel.

15. A data processing device applied to matrix operations, a register determination unit used to determine at least one first vector register in which a first matrix including a plurality of first operation data is stored, and at least one second vector register in which a second matrix including a plurality of second operation data is stored; an information acquiring unit used for acquiring the first data selection information and the second data selection information; a data selection unit used for selecting, according to the first data selection information, at least one first operation data from the plurality of first operation data to obtain at least one first target operation data, and selecting, according to the second data selection information, at least one second operation data from the plurality of second operation data to obtain at least one second target operation data; a data broadcast unit for data-copying the at least one first target operation data as a multiple of a second matrix dimension of the second matrix, and providing the data-copying data to a plurality of computing units to determine a plurality of first multiplication coefficients corresponding one-to-one to the plurality of computing units, and for data-copying the at least one second target operation data as a multiple of a first matrix dimension of the first matrix, and providing the data-copying data to the plurality of computing units to determine a plurality of second multiplication coefficients corresponding one-to-one to the plurality of computing units, A data processing apparatus, wherein the first matrix dimension and the second matrix dimension are both positive integers, and the first matrix dimension and the second matrix dimension are of different types.

16. It is a data processing device, A processor; A storage medium having computer executable instructions stored thereon; A data processing apparatus, the computer executable instructions implementing the data processing method of any one of claims 1 to 14 when executed by the processor.

17. A computer-readable storage medium for non-transitory storage of computer-executable instructions, A computer-readable storage medium, the computer-executable instructions implementing the data processing method of any one of claims 1 to 14 when executed by a processor.

Citation Information

Patent Citations

  • Register-based matrix multiplication

    JP2020527778A

  • Reconfigurable processing system and method

    US20020087846A1