[go: up one dir, main page]

WO2024195694A1 - プロセッサ装置および演算方法 - Google Patents

プロセッサ装置および演算方法 Download PDF

Info

Publication number
WO2024195694A1
WO2024195694A1 PCT/JP2024/010054 JP2024010054W WO2024195694A1 WO 2024195694 A1 WO2024195694 A1 WO 2024195694A1 JP 2024010054 W JP2024010054 W JP 2024010054W WO 2024195694 A1 WO2024195694 A1 WO 2024195694A1
Authority
WO
WIPO (PCT)
Prior art keywords
matrix
vector
storage means
column
calculation
Prior art date
Application number
PCT/JP2024/010054
Other languages
English (en)
French (fr)
Inventor
修作 内堀
Original Assignee
日本電気株式会社
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 日本電気株式会社 filed Critical 日本電気株式会社
Priority to PCT/JP2024/010054 priority Critical patent/WO2024195694A1/ja
Publication of WO2024195694A1 publication Critical patent/WO2024195694A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/34Addressing or accessing the instruction operand or the result ; Formation of operand address; Addressing modes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0475Generative networks

Definitions

  • This disclosure relates to a processor device and a computing method.
  • LLM Large Language Model
  • matrix multiplication matrix-matrix multiplication
  • Patent Document 1 discloses a technology for speeding up large-scale matrix and vector calculations, in which data to be used in calculations is stored in ring buffers of an input storage circuit and a coefficient storage circuit corresponding to a calculator in the order in which it should be calculated, and only the elements of the input vector and the elements of the row or column vector that make up the coefficient matrix required for the calculation of that calculator are prepared in the order in which they should be calculated. With this calculation circuit, calculations can be performed in response to a data access request from the calculator without rearranging the elements of the input vector, enabling high-speed calculations.
  • the technology in Patent Document 1 does not eliminate the bottleneck of memory bandwidth.
  • the ratio of data load amount to calculation amount (1/L) can be reduced.
  • GPGPUs and the like are equipped with a large number of small-sized matrix multiplication calculators, such as 4 x 4 matrices, so the ratio of load amount to calculation amount becomes large and memory bandwidth becomes a bottleneck.
  • One of the objectives of this disclosure is to provide technology that reduces the ratio of the amount of data loaded into memory to the amount of calculations.
  • This disclosure provides a processor device and a computing method that can solve the above problems.
  • the processor device includes an input/output means for inputting and outputting data to and from a memory, a vector storage means which is an area in which memory elements are arranged in columns, a calculation means which performs calculations between row vectors and column vectors, and a matrix storage means which is an area in which memory elements are arranged in a matrix, the vector storage means stores the row vectors and column vectors loaded from the memory by the input/output means, the calculation means performs calculations between the row vectors and column vectors stored in the vector storage means, and the matrix storage means stores the results of the calculations.
  • the calculation method stores row and column vectors loaded from memory in a vector register, which is an area of a processor device in which memory elements are arranged in a column, the processor device performs a calculation on the row and column vectors, stores the result of the calculation in a matrix register, which is an area of the processor device in which memory elements are arranged in a matrix, and the processor device outputs the result of the calculation stored in the matrix register to the memory.
  • the processor device and calculation method disclosed herein can reduce the ratio of the amount of data loaded into memory to the amount of calculation.
  • FIG. 2 is a schematic diagram illustrating an example of a processor device.
  • FIG. 2 is a detailed configuration diagram illustrating an example of a processor device.
  • FIG. 13 is a diagram illustrating an example of a matrix multiply-add operation.
  • FIG. 13 is a diagram illustrating an example of a vector cross product operation.
  • FIG. 2 is a diagram illustrating an example of a matrix calculator and a matrix register.
  • FIG. 1 is a first diagram illustrating the operation of a matrix calculator and a matrix register.
  • FIG. 2 is a second diagram illustrating the operation of the matrix calculator and the matrix register.
  • FIG. 3 is a third diagram illustrating the operation of the matrix calculator and the matrix register.
  • FIG. 4 is a fourth diagram illustrating the operation of the matrix calculator and the matrix register.
  • FIG. 2 is a second schematic diagram illustrating an example of a processor device.
  • FIG. 11 is a third schematic diagram illustrating an example of a processor device.
  • 10 is a flowchart illustrating an
  • FIG. 1 is a schematic diagram showing an example of a processor device 1. As shown in FIG.
  • the processor device 1 includes a matrix expansion control unit 10 and a vector processor device 20 having a vector register length L.
  • the matrix expansion control unit 10 includes a matrix register 110 with L rows and L columns, and a matrix calculator 120.
  • the matrix register 110 stores a matrix with L rows and L columns.
  • the matrix calculator 120 includes an L-column multiplier/accumulator.
  • the matrix calculator 120 and the matrix register 110 correspond to each other in the i-th column of the multiplier/accumulator and are connected to each other.
  • the calculator interface control unit 150 is provided across the matrix expansion control unit 10 and the vector expansion control unit 30.
  • the matrix calculator 120 is connected to the vector register 310 of the vector expansion control unit 30 of the vector processor device 20 by the calculator interface control unit 150.
  • the matrix register access control unit 160 is provided across the matrix expansion control unit 10 and the vector expansion control unit 30.
  • the matrix register 110 is connected to the vector register 310 of the vector expansion control unit 30 of the vector processor device 20 by the matrix register access control unit 160.
  • the matrix expansion control unit 10 has one matrix register 110, but the matrix expansion control unit 10 may have multiple matrix registers 110.
  • the vector processor device 20 includes a vector extension control unit 30 and a RISC (reduced instruction set computer) type scalar processor 40.
  • the scalar processor 40 includes an instruction control unit 490 that executes program instructions, and a scalar register 410, a scalar calculator 420, and a load/store control unit 480 that operate according to program instructions, and the load/store control unit 480 is connected to an external memory 60.
  • the vector extension control unit 30 includes a plurality of vector registers 310 with a register length L (L columns) and a vector calculator 320, and the plurality of vector registers 310 are connected to the load/store control unit 480.
  • the vector extension control unit 30 is controlled by the instruction control unit 490 according to vector instructions.
  • FIG. 2 shows a detailed configuration of the processor unit 1.
  • the matrix register 110 has L ⁇ L registers 111 arranged in L rows and L columns.
  • the matrix calculator 120 has L columns of multiply-accumulate calculators 121.
  • One vector register 310 has L columns of registers 311.
  • the vector calculator 320 has one multiply-accumulate calculator 321.
  • the matrix calculator 120 calculates the cross product of two vector data of vector length L (for example, the column vector aij and the row vector bij in FIG. 4) as a matrix of L rows and L columns, and stores the intermediate results of the matrix multiplication in the matrix register 110 (described later in FIG. 6 to FIG. 9). This keeps the ratio of data volume to the amount of calculation in the matrix multiplication to a theoretically minimum of 1/L, thereby improving memory bandwidth efficiency.
  • L for example, the column vector aij and the row vector bij in FIG. 4
  • the scalar processor 40 is a RISC type processor, and scalar data required for scalar operations is loaded by the load/store control unit 480 through the connection 61 of the memory 60 in response to a scalar load instruction, and stored in the scalar register 410 through the connection 461.
  • the scalar calculator 420 reads scalar data used in the operation from the scalar register 410 through the connection 451, performs the operation, and stores the operation result in the scalar register 410 through the connection 452.
  • the load/store control unit 480 reads the final operation result data through the connection 462 of the scalar register 410 in response to a scalar store instruction, and stores it in the memory 60 through the connection 62.
  • the L pieces of vector data of the operation results are read by the load store control unit 480 through the connection 462 of the vector register 310 by the vector store instruction, and the L pieces of data are stored in the memory 60 through the connection 62.
  • the operations of the vector processor device 20 and the components of the RISC type scalar processor 40 and vector extension control unit 30 described here are known techniques.
  • VOP Vector cross product instruction
  • VLDM Vector Matrix Load Instruction
  • A, B, C, and D are matrices of L rows and L columns, and the elements of the i row and j column of each matrix are aij, bij, cij, and dij, respectively.
  • vector data VC1 (c11, c21, c31, ..., cL1) of the first column of matrix C is loaded from memory 60 to vector register 310 by a vector load instruction.
  • vector data VC1 is written from vector register 310 to the first column of matrix register 110 through connection 161 by a vector matrix store instruction (VSTM).
  • VSTM vector matrix store instruction
  • the following processes (a) and (b) are repeated to write data of matrix C to matrix register 110.
  • Vector data VCj (c1j, c2j, c3j, ..., cLj) of the jth column of matrix C is loaded to vector register 310.
  • vector data VCj is written from vector register 310 to the jth column of matrix register 110 through connection 161 by a vector matrix store instruction (VSTM).
  • the vector load instruction loads the vector data VA1 (a11, a21, a31, ..., aL1) of the first column of matrix A and the vector data VB1 (b11, b12, b13, ..., b1L) of the first row of matrix B from memory 60 to vector register 310.
  • the vector data VA1 and VB1 are each loaded into separate vector registers 310.
  • Figure 4 shows an overview of the vector cross product operation.
  • vector data VAk (a1k, a2k, a3k, ..., aLk) of the kth column of matrix A and vector data VBk (bk1, bk2, bk3, ..., bkL) of the kth row of matrix B are loaded from memory 60 to vector register 310 by a vector load instruction.
  • the intermediate result is written to matrix register 110 via connection 154.
  • a vector matrix load instruction loads vector data VD1 (d11, d21, c31, ..., dL1) from the first column of matrix D in matrix register 110 into vector register 310 via connection 162, and a vector store instruction writes vector data VD1 from vector register 310 to memory 60 via connection 62.
  • a vector matrix load instruction loads vector data VDj (d1j, d2j, c3j, ..., dLj) from the jth column of matrix D in matrix register 110 into vector register 310, and a vector store instruction writes vector data VDj from vector register 310 to memory 60.
  • the matrix expansion control unit 10 in Fig. 5 includes the matrix register 110 having 3 x 3 registers, and the matrix calculator 120 having a total of three columns of multiply-accumulate calculators, one for each column register.
  • each configuration is indicated by assigning column numbers 1 to the left column on the page, 2 to the center column, and 3 to the right column.
  • the left column of the matrix calculator is described as matrix calculator 1
  • the multiply-accumulate calculator of the matrix calculator 1 is described as multiply-accumulate calculator 1.
  • Step 1 The operation of the first cycle (step 1) is shown on the left side of Fig. 6.
  • the first element a11 of vector data VA1 is input to input register A1 of matrix calculator 1
  • the first element b11 of vector data VB1 is input to input register B1
  • c11 of the first column, first row of matrix C is input to input register C1.
  • step 2 (Second cycle operation: step 2) The operation of the second cycle (step 2) is shown near the center of Fig. 6.
  • the second element a21 of the vector data VA1 is input to the input register A1 of the matrix calculator 1, the input register B1 holds the first element b11 of the vector data VB1, and c21 in the first column and second row of the matrix C is input to the input register C1.
  • the data a11 which is the first element of the vector data VA1 and is stored in the input register A1 in the first column of the matrix calculator, is input to the input register A2 of the matrix calculator 2, the second element b12 of the vector data VB1 is input to the input register B2, and c12 in the second column and first row of the matrix C is input to the input register C2.
  • FIG. 6 shows the operation of the third cycle (step 3).
  • the third element a31 of the vector data VA1 is input to the input register A1 of the matrix calculator 1, the input register B1 holds the first element b11 of the vector data VB1, and the input register C1 receives c31 in the first column and third row of the matrix C.
  • the result data d11 stored in the output register D1 of the multiply-add calculator 1 of the matrix calculator 1 is stored in the first column and first row of the matrix D of the matrix register 110.
  • Data a11 which is the first element of vector data VA1 and is stored in the input register of matrix calculator 2, is input to input register A3 of matrix calculator 3, data b13, the third element of vector data VB1, is input to input register B3, and data c13, the third column, first row of matrix C, is input to input register C3.
  • step 4 The left side of FIG. 7 shows the operation of the fourth cycle (step 4).
  • vector data VA2 (a12, a22, a32) in the second column of matrix A and vector data VB2 (b21, b21, b23) in the second row of matrix B are stored in the vector register 310.
  • the first element a12 of vector data VA2 is input to the input register A1 of the matrix calculator 1
  • the first element b21 of vector data VB2 is input to the input register B1
  • d11 in the first column and first row of the matrix register 110 is input to the input register C1.
  • d11 is stored in step 3.
  • Data a31 which is the third element of vector data VA1 and is stored in input register A1 of matrix calculator 1, is input to input register A2 of matrix calculator 2, input register B2 holds the second element b12 of vector data VB1, and c32 in the second column, third row of matrix C is input to input register C2.
  • result data d12 stored in output register D2 of multiply-accumulator 2 in the second column of the matrix calculator is stored in the second column, first row of matrix register 110.
  • Data a21 which is the second element of vector data VA1 and is stored in input register A2 of matrix calculator 2, is input to input register A3 of matrix calculator 3, input register B3 holds the third element b13 of vector data VB1, and element c23 of matrix C in the third column, second row of matrix register 110 is input to input register C3.
  • step 5 The operation of the fifth cycle (step 5) is shown near the center of Fig. 7.
  • the second element a22 of the vector data VA2 is input to the input register A1 of the matrix calculator 1, the input register B1 holds the first element b21 of the vector data VB2, and d21 in the first column, second row of the matrix register 110 is input to the input register C1.
  • d21 is stored in step 4.
  • the result data d31 stored in the output register D1 of the multiply-add calculator 1 of the matrix calculator 1 is stored in the first column, third row of the matrix register 110.
  • Data a12 which is the first element of vector data VA2 and is stored in input register A1 of the first column of the matrix calculator, is input to input register A2 of matrix calculator 2, the second element b22 of vector data VB2 is input to input register B2, and d12 in the first row and second column of matrix C is input to input register C2.
  • result data d22 stored in output register D2 of multiply-accumulator 2 of matrix calculator 2 is stored in the second column and second row of matrix register 110.
  • Data a31 which is the third element of vector data VA1 and is stored in input register A2 of matrix calculator 2, is input to input register A3 of matrix calculator 3, input register B3 holds the third element b13 of vector data VB1, and input register C3 receives c33 in the third column and third row of matrix C.
  • matrix calculator 120 stores result data d13 stored in output register D3 of multiply-accumulator 3 of matrix calculator 3 in the third column and first row of matrix D of the matrix register.
  • the operations from the sixth cycle onwards are executed in a similar manner.
  • the operation of the sixth cycle (step 6) is shown on the right side of Figure 7.
  • the operation of the seventh cycle (step 7) is shown on the left side of Figure 8, the operation of the eighth cycle (step 8) is shown near the centre, and the operation of the ninth cycle (step 9) is shown on the right side.
  • steps 7 to 9 it is assumed that vector data VA3 (a13, a23, a33) in the third column of matrix A and vector data VB3 (b31, b32, b33) in the third row of matrix B are stored in vector register 310.
  • the operations are similar to those described above.
  • step 10 The left side of FIG. 9 shows the operation of the 10th cycle (step 10), the center left side shows the operation of the 11th cycle (step 11), the center right side shows the operation of the 12th cycle (step 12), and the right side shows the operation of the 13th cycle (step 13).
  • step 10 onwards all data of the input matrices A and B are input, and no new data is input to the input data of the first column of the matrix calculator.
  • the vector data VA3 (a13, a23, a33) of the third column of matrix A and the vector data VB3 (b31, b32, b33) of the third row of matrix B are stored in the vector register 310.
  • step 13 the result data f33 stored in the output register D3 of the multiplication and accumulation calculator 3 of the matrix calculator 3 is stored in the third column and third row of the matrix register 110, completing the matrix multiplication calculation A ⁇ B+C.
  • FIG. 10 shows an example of a schematic configuration diagram of the processor device 1, which is a further simplified version of the configurations shown in Figs. 1 and 2.
  • the processor device 1 shown in Fig. 10 reads out a matrix A with M rows and K columns and a matrix B with K rows and N columns stored in a memory 60, calculates a matrix product of the matrix A and the matrix B, and stores a matrix C with M rows and N columns, which is the result of the calculation, in the memory 60.
  • the processor device 1 includes a matrix calculator 120 having L multiply-accumulators, and a matrix register 110 having a register with L rows and L columns for holding the matrix of the calculation result, and is connected to the memory 60 by memory interfaces 61 and 62.
  • the efficiency of the memory bandwidth and the calculation performance can be improved by using the transistor resources of the LSI for the matrix register 110 and the matrix calculator 120.
  • the processor device 1 loads the matrix A with M rows and K columns and the matrix B with K rows and N columns stored in the memory 60 through the memory interface 61, calculates the matrix product of the matrix A and the matrix B through the matrix calculator 120, and stores the matrix C with M rows and N columns in the matrix register 110.
  • the matrix C resulting from the calculation is stored in the memory 60 through the memory interface 62. More specifically, the processor device 1 loads the vector of the matrix A with M rows and 1 column and the vector of the matrix B with 1 row and N columns, calculates the cross product of the two vectors, and accumulates the intermediate result of the matrix product in the matrix register 110. By repeating this process K times, the matrix product of the matrix A and the matrix B is calculated.
  • the vector register 310 has only L columns, only L calculation results can be stored.
  • the processor device 1 of this embodiment is provided with a matrix register 110 of L rows x L columns, so that the values of each element of the calculation result matrix C of M rows and N columns can be stored in the matrix register 110.
  • the processor device 1 is provided with a matrix calculator 120 having a multiply-accumulator of L columns, and can perform calculations in parallel, so that the matrix multiplication calculation can be performed at a higher speed than when the calculation is performed only by the vector calculator 320.
  • the ratio of the amount of data loaded to the amount of calculation is logically 1/L.
  • the process of reading out L column vectors and L row vectors from the memory 60 is repeated L times while performing a matrix multiplication operation in the matrix calculator 120, and when the matrix multiplication operation is completed, the process of storing the calculation results stored in the matrix register 110 into the memory 60 column by column is repeated L times.
  • the memory bandwidth can be used efficiently with the minimum necessary I/O, and the ratio of the data amount to the amount of calculation of the matrix multiplication can be made the theoretical minimum of 1/L.
  • the ratio of the amount of data loaded to the memory to the amount of calculation can be reduced. Also, by increasing L according to the integrated circuit, the memory bandwidth efficiency and calculation performance can be improved.
  • the ratio of the data amount to the amount of calculation of the matrix multiplication can be reduced to 1/L, which is the theoretical minimum, and the memory bandwidth shortage caused by the matrix multiplication can be eliminated. Furthermore, if the size of the LSI becomes 1/A times due to the evolution of process technology, the number of transistors that can be integrated in the LSI of the same area becomes A2 times, and the memory bandwidth becomes A times, but by increasing L to A times, it becomes possible to implement a matrix register of AL rows and AL columns and a multiply-accumulate calculator of A2 x L, and the calculation performance becomes A2 times. In this way, according to this embodiment, the ratio of the data amount to the amount of calculation can be reduced to eliminate the memory bandwidth shortage, and the calculation performance can be improved in line with the evolution of process technology.
  • the matrix expansion control unit 10 may include a plurality of matrix registers 110.
  • the matrix multiplication can be performed more efficiently. For example, if there are two matrix registers (C, D), after a certain matrix product is calculated, the matrix product can be calculated for matrix register D while the calculation result of matrix register C is being transferred to memory 60.
  • the matrix product A ⁇ B of matrix A which is the result of the matrix multiplication
  • matrix B which is in memory. In this case, only the row vectors of matrix B are loaded from memory 60, so the memory bandwidth can be halved. The same applies to the matrix product B ⁇ A.
  • the matrix product A ⁇ B of matrix A, which is the result of the matrix multiplication, and matrix B, which is the result of the matrix multiplication can be calculated without memory access, and the bottleneck of the memory bandwidth can be avoided more effectively.
  • the processor device 800 includes an input/output means 801 for inputting and outputting data to and from a memory, a vector storage means 802 which is an area in which memory elements are arranged in a row or column shape, a calculation means 803 which performs calculations between row vectors and column vectors, and a matrix storage means 804 which is an area in which memory elements are arranged in a matrix shape, the vector storage means 802 stores row vectors and column vectors loaded from the memory by the input/output means, the calculation means 803 performs calculations between row vectors and column vectors stored in the vector storage means, and the matrix storage means 804 stores the results of the calculations.
  • FIG. 12 is a flowchart showing an example of the operation of the processor device.
  • the row vector and column vector loaded from memory are stored in a vector register, which is an area of the processor in which memory elements are arranged in a column shape (step S801)
  • the processor performs a computation on the row vector and the column vector (step S802), and stores the result of the computation in a matrix register, which is an area of the processor in which memory elements are arranged in a matrix shape (step S803)
  • the processor device outputs the result of the computation stored in the matrix register to the memory (step S804).
  • the processor device and the computing method according to the embodiment can be understood, for example, as follows.
  • a processor device includes an input/output means for inputting and outputting data to and from a memory, a vector storage means which is an area in which memory elements are arranged in a row or column shape, a calculation means which performs calculations between row vectors and column vectors, and a matrix storage means which is an area in which memory elements are arranged in a matrix shape, the vector storage means stores row vectors and column vectors loaded from the memory by the input/output means, the calculation means performs calculations between the row vectors and column vectors stored in the vector storage means, and the matrix storage means stores the results of the calculations.
  • a processor device is the processor device according to (1), in which the calculation means includes a number of multiply-accumulate operators equal to the number of columns of the matrix storage means, and the multiply-accumulate operators are connected to the memory elements arranged in the same column as the multiply-accumulate operators in the matrix storage means.
  • a processor device is a processor device according to any one of (1) to (2), in which the matrix storage means has memory elements with a number of columns and rows equal to or greater than the number of columns of the column vector that the vector storage means can store.
  • a processor device is a processor device according to any one of (1) to (3), in which the matrix storage means has memory elements with the same number of columns and rows as the maximum number of columns of the column vector that the vector storage means can store.
  • a processor device is a processor device according to any one of (1) to (4), in which the operation is a matrix-matrix multiplication.
  • a processor device is a processor device according to any one of (1) to (5), in which the vector storage means and the matrix storage means are connected, and the calculation results stored in the matrix storage means are output to the vector storage means and stored in the vector storage means, and are output from the vector storage means to the memory by the input/output means.
  • a processor device is a processor device according to any one of (1) to (6), in which, when matrix A is a matrix of M rows and K columns, and matrix B is a matrix of K rows and N columns, the calculation is matrix A x matrix B, and the vector storage means stores one column of the matrix A loaded by the input/output means and outputs it to the calculation means, then stores one row of the matrix B loaded by the input/output means and outputs it to the calculation means, the calculation means calculates the product of one column of the matrix A and one row of the matrix B, and stores the calculation result in the matrix storage means, repeating this process until the calculation of matrix A x matrix B is completed.
  • the processor device is the processor device according to any one of (1) to (7), in which the vector storage means and the matrix storage means are connected, and the column vectors loaded from the memory and stored in the vector storage means are output from the vector storage means to the matrix storage means and stored in the matrix storage means.
  • the processor device is the processor device according to (8), in which the calculation is matrix A ⁇ matrix B + matrix C, where each of matrix A, matrix B, and matrix C has L rows and L columns, and the input/output means loads the column vector of matrix C one column at a time into the vector storage means, and the matrix storage means repeats the process of outputting and storing the loaded column vector of matrix C to the matrix storage means L times to store the matrix C in the matrix storage means, and the vector storage means stores one column of the matrix A loaded by the input/output means and outputs it to the calculation means, and then stores one row of the matrix B loaded by the input/output means and outputs it to the calculation means, and the calculation means calculates the product of one column of matrix A and one row of matrix B and the sum of matrix C, and stores the calculation result in the matrix storage means, repeating the process until the calculation of matrix A ⁇ matrix B + matrix C is completed.
  • a processor device is a processor device according to any one of (1) to (9), comprising: a first instruction for performing an operation using two vector data loaded into the vector storage means and matrix data stored in the matrix storage means, and storing the operation result in the matrix storage means; a vector matrix store instruction (VSTM): VSTM comprises a second instruction for writing one vector data stored in the vector storage means to a row or column of the matrix storage means; and a third instruction for writing vector data from any row or column of the matrix storage means to the vector storage means.
  • VSTM vector matrix store instruction
  • the 11th aspect of the calculation method involves storing row and column vectors loaded from memory in a vector register, which is an area of a processor device in which memory elements are arranged in a column, having the processor device perform a calculation on the row and column vectors, storing the result of the calculation in a matrix register, which is an area of the processor device in which memory elements are arranged in a matrix, and outputting the result of the calculation stored in the matrix register to the memory.
  • the above-mentioned processor device and calculation method can reduce the ratio of the amount of data loaded into memory to the amount of calculation.
  • Processor device 10 Matrix expansion control unit 20
  • Vector processor device 30 Vector expansion control unit 40
  • Memory 110 Matrix register 111 Register 120
  • Matrix calculator 121 Multiply-accumulate calculator 150
  • Calculator interface control unit 160 Matrix register access control unit 310
  • Vector calculator 321 Multiply-accumulate calculator 410
  • Scalar register 420 Scalar calculator 480
  • Instruction control unit 800 Processor device 801 Input/output means 802
  • Vector storage means 803 Calculation means 804 Matrix storage means

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Biomedical Technology (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Complex Calculations (AREA)

Abstract

プロセッサ装置は、メモリとの入出力を行う入出力手段と、列状に記憶素子を配置した領域であるベクトル格納手段と、行ベクトルと列ベクトルとの演算を行う演算手段と、行列状に記憶素子を配置した領域である行列格納手段と、を備え、前記ベクトル格納手段は、前記メモリから前記入出力手段によってロードされた行ベクトルと列ベクトルを格納し、前記演算手段は、前記ベクトル格納手段に格納された行ベクトルと列ベクトルとの演算を行い、前記行列格納手段は、前記演算の結果を格納する。

Description

プロセッサ装置および演算方法
 この開示は、プロセッサ装置および演算方法に関する。
 プロセステクノロジの進歩により、同一チップ面積のLSI(大規模集積回路)に実装可能な演算器の数は、面積に比例するため2乗で増加するのに対し、LSIのI/Oを経由するメモリ帯域は、LSIの辺の長さに比例して増加する。演算量に必要なデータ量は、演算器の数に比例して増加するため、メモリ帯域のボトルネック化が加速している。
 例えば、近年、成長著しい生成AIの分野においてLLM(Large Language Model)が利用されている。LLMにおいては、数千行×数千列といった大規模な行列同士の乗算である行列行列積(以下、「行列積」と記載する。)が、演算量の大部分を占める。
 L行×L列正方行列同士の行列積は、L×L×L=Lの乗算および約Lの加算からなり、約2×Lの演算量となる。一方、行列積に必要な入力行列データをメモリからロードする際のデータ量は、2×Lである。したがって、演算強度=演算量/データ量=約Lとなり、L×Lの行列サイズLを大きくして行列演算器を大きくすることにより、演算量に対するデータのロード量の比率(約1/L)を小さくすることができ、プロセステクノロジの進歩に比例して増加する演算量に必要なデータ量を相殺することができる。
 LLMにおいては、数千行×数千列といった大規模な行列積が、演算量の大部分を占めており、このような行列積を効率良く実行する演算装置および演算方法が開発されている。また、行列積を実行可能なプロセッサも開発されている。しかしながら、既存の一般的なプロセッサ装置では、大規模な行列積での演算強度大という特徴を活かせておらず、プロセステクノロジの進歩に比例して加速するデータ量に対し、メモリ帯域のボトルネック化という課題に応えることができていない。
 特許文献1には、大規模な行列とベクトルの演算を高速化する技術として、演算器に対応する入力記憶回路と係数記憶回路のリングバッファに、演算されるべき順番に従って演算に用いるデータを格納し、当該演算器の演算に必要な入力ベクトルの要素と係数行列を構成する行または列ベクトルの要素のみを演算されるべき順番で準備しておく演算回路が開示されている。この演算回路によれば、演算器からデータアクセス要求に対し、入力ベクトルの要素の並べ替えを行わずに演算することができるので高速な演算が可能となる。しかし、特許文献1の技術は、メモリ帯域のボトルネック化を解消するものではない。
 上述の通り、演算強度=演算量/データ量=約Lとなり、L×Lの行列サイズLを大きくして行列演算器を大きくすることにより、演算量に対するデータのロード量の比率(1/L)を小さくすることができる。しかし、GPGPU等では、4×4の行列といった小さなサイズの行列積演算器を大量に搭載し、演算量に対するロード量の比率が大きくなり、メモリ帯域がボトルネックとなっている。
国際公開第2019/077933号
 この開示は、演算量に対するメモリへのデータのロード量の比率を小さくする技術の提供を目的の一つとする。
 この開示は、上述の課題を解決することのできるプロセッサ装置および演算方法を提供する。
 この開示の一態様によれば、プロセッサ装置は、メモリとの入出力を行う入出力手段と、列状に記憶素子を配置した領域であるベクトル格納手段と、行ベクトルと列ベクトルとの演算を行う演算手段と、行列状に記憶素子を配置した領域である行列格納手段と、を備え、前記ベクトル格納手段は、前記メモリから前記入出力手段によってロードされた行ベクトルと列ベクトルを格納し、前記演算手段は、前記ベクトル格納手段に格納された行ベクトルと列ベクトルとの演算を行い、前記行列格納手段は、前記演算の結果を格納する。
 この開示の一態様によれば、演算方法は、メモリからロードされた行ベクトルと列ベクトルとを、プロセッサ装置が備える、列状に記憶素子を配置した領域であるベクトルレジスタに格納し、前記プロセッサ装置が前記行ベクトルと前記列ベクトルの演算を行い、前記演算の結果を、前記プロセッサ装置が備える、行列状に記憶素子を配置した領域である行列レジスタに格納し、前記プロセッサ装置が、前記行列レジスタに格納された前記演算の結果を前記メモリへ出力する。
 本開示のプロセッサ装置および演算方法によれば、演算量に対するメモリへのデータのロード量の比率を小さくすることができる。
プロセッサ装置の一例を示す概略構成図である。 プロセッサ装置の一例を示す詳細構成図である。 行列積和演算の一例を示す図である。 ベクトル外積演算の一例を示す図である。 行列演算器と行列レジスタの一例を示す図である。 行列演算器と行列レジスタの操作について説明する第1図である。 行列演算器と行列レジスタの操作について説明する第2図である。 行列演算器と行列レジスタの操作について説明する第3図である。 行列演算器と行列レジスタの操作について説明する第4図である。 プロセッサ装置の一例を示す第2の概略構成図である。 プロセッサ装置の一例を示す第3の概略構成図である。 プロセッサ装置の動作の一例を示すフローチャートである。
 以下、本開示の各実施形態に係るプロセッサ装置について図面を参照して説明する。以下の説明に用いる図面において本開示に関係ない部分の構成については、記載を省略し、図示しない場合がある。すべての図面において同一または相当する構成には同一の符号を付し、共通する説明は省略する場合がある。
<第1実施形態>
(構成)
 図1は、プロセッサ装置1の一例を示す概略構成図である。
 プロセッサ装置1は、行列拡張制御部10と、ベクトルレジスタ長Lのベクトルプロセッサ装置20と、を備える。
 行列拡張制御部10は、L行L列の行列レジスタ110と、行列演算器120を備える。行列レジスタ110は、ベクトルレジスタ310がL列の場合には、L行×L列の行列を格納する。行列演算器120は、L列の積和演算器を備えている。行列演算器120と行列レジスタ110は、i列目の積和演算器とi列目の行列レジスタ110は対応し、これらは接続されている。演算器インタフェース制御部150は、行列拡張制御部10とベクトル拡張制御部30にまたがって設けられている。行列演算器120は、演算器インタフェース制御部150によって、ベクトルプロセッサ装置20のベクトル拡張制御部30のベクトルレジスタ310と接続されている。行列レジスタアクセス制御部160は、行列拡張制御部10とベクトル拡張制御部30にまたがって設けられている。行列レジスタ110は、行列レジスタアクセス制御部160によって、ベクトルプロセッサ装置20のベクトル拡張制御部30のベクトルレジスタ310と接続されている。以下、行列拡張制御部10が、1つの行列レジスタ110を備える場合を例に説明を行うが、行列拡張制御部10は、複数の行列レジスタ110を備えていてもよい。
 ベクトルプロセッサ装置20は、ベクトル拡張制御部30と、RISC(reduced instruction set computer)型のスカラプロセッサ40とを備える。スカラプロセッサ40は、プログラム命令を実行する命令制御部490と、プログラム命令に応じて動作する、スカラレジスタ410とスカラ演算器420とロードストア制御部480を備え、ロードストア制御部480は、外部メモリ60に接続される。ベクトル拡張制御部30は、レジスタ長L(L列)のベクトルレジスタ310を複数と、ベクトル演算器320と、を備え、複数のベクトルレジスタ310は、ロードストア制御部480と接続される。ベクトル拡張制御部30は、ベクトル命令に応じて命令制御部490により制御される。ベクトルプロセッサ装置20、構成要素であるRISC型のスカラプロセッサ40およびベクトル拡張制御部30の構成は、一般的なプロセッサ装置が備える公知技術である。これに対し、一般的なプロセッサ装置は、行列拡張制御部10、行列レジスタアクセス制御部160、演算器インタフェース制御部150の構成を備えない。
 図2に、プロセッサ装置1の詳細構成を示す。行列レジスタ110は、L行×L列に並べられたL×L個のレジスタ111を備える。行列演算器120は、L列の積和演算器121を備える。1つのベクトルレジスタ310は、L列のレジスタ311を備える。ベクトル演算器320は、1つの積和演算器321を備える。
 後述するように、本実施形態では、行列演算器120において2つのベクトル長Lのベクトルデータ(例えば、図4のaijの列ベクトルとbijの行ベクトル)からL行×L列の行列であるベクトルの外積を演算し、行列レジスタ110に行列積の中間結果を蓄積することにより(後に図6~図9で説明する。)、行列積の演算量に対するデータ量の比率を理論上最小の1/Lにし、メモリ帯域効率の向上を図る。
 次にプロセッサ装置1の動作を説明することにより、上記の構成によってメモリ帯域効率が向上することを説明する。
(一般的な動作:スカラ演算)
 まず、図1を参照して、ベクトルプロセッサ装置20の一般的な動作の説明をする。スカラプロセッサ40はRISC型のプロセッサであり、スカラ演算に必要なスカラデータは、スカラロード命令により、メモリ60の接続61を通じてロードストア制御部480によってロードされ、接続461を通じてスカラレジスタ410へ格納される。スカラ演算器420は、演算に使用するスカラデータを、接続451を通じてスカラレジスタ410から読み込んで演算を行い、その演算結果を、接続452を通じてスカラレジスタ410へ格納する。最終的な演算結果のデータは、スカラストア命令により、ロードストア制御部480が、スカラレジスタ410の接続462を通じて読み込み、接続62によってメモリ60へ格納する。
(一般的な動作:ベクトル演算)
 次にベクトル拡張制御部30の一般的な動作の説明をする。ベクトル命令(ベクトル演算の命令)であるかどうかは、命令制御部490により判断される。ベクトルデータは、ベクトルレジスタ310のレジスタ長Lで定義される最大L個のデータである。ベクトル命令と判断されると、まず、ベクトル演算に必要なベクトルデータは、ロードストア制御部480のベクトルロード命令により、メモリ60の接続61を通じてロードされ、接続461を通じて、ベクトルレジスタ310へ格納される。ベクトル演算器320は、演算に使用するL個のデータを、接続351を通じてベクトルレジスタ310から連続して読み込み、L個の演算を行い、その演算結果を、接続352を通じてベクトルレジスタ310へ格納する。演算結果のL個のベクトルデータは、ベクトルストア命令によりベクトルレジスタ310の接続462を通じてロードストア制御部480により読み込まれ、接続62を通じてメモリ60へL個のデータが格納される。ここで説明したベクトルプロセッサ装置20、構成要素であるRISC型のスカラプロセッサ40およびベクトル拡張制御部30の動作は、公知技術である。
(本実施形態に係る動作)
 図1及び詳細図2を参照して、本実施形態の行列拡張制御部10の動作の説明について説明する。
 最初に、本実施形態に係る行列拡張制御部10、行列レジスタアクセス制御部160、演算器インタフェース制御部150に関連する命令として以下の3つを定義する。これらは、命令制御部490によって指令される。
(1)ベクトル外積命令(VOP):VOPは、ベクトルレジスタ310の2つのL個のベクトルデータと行列レジスタ110の1つのL×L行列データから演算を行い、結果のL×L行列を行列レジスタ110へ書き込むことを指示する命令である。
(2)ベクトル行列ストア命令(VSTM):VSTMは、ベクトルレジスタ310の1つのベクトルデータを行列レジスタ110のL×L行列の行または列へ書き込む命令である。
(3)ベクトル行列ロード命令(VLDM):VLDMは、行列レジスタ110のL×L行列の行または列からベクトルレジスタ310のベクトルデータへ書き込む命令である。
 次に行列積演算の具体例を挙げて本実施形態のプロセッサ装置1の動作説明を行う。図3に示すように、A、B、C、DをそれぞれL行×L列の行列とし、各行列のi行j列の要素をそれぞれaij、bij、cij、dijとし、行列積和演算D=A×B+Cを演算する場合の動作を例に説明を行う。メモリ60には、行列A、B、Cが格納されているとする。
(全体の流れ)
 まず、ベクトルロード命令によりメモリ60から、ベクトルレジスタ310へ、行列Cの1列目のベクトルデータVC1(c11、c21、c31、・・・、cL1)をロードする。次にベクトル行列ストア命令(VSTM)により、ベクトルデータVC1をベクトルレジスタ310から接続161を通じて行列レジスタ110の1列目に書き込む。以降、同様にして、以下の(a)、(b)の処理を繰り返し、行列Cのデータを行列レジスタ110へ書き込む。(a)行列Cのj列目のベクトルデータVCj(c1j、c2j、c3j、…、cLj)をベクトルレジスタ310へロードする。(b)次に、ベクトル行列ストア命令(VSTM)により、ベクトルデータVCjをベクトルレジスタ310から行列レジスタ110のj列目に接続161を通じて書き込む。
 次に、ベクトルロード命令によりメモリ60から、ベクトルレジスタ310へ、行列Aの1列目のベクトルデータVA1(a11、a21、a31、・・・、aL1)、および、行列Bの1行目のベクトルデータVB1(b11、b12、b13、・・・、b1L)をロードする。ベクトルデータVA1、VB1はそれぞれ別々のベクトルレジスタ310へロードされる。次にベクトル外積命令(VOP)により、行列演算器120が、接続151を通じてベクトルレジスタ310からVA1、VB1を通じて読み込み、さらに、接続153を通じて行列レジスタ110から行列Cを読み込み、ベクトル外積演算(cij=ai1×b1j+cij)を実行する。図4にベクトル外積演算の概略を示す。中間結果は、接続154を通じて行列レジスタ110へ書き込まれる。以降、ベクトルロード命令により、メモリ60から、ベクトルレジスタ310へ、行列Aのk列目のベクトルデータVAk(a1k、a2k、a3k、・・・、aLk)、および、行列Bのk行目のベクトルデータVBk(bk1、bk2、bk3、・・・、bkL)をロードする。ベクトル外積命令(VOP)により、接続151を通じてベクトルレジスタ310から行列演算器120へVAk、VBkを読み込み、さらに、接続153を通じて行列レジスタ110から行列演算器120へ中間結果行列C(元々のCの要素とベクトル外積演算の中間結果cijが混在する)を読み込み、ベクトル外積演算(cij=aik×bkj+cij)を実行する。中間結果は、接続154で行列レジスタ110へ書き込まれる。kをLまで変化させて都度、ベクトル外積演算を実行することで、行列積D=A×B+Cが得られる。
 結果行列Dのメモリ60への書き込みは、ベクトル行列ロード命令(VLDM)により、行列レジスタ110の行列Dの1列目のベクトルデータVD1(d11、d21、c31、・・・、dL1)を、接続162を通じてベクトルレジスタ310へ取り込み、ベクトルストア命令により、ベクトルレジスタ310からメモリ60へ接続62を通じてベクトルデータVD1を書き込む。以降、ベクトル行列ロード命令(VLDM)により、行列レジスタ110の行列Dのj列目のベクトルデータVDj(d1j、d2j、c3j、・・・、dLj)をベクトルレジスタ310へ取り込み、ベクトルストア命令により、ベクトルレジスタ310からベクトルデータVDjをメモリ60へ書き込む。この処理をL列目まで繰り返すことで、行列Dをメモリ60に書き込むことができる。
(詳細な動作)
 L=3の場合を例に、行列演算器120および行列レジスタ110の動作の詳細を図5~図9を参照して説明する。図5に、L=3の場合の行列演算器120および行列レジスタ110を示す。図5の行列拡張制御部10は、3×3のレジスタを備える行列レジスタ110と、それぞれの列のレジスタに対応する1つずつの計3列の積和演算器を備える行列演算器120と、を備える。以下の説明では、便宜的に紙面左側の列に1、中央列に2、右側の列に3の列番を付して各構成を示す。例えば、行列演算器の左側の列を行列演算器1、行列演算器1の積和演算器を積和演算器1のように記載する。また、積和演算器1には3つの入力レジスタA1、B1、C1と、1つの出力レジスタD1が接続されている。同様に、中央列の積和演算器2には入力レジスタA2、B2、C2と出力レジスタD2が接続され、右側列の積和演算器3には入力レジスタA3、B3、C3と出力レジスタD3が接続されている。積和演算器1~3は、d=a×b+cの演算を実行する。図5では、既に行列Cが行列レジスタ110に格納され、行列Aの1列目のベクトルデータVA1(a11、a21、a31)および行列Bの1行目のベクトルデータVB1(b11、b12、b13)がそれぞれ別々のベクトルレジスタ310に格納されている状態であるとする。図6~図9では、符号を省略している。
(1サイクル目の動作:ステップ1)
 図6の左側に1サイクル目の動作(ステップ1)を示す。行列演算器1の入力レジスタA1にベクトルデータVA1の1要素目a11、入力レジスタB1にベクトルデータVB1の1要素目b11、入力レジスタC1に行列Cの1列目1行目のc11が入力される。
(2サイクル目の動作:ステップ2)
 図6の中央付近に2サイクル目の動作(ステップ2)を示す。行列演算器1の入力レジスタA1にベクトルデータVA1の2要素目a21が入力され、入力レジスタB1はベクトルデータVB1の1要素目b11を保持し、入力レジスタC1に行列Cの1列目2行目のc21が入力される。また、行列演算器1の積和演算器1は、ステップ1にて各入力レジスタA1、B1、C1に格納されたデータa11、b11、c11から積和演算d11=a11×b11+c11を実行し、結果データd11を出力レジスタD1に格納する。そして、行列演算器2の入力レジスタA2にベクトルデータVA1の1要素目であり、行列演算器1列目の入力レジスタA1に格納されているデータa11を入力され、入力レジスタB2にベクトルデータVB1の2要素目b12が入力され、入力レジスタC2に行列Cの2列目1行目のc12が入力される。
(3サイクル目の動作:ステップ3)
 図6の右側に3サイクル目の動作(ステップ3)を示す。行列演算器1の入力レジスタA1にベクトルデータVA1の3要素目a31が入力され、入力レジスタB1はベクトルデータVB1の1要素目b11を保持し、入力レジスタC1に行列Cの1列目3行目のc31が入力される。また、行列演算器1の積和演算器1は、ステップ2にて各入力レジスタに格納されたデータa21、b11、c21から積和演算d21=a21×b11+c21を実行し、結果データd21を出力レジスタD1に格納する。また、行列演算器1の積和演算器1の出力レジスタD1に格納されている結果データd11を、行列レジスタ110の行列Dの1列1行目に格納する。
 行列演算器2の入力レジスタA2にベクトルデータVA1の2要素目であり、行列演算器1の入力レジスタA1に格納されているデータa21が入力され、入力レジスタB2はベクトルデータVB1の1要素目b12を保持し、入力レジスタC2に行列Cの2列目2行目のc22が入力される。また、行列演算器2の積和演算器2は、ステップ2にて各入力レジスタA2、B2、C2に格納されたデータa11、b12、c12から積和演算d12=a11×b12+c12を実行し、結果データd12を出力レジスタD2に格納する。
 行列演算器3の入力レジスタA3にベクトルデータVA1の1要素目であり、行列演算器2の入力レジスタに格納されているデータa11が入力され、入力レジスタB3にベクトルデータVB1の3要素目b13が入力され、入力レジスタC3に行列Cの3列目1行目のc13が入力される。
(4サイクル目の動作:ステップ4)
 図7の左側に4サイクル目の動作(ステップ4)を示す。ステップ4では、行列Aの2列目のベクトルデータVA2(a12、a22、a32)および行列Bの2行目のベクトルデータVB2(b21、b21、b23)がベクトルレジスタ310に格納されているものとする。行列演算器1の入力レジスタA1にベクトルデータVA2の1要素目a12、入力レジスタB1にベクトルデータVB2の1要素目b21、入力レジスタC1に行列レジスタ110の1列目1行目のd11が入力される。d11は、ステップ3で格納したものである。また、行列演算器1の積和演算器1は、ステップ3にて、各入力レジスタA1、B1,C1に格納されたデータa31、b11、c31から積和演算d31=a31×b11+c31を実行し、結果データd31を出力レジスタD1に格納する。また、ステップ3にて行列演算器1の積和演算器1の出力レジスタD1に格納した結果データd21を行列レジスタ110の1列2行目に格納する。
 行列演算器2の入力レジスタA2にベクトルデータVA1の3要素目であり、行列演算器1の入力レジスタA1に格納されているデータa31が入力され、入力レジスタB2はベクトルデータVB1の2要素目b12を保持し、入力レジスタC2に行列Cの2列目3行目のc32が入力される。また、行列演算器2の積和演算器2は、ステップ3にて各入力レジスタに格納されたデータa21、b12、c22から積和演算d22=a21×b12+c22を実行し、結果データd22を出力レジスタD2に格納する。また、行列演算器の2列目の積和演算器2の出力レジスタD2に格納されている結果データd12を行列レジスタ110の2列1行目に格納する。
 行列演算器3の入力レジスタA3にベクトルデータVA1の2要素目であり、行列演算器2の入力レジスタA2に格納されているデータa21が入力され、入力レジスタB3はベクトルデータVB1の3要素目b13を保持し、入力レジスタC3に行列レジスタ110の3列目2行目の行列Cの要素c23が入力される。また、行列演算器3の積和演算器3は、ステップ3にて各入力レジスタに格納されたデータa11、b13、c13から積和演算d13=a11×b13+c13を実行し、結果データd13を出力レジスタD3に格納する。
(5サイクル目の動作:ステップ5)
 図7の中央付近に5サイクル目の動作(ステップ5)を示す。行列演算器1の入力レジスタA1にベクトルデータVA2の2要素目a22を入力し、入力レジスタB1はベクトルデータVB2の1要素目b21を保持し、入力レジスタC1に行列レジスタ110の1列目2行目のd21が入力される。d21は、ステップ4で格納したものである。また、行列演算器1の積和演算器1は、前ステップで各入力レジスタに格納されたデータa12、b21、d11から積和演算e11=a12×b21+d11を実行し、結果データe11を出力レジスタD1に格納する。また、行列演算器1の積和演算器1の出力レジスタD1に格納されている結果データd31を行列レジスタ110の1列3行目に格納する。
 行列演算器2の入力レジスタA2にベクトルデータVA2の1要素目であり、行列演算器1列目の入力レジスタA1に格納されているデータa12が入力され、入力レジスタB2にベクトルデータVB2の2要素目b22が入力され、入力レジスタC2に行列Cの2列目1行目のd12が入力される。また、行列演算器2の積和演算器2は、前ステップで各入力レジスタに格納又は保持されたデータa31、b12、c32から積和演算d32=a31×b12+c32を実行し、結果データd32を出力レジスタD2に格納する。また、行列演算器2の積和演算器2の出力レジスタD2に格納されている結果データd22を行列レジスタ110の2列2行目に格納する。
 行列演算器3の入力レジスタA3にベクトルデータVA1の3要素目であり、行列演算器2の入力レジスタA2に格納されているデータa31が入力され、入力レジスタB3はベクトルデータVB1の3要素目b13を保持し、入力レジスタC3に行列Cの3列目3行目のc33が入力される。また、行列演算器3の積和演算器3は、各入力レジスタに格納されたデータa21、b13、c23から積和演算d23=a21×b13+c23を実行し、結果データd23を出力レジスタD3に格納する。また、行列演算器120は、行列演算器3の積和演算器3の出力レジスタD3に格納されている結果データd13を行列レジスタの行列Dの3列1行目に格納する。
 以下同様にして6サイクル目以降の動作が実行される。図7の右側に6サイクル目の動作(ステップ6)を示す。図8の左側に7サイクル目の動作(ステップ7)を示し、中央付近に8サイクル目の動作(ステップ8)を示し、右側に9サイクル目の動作(ステップ9)を示す。ステップ7~ステップ9では、行列Aの3列目のベクトルデータVA3(a13、a23、a33)および行列Bの3行目のベクトルデータVB3(b31、b32、b33)がベクトルレジスタ310に格納されているものとする。動作は上記と同様である。
 図9の左側に10サイクル目の動作(ステップ10)を示し、中央左側に11サイクル目の動作(ステップ11)を示し、中央右側に12サイクル目の動作(ステップ12)を示し、右側に13サイクル目の動作(ステップ13)を示す。ステップ10以降では、入力行列である行列Aおよび行列Bのすべてのデータが入力され、行列演算器の1列目の入力データに新たなデータは入力されない。つまり、ステップ10~ステップ13では、行列Aの3列目のベクトルデータVA3(a13、a23、a33)および行列Bの3行目のベクトルデータVB3(b31、b32、b33)がベクトルレジスタ310に格納されている。最終的に、ステップ13で、行列演算器3の積和演算器3の出力レジスタD3に格納されている結果データf33が行列レジスタ110の3列3行目に格納され、行列積演算A×B+Cが完了する。
(まとめ)
 図10に図1、図2の構成をさらに簡略化したプロセッサ装置1の概略構成図の一例を示す。図10に示すプロセッサ装置1は、メモリ60に格納されているM行K列の行列AおよびK行N列の行列Bを読み出し、行列Aと行列Bの行列積を演算し、その演算結果であるM行N列の行列Cをメモリ60に格納する。ここで、L≧M、K、Nとすると、プロセッサ装置1は、L個の積和演算器を備える行列演算器120と、演算結果の行列を保持するL行L列のレジスタを備える行列レジスタ110と、を備え、メモリ60とメモリインタフェース61および62で接続される。プロセッサ装置1では、LSIのトランジスタ資源を行列レジスタ110と行列演算器120に使用することで、メモリ帯域の効率と演算性能を向上することができる。プロセッサ装置1は、メモリ60に格納されているM行K列の行列AおよびK行N列の行列Bをメモリインタフェース61でロードし、行列Aと行列Bの行列積を行列演算器120で演算し、M行N列の行列Cを行列レジスタ110に格納する。そして、演算結果の行列Cを、メモリインタフェース62を通じてメモリ60にストアする。より詳細には、プロセッサ装置1は行列AのM行1列のベクトルと行列Bの1行N列のベクトルをロードし、2つのベクトルの外積を演算し、行列レジスタ110に行列積の中間結果を積算する。この処理をK回繰り返すことで、行列Aと行列Bの行列積が演算される。ここで、一般的なベクトルプロセッサ装置20内で行列積を実行することを考えると、ベクトルレジスタ310がL列しかない為、L個の演算結果しか格納できない。この場合、例えば、演算結果を出力するために、行列Aと行列Bの行列積を完了するまでの間でベクトルレジスタ310とメモリ60とのI/Oが何度も発生し、メモリとプロセッサ装置とのIOがボトルネックとなりやすい。これに対し、本実施形態のプロセッサ装置1であれば、L行×L列の行列レジスタ110を備えるため、演算結果のM行N列の行列Cの各要素の値を行列レジスタ110に格納しておくことができる。また、L列の積和演算器を備える行列演算器120を備え、並行して演算を行うことができるため、ベクトル演算器320だけで演算を行う場合と比べ、行列積演算を高速化することができる。
 また、演算器の数がLSI面積に比例し、メモリ帯域はLSIの辺の長さに比例することに基づいて、演算量に対するデータのロード量の比率が論理的には1/Lとなることに関し、本実施形態によれば、L列の列ベクトルとL行の行ベクトルをメモリ60から読み出す処理を、行列演算器120での行列積演算を行いつつ、L回繰り返し、行列積の演算が完了すると、行列レジスタ110に格納された演算結果を1列ずつメモリ60へ格納する処理をL回繰り返す。これ以外にメモリ60とのIOが生じないため、必要最低限のI/Oによりメモリ帯域を効率的に使用することができ、行列積の演算量に対するデータ量の比率を理論上最小の1/Lにすることができる。つまり、本実施形態によれば、演算量に対するメモリへのデータのロード量の比率を小さくすることができる。また、Lを集積回路に応じて大きくすることにより、メモリ帯域効率と演算性能を向上することができる。
(効果)
 以上説明したとおり、本実施形態に係るプロセッサ装置1では、L行L列の行列積演算を実行するために、行列積の演算量に対するデータ量の比率を小さくし、理論上最小の1/Lにすることを可能とし、行列積で生じるメモリ帯域不足を解消することができる。また、プロセステクノロジの進化により、LSIのサイズが1/A倍になった場合、同一面積のLSIに集積可能なトランジスタはA倍になり、メモリ帯域はA倍になるが、LをA倍にすることでAL行AL列の行列レジスタおよびA×Lの積和演算器が実装可能となり、演算性能はA倍となる。このように本実施形態によれば、演算量に対するデータ量の比率を小さくしてメモリ帯域不足の解消を図るとともに、プロセステクノロジの進化に見合った演算性能の向上を実現することができる。
 なお、上記実施形態では行列レジスタ110が1個の場合を例に説明を行ったが、行列拡張制御部10は、複数の行列レジスタ110を備えていてもよい。行列レジスタ110が複数の場合、さらに効率的に行列積を演算することができる。例えば、行列レジスタが2個(C、D)あれば、ある行列積を計算した後、行列レジスタCの計算結果をメモリ60に転送している間に、行列レジスタDに対して行列積を計算することができる。例えば、行列積の結果の行列Aとメモリにある行列Bの行列積A×Bを計算することもできる。この場合、行列Bの行ベクトルのみメモリ60からロードするため、メモリ帯域は半分でよい。行列積B×Aについても同様である。行列レジスタ110が3個あれば、行列積の結果の行列Aと行列積の結果の行列Bとの行列積A×Bをメモリアクセス無しに演算でき、メモリ帯域のボトルネック化をより効果的に回避することができる。
<第2実施形態>
 図11は、プロセッサ装置の一例を示す第3の概略構成図である。プロセッサ装置800は、メモリとの入出力を行う入出力手段801と、列状又は行状に記憶素子を配置した領域であるベクトル格納手段802と、行ベクトルと列ベクトルとの演算を行う演算手段803と、行列状に記憶素子を配置した領域である行列格納手段804と、を備え、前記ベクトル格納手段802は、前記メモリから前記入出力手段によってロードされた行ベクトルと列ベクトルを格納し、前記演算手段803は、前記ベクトル格納手段に格納された行ベクトルと列ベクトルとの演算を行い、前記行列格納手段804は、前記演算の結果を格納する。
 図12は、プロセッサ装置の動作の一例を示すフローチャートである。
 プロセッサ装置800による演算処理では、メモリからロードされた行ベクトルと列ベクトルとを、プロセッサが備える、列状に記憶素子を配置した領域であるベクトルレジスタに格納し(ステップS801)、前記プロセッサが前記行ベクトルと前記列ベクトルの演算を行い(ステップS802)、前記演算の結果を、前記プロセッサが備える、行列状に記憶素子を配置した領域である行列レジスタに格納し(ステップS803)、前記プロセッサ装置が、前記行列レジスタに格納された前記演算の結果を前記メモリへ出力する(ステップS804)。
 以上のとおり、この開示に係るいくつかの実施形態を説明したが、これら全ての実施形態は、例として提示したものであり、発明の範囲を限定することを意図していない。これらの実施形態は、その他の様々な形態で実施されることが可能であり、発明の要旨を逸脱しない範囲で種々の省略、置き換え、変更を行うことができる。これらの実施形態及びその変形は、発明の範囲や要旨に含まれると同様に、特許請求の範囲に記載された発明とその均等の範囲に含まれる。
<付記>
 実施形態に記載のプロセッサ装置および演算方法は、例えば以下のように把握される。
(1)第1の態様に係るプロセッサ装置は、メモリとの入出力を行う入出力手段と、列状又は行状に記憶素子を配置した領域であるベクトル格納手段と、行ベクトルと列ベクトルとの演算を行う演算手段と、行列状に記憶素子を配置した領域である行列格納手段と、を備え、前記ベクトル格納手段は、前記メモリから前記入出力手段によってロードされた行ベクトルと列ベクトルを格納し、前記演算手段は、前記ベクトル格納手段に格納された行ベクトルと列ベクトルとの演算を行い、前記行列格納手段は、前記演算の結果を格納する。
(2)第2の態様に係るプロセッサ装置は、(1)に記載のプロセッサ装置であって、前記演算手段は、前記行列格納手段の列数と同じ数の積和演算器を備え、前記積和演算器と、前記行列格納手段における前記積和演算器と同じ列に配置された前記記憶素子は接続されている。
(3)第3の態様に係るプロセッサ装置は、(1)~(2)の何れかに記載のプロセッサ装置であって、前記行列格納手段は、前記ベクトル格納手段が格納できる前記列ベクトルの列数以上の列数および行数の前記記憶素子を備える。
(4)第4の態様に係るプロセッサ装置は、(1)~(3)の何れかに記載のプロセッサ装置であって、前記行列格納手段は、前記ベクトル格納手段が格納できる前記列ベクトルの最大の列数と同数の列数および行数の前記記憶素子を備える。
(5)第5の態様に係るプロセッサ装置は、(1)~(4)の何れかに記載のプロセッサ装置であって、前記演算は、行列行列積である。
(6)第6の態様に係るプロセッサ装置は、(1)~(5)の何れかに記載のプロセッサ装置であって、前記ベクトル格納手段と前記行列格納手段は接続されていて、前記行列格納手段に格納された演算結果は、前記ベクトル格納手段へ出力されて前記ベクトル格納手段に格納され、前記入出力手段によって、前記ベクトル格納手段から前記メモリへ出力される。
(7)第7の態様に係るプロセッサ装置は、(1)~(6)の何れかに記載のプロセッサ装置であって、前記演算は、行列AをM行K列の行列、行列BをK行N列の行列とした場合、行列A×行列Bであって、前記ベクトル格納手段によって、前記入出力手段によってロードした前記行列Aの1列を格納して前記演算手段へ出力し、続いて、前記入出力手段によってロードした前記行列Bの1行を格納して前記演算手段へ出力し、前記演算手段によって、前記行列Aの1列と前記行列Bの1行の積を演算して、その演算結果を前記行列格納手段に格納する処理を、行列A×行列Bの演算が完了するまで繰り返す。
(8)第8の態様に係るプロセッサ装置は、(1)~(7)の何れかに記載のプロセッサ装置であって、前記ベクトル格納手段と前記行列格納手段は接続されていて、前記メモリからロードされて前記ベクトル格納手段に格納された列ベクトルを、前記ベクトル格納手段から前記行列格納手段へ出力して前記行列格納手段に格納する。
(9)第9の態様に係るプロセッサ装置は、(8)のプロセッサ装置であって、前記演算は、行列A,行列B,行列CのそれぞれをL行L列の行列とした場合、行列A×行列B+行列Cであって、前記入出力手段は、1列ずつ行列Cの列ベクトルを前記ベクトル格納手段へロードし、前記行列格納手段は、ロードされた前記行列Cの列ベクトルを前記行列格納手段へ出力して格納する処理をL回繰り返して、前記行列Cを前記行列格納手段へ格納し、前記ベクトル格納手段によって、前記入出力手段によってロードした前記行列Aの1列を格納して前記演算手段へ出力し、続いて、前記入出力手段によってロードした前記行列Bの1行を格納して前記演算手段へ出力し、前記演算手段によって、前記行列Aの1列と前記行列Bの1行の積と行列Cの和を演算して、その演算結果を前記行列格納手段に格納する処理を行列A×行列B+行列Cの演算が完了するまで繰り返す。
(10)第10の態様に係るプロセッサ装置は、(1)~(9)の何れかに記載のプロセッサ装置であって、前記ベクトル格納手段にロードされた2つのベクトルデータと、前記行列格納手段に格納された行列データと、を用いた演算を行い、その演算結果を前記行列格納手段に格納することを指示する第1命令と、ベクトル行列ストア命令(VSTM):VSTMは、前記ベクトル格納手段に格納された1つのベクトルデータを前記行列格納手段の行または列へ書き込む第2命令と、前記行列格納手段の何れかの行または列から前記ベクトル格納手段へベクトルデータを書き込む第3命令と、を備える。
(11)第11の態様に係る演算方法は、メモリからロードされた行ベクトルと列ベクトルとを、プロセッサ装置が備える、列状に記憶素子を配置した領域であるベクトルレジスタに格納し、前記プロセッサ装置が前記行ベクトルと前記列ベクトルの演算を行い、前記演算の結果を、前記プロセッサ装置が備える、行列状に記憶素子を配置した領域である行列レジスタに格納し、前記プロセッサ装置が、前記行列レジスタに格納された前記演算の結果を前記メモリへ出力する。
 上記したプロセッサ装置および演算方法によれば、演算量に対するメモリへのデータのロード量の比率を小さくすることができる。
1・・・プロセッサ装置
10・・・行列拡張制御部
20・・・ベクトルプロセッサ装置
30・・・ベクトル拡張制御部
40・・・スカラプロセッサ
60・・・メモリ
110・・・行列レジスタ
111・・・レジスタ
120・・・行列演算器
121・・・積和演算器
150・・・演算器インタフェース制御部
160・・・行列レジスタアクセス制御部
310・・・ベクトルレジスタ
311・・・レジスタ
320・・・ベクトル演算器
321・・・積和演算器
410・・・スカラレジスタ
420・・・スカラ演算器
480・・・ロードストア制御部
490・・・命令制御部
800・・・プロセッサ装置
801・・・入出力手段
802・・・ベクトル格納手段
803・・・演算手段
804・・・行列格納手段

Claims (11)

  1.  メモリとの入出力を行う入出力手段と、
     列状に記憶素子を配置した領域であるベクトル格納手段と、
     行ベクトルと列ベクトルとの演算を行う演算手段と、
     行列状に記憶素子を配置した領域である行列格納手段と、
     を備え、
     前記ベクトル格納手段は、前記メモリから前記入出力手段によってロードされた行ベクトルと列ベクトルを格納し、
     前記演算手段は、前記ベクトル格納手段に格納された行ベクトルと列ベクトルとの演算を行い、
     前記行列格納手段は、前記演算の結果を格納する、
     プロセッサ装置。
  2.  前記演算手段は、前記行列格納手段の列数と同じ数の積和演算器を備え、
     前記積和演算器と、前記行列格納手段における前記積和演算器と同じ列に配置された前記記憶素子は接続されている、
     請求項1に記載のプロセッサ装置。
  3.  前記行列格納手段は、
     前記ベクトル格納手段が格納できる前記列ベクトルの最大の列数以上の列数および行数の前記記憶素子を備える、
     請求項1または請求項2に記載のプロセッサ装置。
  4.  前記行列格納手段は、
     前記ベクトル格納手段が格納できる前記列ベクトルの列数と同数の列数および行数の前記記憶素子を備える、
     請求項1または請求項2に記載のプロセッサ装置。
  5.  前記演算は、行列行列積である、
     請求項1または請求項2に記載のプロセッサ装置。
  6.  前記ベクトル格納手段と前記行列格納手段は接続されていて、前記行列格納手段に格納された演算結果は、前記ベクトル格納手段へ出力されて前記ベクトル格納手段に格納され、前記入出力手段によって、前記ベクトル格納手段から前記メモリへ出力される、
     請求項1または請求項2に記載のプロセッサ装置。
  7.  前記演算は、行列AをM行K列の行列、行列BをK行N列の行列とした場合、行列A×行列Bであって、
     前記ベクトル格納手段によって、前記入出力手段によってロードした前記行列Aの1列と前記行列Bの1行を格納して前記演算手段へ出力し、
     前記演算手段によって、前記行列Aの1列と前記行列Bの1行の積を演算して、その演算結果を前記行列格納手段に格納する処理を、行列A×行列Bの演算が完了するまで繰り返す、
     請求項1または請求項2に記載のプロセッサ装置。
  8.  前記ベクトル格納手段と前記行列格納手段は接続されていて、前記メモリからロードされて前記ベクトル格納手段に格納された列ベクトルを、前記ベクトル格納手段から前記行列格納手段へ出力して前記行列格納手段に格納する、
     請求項1または請求項2に記載のプロセッサ装置。
  9.  前記演算は、行列A,行列B,行列CのそれぞれをL行L列の行列とした場合、行列A×行列B+行列Cであって、
     前記入出力手段は、1列ずつ行列Cの列ベクトルを前記ベクトル格納手段へロードし、前記行列格納手段は、ロードされた前記行列Cの列ベクトルを前記行列格納手段へ出力して格納する処理をL回繰り返して、前記行列Cを前記行列格納手段へ格納し、
     前記ベクトル格納手段によって、前記入出力手段によってロードした前記行列Aの1列と前記行列Bの1行を格納して前記演算手段へ出力し、
     前記演算手段によって、前記行列Aの1列と前記行列Bの1行の積と行列Cの和を演算して、その演算結果を前記行列格納手段に格納する処理を、行列A×行列B+行列Cの演算が完了するまで繰り返す、
     請求項8に記載のプロセッサ装置。
  10.  前記ベクトル格納手段にロードされた2つのベクトルデータと、前記行列格納手段に格納された行列データと、を用いた演算を行い、その演算結果を前記行列格納手段に格納することを指示する第1命令と、ベクトル行列ストア命令(VSTM):VSTMは、前記ベクトル格納手段に格納された1つのベクトルデータを前記行列格納手段の行または列へ書き込む第2命令と、前記行列格納手段の何れかの行または列から前記ベクトル格納手段へベクトルデータを書き込む第3命令と、
     を備える請求項1または請求項2に記載のプロセッサ装置。
  11.  メモリからロードされた行ベクトルと列ベクトルとを、プロセッサ装置が備える、列状に記憶素子を配置した領域であるベクトルレジスタに格納し、
     前記プロセッサ装置が前記行ベクトルと前記列ベクトルの演算を行い、
     前記演算の結果を、前記プロセッサ装置が備える、行列状に記憶素子を配置した領域である行列レジスタに格納し、
     前記プロセッサ装置が、前記行列レジスタに格納された前記演算の結果を前記メモリへ出力する、
     演算方法。
PCT/JP2024/010054 2024-03-14 2024-03-14 プロセッサ装置および演算方法 WO2024195694A1 (ja)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/JP2024/010054 WO2024195694A1 (ja) 2024-03-14 2024-03-14 プロセッサ装置および演算方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2024/010054 WO2024195694A1 (ja) 2024-03-14 2024-03-14 プロセッサ装置および演算方法

Publications (1)

Publication Number Publication Date
WO2024195694A1 true WO2024195694A1 (ja) 2024-09-26

Family

ID=92841472

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2024/010054 WO2024195694A1 (ja) 2024-03-14 2024-03-14 プロセッサ装置および演算方法

Country Status (1)

Country Link
WO (1) WO2024195694A1 (ja)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005149492A (ja) * 2003-11-18 2005-06-09 Internatl Business Mach Corp <Ibm> 行列ベクトル・レジスタ・アレイの二次元アドレッシング
WO2013054468A1 (ja) * 2011-10-14 2013-04-18 パナソニック株式会社 転置演算装置とその集積回路、および転置処理方法
WO2021023956A1 (en) * 2019-08-05 2021-02-11 Arm Limited Data structure relinquishing

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005149492A (ja) * 2003-11-18 2005-06-09 Internatl Business Mach Corp <Ibm> 行列ベクトル・レジスタ・アレイの二次元アドレッシング
WO2013054468A1 (ja) * 2011-10-14 2013-04-18 パナソニック株式会社 転置演算装置とその集積回路、および転置処理方法
WO2021023956A1 (en) * 2019-08-05 2021-02-11 Arm Limited Data structure relinquishing

Similar Documents

Publication Publication Date Title
US11775313B2 (en) Hardware accelerator for convolutional neural networks and method of operation thereof
JP7009609B2 (ja) 加速数学エンジン
US8595280B2 (en) Apparatus and method for performing multiply-accumulate operations
CN109871236B (zh) 具有低功率并行矩阵乘法流水线的流处理器
JP7616757B2 (ja) 行列演算アクセラレータの命令のための装置、方法、及びシステム
CN110415157B (zh) 一种矩阵乘法的计算方法及装置
US6539368B1 (en) Neural processor, saturation unit, calculation unit and adder circuit
US9355061B2 (en) Data processing apparatus and method for performing scan operations
CN108885550B (zh) 复数乘法指令
US12141226B2 (en) Systems and processes for organizing and controlling multiple matrix processor circuits
CN101398753A (zh) 用于执行扫描运算的系统、方法及计算机程序产品
US20210389948A1 (en) Mixed-element-size instruction
KR102780370B1 (ko) Pim(processing-in-memory) 연산 수행 방법, 및 관련 메모리 디바이스 및 시스템
KR101202445B1 (ko) 프로세서
JP7495194B2 (ja) 積和演算用のプロセッサ・ユニット
US7013321B2 (en) Methods and apparatus for performing parallel integer multiply accumulate operations
JP2518293B2 (ja) デ−タフロ−プロセツサ
CN220773595U (zh) 可重配置处理电路以及处理核心
WO2024195694A1 (ja) プロセッサ装置および演算方法
JP3333779B2 (ja) 行列演算装置
US11416261B2 (en) Group load register of a graph streaming processor
CN113298236A (zh) 基于数据流结构的低精度神经网络计算装置及加速方法
JPS6165336A (ja) 高速演算方式
US20250036363A1 (en) Flooring divide using multiply with right shift
US20250165254A1 (en) Looping instruction

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 24774832

Country of ref document: EP

Kind code of ref document: A1