WO2019053835A1 - 演算回路、演算方法、およびプログラム - Google Patents

演算回路、演算方法、およびプログラム Download PDF

Info

Publication number
WO2019053835A1
WO2019053835A1 PCT/JP2017/033225 JP2017033225W WO2019053835A1 WO 2019053835 A1 WO2019053835 A1 WO 2019053835A1 JP 2017033225 W JP2017033225 W JP 2017033225W WO 2019053835 A1 WO2019053835 A1 WO 2019053835A1
Authority
WO
WIPO (PCT)
Prior art keywords
vector
coefficient matrix
multiplication
arithmetic
row
Prior art date
Application number
PCT/JP2017/033225
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/JP2017/033225 priority Critical patent/WO2019053835A1/ja
Priority to CN201780094576.0A priority patent/CN111052111A/zh
Priority to US16/633,845 priority patent/US11281746B2/en
Priority to JP2019541561A priority patent/JP6956796B2/ja
Priority to DE112017008040.1T priority patent/DE112017008040T5/de
Publication of WO2019053835A1 publication Critical patent/WO2019053835A1/ja

Links

Images

Classifications

    • 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
    • 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
    • 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
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
    • G06F18/2413Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on distances to training or reference patterns
    • G06F18/24133Distances to prototypes
    • 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/045Combinations of networks
    • 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/048Activation functions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/94Hardware or software architectures specially adapted for image or video understanding
    • G06V10/955Hardware or software architectures specially adapted for image or video understanding using specific electronic processors

Definitions

  • the present disclosure relates to an arithmetic circuit, an arithmetic method, and a program for executing the arithmetic method, and is suitably used, for example, in the operation of a convolution layer in a convolution neural network.
  • CNN Convolutional Neural Network
  • CNN consists of a convolution layer that performs convolution operations, a pooling layer that calculates local statistics, and an entire combined layer.
  • the convolutional layer repeatedly performs a product-sum operation of the corresponding part of the input feature map and the kernel while scanning the kernel (also referred to as a filter) on a pixel basis on the input feature map, and the final product-sum operation result is non-linear Output feature map is generated by conversion.
  • Patent Document 1 discloses an arithmetic circuit for executing a convolution operation in parallel processing. Specifically, the arithmetic circuit described in this document performs parallel arithmetic using multipliers and a cumulative adder for the number of column-direction sizes of the kernel.
  • a method is often used in which a feature map or kernel is expanded into one row and then calculated.
  • the convolution operation results in the product of the coefficient matrix and the vector, that is, the product-sum operation of the element of each row of the coefficient matrix and the element of the vector.
  • parallel operations can be performed by product-sum operators for the number of rows of the coefficient matrix.
  • the product-sum operation unit if it is simply executed by each product-sum operation unit, it consumes time for useless operation if the elements of the coefficient matrix include 0.
  • a method is employed in which the product-sum operation unit performs the operation excluding the zero element in the coefficient matrix.
  • the total processing time is determined by the number of nonzero elements in the largest row. For this reason, if there is only one row with many nonzero elements, the entire processing time is limited in the product-sum operation in that row, and as a result, the overall processing time can not be reduced as much as you think.
  • This disclosure takes the above problems into consideration, and its object is to provide an arithmetic circuit and an arithmetic method capable of shortening the overall processing time when performing multiplication of a coefficient matrix containing 0 in an element and a vector.
  • the arithmetic circuit and the arithmetic method according to the present disclosure are suitably used in the convolutional operation in CNN, the present invention is not limited to CNN and can be applied to other fields.
  • the arithmetic circuit in one embodiment is for multiplying a coefficient matrix including non-zero elements and zero elements from the right with an input vector and outputting an operation result to an output vector.
  • the arithmetic circuit includes a control processor and a plurality of arithmetic units capable of parallel processing.
  • the control processor uses the multiplication of each nonzero element included in the coefficient matrix and the corresponding element of the input vector as a processing unit, and assigns the multiplication to each computing element so that the number of processing units in each computing element is equalized. .
  • Each operator sequentially executes the assigned multiplication, and integrates the result of the multiplication into the corresponding element of the output vector.
  • each multiplication is processed so that multiplication of each non-zero element included in the coefficient matrix and the corresponding element of the input vector is a processing unit, and the number of processing units in each computing unit is equalized.
  • the assignment to the computing units can reduce the overall processing time.
  • FIG. 7 is a diagram for explaining the effect of the first embodiment. 7 is a flowchart showing the procedure of convolution operation according to the second embodiment.
  • FIG. 1 is a flowchart showing operation processing by CNN.
  • CNN includes an input layer S201, convolutional layers S202 and S204, pooling layers S203 and S205, a total coupling layer S206, and an output layer S207.
  • the input layer S201 receives input of data to be processed, such as image data.
  • the output layer S207 outputs the final result after data processing.
  • the combination of the convolution layer and the pooling layer (S202, S203; S204, S205) is repeated twice for simplicity, but may be repeated more times.
  • Data input to the convolutional layer is called an input feature map
  • data output from the convolutional layer is called an output feature map.
  • the convolutional layers S202 and S204 repeatedly perform a product-sum operation of the corresponding part of the input feature map and the kernel while scanning the kernel (also referred to as a filter) on a pixel basis on the input feature map, and perform the final product-sum operation.
  • Output feature maps are generated by non-linear transformation of the results.
  • the elements of the kernel also called "weights" are determined in advance by learning. Details of the convolution operation will be described later with reference to FIG.
  • the pooling layers S203 and S205 reduce the space size of the feature map by performing an operation to combine local regions of the output feature map into one element.
  • the pooling layers S203 and S205 for example, take the maximum value of the local region, and average elements included in the local region.
  • the entire bonding layer S206 is provided adjacent to the output layer S207 in one or more layers.
  • Each neuron in S206 of the total connection layer has connections with all neurons in the adjacent layer.
  • FIG. 2 is a diagram for explaining the convolution operation.
  • output data 102 is generated by a convolution operation of input data 100 as an input feature map and kernel 101.
  • An output feature map is generated by adding a bias to each element of the output data 102 and further applying an activation function.
  • a non-linear function such as ReLU (Rectified Linear Unit) is used as the activation function.
  • the input data size is (7, 7) and the kernel size is (3, 3) for simplicity.
  • the perimeter 104 of the input data 100 may be filled with fixed data (e.g., 0) to adjust the output data size. This is called padding. Padding having a width of 1 and a value of 0 is applied to the input data 100 of FIG.
  • elements of the kernel 101 are multiplied by corresponding elements of the input data 100 while sliding the kernel 101 at regular intervals on the input data 100 including the padding part, and their sum is obtained. That is, a product-sum operation is performed. The result of the product-sum operation is stored in the corresponding element of the output data 102.
  • the interval at which the kernel 101 is slid is referred to as stride. In the case of FIG. 2, the stride is one.
  • the product-sum operation result “30” is stored at the position of the corresponding element 106 of the output data 102.
  • the product-sum operation result “13” is stored at the position of the corresponding element 107 of the output data 102.
  • FIG. 3 is a diagram for explaining the development of the feature map and the kernel.
  • the feature map is expanded into one column by connecting the rows of the feature map.
  • the input vector 110 of FIG. 3 is generated by connecting the respective rows of the input data 100 of FIG.
  • the output data 102 of FIG. 2 is also expanded into one column by connecting the rows one by one.
  • the number of elements of the output vector corresponding to the output data 102 is also 49.
  • Kernel 101 of FIG. 2 is expanded into a matrix such that when the input vector 110 is multiplied from the right, an output vector corresponding to the output data 102 of FIG. 2 is generated.
  • the coefficient matrix 111 is thereby generated.
  • the number of rows of the coefficient matrix 111 is 49 in the first to 49th rows, and the number of columns of the coefficient matrix 111 is 49 in the first to 49th columns.
  • the first row of the coefficient matrix 111 is (3, 2, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0), and the kernel 101 of FIG. This corresponds to the case of being positioned in the upper thick broken line frame 105.
  • the ninth row of the coefficient matrix 111 is (3, 2, 1, 0, 0, 0, 0, 1, 3, 2, 2, 0, 0, 0, 0, 2, 1, 3, 3, 0, ... , 0), which corresponds to the case where the kernel 101 of FIG. 2 is positioned in the thick solid frame 103 on the feature map 100.
  • data "30" stored at the position of the corresponding element 106 of the output data 102 of FIG. 2 is generated.
  • the matrix equation to be executed in the convolution operation is generally expressed by equation (1). That is, the output vector f of the convolution operation is obtained by multiplying the coefficient matrix A by the input vector x from the right and adding the bias vector b to the result of the operation.
  • the coefficient matrix A is characterized in that it contains a relatively large number of elements whose value is zero.
  • the elements of the output vector f are f 1 ,..., F n .
  • An element of the i-th output vector f is described as f i or f (i).
  • An element of the j-th input vector x is described as x j or x (j).
  • the elements of the bias vector b are b 1 ,..., B n .
  • An element of the i-th bias vector b is described as b i or b (i).
  • the coefficient matrix A is configured by the first to n-th n rows and the first to m-th rows.
  • An element of the coefficient matrix A in the i-th row and the j-th column is described as A ij or A (i, j).
  • the matrix operation represented by the above equation (1) can be executed by a parallel computer including a plurality of computing units.
  • a parallel computer including a plurality of computing units.
  • the matrix operation represented by the above equation (1) may be executed by an application specific integrated circuit (ASIC) provided with a plurality of computing units capable of parallel processing with each other.
  • ASIC application specific integrated circuit
  • FIG. 4 is a block diagram showing an example of the configuration of a parallel computer.
  • parallel computer 120 is dedicated to a plurality of processing units 121A, 121B,..., Each including a plurality of computing units CL0, CL1,..., L2 cache memory (Level 2 Cache Memory) 125, and And a memory 126.
  • processing units 121A, 121B,... Each including a plurality of computing units CL0, CL1,..., L2 cache memory (Level 2 Cache Memory) 125, and And a memory 126.
  • CL0, CL1,... L2 cache memory (Level 2 Cache Memory) 125
  • L2 cache memory Level 2 Cache Memory
  • Each processing unit 121 (121A, 121B, ...) includes a plurality of computing units CL0, CL1, ..., register groups R0, R1, ... corresponding to the respective computing units, and L1 cache memory (Level 1 Cache Memory) 122 And.
  • the plurality of processing units 121A, 121B,... Can execute programs in parallel with each other. Furthermore, the plurality of computing units CL 0, CL 1,... Of each processing unit 121 can execute programs in parallel with each other.
  • the program may be provided via a network, or may be provided by a storage medium which stores the program non-temporarily by using a magnetic or optical method or a semiconductor memory or the like.
  • the parallel computer 120 may be connected to a central processing unit (CPU) 130 that controls the entire program via a high-speed interface.
  • CPU central processing unit
  • data may be transferred between the memory 131 for the CPU 130 and the dedicated memory 126 of the parallel computer 120 by direct memory access.
  • the CPU 130 for control and the memory 131 may be incorporated in the parallel computer 120.
  • FIG. 5 is a flowchart showing an outline of the procedure of the convolution operation. It is assumed that each element of the kernel used for the convolution operation has already been learned.
  • the convolution operation process can be divided into pre-processing S500 which is performed only once at first and product-sum operation S510 which is repeated according to the input data.
  • the pre-processing can be performed by a general purpose CPU (e.g., the CPU 130 of FIG. 4).
  • the product-sum operation is mainly performed by, for example, the parallel computer 120 of FIG. 4, and the entire control is performed by the CPU 130, for example.
  • a processor such as a CPU generates a coefficient matrix A from a learned kernel as described in FIG. 2 and FIG.
  • the generated coefficient matrix A is stored in the memory.
  • the processor searches all non-zero elements of the coefficient matrix A.
  • the search results are stored in memory.
  • the total number of nonzero elements included in the coefficient matrix A can be determined. It is assumed that the input data is converted into an input vector by being expanded into one column.
  • the processor takes as a processing unit the multiplication of each non-zero element found and the corresponding element of the input vector x, and the number of processing units in each arithmetic unit CL provided in the parallel computer 120 is equalized.
  • the multiplication is assigned to each computing unit CL. This makes it possible to make the processing time in each computing unit approximately equal. This is the end of the pre-processing stage.
  • step S511 the bias vector b is input to the output vector f as an initial value.
  • the bias vector b may be added to the output vector f at the end of the product-sum operation.
  • each computing unit CL of the parallel computer 120 sequentially executes the assigned multiplication.
  • Each computing unit CL adds each multiplication result to the value currently stored in the corresponding element of the output vector f. That is, the multiplication result is integrated to the corresponding element of the output vector f.
  • Step S512 is repeated until all assigned multiplications are completed (until YES in step S513).
  • steps S512 and S513 it can be considered that the product-sum operation of each row of the coefficient matrix A and the input vector x is decomposed into a unit product-sum operation and executed.
  • the unit product sum operation is composed of the multiplication of one nonzero element of the coefficient matrix A by the corresponding element of the input vector and the addition of the multiplication result to the corresponding element of the output vector f.
  • the i-th (1 ⁇ i ⁇ m) computing unit CL performs an operation of A 1i ⁇ x i , and the operation result is the value currently stored in the first element f 1 of the output vector f Add to
  • the addition operations in each arithmetic unit CL compete with each other, and thus are exclusively controlled.
  • the first operator CL adds the operation result of A 11 ⁇ x 1 to the initial value b 1 of the element f 1 of the output vector f.
  • the second arithmetic unit CL is, A and 12 ⁇ x 2 of the operation result is added in the elements f 1 of the output vector f to b 1 + A 11 ⁇ x 1 currently stored. Likewise, the addition operation is sequentially repeated.
  • FIG. 6 is a flowchart showing details of the procedure of the convolution operation.
  • steps S101 to S108 correspond to the pre-processing of step S500 of FIG.
  • step S101 initialization of variables is performed. Specifically, the processor initializes both the row direction variable i and the column direction variable j to 1 and initializes the non-zero element number (that is, the unit product sum operator number) k to 0.
  • step S102 it is determined whether or not it is a non-zero element. Specifically, the processor checks the value of the element A (i, j) of the coefficient matrix A, and if the value is 0, the element A (i, j) is a non-target element of the product-sum operation, The process proceeds to step S105 for counting up the row direction variable i. On the other hand, if the value of element A (i, j) is not 0, element A (i, j) is the target element of the product-sum operation, so the processor proceeds to step S103 for storing non-zero elements. Advance.
  • step S103 a pointer to the retrieved nonzero element is stored.
  • the processor stores the pointer to the target element A (i, j) of the product-sum operation, so the row direction variable i is stored in the row number storage array A ROW (k), and the column number is stored.
  • the non-zero element count k is incremented. Specifically, the processor increments a variable k that represents the number of non-zero elements.
  • the processor increments the row direction variable i to check the next line.
  • next step S106 when the processing for one column is completed, in order to shift the processing to the next column, it is determined whether the processing for one column of the coefficient matrix is completed. Specifically, the processor determines whether processing of the current column is completed by comparing the row direction variable i with the number of rows n of the coefficient matrix. If the row direction variable i is larger than the number of rows n, the processor determines that the processing of the current column is completed, and advances the process to step S107 for updating the column direction variable j to process the next column. . On the other hand, the processor determines that the treatment of the current column is not completed if the row direction variable i is not larger than the number of rows n, and determines whether or not it is a nonzero element to process the next row. The process proceeds to step S102 to be performed.
  • step S107 the variables are updated for the processing of the next column. Specifically, the processor initializes a row direction variable i to 1 in order to perform processing from the first row of the next column. Furthermore, the processor increments the column direction variable j.
  • step S108 a determination is made as to whether all rows have been processed. Specifically, the processor determines whether the processing of all the matrices is completed by comparing the column direction variable j with the number of rows m of the coefficient matrix A in order to determine whether the processing of all the columns is completed. . If the column direction variable j is larger than the number of columns m, the processor determines that the processing of all the matrices is completed, and advances the process to step S109 for initializing the variable f (corresponding to the output vector) of the product-sum operation. . On the other hand, if the column direction variable j is not larger than the number of columns m, the processor determines that an unprocessed column remains, and advances the process to step S102 for determining non-zero elements.
  • next steps S109 to S112 correspond to the product-sum operation S510 of FIG. These steps are mainly performed by the parallel computer 120 in FIG. 4 or a dedicated ASIC capable of parallel operation.
  • step S109 initialization of each variable used for product-sum operation is performed.
  • the processor controlling the entire operation (for example, the CPU 130 in FIG. 4) initializes the index variable o of the array for storing the row number and the column number to 0. Further, the processor initializes output vectors f (1) to f (n) that output product-sum operations to elements b (1) to b (n) of the bias vector b, respectively.
  • a total of k unit product sum operations are sequentially performed by n product sum operators. Specifically, using a row number storage array A ROW (p) and a column number storage array A COL (p) as a pointer to the coefficient matrix A, a unit product-sum operation represented by the following equation (2) Is executed by the p-th computing unit CL.
  • step S111 count-up of the product-sum operation variable is executed. Specifically, the control processor increments the index variable o of the row number storage array A ROW (p) and the column number storage array A COL (p) by the number n of operators to increase Prepare for this product-sum operation.
  • next step S112 it is determined whether all unit product-sum operations have been completed. Specifically, the control processor compares the index variable o of the array for storing row numbers and column numbers with the number k of nonzero elements to determine whether the product-sum operation of all nonzero elements is completed. Determine If the index variable o of the array for storing row numbers and column numbers is equal to or more than the number of non-zero elements k, the control processor determines that all product-sum operations have been completed, and ends the product-sum operation processing. On the other hand, if the index variable o of the array for storing the row number and the column number does not exceed the number of non-zero elements k, the control processor performs the product-sum operation on the rest. Proceed with the process.
  • the inspection of the nonzero elements of the coefficient matrix A is performed in the order of row and column, but may be performed in order of column and row.
  • the total number of computing units CL is equal to the number n of rows, it may be equal to the number m of columns or may be set to an arbitrary number.
  • FIG. 7 is a flow chart showing an example of an execution procedure of unit product sum operation in each computing element of the parallel computer of FIG. In the following procedure, the first register and the second register are provided in the register group R corresponding to each computing unit CL.
  • each arithmetic unit CL reads out the corresponding element A (A ROW (p), A COL (p)) of the coefficient matrix from the dedicated memory 126 or the L1 cache memory 122 or the L2 cache 125, and performs a corresponding operation. Store in the first register.
  • each arithmetic unit CL reads the corresponding element x (A COL (p)) of the input vector from the dedicated memory 126 or the L1 cache memory 122 or the L2 cache 125 to the corresponding second register.
  • Step S302 may be performed simultaneously with step S301, or may be performed before step S301.
  • each arithmetic unit CL multiplies the value stored in the first register by the value stored in the second register, and stores the multiplication result in the first register, for example.
  • the subsequent steps are executed when access to the corresponding element f (A ROW (p)) of the output vector is possible, that is, when there is no competition (YES in step S304).
  • each arithmetic unit CL reads f (A ROW (p)) from the dedicated memory 126 or the L1 cache memory 122 or the L2 cache 125, and stores it in the second register.
  • step S306 the value stored in the first register (that is, the calculation result of step S303) and the value stored in the second register are added, and the addition result is stored, for example, in the first register.
  • each computing unit CL stores the value stored in the first register (that is, the computation result of step S306) in the corresponding address of the L1 cache memory 122.
  • the unit product sum operation is completed.
  • the number of operations of the first operator is the largest, and the number of operators of the third and fourth operators is the smallest. Then, the overall processing time is limited by the operation time of the first computing unit.
  • the array for storing row numbers A ROW (p) and the array for storing column numbers A COL (p) Is as shown in Table 1 below.
  • the unit product-sum operation to be executed in the coefficient matrix A is written based on the above storage array A ROW (p) and the column number storage array A COL (p), the following (6.1) to Equation (6.7) is obtained.
  • unit product sum operations of the equations (6.1) to (6.4) are respectively performed by the 0th to third computing units CL0 to CL3. To be executed.
  • exclusive control is given to access to the corresponding element f (1) of the output vector. It will be done.
  • unit product sum operations of the equations (6.5) to (6.7) are executed by the 0th to second computing units CL0 to CL2, respectively.
  • non-zero elements of coefficient matrix A are searched, and unit product sum operations are distributed to each computing element for each non-zero element based on the search result. .
  • the product-sum operation can be efficiently executed by a plurality of operation units.
  • FIG. 8 is a diagram for explaining the effect of the first embodiment.
  • FIG. 8 (A) shows a comparative example
  • FIG. 8 (B) shows the case of the present embodiment.
  • FIG. 8A shows the case where the product-sum operation of each row of the coefficient matrix A and the input vector x is individually assigned to each computing unit CL. In this case, even if only non-zero elements are calculated, if the number of non-zero elements differs for each row of the coefficient matrix, the entire operation is performed by the operation of the operation unit CL corresponding to the row with the largest number of non-zero elements. Time is limited.
  • each unit product sum operation is allocated substantially equally to each computing element. That is, in the case of FIG. 8A, a part of the unit product-sum operation that has been executed by the computing unit (1) and the computing unit (2) is allocated to another computing unit. This can reduce the overall processing time.
  • step S110 of the flowchart shown in FIG. 6 the n arithmetic operators CL transmit the coefficient matrix A of n rows and m columns through the array A ROW (p) for storing row numbers and the array A COL (p) for storing column numbers. Access to all at once. Therefore, there is a problem that the processing load of the large-scale coefficient matrix A becomes high. Therefore, in the second embodiment, the coefficient matrix A of n rows and m columns is not accessed through the array for storing row numbers A ROW (p) and the array for storing column numbers A COL (p).
  • a coefficient array A ′ (also referred to as a coefficient vector A ′) except for n is newly defined, and n arithmetic operators CL are made to access the coefficient array A ′. This can prevent concentration of access to the coefficient matrix A of n rows and m columns.
  • FIG. 9 is a flowchart showing the procedure of the convolution operation according to the second embodiment. Steps S401 to S412 in FIG. 9 correspond to steps S101 to S112 in FIG. 6, respectively. However, the processes in step S403 and step S412 are partially different. In the following, steps S403 and S412 different in processing will be mainly described, and the description of the same processing steps as FIG. 6 will not be repeated.
  • step S403 values of non-zero elements included in coefficient matrix A and their row numbers and column numbers are stored.
  • the processor stores the row direction variable i in the row number storage array A ROW (k) to store the target element A (i, j) of the product-sum operation, and stores the column number storage array
  • the column direction variable j is stored in A COL (k)
  • the elements A (i, j) of the coefficient matrix A are stored in the coefficient array A ′ (k).
  • step S410 a total of k unit product sum operations are sequentially performed by the n computing units CL.
  • the row number storage array A ROW (p) and the column number storage array A COL (p) are used as pointers to the output vector f and the input vector x, respectively, by the following equation (7)
  • the p-th computing unit CL executes a unit product sum operation to be shown.
  • the same effect as that of the first embodiment can be obtained, and concentration of access to the coefficient matrix A of n rows and m columns can be prevented.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Molecular Biology (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Algebra (AREA)
  • Neurology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Multimedia (AREA)
  • Complex Calculations (AREA)

Abstract

一実施形態において、畳み込みニューラルネットワークにおける畳み込み層の演算方法が提供される。演算方法は、畳み込み層に入力される特徴マップを一列に展開することによって得られる入力ベクトル(x)に対応するように、畳み込み層で使用されるカーネルを変換することによって係数行列(A)を生成するステップと、係数行列に含まれる非零要素を検索するステップと、係数行列に含まれる各非零要素と入力ベクトルの対応する要素との乗算を処理単位として、互いに並列処理可能な複数の演算器(CL)の各々での処理単位数が平準化するように、当該乗算を各演算器に割り当てるステップと、各演算器が割当てられた乗算を順次実行し、乗算の結果を出力ベクトル(f)の対応する要素に積算するステップとを備える。

Description

演算回路、演算方法、およびプログラム
 この開示は、演算回路、演算方法、およびこの演算方法を実行するためのプログラムに関し、たとえば、畳み込みニューラルネットワークにおける畳み込み層の演算において好適に用いられる。
 パターン認識等の画像処理、声紋分析、ロボディクスなどの多くの分野において、畳み込みニューラルネットワーク(CNN:Convolutional Neural Network)と呼ばれる演算方法がしばしば用いられる。一般にCNNは、畳み込み演算を行う畳み込み層、局所統計量を計算するプーリング層、および全結合層で構成される。畳み込み層は、カーネル(フィルタとも称する)を入力特徴マップ上において画素単位で走査させながら、入力特徴マップの対応部分とカーネルとの積和演算を繰り返して行い、最終的な積和演算結果を非線形変換することによって出力特徴マップを生成する。
 特開2010-134697号公報(特許文献1)は、畳み込み演算を並列処理で実行するための演算回路を開示する。具体的に、この文献に記載された演算回路は、カーネルの列方向サイズの個数分の乗算器および累積加算器を用いて並列演算を行う。
特開2010-134697号公報
 上記の特許文献に記載の演算回路では、特徴マップおよびカーネルをそのまま使用して演算しているために演算の繰り返し回数が増えて処理が遅くなるという問題がある。
 そこで、処理時間の短縮のために、特徴マップまたはカーネルを1列に展開してから演算する方法がしばしば用いられる。この方法によれば、畳み込み演算は、係数行列とベクトルとの積、すなわち係数行列の各行の要素とベクトルの要素との積和演算に帰着する。たとえば、係数行列の行数分の積和演算器によって並列演算を行うことができる。
 ここで、各積和演算器によって単純に積和演算器を実行すると、係数行列の要素に0が含まれている場合には、無駄な演算に時間を費やすことになることに注意しなければならい。したがって、通常は、係数行列のうち0の要素を除いて積和演算器による演算を実行する方法が採られる。ところが、非零要素の数は係数行列の行により異なるので、係数行列全体として非零要素の数が少なくても、最も多い行の非零要素の数で全体の処理時間が決定される。このため、非零要素の多い行が1行でもあれば、その行での積和演算に全体の処理時間が律速され、結果として全体の処理時間を思うほど短縮できないことになる。
 この開示は、上記の問題を考慮したものであり、その目的は、要素に0を含む係数行列とベクトルとの掛け算を行う際に全体の処理時間を短縮することが可能な演算回路および演算方法を提供することである。なお、この開示による演算回路および演算方法は、CNNにおける畳み込み演算において好適に用いられるものであるが、CNNに限らず他の分野にも適用することができる。
 一実施形態における演算回路は、非零要素と零要素とを含む係数行列に右から入力ベクトルを掛け、演算結果を出力ベクトルに出力するためのものである。演算回路は、制御プロセッサと、互いに並列処理可能な複数の演算器とを備える。制御プロセッサは、係数行列に含まれる各非零要素と入力ベクトルの対応する要素との乗算を処理単位とし、各演算器での処理単位数が平準化するように当該乗算を各演算器に割り当てる。各演算器は、割り当てられた乗算を順次実行し、乗算の結果を出力ベクトルの対応する要素に積算する。
 上記の実施形態によれば、係数行列に含まれる各非零要素と入力ベクトルの対応する要素との乗算を処理単位とし、各演算器での処理単位数が平準化するように当該乗算を各演算器に割り当てるので、全体の処理時間を短縮することができる。
CNNによる演算処理を示すフローチャートである。 畳み込み演算について説明するための図である。 特徴マップおよびカーネルの展開について説明するための図である。 並列計算機の構成の一例を示すブロック図である。 畳み込み演算の手順の概要を示すフローチャートである。 畳み込み演算の手順の詳細を示すフローチャートである。 図4の並列計算機の各演算器における単位積和演算の実行手順の一例を示すフローチャートである。 実施の形態1の効果を説明するための図である。 実施の形態2による畳み込み演算の手順を示すフローチャートである。
 以下、各実施の形態について図面を参照して詳しく説明する。なお、同一または相当する部分には同一の参照符号を付して、その説明を繰り返さない。
 実施の形態1.
 [CNNについて]
 最初にCNNについて簡単に説明する。図1は、CNNによる演算処理を示すフローチャートである。
 図1を参照して、CNNは、入力層S201と、畳み込み層S202,S204と、プーリング層S203,S205と、全結合層S206と、出力層S207とを含む。
 入力層S201は、画像データなどの処理対象のデータの入力を受ける。出力層S207は、データ処理後の最終結果を出力する。図1では、簡単のために畳み込み層とプーリング層の組み合わせ(S202,S203;S204,S205)が2回繰り返されているが、さらに多数回繰り返されていてもよい。
 畳み込み層に入力されるデータを入力特徴マップといい、畳み込み層から出力されたデータを出力特徴マップという。畳み込み層S202,S204は、カーネル(フィルタとも称する)を入力特徴マップ上において画素単位で走査しながら、入力特徴マップの対応部分とカーネルとの積和演算を繰り返して行い、最終的な積和演算結果を非線形変換することによって出力特徴マップを生成する。カーネルの要素(「重み」とも称する)は事前に学習によって決定される。畳み込み演算の詳細は図2を参照して後述する。
 プーリング層S203,S205は、出力特徴マップの局所領域をひとつの要素にまとめるような動作を行うことによって特徴マップの空間サイズを小さくするものである。プーリング層S203,S205は、たとえば、局所領域の最大値を取ったり、局所領域に含まれる要素を平均化したりする。
 全結合層S206は、出力層S207に隣接して1または複数層設けられる。全結合層のS206の各ニューロンは、隣接層の全てのニューロンとの結合を有する。
 [畳み込み演算について]
 図2は、畳み込み演算について説明するための図である。図2に示すように、入力特徴マップとしての入力データ100とカーネル101との畳み込み演算によって出力データ102が生成される。出力データ102の各要素にバイアスを加算し、さらに活性化関数を施すことによって出力特徴マップが生成される。活性化関数として、たとえば、ReLU(Rectified Linear Unit)などの非線形関数が用いられる。
 図2の例では、簡単のために入力データサイズを(7,7)とし、カーネルサイズを(3,3)としている。出力データサイズの調整のために、入力データ100の周囲104が固定データ(たとえば、0)で埋められていてもよい。これをパッディングと称する。図2の入力データ100には、幅が1で値が0のパディングが適用されている。
 畳み込み演算では、パディングの部分を含めた入力データ100の上においてカーネル101を一定間隔でスライドさせながら、カーネル101の要素と対応する入力データ100の要素とを乗算し、それらの和が求められる。すなわち、積和演算が実行される。積和演算の結果は、出力データ102の対応する要素に格納される。カーネル101をスライドさせる間隔をストライドと称する。図2の場合、ストライドは1である。
 具体的に、カーネル101の配置が図2の太い実線の枠103に対応している場合、積和演算結果である「30」は出力データ102の対応する要素106の位置に格納される。カーネル101の配置が図2の太い破線の枠105に対応している場合、積和演算結果である「13」は、出力データ102の対応する要素107の位置に格納される。
 [特徴マップおよびカーネルの展開]
 図3は、特徴マップおよびカーネルの展開について説明するための図である。本実施の形態の場合、畳み込み演算の処理時間を短縮するために、特徴マップの各行をつなぎ合わせることによって特徴マップが1列に展開される。
 具体的に、図2および図3を参照して、図2の入力データ100の各行をつなぎ合わせることによって図3の入力ベクトル110が生成される。入力データ100に対応する入力ベクトル110の要素数は7×7=49である。図2の出力データ102も行ごとにつなぎ合わせることによって1列に展開される。出力データ102に対応する出力ベクトルの要素数も49である。
 図2のカーネル101は、入力ベクトル110を右から掛けたときに、図2の出力データ102に対応する出力ベクトルが生成されるように行列に展開される。これによって係数行列111が生成される。係数行列111の行数は第1行から第49行までの49であり、係数行列111の列数は第1列から第49列までの49である。なお、図3に示す係数行列111において空白部分のマス目の要素は0である。
 具体的に、係数行列111の第1行は、(3,2,0,0,0,0,0,1,3,0,…,0)であり、図2のカーネル101が特徴マップ100上の太い破線の枠105に位置する場合に相当する。この係数行列111の第1行と入力ベクトル110との積和演算が実行されることによって、図2の出力データ102の対応する要素107の位置に格納されるデータ「13」が生成される。
 同様に、係数行列111の第9行は、(3,2,1,0,0,0,0,1,3,2,0,0,0,0,2,1,3,0,…,0)であり、図2のカーネル101が特徴マップ100上の太い実線の枠103に位置する場合に相当する。この係数行列111の第9行と入力ベクトル110との積和演算が実行されることによって、図2の出力データ102の対応する要素106に位置に格納されるデータ「30」が生成される。
 図2においてパディングが適用されていない場合には、入力データ100に対応する入力ベクトル110には変更はなく、その要素数は49である。出力データ102のデータサイズは(5,5)になるので、出力データ102に対応する出力ベクトルの要素数は、5×5=25になる。また、カーネル101に対応する係数行列111の行数は25になり、その列数は49になる。
 畳み込み演算において実行される行列演算式は一般に(1)式で表される。すなわち、畳み込み演算の出力ベクトルfは、係数行列Aに入力ベクトルxを右から掛け、その演算結果にバイアスベクトルbを加算することによって得られる。ここで、係数行列Aは、値が0である要素を比較的多く含んでいる点に特徴がある。
Figure JPOXMLDOC01-appb-M000001
 この明細書では、出力ベクトルfの要素をf1,…,fnとする。第i番目の出力ベクトルfの要素をfiまたはf(i)と記載する。入力ベクトルxの要素をx1,…,xmとする。第j番目の入力ベクトルxの要素をxjまたはx(j)と記載する。バイアスベクトルbの要素をb1,…,bnとする。第i番目のバイアスベクトルbの要素をbiまたはb(i)と記載する。また、係数行列Aは、第1から第nまでのn行と第1から第mまでのm行で構成される。第i行第j列の係数行列Aの要素をAijまたはA(i,j)と記載する。
 [並列計算機の構成]
 上記(1)式で示される行列演算は、複数の演算器を含む並列計算機によって実行することができる。以下、汎用的な並列計算機の構成例を示す。図4の例と異なり、互いに並列処理可能な演算器を複数備えたASIC(Application Specific Integrated Circuit)によって上記の(1)式で示される行列演算を実行してもよい。
 図4は、並列計算機の構成の一例を示すブロック図である。図4を参照して、並列計算機120は、各々が複数個の演算器CL0,CL1,…を含む複数の処理ユニット121A,121B,…と、L2キャッシュメモリ(Level 2 Cache Memory)125と、専用メモリ126とを備える。
 各処理ユニット121(121A,121B,…)は、複数の演算器CL0,CL1,…と、それぞれの演算器に対応するレジスタ群R0,R1,…と、L1キャッシュメモリ(Level 1 Cache Memory)122とを含む。同じ処理ユニット121に含まれる演算器CL(CL0,CL1,…)は、L1キャッシュメモリ122を共有する。
 上記の構成において、複数の処理ユニット121A,121B,…は互いに並列的にプログラムを実行可能である。さらに、各処理ユニット121の複数の演算器CL0,CL1,…は互いに並列的にプログラムを実行可能である。なお、プログラムは、ネットワークを介して提供されてもよいし、磁気的または光学的な方法または半導体メモリなどを使用することによりプログラムを非一時的に記憶する記憶媒体によって提供されてもよい。
 並列計算機120は、プログラム全体を制御するCPU(Central Processing Unit)130と高速インターフェイスを介して接続されていてもよい。この場合、CPU130用のメモリ131と、並列計算機120の専用メモリ126との間でダイレクトメモリアクセスによってデータ転送できるようにしてもよい。図4の構成と異なり、上記の制御用のCPU130およびメモリ131は、並列計算機120に内蔵されていてもよい。
 [畳み込み演算の手順の概要]
 以下、畳み込み演算の手順の概要、特に(1)式の行列演算の手順の概略について説明する。
 図5は、畳み込み演算の手順の概要を示すフローチャートである。畳み込み演算に用いるカーネルの各要素は既に学習済みであるとする。図5に示すように、畳み込み演算処理は、最初に1回のみ行われる前処理S500と、入力データに応じて繰り返される積和演算S510とに区分できる。前処理は、汎用のCPU(たとえば、図4のCPU130)によって実行することができる。一方、積和演算は、たとえば、図4の並列計算機120によって主として実行され、その全体的な制御は例えばCPU130によって実行される。
 前処理段階では、まず、ステップS501において、図2および図3で説明したようにCPU等のプロセッサは、学習済みのカーネルから係数行列Aを生成する。生成した係数行列Aはメモリに格納される。
 次のステップS502において、プロセッサは、係数行列Aのうちの非零要素を全て検索する。検索結果はメモリに格納される。これによって係数行列Aに含まれる非零要素の総数が判明する。なお、入力データは、一列に展開されることによって入力ベクトルに変換されることが想定されている。
 次のステップS503において、プロセッサは、検索した各非零要素と入力ベクトルxの対応する要素との乗算を処理単位とし、並列計算機120に備えられた各演算器CLでの処理単位数が平準化するように当該乗算を各演算器CLに割当てる。これによって、各演算器での処理時間をほぼ等しくすることができる。以上で前処理段階が終了する。
 次の積和演算では、まず、ステップS511において、出力ベクトルfにバイアスベクトルbが初期値として入力される。なお、バイアスベクトルbは、積和演算の最後に出力ベクトルfに加算するようにしてもよい。
 次のステップS512において、並列計算機120の各演算器CLは、割り当てられた乗算を順次実行する。各演算器CLは、各乗算結果を出力ベクトルfの対応する要素において現在格納されている値に加算する。すなわち、乗算結果は、出力ベクトルfの対応する要素に積算されていくことになる。ステップS512は、割当てられた乗算が全て終了するまで(ステップS513でYESとなるまで)繰り返される。
 なお、ステップS512,S513では、係数行列Aの各行と入力ベクトルxとの積和演算が、単位積和演算に分解されて実行されると考えることができる。ここで、単位積和演算は、係数行列Aの1つの非零要素と入力ベクトルの対応する要素との乗算と、乗算結果の出力ベクトルfの対応する要素への加算とから構成される。
 以下、簡単な具体例を挙げて説明する。たとえば、(1)式の係数行列Aにおいて、n=mとし、対角要素のみが非零要素であったとする。また、演算器CLの総数はn個であったとする。この場合、第i番目(1≦i≦n)の演算器CLは、Aiiとxとの乗算を行い、乗算結果を出力ベクトルfの要素fiにおいて現在格納されているバイアス値biに加算する。
 別の例として、(1)式係数行列Aにおいて、第1行目の要素A11~A1mのみが非零要素であったとする。また、演算器CLの総数はm個であったとする。この場合、第i番目(1≦i≦m)の演算器CLは、A1i・xiの演算を行い、演算結果を出力ベクトルfの第1番目の要素f1において現在格納されている値に加算する。この場合、各演算器CLにおいて加算演算は互いに競合するので排他制御される。たとえば、第1番目の演算器CLは、A11・x1の演算結果を、出力ベクトルfの要素f1の初期値b1に加算する。この加算演算の終了後に、第2番目の演算器CLは、A12・x2の演算結果を、出力ベクトルfの要素f1において現在格納されているb1+A11・x1に加算する。以下同様に、加算演算が順次繰り返される。
 [畳み込み演算の手順の詳細]
 図6は、畳み込み演算の手順の詳細を示すフローチャートである。
 図6を参照して、ステップS101からステップS108までが、図5のステップS500の前処理に相当する。
 まず、ステップS101において、変数の初期化が行われる。具体的に、プロセッサは、行方向変数iおよび列方向変数jをともに1に初期化し、非零要素数(すなわち、単位積和演算数)kを0に初期化する。
 次のステップS102において、非零要素か否かの判定が実行される。具体的に、プロセッサは、係数行列Aの要素A(i,j)の値を検査し、その値が0であれば要素A(i,j)は積和演算の非対象要素であるため、行方向変数iをカウントアップするためのステップS105へ処理を進める。一方、要素A(i,j)の値が0でなければ要素A(i,j)は、積和演算の対象要素であるため、プロセッサは、非零要素を格納するためのステップS103へ処理を進める。
 ステップS103において、検索された非零要素へのポインタが格納される。具体的に、プロセッサは、積和演算の対象要素A(i,j)へのポインタを記憶するため、行番号の格納用配列AROW(k)へ行方向変数iを、列番号の格納用配列ACOL(k)へ列方向変数jを格納する。
 次のステップS104において、非零要素数kのカウントアップが実行される。具体的に、プロセッサは、非零要素数を表す変数kをインクリメントする。
 次のステップS105において、プロセッサは、次の行を検査するため、行方向変数iをインクリメントする。
 次のステップS106において、1列分の処理が完了したら次の列へ処理を移行するため、係数行列の1列分の処理が完了したかの判定が実行される。具体的に、プロセッサは、行方向変数iと係数行列の行数nとを比較することによって、現在の列の処理が完了したか否かを判定する。プロセッサは、行方向変数iが行数nより大きければ現在の列の処理が完了した判断し、次の列の処理を行うために、列方向変数jを更新するためのステップS107へ処理を進める。一方、プロセッサは、行方向変数iが行数nより大きくなければまだ現在の列の処置が完了していないと判断し、次の行の処理を行うために非零要素か否かの判定を行うためのステップS102へ処理を進める。
 ステップS107において、次列の処理のために変数の更新が行われる。具体的に、プロセッサは、次列の1行目から処理を行うために、行方向変数iを1に初期化する。さらに、プロセッサは、列方向変数jをインクリメントする。
 次のステップS108において、全列の処理が完了したか否かの判定が実行される。具体的に、プロセッサは、全列の処理が完了したか判断するため、列方向変数jと係数行列Aの行数mとを比較することによって全行列の処理が完了したか否かを判定する。プロセッサは、列方向変数jが列数mより大きければ全行列の処理が完了したと判断し、積和演算の変数f(出力ベクトルに対応する)を初期化するためのステップS109へ処理を進める。一方、プロセッサは、列方向変数jが列数mより大きくなければ、未処理の列が残っていると判断し、非零要素を判定するためのステップS102へ処理を進める。
 次のステップS109からステップS112までが図5の積和演算S510に相当する。これらのステップは、主として図4の並列計算機120または並列演算が可能な専用のASICなどによって実行される。
 まず、ステップS109において、積和演算に用いられる各変数の初期化が実行される。具体的に、全体の動作を制御するプロセッサ(たとえば、図4のCPU130)は、行番号および列番号の格納用配列のインデックス変数oを0に初期化する。さらに、プロセッサは、積和演算計算を出力する出力ベクトルf(1)からf(n)をそれぞれバイアスベクトルbの要素b(1)からb(n)に初期化する。
 次のステップS110において、総数k個の単位積和演算がn個の積和演算器により順番に実行される。具体的に、行番号の格納用配列AROW(p)および列番号の格納用配列ACOL(p)を係数行列Aへのポインタとして利用し、以下の(2)式で示す単位積和演算を第p番目の演算器CLが実行する。
Figure JPOXMLDOC01-appb-M000002
 ここで、n個の演算器により並列に単位積和演算を行うため、上記(2)式の変数pはp=oからp=o+n-1までのn個の値をとる。さらに非零要素数kを超えて積和演算を行わないため、p<kを満たす場合にのみ積和演算が実施される。
 次のステップS111において、積和演算用変数のカウントアップが実行される。具体的に制御用プロセッサは、行番号の格納用配列AROW(p)および列番号の格納用配列ACOL(p)のインデックス変数oを演算器の数nだけインクリメントすることによって、次のn個の積和演算に備える。
 次のステップS112において、単位積和演算が全て完了したか否かが判定される。具体的に、制御用プロセッサは、行番号および列番号の格納用配列のインデックス変数oと非零要素数kとを比較することによって、全ての非零要素の積和演算が完了したか否かを判定する。制御用プロセッサは、行番号および列番号の格納用配列のインデックス変数oが非零要素数k以上であれば、すべての積和演算が完了したと判定し、積和演算処理を終了する。一方、制御用プロセッサは、行番号および列番号の格納用配列のインデックス変数oが非零要素数k以上でなければ、残りの積和演算を行うため、積和演算を行うためのステップS110へ処理を進める。
 なお、上記の演算手順において、係数行列Aの非零要素の検査を行、列の順に行ったが、列、行の順に行ってもよい。また、演算器CLの総数を行の数nに等しくしたが、列の数mに等しくしてもよいし、任意の数に設定してもよい。
 図7は、図4の並列計算機の各演算器における単位積和演算の実行手順の一例を示すフローチャートである。なお、以下の手順において第1レジスタおよび第2レジスタは、各演算器CLに対応するレジスタ群Rに備えられている。
 ステップS301において、各演算器CLは、専用メモリ126またはL1キャッシュメモリ122またはL2キャッシュ125から、係数行列の対応する要素A(AROW(p),ACOL(p))を読出して、対応する第1レジスタに格納する。
 次のステップS302において、各演算器CLは、専用メモリ126またはL1キャッシュメモリ122またはL2キャッシュ125から、入力ベクトルの対応する要素x(ACOL(p))を読出して、対応する第2レジスタに格納する。なお、ステップS302は、ステップS301と同時に実行してもよいし、ステップS301の前に実行してもよい。
 次のステップS303において、各演算器CLは、第1レジスタに格納された値と第2レジスタに格納された値とを乗算し、乗算結果をたとえば第1レジスタに格納する。
 以降のステップは、出力ベクトルの対応する要素f(AROW(p))へのアクセスが可能な場合、すなわち、競合していない場合(ステップS304でYES)に実行される。
 まず、ステップS305において、各演算器CLは、専用メモリ126またはL1キャッシュメモリ122またはL2キャッシュ125から、f(AROW(p))を読出して第2レジスタに格納する。
 次のステップS306において、第1レジスタに格納された値(すなわち、ステップS303の演算結果)と第2レジスタに格納された値とを加算し、加算結果をたとえば第1レジスタに格納する。
 次のステップS307において、各演算器CLは、第1レジスタに格納された値(すなわち、ステップS306の演算結果)を、L1キャッシュメモリ122の対応するアドレスに格納する。以上によって、単位積和演算が完了する。
 [畳み込み演算の具体例]
 以下、数値例を挙げて、図6の畳み込み演算の手順をさらに詳しく説明する。具体的に、係数行列A、入力ベクトルx、およびバイアスベクトルbを以下の(3)式のように設定する。
Figure JPOXMLDOC01-appb-M000003
 仮に、上記の行列演算の各行を対応する演算器CLで個別に実行したとすれば、以下の(4)式に示す4つの演算が、4個の演算にそれぞれ割り当てられる。
Figure JPOXMLDOC01-appb-M000004
 したがって、この場合、1番目の演算器の演算数が最も多くなり、3番目および4番目の演算器の演算数が最も少なくなる。そして、1番目の演算器の演算時間によって全体の処理時間が律速されることになる。
 一方、(3)式の数値例を、本実施の形態の図6のステップS101~S108に適用すると、行番号の格納用配列AROW(p)および列番号の格納用配列ACOL(p)は、次の表1のようになる。
Figure JPOXMLDOC01-appb-T000005
 参考までに、上記の表1のインデックスpを係数行列Aに添え字として記入すると、次の(5)式のとおりである。(5)式に示すように、非零要素の総数、すなわち、単位積和演算の総数は7個である。
Figure JPOXMLDOC01-appb-M000006
 上記の格納用配列AROW(p)および列番号の格納用配列ACOL(p)に基づいて、係数行列Aにおいて実行すべき単位積和演算を書き下すと、次の(6.1)~(6.7)式が得られる。
Figure JPOXMLDOC01-appb-M000007
 演算器CLの個数nは4であるので、最初のステップで、(6.1)~(6.4)式の単位積和演算が第0番目から第3番目の演算器CL0~CL3によってそれぞれ実行される。この場合、(6.1)式、(6.2)式、および(6.4)式の各単位積和演算のうち、出力ベクトルの対応する要素f(1)へのアクセスについては排他制御されることになる。
 次のステップで、(6.5)~(6.7)式の単位積和演算が第0番目から第2番目の演算器CL0~CL2でそれぞれ実行される。
 [効果]
 以上のように、実施の形態1によれば、係数行列Aの非零要素を検索し、検索結果に基づいて、各非零要素について単位積和演算が各演算器に分配されて実行される。これによって、各演算器における単位積和演算の処理数を平準化できるので、複数の演算器による積和演算を効率的に実行することができる。
 図8は、実施の形態1の効果を説明するための図である。図8(A)は比較例を示し、図8(B)は本実施の形態の場合を示す。
 図8(A)では、係数行列Aの各行と入力ベクトルxとの積和演算を各演算器CLに個別に割り振った場合が示されている。この場合、非零要素のみを計算したとしても、非零要素数が係数行列の行ごとに異なっていれば、非零要素数の最も多い行に対応する演算器CLでの演算によって全体の演算時間が律速される。
 図8(B)に示す本実施の形態の場合には、各単位積和演算が各演算器にほぼ均等に割り当てらる。すなわち、図8(A)の場合に演算器(1)および演算器(2)で実行されていた単位積和演算の一部が他の演算器に割当てられることになる。これによって、全体の処理時間を削減することができる。
 実施の形態2.
 図6に示すフローチャートのステップS110では、n個ある演算器CLは、行番号の格納用配列AROW(p)および列番号の格納用配列ACOL(p)を通じてn行m列の係数行列Aに一斉にアクセスする。このため、大規模な係数行列Aの処理負荷が高くなるという問題がある。そこで、実施の形態2においては行番号の格納用配列AROW(p)および列番号の格納用配列ACOL(p)を通じてn行m列の係数行列Aにアクセスするのではなく、非零要素を除いた係数配列A’(係数ベクトルA’とも称する)を新しく定義し、n個ある演算器CLを係数配列A’にアクセスするようにする。これによって、n行m列の係数行列Aへのアクセスの集中を防止することができる。
 図9は、実施の形態2による畳み込み演算の手順を示すフローチャートである。図9のステップS401~S412は、図6のステップS101~S112にそれぞれ対応している。ただし、ステップS403とステップS412とでの処理が一部異なっている。以下では、処理の異なるステップS403,S412について主に説明し、図6と同じ処理のステップについては説明を繰り返さない。
 図9を参照して、ステップS403において、係数行列Aに含まれる非零要素の値とその行番号および列番号が格納される。具体的に、プロセッサは、積和演算の対象要素A(i,j)を記憶するため、行番号の格納用配列AROW(k)に行方向変数iを格納し、列番号の格納用配列ACOL(k)に列方向変数jを格納し、さらに、係数配列A’(k)に係数行列Aの要素A(i,j)を記憶する。
 具体的に、前述の(3)式の数値例の場合について説明する。この場合、係数配列A’は次の表2で与えられる。
Figure JPOXMLDOC01-appb-T000008
 ステップS410において、総数k個の単位積和演算がn個の演算器CLにより順番に実行される。具体的に、行番号の格納用配列AROW(p)および列番号の格納用配列ACOL(p)を出力ベクトルfおよび入力ベクトルxへのポインタとしてそれぞれ利用し、以下の(7)式で示す単位積和演算を、第p番目の演算器CLが実行する。
Figure JPOXMLDOC01-appb-M000009
 ここで、n個の演算器により並列に単位積和演算を行うため、上記(7)式の変数pはp=oからp=o+n-1までのn個の値をとる。さらに非零要素数kを超えて積和演算を行わないため、p<kを満たす場合にのみ積和演算が実施される。
 上記のとおり、実施の形態2によれば、実施の形態1の場合と同様の効果を奏するとともに、n行m列の係数行列Aへのアクセスの集中を防止することができる。
 今回開示された実施の形態はすべての点で例示であって制限的なものでないと考えられるべきである。この発明の範囲は上記した説明ではなくて請求の範囲によって示され、請求の範囲と均等の意味および範囲内でのすべての変更が含まれることが意図される。
 100 入力データ(入力特徴マップ)、101 カーネル、102 出力データ、110,x 入力ベクトル、111,A 係数行列、120 並列計算機、121 処理ユニット、122 L1キャッシュメモリ、125 L2キャッシュメモリ、126 専用メモリ、130 CPU、131 メモリ、A’ 係数配列(係数ベクトル)、CL 演算器、R レジスタ群、b バイアスベクトル、f 出力ベクトル。

Claims (7)

  1.  非零要素と零要素とを含む係数行列に右から入力ベクトルを掛け、演算結果を出力ベクトルに出力するための演算回路であって、制御プロセッサと、互いに並列処理可能な複数の演算器とを備え、
     前記制御プロセッサは、前記係数行列に含まれる各非零要素と前記入力ベクトルの対応する要素との乗算を処理単位として、各前記演算器での処理単位数が平準化するように当該乗算を各前記演算器に割り当てるように構成され、
     各前記演算器は、割り当てられた前記乗算を順次実行し、前記乗算の結果を前記出力ベクトルの対応する要素に積算するように構成される、演算回路。
  2.  前記演算回路は、畳み込みニューラルネットワークにおける畳み込み層の演算を実行するためのものであり、
     前記入力ベクトルは、前記畳み込み層に入力される特徴マップを一列に展開したものであり、
     前記係数行列は、前記畳み込み層で利用されるカーネルに対応する、請求項1に記載の演算回路。
  3.  前記係数行列に含まれる非零要素のみを取り出して格納するための係数ベクトルをさらに備え、
     各前記演算器は、前記係数ベクトルから取り出した対応の非零要素を使用することによって、前記乗算を実行するように構成される、請求項1または2に記載の演算回路。
  4.  畳み込みニューラルネットワークにおける畳み込み層の演算方法であって、
     前記畳み込み層に入力される特徴マップを一列に展開することによって得られる入力ベクトルに対応するように、前記畳み込み層で使用されるカーネルを変換することによって係数行列を生成するステップと、
     前記係数行列に含まれる非零要素を検索するステップと、
     前記係数行列に含まれる各非零要素と前記入力ベクトルの対応する要素との乗算を処理単位とし、互いに並列処理可能な複数の演算器の各々での処理単位数が平準化するように、当該乗算を各前記演算器に割り当てるステップと、
     各前記演算器が割当てられた前記乗算を順次実行し、前記乗算の結果を出力ベクトルの対応する要素に積算するステップとを備える、演算方法。
  5.  前記出力ベクトルの初期値としてバイアスベクトルを入力するステップをさらに備える、請求項4に記載の演算方法。
  6.  前記係数行列に含まれる非零要素のみを取り出して係数ベクトルに格納するステップをさらに備え、
     各前記演算器は、前記係数ベクトルから取り出した対応の非零要素を使用することによって、前記乗算を実行する、請求項4または5に記載の演算方法。
  7.  請求項4~6のいずれか1項に記載の演算方法をコンピュータに実行させるためのプログラム。
PCT/JP2017/033225 2017-09-14 2017-09-14 演算回路、演算方法、およびプログラム WO2019053835A1 (ja)

Priority Applications (5)

Application Number Priority Date Filing Date Title
PCT/JP2017/033225 WO2019053835A1 (ja) 2017-09-14 2017-09-14 演算回路、演算方法、およびプログラム
CN201780094576.0A CN111052111A (zh) 2017-09-14 2017-09-14 运算电路、运算方法以及程序
US16/633,845 US11281746B2 (en) 2017-09-14 2017-09-14 Arithmetic operation circuit, arithmetic operation method, and program
JP2019541561A JP6956796B2 (ja) 2017-09-14 2017-09-14 演算回路、演算方法、およびプログラム
DE112017008040.1T DE112017008040T5 (de) 2017-09-14 2017-09-14 Rechenoperationsschaltung, rechenoperationsverfahren und programm

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2017/033225 WO2019053835A1 (ja) 2017-09-14 2017-09-14 演算回路、演算方法、およびプログラム

Publications (1)

Publication Number Publication Date
WO2019053835A1 true WO2019053835A1 (ja) 2019-03-21

Family

ID=65723958

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2017/033225 WO2019053835A1 (ja) 2017-09-14 2017-09-14 演算回路、演算方法、およびプログラム

Country Status (5)

Country Link
US (1) US11281746B2 (ja)
JP (1) JP6956796B2 (ja)
CN (1) CN111052111A (ja)
DE (1) DE112017008040T5 (ja)
WO (1) WO2019053835A1 (ja)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2020166368A (ja) * 2019-03-28 2020-10-08 三菱電機株式会社 アクセラレータ装置
JP2021099658A (ja) * 2019-12-23 2021-07-01 三菱電機マイコン機器ソフトウエア株式会社 ニューラルネットワーク処理装置
US11403104B2 (en) * 2019-12-09 2022-08-02 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Neural network processor, chip and electronic device

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107633295B (zh) * 2017-09-25 2020-04-28 南京地平线机器人技术有限公司 用于适配神经网络的参数的方法和装置
US11636327B2 (en) * 2017-12-29 2023-04-25 Intel Corporation Machine learning sparse computation mechanism for arbitrary neural networks, arithmetic compute microarchitecture, and sparsity for training mechanism
US11487846B2 (en) * 2018-05-04 2022-11-01 Apple Inc. Performing multiply and accumulate operations in neural network processor

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160358069A1 (en) * 2015-06-03 2016-12-08 Samsung Electronics Co., Ltd. Neural network suppression

Family Cites Families (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0748207B2 (ja) * 1989-04-14 1995-05-24 シャープ株式会社 行列演算装置
JP2825133B2 (ja) * 1989-09-20 1998-11-18 富士通株式会社 並列データ処理方式
TW325552B (en) * 1996-09-23 1998-01-21 Advanced Risc Mach Ltd Data processing condition code flags
JP2888292B2 (ja) 1997-07-24 1999-05-10 日本電気株式会社 2次元逆離散コサイン変換(idct)装置
JP2003122736A (ja) * 2001-10-11 2003-04-25 Matsushita Electric Ind Co Ltd 行列演算装置
JP4014512B2 (ja) * 2002-02-12 2007-11-28 株式会社リバーベル 画像改質処理方法およびその装置、プログラム、並びにデータ記録媒体
CN1682214A (zh) * 2003-03-07 2005-10-12 松下电器产业株式会社 矩阵运算装置
JP3981399B1 (ja) * 2006-03-10 2007-09-26 松下電器産業株式会社 固定符号帳探索装置および固定符号帳探索方法
EP1989683B1 (en) * 2006-02-22 2017-05-31 Koninklijke Philips N.V. Image reconstruction using data ordering
CN101136882B (zh) * 2006-10-25 2010-05-19 中兴通讯股份有限公司 无线通信基带处理的系统矩阵计算方法和装置
JP5376920B2 (ja) 2008-12-04 2013-12-25 キヤノン株式会社 コンボリューション演算回路、階層的コンボリューション演算回路及び物体認識装置
CN101533387A (zh) * 2009-04-24 2009-09-16 西安电子科技大学 基于fpga的边角块稀疏矩阵并行lu分解器
CN102541814B (zh) * 2010-12-27 2015-10-14 北京国睿中数科技股份有限公司 用于数据通信处理器的矩阵计算装置和方法
CN106445471B (zh) * 2016-10-13 2018-06-01 北京百度网讯科技有限公司 处理器和用于在处理器上执行矩阵乘运算的方法
US20180330275A1 (en) * 2017-05-09 2018-11-15 Microsoft Technology Licensing, Llc Resource-efficient machine learning

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160358069A1 (en) * 2015-06-03 2016-12-08 Samsung Electronics Co., Ltd. Neural network suppression

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
OSODA, TSUTOMA ET AL.: "Vectorization and parallelization technique of block ILU preconditioning for unstructural problems", TRANSACTIONS OF THE INFORMATION PROCESSING SOCIETY OF JAPAN, vol. 41, no. SIG8 (HPS2), November 2000 (2000-11-01), pages 92 - 100 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2020166368A (ja) * 2019-03-28 2020-10-08 三菱電機株式会社 アクセラレータ装置
JP7199283B2 (ja) 2019-03-28 2023-01-05 三菱電機株式会社 アクセラレータ装置
US11403104B2 (en) * 2019-12-09 2022-08-02 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Neural network processor, chip and electronic device
JP2021099658A (ja) * 2019-12-23 2021-07-01 三菱電機マイコン機器ソフトウエア株式会社 ニューラルネットワーク処理装置

Also Published As

Publication number Publication date
US20210149983A1 (en) 2021-05-20
US11281746B2 (en) 2022-03-22
DE112017008040T5 (de) 2020-07-09
CN111052111A (zh) 2020-04-21
JP6956796B2 (ja) 2021-11-02
JPWO2019053835A1 (ja) 2020-10-01

Similar Documents

Publication Publication Date Title
JP6956796B2 (ja) 演算回路、演算方法、およびプログラム
US11568258B2 (en) Operation method
JP6504590B2 (ja) 画像のセマンティックセグメンテーションのためのシステム及びコンピューター実施方法、並びに非一時的コンピューター可読媒体
US20180260709A1 (en) Calculating device and method for a sparsely connected artificial neural network
US11475284B2 (en) Information processing apparatus, neural network program, and processing method for neural network
CN115456160A (zh) 一种数据处理方法和数据处理设备
Chen et al. Multiobjective tracking control design of T–S fuzzy systems: Fuzzy Pareto optimal approach
JP2015197702A (ja) 情報処理装置、情報処理方法
WO2022105108A1 (zh) 一种网络数据分类方法、装置、设备及可读存储介质
JP6822581B2 (ja) 情報処理装置、情報処理方法及びプログラム
US11803360B2 (en) Compilation method, apparatus, computing device and medium
US11631002B2 (en) Information processing device and information processing method
WO2017198169A1 (en) Reduction of parameters in fully connected layers of neural networks
JP5396977B2 (ja) データ処理装置、データ処理方法およびプログラム
US9600446B2 (en) Parallel multicolor incomplete LU factorization preconditioning processor and method of use thereof
KR20220158768A (ko) 기계 학습 가속을 위한 전력 감소
JP2020080048A (ja) 並列処理装置およびプログラム
KR20210014897A (ko) 인공 신경망을 위한 행렬 연산기 및 행렬 연산 방법
US20240046098A1 (en) Computer implemented method for transforming a pre trained neural network and a device therefor
JP2020030702A (ja) 学習装置、学習方法及び学習プログラム
US20230419145A1 (en) Processor and method for performing tensor network contraction in quantum simulator
WO2022077343A1 (en) Method and apparatus for weight-sharing neural network with stochastic architectures
WO2024100709A1 (ja) 最適化装置、最適化方法及びプログラム
TWI659324B (zh) 電路規劃結果產生方法與系統
Melo et al. Quantum-inspired evolutionary algorithm and differential evolution used in the adaptation of segmentation parameters

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

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2019541561

Country of ref document: JP

Kind code of ref document: A

122 Ep: pct application non-entry in european phase

Ref document number: 17925243

Country of ref document: EP

Kind code of ref document: A1