WO2021020848A2 - 인공 신경망을 위한 행렬 연산기 및 행렬 연산 방법 - Google Patents

인공 신경망을 위한 행렬 연산기 및 행렬 연산 방법 Download PDF

Info

Publication number
WO2021020848A2
WO2021020848A2 PCT/KR2020/009881 KR2020009881W WO2021020848A2 WO 2021020848 A2 WO2021020848 A2 WO 2021020848A2 KR 2020009881 W KR2020009881 W KR 2020009881W WO 2021020848 A2 WO2021020848 A2 WO 2021020848A2
Authority
WO
WIPO (PCT)
Prior art keywords
matrix
elements
row
multiplication
column
Prior art date
Application number
PCT/KR2020/009881
Other languages
English (en)
French (fr)
Other versions
WO2021020848A3 (ko
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 한양대학교 산학협력단
Publication of WO2021020848A2 publication Critical patent/WO2021020848A2/ko
Publication of WO2021020848A3 publication Critical patent/WO2021020848A3/ko

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/16Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/06Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
    • G06N3/063Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means

Definitions

  • the present invention relates to an artificial neural network module and a scheduling method thereof, and to an artificial neural network module for highly efficient computation and a scheduling method thereof.
  • Such artificial neural networks require learning based on vast amounts of data, and in this process, a large amount of addition and multiplication operations must be performed. Accordingly, in the chip structure that performs operations for artificial neural networks, the multiply-accumulate operater (MAC) and The same multiple operation circuits must be provided.
  • MAC multiply-accumulate operater
  • Deep learning accelerators were presented in different forms depending on the usage environment and purpose.
  • GPUs Graphics Processing Unit
  • FPGAs field programmable gate arrays
  • ASICs application specific integrated circuits
  • NPU Neurological Processing Unit
  • the control circuit becomes complicated. Accordingly, some computing devices are not used and remain in an idle state in the process of performing the calculation of the artificial neural network, resulting in inefficiency. Additional power may be consumed.
  • An object of the present invention is to provide a matrix operator and a matrix operation method capable of increasing operation efficiency and reducing power consumption by simultaneously performing a multiplication operation and an addition operation in parallel according to a pipeline technique.
  • a matrix operator for an artificial neural network for achieving the above object includes: a first buffer for receiving and storing a first matrix, which is a multiplicand matrix; A second buffer for receiving and storing a second matrix, which is a multiplier matrix multiplied by the first matrix; And receiving a plurality of elements sequentially selected in column units in the first matrix, and receiving a plurality of elements sequentially selected in row units in the second matrix corresponding to the columns selected in the first matrix, and in the first matrix
  • the first matrix and the second matrix are multiplied by multiplying each element of the selected column with all the elements of the row selected in the second matrix, and the result of the multiplication operation between the columns of the first matrix and the rows of the second matrix that are sequentially selected.
  • an operation unit that obtains a result matrix that is a result of a matrix multiplication operation of the matrix.
  • the operation unit receives and multiplies each of the elements of the column selected in the first matrix and all the elements in the row selected in the second matrix, and multiplies the result of multiplication between the elements to the accumulated value of the previous multiplication result. It may include a plurality of processing lanes for obtaining elements of a row of a partial accumulation matrix by adding.
  • each of the plurality of processing lanes adds the result of the inter-element multiplication to the accumulated value of the previous multiplication result, the element of the column in the first matrix and the row in the second matrix selected next according to a predetermined sequence. All elements are applied and multiplication operation can be performed.
  • Each of the plurality of processing lanes includes a plurality of process elements, and each of the plurality of process elements corresponds to one of a corresponding element in a selected column of the first matrix and a plurality of elements in a row selected in the second matrix.
  • a multiplier for multiplying by receiving one element;
  • An adder for updating the accumulated value by adding the multiplication result output from the multiplier to the accumulated value obtained by accumulating the multiplication result of the previously applied element;
  • an accumulation register that stores the accumulated value updated by the adder.
  • the second buffer may select the i-th row of the second matrix.
  • the matrix calculator is implemented as an artificial neural network module for performing a designated operation on at least one layer among a plurality of layers of the artificial neural network, and the first matrix is a feature map applied to the at least one layer, and the second matrix May be a kernel defined in the at least one layer.
  • a method for calculating a matrix for an artificial neural network includes: receiving and storing a first matrix as a multiplicand and a second matrix as a multiplier matrix multiplied by the first matrix; Receiving a plurality of elements sequentially selected in column units in the first matrix and a plurality of elements sequentially selected in row units in the second matrix corresponding to columns selected in the first matrix; Multiplying each element of the column selected in the first matrix with all the elements in the row selected in the second matrix; And obtaining a result matrix that is a result of a matrix multiplication operation of the first matrix and the second matrix by cumulatively adding a multiplication operation result between the columns of the first matrix and the rows of the second matrix that are sequentially selected.
  • the matrix calculator and the matrix calculation method for an artificial neural network enable a matrix multiplication operation and an addition operation performed in multiple layers of the artificial neural network to be simultaneously performed in parallel, thereby increasing computation efficiency and power It can reduce consumption.
  • FIG. 1 shows a schematic structure of an example of an artificial neural network.
  • FIG. 2 is a diagram showing a general matrix multiplication algorithm.
  • FIG. 3 shows the number of times of multiplication and addition operations required in the matrix multiplication algorithm of FIG. 2.
  • FIG. 4 shows a schematic structure of a matrix operator according to an embodiment of the present invention.
  • FIG. 5 shows a detailed configuration of an operation processing lane of FIG. 4.
  • FIG. 6 shows a detailed configuration of the process element of FIG. 5.
  • FIG. 7 shows a matrix multiplication algorithm according to an embodiment of the present invention.
  • FIG. 8 shows a method for calculating a matrix according to an embodiment of the present invention.
  • FIG. 1 shows a schematic structure of an example of an artificial neural network.
  • CNN convolution neural network
  • LeNet-5 a representative convolutional neural network developed for postal code recognition and number recognition.
  • LeNet-5 receives an input image of size 32 ⁇ 32, repeatedly performs convolution and sub-sampling operations, extracts a feature map (f.map), and extracts it from the feature map. It is configured to select a value corresponding to the most probable class among the predefined classes based on the specified feature value.
  • LeNet-5 is a neural network developed to recognize numbers
  • LeNet-5 classifies feature values into numbers between 0 and 9 as an example, and can select one of the numbers between 0 and 9 as a result value.
  • LeNet-5 will be described as an example, but other convolutional neural networks and artificial neural networks also have basically similarities, and the concept of the present invention is not limited to LeNet-5 and can be applied to various artificial neural networks.
  • C denotes a convolution layer
  • S denotes a sub-sampling layer
  • FC denotes a fully-connected layer
  • numbers after C, S, and FC denote layers. Represents the index. That is, LeNet-5 includes three convolutional layers (C1, C2, C3), two sub-sampling layers (S1, S2), and two fully connected layers (FC1, FC2).
  • each of a plurality of convolutional layers receives a feature map (f.map) (or an input image (Input)), and the applied feature map (f. .map) (or the input image (Input)) corresponding to each of the convolutional layers (C1, C2, C3) a predetermined kernel and a convolution operation is performed.
  • the convolution operation consists of a number of multiplication and addition operations.
  • a multiplication operation is also performed in a plurality of fully connected layers FC1 and FC2.
  • artificial neural networks perform matrix multiplication and matrix addition operations by converting a feature map (or input image) and a kernel into a matrix according to a predetermined algorithm such as im2col (image blocks into columns). By doing so, the calculation speed is improved.
  • the inter-matrix multiplication operation obtains an operation result by multiplying specified elements in each matrix and then adding all the multiplied results.
  • the process of adding the inter-element multiplication result must be repeated a plurality of times according to the number of values to be added.
  • FIG. 2 is a diagram illustrating a general matrix multiplication operation method
  • FIG. 3 shows the number of multiplication operations and addition operations required in the matrix multiplication operation method of FIG. 2.
  • the multiplication operation of the matrix is performed by the elements of each row (#1, #2, #3, ..., #m) of matrix A of size m ⁇ k and B of size k ⁇ n.
  • One element of matrix C which is the result of multiplying matrix A and matrix B, by multiplying the corresponding elements among the elements of each column of the matrix (&1, &2, &3, ..., &n) and adding the multiplied values (# , &).
  • the matrix A is called a multiplicand matrix
  • the matrix B is called a multiplier matrix
  • an operation for obtaining the elements (#1, &1) of the 1st row and 1st column of the C matrix is read, the matrix A, which is the multiplicand, in row units, according to the general matrix operation rule, and the matrix B, which is the multiplier matrix.
  • the rows of the read matrix A and the columns of the matrix B are multiplied with each other, and all the multiplied results are added.
  • the elements in the first row (#1) of matrix A and the elements in the first column (&1) of matrix B are multiplied with each other.
  • an operation element such as a process element PE is configured to receive two inputs and perform a multiplication or addition operation. Therefore, as shown in FIG. 3, it is necessary to select 16 multiplication values by two and perform an addition operation first, and then to repeatedly perform an addition operation by selecting two each of the added values. This means that four addition operations must be repeatedly performed for 16 multiplication values, and as a result, the operation time of the addition operation for the multiplication result is very long compared to the inter-element multiplication operation.
  • inter-element multiplication and addition operations are performed sequentially. In other words, the multiplication operation and the addition operation must be performed separately. Therefore, as shown in FIG. 3, a total of five operations are required for multiplication between 16 elements.
  • FIG. 4 shows a schematic structure of a matrix operator according to an embodiment of the present invention
  • FIG. 5 shows a detailed configuration of an operation processing lane of FIG. 4
  • FIG. 6 shows a detailed configuration of a process element of FIG. 5.
  • the matrix operator 100 includes an operation control unit 110, a first buffer unit 120, and a second buffer unit 130. And an operation unit 140, and, as described above, may be used as a module of an artificial neural network.
  • the operation control unit 110 receives a plurality of matrices to be performed in each layer of the artificial neural network.
  • the plurality of matrices to be performed may be at least one feature map (or input image) applied to a layer and at least one kernel designated for each layer.
  • the operation control unit 110 selects two matrices to be operated from among the applied matrices, and transfers the selected two matrices to the first buffer unit 120 and the second buffer unit 130 together with an operation command. do.
  • the matrix A which is a multiplicand matrix for at least one feature map applied to the layer of the artificial neural network
  • the multiplier for the kernel designated in the layer of the artificial neural network is applied to the second buffer unit 130.
  • Apply the matrix B which is a matrix.
  • the operation control unit 110 may receive the result of performing the matrix operation from the operation unit 140 and transmit it to a memory (not shown) and store it.
  • the operation control unit 110 applies the selected matrix together with the operation command in order to perform a matrix multiplication operation by selecting an element of each matrix based on the matrix multiplication algorithm according to the present embodiment to be described later.
  • the first buffer unit 120 selects an element in a column unit from the matrix A applied from the operation control unit 110 according to an operation command, and transmits it to the operation unit 140.
  • the second buffer unit 130 selects an element in row units from the applied B matrix according to the operation command and transmits the selected element to the operation unit 140.
  • the operation unit 140 may include a plurality of operation processing lanes SIMDL.
  • each of the plurality of processing lanes SIMDL may include a plurality of process elements PE and a SIMD unit SIMDU, as shown in FIG. 5.
  • SIMD Single Instruction Multiple Data
  • PEs process elements
  • SIMD SIMD unit
  • SIMD unit allows the first and second buffer units 120 and 130 to perform the same operation in parallel in which a plurality of process elements PE are assigned to elements applied in a row or column unit.
  • SIMD unit may be implemented as hardware in the operation unit 140, but may be implemented as software that designates an operation performed by the operation unit 140. Also, in some cases, it may be implemented in the operation control unit 110.
  • Each of the plurality of process elements PE receives elements to be computed from among the elements (a, b) of matrix A and matrix B from the first and second buffer units 120 and 130 and performs multiplication or addition operation. do.
  • each of the plurality of process elements PE may be implemented with a multiply-accumulate operater (MAC).
  • each of the plurality of process elements PE may include a multiplier MUL, an adder ADD, and an accumulation register ACC.
  • the multiplier (MUL) multiplies the element (a) of the matrix A applied from the first buffer unit 120 and the element (b) of the matrix B applied from the second buffer unit 130 to output to the adder ADD.
  • the adder ADD updates the accumulated subtotal by receiving and adding the output value of the multiplier MUL and the previously calculated accumulated subtotal stored in the accumulation register ACC.
  • the accumulation register ACC stores the updated accumulated subtotal output from the adder ADD.
  • FIG. 7 shows a matrix multiplication algorithm according to an embodiment of the present invention.
  • elements are selected in column units (&1, &2, ..., &k) from matrix A, which is a multiplicand matrix, and column units (&1, By selecting elements with &2, ..., &n), the corresponding elements among the selected elements are multiplied with each other, and then all of them are added to perform a multiplication operation.
  • the first buffer 120 selects elements in column units (&1, &2, ..., &k) from the matrix A, which is a multiplicand matrix
  • the second buffer 130 selects elements in row units (#1, #2, ..., #k) from matrix B, which is a multiplier matrix, and transmits them to the operator 140.
  • Each of the plurality of operation processing lanes SIMDL of the operation unit 140 receives corresponding elements from matrix A and matrix B, multiplies each other, and accumulates and adds the multiplied results.
  • each of the plurality of operation processing lanes is one of the elements selected in column units (&1, &2, ..., &k) of matrix A and row units of matrix B (#1, # 2, ..., #k) are multiplied with each other.
  • the first processing lane among the plurality of processing lanes is the first column (&1) of matrix A.
  • the multiplier MUL is an element a (a 0,0 ) and elements b (b 0,0 , b 0,1 , ..., b
  • the corresponding b element among 0,n ) is applied, multiplied, and transferred to the adder ADD. Since there is no previously calculated multiplication result, that is, there is no accumulated value previously stored in the accumulation register ACC, the adder ADD transfers the output of the multiplier MUL as it is to the accumulation register ACC and stores it.
  • the first processing lane is the elements (a 0,0 ) of the first row and the first column of matrix A and the elements of the first row (#1) of the matrix B (b 0,0 , b 0,1 , ..
  • the multiplication result between ., b 0,n ) is the element value (c 0 0,0 , c 0 0,1 , ..., c 0 ) of the first row (#1) of the first cumulative matrix (C 0 ) It is obtained as 0,n ).
  • the obtained element values (c 0 0,0 , c 0 0,1 , ..., c 0 0,n ) of the first row (#1) are stored in the accumulation register (ACC) of each process element (PE). Is saved.
  • the second arithmetic processing lane is an element (a 1,0 ) of the second row of the first column (&1) of matrix A and the b elements (b 0,0 ,) of the first row (#1) of matrix B.
  • b 0,1 , ..., b 0,n is applied, and a element (a 1,0 ) is assigned to b elements (b 0,0 , b 0,1 , ..., b 0,n )
  • it is acquired and stored as the element value (c 0 1,0 , c 0 1,1 , ..., c 0 1,n ) of the second row (#2) of the first cumulative matrix (C 0 ) do.
  • the mth arithmetic processing lane is an element a (a m,0 ) of the mth row of the first column (&1) of the matrix A and the b elements (b 0 ) of the first row (#1) of the matrix B. ,0 , b 0,1 , ..., b 0,n ) by multiplying the element values of the mth row (#m) of the first cumulative matrix (C 0 ) (c 0 m,0 , c 0 m, 1 , ..., c 0 m,n ) and store.
  • the multiplication of all the elements in the first column (&1) of the matrix A and all the elements in the first row (#1) of the matrix B is performed in one operation by a plurality of operation processing lanes (SIML) of the operation unit 140. It is performed simultaneously.
  • SIML operation processing lanes
  • the first buffer 120 transfers the a elements (a 0,1 , a 1,1 , ..., a m,1 ) of the second column (&2) of the matrix A to a plurality of processing lanes ( SIMDL) to the corresponding operation processing lane
  • the second buffer 130 transmits the b elements (b 1,0 , b 1 , 1 , ..., b 1 ) of the second row (#2) of the B matrix ,n ) are transferred to each of a plurality of operation processing lanes (SIMDL).
  • each process element (PE) of the operation processing lane (SIMDL) one a element (a 0,1 , a 1,1 , ..., a m ) of the second column (&2) to which a multiplier (MUL) is applied ,1 ) and the corresponding b element among the b elements (b 1,0 , b 1,1 , ..., b 1,n ) in the second row (#2) are multiplied, and the adder (ADD) is a multiplier ( MUL), the accumulated value (c 0 0,0 , c 0 0,1 , ..., c 0 0,n ) previously acquired and stored in the accumulator register (ACC) is applied and added, 2 Obtained as the element values (c 1 0,0 , c 1 0,1 , ..., c 1 0,n ) of the first row (#1) of the cumulative matrix (C 1 ), and the obtained element values ( c 1 0,0 , c 1 0,1 , ..., c 1 0,n ) of
  • the second arithmetic processing lane is the elements (a 1,1 ) of the second row of the second column (&2) of matrix A and the elements (b 1,0 , b) of the second row of matrix B (#2).
  • 1,0 , ..., b 1,n ) is applied, and element a (a 1,1 ) is assigned to each of the elements (b 1,0 , b 1,0 , ..., b 1,n )
  • the m-th operation processing lane is an element a (a m,0 ) in the m-th row of the second column (&2) of the matrix A and the b elements (b 1,0 ,) of the second row (#2) of the matrix B.
  • the second cumulative matrix by multiplying b 1,0 , ..., b 1 ,n ) and adding the cumulative values (c 0 m,0 , c 0 m,1 , ..., c 0 m,n ) and (C 1) stores the value obtained with the elements (c 1 m, 0, c 1 m, 1, ..., c 1 m, n) of the m-th row (#m) of the.
  • the operation unit 140 sequentially receives the elements up to the kth column (&k) of the matrix A and the kth row (#k) of the matrix B, multiplies the applied elements, and adds the previously calculated cumulative value to finally As a result of multiplying the matrix A and the matrix B, the kth cumulative matrix C k is obtained.
  • each of the plurality of process elements PE of the p-th SIDM lane corresponds to the corresponding first in matrix A.
  • Each of the a elements in row p (a p,0 , a p,1 , ..., a p,k ) is assigned to the corresponding b elements in the pth column in the B matrix (b 0,p , b 1,p , ..., b k,p ) is sequentially multiplied, and the multiplication result is added to the accumulated value of the previous multiplication result, and the elements of the pth row of the kth accumulation matrix (C k ) (c k p,0 , c k p ,0 , ..., c k p, n ) value.
  • each of the process elements PE is the same as the process of calculating one element (#, &) of the C matrix in the general matrix multiplication operation shown in FIG. 2.
  • the operation unit performs multiplication by simultaneously applying the elements of matrix A and matrix B required to calculate one element (#, &) of matrix C, and then adds the result of the multiplication. Since the operation has to be repeatedly performed, as shown in FIG. 3, each time each element (#, &) of the C matrix is acquired, the addition operation has to be performed multiple times after the multiplication operation.
  • the multiplier (MUL) in each of the plurality of process elements (PE) of the plurality of operation processing lanes (SIMDL) is the multiplication result output from the previous multiplier (MUL) by the adder (ADD) and the accumulated value stored in the accumulation register (ACC).
  • a multiplication operation can be performed by receiving elements a and b to be multiplied next. That is, a multiplier (MUL) and an adder (ADD) may perform simultaneous operations according to a pipeline technique.
  • the matrix multiplication operation time can be greatly reduced by making the matrix multiplication operation rarely require time for the addition operation.
  • FIG. 8 shows a method for calculating a matrix according to an embodiment of the present invention.
  • the matrix operation method of FIG. 8 when the matrix operation method of FIG. 8 is described, first, two matrices to be multiplied are obtained (S10 ).
  • One of the two matrices is an m ⁇ k multiplicand is referred to as an A matrix, and the other is a k ⁇ n multiplier matrix and may be referred to as a B matrix.
  • the matrix A may be all or part of the feature map (f.map) (or input image) input to each layer of the artificial neural network
  • the matrix B may be all or part of the kernel specified in each layer. have.
  • the i-th column is selected from the matrix A, which is the multiplicand matrix (S20). Then, the ith row is selected from the matrix B, which is a multiplier matrix (S30).
  • the initial value of i is 1, and first column of matrix A and 1 row of matrix B are selected.
  • each of the elements in the i-th column of the selected matrix A (a 0,i , a 1,i , ..., a m,i ) is selected from all the elements in the i-th row of the selected matrix B (b i,0 , b i, By multiplying by 1 , ..., b i, n ), m ⁇ n multiplication results are obtained (S40).
  • the obtained multiplication result is added to the previously obtained accumulated value (S50). If there is no previously acquired cumulative value, the multiplication result is acquired as an initial cumulative value, and if there is a previously acquired cumulative value, the result of adding the acquired multiplication result to the previously acquired cumulative value is stored as an updated cumulative value ( S60).
  • i is less than the number of columns of matrix A or k, which is the number of rows of matrix B (S70). If i is less than k (i ⁇ k), i is changed to i+1 (S80). Accordingly, the next column and the next row previously selected from the matrix A and the matrix B are selected (S20).
  • a cumulative matrix composed of the stored m ⁇ n cumulative values is output as a C matrix, which is a result of matrix multiplication of matrix A and matrix B (S90).
  • the method according to the present invention may be implemented as a computer program stored in a medium for execution on a computer.
  • the computer-readable medium may be any available medium that can be accessed by a computer, and may also include all computer storage media.
  • Computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, and ROM (Read Dedicated memory), RAM (random access memory), CD (compact disk)-ROM, DVD (digital video disk)-ROM, magnetic tape, floppy disk, optical data storage device, and the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Mathematical Physics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computing Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Analysis (AREA)
  • General Health & Medical Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Computational Linguistics (AREA)
  • Pure & Applied Mathematics (AREA)
  • Computational Mathematics (AREA)
  • Molecular Biology (AREA)
  • Mathematical Optimization (AREA)
  • Neurology (AREA)
  • Algebra (AREA)
  • Databases & Information Systems (AREA)
  • Complex Calculations (AREA)
  • Image Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

본 발명은 피승수 행렬인 제1 행렬을 인가받아 저장하는 제1 버퍼, 제1 행렬에 곱해지는 승수 행렬인 제2 행렬을 인가받아 저장하는 제2 버퍼 및 제1 행렬에서 열 단위로 순차적 선택된 다수의 원소를 인가받고, 제1 행렬에서 선택된 열에 대응하여 제2 행렬에서 행 단위로 순차적으로 선택된 다수의 원소를 인가받으며, 제1 행렬에서 선택된 열의 원소 각각을 제2 행렬에서 선택된 행의 모든 원소와 곱셈 연산하고, 순차적 선택된 제1 행렬의 열 및 제2 행렬의 행 사이의 곱셈 연산 결과를 누적 가산하여 제1 행렬과 제2 행렬의 행렬 곱셈 연산 결과인 결과 행렬을 획득하는 연산부를 포함하여, 연산 효율성과 연산 속도를 높이고 전력 소모를 줄일 수 있는 인공 신경망을 위한 행렬 연산기 및 행렬 연산 방법을 제공할 수 있다.

Description

인공 신경망을 위한 행렬 연산기 및 행렬 연산 방법
본 발명은 인공 신경망 모듈 및 이의 스케쥴링 방법에 관한 것으로, 고효율 연산 처리를 위한 인공 신경망 모듈 및 이의 스케쥴링 방법에 관한 것이다.
최근 인간의 두뇌가 패턴을 인식하는 방법을 모사하여 두뇌와 비슷한 방식으로 여러 정보를 처리하도록 구성되는 인공 신경망(artificial neural network)이 다양한 분야에 적용되어 사용되고 있다.
이러한 인공 신경망은 방대한 데이터를 바탕으로 학습을 필요로 하며, 이과정에서 대량의 덧셈 및 곱셈 연산을 수행해야 하며, 이에 인공 신경망을 위한 연산을 수행하는 칩 구조에서는 MAC 연산기(Multiply-accumulate operater)와 같은 다수의 연산 회로가 구비되어야 한다.
따라서 최근에는 인공 신경망의 딥러닝에 특화된 새로운 종류의 하드웨어 가속기 분야가 큰 주목을 받고 있다. 딥러닝 가속기는 사용 환경 및 목적에 따라 서로 다른 형태로 제시되었다. 일예로 성능을 중시하는 서버나 워크스테이션 등에는 GPU(Graphics Processing Unit)가 주로 사용되고, 저전력을 우선시 하는 스마트폰과 같은 엣지 디바이스에서는 FPGA(Field Programmable Gate Array) 또는 ASIC(application specific integrated circuit)을 이용하여 설계한 전용 하드웨어, 즉 NPU(Neural Processing Unit)가 주로 사용되고 있다.
그러나 현재까지 나온 많은 가속기들은 전용 하드웨어 특성상 다양한 인공신경망에서 사용하는 다양한 형태의 레이어(layer) 또는 텐서(tensor)에 대응할 유연성이 부족하다. 이러한 단점은 현재 매우 다양하게 사용되고 있는 딥러닝 어플리케이션 및 모델들을 대응하기 힘들다는 점에서 문제가 있다.
한편, 다수의 연산 장치를 가변적으로 사용하기 위해서는 제어 회로가 복잡해지며, 이에 인공 신경망의 연산 수행 과정에서 일부 연산 장치가 이용되지 않고 유휴 상태에 머물러 있는 경우가 발생하게 되어 비효율성이 유발되며, 불필요한 전력이 추가로 소모될 수 있다.
본 발명의 목적은 곱셈연산과 덧셈 연산을 파이프라인 기법에 따라 병렬로 동시에 수행하여 연산 효율성을 높이고 전력 소모를 줄일 수 있는 행렬 연산기 및 행렬 연산 방법을 제공하는데 있다.
상기 목적을 달성하기 위한 본 발명의 일 실시예에 따른 인공 신경망을 위한 행렬 연산기는 피승수 행렬인 제1 행렬을 인가받아 저장하는 제1 버퍼; 상기 제1 행렬에 곱해지는 승수 행렬인 제2 행렬을 인가받아 저장하는 제2 버퍼; 및 상기 제1 행렬에서 열 단위로 순차적 선택된 다수의 원소를 인가받고, 상기 제1 행렬에서 선택된 열에 대응하여 상기 제2 행렬에서 행 단위로 순차적으로 선택된 다수의 원소를 인가받으며, 상기 제1 행렬에서 선택된 열의 원소 각각을 상기 제2 행렬에서 선택된 행의 모든 원소와 곱셈 연산하고, 순차적 선택된 제1 행렬의 열 및 제2 행렬의 행 사이의 곱셈 연산 결과를 누적 가산하여 상기 제1 행렬과 상기 제2 행렬의 행렬 곱셈 연산 결과인 결과 행렬을 획득하는 연산부를 포함한다.
상기 연산부는 각각 상기 제1 행렬에서 선택된 열의 원소 중 대응하는 하나의 원소와 상기 제2 행렬에서 선택된 행의 모든 원소를 인가받아 곱셈하고, 원소간 곱셈 결과를 이전 곱셈 결과의 누적 가산된 누적값에 가산하여 부분 누적 행렬의 행의 원소를 획득하는 다수의 연산 처리 레인을 포함할 수 있다.
상기 다수의 연산 처리 레인 각각은 원소간 곱셈 결과를 이전 곱셈 결과의 누적 가산된 누적값에 가산하는 동안, 기지정된 순차에 따라 다음 선택되는 상기 제1 행렬에서 열의 원소와 상기 제2 행렬에서 행의 모든 원소를 인가받아 곱셈 연산을 수행할 수 있다.
상기 다수의 연산 처리 레인 각각은 다수의 프로세스 소자를 포함하고, 상기 다수의 프로세스 소자 각각은 상기 제1 행렬의 선택된 열에서 대응하는 하나의 원소와 상기 제2 행렬에서 선택된 행의 다수의 원소 중 대응하는 하나의 원소를 인가받아 곱셈 연산하는 곱셈기; 상기 곱셈기에서 출력되는 곱셈 결과를 이전 인가된 원소의 곱셈 결과를 누적 가산한 누적값과 가산하여 누적값을 갱신하는 가산기; 및 상기 가산기에서 갱신된 누적값을 저장하는 누적 레지스터를 포함할 수 있다.
상기 제2 버퍼는 상기 제1 버퍼에서 상기 제1 행렬의 제i(여기서 i는 자연수) 열이 선택되면, 상기 제2 행렬의 제i 행을 선택할 수 있다.
상기 행렬 연산기는 인공 신경망의 다수의 레이어 중 적어도 하나의 레이어에 지정된 연산을 수행하기 위한 인공 신경망 모듈로 구현되고, 상기 제1 행렬은 상기 적어도 하나의 레이어로 인가되는 특징맵이고, 상기 제2 행렬은 상기 적어도 하나의 레이어에 기지정된 커널일 수 있다.
상기 목적을 달성하기 위한 본 발명의 다른 실시예에 따른 인공 신경망을 위한 행렬 연산 방법은 피승수 행렬인 제1 행렬과 상기 제1 행렬에 곱해지는 승수 행렬인 제2 행렬을 인가받아 저장하는 단계; 상기 제1 행렬에서 열 단위로 순차적 선택된 다수의 원소와, 상기 제1 행렬에서 선택된 열에 대응하여 상기 제2 행렬에서 행 단위로 순차적으로 선택된 다수의 원소를 인가받는 단계; 상기 제1 행렬에서 선택된 열의 원소 각각을 상기 제2 행렬에서 선택된 행의 모든 원소와 곱셈 연산하는 단계; 및 순차적 선택된 제1 행렬의 열 및 제2 행렬의 행 사이의 곱셈 연산 결과를 누적 가산하여 상기 제1 행렬과 상기 제2 행렬의 행렬 곱셈 연산 결과인 결과 행렬을 획득하는 단계를 포함한다.
따라서, 본 발명의 실시예에 따른 인공 신경망을 위한 행렬 연산기 및 행렬 연산 방법은 인공 신경망의 다수의 레이어에서 수행되는 행렬 곱셈 연산과 덧셈 연산을 병렬로 동시에 수행할 수 있도록 하여, 연산 효율성을 높이고 전력 소모를 줄일 수 있다. 특히 파이프 라인 기법에 따라 곱셈 연산이 수행되는 동안 덧셈 연산이 누산되도록 하여 연산 효율성을 극대화 할 수 있다.
도 1은 인공 신경망의 일예에 대한 개괄적 구조를 나타낸다.
도 2는 일반적인 행렬의 곱셈 연산 알고리즘을 나타낸 도면이다.
도 3은 도 2의 행렬 곱셈 연산 알고리즘에서 요구되는 곱셈 연산 및 덧셈 연산의 횟수를 나타낸다.
도 4는 본 발명의 일 실시예에 따른 행렬 연산기의 개략적 구조를 나타낸다.
도 5는 도 4의 연산 처리 레인의 상세 구성을 나타낸다.
도 6은 도 5의 프로세스 소자의 상세 구성을 나타낸다.
도 7은 본 발명의 일 실시예에 따른 행렬의 곱셈 연산 알고리즘을 나타낸다.
도 8은 본 발명의 일 실시예에 따른 행렬 연산 방법을 나타낸다.
본 발명과 본 발명의 동작상의 이점 및 본 발명의 실시에 의하여 달성되는 목적을 충분히 이해하기 위해서는 본 발명의 바람직한 실시예를 예시하는 첨부 도면 및 첨부 도면에 기재된 내용을 참조하여야만 한다.
이하, 첨부한 도면을 참조하여 본 발명의 바람직한 실시예를 설명함으로써, 본 발명을 상세히 설명한다. 그러나, 본 발명은 여러 가지 상이한 형태로 구현될 수 있으며, 설명하는 실시예에 한정되는 것이 아니다. 그리고, 본 발명을 명확하게 설명하기 위하여 설명과 관계없는 부분은 생략되며, 도면의 동일한 참조부호는 동일한 부재임을 나타낸다.
명세서 전체에서, 어떤 부분이 어떤 구성요소를 "포함"한다고 할 때, 이는 특별히 반대되는 기재가 없는 한 다른 구성요소를 제외하는 것이 아니라, 다른 구성요소를 더 포함할 수 있는 것을 의미한다. 또한, 명세서에 기재된 "...부", "...기", "모듈", "블록" 등의 용어는 적어도 하나의 기능이나 동작을 처리하는 단위를 의미하며, 이는 하드웨어나 소프트웨어 또는 하드웨어 및 소프트웨어의 결합으로 구현될 수 있다.
도 1은 인공 신경망의 일예에 대한 개괄적 구조를 나타낸다.
도 1은 인공 신경망(artificial neural network)의 대표적인 일예로서, 컨볼루션 신경망(Convolution Neural Network: 이하 CNN)을 도시하였다. 특히 컨볼루션 신경망에서도 광학적 문자 인식(Optical character reader)에 사용되는 인공 신경망으로, 우편물의 우편 번호 인식, 및 숫자 인식을 위해 개발된 대표적인 컨볼루션 신경망인 LeNet-5의 개괄적 구조를 나타낸다.
LeNet-5는 일예로 32 × 32 크기의 입력 이미지(Input)를 인가받아, 컨볼루션 연산 및 서브 샘플링 연산을 반복적으로 수행하며 특징맵(feature map: f.map)을 추출하고, 특징맵에서 추출된 특징값을 기반으로 기지정된 클래스 중 가장 가능성이 큰 클래스에 대응하는 값을 선택하도록 구성된다.
LeNet-5는 숫자를 인식하기 위해 개발된 신경망이므로, LeNet-5는 일예로 특징값을 0 ~ 9 사이의 숫자로 분류하고, 0 ~ 9 사이의 숫자 중 하나를 결과값으로 선택할 수 있다.
이하에서는 일예로 LeNet-5를 설명하지만, 다른 컨볼루션 신경망 및 인공 신경망 또한 기본적으로는 유사성을 갖고 있으며, 본 발명의 개념은 LeNet-5에 한정되지 않고, 다양한 인공 신경망에 적용될 수 있다.
도 1에서 C는 컨볼루션 레이어(Convolution layer), S는 서브 샘플링 레이어(Sub-sampling layer), FC는 완전 연결 레이어(Fully-Connected layer)를 의미하며, C, S, FC 뒤의 숫자는 레이어 인덱스를 나타낸다. 즉 LeNet-5는 3 개의 컨볼루션 레이어(C1, C2, C3), 2 개의 서브 샘플링 레이어(S1, S2) 및 2 개의 완전 연결 레이어(FC1, FC2)를 포함한다.
도 1에 도시된 바와 같은 CNN의 경우, 다수의 컨볼루션 레이어(C1, C2, C3) 각각이 특징맵(f.map)(또는 입력 이미지(Input))을 인가받고, 인가된 특징맵(f.map)(또는 입력 이미지(Input))을 대응하는 컨볼루션 레이어(C1, C2, C3) 각각에 기지정된 커널과 컨볼루션 연산을 수행하게 된다. 그리고 컨볼루션 연산은 다수의 곱셈 및 덧셈 연산으로 구성된다. 또한 다수의 완전 연결 레이어(FC1, FC2)에서도 곱셈 연산이 수행된다.
즉 도 1에 도시된 CNN의 경우, 다수의 곱셈 연산과 덧셈 연산을 수행해야 한다. 그리고 CNN이 아닌 다른 인공 신경망의 경우에도 기본적으로 곱셈 연산과 덧셈 연산을 수행하도록 구성된다.
일반적으로 인공 신경망은 특징맵(f.map)(또는 입력 이미지(Input))과 커널을 im2col(image blocks into columns)과 같은 기지정된 알고리즘에 따라 행렬로 변환하여, 행렬 곱셈 및 행렬 덧셈 연산을 수행함으로써 연산 속도를 향상시키고 있다.
행렬간 곱셈 연산은 잘 알려진 바와 같이, 각 행렬에서 지정된 원소들을 곱한 후, 곱해진 결과를 모두 가산하여 연산 결과를 획득한다. 이때 원소간 곱셈의 경우, 병렬로 수행되어 1회의 곱셈 연산이 수행되는 반해, 원소간 곱셈 결과를 가산하는 과정은 가산되어야 하는 값의 개수에 따라 다수 횟수로 반복 연산이 수행되어야 한다.
도 2는 일반적인 행렬의 곱셈 연산 방법을 나타낸 도면이고, 도 3은 도 2의 행렬 곱셈 연산 방법에서 요구되는 곱셈 연산 및 덧셈 연산의 횟수를 나타낸다.
도 2에 도시된 바와 같이, 행렬의 곱셈 연산은 m × k 크기의 A 행렬의 각 행(#1, #2, #3, ..., #m)의 원소들과 k × n 크기의 B 행렬의 각 열(&1, &2, &3, ..., &n)의 원소들 중 서로 대응하는 원소들을 곱하고 곱해진 값들을 더하여, A 행렬과 B 행렬의 곱셈 결과인 C 행렬의 하나의 원소(#, &)를 획득한다.
여기서 A 행렬을 피승수 행렬(Multiplicand Matrix)이라 하고, B 행렬을 승수 행렬(Multiplier Matrix)이라 한다.
도 3을 참조하여 C 행렬의 1행 1열의 원소(#1, &1)을 획득하기 위한 연산을 살펴보면, 일반적인 행렬의 연산 규칙에 따라 피승수 행렬인 A 행렬을 행단위로 리드하고, 승수 행렬인 B 행렬을 열 단위로 리드하여, 리드된 A 행렬의 행과 B 행렬의 열을 서로 곱하고 곱해진 결과를 모두 더한다.
일예로 우선 A 행렬의 제 1행(#1)의 원소들과 B 행렬의 제 1열(&1)의 원소 각각을 서로 곱한다. 여기서는 일예로 k가 16인 것으로 가정하였으며, 이에 행렬 연산기가 16개의 프로세스 소자(Processing Element: 이하 PE)를 구비하고 있다면, A 행렬의 제 1행(#1)의 16개의 원소들과 B 행렬의 제 1열(&1)의 16개의 원소가 병렬로 동시에 곱셈 연산이 수행될 수 있다. 즉 A 행렬의 제 1행(#1)의 원소들과 B 행렬의 제 1열(&1)의 원소에 대한 곱셈은 1회의 병렬 연산만이 수행된다.
그러나 이후 대응하는 원소간 곱셈으로 획득된 16개의 곱셈 값들의 합은 1회의 연산으로 계산되지 않는다. 일반적으로 프로세스 소자(PE) 와 같은 연산 소자는 2개의 입력을 인가받아 곱셈 또는 덧셈 연산을 수행하도록 구성된다. 따라서 도 3에 도시된 바와 같이, 16개의 곱셈값들을 2개씩 선택하여 우선 덧셈 연산을 수행하고, 덧셈 연산된 값에 대해 다시 2개씩 선택하여 반복적으로 덧셈 연산을 수행해야 한다. 이는 16개의 곱셈값들에 대해 4번의 덧셈 연산이 반복적으로 수행되어야 함을 의미하며, 결과적으로 원소간 곱셈 연산에 비해 곱셈 결과에 대한 덧셈 연산의 연산 시간이 매우 길다는 것을 의미한다.
또한 원소간 곱셈 결과를 가산해야 하므로, 원소간 곱셈과 덧셈 연산이 순차적으로 수행된다. 즉 곱셈 연산과 덧셈 연산이 개별적으로 수행되어야 한다. 따라서 도 3에 도시된 바와 같이, 16개의 원소간 곱셈에 대해 총 5회의 연산을 필요로 한다.
그리고 이는 C 행렬의 하나의 원소(예를 들면, c 0,0)에 대한 값을 획득하기 위한 연산으로, 각각 16개의 프로세스 소자(PE)를 포함하는 연산 처리 레인의 개수가 m 개라고 가정하면, C 행렬 전체에 대해서는 A 행렬과 B 행렬의 크기에 비례하는 횟수만큼 수행되어야 하므로, 결과적으로 n × 5 회의 연산을 필요로 하게 된다.
따라서 행렬의 연산 속도를 가속하기 위해서는 덧셈 연산에 소요되는 시간을 저감하는 것이 매우 중요하다.
도 4는 본 발명의 일 실시예에 따른 행렬 연산기의 개략적 구조를 나타내고, 도 5는 도 4의 연산 처리 레인의 상세 구성을 나타내며, 도 6은 도 5의 프로세스 소자의 상세 구성을 나타낸다.
도 4 내지 도 6을 참조하여, 본 실시예에 따른 행렬 연산기(100)를 설명하면, 행렬 연산기(100)는 연산 제어부(110), 제1 버퍼부(120), 제2 버퍼부(130) 및 연산부(140)를 포함하며, 상기한 바와 같이, 인공 신경망의 모듈로서 이용될 수 있다.
연산 제어부(110)는 인공 신경망의 각 레이어에서 연산이 수행되어야 할 다수의 행렬을 인가받는다. 여기서 연산이 수행되어야 하는 다수의 행렬은 레이어로 인가되는 적어도 하나의 특징맵(또는 입력 이미지)과 각각의 레이어에 지정된 적어도 하나의 커널일 수 있다.
연산 제어부(110)는 인가된 다수의 행렬 중 연산이 수행되어야 하는 2개의 행렬을 선택하고, 선택된 2개의 행렬을 연산 명령과 함께 제1 버퍼부(120) 및 제2 버퍼부(130)로 전달한다. 이때 제1 버퍼부(120)로는 인공 신경망의 레이어로 인가되는 적어도 하나의 특징맵에 대한 피승수 행렬인 A 행렬을 인가하고, 제2 버퍼부(130)로는 인공 신경망의 레이어에 지정된 커널에 대한 승수 행렬인 B 행렬을 인가한다.
그리고 연산 제어부(110)는 연산부(140)으로부터 행렬 연산 수행 결과를 인가받아 메모리(미도시) 등으로 전송하여 저장할 수 있다.
연산 제어부(110)가 선택된 행렬을 연산 명령과 함께 인가하는 것은 후술하는 본 실시예에 따른 행렬의 곱셈 알고리즘에 기반하여, 각 행렬의 원소를 선택하여 행렬 곱셈 연산을 수행할 수 있도록 하기 위함이다.
제1 버퍼부(120)는 연산 명령에 따라 연산 제어부(110)에서 인가된 A 행렬에서 열 단위로 원소를 선택하여 연산부(140)로 전달한다. 그리고 제2 버퍼부(130)는 연산 명령에 따라 인가된 B 행렬에서 행 단위로 원소를 선택하여 연산부(140)로 전달한다.
연산부(140)는 다수의 연산 처리 레인(SIMDL)을 포함할 수 있다. 그리고 다수의 연산 처리 레인(SIMDL) 각각은 도 5에 도시된 바와 같이, 다수의 프로세스 소자(PE)와 SIMD 유닛(SIMDU)을 포함할 수 있다.
최근 행렬 연산기는 연산 효율성을 높이기 위해, 복잡한 연산을 단일 명령으로 일괄 처리할 수 있도록 SIMD(Single Instruction Multiple Data) 기법을 이용하는 것이 일반적이다. SIMD 기법은 다수의 프로세스 소자(PE)들이 동일(또는 유사)한 연산을 다수의 데이터에 적용하여 동시에 처리하는 방식으로, 주로 백터(vector) 프로세서에서 이용되는 기술이다.
SIMD 기법에서는 명령의 효율성을 극대화 하기 위해, 단일 명령으로 다중 데이터를 처리할 수 있는 다수의 명령어 집합을 저장하고 있다. 그리고 저장된 명령어 집합 각각은 다수의 프로세스 소자(PE)에 대해 데이터 수준 병렬성(Data Level Parallelism; DLP)을 이용하여 동시에 병렬로 연산을 수행하도록 한다. 즉 SIMD 유닛(SIMDU)은 제1 및 제2 버퍼부(120, 130)에서 행 또는 열 단위로 인가되는 원소들에 다수의 프로세스 소자(PE)가 지정된 동일한 연산을 병렬로 수행하도록 한다.
여기서 SIMD 유닛(SIMDU)은 연산부(140)내의 하드웨어로 구현될 수도 있으나 연산부(140)에서 수행되는 동작을 지정하는 소프트웨어로 구현될 수도 있다. 또한 경우에 따라서는 연산 제어부(110) 내에 구현될 수도 있다.
다수의 프로세스 소자(PE) 각각은 제1 및 제2 버퍼부(120, 130)로부터 A 행렬과 B 행렬의 원소(a, b)들 중 서로 연산되어야 하는 원소들을 인가받아 곱셈 또는 덧셈 연산을 수행한다. 그리고 다수의 프로세스 소자(PE) 각각은 MAC 연산기(Multiply-accumulate operater)로 구현될 수 있다.
도 6을 참조하면, 다수의 프로세스 소자(PE) 각각은 곱셈기(MUL), 가산기(ADD) 및 누적 레지스터(ACC)를 포함할 수 있다.
곱셈기(MUL)는 제1 버퍼부(120)로부터 인가된 A 행렬의 원소(a)와 제2 버퍼부(130)로부터 인가된 B 행렬의 원소(b)를 서로 곱하여 가산기(ADD)로 출력한다. 가산기(ADD)는 곱셈기(MUL)의 출력값과 누적 레지스터(ACC)에 저장된 이전 계산된 누적 부분합을 인가받아 가산하여 누적 부분합을 갱신한다. 누적 레지스터(ACC)는 가산기(ADD)에서 출력되는 갱신된 누적 부분합을 저장한다.
도 7은 본 발명의 일 실시예에 따른 행렬의 곱셈 연산 알고리즘을 나타낸다.
이하에서는 도 4 내지 도 6을 참조하여, 도 7의 행렬의 곱셈 연산 알고리즘을 설명한다.
일반적인 행렬의 곱셈 연산에서는 도 2에 도시된 바와 같이, 피승수 행렬인 A 행렬에서 열 단위(&1, &2, ..., &k)로 원소를 선택하고, 승수 행렬인 B 행렬에서 열 단위(&1, &2, ..., &n)로 원소를 선택하여 선택된 원소들 중 대응하는 원소들을 서로 곱한 후 모두 가산하여 곱셈 연산을 수행하였다.
그에 반해 도 7에 도시된 본 실시예에 따른 행렬의 곱셈 연산 방법에서는 제1 버퍼(120)가 피승수 행렬인 A 행렬에서 열 단위(&1, &2, ..., &k)로 원소를 선택하고, 제2 버퍼(130)가 승수 행렬인 B 행렬에서 행 단위(#1, #2, ..., #k)로 원소를 선택하여 연산부(140)로 전송한다.
연산부(140)의 다수의 연산 처리 레인(SIMDL) 각각은 A 행렬과 B 행렬에서 대응하는 원소들을 인가받아 서로 곱하고, 곱해진 결과를 누적하여 가산한다.
특히 본 실시예에서 다수의 연산 처리 레인(SIMDL) 각각은 A 행렬에서 열 단위(&1, &2, ..., &k)로 선택된 원소들 중 하나의 원소와 B 행렬의 행 단위(#1, #2, ..., #k)로 선택된 다수의 원소들을 서로 곱한다.
일예로 A 행렬의 제1 열(&1)과 B 행렬의 제1 행(#1)인 선택된 경우, 다수의 연산 처리 레인(SIMDL) 중 제1 연산 처리 레인은 A 행렬의 제1 열(&1)의 제1 행의 a 원소(a 0,0)와 B 행렬의 제1 행(#1)의 b 원소들(b 0,0, b 0,1, ..., b 0,n)을 인가받고, a 원소(a 0,0)를 b 원소들(b 0,0, b 0,1, ..., b 0,n) 각각에 곱한다.
이때, 제1 연산 처리 레인의 다수개의 프로세스 소자(PE) 각각에서 곱셈기(MUL)는 a 원소(a 0,0)와 b 원소들(b 0,0, b 0,1, ..., b 0,n) 중 대응하는 하나의 b 원소를 인가받아 곱셈하여 가산기(ADD)로 전달한다. 이전 계산된 곱셈 결과가 없으므로, 즉 누적 레지스터(ACC)에 이전 저장된 누적값이 없으므로, 가산기(ADD)는 곱셈기(MUL)의 출력을 그대로 누적 레지스터(ACC)로 전달하여 저장한다.
즉 제1 연산 처리 레인은 A 행렬의 제1행 제1열의 원소(a 0,0)와 B 행렬의 제1 행(#1)의 원소들(b 0,0, b 0,1, ..., b 0,n) 사이의 곱셈 결과를 제1 누적 행렬(C 0)의 제1 행(#1)의 원소값(c 0 0,0, c 0 0,1, ..., c 0 0,n)으로 획득한다. 그리고 획득된 제1 행(#1)의 원소값(c 0 0,0, c 0 0,1, ..., c 0 0,n)은 각 프로세스 소자(PE)의 누적 레지스터(ACC)에 저장된다.
한편, 제2 연산 처리 레인은 A 행렬의 제1 열(&1)의 제2 행의 원소(a 1,0)와 B 행렬의 제1 행(#1)의 b 원소들(b 0,0, b 0,1, ..., b 0,n)을 인가받고, a 원소(a 1,0)를 b 원소들(b 0,0, b 0,1, ..., b 0,n) 각각에 곱하여, 제1 누적 행렬(C 0)의 제2 행(#2)의 원소값(c 0 1,0, c 0 1,1, ..., c 0 1,n)으로 획득하여 저장한다.
이와 같은 방식으로 제m 연산 처리 레인은 A 행렬의 제1 열(&1)의 제m 행의 a 원소(a m,0)와 B 행렬의 제1 행(#1)의 b 원소들(b 0,0, b 0,1, ..., b 0,n)을 곱하여, 제1 누적 행렬(C 0)의 제m 행(#m)의 원소값(c 0 m,0, c 0 m,1, ..., c 0 m,n)으로 획득하여 저장한다.
즉 연산부(140)의 다수의 연산 처리 레인(SIML)에 의해 A 행렬의 제1 열(&1)의 모든 원소와 B 행렬의 제1 행(#1)의 모든 원소에 대한 곱셈이 1회의 연산으로 동시에 수행된다.
이후, 제1 버퍼(120)는 A 행렬의 제2 열(&2)의 a 원소들(a 0,1, a 1,1, ..., a m,1)을 각각 다수의 연산 처리 레인(SIMDL) 중 대응하는 연산 처리 레인으로 전달하고, 제2 버퍼(130)는 B 행렬의 제2 행(#2)의 b 원소들(b 1,0, b 1,1, ..., b 1,n)을 다수의 연산 처리 레인(SIMDL) 각각으로 전달한다.
이에 연산 처리 레인(SIMDL) 각각의 프로세스 소자(PE)에서는 곱셈기(MUL)가 인가된 제2 열(&2)의 하나의 a 원소(a 0,1, a 1,1, ..., a m,1)와 제2 행(#2)의 b 원소들(b 1,0, b 1,1, ..., b 1,n) 중 대응하는 b 원소를 곱하고, 가산기(ADD)가 곱셈기(MUL)에서 출력되는 곱셈 결과에 이전 획득되어 누적 레지스터(ACC)에 저장된 누적값(c 0 0,0, c 0 0,1, ..., c 0 0,n)을 인가받아 가산하여, 제2 누적 행렬(C 1)의 제1 행(#1)의 원소값(c 1 0,0, c 1 0,1, ..., c 1 0,n)으로 획득하고, 획득된 원소값(c 1 0,0, c 1 0,1, ..., c 1 0,n)을 다시 누적 레지스터(ACC)에 저장한다.
유사하게 제2 연산 처리 레인은 A 행렬의 제2 열(&2)의 제2 행의 원소(a 1,1)와 B 행렬의 제2 행(#2)의 원소들(b 1,0, b 1,0, ..., b 1,n)을 인가받고, a 원소(a 1,1)를 원소들(b 1,0, b 1,0, ..., b 1,n) 각각에 곱하고, 곱셈 결과를 누적 레지스터(ACC)에 저장된 누적값(c 0 1,0, c 0 1,1, ..., c 0 1,n)과 가산하여, 제2 누적 행렬(C 1)의 제2 행(#2)의 원소값(c 1 1,0, c 1 1,1, ..., c 1 1,n)으로 획득하여 저장한다.
그리고 제m 연산 처리 레인은 A 행렬의 제2 열(&2)의 제m 행의 a 원소(a m,0)와 B 행렬의 제2 행(#2)의 b 원소들(b 1,0, b 1,0, ..., b 1,n)을 곱하고, 누적값(c 0 m,0, c 0 m,1, ..., c 0 m,n)을 가산하여, 제2 누적 행렬(C 1)의 제m 행(#m)의 원소값(c 1 m,0, c 1 m,1, ..., c 1 m,n)으로 획득하여 저장한다.
이와 같이 연산부(140)는 A 행렬의 제k 열(&k)과 B 행렬의 제k 행(#k)까지의 원소들을 순차적으로 인가받고, 인가된 원소들을 곱하고 이전 계산된 누적값과 가산하여 최종적으로 A 행렬과 B 행렬의 행렬 곱셈 결과인 제k 누적 행렬(C k)을 획득한다.
상기한 행렬 곱셈 알고리즘을 다수의 연산 처리 레인(SIMDL)의 다수의 프로세스 소자(PE) 각각의 관점에서 다시 설명하면, 제p SIDM 레인의 다수의 프로세스 소자(PE) 각각은 A 행렬에서 대응하는 제p 행의 a 원소들(a p,0, a p,1, ..., a p,k) 각각을 B 행렬에서 대응하는 제p 열의 b 원소들(b 0,p, b 1,p, ..., b k,p)과 순차적으로 곱하고, 곱셈 결과를 이전 곱셈 결과의 누적값에 가산하여 제k 누적 행렬(C k)의 제p 행의 원소(c k p,0, c k p,0, ..., c k p,n)값으로 획득한다.
그리고 이러한 프로세스 소자(PE) 각각의 계산 방식은 도 2에 도시된 일반적인 행렬의 곱셈 연산에서 C 행렬의 하나의 원소(#, &)를 계산하는 과정과 동일하다. 다만 도 2의 알고리즘의 경우, 연산부가 C 행렬의 하나의 원소(#, &)를 계산하기 위해 요구되는 A 행렬과 B 행렬의 원소들을 동시에 인가받아 곱셈을 수행하고, 곱셈 수행 결과에 대해 다시 덧셈 연산을 반복적으로 수행해야 하므로, 도 3에 도시된 바와 같이, C 행렬의 각 원소(#, &)를 획득할 때마다 한번의 곱셈 연산 이후 다수 횟수로 덧셈 연산을 수행해야 하였다.
그러나 도 7에 도시된 본 실시예에 따른 행렬 곱셈 알고리즘에서는 순차적으로 누적되는 누적 행렬(C 0, C 1, ..., C k)을 획득하므로, k번의 곱셈 연산과 k번의 덧셈 연산만으로 A 행렬과 B 행렬 사이의 곱셈 결과인 C 행렬을 획득할 수 있다.
특히 다수의 연산 처리 레인(SIMDL)의 다수의 프로세스 소자(PE) 각각에서 곱셈기(MUL)는, 가산기(ADD)가 이전 곱셈기(MUL)에서 출력되는 곱셈 결과와 누적 레지스터(ACC)에 저장된 누적값을 가산하는 동안, 다음 곱셈 연산되어야 하는 a 원소와 b 원소를 인가받아 곱셈 연산을 수행할 수 있다. 즉 파이프 라인(Pipeline) 기법에 따라 곱셈기(MUL)와 가산기(ADD)가 동시 연산을 수행할 수 있다.
이는 A 행렬과 B 행렬 사이의 곱셈 결과인 C 행렬을 획득하기 위해 2k 만큼의 연산 시간이 소요되는 것이 아니라, k+1 만큼의 연산 시간이 소요되는 것을 의미한다.
즉 행렬의 곱셈 연산에서 덧셈 연산을 위한 시간을 거의 필요로 하지 않도록 하여 행렬 곱셈 연산 시간을 크게 줄일 수 있다.
도 8은 본 발명의 일 실시예에 따른 행렬 연산 방법을 나타낸다.
도 4 내지 도 7을 참조하여, 도 8의 행렬 연산 방법을 설명하면, 우선 곱셈 연산 대상이 되는 2개의 행렬을 획득한다(S10). 2개의 행렬 중 하나는 m × k 크기의 피승수 행렬로서 A 행렬이라 하고, 나머지 하나는 k × n 크기의 승수 행렬로서 B 행렬이라 할 수 있다. 여기서 A 행렬은 인공 신경망의 각 레이어에 입력되는 특징맵(f.map)(또는 입력 이미지(Input))의 전체 또는 일부 일 수 있으며, B 행렬은 각 레이어에 기지정된 커널의 전체 또는 일부 일 수 있다.
연산 대상인 2개의 행렬이 획득되면, 피승수 행렬인 A 행렬에서 제i 열을 선택한다(S20). 그리고 승수 행렬인 B 행렬에서 제i 행을 선택한다(S30). 여기서 i의 초기값은 1로서, 우선 A 행렬의 제1 열과 B 행렬의 1행을 선택한다.
그리고 선택된 A 행렬의 제i 열의 원소(a 0,i, a 1,i, ..., a m,i) 각각을 선택된 B 행렬의 제i 행의 모든 원소(b i,0, b i,1, ..., b i,n)와 곱하여, m × n개의 곱셈 결과를 획득한다(S40).
m × n개의 곱셈 결과를 획득되면, 획득된 곱셈 결과를 이전 획득된 누적값에 가산한다(S50). 만일 이전 획득된 누적값이 없으면, 곱셈 결과를 초기 누적값으로 획득하고, 이전 획득된 누적값이 있으면, 획득된 곱셈 결과를 이전 획득된 누적값에 가산한 결과를 갱신된 누적값으로 저장한다(S60).
그리고 i가 A 행렬의 열 개수 또는 B 행렬의 행 개수인 k보다 작은지 판별한다(S70). 만일 i가 k보다 작으면(i < k), i를 i+1로 변경한다(S80). 이에 A 행렬과 B 행렬에서 이전 선택된 다음 열과 다음 행을 선택한다(S20).
그러나, i가 k이상이면, 저장된 m × n 크기의 누적값으로 구성된 누적 행렬을 A 행렬과 B 행렬의 행렬 곱셈 결과인 C 행렬로서 출력한다(S90).
본 발명에 따른 방법은 컴퓨터에서 실행 시키기 위한 매체에 저장된 컴퓨터 프로그램으로 구현될 수 있다. 여기서 컴퓨터 판독가능 매체는 컴퓨터에 의해 액세스 될 수 있는 임의의 가용 매체일 수 있고, 또한 컴퓨터 저장 매체를 모두 포함할 수 있다. 컴퓨터 저장 매체는 컴퓨터 판독가능 명령어, 데이터 구조, 프로그램 모듈 또는 기타 데이터와 같은 정보의 저장을 위한 임의의 방법 또는 기술로 구현된 휘발성 및 비휘발성, 분리형 및 비분리형 매체를 모두 포함하며, ROM(판독 전용 메모리), RAM(랜덤 액세스 메모리), CD(컴팩트 디스크)-ROM, DVD(디지털 비디오 디스크)-ROM, 자기 테이프, 플로피 디스크, 광데이터 저장장치 등을 포함할 수 있다.
본 발명은 도면에 도시된 실시예를 참고로 설명되었으나 이는 예시적인 것에 불과하며, 본 기술 분야의 통상의 지식을 가진 자라면 이로부터 다양한 변형 및 균등한 타 실시예가 가능하다는 점을 이해할 것이다.
따라서, 본 발명의 진정한 기술적 보호 범위는 첨부된 청구범위의 기술적 사상에 의해 정해져야 할 것이다.

Claims (10)

  1. 피승수 행렬인 제1 행렬을 인가받아 저장하는 제1 버퍼;
    상기 제1 행렬에 곱해지는 승수 행렬인 제2 행렬을 인가받아 저장하는 제2 버퍼; 및
    상기 제1 행렬에서 열 단위로 순차적 선택된 다수의 원소를 인가받고, 상기 제1 행렬에서 선택된 열에 대응하여 상기 제2 행렬에서 행 단위로 순차적으로 선택된 다수의 원소를 인가받으며, 상기 제1 행렬에서 선택된 열의 원소 각각을 상기 제2 행렬에서 선택된 행의 모든 원소와 곱셈 연산하고, 순차적 선택된 제1 행렬의 열 및 제2 행렬의 행 사이의 곱셈 연산 결과를 누적 가산하여 상기 제1 행렬과 상기 제2 행렬의 행렬 곱셈 연산 결과인 결과 행렬을 획득하는 연산부를 포함하는 행렬 연산기.
  2. 제1 항에 있어서, 상기 연산부는
    각각 상기 제1 행렬에서 선택된 열의 원소 중 대응하는 하나의 원소와 상기 제2 행렬에서 선택된 행의 모든 원소를 인가받아 곱셈하고, 원소간 곱셈 결과를 이전 곱셈 결과의 누적 가산된 누적값에 가산하여 부분 누적 행렬의 행의 원소를 획득하는 다수의 연산 처리 레인을 포함하는 행렬 연산기.
  3. 제1 항에 있어서, 상기 다수의 연산 처리 레인 각각은
    원소간 곱셈 결과를 이전 곱셈 결과의 누적 가산된 누적값에 가산하는 동안, 기지정된 순차에 따라 다음 선택되는 상기 제1 행렬에서 열의 원소와 상기 제2 행렬에서 행의 모든 원소를 인가받아 곱셈 연산을 수행하는 행렬 연산기.
  4. 제2 항에 있어서, 상기 다수의 연산 처리 레인 각각은
    다수의 프로세스 소자를 포함하고,
    상기 다수의 프로세스 소자 각각은
    상기 제1 행렬의 선택된 열에서 대응하는 하나의 원소와 상기 제2 행렬에서 선택된 행의 다수의 원소 중 대응하는 하나의 원소를 인가받아 곱셈 연산하는 곱셈기;
    상기 곱셈기에서 출력되는 곱셈 결과를 이전 인가된 원소의 곱셈 결과를 누적 가산한 누적값과 가산하여 누적값을 갱신하는 가산기; 및
    상기 가산기에서 갱신된 누적값을 저장하는 누적 레지스터를 포함하는 행렬 연산기.
  5. 제1 항에 있어서, 상기 제2 버퍼는
    상기 제1 버퍼에서 상기 제1 행렬의 제i(여기서 i는 자연수) 열이 선택되면, 상기 제2 행렬의 제i 행을 선택하는 행렬 연산기.
  6. 제1 항에 있어서, 상기 행렬 연산기는
    인공 신경망의 다수의 레이어 중 적어도 하나의 레이어에 지정된 연산을 수행하기 위한 인공 신경망 모듈로 구현되고,
    상기 제1 행렬은 상기 적어도 하나의 레이어로 인가되는 특징맵이고, 상기 제2 행렬은 상기 적어도 하나의 레이어에 기지정된 커널인 행렬 연산기.
  7. 피승수 행렬인 제1 행렬과 상기 제1 행렬에 곱해지는 승수 행렬인 제2 행렬을 인가받아 저장하는 단계;
    상기 제1 행렬에서 열 단위로 순차적 선택된 다수의 원소와, 상기 제1 행렬에서 선택된 열에 대응하여 상기 제2 행렬에서 행 단위로 순차적으로 선택된 다수의 원소를 인가받는 단계;
    상기 제1 행렬에서 선택된 열의 원소 각각을 상기 제2 행렬에서 선택된 행의 모든 원소와 곱셈 연산하는 단계; 및
    순차적 선택된 제1 행렬의 열 및 제2 행렬의 행 사이의 곱셈 연산 결과를 누적 가산하여 상기 제1 행렬과 상기 제2 행렬의 행렬 곱셈 연산 결과인 결과 행렬을 획득하는 단계를 포함하는 행렬 연산 방법.
  8. 제7 항에 있어서, 상기 결과 행렬을 획득하는 단계는
    상기 모든 원소와 곱셈하는 단계에서 획득되는 원소간 곱셈 결과를 이전 대응하는 원소간 곱셈 결과가 누적 가산된 누적값에 가산하여 부분 누적 행렬의 원소를 획득하는 행렬 연산 방법.
  9. 제7 항에 있어서, 상기 다수의 연산 처리 레인 각각은
    원소간 곱셈 결과를 이전 곱셈 결과의 누적 가산된 누적값에 가산하는 동안, 기지정된 순차에 따라 다음 선택되는 상기 제1 행렬에서 열의 원소와 상기 제2 행렬에서 행의 모든 원소를 인가받아 곱셈 연산을 수행하는 행렬 연산 방법.
  10. 제7 항에 있어서, 상기 선택된 다수의 원소를 인가받는 단계는
    상기 제1 행렬의 제i(여기서 i는 자연수) 열이 선택되면, 상기 제2 행렬의 제i 행의 다수의 원소를 인가받는 행렬 연산 방법.
PCT/KR2020/009881 2019-07-31 2020-07-29 인공 신경망을 위한 행렬 연산기 및 행렬 연산 방법 WO2021020848A2 (ko)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR1020190092932A KR102372869B1 (ko) 2019-07-31 2019-07-31 인공 신경망을 위한 행렬 연산기 및 행렬 연산 방법
KR10-2019-0092932 2019-07-31

Publications (2)

Publication Number Publication Date
WO2021020848A2 true WO2021020848A2 (ko) 2021-02-04
WO2021020848A3 WO2021020848A3 (ko) 2021-03-25

Family

ID=74228727

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/KR2020/009881 WO2021020848A2 (ko) 2019-07-31 2020-07-29 인공 신경망을 위한 행렬 연산기 및 행렬 연산 방법

Country Status (2)

Country Link
KR (1) KR102372869B1 (ko)
WO (1) WO2021020848A2 (ko)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102561205B1 (ko) * 2021-04-16 2023-07-28 포항공과대학교 산학협력단 분산 sram 아키텍쳐를 가지는 모바일넷 하드웨어 가속기 및 상기 가속기의 채널 정상 데이터 플로우 설계 방법

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180007302A1 (en) * 2016-07-01 2018-01-04 Google Inc. Block Operations For An Image Processor Having A Two-Dimensional Execution Lane Array and A Two-Dimensional Shift Register
JP2018022339A (ja) * 2016-08-03 2018-02-08 富士通株式会社 演算処理装置及び演算処理装置の制御方法
US20180113840A1 (en) * 2016-10-25 2018-04-26 Wisconsin Alumni Research Foundation Matrix Processor with Localized Memory
KR101981109B1 (ko) * 2017-07-05 2019-05-22 울산과학기술원 연산 속도를 향상시킨 simd mac 유닛, 그 동작 방법 및 simd mac 유닛의 배열을 이용한 콘볼루션 신경망 가속기
CN109213962B (zh) * 2017-07-07 2020-10-09 华为技术有限公司 运算加速器
CN107832839B (zh) * 2017-10-31 2020-02-14 南京地平线机器人技术有限公司 执行卷积神经网络中的运算的方法和装置
KR102095335B1 (ko) 2017-11-15 2020-03-31 에스케이텔레콤 주식회사 연산 가속화가 적용된 신경망 모델의 생성 및 활용을 위한 장치 및 방법

Also Published As

Publication number Publication date
WO2021020848A3 (ko) 2021-03-25
KR102372869B1 (ko) 2022-03-08
KR20210014897A (ko) 2021-02-10

Similar Documents

Publication Publication Date Title
US10846591B2 (en) Configurable and programmable multi-core architecture with a specialized instruction set for embedded application based on neural networks
CN107341541B (zh) 一种用于执行全连接层神经网络训练的装置和方法
CN112084038B (zh) 神经网络的内存分配方法及装置
CN110705703B (zh) 基于脉动阵列的稀疏神经网络处理器
US11017290B2 (en) Signal processing module, especially for a neural network and a neuronal circuit
Chen et al. A high-throughput neural network accelerator
WO2023065983A1 (zh) 计算装置、神经网络处理设备、芯片及处理数据的方法
US8941674B2 (en) System and method for efficient resource management of a signal flow programmed digital signal processor code
CN111045728B (zh) 一种计算装置及相关产品
WO2021020848A2 (ko) 인공 신경망을 위한 행렬 연산기 및 행렬 연산 방법
EP3908986A1 (en) Convolution streaming engine for deep neural networks
WO2015130093A1 (en) Method and apparatus for preventing bank conflict in memory
US11775808B2 (en) Neural network computation device and method
CN110059809B (zh) 一种计算装置及相关产品
CN110008436B (zh) 基于数据流架构的快速傅里叶变换方法、系统和存储介质
WO2023136417A1 (ko) 비디오 스토리 질의 응답을 위한 트랜스포머 모델을 구축하는 장치 및 방법
WO2023068463A1 (ko) 양자 회로 시뮬레이션을 위한 저장장치 시스템
WO2023120788A1 (ko) Snn/cnn 동시 구동이 가능한 데이터 처리 시스템 및 방법
US10769527B2 (en) Accelerating artificial neural network computations by skipping input values
Kong et al. A high efficient architecture for convolution neural network accelerator
Borges AlexNet deep neural network on a many core platform
WO2023214608A1 (ko) 양자 회로 시뮬레이션 하드웨어
WO2023214609A1 (ko) 상태 벡터를 효율적으로 계산하는 양자 회로 연산 방법
WO2023121086A1 (ko) 콘볼루션 신경망 컴퓨팅 장치
WO2023068464A1 (ko) 저장장치를 이용한 양자 회로 시뮬레이션 시스템 및 그 동작 방법

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: 20847629

Country of ref document: EP

Kind code of ref document: A2

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20847629

Country of ref document: EP

Kind code of ref document: A2