WO2023139990A1 - ニューラルネットワーク回路およびニューラルネットワーク演算方法 - Google Patents

ニューラルネットワーク回路およびニューラルネットワーク演算方法 Download PDF

Info

Publication number
WO2023139990A1
WO2023139990A1 PCT/JP2022/046214 JP2022046214W WO2023139990A1 WO 2023139990 A1 WO2023139990 A1 WO 2023139990A1 JP 2022046214 W JP2022046214 W JP 2022046214W WO 2023139990 A1 WO2023139990 A1 WO 2023139990A1
Authority
WO
WIPO (PCT)
Prior art keywords
circuit
core
quantization
neural network
memory
Prior art date
Application number
PCT/JP2022/046214
Other languages
English (en)
French (fr)
Inventor
賢治 渡邊
Original Assignee
LeapMind株式会社
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 LeapMind株式会社 filed Critical LeapMind株式会社
Publication of WO2023139990A1 publication Critical patent/WO2023139990A1/ja

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
    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present invention relates to a neural network circuit and a neural network operation method.
  • This application claims priority based on Japanese Patent Application No. 2022-008692 filed in Japan on January 24, 2022, the content of which is incorporated herein.
  • CNN convolutional neural networks
  • a convolutional neural network has a multilayer structure having convolution layers and pooling layers, and requires a large number of operations such as convolution operations.
  • Various calculation methods have been devised for speeding up calculation by a convolutional neural network (Patent Document 1, etc.).
  • the object of the present invention is to provide a high-performance neural network circuit and neural network operation method that can be incorporated into embedded devices such as IoT devices.
  • a neural network circuit has a plurality of neural network operation cores each having a convolution operation circuit that performs a convolution operation and a quantization operation circuit that performs a quantization operation, and the plurality of neural network operation cores are connected so as to be capable of inputting and outputting data.
  • a neural network operation method is a neural network operation method using a first neural network operation core and a second neural network operation core, wherein output data of the first neural network operation core is switched between loopback data flow for looping back to the first neural network and bypass data flow for bypassing the second neural network operation core.
  • the neural network circuit and neural network operation method of the present invention can be incorporated into embedded devices such as IoT devices and have high performance.
  • FIG. 2 illustrates a convolutional neural network
  • FIG. 4 is a diagram for explaining convolution operations performed by a convolution layer
  • FIG. 4 is a diagram for explaining expansion of data in a convolution operation
  • 1 is a diagram showing the overall configuration of a neural network circuit according to a first embodiment
  • FIG. It is a figure which shows the whole structure of NN arithmetic core.
  • 4 is a timing chart showing an operation example of the same NN arithmetic core
  • 4 is a timing chart showing another operation example of the same NN operation core
  • It is a figure which shows NN arithmetic multi-core.
  • It is a timing chart showing an operation example of the same NN calculation multi-core.
  • FIG. 4 is a timing chart showing another operation example of the same NN arithmetic multi-core; 4 is a timing chart showing another operation example of the same NN arithmetic multi-core; 3 is an internal block diagram of the DMAC of the same neural network circuit; FIG. 4 is a state transition diagram of a control circuit of the same DMAC; FIG. 4 is an internal block diagram of a convolution operation circuit of the same neural network circuit; FIG. FIG. 4 is an internal block diagram of a multiplier of the convolution arithmetic circuit; 3 is an internal block diagram of a sum-of-products operation unit of the same multiplier; FIG. FIG.
  • FIG. 4 is an internal block diagram of an accumulator circuit of the same convolution arithmetic circuit; It is an internal block diagram of the accumulator unit of the same accumulator circuit. 4 is an internal block diagram of a quantization arithmetic circuit of the same neural network circuit; FIG. 3 is an internal block diagram of a vector operation circuit and a quantization circuit of the same quantization operation circuit; FIG. 4 is a block diagram of an arithmetic unit; FIG. 4 is an internal block diagram of a vector quantization unit of the same quantization circuit; FIG. It is a figure explaining control of the same neural network circuit by a semaphore. It is a timing chart of the first data flow. It is a timing chart of the second data flow.
  • FIG. 8 is an internal block diagram of a convolution circuit of the neural network circuit according to the second embodiment
  • FIG. 4 is an internal block diagram of a multiplier of the convolution arithmetic circuit
  • FIG. 4 is an internal block diagram of a sum-of-products operation unit array of the same multiplier
  • FIG. 4 is an internal block diagram of a sum-of-products operation unit of the same sum-of-products operation unit array
  • It is a figure which shows the whole structure of the neural-network circuit which concerns on 3rd embodiment.
  • 4 is an internal block diagram of the first DMAC of the same neural network circuit;
  • FIG. 8 is an internal block diagram of a convolution circuit of the neural network circuit according to the second embodiment
  • FIG. 4 is an internal block diagram of a multiplier of the convolution arithmetic circuit
  • FIG. 4 is an internal block diagram of a sum-of-products operation unit array of the same multiplier
  • FIG. 4 is an internal block diagram of a sum-of-products operation
  • FIG. 4 is a timing chart showing the operation of a clock control unit such as the first DMAC; 4 is an internal block diagram of a convolution operation circuit of the same neural network circuit; FIG. 4 is an internal block diagram of a quantization arithmetic circuit of the same neural network circuit; FIG. It is a figure which shows the whole structure of the neural-network circuit which concerns on 4th embodiment.
  • FIG. 1 is a diagram showing a convolutional neural network 200 (hereinafter referred to as "CNN 200").
  • CNN 200 convolutional neural network
  • the computations performed by the neural network circuit 100 (hereinafter referred to as "NN circuit 100") according to the first embodiment are at least part of the trained CNN 200 used during inference.
  • the CNN 200 is a multi-layered network including a convolution layer 210 that performs convolution operations, a quantization operation layer 220 that performs quantization operations, and an output layer 230 .
  • convolutional layers 210 and quantization operation layers 220 are interleaved.
  • CNN200 is a model widely used for image recognition and moving image recognition.
  • the CNN 200 may further have layers with other functions, such as fully connected layers.
  • FIG. 2 is a diagram for explaining the convolution operation performed by the convolution layer 210.
  • the convolution layer 210 performs a convolution operation on input data a using weight w.
  • the convolution layer 210 performs a sum-of-products operation with input data a and weight w as inputs.
  • Input data a (also called activation data or feature map) to the convolution layer 210 is multidimensional data such as image data.
  • the input data a is a three-dimensional tensor consisting of elements (x, y, c).
  • the convolution layer 210 of the CNN 200 performs a convolution operation on low-bit input data a.
  • the elements of the input data a are 2-bit unsigned integers (0, 1, 2, 3).
  • Elements of input data a may be, for example, 4-bit or 8-bit unsigned integers.
  • the CNN 200 may further have an input layer that performs type conversion and quantization before the convolutional layer 210.
  • the weights w (also called filters or kernels) of the convolutional layer 210 are multidimensional data whose elements are learnable parameters.
  • the weight w is a 4-dimensional tensor consisting of elements (i,j,c,d).
  • the weight w has d three-dimensional tensors (hereinafter referred to as “weight wo”) each having elements (i, j, c).
  • the weight w in the learned CNN 200 is learned data.
  • Convolutional layer 210 of CNN 200 performs a convolution operation using low-bit weights w.
  • the elements of the weight w are 1-bit signed integers (0,1), where the value '0' represents +1 and the value '1' represents -1.
  • the convolution layer 210 performs the convolution operation shown in Equation 1 and outputs output data f.
  • s indicates stride.
  • the area indicated by the dotted line in FIG. 2 indicates one of the areas ao (hereinafter referred to as “applied area ao”) to which the weight wo is applied to the input data a.
  • Elements of the application area ao are represented by (x+i, y+j, c).
  • the quantization operation layer 220 performs quantization and the like on the convolution operation output from the convolution layer 210 .
  • the quantization operation layer 220 has a pooling layer 221 , a batch normalization layer 222 , an activation function layer 223 and a quantization layer 224 .
  • the pooling layer 221 compresses the output data f of the convolution layer 210 by performing calculations such as average pooling (formula 2) and MAX pooling (formula 3) on the convolutional calculation output data f output by the convolution layer 210 .
  • u indicates the input tensor
  • v indicates the output tensor
  • T indicates the size of the pooling region.
  • max is a function that outputs the maximum value of u for combinations of i and j contained in T.
  • the Batch normalization layer 222 normalizes the data distribution of the output data of the quantization operation layer 220 and the pooling layer 221 by, for example, the operation shown in Equation 4.
  • Equation 4 u denotes the input tensor, v the output tensor, ⁇ the scale, and ⁇ the bias.
  • ⁇ and ⁇ are trained constant vectors.
  • the activation function layer 223 computes an activation function such as ReLU (equation 5) on the outputs of the quantization computation layer 220, the pooling layer 221, and the batch normalization layer 222.
  • ReLU activation function
  • u is the input tensor
  • v is the output tensor.
  • max is a function that outputs the largest numerical value among the arguments.
  • the quantization layer 224 quantizes the output of the pooling layer 221 and the activation function layer 223 based on the quantization parameter, as shown in Equation 6, for example.
  • the quantization shown in Equation 6 reduces the input tensor u to 2 bits.
  • q(c) is the vector of quantization parameters.
  • q(c) is a trained constant vector.
  • the inequality sign “ ⁇ ” in Equation 6 may be “ ⁇ ”.
  • the output layer 230 is a layer that outputs the results of the CNN 200 using the identity function, softmax function, and the like.
  • a layer preceding the output layer 230 may be the convolution layer 210 or the quantization operation layer 220 .
  • the quantized output data of the quantization layer 224 is input to the convolution layer 210, so the convolution operation load of the convolution layer 210 is small compared to other convolutional neural networks that do not perform quantization.
  • the NN circuit 100 divides the input data for the convolution operation (Equation 1) of the convolution layer 210 into partial tensors and performs the operation.
  • the method of division into partial tensors and the number of divisions are not particularly limited.
  • a partial tensor is formed, for example, by splitting the input data a(x+i, y+j, c) into a(x+i, y+j, co).
  • the NN circuit 100 can also perform computation without dividing the input data for the convolution computation (equation 1) of the convolution layer 210 .
  • the variable c in Equation 1 is divided into blocks of size Bc as shown in Equation 7.
  • the variable d in Equation 1 is divided into blocks of size Bd, as shown in Equation 8.
  • co is the offset and ci is the index from 0 to (Bc-1).
  • do is the offset and di is the index from 0 to (Bd-1). Note that the size Bc and the size Bd may be the same.
  • the input data a(x+i, y+j, c) in Equation 1 is divided by the size Bc in the c-axis direction and represented by the divided input data a(x+i, y+j, co).
  • the divided input data a is also referred to as "divided input data a".
  • the weight w (i, j, c, d) in Equation 1 is divided by the size Bc in the c-axis direction and the size Bd in the d-axis direction, and is represented by the divided weight w (i, j, co, do).
  • the divided weight w is also referred to as "divided weight w".
  • the output data f(x, y, do) divided by the size Bd is obtained by Equation 9.
  • the final output data f(x, y, d) can be calculated.
  • the NN circuit 100 develops the input data a and the weight w in the convolution operation of the convolution layer 210 and performs the convolution operation.
  • FIG. 3 is a diagram for explaining expansion of data in a convolution operation.
  • Divided input data a(x+i, y+j, co) is developed into vector data having Bc elements. Elements of the divided input data a are indexed by ci (0 ⁇ ci ⁇ Bc).
  • divided input data a developed into vector data for each i and j is also referred to as "input vector A".
  • Input vector A has elements from divided input data a(x+i, y+j, co ⁇ Bc) to divided input data a(x+i, y+j, co ⁇ Bc+(Bc ⁇ 1)).
  • the division weight w (i, j, co, do) is developed into matrix data with Bc ⁇ Bd elements.
  • the elements of the division weight w developed into matrix data are indexed by ci and di (0 ⁇ di ⁇ Bd).
  • the divided weight w developed into matrix data for each i and j is also referred to as "weight matrix W".
  • the weight matrix W has division weights w (i, j, co ⁇ Bc, do ⁇ Bd) to division weights w (i, j, co ⁇ Bc+(Bc ⁇ 1), do ⁇ Bd+(Bd ⁇ 1)) as elements.
  • Output data f(x, y, do) can be obtained by shaping the vector data calculated for each of i, j, and co into a three-dimensional tensor.
  • the convolution operation of the convolution layer 210 can be performed by multiplying the vector data and the matrix data.
  • FIG. 4 is a diagram showing the overall configuration of the NN circuit 100 according to this embodiment.
  • the NN circuit 100 includes a first DMA controller 3 (hereinafter also referred to as “first DMAC 3”), a controller 6, an IFU 7, a shared memory 8, a second DMA controller 9 (hereinafter also referred to as “second DMAC 9”), and at least one neural network operation core 10 (hereinafter also referred to as "NN operation core 10").
  • the NN circuit 100 can implement a plurality of NN operation cores 10.
  • the NN circuit 100 illustrated in FIG. 4 can implement up to four NN operation cores 10 .
  • the plurality of NN operation cores 10 constitute a "neural network operation multi-core 10M (hereinafter also referred to as "NN operation multi-core 10M")" that cooperates to execute at least part of the operation of the NN 200.
  • FIG. A plurality of NN operation cores 10 are daisy-chained in this embodiment. Note that the number of NN operation cores 10 that can be implemented in the NN circuit 100 may be five or more.
  • the first DMAC 3 is connected to the external bus EB and performs data transfer between the external memory 120 such as DRAM and the NN operation core 10 .
  • the first DMAC 3 transfers data read from the external memory 120 to one of the NN operation cores 10 .
  • the first DMAC 3 may be capable of transferring the same data read from the external memory 120 to a plurality of NN operation cores 10, or may be capable of broadcasting.
  • the first DMAC 3 also transfers data between an external memory such as a DRAM and the shared memory 8 .
  • the controller 6 is connected to the external bus EB and operates as a slave of the external host CPU 110 .
  • the controller 6 has a bus bridge 60 and a register 61 .
  • the bus bridge 60 relays bus access from the external bus EB to the internal bus IB.
  • the bus bridge 60 also relays write requests and read requests from the external host CPU 110 to the register 61 .
  • the register 61 has a parameter register and a status register.
  • a parameter register is a register that controls the operation of the NN circuit 100 .
  • the status register is a register that indicates the status of the NN circuit 100, including a pointer to the instruction sequence of each module, the number of instructions, and the like. Also, the status register may be configured to include a semaphore S.
  • FIG. The external host CPU 110 can access the register 61 via the bus bridge 60 of the controller 6 .
  • the controller 6 is connected to each block of the NN circuit 100 (first DMAC 3, IFU 7, second DMAC 9, NN arithmetic core 10) via an internal bus IB.
  • the external host CPU 110 can access each block of the NN circuit 100 via the controller 6 .
  • the external host CPU 110 can issue instructions to the NN arithmetic core 10 via the controller 6 .
  • each block can update the status register (which may include the semaphore S) of the controller 6 via the internal bus IB.
  • the status register may be configured to be updated via dedicated wiring connected to each block.
  • the IFU (Instruction Fetch Unit) 7 reads from the external memory 120 instructions for each block of the NN circuit 100 (the first DMAC 3, the second DMAC 9, and the NN arithmetic core 10) via the external bus EB based on instructions from the external host CPU 110. Also, the IFU 7 transfers the read instruction command to each corresponding block of the NN circuit 100 (the first DMAC 3, the second DMAC 9, and the NN operation core 10).
  • the shared memory 8 is a rewritable memory such as a volatile memory composed of, for example, SRAM (Static RAM).
  • the shared memory 8 is a memory for temporarily recording data used by the NN operation core 10 and for recording data shared by a plurality of NN operation cores.
  • the second DMAC 9 connects the shared memory 8 and the NN operation core 10 and performs data transfer between the shared memory 8 and the NN operation core 10 .
  • the second DMAC 9 may be capable of broadcasting data read from the shared memory 8 to the multiple NN operation cores 10 .
  • the NN circuit 100 can temporarily save data and the like shared by a plurality of NN calculation cores to the shared memory 8 using the second DMAC 9 without saving it to the external memory 120 using the first DMAC 3, thereby speeding up the data transfer between the NN calculation cores. Note that the NN circuit 100 does not have to have the shared memory 8 and the second DMAC 9 .
  • FIG. 5 is a diagram showing the overall configuration of the NN operation core 10. As shown in FIG.
  • the NN operation core 10 includes a first memory 1 , a second memory 2 , a convolution operation circuit 4 and a quantization operation circuit 5 .
  • the NN operation core 10 is characterized in that a convolution operation circuit 4 and a quantization operation circuit 5 are formed in a loop via a first memory 1 and a second memory 2 .
  • the first memory 1 is a rewritable memory such as a volatile memory composed of, for example, SRAM (Static RAM). Data is written to and read from the first memory 1 via the first DMAC 3, the second DMAC 9, and the internal bus IB.
  • the external host CPU 110 can input/output data to/from the NN operation core 10 by writing/reading data to/from the first memory 1 .
  • the first memory 1 is connected to the input port of the convolution operation circuit 4 , and the convolution operation circuit 4 can read data from the first memory 1 . Also, the first memory 1 is loop-connected (C1) to the output port of the quantization operation circuit 5 , and the quantization operation circuit 5 can write data to the first memory 1 . In addition, the first memory 1 can transfer data through the inter-core connection (C2) with another NN operation core 10, and the other NN operation core 10 connected between the cores (C2) can write data to the first memory 1. In this embodiment, daisy chain connection is used as an example of inter-core connection (C2).
  • the second memory 2 is a rewritable memory such as a volatile memory composed of, for example, SRAM (Static RAM). Data is written to and read from the second memory 2 via the first DMAC 3, the second DMAC 9, and the internal bus IB.
  • the external host CPU 110 can input/output data to/from the NN operation core 10 by writing/reading data to/from the second memory 2 .
  • the second memory 2 is connected to the input port of the quantization arithmetic circuit 5, and the quantization arithmetic circuit 5 can read data from the second memory 2.
  • the second memory 2 is also connected to the output port of the convolution circuit 4 , and the convolution circuit 4 can write data to the second memory 2 .
  • the convolution operation circuit 4 is a circuit that performs convolution operations in the convolution layer 210 of the trained CNN 200 .
  • the convolution operation circuit 4 reads the input data a stored in the first memory 1 and performs a convolution operation on the input data a.
  • the convolution operation circuit 4 writes output data f of the convolution operation (hereinafter also referred to as “convolution operation output data”) to the second memory 2 .
  • the quantization operation circuit 5 is a circuit that performs at least part of the quantization operation in the quantization operation layer 220 of the trained CNN 200.
  • the quantization operation circuit 5 reads out the output data f of the convolution operation stored in the second memory 2, and performs a quantization operation on the output data f of the convolution operation (operation including at least quantization among pooling, batch normalization, activation function, and quantization).
  • the quantization operation circuit 5 writes the output data of the quantization operation (hereinafter also referred to as "quantization operation output data") to the loop-connected (C1) first memory 1 . Further, the quantization operation circuit 5 can transfer data to another NN operation core 10 via the inter-core connection (C2), and the quantization operation circuit 5 can output the quantization operation output data to the other NN operation core 10 connected to the inter-core connection (C2).
  • the NN operation core 10 Since the NN operation core 10 has the first memory 1, the second memory 2, etc., it is possible to reduce the number of data transfers of overlapping data in the data transfer by the first DMAC 3 from the external memory such as DRAM. As a result, the power consumption or processing load caused by memory access can be greatly reduced.
  • FIG. 6 is a timing chart showing an operation example of the NN arithmetic core 10.
  • the first DMAC 3 stores the layer 1 input data a in the first memory 1 .
  • the first DMAC 3 may divide the input data a of the layer 1 according to the order of the convolution operation performed by the convolution operation circuit 4 and transfer the divided data to the first memory 1 .
  • the convolution operation circuit 4 reads the layer 1 input data a stored in the first memory 1 .
  • the convolution operation circuit 4 performs the layer 1 convolution operation shown in FIG. 1 on the layer 1 input data a.
  • the output data f of the layer 1 convolution operation is stored in the second memory 2 .
  • the quantization arithmetic circuit 5 reads the layer 1 output data f stored in the second memory 2 .
  • a quantization operation circuit 5 performs a layer 2 quantization operation on layer 1 output data f.
  • the output data of the layer 2 quantization operation is stored in the first memory 1 .
  • the convolution operation circuit 4 reads the output data of the layer 2 quantization operation stored in the first memory 1 .
  • the convolution operation circuit 4 performs a layer 3 convolution operation using the output data of the layer 2 quantization operation as input data a.
  • the output data f of the layer 3 convolution operation is stored in the second memory 2 .
  • the convolution operation circuit 4 reads the output data of the quantization operation of the layer 2M-2 (M is a natural number) stored in the first memory 1.
  • the convolution operation circuit 4 performs the convolution operation of the layer 2M-1 using the output data of the quantization operation of the layer 2M-2 as the input data a.
  • the output data f of the layer 2M-1 convolution operation is stored in the second memory 2.
  • the quantization arithmetic circuit 5 reads the layer 2M-1 output data f stored in the second memory 2 .
  • the quantization operation circuit 5 performs a layer 2M quantization operation on the output data f of the 2M ⁇ 1 layer.
  • the output data of the layer 2M quantization operation are stored in the first memory 1 .
  • the convolution operation circuit 4 reads the output data of the layer 2M quantization operation stored in the first memory 1 .
  • the convolution operation circuit 4 performs a layer 2M+1 convolution operation using the output data of the layer 2M quantization operation as input data a.
  • the output data f of the layer 2M+1 convolution operation are stored in the second memory 2 .
  • the convolution operation circuit 4 and the quantization operation circuit 5 alternately perform operations to advance the operation of the CNN 200 shown in FIG.
  • the convolution operation circuit 4 performs the convolution operation of layer 2M-1 and layer 2M+1 by time division.
  • the quantization operation circuit 5 performs the quantization operation of layer 2M-2 and layer 2M by time division. Therefore, the NN operation core 10 has a significantly smaller circuit scale compared to the case where separate convolution operation circuits 4 and quantization operation circuits 5 are implemented for each layer.
  • the NN operation core 10 performs operations of the CNN 200, which has a multilayer structure of multiple layers, using circuits formed in a loop.
  • the NN operation core 10 can efficiently use hardware resources due to its looped circuit configuration. Since the NN operation core 10 forms a circuit in a loop, parameters in the convolution operation circuit 4 and the quantization operation circuit 5 that change in each layer are updated as appropriate.
  • the NN computation core 10 transfers intermediate data to an external computation device such as the external host CPU 110. After the external arithmetic device performs arithmetic on the intermediate data, the arithmetic result by the external arithmetic device is input to the first memory 1 and the second memory 2 . The NN operation core 10 resumes operation on the operation result by the external operation device.
  • FIG. 7 is a timing chart showing another operation example of the NN arithmetic core 10.
  • the NN operation core 10 may divide the input data a into partial tensors and perform operations on the partial tensors by time division.
  • the method of division into partial tensors and the number of divisions are not particularly limited.
  • FIG. 7 shows an operation example when the input data a is decomposed into two partial tensors.
  • the decomposed partial tensors be “first partial tensor a 1 ” and “second partial tensor a 2 ”.
  • the convolution operation of layer 2M-1 is decomposed into a convolution operation corresponding to the first partial tensor a 1 (denoted as “layer 2M-1 (a 1 )” in FIG. 7) and a convolution operation corresponding to the second partial tensor a 2 (denoted “layer 2M-1 (a 2 )” in FIG. 7).
  • the convolution and quantization operations corresponding to the first partial tensor a 1 and the convolution and quantization operations corresponding to the second partial tensor a 2 can be performed independently, as shown in FIG.
  • the convolution operation circuit 4 performs a layer 2M-1 convolution operation (operation indicated by layer 2M-1 (a 1 ) in FIG. 7) corresponding to the first partial tensor a 1 . After that, the convolution operation circuit 4 performs a layer 2M-1 convolution operation (operation indicated by layer 2M-1 (a 2 ) in FIG. 7) corresponding to the second partial tensor a 2 .
  • the quantization operation circuit 5 also performs a layer 2M quantization operation (operation indicated by layer 2M(a 1 ) in FIG. 7) corresponding to the first partial tensor a 1 . In this way, the NN operation core 10 can perform the layer 2M-1 convolution operation corresponding to the second partial tensor a 2 and the layer 2M quantization operation corresponding to the first partial tensor a 1 in parallel.
  • the convolution operation circuit 4 performs a layer 2M+1 convolution operation (operation indicated by layer 2M+1 (a 1 ) in FIG. 7) corresponding to the first partial tensor a 1 .
  • the quantization operation circuit 5 also performs a layer 2M quantization operation (operation indicated by layer 2M (a 2 ) in FIG. 7) corresponding to the second partial tensor a2.
  • the NN operation core 10 can perform the layer 2M+ 1 convolution operation corresponding to the first partial tensor a1 and the layer 2M quantization operation corresponding to the second partial tensor a2 in parallel.
  • the convolution and quantization operations corresponding to the first partial tensor a 1 and the convolution and quantization operations corresponding to the second partial tensor a 2 can be performed independently. Therefore, the NN operation core 10 may perform, for example, a layer 2M ⁇ 1 convolution operation corresponding to the first partial tensor a 1 and a layer 2M+2 quantization operation corresponding to the second partial tensor a 2 in parallel. That is, the convolution operation and quantization operation that the NN operation core 10 performs in parallel are not limited to the operation of successive layers.
  • the NN operation core 10 can operate the convolution operation circuit 4 and the quantization operation circuit 5 in parallel. As a result, the waiting time of the convolution operation circuit 4 and the quantization operation circuit 5 is reduced, and the operation processing efficiency of the NN operation core 10 is improved.
  • the number of divisions is 2 in the operation example shown in FIG. 7, the NN operation core 10 can operate the convolution operation circuit 4 and the quantization operation circuit 5 in parallel even when the number of divisions is greater than 2.
  • the NN operation core 10 may perform the layer 2M-1 convolution operation corresponding to the second partial tensor a 2 and the layer 2M quantization operation corresponding to the third partial tensor a 3 in parallel.
  • the order of operations is appropriately changed according to the storage conditions of the input data a in the first memory 1 and the second memory 2 .
  • Method 1 As a calculation method for partial tensors, an example (Method 1) is shown in which partial tensors in the same layer are calculated in the convolution calculation circuit 4 or quantization calculation circuit 5, and then partial tensors in the next layer are calculated.
  • Method 1 As shown in FIG. 7, in the convolution operation circuit 4, after performing the layer 2M-1 convolution operation corresponding to the first partial tensor a 1 and the second partial tensor a 2 (in FIG.
  • the calculation method for partial tensors is not limited to this.
  • the calculation method for the partial tensors may be a method of calculating partial tensors in multiple layers and then calculating remaining partial tensors (Method 2). For example, in the convolution operation circuit 4, after performing the layer 2M ⁇ 1 corresponding to the first partial tensor a 1 and the layer 2M+ 1 corresponding to the first partial tensor a 1 , the layer 2M ⁇ 1 corresponding to the second partial tensor a2 and the layer 2M+ 1 corresponding to the second partial tensor a2 may be carried out.
  • the method of computing partial tensors may be a method of computing partial tensors by combining method 1 and method 2. However, when method 2 is used, it is necessary to perform operations in accordance with the dependency regarding the operation order of partial tensors.
  • FIG. 8 is a diagram showing the NN arithmetic multicore 10M.
  • the NN operation multi-core 10M illustrated in FIG. 8 includes two NN operation cores 10 that are daisy-chained. When distinguishing between the two NN operation cores 10, the two NN operation cores 10 are referred to as "first NN operation core 10A” and "second NN operation core 10B".
  • the first memory 1 is abbreviated as "A”
  • the convolution operation circuit 4 as "C”
  • the second memory 2 as "F”
  • the quantization operation circuit 5 as "Q”.
  • the quantization arithmetic circuit 5 of the first NN arithmetic core 10A and the first memory 1 of the second NN arithmetic core 10B are daisy chain connected (C2).
  • the quantization operation circuit 5 of the first NN operation core 10A can write quantization operation output data to the first memory 1 of the loop-connected (C1) first NN operation core 10A and/or the first memory 1 of the daisy-chain-connected (C2) second NN operation core 10B.
  • the quantization arithmetic circuit 5 of the second NN arithmetic core 10B and the first memory 1 of the first NN arithmetic core 10A are daisy chain connected (C2).
  • the quantization operation circuit 5 of the second NN operation core 10B can write the quantization operation output data to the first memory 1 of the loop-connected (C1) second NN operation core 10B and/or the first memory 1 of the daisy-chain-connected (C2) first NN operation core 10A.
  • the NN operation multi-core 10M includes three or more NN operation cores 10
  • the plurality of NN operation cores 10 are daisy-chained.
  • the quantization operation circuits 5 of the NN operation cores 10 other than the NN operation core 10 at the final stage are daisy-chain connected (C2) to the first memory 1 of the NN operation core 10B at the subsequent stage.
  • the quantization operation circuit 5 of the NN operation core 10 at the final stage is daisy-chain connected (C2) to the first memory 1 of the NN operation core 10 at the first stage.
  • a plurality of NN operation cores 10 are characterized in that they are formed in a daisy chain loop.
  • the first memory (A) 1, the convolution operation circuit (C) 4, the second memory (F) 2, and the quantization operation circuit (Q) 5 are connected in a loop.
  • the first memory (A) 1, the convolution operation circuit (C) 4, the second memory (F) 2, and the quantization operation circuit (Q) 5 are connected in a daisy chain loop so that the first memory (A) 1, the convolution operation circuit (C) 4, the second memory (F) 2, and the quantization operation circuit (Q) 5 are repeatedly arranged in the same order.
  • the multiple NN operation cores 10 that make up the NN operation multi-core 10M do not have to have the same hardware configuration.
  • the capacity/configuration of the first memory 1 of the first NN operation core 10A may be different from the capacity/configuration of the first memory 1 of the second NN operation core 10B.
  • the configuration of the quantization operation circuit 5 of the first NN operation core 10A may be different from the configuration of the quantization operation circuit 5 of the second NN operation core 10B.
  • FIG. 9 is a timing chart showing operation example 1 of the NN arithmetic multi-core 10M.
  • the convolution operation and quantization operation corresponding to the first partial tensor a 1 and the convolution operation and quantization operation corresponding to the second partial tensor a 2 are performed independently by different NN operation cores 10, as shown in FIG.
  • the convolution operation circuit 4 of the first NN operation core 10A performs a layer 2M- 1 convolution operation (operation indicated by layer 2M-1 (a 1 ) in FIG. 9) corresponding to the first partial tensor a 1 .
  • the quantization operation circuit 5 of the first NN operation core 10A performs a layer 2M quantization operation (operation indicated by layer 2M(a 1 ) in FIG. 9) corresponding to the first partial tensor a 1 .
  • the quantization operation circuit 5 of the first NN operation core 10A stores the layer 2M quantization operation output data corresponding to the first partial tensor a 1 in the first memory 1 of the first NN operation core 10A.
  • the convolution operation circuit 4 of the second NN operation core 10B performs a layer 2M-1 convolution operation (operation indicated by layer 2M-1 (a 2 ) in FIG. 9) corresponding to the second partial tensor a 2 .
  • the quantization operation circuit 5 of the second NN operation core 10B performs a layer 2M quantization operation (operation indicated by layer 2M(a 2 ) in FIG. 9) corresponding to the second partial tensor a2.
  • the quantization operation circuit 5 of the second NN operation core 10B stores the layer 2M quantization operation output data corresponding to the second partial tensor a2 in the first memory 1 of the second NN operation core 10B.
  • the second DMAC 9 DMA-transfers the layer 2M quantization operation output data corresponding to the first partial tensor a 1 stored in the first memory 1 of the first NN operation core 10A to the shared memory 8 (transfer indicated by DMA1 in FIG. 9).
  • the second DMAC 9 DMA-transfers the layer 2M quantization calculation output data corresponding to the second partial tensor a2 stored in the first memory 1 of the second NN calculation core 10B to the shared memory 8 (transfer indicated by DMA2 in FIG. 9).
  • the first DMAC 3 DMA-transfers the layer 2M quantization operation output data corresponding to the first partial tensor a 1 and the second partial tensor a 2 stored in the shared memory 8 to the external memory 120 (transfer indicated by DMA 3 in FIG. 9).
  • the NN operation multi-core 10M can, for example, independently perform operations on the same layer using different NN operation cores 10 to shorten the time required for the operation.
  • the shared memory 8 and the second DMAC 9 can organize the calculation results of the NN calculation cores 10 .
  • FIG. 10 is a timing chart showing operation example 2 of the NN arithmetic multi-core 10M. Convolution and quantization operations corresponding to the first partial tensor a 1 are performed cooperatively by different NN operation cores 10 .
  • the convolution operation circuit 4 of the first NN operation core 10A performs the layer 2M-1 convolution operation (the operation indicated by layer 2M-1 (a 1 ) in FIG. 10) corresponding to the first partial tensor a 1 .
  • the quantization operation circuit 5 of the first NN operation core 10A performs a layer 2M quantization operation (operation indicated by layer 2M(a 1 ) in FIG. 10) corresponding to the first partial tensor a 1 .
  • the quantization operation circuit 5 of the first NN operation core 10A stores the layer 2M quantization operation output data corresponding to the first partial tensor a 1 in the first memory 1 of the second NN operation core 10B.
  • the convolution operation circuit 4 of the second NN operation core 10B performs the layer 2M+1 convolution operation (the operation indicated by layer 2M+1 (a 1 ) in FIG. 10) corresponding to the first partial tensor a 1 . Thereafter, the quantization operation circuit 5 of the second NN operation core 10B performs a layer 2M+2 quantization operation (operation indicated by layer 2M+2 (a 1 ) in FIG. 10) corresponding to the first partial tensor a 1 .
  • the quantization operation circuit 5 of the second NN operation core 10B stores the quantization operation output data of layer 2M+ 2 corresponding to the second partial tensor a2 in the first memory 1 of the second NN operation core 10B.
  • the first DMAC 3 DMA-transfers the layer 2M+2 quantization operation output data corresponding to the first partial tensor a 1 stored in the first memory 1 of the second NN operation core 10B to the external memory 120 (transfer indicated by DMA in FIG. 10).
  • the NN computation multi-core 10M can reduce the time required for computation by successively performing computations corresponding to the same partial tensor by different NN computation cores 10, for example.
  • FIG. 11 is a timing chart showing operation example 3 of the NN arithmetic multi-core 10M.
  • operation example 3 the configuration of the partial tensor is changed in the layer 2M ⁇ 1 convolution operation and the layer 2M+1 convolution operation.
  • the second DMAC 9 DMA-transfers the first partial tensor a 1 to the first memory 1 of the first NN operation core 10A (transfer indicated by DMA1 in FIG. 11).
  • the second DMAC 9 DMA-transfers the second partial tensor a2 to the first memory 1 of the second NN operation core 10B (transfer indicated by DMA2 in FIG. 11).
  • the convolution operation circuit 4 of the first NN operation core 10A performs the layer 2M-1 convolution operation (the operation indicated by layer 2M-1 (a 1 ) in FIG. 11) corresponding to the first partial tensor a 1 .
  • the quantization operation circuit 5 of the first NN operation core 10A performs a layer 2M quantization operation (operation indicated by layer 2M(a 1 ) in FIG. 11) corresponding to the first partial tensor a 1 .
  • the quantization operation circuit 5 of the first NN operation core 10A stores the layer 2M quantization operation output data corresponding to the first partial tensor a 1 in the first memory 1 of the first NN operation core 10A.
  • the second DMAC 9 DMA-transfers the layer 2M quantization operation output data corresponding to the first partial tensor a 1 stored in the first memory 1 of the first NN operation core 10A to the shared memory 8 (transfer indicated by DMA3 in FIG. 11).
  • the convolution operation circuit 4 of the second NN operation core 10B performs a layer 2M-1 convolution operation (operation indicated by layer 2M-1 (a 2 ) in FIG. 11) corresponding to the second partial tensor a 2 .
  • the start of the convolution operation by the convolution operation circuit 4 of the second NN operation core 10B is later than the start of the convolution operation by the convolution operation circuit 4 of the first NN operation core 10A.
  • the quantization operation circuit 5 of the second NN operation core 10B performs a layer 2M quantization operation corresponding to the second partial tensor a2 (the operation indicated by layer 2M( a2 ) in FIG. 11).
  • the quantization operation circuit 5 of the second NN operation core 10B stores the layer 2M quantization operation output data corresponding to the second partial tensor a2 in the first memory 1 of the second NN operation core 10B.
  • the second DMAC 9 DMA-transfers the layer 2M quantization operation output data corresponding to the second partial tensor a 2 stored in the first memory 1 of the second NN operation core 10B to the shared memory 8 (transfer indicated by DMA4 in FIG. 11).
  • each NN operation core 10 is optimized to perform parallel operations on input data a with 32 channels in the c-axis direction, and performs a layer 2M+1 convolution operation in which input data a has 64 channels in the c-axis direction.
  • the manner in which the input data a is divided into partial tensors may be changed so that the convolution operation circuit 4 of the NN operation core 10A operates on the input data a of channels 0 to 31, and the convolution operation circuit 4 of the NN operation core 10B operates on the input data a of channels 32 to 63.
  • Two of the subdivided partial tensors are called “third partial tensor a 3 ” and “fourth partial tensor a 4 ”.
  • the second DMAC 9 DMA-transfers the third partial tensor a3 to the first memory 1 of the first NN operation core 10A (transfer indicated by DMA5 in FIG. 11).
  • the second DMAC 9 DMA-transfers the fourth partial tensor a4 to the first memory 1 of the second NN operation core 10B (transfer indicated by DMA6 in FIG. 11).
  • the convolution operation circuit 4 of the first NN operation core 10A performs a layer 2M+1 convolution operation (operation indicated by layer 2M+1 (a 3 ) in FIG. 11) corresponding to the third partial tensor a 3 .
  • the quantization operation circuit 5 of the first NN operation core 10A performs a layer 2M+2 quantization operation (operation indicated by layer 2M+2 (a 3 ) in FIG. 11) corresponding to the third partial tensor a3 .
  • the quantization operation circuit 5 of the first NN operation core 10A stores the quantization operation output data of layer 2M+2 corresponding to the third partial tensor a3 in the first memory 1 of the first NN operation core 10A.
  • the convolution operation circuit 4 of the second NN operation core 10B performs a layer 2M+1 convolution operation (operation indicated by layer 2M+1 (a 4 ) in FIG. 11) corresponding to the fourth partial tensor a 4 .
  • the quantization operation circuit 5 of the second NN operation core 10B performs a layer 2M+2 quantization operation (operation indicated by layer 2M+2 (a 4 ) in FIG. 11) corresponding to the fourth partial tensor a 4 .
  • the quantization operation circuit 5 of the second NN operation core 10B stores the quantization operation output data of layer 2M+2 corresponding to the fourth partial tensor a4 in the first memory 1 of the second NN operation core 10B.
  • the NN circuit 100 uses the second DMAC 9 and the shared memory 8 to change the division mode of the partial tensor assigned to the NN operation core 10.
  • the NN circuit 100 can reduce the number of times the input data a is saved in the external memory 120 by DMA transfer using the first DMAC 3 even when changing the division mode of the partial tensor.
  • FIG. 12 is an internal block diagram of the first DMAC3.
  • the first DMAC 3 has a data transfer circuit 31 and a state controller 32 .
  • the first DMAC 3 has a dedicated state controller 32 for the data transfer circuit 31, and when an instruction command is input, DMA data transfer can be performed without the need for an external controller.
  • the data transfer circuit 31 is connected to the external bus EB and performs DMA data transfer between the external memory 120 such as DRAM and the NN operation core 10 .
  • the data transfer circuit 31 also performs DMA data transfer between the external memory 120 such as a DRAM and the shared memory 8 .
  • the number of DMA channels of the data transfer circuit 31 is not limited.
  • each of the first NN operation core 10A and the second NN operation core 10B may have a dedicated DMA channel.
  • the state controller 32 controls the state of the data transfer circuit 31 . Also, the state controller 32 is connected to the controller 6 via an internal bus IB. The state controller 32 has an instruction queue 33 and a control circuit 34 .
  • the instruction queue 33 is a queue in which the instruction command C3 for the first DMAC 3 is stored, and is composed of a FIFO memory, for example.
  • One or more instruction commands C3 are written into the instruction queue 33 via the IFU 7 or via the internal bus IB.
  • the control circuit 34 is a state machine that decodes the instruction command C3 and sequentially controls the data transfer circuit 31 based on the instruction command C3.
  • the control circuit 34 may be implemented by a logic circuit or by a CPU controlled by software.
  • FIG. 13 is a state transition diagram of the control circuit 34. As shown in FIG. When the instruction command C3 is input to the instruction queue 33 (Not empty), the control circuit 34 transitions from the idle state ST1 to the decode state ST2.
  • the control circuit 34 decodes the instruction command C3 output from the instruction queue 33 in the decode state ST2. Also, the control circuit 34 reads the semaphore S stored in the register 61 of the controller 6 and determines whether the operation of the data transfer circuit 31 instructed by the instruction command C3 can be executed. If it is not executable (Not ready), the control circuit 34 waits until it becomes executable (Wait). If it is executable (ready), the control circuit 34 transitions from the decode state ST2 to the execution state ST3.
  • the control circuit 34 controls the data transfer circuit 31 to perform the operation instructed by the instruction command C3.
  • the control circuit 34 removes the executed instruction command C3 from the instruction queue 33 and updates the semaphore S stored in the register 61 of the controller 6 .
  • the control circuit 34 transitions from the execution state ST3 to the decode state ST2.
  • the control circuit 34 transitions from the execution state ST3 to the idle state ST1.
  • FIG. 14 is an internal block diagram of the convolution operation circuit 4. As shown in FIG.
  • the convolution circuit 4 has a weight memory 41 , a multiplier 42 , an accumulator circuit 43 and a state controller 44 .
  • the convolution operation circuit 4 has a dedicated state controller 44 for the multiplier 42 and the accumulator circuit 43, and when an instruction command is input, the convolution operation can be performed without the need for an external controller.
  • the weight memory 41 is a memory that stores the weight w used in the convolution operation, and is a rewritable memory such as a volatile memory configured with SRAM (Static RAM), for example.
  • the first DMAC 3 writes the weight w required for the convolution operation into the weight memory 41 by DMA transfer.
  • FIG. 15 is an internal block diagram of the multiplier 42.
  • Multiplier 42 multiplies input vector A and weight matrix W.
  • the input vector A is vector data having Bc elements obtained by expanding divided input data a(x+i, y+j, co) for each i and j, as described above.
  • the weight matrix W is matrix data having Bc ⁇ Bd elements in which divided weights w(i, j, co, do) are expanded for each i and j.
  • the multiplier 42 has Bc ⁇ Bd product-sum operation units 47, and can perform multiplication of the input vector A and the weight matrix W in parallel.
  • the multiplier 42 reads out the input vector A and the weight matrix W required for multiplication from the first memory 1 and the weight memory 41 to carry out the multiplication.
  • the multiplier 42 outputs Bd sum-of-products operation results O(di).
  • FIG. 16 is an internal block diagram of the sum-of-products operation unit 47.
  • Sum-of-products unit 47 performs multiplication of input vector A element A(ci) with weight matrix W element W(ci, di). Further, the sum-of-products operation unit 47 adds the multiplication result and the multiplication result S(ci, di) of another sum-of-products operation unit 47 .
  • the sum-of-products operation unit 47 outputs the addition result S(ci+1, di).
  • Element A(ci) is a 2-bit unsigned integer (0, 1, 2, 3).
  • the element W(ci,di) is a 1-bit signed integer (0,1), where the value "0" represents +1 and the value "1" represents -1.
  • the sum-of-products operation unit 47 has an inverter (inverter) 47a, a selector 47b, and an adder 47c.
  • the sum-of-products operation unit 47 performs multiplication using only the inverter 47a and the selector 47b without using a multiplier.
  • the selector 47b selects the input of the element A(ci) when the element W(ci, di) is "0". When the element W(ci, di) is "1", the selector 47b selects the complement of the element A(ci) inverted by the inverter. Element W(ci, di) is also input to Carry-in of adder 47c.
  • the adder 47c outputs a value obtained by adding the element A(ci) to S(ci, di) when the element W(ci, di) is "0".
  • the adder 47c outputs a value obtained by subtracting the element A(ci) from S(ci, di) when W(ci, di) is "1".
  • FIG. 17 is an internal block diagram of the accumulator circuit 43. As shown in FIG. The accumulator circuit 43 accumulates the sum-of-products operation result O(di) of the multiplier 42 in the second memory 2 .
  • the accumulator circuit 43 has Bd accumulator units 48 and can accumulate Bd product-sum operation results O(di) in parallel in the second memory 2 .
  • FIG. 18 is an internal block diagram of the accumulator unit 48.
  • the accumulator unit 48 has an adder 48a and a mask portion 48b.
  • the adder 48 a adds the element O(di) of the sum-of-products operation result O and the partial sum, which is the intermediate progress of the convolution operation shown in Equation 1, stored in the second memory 2 .
  • the addition result is 16 bits per element.
  • the addition result is not limited to 16 bits per element, and may be, for example, 15 bits or 17 bits per element.
  • the adder 48a writes the addition result to the same address in the second memory 2.
  • the mask unit 48b masks the output from the second memory 2 and zeros the addition target for the element O(di) when the initialization signal clear is asserted.
  • the initialization signal clear is asserted when the intermediate partial sum is not stored in the second memory 2 .
  • the second memory 2 stores the output data f(x, y, do).
  • a state controller 44 controls the states of the multiplier 42 and the accumulator circuit 43 . Also, the state controller 44 is connected to the controller 6 via an internal bus IB. The state controller 44 has an instruction queue 45 and a control circuit 46 .
  • the instruction queue 45 is a queue in which the instruction command C4 for the convolution operation circuit 4 is stored, and is composed of, for example, a FIFO memory. An instruction command C4 is written into the instruction queue 45 via the IFU 7 or via the internal bus IB.
  • the control circuit 46 is a state machine that decodes the instruction command C4 and controls the multiplier 42 and the accumulator circuit 43 based on the instruction command C4.
  • the control circuit 46 has the same configuration as the control circuit 34 of the state controller 32 of the first DMAC3.
  • FIG. 19 is an internal block diagram of the quantization arithmetic circuit 5.
  • the quantization arithmetic circuit 5 has a quantization parameter memory 51 , a vector arithmetic circuit 52 , a quantization circuit 53 and a state controller 54 .
  • the quantization operation circuit 5 has a dedicated state controller 54 for the vector operation circuit 52 and the quantization circuit 53, and when an instruction command is input, the quantization operation can be performed without requiring an external controller.
  • the quantization parameter memory 51 is a memory that stores the quantization parameter q used in the quantization calculation, and is a rewritable memory such as a volatile memory configured with SRAM (Static RAM), for example.
  • the first DMAC 3 writes the quantization parameter q required for the quantization calculation into the quantization parameter memory 51 by DMA transfer.
  • FIG. 20 is an internal block diagram of the vector operation circuit 52 and the quantization circuit 53. As shown in FIG. The vector computation circuit 52 computes the output data f(x, y, do) stored in the second memory 2 . The vector operation circuit 52 has Bd number of operation units 57 and performs SIMD operations on the output data f(x, y, do) in parallel.
  • FIG. 21 is a block diagram of the arithmetic unit 57.
  • the arithmetic unit 57 has, for example, an ALU 57a, a first selector 57b, a second selector 57c, a register 57d, and a shifter 57e.
  • the arithmetic unit 57 may further include other calculators and the like that a known general-purpose SIMD arithmetic circuit has.
  • the vector operation circuit 52 performs at least one of the operations of the pooling layer 221 in the quantization operation layer 220, the batch normalization layer 222, and the activation function layer 223 on the output data f(x, y, do) by combining the operation units of the operation unit 57.
  • the arithmetic unit 57 can add the data stored in the register 57d and the element f(di) of the output data f(x, y, do) read from the second memory 2 by the ALU 57a.
  • the arithmetic unit 57 can store the addition result by the ALU 57a in the register 57d.
  • the arithmetic unit 57 can initialize the addition result by inputting "0" to the ALU 57a instead of the data stored in the register 57d by selecting the first selector 57b. For example, when the pooling area is 2 ⁇ 2, the shifter 57e can output the average value of the addition result by shifting the output of the ALU 57a to the right by 2 bits.
  • the vector operation circuit 52 can perform the average pooling operation shown in Equation 2 by repeating the above operations and the like by the Bd number of operation units 57 .
  • the arithmetic unit 57 can compare the data stored in the register 57d with the element f(di) of the output data f(x, y, do) read from the second memory 2 by the ALU 57a.
  • the arithmetic unit 57 can control the second selector 57c according to the comparison result by the ALU 57a to select the larger one of the data stored in the register 57d and the element f(di).
  • the arithmetic unit 57 can initialize the comparison target to the minimum value by inputting the minimum value of the possible values of the element f(di) to the ALU 57a by selecting the first selector 57b.
  • the vector operation circuit 52 can implement the MAX pooling operation of Equation 3 by repeating the above operations and the like by the Bd number of operation units 57 . Note that the shifter 57e does not shift the output of the second selector 57c in the MAX pooling calculation.
  • the arithmetic unit 57 can subtract the data stored in the register 57d and the element f(di) of the output data f(x, y, do) read from the second memory 2 by the ALU 57a.
  • Shifter 57e can left shift (ie, multiply) or right shift (ie, divide) the output of ALU 57a.
  • the vector operation circuit 52 can perform the operation of Batch Normalization of Equation 4 by repeating the above operation and the like by the Bd number of operation units 57 .
  • the arithmetic unit 57 can use the ALU 57a to compare the element f(di) of the output data f(x, y, do) read from the second memory 2 and "0" selected by the first selector 57b.
  • the arithmetic unit 57 can select and output either the element f(di) or the constant value "0" previously stored in the register 57d according to the comparison result by the ALU 57a.
  • the vector operation circuit 52 can perform the ReLU operation of Equation 5 by repeating the above operations and the like by the Bd number of operation units 57 .
  • the vector operation circuit 52 can implement average pooling, MAX pooling, batch normalization, activation function operations, and combinations of these operations. Since vector arithmetic circuit 52 is capable of performing general-purpose SIMD operations, it may also perform other operations required for operations in quantization operations layer 220 . Also, the vector operation circuit 52 may perform operations other than the operations in the quantization operation layer 220 .
  • the quantization arithmetic circuit 5 does not have to have the vector arithmetic circuit 52 . If the quantization operation circuit 5 does not have the vector operation circuit 52 , the output data f(x, y, do) are input to the quantization circuit 53 .
  • the quantization circuit 53 quantizes the output data of the vector operation circuit 52 . As shown in FIG. 20, the quantization circuit 53 has Bd quantization units 58 and performs operations on the output data of the vector operation circuit 52 in parallel.
  • FIG. 22 is an internal block diagram of quantization unit 58.
  • a quantization unit 58 quantizes the element in(di) of the output data of the vector operation circuit 52 .
  • Quantization unit 58 comprises a comparator 58a and an encoder 58b.
  • the quantization unit 58 performs the operation (formula 6) of the quantization layer 224 in the quantization operation layer 220 on the output data (16 bits/element) of the vector operation circuit 52 .
  • the quantization unit 58 reads the necessary quantization parameters q (th0, th1, th2) from the quantization parameter memory 51, and the comparator 58a compares the input in(di) with the quantization parameter q.
  • Quantization unit 58 quantizes the result of comparison by comparator 58a to 2 bits/element by encoder 58b. Since ⁇ (c) and ⁇ (c) in Equation 4 are different parameters for each variable c, the quantization parameters q(th0, th1, th2) reflecting ⁇ (c) and ⁇ (c) are different parameters for each in(di).
  • the quantization unit 58 classifies the input in(di) into four regions (for example, in ⁇ th0, th0 ⁇ in ⁇ th1, th1 ⁇ in ⁇ th2, th2 ⁇ in) by comparing the input in(di) with three thresholds th0, th1, and th2, encodes the classification result into 2 bits, and outputs it.
  • the quantization unit 58 can also perform Batch Normalization and calculation of an activation function together with quantization by setting quantization parameters q (th0, th1, th2).
  • the quantization unit 58 performs quantization by setting the threshold th0 as ⁇ (c) in Equation 4 and the threshold difference (th1 ⁇ th0) and (th2 ⁇ th1) as ⁇ (c) in Equation 4, thereby performing the Batch Normalization operation shown in Equation 4 together with quantization.
  • ⁇ (c) can be reduced by increasing (th1-th0) and (th2-th1).
  • ⁇ (c) can be increased by decreasing (th1-th0) and (th2-th1).
  • Quantization unit 58 can implement an activation function in conjunction with quantization of input in(di). For example, quantization unit 58 saturates the output values in regions where in(di) ⁇ th0 and th2 ⁇ in(di). Quantization unit 58 may perform activation function computation in conjunction with quantization by setting the quantization parameter q such that the output is non-linear.
  • the state controller 54 controls the states of the vector operation circuit 52 and the quantization circuit 53. Also, the state controller 54 is connected to the controller 6 via an internal bus IB.
  • the state controller 54 has an instruction queue 55 and a control circuit 56 .
  • the instruction queue 55 is a queue in which the instruction command C5 for the quantization arithmetic circuit 5 is stored, and is composed of a FIFO memory, for example. An instruction command C5 is written into the instruction queue 55 via the IFU 7 or via the internal bus IB.
  • the control circuit 56 is a state machine that decodes the instruction command C5 and controls the vector operation circuit 52 and the quantization circuit 53 based on the instruction command C5.
  • the control circuit 56 has the same configuration as the control circuit 34 of the state controller 32 of the first DMAC3.
  • the quantization operation circuit 5 writes quantization operation output data having Bd elements to the first memory 1 .
  • Formula 10 shows a suitable relationship between Bd and Bc.
  • n is an integer.
  • the controller 6 transfers instruction commands transferred from the external host CPU 110 to the instruction queues of the first DMAC 3, the second DMAC 9, the convolution operation circuit 4 and the quantization operation circuit 5 via the internal bus IB.
  • the controller 6 may have an instruction memory that stores instruction commands for each circuit.
  • the controller 6 is connected to the external bus EB and operates as a slave of the external host CPU 110 .
  • the controller 6 has registers 61 including parameter registers and status registers.
  • a parameter register is a register that controls the operation of the NN circuit 100 .
  • the status register is a register that indicates the status of the NN circuit 100 including the semaphore S.
  • the semaphore S is decremented by the P operation and incremented by the V operation.
  • the P operation and V operation by the first DMAC 3, the convolution operation circuit 4 and the quantization operation circuit 5 update the semaphore S of the controller 6 via the internal bus IB.
  • FIG. 23A and 23B are diagrams for explaining control of the NN circuit 100 by the semaphore S.
  • FIG. A semaphore S is provided for each data flow F via the memories (first memory 1, second memory 2) in the NN circuit 100.
  • FIG. 23 and the following description semaphores related to data flow related to the second DMAC 9 are omitted for simplicity of description. Since the NN circuit 100 in this embodiment includes a plurality of NN operation cores 10, there are a plurality of data flows. Which data flow is used to perform operations on CNN 200 is controlled by the corresponding instruction command.
  • the semaphore S has a first semaphore S11, a second semaphore S12, a third semaphore S13, and a fourth semaphore S14 for the first NN operation core 10A.
  • the first semaphore S11 is used to control the first data flow F11 of the first NN operation core 10A.
  • the first data flow F11 is a data flow in which the first DMAC 3 (Producer) writes the input data a to the first memory 1 of the first NN operation core 10A, and the convolution operation circuit 4 (Consumer) of the first NN operation core 10A reads the input data a.
  • the first semaphore S11 has a first write semaphore S11W and a first read semaphore S11R.
  • the second semaphore S12 is used to control the second data flow F12 of the first NN operation core 10A.
  • the second data flow F12 is a data flow in which the convolution operation circuit 4 (Producer) of the first NN operation core 10A writes the output data f to the second memory 2 of the first NN operation core 10A, and the quantization operation circuit 5 (Consumer) of the first NN operation core 10A reads the output data f.
  • the second semaphore S12 has a second write semaphore S12W and a second read semaphore S12R.
  • the third semaphore S13 is used to control the third data flow F13 of the first NN arithmetic core 10A.
  • the third data flow F13 is a data flow in which the quantization operation circuit 5 (Producer) of the first NN operation core 10A writes the quantization operation output data to the first memory 1 of the first NN operation core 10A, and the convolution operation circuit 4 (Consumer) of the first NN operation core 10A reads the quantization operation output data.
  • the third semaphore S13 has a third write semaphore S13W and a third read semaphore S13R.
  • the fourth semaphore S14 is used to control the fourth data flow F14 of the first NN operation core 10A.
  • the fourth data flow F14 is a data flow in which the quantization operation circuit 5 (Producer) of the second NN operation core 10B writes the quantization operation output data to the first memory 1 of the first NN operation core 10A, and the convolution operation circuit 4 (Consumer) of the first NN operation core 10A reads out the quantization operation output data.
  • the fourth semaphore S14 has a fourth write semaphore S14W and a fourth read semaphore S14R.
  • the semaphore S has a first semaphore S21, a second semaphore S22, a third semaphore S23, and a fourth semaphore S24 for the second NN operation core 10B.
  • the first semaphore S21 is used to control the first data flow F21 of the second NN operation core 10B.
  • the first data flow F21 is a data flow in which the first DMAC 3 (Producer) writes the input data a to the first memory 1 of the second NN operation core 10B, and the convolution operation circuit 4 (Consumer) of the second NN operation core 10B reads the input data a.
  • the first semaphore S21 has a first write semaphore S21W and a first read semaphore S21R.
  • the second semaphore S22 is used to control the second data flow F22 of the second NN operation core 10B.
  • the second data flow F22 is a data flow in which the convolution operation circuit 4 (Producer) of the second NN operation core 10B writes the output data f to the second memory 2 of the second NN operation core 10B, and the quantization operation circuit 5 (Consumer) of the second NN operation core 10B reads the output data f.
  • the second semaphore S22 has a second write semaphore S22W and a second read semaphore S22R.
  • the third semaphore S23 is used to control the third data flow F23 of the second NN arithmetic core 10B.
  • the third data flow F23 is a data flow in which the quantization operation circuit 5 (Producer) of the second NN operation core 10B writes the quantization operation output data to the first memory 1 of the second NN operation core 10B, and the convolution operation circuit 4 (Consumer) of the second NN operation core 10B reads out the quantization operation output data.
  • the third semaphore S23 has a third write semaphore S23W and a third read semaphore S23R.
  • the fourth semaphore S24 is used to control the fourth data flow F24 of the second NN operation core 10B.
  • the fourth data flow F24 is a data flow in which the quantization operation circuit 5 (Producer) of the first NN operation core 10A writes the quantization operation output data to the first memory 1 of the second NN operation core 10B, and the convolution operation circuit 4 (Consumer) of the second NN operation core 10B reads the quantization operation output data.
  • the fourth semaphore S24 has a fourth write semaphore S24W and a fourth read semaphore S24R.
  • FIG. 24 is a timing chart of the first data flow F11.
  • the first write semaphore S11W is a semaphore that restricts writing to the first memory 1 of the first NN operation core 10A by the first DMAC 3 in the first data flow F11 of the first NN operation core 10A.
  • the first write semaphore S11W indicates the number of memory areas in the first memory 1 that can store data of a predetermined size, such as the input vector A, in which data has already been read and other data can be written.
  • the first write semaphore S11W is "0"
  • the first DMAC 3 cannot write to the first memory 1 in the first data flow F11, and has to wait until the first write semaphore S11W becomes "1" or more.
  • the first read semaphore S11R is a semaphore that restricts reading from the first memory 1 of the first NN operation core 10A by the convolution circuit 4 of the first NN operation core 10A in the first data flow F1 of the first NN operation core 10A.
  • the first read semaphore S11R indicates the number of memory areas in which data has been written and can be read out of the memory areas in which data of a predetermined size such as the input vector A can be stored in the first memory 1 .
  • the convolution circuit 4 cannot read from the first memory 1 in the first data flow F11, and is kept waiting until the first read semaphore S11R becomes "1" or more.
  • the first DMAC 3 starts DMA transfer when the instruction command C3 is stored in the instruction queue 33 . As shown in FIG. 24, since the first write semaphore S11W is not "0", the first DMAC 3 starts DMA transfer (DMA transfer 1). The first DMAC 3 performs a P operation on the first write semaphore S11W when starting DMA transfer. After completing the DMA transfer, the first DMAC 3 performs the V operation on the first read semaphore S11R.
  • the convolution operation circuit 4 of the first NN operation core 10A starts the convolution operation.
  • the convolution circuit 4 is kept waiting until the first read semaphore S11R becomes "1" or more (Wait in decode state ST2).
  • the convolution operation circuit 4 starts the convolution operation (convolution operation 1).
  • the convolution operation circuit 4 performs the P operation on the first read semaphore S11R.
  • the convolution operation circuit 4 performs the V operation on the first write semaphore S11W.
  • the first DMAC 3 starts the DMA transfer described as "DMA transfer 3" in FIG. 24, the first write semaphore S11W is "0", so the first DMAC 3 waits until the first write semaphore S11W becomes "1" or more (Wait in decode state ST2). When the first write semaphore S11W becomes "1" or more by V operation by the convolution operation circuit 4, the first DMAC 3 starts DMA transfer.
  • the first DMAC 3 and the convolution operation circuit 4 of the first NN operation core 10A can prevent access contention to the first memory 1 in the first data flow F11.
  • the first DMAC 3 and the convolution circuit 4 of the first NN operation core 10A can operate independently and in parallel while synchronizing the data transfer in the first data flow F11 of the first NN operation core 10A by using the first semaphore S11.
  • FIG. 25 is a timing chart of the second data flow F12.
  • the second write semaphore S12W is a semaphore that restricts writing to the second memory 2 of the first NN operation core 10A by the convolution circuit 4 of the first NN operation core 10A in the second data flow F12 of the first NN operation core 10A.
  • the second write semaphore S12W indicates the number of memory areas in which data has been read and other data can be written, among memory areas in which data of a predetermined size such as output data f can be stored in the second memory 2 .
  • the convolution circuit 4 cannot write to the second memory 2 in the second data flow F12, and is kept waiting until the second write semaphore S12W becomes "1" or more.
  • the second read semaphore S12R is a semaphore that restricts reading from the second memory 2 of the first NN operation core 10A by the quantization operation circuit 5 of the first NN operation core 10A in the second data flow F2 of the first NN operation core 10A.
  • the second read semaphore S12R indicates the number of memory areas in which data has been written and can be read out of memory areas in which data of a predetermined size, such as output data f, can be stored in the second memory 2 .
  • the quantization arithmetic circuit 5 cannot read from the second memory 2 in the second data flow F12, and is kept waiting until the second read semaphore S12R becomes "1" or more.
  • the convolution operation circuit 4 of the first NN operation core 10A performs the P operation on the second write semaphore S12W when starting the convolution operation. After completing the convolution operation, the convolution operation circuit 4 performs V operation on the second read semaphore S12R.
  • the quantization operation circuit 5 of the first NN operation core 10A starts the quantization operation when the instruction command C5 is stored in the instruction queue 55. As shown in FIG. 25, since the second read semaphore S12R is "0", the quantization arithmetic circuit 5 is kept waiting until the second read semaphore S12R becomes "1" or more (Wait in decode state ST2). When the second read semaphore S12R becomes "1" by V operation by the convolution operation circuit 4, the quantization operation circuit 5 starts the quantization operation (quantization operation 1). When starting the quantization operation, the quantization operation circuit 5 performs the P operation on the second read semaphore S12R. After completing the quantization operation, the quantization operation circuit 5 performs V operation on the second write semaphore S12W.
  • the quantization operation circuit 5 starts the quantization operation described as "quantization operation 2" in FIG. 25, since the second read semaphore S12R is "0", the quantization operation circuit 5 is kept waiting until the second read semaphore S12R becomes "1" or more (Wait in decode state ST2). When the second read semaphore S12R becomes "1" or more by V operation by the convolution operation circuit 4, the quantization operation circuit 5 starts the quantization operation.
  • the convolution operation circuit 4 of the first NN operation core 10A and the quantization operation circuit 5 of the first NN operation core 10A can prevent access conflicts for the second memory 2 in the second data flow F12 by using the second semaphore S12. Further, the convolution operation circuit 4 of the first NN operation core 10A and the quantization operation circuit 5 of the first NN operation core 10A can operate independently and in parallel while synchronizing data transfer in the second data flow F12 by using the second semaphore S12.
  • FIG. 26 is a timing chart of the third data flow F13.
  • the third write semaphore S13W is a semaphore that restricts writing to the first memory 1 of the first NN operation core 10A by the quantization operation circuit 5 of the first NN operation core 10A in the third data flow F13 of the first NN operation core 10A.
  • the third write semaphore S13W indicates the number of memory areas in the first memory 1 that can store data of a predetermined size, such as the quantization operation output data of the quantization operation circuit 5, to which data has already been read and other data can be written.
  • the quantization arithmetic circuit 5 cannot write to the first memory 1 in the third data flow F13, and is kept waiting until the third write semaphore S13W becomes "1" or more.
  • the third read semaphore S13R is a semaphore that restricts reading from the first memory 1 of the first NN operation core 10A by the convolution operation circuit 4 of the first NN operation core 10A in the third data flow F13 of the first NN operation core 10A.
  • the third read semaphore S13R indicates the number of memory areas in which data has been written and can be read out of memory areas in which data of a predetermined size, such as quantization operation output data of the quantization operation circuit 5, can be stored in the first memory 1.
  • the third read semaphore S13R is "0"
  • the convolution circuit 4 cannot read from the first memory 1 in the third data flow F13, and is kept waiting until the third read semaphore S13R becomes "1" or more.
  • the quantization operation circuit 5 of the first NN operation core 10A performs the P operation on the third write semaphore S13W when starting the quantization operation. After completing the convolution operation, the quantization operation circuit 5 performs V operation on the third read semaphore S13R.
  • the convolution operation circuit 4 of the first NN operation core 10A starts the convolution operation.
  • the convolution operation circuit 4 is kept waiting until the third read semaphore S13R becomes "1" or more (Wait in decode state ST2).
  • the convolution operation circuit 4 starts the convolution operation (convolution operation 5).
  • the convolution operation circuit 4 performs the P operation on the third read semaphore S13R.
  • the convolution operation circuit 4 performs the V operation on the third write semaphore S13W.
  • the convolution operation circuit 4 starts the convolution operation described as "convolution operation 7" in FIG. 26, since the third read semaphore S13R is "0", the convolution operation circuit 4 waits until the third read semaphore S13R becomes "1" or more (Wait in decode state ST2). When the third read semaphore S13R becomes "1" or more by V operation by the quantization operation circuit 5, the convolution operation circuit 4 starts the convolution operation.
  • the quantization operation circuit 5 of the first NN operation core 10A and the convolution operation circuit 4 of the first NN operation core 10A can prevent access contention to the first memory 1 in the third data flow F13. Also, the quantization operation circuit 5 of the first NN operation core 10A and the convolution operation circuit 4 of the first NN operation core 10A can operate independently and in parallel while synchronizing the data transfer in the third data flow F13 by using the third semaphore S13.
  • FIG. 27 is a timing chart of the fourth data flow F14.
  • the fourth write semaphore S14W is a semaphore that restricts writing to the first memory 1 of the first NN operation core 10A by the quantization operation circuit 5 of the second NN operation core 10B in the fourth data flow F14 of the first NN operation core 10A.
  • the fourth write semaphore S14W indicates the number of memory areas in the first memory 1 that can store data of a predetermined size, such as the quantization operation output data of the quantization operation circuit 5, in which data has already been read and other data can be written.
  • the quantization arithmetic circuit 5 cannot write to the first memory 1 in the fourth data flow F14, and is kept waiting until the fourth write semaphore S14W becomes "1" or more.
  • the fourth read semaphore S14R is a semaphore that restricts reading from the first memory 1 of the first NN operation core 10A by the convolution operation circuit 4 of the first NN operation core 10A in the fourth data flow F14 of the first NN operation core 10A.
  • the fourth read semaphore S14R indicates the number of memory areas in which data has been written and can be read out of memory areas in which data of a predetermined size, such as quantization operation output data of the quantization operation circuit 5, can be stored in the first memory 1.
  • the fourth read semaphore S14R is "0"
  • the convolution circuit 4 cannot read from the first memory 1 in the fourth data flow F14, and is kept waiting until the fourth read semaphore S14R becomes "1" or more.
  • the quantization operation circuit 5 of the second NN operation core 10B performs the P operation on the fourth write semaphore S14W when starting the quantization operation. After completing the convolution operation, the quantization operation circuit 5 performs V operation on the fourth read semaphore S14R.
  • the convolution operation circuit 4 of the first NN operation core 10A starts the convolution operation.
  • the convolution circuit 4 is kept waiting until the fourth read semaphore S14R becomes "1" or more (Wait in decode state ST2).
  • the convolution operation circuit 4 starts the convolution operation (convolution operation 9).
  • the convolution operation circuit 4 performs the P operation on the fourth read semaphore S14R.
  • the convolution operation circuit 4 performs the V operation on the fourth write semaphore S14W.
  • the convolution operation circuit 4 starts the convolution operation described as "convolution operation 10" in FIG. 27, the fourth read semaphore S14R is "0", so the convolution operation circuit 4 waits until the fourth read semaphore S14R becomes "1" or more (Wait in decode state ST2). When the fourth read semaphore S14R becomes "1" or more by V operation by the quantization operation circuit 5, the convolution operation circuit 4 starts the convolution operation.
  • the quantization operation circuit 5 of the second NN operation core 10B and the convolution operation circuit 4 of the first NN operation core 10A can prevent access conflicts for the first memory 1 in the fourth data flow F14 by using the fourth semaphore S14. Further, the quantization operation circuit 5 of the second NN operation core 10B and the convolution operation circuit 4 of the first NN operation core 10A can operate independently and in parallel while synchronizing the data transfer between the plurality of NN operation cores 10 in the fourth data flow F14 by using the fourth semaphore S14.
  • the first memory 1 of the first NN operation core 10A is shared by three data flows (first data flow F11, third data flow F13 and fourth data flow F14).
  • first data flow F11 third data flow F13
  • fourth data flow F14 fourth data flow F14
  • the first data flow F21 of the second NN operation core 10B is equivalent to the first data flow F11 of the first NN operation core 10A.
  • the first DMAC 3 and the convolution operation circuit 4 of the second NN operation core 10B can prevent access contention to the first memory 1 in the first data flow F21 by using the first semaphore S21.
  • the first DMAC 3 and the convolution operation circuit 4 of the second NN operation core 10B can operate independently and in parallel while synchronizing the data transfer in the first data flow F21 of the second NN operation core 10B by using the first semaphore S21.
  • the second data flow F22 of the second NN operation core 10B is equivalent to the second data flow F12 of the first NN operation core 10A.
  • the convolution operation circuit 4 of the second NN operation core 10B and the quantization operation circuit 5 of the second NN operation core 10B can prevent access conflicts with respect to the second memory 2 in the second data flow F22 by using the second semaphore S22.
  • the convolution operation circuit 4 of the second NN operation core 10B and the quantization operation circuit 5 of the second NN operation core 10B can operate independently and in parallel while synchronizing data transfer in the second data flow F22 by using the second semaphore S22.
  • the third data flow F23 of the second NN operation core 10B is equivalent to the third data flow F13 of the first NN operation core 10A.
  • the quantization operation circuit 5 of the second NN operation core 10B and the convolution operation circuit 4 of the second NN operation core 10B can prevent access conflicts with respect to the first memory 1 in the third data flow F23 by using the third semaphore S23. Further, the quantization operation circuit 5 of the second NN operation core 10B and the convolution operation circuit 4 of the second NN operation core 10B can operate independently and in parallel while synchronizing data transfer in the third data flow F23 by using the third semaphore S23.
  • the fourth data flow F24 of the second NN operation core 10B is equivalent to the fourth data flow F14 of the first NN operation core 10A.
  • the quantization operation circuit 5 of the first NN operation core 10A and the convolution operation circuit 4 of the second NN operation core 10B can prevent access conflicts for the first memory 1 in the fourth data flow F24 by using the fourth semaphore S24. Further, the quantization operation circuit 5 of the first NN operation core 10A and the convolution operation circuit 4 of the second NN operation core 10B can operate independently and in parallel while synchronizing the data transfer between the plurality of NN operation cores 10 in the fourth data flow F24 by using the fourth semaphore S24.
  • the convolution operation circuit 4 of the first NN operation core 10A performs the convolution operation, it reads from the first memory 1 of the first NN operation core 10A and writes to the second memory 2 of the first NN operation core 10A. That is, the convolution operation circuit 4 is the Consumer in the three data flows (the first data flow F11, the third data flow F13, and the fourth data flow F14) and the Producer in the second data flow F12.
  • the convolution operation circuit 4 when starting the convolution operation, performs the P operation on the read semaphore (first read semaphore S11R, third read semaphore S13R, or fourth read semaphore S14R) corresponding to the data flow (see FIGS. 24, 26, and 27), and performs the P operation on the second write semaphore S12W (see FIG. 24).
  • the convolution operation circuit 4 After completing the convolution operation, the convolution operation circuit 4 performs V operation on the write semaphore corresponding to the data flow (first write semaphore S11W, third write semaphore S13W, fourth write semaphore S14W) (see FIGS. 24, 26, and 27), and performs V operation on the second read semaphore S12R (see FIG. 25).
  • the convolution operation circuit 4 of the first NN operation core 10A waits until the read semaphore (first read semaphore S11R, third read semaphore S13R, or fourth read semaphore S14R) corresponding to the data flow becomes "1" or more and the second write semaphore S12W becomes “1" or more (Wait in decode state ST2).
  • the quantization operation circuit 5 of the first NN operation core 10A reads from the second memory 2 of the first NN operation core 10A and writes to the first memory 1 of the first NN operation core 10A or the first memory 1 of the second NN operation core 10B. That is, the quantization arithmetic circuit 5 is the Consumer in the second data flow F12 and the Producer in the two data flows (the third data flow F13 and the fourth data flow F24). Therefore, when starting the quantization operation, the quantization operation circuit 5 performs the P operation on the second read semaphore S12R (see FIG.
  • the quantization operation circuit 5 performs V operation on the second write semaphore S12W (see FIG. 25), and performs V operation on the read semaphore (third read semaphore S13R or fourth read semaphore S24R) corresponding to the data flow (see FIG. 26).
  • the quantization operation circuit 5 of the first NN operation core 10A waits until the second read semaphore S12R becomes “1" or more and the write semaphore (third write semaphore S13W or fourth write semaphore S24W) corresponding to the data flow becomes "1" or more (Wait in decode state ST2).
  • the quantization operation circuit 5 of the first NN operation core 10A can switch between the third data flow F13 and the fourth data flow F24 to change the first memory 1 that stores the quantization operation output data.
  • the quantization operation circuit 5 of the second NN operation core 10B can switch between the third data flow F23 and the fourth data flow F14 to change the first memory 1 storing the quantization operation output data.
  • the NN circuit 100 that can be embedded in embedded equipment such as IoT equipment can be operated with high performance.
  • IoT equipment such as IoT equipment
  • a second embodiment of the present invention will be described with reference to FIGS. 28 to 31.
  • FIG. In the following description, the same reference numerals are given to the same configurations as those already described, and redundant descriptions will be omitted.
  • a neural network circuit 100B (hereinafter referred to as “NN circuit 100B”) according to the second embodiment differs from the neural network circuit 100 according to the first embodiment in the convolution operation circuit 4 .
  • the NN circuit 100B includes a first DMAC 3, a controller 6, an IFU 7, a shared memory 8, a second DMAC 9, and at least one neural network operation core 10E (hereinafter also referred to as "NN operation core 10E").
  • the NN operation core 10E includes a first memory 1, a second memory 2, a convolution operation circuit 4B, and a quantization operation circuit 5.
  • the convolution operation circuit 4B is a circuit that performs a convolution operation in the convolution layer 210 of the trained CNN 200.
  • the convolution operation circuit 4B reads the input data a stored in the first memory 1 and performs a convolution operation on the input data a.
  • the convolution operation circuit 4B writes the convolution operation output data to the second memory 2.
  • FIG. 28 is an internal block diagram of the convolution operation circuit 4B.
  • the convolution circuit 4B has a weight memory 41, a multiplier 42B, an accumulator circuit 43, and a state controller 44.
  • FIG. 29 is an internal block diagram of the multiplier 42.
  • a multiplier (arithmetic unit array) 42B multiplies each element a(x+i, y+j, ci) of the divided input data a(x+i, y+j, co) and each element w(i, j, ci, di) of the divided weight w(i, j, co, do).
  • the multiplier 42 has a Bc ⁇ Bd sum-of-products operation unit array 42A, and can perform parallel multiplication of the element a(x+i, y+j, ci) of the divided input data a(x+i, y+j, co) and the element w(i, j, ci, di) of the divided weight w(i, j, co, do).
  • the multiplier (arithmetic unit array) 42B reads out the elements a and w necessary for multiplication from the first memory 1 and the weight memory 41 and performs multiplication.
  • the multiplier 42 outputs Bd sum-of-products operation results O(x+i, y+j, di).
  • the number of product-sum operation unit arrays 42A included in the multiplier 42 is not limited to Bc ⁇ Bd.
  • the number of sum-of-products operation unit arrays 42A may be (Bc/P) ⁇ Bd (P is Bc or a divisor of Bc).
  • the sum-of-products operation unit array 42A divides the divided input data a(x+i, y+j, co) into P pieces in the c-axis direction.
  • the multiplier (arithmetic unit array) 42B reads the element a (x+i, y+j, ci), the element a (x+i, y+y1+j, ci), and the element a (x+i, y+y2+j, ci) from the first memory 1 (0 ⁇ y1 ⁇ y2).
  • the three sets of elements a are line data separated by a predetermined number of lines ST in the y-axis direction (ST is the stride in the y-axis direction).
  • the multiplier (arithmetic unit array) 42B may have a line memory that stores the element a.
  • the first memory 1 is preferably a multi-bank memory.
  • elements a(x+i, y+j, ci), elements a(x+i, y+y1+j, ci), and elements a(x+i, y+y2+j, ci) are stored in different banks, and each element is read independently at high speed.
  • FIG. 30 is an internal block diagram of the sum-of-products operation unit array 42A.
  • the sum-of-products operation unit array 42A multiplies the element a and the element w.
  • the sum-of-products operation unit array 42A has three sum-of-products operation units 47B.
  • the three sum-of-products operation units 47B are referred to as a first sum-of-products operation unit 471, a second sum-of-products operation unit 472, and a third sum-of-products operation unit 473.
  • FIG. 31 is an internal block diagram of the sum-of-products operation unit 47B.
  • the sum-of-products operation unit 47B multiplies the element A(ci) of the input vector A by the element W(ci, di) of the weight matrix W.
  • FIG. The sum-of-products operation unit 47 outputs the multiplication result s(ci).
  • Element A(ci) is a 2-bit unsigned integer (0, 1, 2, 3).
  • the element W(ci,di) is a 1-bit signed integer (0,1), where the value "0" represents +1 and the value "1" represents -1.
  • the sum-of-products operation unit 47B has an inverter (inverter) 47a, a selector 47b, and an adder 47c.
  • the sum-of-products operation unit 47 performs multiplication using only the inverter 47a and the selector 47b without using a multiplier.
  • the selector 47b selects the input of the element A(ci) when the element W(ci, di) is "0". When the element W(ci, di) is "1", the selector 47b selects the complement of the element A(ci) inverted by the inverter. Element W(ci, di) is also input to Carry-in of adder 47c.
  • the adder 47c outputs a value obtained by adding the element A(ci) to m(ci, di) when the element W(ci, di) is "0".
  • the adder 47c outputs a value obtained by subtracting the element A(ci) from m(ci, di) when W(ci, di) is "1".
  • the first sum-of-products operation unit 471 multiplies the element a (X, Y, ci) and the element w (i, j, ci, di) (X is an arbitrary x-coordinate included in the input data a, Y is an arbitrary y-coordinate included in the input data a).
  • the first sum-of-products operation unit 471 outputs the output m(i, j, ci, di) to the adder 47A.
  • the second sum-of-products operation unit 472 multiplies the element a (X, Y+y1, ci) and the element w (i, j+1, ci, di).
  • the second sum-of-products operation unit 472 outputs the output m(i, j+1, ci, di) to the adder 47A.
  • the third sum-of-products operation unit 473 multiplies the element a (X, Y+y2, ci) and the element w (i, j+2, ci, di).
  • the third sum-of-products operation unit 473 outputs the output m(i, j+2, ci, di) to the adder 47A.
  • the adder 47A adds the output m (i, j, ci, di), the output m (i, j+1, ci, di), the output m (i, j+2, ci, di), and the multiplication result S (x+i, y+j, ci, di) of the other product-sum operation unit 47B, and outputs the addition result S (x+i, y+j, ci+1, di).
  • operations can be parallelized by the sum-of-products operation unit array 42A, and convolution operations can be speeded up.
  • the neural network circuit 100B can suitably perform the convolution operation even if the stride ST in the y-axis direction in the convolution operation is 2 or more.
  • a third embodiment of the present invention will be described with reference to FIGS. 32 to 36.
  • FIG. In the following description, the same reference numerals are given to the same configurations as those already described, and redundant descriptions will be omitted.
  • a neural network circuit 100G (hereinafter referred to as "NN circuit 100G") according to the third embodiment further has a clock gating function and a power gating function compared to the neural network circuit 100 according to the first embodiment.
  • FIG. 32 is a diagram showing the overall configuration of the NN circuit 100G according to this embodiment.
  • the NN circuit 100G includes a first DMAC 3G, a controller 6, an IFU 7, a shared memory 8, a second DMAC 9, and at least one neural network operation core 10G (hereinafter also referred to as "NN operation core 10G"). Note that the NN circuit 100G may not have the shared memory 8 and the second DMAC 9.
  • FIG. 10G is a diagram showing the overall configuration of the NN circuit 100G according to this embodiment.
  • the NN circuit 100G includes a first DMAC 3G, a controller 6, an IFU 7, a shared memory 8, a second DMAC 9, and at least one neural network operation core 10G (hereinafter also referred to as "NN operation core 10G"). Note that the NN circuit 100G may not have the shared memory 8 and the second DMAC 9.
  • FIG. 10G neural network operation core 10G
  • the NN circuit 100G can implement a plurality of NN operation cores 10G.
  • the NN circuit 100G illustrated in FIG. 32 can implement up to four NN operation cores 10G.
  • a plurality of NN operation cores 10G constitute an "NN operation multi-core 10M" that cooperates to execute at least part of operations of the NN 200, like the NN operation cores 10 of the first embodiment.
  • a plurality of NN operation cores 10G are daisy-chained as in the first embodiment. Note that the number of NN operation cores 10 that can be implemented in the NN circuit 100G is not limited to four.
  • FIG. 33 is an internal block diagram of the first DMAC3G.
  • the first DMAC 3G like the first DMAC 3 of the first embodiment, is connected to the external bus EB and performs data transfer between the external memory 120 such as DRAM and the NN operation core 10G.
  • the first DMAC 3G has a data transfer circuit 31, a state controller 32, and a clock control section 39.
  • FIG. 34 is a timing chart showing the operation of the clock control section 39.
  • the clock control unit 39 generates a gated clock (third clock) GC3 from the clock CK supplied to the NN circuit 100G based on the clock enable signal CE3.
  • the clock enable signal CE3 is negated and set to disabled (Low in FIG. 34)
  • the toggling of the gated clock GC3 is stopped.
  • the clock enable signal CE3 is asserted and set to Enable (High in FIG. 34)
  • the gated clock GC3 starts toggling.
  • a circuit for generating the gated clock GC3 is a circuit appropriately selected from known clock gating circuits.
  • the clock enable signal CE3 is controlled by the state controller 32.
  • the control circuit 34 of the state controller 32 determines in the decode state ST2 that the operation of the data transfer circuit 31 instructed by the instruction command C3 cannot be executed, it waits until it becomes executable (Wait).
  • the control circuit 34 negates the clock enable signal CE3 to disable it during the waiting period until the above operation becomes executable. As a result, the toggling of the gated clock GC3 is stopped.
  • the control circuit 34 of the state controller 32 asserts and enables the clock enable signal CE3 when the above operation becomes executable and the decode state ST2 transitions to the execution state ST3. As a result, when the control circuit 34 is in the run state ST3, the toggling of the gated clock GC3 is resumed.
  • the generated gated clock GC3 is output to part of the state controller 32 and the data transfer circuit 31, as shown in FIG. 33, and used as an operating clock.
  • the clock control unit 39 may negate the clock enable signal CE3 to disable it in the idle state ST1. Furthermore, in the idle state ST1, the control circuit 34 may stop power supply (power gating) to the circuit to which the gated clock GC3 is supplied, and transition to the power saving mode.
  • the NN operation core 10G includes a first memory 1, a second memory 2, a convolution operation circuit 4G, and a quantization operation circuit 5G.
  • FIG. 35 is an internal block diagram of the convolution operation circuit 4G.
  • the convolution circuit 4G has a weight memory 41, a multiplier 42, an accumulator circuit 43, a state controller 44, and a clock control section 49.
  • the clock control unit 49 generates a gated clock (first clock) GC4 from the clock CK supplied to the NN circuit 100G based on the clock enable signal CE4. As shown in FIG. 34, when the clock enable signal CE4 is negated and set to disabled, the toggling of the gated clock GC4 is stopped. When the clock enable signal CE4 is asserted and set to enable, the gated clock GC4 starts toggling.
  • the clock control unit 49 has the same configuration as the clock control unit 39 of the first DMAC 3G.
  • the clock enable signal CE4 is controlled by the state controller 44.
  • the control circuit 46 of the state controller 44 determines in the decode state ST2 that the operation of the multiplier 42, the accumulator circuit 43, etc. indicated by the instruction command C4 cannot be executed, it waits until it becomes executable (Wait).
  • the control circuit 46 negates the clock enable signal CE4 to disable it during the period of waiting until the above operation becomes executable. As a result, the toggling of the gated clock GC4 is stopped.
  • the control circuit 46 of the state controller 44 asserts and enables the clock enable signal CE4 when the above operation becomes executable and the decode state ST2 transitions to the execution state ST3. As a result, when the control circuit 46 is in the run state ST3, the toggling of the gated clock GC4 is resumed.
  • the generated gated clock GC4 is output to part of the state controller 44, the weight memory 41, the multiplier 42, and the accumulator circuit 43, as shown in FIG. 35, and used as an operation clock.
  • the clock control unit 49 may negate the clock enable signal CE4 to disable it in the idle state ST1. Furthermore, in the idle state ST1, the control circuit 46 may stop power supply (power gating) to the circuit to which the gated clock GC4 is supplied, and transition to the power saving mode.
  • FIG. 36 is an internal block diagram of the quantization arithmetic circuit 5G.
  • the quantization operation circuit 5G has a quantization parameter memory 51, a vector operation circuit 52, a quantization circuit 53, a state controller 54, and a clock control section 59.
  • the clock control unit 59 generates a gated clock (third clock) GC5 from the clock CK supplied to the NN circuit 100G based on the clock enable signal CE5. As shown in FIG. 34, when the clock enable signal CE5 is negated and set to disabled, the toggling of the gated clock GC5 is stopped. When the clock enable signal CE5 is asserted and set to enable, the gated clock GC5 starts toggling.
  • the clock control section 59 has the same configuration as the clock control section 39 of the first DMAC 3G.
  • the clock enable signal CE5 is controlled by the state controller 54.
  • the control circuit 56 of the state controller 54 determines in the decode state ST2 that the operation of the vector operation circuit 52, the quantization circuit 53, etc., instructed by the instruction command C5 is not executable, it waits until it becomes executable (Wait).
  • the control circuit 56 negates the clock enable signal CE5 to disable it during the period of waiting until the above operation becomes executable.
  • the toggling of the gated clock GC5 is stopped.
  • the control circuit 56 of the state controller 54 asserts and enables the clock enable signal CE5 when the above operation becomes executable and the decode state ST2 transitions to the execution state ST3.
  • the control circuit 56 is in the run state ST3, the toggling of the gated clock GC5 is resumed.
  • the generated gated clock GC5 is output to part of the state controller 54, the quantization parameter memory 51, the vector operation circuit 52, and the quantization circuit 53, as shown in FIG. 36, and used as an operation clock.
  • the clock control unit 59 may negate the clock enable signal CE5 to disable it in the idle state ST1. Furthermore, in the idle state ST1, the control circuit 56 may stop supplying power (power gating) to the circuit to which the gated clock GC5 is supplied, and transition to the power saving mode.
  • power consumption can be reduced by clock gating and power gating.
  • the first DMAC 3G, the convolution operation circuit 4G, and the quantization operation circuit 5G independently perform clock gating and power gating.
  • a fourth embodiment of the present invention will be described with reference to FIG. In the following description, the same reference numerals are given to the same configurations as those already described, and redundant descriptions will be omitted.
  • a neural network circuit 100H (hereinafter referred to as "NN circuit 100H") according to the fourth embodiment further includes a multi-core manager 11 compared to the neural network circuit 100 according to the first embodiment.
  • FIG. 37 is a diagram showing the overall configuration of the NN circuit 100H according to this embodiment.
  • the NN circuit 100 ⁇ /b>H includes a first DMAC 3 , a controller 6 , an IFU 7 , a shared memory 8 , a second DMAC 9 , at least one NN operation core 10 and a multicore manager 11 .
  • the multi-core management unit 11 monitors the state of the NN calculation multi-core 10M and manages the clock and power supplied to the NN calculation core 10.
  • the clock and power are supplied to the operating NN operation cores 10 of the NN operation multi-core 10M, and the clock and power are not supplied to at least some of the NN operation cores 10 that are not operating. That is, the multi-core management unit 11 performs at least one of clock gating and power gating for each NN operation core 10 according to the operation status of the NN operation core 10 .
  • the NN circuit 100H can improve the arithmetic performance by mounting a plurality of the NN arithmetic cores 10, and can suitably suppress an increase in power consumption accompanying an increase in circuit scale.
  • the multi-core management unit 11 may be able to forcibly select an operable NN operation core 10. For example, the multi-core management unit 11 sets some NN operation cores 10 to be operable and other NN operation cores 10 to be inoperable. The multi-core management unit 11 stops providing clocks and power to the NN operation cores 10 set to be inoperable. By limiting the NN operation cores 10 that can operate, the multi-core management unit 11 can reduce the power consumption although the operation performance is degraded. In addition, the multi-core management unit 11 sets all the NN operation cores 10 to be operable, thereby improving the operation performance although the power consumption is increased.
  • power consumption can be reduced by clock gating and power gating.
  • the multi-core management unit 11 independently performs clock gating and power gating for each NN operation core 10 .
  • the NN circuit 100H may also perform the clock gating and power gating performed by the first DMAC 3G, the convolution operation circuit 4G and the quantization operation circuit 5G in the third embodiment.
  • the plurality of NN operation cores 10 are daisy-chained, but the manner of connection of the plurality of NN operation cores 10 is not limited to this.
  • the NN operation core 10 may be connected to at least one other NN operation core 10 so that data can be input/output.
  • the NN circuit 100 is controlled using a semaphore S provided for each data flow even when the connection modes of the plurality of NN operation cores 10 are different.
  • the first memory 1 and the second memory 2 are different memories, but the aspect of the first memory 1 and the second memory 2 is not limited to this.
  • the first memory 1 and the second memory 2 may be, for example, a first memory area and a second memory area in the same memory.
  • the semaphore S is provided for the first data flow (F11, F21), the second data flow (F12, F22), the third data flow (F13, F23), and the fourth data flow (F14, F24), but the aspect of the semaphore S is not limited to this.
  • the semaphore S may, for example, be provided in a data flow in which the first DMAC 3 writes the weight w to the weight memory 41 and the multiplier 42 reads the weight w.
  • the semaphore S may be provided, for example, in a data flow in which the first DMAC 3 writes the quantization parameter q to the quantization parameter memory 51 and the quantization circuit 53 reads the quantization parameter q.
  • the data input to the NN circuit 100 described in the above embodiments is not limited to a single format, and can consist of still images, moving images, voices, characters, numerical values, and combinations thereof.
  • the data input to the NN circuit 100 is not limited to the measurement results of a physical quantity measuring instrument such as an optical sensor, a thermometer, a Global Positioning System (GPS) measuring instrument, an angular velocity measuring instrument, and an anemometer that can be mounted on an edge device provided with the NN circuit 100.
  • Peripheral information such as base station information, vehicle/vessel information, weather information, and congestion information received from peripheral devices via wired or wireless communication, and different information such as financial information and personal information may be combined.
  • Edge devices provided with the NN circuit 100 are assumed to be communication devices such as mobile phones driven by batteries, smart devices such as personal computers, mobile devices such as digital cameras, game devices, and robot products, but are not limited to these. Unprecedented effects can also be obtained by using power on Ethernet (PoE), etc., to limit the peak power that can be supplied, reduce product heat generation, or use it for products that require long-time operation. For example, by applying it to in-vehicle cameras installed in vehicles and ships, surveillance cameras installed in public facilities and roads, etc., it is possible not only to realize long-time shooting, but also to contribute to weight reduction and durability. Similar effects can be obtained by applying the present invention to display devices such as televisions and displays, medical equipment such as medical cameras and surgical robots, and work robots used at manufacturing sites and construction sites.
  • PoE power on Ethernet
  • NN circuit 100 may implement part or all of NN circuit 100 using one or more processors.
  • the NN circuit 100 may implement part or all of the input layer or the output layer by software processing by a processor.
  • a part of the input layer or output layer realized by software processing is, for example, data normalization and transformation. This allows for various input or output formats.
  • the software executed by the processor may be rewritable using communication means or external media.
  • the NN circuit 100 may implement part of the processing in the CNN 200 by combining a graphics processing unit (GPU) on the cloud.
  • the NN circuit 100 performs further processing on the cloud in addition to the processing performed by the edge device provided with the NN circuit 100, or performs processing on the edge device in addition to the processing on the cloud, thereby realizing more complicated processing with less resources.
  • the NN circuit 100 can reduce the amount of communication between the edge device and the cloud due to processing distribution.
  • the present invention can be applied to neural network operations.

Landscapes

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

Abstract

ニューラルネットワーク回路は、畳み込み演算を行う畳み込み演算回路と、量子化演算を行う量子化演算回路と、を有するニューラルネットワーク演算コアを複数有し、前記複数のニューラルネットワーク演算コアは、データ入出力可能に接続されている。

Description

ニューラルネットワーク回路およびニューラルネットワーク演算方法
 本発明は、ニューラルネットワーク回路およびニューラルネットワーク演算方法に関する。本願は、2022年01月24日に、日本国に出願された特願2022-008692号に基づき優先権を主張し、その内容をここに援用する。
 近年、畳み込みニューラルネットワーク(Convolutional Neural Network:CNN)が画像認識等のモデルとして用いられている。畳み込みニューラルネットワークは、畳み込み層やプーリング層を有する多層構造であり、畳み込み演算等の多数の演算を必要とする。畳み込みニューラルネットワークによる演算を高速化する演算手法が様々考案されている(特許文献1など)。
特開2018-077829号公報
 一方で、IoT機器などの組み込み機器においても畳み込みニューラルネットワークを利用した画像認識等を実現することが望まれている。組み込み機器においては、特許文献1等に記載された大規模な専用回路を組み込むことは難しい。また、CPUやメモリ等のハードウェアリソースが限られた組み込み機器においては、畳み込みニューラルネットワークの十分な演算性能をソフトウェアのみにより実現することは難しい。
 上記事情を踏まえ、本発明は、IoT機器などの組み込み機器に組み込み可能かつ高性能なニューラルネットワーク回路およびニューラルネットワーク演算方法を提供することを目的とする。
 上記課題を解決するために、この発明は以下の手段を提案している。
 本発明の第一の態様に係るニューラルネットワーク回路は、畳み込み演算を行う畳み込み演算回路と、量子化演算を行う量子化演算回路と、を有するニューラルネットワーク演算コアを複数有し、前記複数のニューラルネットワーク演算コアは、データ入出力可能に接続されている。
 本発明の第二の態様に係るニューラルネットワーク演算方法は、第一ニューラルネットワーク演算コアと第二ニューラルネットワーク演算コアを用いるニューラルネットワーク演算方法であって、前記第一ニューラルネットワーク演算コアの出力データを、前記第一ニューラルネットワークにループバックさせるループバックデータフローと、第二ニューラルネットワーク演算コアにバイパスさせるバイパスデータデータフローと、を切り替える。
 本発明のニューラルネットワーク回路およびニューラルネットワーク演算方法は、IoT機器などの組み込み機器に組み込み可能かつ高性能である。
畳み込みニューラルネットワークを示す図である。 畳み込み層が行う畳み込み演算を説明する図である。 畳み込み演算のデータの展開を説明する図である。 第一実施形態に係るニューラルネットワーク回路の全体構成を示す図である。 NN演算コアの全体構成を示す図である。 同NN演算コアの動作例を示すタイミングチャートである。 同NN演算コアの他の動作例を示すタイミングチャートである。 NN演算マルチコアを示す図である。 同NN演算マルチコアの動作例を示すタイミングチャートである。 同NN演算マルチコアの他の動作例を示すタイミングチャートである。 同NN演算マルチコアの他の動作例を示すタイミングチャートである。 同ニューラルネットワーク回路のDMACの内部ブロック図である。 同DMACの制御回路のステート遷移図である。 同ニューラルネットワーク回路の畳み込み演算回路の内部ブロック図である。 同畳み込み演算回路の乗算器の内部ブロック図である。 同乗算器の積和演算ユニットの内部ブロック図である。 同畳み込み演算回路のアキュムレータ回路の内部ブロック図である。 同アキュムレータ回路のアキュムレータユニットの内部ブロック図である。 同ニューラルネットワーク回路の量子化演算回路の内部ブロック図である。 同量子化演算回路のベクトル演算回路と量子化回路の内部ブロック図である。 演算ユニットのブロック図である。 同量子化回路のベクトル量子化ユニットの内部ブロック図である。 セマフォによる同ニューラルネットワーク回路の制御を説明する図である。 第一データフローのタイミングチャートである。 第二データフローのタイミングチャートである。 第一データフローのタイミングチャートである。 第二データフローのタイミングチャートである。 第二実施形態に係るニューラルネットワーク回路の畳み込み演算回路の内部ブロック図である。 同畳み込み演算回路の乗算器の内部ブロック図である。 同乗算器の積和演算ユニットアレイの内部ブロック図である。 同積和演算ユニットアレイの積和演算ユニットの内部ブロック図である。 第三実施形態に係るニューラルネットワーク回路の全体構成を示す図である。 同ニューラルネットワーク回路の第一DMACの内部ブロック図である。 同第一DMACなどのクロック制御部の動作を示すタイミングチャートである。 同ニューラルネットワーク回路の畳み込み演算回路の内部ブロック図である。 同ニューラルネットワーク回路の量子化演算回路の内部ブロック図である。 第四実施形態に係るニューラルネットワーク回路の全体構成を示す図である。
(第一実施形態)
 本発明の第一実施形態について、図1から図27を参照して説明する。
 図1は、畳み込みニューラルネットワーク200(以下、「CNN200」という)を示す図である。第一実施形態に係るニューラルネットワーク回路100(以下、「NN回路100」という)が行う演算は、推論時に使用する学習済みのCNN200の少なくとも一部である。
[CNN200]
 CNN200は、畳み込み演算を行う畳み込み層210と、量子化演算を行う量子化演算層220と、出力層230と、を含む多層構造のネットワークである。CNN200の少なくとも一部において、畳み込み層210と量子化演算層220とが交互に連結されている。CNN200は、画像認識や動画認識に広く使われるモデルである。CNN200は、全結合層などの他の機能を有する層(レイヤ)をさらに有してもよい。
 図2は、畳み込み層210が行う畳み込み演算を説明する図である。
 畳み込み層210は、入力データaに対して重みwを用いた畳み込み演算を行う。畳み込み層210は、入力データaと重みwとを入力とする積和演算を行う。
 畳み込み層210への入力データa(アクティベーションデータ、特徴マップともいう)は、画像データ等の多次元データである。本実施形態において、入力データaは、要素(x,y,c)からなる3次元テンソルである。CNN200の畳み込み層210は、低ビットの入力データaに対して畳み込み演算を行う。本実施形態において、入力データaの要素は、2ビットの符号なし整数(0,1,2,3)である。入力データaの要素は、例えば、4ビットや8ビット符号なし整数でもよい。
 CNN200に入力される入力データが、例えば32ビットの浮動小数点型など、畳み込み層210への入力データaと形式が異なる場合、CNN200は畳み込み層210の前に型変換や量子化を行う入力層をさらに有してもよい。
 畳み込み層210の重みw(フィルタ、カーネルともいう)は、学習可能なパラメータである要素を有する多次元データである。本実施形態において、重みwは、要素(i,j,c,d)からなる4次元テンソルである。重みwは、要素(i,j,c)からなる3次元テンソル(以降、「重みwo」という)をd個有している。学習済みのCNN200における重みwは、学習済みのデータである。CNN200の畳み込み層210は、低ビットの重みwを用いて畳み込み演算を行う。本実施形態において、重みwの要素は、1ビットの符号付整数(0,1)であり、値「0」は+1を表し、値「1」は-1を表す。
 畳み込み層210は、式1に示す畳み込み演算を行い、出力データfを出力する。式1において、sはストライドを示す。図2において点線で示された領域は、入力データaに対して重みwoが適用される領域ao(以降、「適用領域ao」という)の一つを示している。適用領域aoの要素は、(x+i,y+j,c)で表される。
Figure JPOXMLDOC01-appb-M000001
 量子化演算層220は、畳み込み層210が出力する畳み込み演算の出力に対して量子化などを実施する。量子化演算層220は、プーリング層221と、Batch Normalization層222と、活性化関数層223と、量子化層224と、を有する。
 プーリング層221は、畳み込み層210が出力する畳み込み演算の出力データfに対して平均プーリング(式2)やMAXプーリング(式3)などの演算を実施して、畳み込み層210の出力データfを圧縮する。式2および式3において、uは入力テンソルを示し、vは出力テンソルを示し、Tはプーリング領域の大きさを示す。式3において、maxはTに含まれるiとjの組み合わせに対するuの最大値を出力する関数である。
Figure JPOXMLDOC01-appb-M000002
Figure JPOXMLDOC01-appb-M000003
 Batch Normalization層222は、量子化演算層220やプーリング層221の出力データに対して、例えば式4に示すような演算によりデータ分布の正規化を行う。式4において、uは入力テンソルを示し、vは出力テンソルを示し、αはスケールを示し、βはバイアスを示す。学習済みのCNN200において、αおよびβは学習済みの定数ベクトルである。
Figure JPOXMLDOC01-appb-M000004
 活性化関数層223は、量子化演算層220やプーリング層221やBatch Normalization層222の出力に対してReLU(式5)などの活性化関数の演算を行う。式5において、uは入力テンソルであり、vは出力テンソルである。式5において、maxは引数のうち最も大きい数値を出力する関数である。
Figure JPOXMLDOC01-appb-M000005
 量子化層224は、量子化パラメータに基づいて、プーリング層221や活性化関数層223の出力に対して例えば式6に示すような量子化を行う。式6に示す量子化は、入力テンソルuを2ビットにビット削減している。式6において、q(c)は量子化パラメータのベクトルである。学習済みのCNN200において、q(c)は学習済みの定数ベクトルである。式6における不等号「≦」は「<」であってもよい。
Figure JPOXMLDOC01-appb-M000006
 出力層230は、恒等関数やソフトマックス関数等によりCNN200の結果を出力する層である。出力層230の前段のレイヤは、畳み込み層210であってもよいし、量子化演算層220であってもよい。
 CNN200は、量子化された量子化層224の出力データが、畳み込み層210に入力されるため、量子化を行わない他の畳み込みニューラルネットワークと比較して、畳み込み層210の畳み込み演算の負荷が小さい。
[畳み込み演算の分割]
 NN回路100は、畳み込み層210の畳み込み演算(式1)の入力データを部分テンソルに分割して演算する。部分テンソルへの分割方法や分割数は特に限定されない。部分テンソルは、例えば、入力データa(x+i,y+j,c)をa(x+i,y+j,co)に分割することにより形成される。なお、NN回路100は、畳み込み層210の畳み込み演算(式1)の入力データを分割せずに演算することもできる。
 畳み込み演算の入力データ分割において、式1における変数cは、式7に示すように、サイズBcのブロックで分割される。また、式1における変数dは、式8に示すように、サイズBdのブロックで分割される。式7において、coはオフセットであり、ciは0から(Bc-1)までのインデックスである。式8において、doはオフセットであり、diは0から(Bd-1)までのインデックスである。なお、サイズBcとサイズBdは同じであってもよい。
Figure JPOXMLDOC01-appb-M000007
Figure JPOXMLDOC01-appb-M000008
 式1における入力データa(x+i,y+j,c)は、c軸方向においてサイズBcにより分割され、分割された入力データa(x+i,y+j,co)で表される。以降の説明において、分割された入力データaを「分割入力データa」ともいう。
 式1における重みw(i,j,c,d)は、c軸方向においてサイズBcおよびd軸方向においてサイズBdにより分割され、分割された重みw(i,j,co,do)で表される。以降の説明において、分割された重みwを「分割重みw」ともいう。
 サイズBdにより分割された出力データf(x,y,do)は、式9により求まる。分割された出力データf(x,y,do)を組み合わせることで、最終的な出力データf(x,y,d)を算出できる。
Figure JPOXMLDOC01-appb-M000009
[畳み込み演算のデータの展開]
 NN回路100は、畳み込み層210の畳み込み演算における入力データaおよび重みwを展開して畳み込み演算を行う。
 図3は、畳み込み演算のデータの展開を説明する図である。
 分割入力データa(x+i、y+j、co)は、Bc個の要素を持つベクトルデータに展開される。分割入力データaの要素は、ciでインデックスされる(0≦ci<Bc)。以降の説明において、i,jごとにベクトルデータに展開された分割入力データaを「入力ベクトルA」ともいう。入力ベクトルAは、分割入力データa(x+i、y+j、co×Bc)から分割入力データa(x+i、y+j、co×Bc+(Bc-1))までを要素とする。
 分割重みw(i,j,co、do)は、Bc×Bd個の要素を持つマトリクスデータに展開される。マトリクスデータに展開された分割重みwの要素は、ciとdiでインデックスされる(0≦di<Bd)。以降の説明において、i,jごとにマトリクスデータに展開された分割重みwを「重みマトリクスW」ともいう。重みマトリクスWは、分割重みw(i,j,co×Bc、do×Bd)から分割重みw(i,j,co×Bc+(Bc-1)、do×Bd+(Bd-1))までを要素とする。
 入力ベクトルAと重みマトリクスWとを乗算することで、ベクトルデータが算出される。i,j,coごとに算出されたベクトルデータを3次元テンソルに整形することで、出力データf(x,y,do)を得ることができる。このようなデータの展開を行うことで、畳み込み層210の畳み込み演算を、ベクトルデータとマトリクスデータとの乗算により実施できる。
[NN回路100]
 図4は、本実施形態に係るNN回路100の全体構成を示す図である。
 NN回路100は、第一DMAコントローラ3(以下、「第一DMAC3」ともいう)と、コントローラ6と、IFU7と、共有メモリ8と、第二DMAコントローラ9(以下、「第二DMAC9」ともいう)と、少なくとも一つのニューラルネットワーク演算コア10(以下、「NN演算コア10」ともいう)と、を備える。
 NN回路100は、複数のNN演算コア10を実装可能である。図4に例示するNN回路100は、NN演算コア10を最大4つまで実装可能である。複数のNN演算コア10は、NN200の少なくとの一部の演算を連携して実行する「ニューラルネットワーク演算マルチコア10M(以下、「NN演算マルチコア10M」ともいう)」を構成する。複数のNN演算コア10は、本実施形態においてデイジーチェーン接続されている。なお、NN回路100に実装可能なNN演算コア10の数は5個以上であってもよい。
 第一DMAC3は、外部バスEBに接続されており、DRAMなどの外部メモリ120とNN演算コア10との間のデータ転送を行う。第一DMAC3は、複数のNN演算コア10のいずれかに対して外部メモリ120から読み出したデータの転送を行う。なお、第一DMAC3は、複数のNN演算コア10に対して外部メモリ120から読み出した同一のデータを転送可能であってもよいし、ブロードキャスト可能であってもよい。また、第一DMAC3は、DRAMなどの外部メモリと共有メモリ8との間のデータ転送を行う。
 コントローラ6は、外部バスEBに接続されており、外部のホストCPU110のスレーブとして動作する。コントローラ6は、バスブリッジ60と、レジスタ61と、を有する。
 バスブリッジ60は、外部バスEBから内部バスIBへのバスアクセスを中継する。また、バスブリッジ60は、外部ホストCPU110からレジスタ61への書き込み要求および読み込み要求を中継する。
 レジスタ61は、パラメータレジスタや状態レジスタを有する。パラメータレジスタは、NN回路100の動作を制御するレジスタである。状態レジスタは各モジュールの命令列のポインタ・命令数などを含み、NN回路100の状態を示すレジスタである。また、状態レジスタはセマフォSを含む構成としてよい。外部ホストCPU110は、コントローラ6のバスブリッジ60を経由して、レジスタ61にアクセスできる。
 コントローラ6は、内部バスIBを介して、NN回路100の各ブロック(第一DMAC3、IFU7、第二DMAC9、NN演算コア10)と接続されている。外部ホストCPU110は、コントローラ6を経由して、NN回路100の各ブロックに対してアクセスできる。例えば、外部ホストCPU110は、コントローラ6を経由して、NN演算コア10に対する命令を指示することができる。また、各ブロックは、内部バスIBを介して、コントローラ6が有する状態レジスタ(セマフォSを含んでもよい)を更新できる。状態レジスタは、各ブロックと接続された専用配線を介して更新されるように構成されていてもよい。
 IFU(Instruction Fetch Unit)7は、外部ホストCPU110の指示に基づいて、外部バスEBを経由してNN回路100の各ブロック(第一DMAC3、第二DMAC9、NN演算コア10)に対する命令コマンドを外部メモリ120から読み出す。また、IFU7は、読み出した命令コマンドを対応するNN回路100の各ブロック(第一DMAC3、第二DMAC9、NN演算コア10)に転送する。
 共有メモリ8は、例えばSRAM(Static RAM)などで構成された揮発性のメモリ等の書き換え可能なメモリである。共有メモリ8は、NN演算コア10が使用するデータを一時的に記録したり、複数のNN演算コアが共有するデータを記録したりするメモリである。
 第二DMAC9は、共有メモリ8とNN演算コア10とを接続しており、共有メモリ8とNN演算コア10との間のデータ転送を行う。なお、第二DMAC9は、複数のNN演算コア10に対して共有メモリ8から読み出したデータをブロードキャスト可能であってもよい。
 NN回路100は、複数のNN演算コアが共有するデータ等を、第一DMAC3を用いて外部メモリ120に退避させなくとも、第二DMAC9を用いて共有メモリ8に一時的に退避させることができ、NN演算コア間のデータ転送を高速化できる。なお、NN回路100は、共有メモリ8および第二DMAC9を有していなくてもよい。
[NN演算コア10]
 図5は、NN演算コア10の全体構成を示す図である。
 NN演算コア10は、第一メモリ1と、第二メモリ2と、畳み込み演算回路4と、量子化演算回路5と、を備える。NN演算コア10は、第一メモリ1および第二メモリ2を介して、畳み込み演算回路4と量子化演算回路5とがループ状に形成されていることを特徴とする。
 第一メモリ1は、例えばSRAM(Static RAM)などで構成された揮発性のメモリ等の書き換え可能なメモリである。第一メモリ1には、第一DMAC3や第二DMAC9や内部バスIBを介してデータの書き込みおよび読み出しが行われる。外部ホストCPU110は、第一メモリ1に対するデータの書き込みや読み出しにより、NN演算コア10に対するデータの入出力を行うことができる。
 第一メモリ1は、畳み込み演算回路4の入力ポートと接続されており、畳み込み演算回路4は第一メモリ1からデータを読み出すことができる。また、第一メモリ1は、量子化演算回路5の出力ポートとループ接続(C1)されており、量子化演算回路5は第一メモリ1にデータを書き込むことができる。また、第一メモリ1は、他のNN演算コア10との間のコア間接続(C2)でデータ転送が可能であり、コア間接続(C2)された他のNN演算コア10は第一メモリ1にデータを書き込むことができる。なお、本実施形態において、コア間接続(C2)の一例として、デイジーチェーン接続を用いている。
 第二メモリ2は、例えばSRAM(Static RAM)などで構成された揮発性のメモリ等の書き換え可能なメモリである。第二メモリ2には、第一DMAC3や第二DMAC9や内部バスIBを介してデータの書き込みおよび読み出しが行われる。外部ホストCPU110は、第二メモリ2に対するデータの書き込みや読み出しにより、NN演算コア10に対するデータの入出力を行うことができる。
 第二メモリ2は、量子化演算回路5の入力ポートと接続されており、量子化演算回路5は第二メモリ2からデータを読み出すことができる。また、第二メモリ2は、畳み込み演算回路4の出力ポートと接続されており、畳み込み演算回路4は第二メモリ2にデータを書き込むことができる。
 畳み込み演算回路4は、学習済みのCNN200の畳み込み層210における畳み込み演算を行う回路である。畳み込み演算回路4は、第一メモリ1に格納された入力データaを読み出し、入力データaに対して畳み込み演算を実施する。畳み込み演算回路4は、畳み込み演算の出力データf(以降、「畳み込み演算出力データ」ともいう)を第二メモリ2に書き込む。
 量子化演算回路5は、学習済みのCNN200の量子化演算層220における量子化演算の少なくとも一部を行う回路である。量子化演算回路5は、第二メモリ2に格納された畳み込み演算の出力データfを読み出し、畳み込み演算の出力データfに対して量子化演算(プーリング、Batch Normalization、活性化関数、および量子化のうち少なくとも量子化を含む演算)を実施する。
 量子化演算回路5は、量子化演算の出力データ(以降、「量子化演算出力データ」ともいう)をループ接続(C1)された第一メモリ1に書き込む。また、量子化演算回路5は、他のNN演算コア10とコア間接続(C2)経由でデータ転送可能であり、量子化演算回路5はコア間接続(C2)された他のNN演算コア10に量子化演算出力データを出力することができる。
 NN演算コア10は、第一メモリ1や第二メモリ2等を有するため、DRAMなどの外部メモリからの第一DMAC3によるデータ転送において、重複するデータのデータ転送の回数を低減できる。これにより、メモリアクセスにより発生する消費電力または処理負荷を大幅に低減することができる。
[NN演算コア10の動作例1]
 図6は、NN演算コア10の動作例を示すタイミングチャートである。
 第一DMAC3は、レイヤ1の入力データaを第一メモリ1に格納する。第一DMAC3は、畳み込み演算回路4が行う畳み込み演算の順序にあわせて、レイヤ1の入力データaを分割して第一メモリ1に転送してもよい。
 畳み込み演算回路4は、第一メモリ1に格納されたレイヤ1の入力データaを読み出す。畳み込み演算回路4は、レイヤ1の入力データaに対して図1に示すレイヤ1の畳み込み演算を行う。レイヤ1の畳み込み演算の出力データfは、第二メモリ2に格納される。
 量子化演算回路5は、第二メモリ2に格納されたレイヤ1の出力データfを読み出す。量子化演算回路5は、レイヤ1の出力データfに対してレイヤ2の量子化演算を行う。レイヤ2の量子化演算の出力データは、第一メモリ1に格納される。
 畳み込み演算回路4は、第一メモリ1に格納されたレイヤ2の量子化演算の出力データを読み出す。畳み込み演算回路4は、レイヤ2の量子化演算の出力データを入力データaとしてレイヤ3の畳み込み演算を行う。レイヤ3の畳み込み演算の出力データfは、第二メモリ2に格納される。
 畳み込み演算回路4は、第一メモリ1に格納されたレイヤ2M-2(Mは自然数)の量子化演算の出力データを読み出す。畳み込み演算回路4は、レイヤ2M-2の量子化演算の出力データを入力データaとしてレイヤ2M-1の畳み込み演算を行う。レイヤ2M-1の畳み込み演算の出力データfは、第二メモリ2に格納される。
 量子化演算回路5は、第二メモリ2に格納されたレイヤ2M-1の出力データfを読み出す。量子化演算回路5は、2M-1レイヤの出力データfに対してレイヤ2Mの量子化演算を行う。レイヤ2Mの量子化演算の出力データは、第一メモリ1に格納される。
 畳み込み演算回路4は、第一メモリ1に格納されたレイヤ2Mの量子化演算の出力データを読み出す。畳み込み演算回路4は、レイヤ2Mの量子化演算の出力データを入力データaとしてレイヤ2M+1の畳み込み演算を行う。レイヤ2M+1の畳み込み演算の出力データfは、第二メモリ2に格納される。
 畳み込み演算回路4と量子化演算回路5とが交互に演算を行い、図1に示すCNN200の演算を進めていく。NN演算コア10は、畳み込み演算回路4が時分割によりレイヤ2M-1とレイヤ2M+1の畳み込み演算を実施する。また、NN演算コア10は、量子化演算回路5が時分割によりレイヤ2M-2とレイヤ2Mの量子化演算を実施する。そのため、NN演算コア10は、レイヤごとに別々の畳み込み演算回路4と量子化演算回路5を実装する場合と比較して、回路規模が著しく小さい。
 NN演算コア10は、複数のレイヤの多層構造であるCNN200の演算を、ループ状に形成された回路により演算する。NN演算コア10は、ループ状の回路構成により、ハードウェア資源を効率的に利用できる。なお、NN演算コア10は、ループ状に回路を形成するために、各レイヤで変化する畳み込み演算回路4や量子化演算回路5におけるパラメータは適宜更新される。
 CNN200の演算にNN演算コア10により実施できない演算が含まれる場合、NN演算コア10は外部ホストCPU110などの外部演算デバイスに中間データを転送する。外部演算デバイスが中間データに対して演算を行った後、外部演算デバイスによる演算結果は第一メモリ1や第二メモリ2に入力される。NN演算コア10は、外部演算デバイスによる演算結果に対する演算を再開する。
[NN演算コア10の動作例2]
 図7は、NN演算コア10の他の動作例を示すタイミングチャートである。
 NN演算コア10は、入力データaを部分テンソルに分割して、時分割により部分テンソルに対する演算を行ってもよい。部分テンソルへの分割方法や分割数は特に限定されない。
 図7は、入力データaを二つの部分テンソルに分解した場合の動作例を示している。分解された部分テンソルを、「第一部分テンソルa1」、「第二部分テンソルa2」とする。例えば、レイヤ2M-1の畳み込み演算は、第一部分テンソルa1に対応する畳み込み演算(図7において、「レイヤ2M-1(a1)」と表記)と、第二部分テンソルa2に対応する畳み込み演算(図7において、「レイヤ2M-1(a2)」と表記)と、に分解される。
 第一部分テンソルa1に対応する畳み込み演算および量子化演算と、第二部分テンソルa2に対応する畳み込み演算および量子化演算とは、図7に示すように、独立して実施することができる。
 畳み込み演算回路4は、第一部分テンソルa1に対応するレイヤ2M-1の畳み込み演算(図7において、レイヤ2M-1(a1)で示す演算)を行う。その後、畳み込み演算回路4は、第二部分テンソルaに対応するレイヤ2M-1の畳み込み演算(図7において、レイヤ2M-1(a)で示す演算)を行う。また、量子化演算回路5は、第一部分テンソルa1に対応するレイヤ2Mの量子化演算(図7において、レイヤ2M(a1)で示す演算)を行う。このように、NN演算コア10は、第二部分テンソルaに対応するレイヤ2M-1の畳み込み演算と、第一部分テンソルa1に対応するレイヤ2Mの量子化演算と、を並列に実施できる。
 次に、畳み込み演算回路4は、第一部分テンソルa1に対応するレイヤ2M+1の畳み込み演算(図7において、レイヤ2M+1(a1)で示す演算)を行う。また、量子化演算回路5は、第二部分テンソルaに対応するレイヤ2Mの量子化演算(図7において、レイヤ2M(a)で示す演算)を行う。このように、NN演算コア10は、第一部分テンソルa1に対応するレイヤ2M+1の畳み込み演算と、第二部分テンソルaに対応するレイヤ2Mの量子化演算と、を並列に実施できる。
 第一部分テンソルa1に対応する畳み込み演算および量子化演算と、第二部分テンソルa2に対応する畳み込み演算および量子化演算とは、独立して実施することができる。そのため、NN演算コア10は、例えば、第一部分テンソルa1に対応するレイヤ2M-1の畳み込み演算と、第二部分テンソルaに対応するレイヤ2M+2の量子化演算と、を並列に実施してもよい。すなわち、NN演算コア10が並列で演算する畳み込み演算と量子化演算は、連続するレイヤの演算に限定されない。
 入力データaを部分テンソルに分割することで、NN演算コア10は畳み込み演算回路4と量子化演算回路5とを並列して動作させることができる。その結果、畳み込み演算回路4と量子化演算回路5が待機する時間が削減され、NN演算コア10の演算処理効率が向上する。図7に示す動作例において分割数は2であったが、分割数が2より大きい場合も同様に、NN演算コア10は畳み込み演算回路4と量子化演算回路5とを並列して動作させることができる。
 例えば、入力データaが「第一部分テンソルa1」、「第二部分テンソルa2」および「第三部分テンソルa」に分割される場合、NN演算コア10は、第二部分テンソルaに対応するレイヤ2M-1の畳み込み演算と、第三部分テンソルaに対応するレイヤ2Mの量子化演算と、を並列に実施してもよい。演算の順序は、第一メモリ1および第二メモリ2における入力データaの格納状況によって適宜変更される。
 なお、部分テンソルに対する演算方法としては、同一レイヤにおける部分テンソルの演算を畳み込み演算回路4または量子化演算回路5で行った後に次のレイヤにおける部分テンソルの演算を行う例(方法1)を示した。例えば、図7に示すように、畳み込み演算回路4において、第一部分テンソルa1および第二部分テンソルaに対応するレイヤ2M-1の畳み込み演算(図7において、レイヤ2M-1(a1)およびレイヤ2M-1(a)で示す演算)を行った後に、第一部分テンソルa1および第二部分テンソルaに対応するレイヤ2M+1の畳み込み演算(図7において、レイヤ2M+1(a1)およびレイヤ2M+1(a)で示す演算)を実施している。
 しかしながら、部分テンソルに対する演算方法はこれに限られない。部分テンソルに対する演算方法は、複数レイヤにおける一部の部分テンソルの演算をした後に残部の部分テンソルの演算を実施する方法でもよい(方法2)。例えば、畳み込み演算回路4において、第一部分テンソルa1に対応するレイヤ2M-1および第一部分テンソルa1に対応するレイヤ2M+1の畳み込み演算を行った後に、第二部分テンソルaに対応するレイヤ2M-1および第二部分テンソルaに対応するレイヤ2M+1の畳み込み演算を実施してもよい。
 また、部分テンソルに対する演算方法は、方法1と方法2とを組み合わせて部分テンソルを演算する方法でもよい。ただし、方法2を用いる場合は、部分テンソルの演算順序に関する依存関係に従って演算を実施する必要がある。
[NN演算マルチコア10M]
 図8は、NN演算マルチコア10Mを示す図である。
 図8に例示するNN演算マルチコア10Mは、デイジーチェーン接続された二つのNN演算コア10を備える。二つのNN演算コア10を区別する場合、二つのNN演算コア10を、「第一NN演算コア10A」と、「第二NN演算コア10B」という。なお、図8において、第一メモリ1は「A」、畳み込み演算回路4は「C」、第二メモリ2は「F」、量子化演算回路5は「Q」として略記されている。
 具体的には、第一NN演算コア10Aの量子化演算回路5と、第二NN演算コア10Bの第一メモリ1とがデイジーチェーン接続(C2)されている。第一NN演算コア10Aの量子化演算回路5は、ループ接続(C1)された第一NN演算コア10Aの第一メモリ1または/およびデイジーチェーン接続(C2)された第二NN演算コア10Bの第一メモリ1に量子化演算出力データを書き込むことができる。
 具体的には、第二NN演算コア10Bの量子化演算回路5と、第一NN演算コア10Aの第一メモリ1とがデイジーチェーン接続(C2)されている。第二NN演算コア10Bの量子化演算回路5は、ループ接続(C1)された第二NN演算コア10Bの第一メモリ1または/およびデイジーチェーン接続(C2)された第一NN演算コア10Aの第一メモリ1に量子化演算出力データを書き込むことができる。
 NN演算マルチコア10Mが三つ以上のNN演算コア10を備える場合も同様に、複数のNN演算コア10はデイジーチェーン接続される。最終段のNN演算コア10以外のNN演算コア10の量子化演算回路5は、後段のNN演算コア10Bの第一メモリ1とデイジーチェーン接続(C2)される。最終段のNN演算コア10の量子化演算回路5は、最初段のNN演算コア10の第一メモリ1とデイジーチェーン接続(C2)されている。複数のNN演算コア10はデイジーチェーンループ(数珠繋ぎ)状に形成されていることを特徴とする。
 一つのNN演算コア10において、第一メモリ(A)1と畳み込み演算回路(C)4と第二メモリ(F)2と量子化演算回路(Q)5とは、ループ状に接続されている。一方、NN演算マルチコア10Mにおいては、第一メモリ(A)1と畳み込み演算回路(C)4と第二メモリ(F)2と量子化演算回路(Q)5とは、第一メモリ(A)1と畳み込み演算回路(C)4と第二メモリ(F)2と量子化演算回路(Q)5とが同じ順番で繰り返し配列するように、デイジーチェーンループ(数珠繋ぎ)状に接続されている。
 NN演算マルチコア10Mを構成する複数のNN演算コア10は、同一のハードウェア構成でなくてもよい。例えば、第一NN演算コア10Aの第一メモリ1の容量・構成は、第二NN演算コア10Bの第一メモリ1の容量・構成と異なっていてもよい。例えば、第一NN演算コア10Aの量子化演算回路5の構成は、第二NN演算コア10Bの量子化演算回路5の構成と異なっていてもよい。
[NN演算マルチコア10Mの動作例1]
 図9は、NN演算マルチコア10Mの動作例1を示すタイミングチャートである。
 第一部分テンソルa1に対応する畳み込み演算および量子化演算と、第二部分テンソルa2に対応する畳み込み演算および量子化演算とは、図9に示すように、異なるNN演算コア10により独立して実施される。
 第一NN演算コア10Aの畳み込み演算回路4は、第一部分テンソルa1に対応するレイヤ2M-1の畳み込み演算(図9において、レイヤ2M-1(a1)で示す演算)を行う。その後、第一NN演算コア10Aの量子化演算回路5は、第一部分テンソルa1に対応するレイヤ2Mの量子化演算(図9において、レイヤ2M(a1)で示す演算)を行う。第一NN演算コア10Aの量子化演算回路5は、第一部分テンソルa1に対応するレイヤ2Mの量子化演算出力データを第一NN演算コア10Aの第一メモリ1に格納する。
 第二NN演算コア10Bの畳み込み演算回路4は、第二部分テンソルa2に対応するレイヤ2M-1の畳み込み演算(図9において、レイヤ2M-1(a2)で示す演算)を行う。その後、第二NN演算コア10Bの量子化演算回路5は、第二部分テンソルaに対応するレイヤ2Mの量子化演算(図9において、レイヤ2M(a)で示す演算)を行う。第二NN演算コア10Bの量子化演算回路5は、第二部分テンソルaに対応するレイヤ2Mの量子化演算出力データを第二NN演算コア10Bの第一メモリ1に格納する。
 第二DMAC9は、第一NN演算コア10Aの第一メモリ1に格納された第一部分テンソルa1に対応するレイヤ2Mの量子化演算出力データを、共有メモリ8にDMA転送(図9において、DMA1で示す転送)する。つぎに、第二DMAC9は、第二NN演算コア10Bの第一メモリ1に格納された第二部分テンソルaに対応するレイヤ2Mの量子化演算出力データを、共有メモリ8にDMA転送(図9において、DMA2で示す転送)する。
 第一DMAC3は、共有メモリ8に格納された第一部分テンソルa1および第二部分テンソルa2に対応するレイヤ2Mの量子化演算出力データを、外部メモリ120に対してDMA転送(図9において、DMA3で示す転送)する。
 NN演算マルチコア10Mは、例えば同じレイヤの演算を異なるNN演算コア10により独立して実施して演算に必要な時間を短縮できる。また、共有メモリ8および第二DMAC9により、各NN演算コア10の演算結果を取りまとめることができる。
[NN演算マルチコア10Mの動作例2]
 図10は、NN演算マルチコア10Mの動作例2を示すタイミングチャートである。
 第一部分テンソルa1に対応する畳み込み演算および量子化演算は、異なるNN演算コア10により協調して実施される。
 第一NN演算コア10Aの畳み込み演算回路4は、第一部分テンソルa1に対応するレイヤ2M-1の畳み込み演算(図10において、レイヤ2M-1(a1)で示す演算)を実施する。その後、第一NN演算コア10Aの量子化演算回路5は、第一部分テンソルa1に対応するレイヤ2Mの量子化演算(図10において、レイヤ2M(a1)で示す演算)を実施する。第一NN演算コア10Aの量子化演算回路5は、第一部分テンソルa1に対応するレイヤ2Mの量子化演算出力データを第二NN演算コア10Bの第一メモリ1に格納する。
 第二NN演算コア10Bの畳み込み演算回路4は、第一部分テンソルaに対応するレイヤ2M+1の畳み込み演算(図10において、レイヤ2M+1(a)で示す演算)を実施する。その後、第二NN演算コア10Bの量子化演算回路5は、第一部分テンソルaに対応するレイヤ2M+2の量子化演算(図10において、レイヤ2M+2(a)で示す演算)を行う。第二NN演算コア10Bの量子化演算回路5は、第二部分テンソルaに対応するレイヤ2M+2の量子化演算出力データを第二NN演算コア10Bの第一メモリ1に格納する。
 第一DMAC3は、第二NN演算コア10Bの第一メモリ1に格納された第一部分テンソルa1に対応するレイヤ2M+2の量子化演算出力データを、外部メモリ120に対してDMA転送(図10において、DMAで示す転送)する。
 NN演算マルチコア10Mは、例えば同じ部分テンソルに対応する演算を異なるNN演算コア10により連続して実施して演算に必要な時間を短縮できる。
[NN演算マルチコア10Mの動作例3]
 図11は、NN演算マルチコア10Mの動作例3を示すタイミングチャートである。
 動作例3においては、レイヤ2M-1の畳み込み演算と、レイヤ2M+1の畳み込み演算において部分テンソルの構成が変更される。
 第二DMAC9は、第一NN演算コア10Aの第一メモリ1に第一部分テンソルa1をDMA転送(図11において、DMA1で示す転送)する。つぎに、第二DMAC9は、第二NN演算コア10Bの第一メモリ1に第二部分テンソルaをDMA転送(図11において、DMA2で示す転送)する。
 第一NN演算コア10Aの畳み込み演算回路4は、第一部分テンソルa1に対応するレイヤ2M-1の畳み込み演算(図11において、レイヤ2M-1(a1)で示す演算)を行う。その後、第一NN演算コア10Aの量子化演算回路5は、第一部分テンソルa1に対応するレイヤ2Mの量子化演算(図11において、レイヤ2M(a1)で示す演算)を行う。第一NN演算コア10Aの量子化演算回路5は、第一部分テンソルa1に対応するレイヤ2Mの量子化演算出力データを第一NN演算コア10Aの第一メモリ1に格納する。
 第二DMAC9は、第一NN演算コア10Aの第一メモリ1に格納された第一部分テンソルa1に対応するレイヤ2Mの量子化演算出力データを、共有メモリ8にDMA転送(図11において、DMA3で示す転送)する。
 第二NN演算コア10Bの畳み込み演算回路4は、第二部分テンソルa2に対応するレイヤ2M-1の畳み込み演算(図11において、レイヤ2M-1(a2)で示す演算)を行う。第二NN演算コア10Bの畳み込み演算回路4による畳み込み演算の開始は、第一NN演算コア10Aの畳み込み演算回路4による畳み込み演算の開始より遅い。その後、第二NN演算コア10Bの量子化演算回路5は、第二部分テンソルaに対応するレイヤ2Mの量子化演算(図11において、レイヤ2M(a)で示す演算)を行う。第二NN演算コア10Bの量子化演算回路5は、第二部分テンソルaに対応するレイヤ2Mの量子化演算出力データを第二NN演算コア10Bの第一メモリ1に格納する。
 第二DMAC9は、第二NN演算コア10Bの第一メモリ1に格納された第二部分テンソルa2に対応するレイヤ2Mの量子化演算出力データを、共有メモリ8にDMA転送(図11において、DMA4で示す転送)する。
 例えば、レイヤ2M-1の畳み込み演算において入力データaがc軸方向のチャンネル数が32チャンネルであり、レイヤ2M+1の畳み込み演算において入力データaがc軸方向のチャンネル数が64チャンネルであるような場合、レイヤ2M+1の畳み込み演算において畳み込み演算回路4等を効率的に使用するために、部分テンソルの分割態様を変更することが望ましい。たとえば、各NN演算コア10がc軸方向のチャンネル数が32チャンネルの入力データaを並列演算できるように最適化されており、入力データaのc軸方向のチャンネル数が64チャンネルであるレイヤ2M+1の畳み込み演算を実施する場合を想定する。この場合、NN演算コア10Aの畳み込み演算回路4が0から31チャンネルまでの入力データaの演算を実施し、NN演算コア10Bの畳み込み演算回路4が32から63チャンネルまでの入力データaの演算を実施するように、入力データaから部分テンソルへの分割態様を変更してもよい。再分割された部分テンソルのうちの二つを「第三部分テンソルa」と「第四部分テンソルa」という。
 第二DMAC9は、第一NN演算コア10Aの第一メモリ1に第三部分テンソルaをDMA転送(図11において、DMA5で示す転送)する。つぎに、第二DMAC9は、第二NN演算コア10Bの第一メモリ1に第四部分テンソルaをDMA転送(図11において、DMA6で示す転送)する。
 第一NN演算コア10Aの畳み込み演算回路4は、第三部分テンソルaに対応するレイヤ2M+1の畳み込み演算(図11において、レイヤ2M+1(a)で示す演算)を行う。その後、第一NN演算コア10Aの量子化演算回路5は、第三部分テンソルaに対応するレイヤ2M+2の量子化演算(図11において、レイヤ2M+2(a)で示す演算)を行う。第一NN演算コア10Aの量子化演算回路5は、第三部分テンソルaに対応するレイヤ2M+2の量子化演算出力データを第一NN演算コア10Aの第一メモリ1に格納する。
 第二NN演算コア10Bの畳み込み演算回路4は、第四部分テンソルaに対応するレイヤ2M+1の畳み込み演算(図11において、レイヤ2M+1(a)で示す演算)を行う。その後、第二NN演算コア10Bの量子化演算回路5は、第四部分テンソルaに対応するレイヤ2M+2の量子化演算(図11において、レイヤ2M+2(a)で示す演算)を行う。第二NN演算コア10Bの量子化演算回路5は、第四部分テンソルaに対応するレイヤ2M+2の量子化演算出力データを第二NN演算コア10Bの第一メモリ1に格納する。
 入力データaの特徴が変わった場合(例えば畳み込み演算においてチャンネル数が増える等)であっても、NN回路100は、第二DMAC9と共有メモリ8と用いて、NN演算コア10に割り当てる部分テンソルの分割態様を変更することができる。NN回路100は、部分テンソルの分割態様を変更する場合あっても、第一DMAC3を用いて外部メモリ120に入力データaをDMA転送により退避させる回数を削減できる。
 次に、NN回路100の各構成に関して詳しく説明する。
[第一DMAC3]
 図12は、第一DMAC3の内部ブロック図である。
 第一DMAC3は、データ転送回路31と、ステートコントローラ32と、を有する。第一DMAC3は、データ転送回路31に対する専用のステートコントローラ32を有しており、命令コマンドが入力されると、外部のコントローラを必要とせずにDMAデータ転送を実施できる。
 データ転送回路31は、外部バスEBに接続されており、DRAMなどの外部メモリ120とNN演算コア10との間のDMAデータ転送を行う。また、データ転送回路31は、DRAMなどの外部メモリ120と共有メモリ8との間のDMAデータ転送を行う。データ転送回路31のDMAチャンネル数は限定されない。例えば、第一NN演算コア10Aと第二NN演算コア10Bのそれぞれに専用のDMAチャンネルを有していてもよい。
 ステートコントローラ32は、データ転送回路31のステートを制御する。また、ステートコントローラ32は、内部バスIBを介してコントローラ6と接続されている。ステートコントローラ32は、命令キュー33と制御回路34とを有する。
 命令キュー33は、第一DMAC3用の命令コマンドC3が格納されるキューであり、例えばFIFOメモリで構成される。命令キュー33には、IFU7経由または内部バスIB経由で1つ以上の命令コマンドC3が書き込まれる。
 制御回路34は、命令コマンドC3をデコードし、命令コマンドC3に基づいて順次データ転送回路31を制御するステートマシンである。制御回路34は、論理回路により実装されていてもよいし、ソフトウェアによって制御されるCPUによって実装されていてもよい。
 図13は、制御回路34のステート遷移図である。
 制御回路34は、命令キュー33に命令コマンドC3が入力されると(Not empty)、アイドルステートST1からデコードステートST2に遷移する。
 制御回路34は、デコードステートST2において、命令キュー33から出力される命令コマンドC3をデコードする。また、制御回路34は、コントローラ6のレジスタ61に格納されたセマフォSを読み出し、命令コマンドC3において指示されたデータ転送回路31の動作を実行可能であるかを判定する。実行不能である場合(Not ready)、制御回路34は実行可能となるまで待つ(Wait)。実行可能である場合(ready)、制御回路34はデコードステートST2から実行ステートST3に遷移する。
 制御回路34は、実行ステートST3において、データ転送回路31を制御して、データ転送回路31に命令コマンドC3において指示された動作を実施させる。制御回路34は、データ転送回路31の動作が終わると、命令キュー33から実行を終えた命令コマンドC3を取り除くとともに、コントローラ6のレジスタ61に格納されたセマフォSを更新する。制御回路34は、命令キュー33に命令がある場合(Not empty)、実行ステートST3からデコードステートST2に遷移する。制御回路34は、命令キュー33に命令がない場合(empty)、実行ステートST3からアイドルステートST1に遷移する。
[畳み込み演算回路4]
 図14は、畳み込み演算回路4の内部ブロック図である。
 畳み込み演算回路4は、重みメモリ41と、乗算器42と、アキュムレータ回路43と、ステートコントローラ44と、を有する。畳み込み演算回路4は、乗算器42およびアキュムレータ回路43に対する専用のステートコントローラ44を有しており、命令コマンドが入力されると、外部のコントローラを必要とせずに畳み込み演算を実施できる。
 重みメモリ41は、畳み込み演算に用いる重みwが格納されるメモリであり、例えばSRAM(Static RAM)などで構成された揮発性のメモリ等の書き換え可能なメモリである。第一DMAC3は、DMA転送により、畳み込み演算に必要な重みwを重みメモリ41に書き込む。
 図15は、乗算器42の内部ブロック図である。
 乗算器42は、入力ベクトルAと重みマトリクスWとを乗算する。入力ベクトルAは、上述したように、分割入力データa(x+i、y+j、co)がi、jごとに展開されたBc個の要素を持つベクトルデータである。また、重みマトリクスWは、分割重みw(i,j,co、do)がi、jごとに展開されたBc×Bd個の要素を持つマトリクスデータである。乗算器42は、Bc×Bd個の積和演算ユニット47を有し、入力ベクトルAと重みマトリクスWとを乗算を並列して実施できる。
 乗算器42は、乗算に必要な入力ベクトルAと重みマトリクスWを、第一メモリ1および重みメモリ41から読み出して乗算を実施する。乗算器42は、Bd個の積和演算結果O(di)を出力する。
 図16は、積和演算ユニット47の内部ブロック図である。
 積和演算ユニット47は、入力ベクトルAの要素A(ci)と、重みマトリクスWの要素W(ci,di)との乗算を実施する。また、積和演算ユニット47は、乗算結果と他の積和演算ユニット47の乗算結果S(ci,di)と加算する。積和演算ユニット47は、加算結果S(ci+1,di)を出力する。要素A(ci)は、2ビットの符号なし整数(0,1,2,3)である。要素W(ci,di)は、1ビットの符号付整数(0,1)であり、値「0」は+1を表し、値「1」は-1を表す。
 積和演算ユニット47は、反転器(インバータ)47aと、セレクタ47bと、加算器47cと、を有する。積和演算ユニット47は、乗算器を用いず、反転器47aおよびセレクタ47bのみを用いて乗算を行う。セレクタ47bは、要素W(ci,di)が「0」の場合、要素A(ci)の入力を選択する。セレクタ47bは、要素W(ci,di)が「1」の場合、要素A(ci)を反転器により反転させた補数を選択する。要素W(ci,di)は、加算器47cのCarry-inにも入力される。加算器47cは、要素W(ci,di)が「0」のとき、S(ci,di)に要素A(ci)を加算した値を出力する。加算器47cは、W(ci,di)が「1」のとき、S(ci,di)から要素A(ci)を減算した値を出力する。
 図17は、アキュムレータ回路43の内部ブロック図である。
 アキュムレータ回路43は、乗算器42の積和演算結果O(di)を第二メモリ2にアキュムレートする。アキュムレータ回路43は、Bd個のアキュムレータユニット48を有し、Bd個の積和演算結果O(di)を並列して第二メモリ2にアキュムレートできる。
 図18は、アキュムレータユニット48の内部ブロック図である。
 アキュムレータユニット48は、加算器48aと、マスク部48bとを有している。加算器48aは、積和演算結果Oの要素O(di)と、第二メモリ2に格納された式1に示す畳み込み演算の途中経過である部分和と、を加算する。加算結果は、要素あたり16ビットである。加算結果は、要素あたり16ビットに限定されず、例えば要素あたり15ビットや17ビットであってもよい。
 加算器48aは、加算結果を第二メモリ2の同一アドレスに書き込む。マスク部48bは、初期化信号clearがアサートされた場合に、第二メモリ2からの出力をマスクし、要素O(di)に対する加算対象をゼロにする。初期化信号clearは、第二メモリ2に途中経過の部分和が格納されていない場合にアサートされる。
 乗算器42およびアキュムレータ回路43による畳み込み演算が完了すると、第二メモリ2に、出力データf(x,y,do)が格納される。
 ステートコントローラ44は、乗算器42およびアキュムレータ回路43のステートを制御する。また、ステートコントローラ44は、内部バスIBを介してコントローラ6と接続されている。ステートコントローラ44は、命令キュー45と制御回路46とを有する。
 命令キュー45は、畳み込み演算回路4用の命令コマンドC4が格納されるキューであり、例えばFIFOメモリで構成される。命令キュー45には、IFU7経由または内部バスIB経由で命令コマンドC4が書き込まれる。
 制御回路46は、命令コマンドC4をデコードし、命令コマンドC4に基づいて乗算器42およびアキュムレータ回路43を制御するステートマシンである。制御回路46は、第一DMAC3のステートコントローラ32の制御回路34と同様の構成である。
[量子化演算回路5]
 図19は、量子化演算回路5の内部ブロック図である。
 量子化演算回路5は、量子化パラメータメモリ51と、ベクトル演算回路52と、量子化回路53と、ステートコントローラ54と、を有する。量子化演算回路5は、ベクトル演算回路52および量子化回路53に対する専用のステートコントローラ54を有しており、命令コマンドが入力されると、外部のコントローラを必要とせずに量子化演算を実施できる。
 量子化パラメータメモリ51は、量子化演算に用いる量子化パラメータqが格納されるメモリであり、例えばSRAM(Static RAM)などで構成された揮発性のメモリ等の書き換え可能なメモリである。第一DMAC3は、DMA転送により、量子化演算に必要な量子化パラメータqを量子化パラメータメモリ51に書き込む。
 図20は、ベクトル演算回路52と量子化回路53の内部ブロック図である。
 ベクトル演算回路52は、第二メモリ2に格納された出力データf(x,y,do)に対して演算を行う。ベクトル演算回路52は、Bd個の演算ユニット57を有し、出力データf(x,y,do)に対して並列にSIMD演算を行う。
 図21は、演算ユニット57のブロック図である。
 演算ユニット57は、例えば、ALU57aと、第一セレクタ57bと、第二セレクタ57cと、レジスタ57dと、シフタ57eと、を有する。演算ユニット57は、公知の汎用SIMD演算回路が有する他の演算器等をさらに有してもよい。
 ベクトル演算回路52は、演算ユニット57が有する演算器等を組み合わせることで、出力データf(x,y,do)に対して、量子化演算層220におけるプーリング層221や、Batch Normalization層222や、活性化関数層223の演算のうち少なくとも一つの演算を行う。
 演算ユニット57は、レジスタ57dに格納されたデータと第二メモリ2から読み出した出力データf(x,y,do)の要素f(di)とをALU57aにより加算できる。演算ユニット57は、ALU57aによる加算結果をレジスタ57dに格納できる。演算ユニット57は、第一セレクタ57bの選択によりレジスタ57dに格納されたデータに代えて「0」をALU57aに入力することで加算結果を初期化できる。例えばプーリング領域が2×2である場合、シフタ57eはALU57aの出力を2bit右シフトすることで加算結果の平均値を出力できる。ベクトル演算回路52は、Bd個の演算ユニット57による上記の演算等を繰り返すことで、式2に示す平均プーリングの演算を実施できる。
 演算ユニット57は、レジスタ57dに格納されたデータと第二メモリ2から読み出した出力データf(x,y,do)の要素f(di)とをALU57aにより比較できる。
演算ユニット57は、ALU57aによる比較結果に応じて第二セレクタ57cを制御して、レジスタ57dに格納されたデータと要素f(di)の大きい方を選択できる。演算ユニット57は、第一セレクタ57bの選択により要素f(di)の取りうる値の最小値をALU57aに入力することで比較対象を最小値に初期化できる。本実施形態において要素f(di)は16bit符号付き整数であるので、要素f(di)の取りうる値の最小値は「0x8000」である。ベクトル演算回路52は、Bd個の演算ユニット57による上記の演算等を繰り返すことで、式3のMAXプーリングの演算を実施できる。なお、MAXプーリングの演算ではシフタ57eは第二セレクタ57cの出力をシフトしない。
 演算ユニット57は、レジスタ57dに格納されたデータと第二メモリ2から読み出した出力データf(x,y,do)の要素f(di)とをALU57aにより減算できる。シフタ57eはALU57aの出力を左シフト(すなわち乗算)もしくは右シフト(すなわち除算)できる。ベクトル演算回路52は、Bd個の演算ユニット57による上記の演算等を繰り返すことで、式4のBatch Normalizationの演算を実施できる。
 演算ユニット57は、第二メモリ2から読み出した出力データf(x,y,do)の要素f(di)と第一セレクタ57bにより選択された「0」とをALU57aにより比較できる。演算ユニット57は、ALU57aによる比較結果に応じて要素f(di)と予めレジスタ57dに格納された定数値「0」のいずれかを選択して出力できる。ベクトル演算回路52は、Bd個の演算ユニット57による上記の演算等を繰り返すことで、式5のReLU演算を実施できる。
 ベクトル演算回路52は、平均プーリング、MAXプーリング、Batch Normalization、活性化関数の演算およびこれらの演算の組み合わせを実施できる。ベクトル演算回路52は、汎用SIMD演算を実施できるため、量子化演算層220における演算に必要な他の演算を実施してもよい。また、ベクトル演算回路52は、量子化演算層220における演算以外の演算を実施してもよい。
 なお、量子化演算回路5は、ベクトル演算回路52を有してなくてもよい。量子化演算回路5がベクトル演算回路52を有していない場合、出力データf(x,y,do)は量子化回路53に入力される。
 量子化回路53は、ベクトル演算回路52の出力データに対して、量子化を行う。量子化回路53は、図20に示すように、Bd個の量子化ユニット58を有し、ベクトル演算回路52の出力データに対して並列に演算を行う。
 図22は、量子化ユニット58の内部ブロック図である。
 量子化ユニット58は、ベクトル演算回路52の出力データの要素in(di)に対して量子化を行う。量子化ユニット58は、比較器58aと、エンコーダ58bと、を有する。量子化ユニット58はベクトル演算回路52の出力データ(16ビット/要素)に対して、量子化演算層220における量子化層224の演算(式6)を行う。量子化ユニット58は、量子化パラメータメモリ51から必要な量子化パラメータq(th0,th1,th2)を読み出し、比較器58aにより入力in(di)と量子化パラメータqとの比較を行う。量子化ユニット58は、比較器58aによる比較結果をエンコーダ58bにより2ビット/要素に量子化する。式4におけるα(c)とβ(c)は、変数cごとに異なるパラメータであるため、α(c)とβ(c)を反映する量子化パラメータq(th0,th1,th2)はin(di)ごとに異なるパラメータである。
 量子化ユニット58は、入力in(di)を3つの閾値th0,th1,th2と比較することにより、入力in(di)を4領域(例えば、in≦th0,th0<in≦th1,th1<in≦th2,th2<in)に分類し、分類結果を2ビットにエンコードして出力する。量子化ユニット58は、量子化パラメータq(th0,th1,th2)の設定により、量子化と併せてBatch Normalizationや活性化関数の演算を行うこともできる。
 量子化ユニット58は、閾値th0を式4のβ(c)、閾値の差(th1―th0)および(th2―th1)を式4のα(c)として設定して量子化を行うことで、式4に示すBatch Normalizationの演算を量子化と併せて実施できる。(th1―th0)および(th2―th1)を大きくすることでα(c)を小さくできる。(th1―th0)および(th2―th1)を小さくすることで、α(c)を大きくできる。
 量子化ユニット58は、入力in(di)の量子化と併せて活性化関数を実施できる。例えば、量子化ユニット58は、in(di)≦th0およびth2<in(di)となる領域では出力値を飽和させる。量子化ユニット58は、出力が非線形とするように量子化パラメータqを設定することで活性化関数の演算を量子化と併せて実施できる。
 ステートコントローラ54は、ベクトル演算回路52および量子化回路53のステートを制御する。また、ステートコントローラ54は、内部バスIBを介してコントローラ6と接続されている。ステートコントローラ54は、命令キュー55と制御回路56とを有する。
 命令キュー55は、量子化演算回路5用の命令コマンドC5が格納されるキューであり、例えばFIFOメモリで構成される。命令キュー55には、IFU7経由または内部バスIB経由で命令コマンドC5が書き込まれる。
 制御回路56は、命令コマンドC5をデコードし、命令コマンドC5に基づいてベクトル演算回路52および量子化回路53を制御するステートマシンである。制御回路56は、第一DMAC3のステートコントローラ32の制御回路34と同様の構成である。
 量子化演算回路5は、Bd個の要素を持つ量子化演算出力データを第一メモリ1に書き込む。なお、BdとBcの好適な関係を式10に示す。式10においてnは整数である。
Figure JPOXMLDOC01-appb-M000010
[コントローラ6]
 コントローラ6は、外部ホストCPU110から転送される命令コマンドを、内部バスIBを介して、第一DMAC3、第二DMAC9、畳み込み演算回路4および量子化演算回路5が有する命令キューに転送する。コントローラ6は、各回路に対する命令コマンドを格納する命令メモリを有してもよい。
 コントローラ6は、外部バスEBに接続されており、外部ホストCPU110のスレーブとして動作する。コントローラ6は、パラメータレジスタや状態レジスタを含むレジスタ61を有している。パラメータレジスタは、NN回路100の動作を制御するレジスタである。状態レジスタは、セマフォSを含むNN回路100の状態を示すレジスタである。
[セマフォS]
 セマフォSは、P操作によりデクリメントされ、V操作によってインクリメントされる。第一DMAC3、畳み込み演算回路4および量子化演算回路5によるP操作およびV操作は、内部バスIBを経由して、コントローラ6が有するセマフォSを更新する。
 図23は、セマフォSによるNN回路100の制御を説明する図である。
 セマフォSは、NN回路100におけるメモリ(第一メモリ1、第二メモリ2)を介したデータフローFごとに設けられる。図23および以降の説明において、説明を簡略化するため、第二DMAC9に関連するデータフローに関するセマフォは省略されている。なお、本実施形態におけるNN回路100は、複数のNN演算コア10を含むため、複数のデータフローが存在する。いずれのデータフローを用いてCNN200に関する演算を実行するかは、対応する命令コマンドによって制御される。
[第一NN演算コア10Aに関するセマフォS]
 セマフォSは、第一NN演算コア10Aに関して、第一セマフォS11と、第二セマフォS12と、第三セマフォS13と、第四セマフォS14と、を有する。
 第一セマフォS11は、第一NN演算コア10Aの第一データフローF11の制御に用いられる。第一データフローF11は、第一DMAC3(Producer)が第一NN演算コア10Aの第一メモリ1に入力データaを書き込み、第一NN演算コア10Aの畳み込み演算回路4(Consumer)が入力データaを読み出すデータフローである。第一セマフォS11は、第一ライトセマフォS11Wと、第一リードセマフォS11Rと、を有する。
 第二セマフォS12は、第一NN演算コア10Aの第二データフローF12の制御に用いられる。第二データフローF12は、第一NN演算コア10Aの畳み込み演算回路4(Producer)が出力データfを第一NN演算コア10Aの第二メモリ2に書き込み、第一NN演算コア10Aの量子化演算回路5(Consumer)が出力データfを読み出すデータフローである。第二セマフォS12は、第二ライトセマフォS12Wと、第二リードセマフォS12Rと、を有する。
 第三セマフォS13は、第一NN演算コア10Aの第三データフローF13の制御に用いられる。第三データフローF13は、第一NN演算コア10Aの量子化演算回路5(Producer)が量子化演算出力データを第一NN演算コア10Aの第一メモリ1に書き込み、第一NN演算コア10Aの畳み込み演算回路4(Consumer)が量子化演算出力データを読み出すデータフローである。第三セマフォS13は、第三ライトセマフォS13Wと、第三リードセマフォS13Rと、を有する。
 第四セマフォS14は、第一NN演算コア10Aの第四データフローF14の制御に用いられる。第四データフローF14は、第二NN演算コア10Bの量子化演算回路5(Producer)が量子化演算出力データを第一NN演算コア10Aの第一メモリ1に書き込み、第一NN演算コア10Aの畳み込み演算回路4(Consumer)が量子化演算出力データを読み出すデータフローである。第四セマフォS14は、第四ライトセマフォS14Wと、第四リードセマフォS14Rと、を有する。
[第二NN演算コア10Bに関するセマフォS]
 セマフォSは、第二NN演算コア10Bに関して、第一セマフォS21と、第二セマフォS22と、第三セマフォS23と、第四セマフォS24と、を有する。
 第一セマフォS21は、第二NN演算コア10Bの第一データフローF21の制御に用いられる。第一データフローF21は、第一DMAC3(Producer)が第二NN演算コア10Bの第一メモリ1に入力データaを書き込み、第二NN演算コア10Bの畳み込み演算回路4(Consumer)が入力データaを読み出すデータフローである。第一セマフォS21は、第一ライトセマフォS21Wと、第一リードセマフォS21Rと、を有する。
 第二セマフォS22は、第二NN演算コア10Bの第二データフローF22の制御に用いられる。第二データフローF22は、第二NN演算コア10Bの畳み込み演算回路4(Producer)が出力データfを第二NN演算コア10Bの第二メモリ2に書き込み、第二NN演算コア10Bの量子化演算回路5(Consumer)が出力データfを読み出すデータフローである。第二セマフォS22は、第二ライトセマフォS22Wと、第二リードセマフォS22Rと、を有する。
 第三セマフォS23は、第二NN演算コア10Bの第三データフローF23の制御に用いられる。第三データフローF23は、第二NN演算コア10Bの量子化演算回路5(Producer)が量子化演算出力データを第二NN演算コア10Bの第一メモリ1に書き込み、第二NN演算コア10Bの畳み込み演算回路4(Consumer)が量子化演算出力データを読み出すデータフローである。第三セマフォS23は、第三ライトセマフォS23Wと、第三リードセマフォS23Rと、を有する。
 第四セマフォS24は、第二NN演算コア10Bの第四データフローF24の制御に用いられる。第四データフローF24は、第一NN演算コア10Aの量子化演算回路5(Producer)が量子化演算出力データを第二NN演算コア10Bの第一メモリ1に書き込み、第二NN演算コア10Bの畳み込み演算回路4(Consumer)が量子化演算出力データを読み出すデータフローである。第四セマフォS24は、第四ライトセマフォS24Wと、第四リードセマフォS24Rと、を有する。
[第一NN演算コア10Aの第一データフローF11]
 図24は、第一データフローF11のタイミングチャートである。
 第一ライトセマフォS11Wは、第一NN演算コア10Aの第一データフローF11における第一DMAC3による第一NN演算コア10Aの第一メモリ1に対する書き込みを制限するセマフォである。第一ライトセマフォS11Wは、第一メモリ1において、例えば入力ベクトルAなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが読み出し済みで他のデータを書き込み可能なメモリ領域の数を示している。第一ライトセマフォS11Wが「0」の場合、第一DMAC3は第一メモリ1に対して第一データフローF11における書き込みを行えず、第一ライトセマフォS11Wが「1」以上となるまで待たされる。
 第一リードセマフォS11Rは、第一NN演算コア10Aの第一データフローF1における第一NN演算コア10Aの畳み込み演算回路4による第一NN演算コア10Aの第一メモリ1からの読み出しを制限するセマフォである。第一リードセマフォS11Rは、第一メモリ1において、例えば入力ベクトルAなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが書き込み済みで読み出し可能なメモリ領域の数を示している。第一リードセマフォS11Rが「0」の場合、畳み込み演算回路4は第一メモリ1からの第一データフローF11における読み出しを行えず、第一リードセマフォS11Rが「1」以上となるまで待たされる。
 第一DMAC3は、命令キュー33に命令コマンドC3が格納されることにより、DMA転送を開始する。図24に示すように、第一ライトセマフォS11Wが「0」でないため、第一DMAC3はDMA転送を開始する(DMA転送1)。第一DMAC3は、DMA転送を開始する際に、第一ライトセマフォS11Wに対してP操作を行う。第一DMAC3は、DMA転送の完了後に、第一リードセマフォS11Rに対してV操作を行う。
 第一NN演算コア10Aの畳み込み演算回路4は、命令キュー45に命令コマンドC4が格納されることにより、畳み込み演算を開始する。図24に示すように、第一リードセマフォS11Rが「0」であるため、畳み込み演算回路4は第一リードセマフォS11Rが「1」以上となるまで待たされる(デコードステートST2におけるWait)。第一DMAC3によるV操作により第一リードセマフォS11Rが「1」となると、畳み込み演算回路4は畳み込み演算を開始する(畳み込み演算1)。畳み込み演算回路4は、畳み込み演算を開始する際、第一リードセマフォS11Rに対してP操作を行う。畳み込み演算回路4は、畳み込み演算の完了後に、第一ライトセマフォS11Wに対してV操作を行う。
 図24において「DMA転送3」と記載されたDMA転送を第一DMAC3が開始する際、第一ライトセマフォS11Wが「0」であるため、第一DMAC3は第一ライトセマフォS11Wが「1」以上となるまで待たされる(デコードステートST2におけるWait)。畳み込み演算回路4によるV操作により第一ライトセマフォS11Wが「1」以上となると、第一DMAC3はDMA転送を開始する。
 第一DMAC3と第一NN演算コア10Aの畳み込み演算回路4とは、第一セマフォS11を使用することで、第一データフローF11において第一メモリ1に対するアクセス競合を防止できる。また、第一DMAC3と第一NN演算コア10Aの畳み込み演算回路4とは、第一セマフォS11を使用することで、第一NN演算コア10Aの第一データフローF11におけるデータ転送の同期を取りつつ、独立して並列に動作できる。
[第一NN演算コア10Aの第二データフローF12]
 図25は、第二データフローF12のタイミングチャートである。
 第二ライトセマフォS12Wは、第一NN演算コア10Aの第二データフローF12における第一NN演算コア10Aの畳み込み演算回路4による第一NN演算コア10Aの第二メモリ2に対する書き込みを制限するセマフォである。第二ライトセマフォS12Wは、第二メモリ2において、例えば出力データfなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが読み出し済みで他のデータを書き込み可能なメモリ領域の数を示している。第二ライトセマフォS12Wが「0」の場合、畳み込み演算回路4は第二メモリ2に対して第二データフローF12における書き込みを行えず、第二ライトセマフォS12Wが「1」以上となるまで待たされる。
 第二リードセマフォS12Rは、第一NN演算コア10Aの第二データフローF2における第一NN演算コア10Aの量子化演算回路5による第一NN演算コア10Aの第二メモリ2からの読み出しを制限するセマフォである。第二リードセマフォS12Rは、第二メモリ2において、例えば出力データfなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが書き込み済みで読み出し可能なメモリ領域の数を示している。第二リードセマフォS12Rが「0」の場合、量子化演算回路5は第二メモリ2からの第二データフローF12における読み出しを行えず、第二リードセマフォS12Rが「1」以上となるまで待たされる。
 第一NN演算コア10Aの畳み込み演算回路4は、図25に示すように、畳み込み演算を開始する際、第二ライトセマフォS12Wに対してP操作を行う。畳み込み演算回路4は、畳み込み演算の完了後に、第二リードセマフォS12Rに対してV操作を行う。
 第一NN演算コア10Aの量子化演算回路5は、命令キュー55に命令コマンドC5が格納されることにより、量子化演算を開始する。図25に示すように、第二リードセマフォS12Rが「0」であるため、量子化演算回路5は第二リードセマフォS12Rが「1」以上となるまで待たされる(デコードステートST2におけるWait)。畳み込み演算回路4によるV操作により第二リードセマフォS12Rが「1」となると、量子化演算回路5は量子化演算を開始する(量子化演算1)。量子化演算回路5は、量子化演算を開始する際、第二リードセマフォS12Rに対してP操作を行う。量子化演算回路5は、量子化演算の完了後に、第二ライトセマフォS12Wに対してV操作を行う。
 図25において「量子化演算2」と記載された量子化演算を量子化演算回路5が開始する際、第二リードセマフォS12Rが「0」であるため、量子化演算回路5は第二リードセマフォS12Rが「1」以上となるまで待たされる(デコードステートST2におけるWait)。畳み込み演算回路4によるV操作により第二リードセマフォS12Rが「1」以上となると、量子化演算回路5は量子化演算を開始する。
 第一NN演算コア10Aの畳み込み演算回路4と第一NN演算コア10Aの量子化演算回路5とは、第二セマフォS12を使用することで、第二データフローF12において第二メモリ2に対するアクセス競合を防止できる。また、第一NN演算コア10Aの畳み込み演算回路4と第一NN演算コア10Aの量子化演算回路5とは、第二セマフォS12を使用することで、第二データフローF12におけるデータ転送の同期を取りつつ、独立して並列に動作できる。
[第一NN演算コア10Aの第三データフローF13]
 図26は、第三データフローF13のタイミングチャートである。
 第三ライトセマフォS13Wは、第一NN演算コア10Aの第三データフローF13における第一NN演算コア10Aの量子化演算回路5による第一NN演算コア10Aの第一メモリ1に対する書き込みを制限するセマフォである。第三ライトセマフォS13Wは、第一メモリ1において、例えば量子化演算回路5の量子化演算出力データなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが読み出し済みで他のデータを書き込み可能なメモリ領域の数を示している。第三ライトセマフォS13Wが「0」の場合、量子化演算回路5は第一メモリ1に対して第三データフローF13における書き込みを行えず、第三ライトセマフォS13Wが「1」以上となるまで待たされる。
 第三リードセマフォS13Rは、第一NN演算コア10Aの第三データフローF13における第一NN演算コア10Aの畳み込み演算回路4による第一NN演算コア10Aの第一メモリ1からの読み出しを制限するセマフォである。第三リードセマフォS13Rは、第一メモリ1において、例えば量子化演算回路5の量子化演算出力データなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが書き込み済みで読み出し可能なメモリ領域の数を示している。第三リードセマフォS13Rが「0」の場合、畳み込み演算回路4は第三データフローF13における第一メモリ1からの読み出しを行えず、第三リードセマフォS13Rが「1」以上となるまで待たされる。
 第一NN演算コア10Aの量子化演算回路5は、図26に示すように、量子化演算を開始する際、第三ライトセマフォS13Wに対してP操作を行う。量子化演算回路5は、畳み込み演算の完了後に、第三リードセマフォS13Rに対してV操作を行う。
 第一NN演算コア10Aの畳み込み演算回路4は、命令キュー45に命令コマンドC4が格納されることにより、畳み込み演算を開始する。図26に示すように、第三リードセマフォS13が「0」であるため、畳み込み演算回路4は第三リードセマフォS13Rが「1」以上となるまで待たされる(デコードステートST2におけるWait)。量子化演算回路5によるV操作により第三リードセマフォS13Rが「1」となると、畳み込み演算回路4は畳み込み演算を開始する(畳み込み演算5)。畳み込み演算回路4は、畳み込み演算を開始する際、第三リードセマフォS13Rに対してP操作を行う。畳み込み演算回路4は、畳み込み演算の完了後に、第三ライトセマフォS13Wに対してV操作を行う。
 図26において「畳み込み演算7」と記載された畳み込み演算を畳み込み演算回路4が開始する際、第三リードセマフォS13Rが「0」であるため、畳み込み演算回路4は第三リードセマフォS13Rが「1」以上となるまで待たされる(デコードステートST2におけるWait)。量子化演算回路5によるV操作により第三リードセマフォS13Rが「1」以上となると、畳み込み演算回路4は畳み込み演算を開始する。
 第一NN演算コア10Aの量子化演算回路5と第一NN演算コア10Aの畳み込み演算回路4とは、第三セマフォS13を使用することで、第三データフローF13において第一メモリ1に対するアクセス競合を防止できる。また、第一NN演算コア10Aの量子化演算回路5と第一NN演算コア10Aの畳み込み演算回路4とは、第三セマフォS13を使用することで、第三データフローF13におけるデータ転送の同期を取りつつ、独立して並列に動作できる。
[第一NN演算コア10Aの第四データフローF14]
 図27は、第四データフローF14のタイミングチャートである。
 第四ライトセマフォS14Wは、第一NN演算コア10Aの第四データフローF14における第二NN演算コア10Bの量子化演算回路5による第一NN演算コア10Aの第一メモリ1に対する書き込みを制限するセマフォである。第四ライトセマフォS14Wは、第一メモリ1において、例えば量子化演算回路5の量子化演算出力データなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが読み出し済みで他のデータを書き込み可能なメモリ領域の数を示している。第四ライトセマフォS14Wが「0」の場合、量子化演算回路5は第一メモリ1に対して第四データフローF14における書き込みを行えず、第四ライトセマフォS14Wが「1」以上となるまで待たされる。
 第四リードセマフォS14Rは、第一NN演算コア10Aの第四データフローF14における第一NN演算コア10Aの畳み込み演算回路4による第一NN演算コア10Aの第一メモリ1からの読み出しを制限するセマフォである。第四リードセマフォS14Rは、第一メモリ1において、例えば量子化演算回路5の量子化演算出力データなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが書き込み済みで読み出し可能なメモリ領域の数を示している。第四リードセマフォS14Rが「0」の場合、畳み込み演算回路4は第四データフローF14における第一メモリ1からの読み出しを行えず、第四リードセマフォS14Rが「1」以上となるまで待たされる。
 第二NN演算コア10Bの量子化演算回路5は、図27に示すように、量子化演算を開始する際、第四ライトセマフォS14Wに対してP操作を行う。量子化演算回路5は、畳み込み演算の完了後に、第四リードセマフォS14Rに対してV操作を行う。
 第一NN演算コア10Aの畳み込み演算回路4は、命令キュー45に命令コマンドC4が格納されることにより、畳み込み演算を開始する。図27に示すように、第四リードセマフォS14Rが「0」であるため、畳み込み演算回路4は第四リードセマフォS14Rが「1」以上となるまで待たされる(デコードステートST2におけるWait)。量子化演算回路5によるV操作により第四リードセマフォS14Rが「1」となると、畳み込み演算回路4は畳み込み演算を開始する(畳み込み演算9)。畳み込み演算回路4は、畳み込み演算を開始する際、第四リードセマフォS14Rに対してP操作を行う。畳み込み演算回路4は、畳み込み演算の完了後に、第四ライトセマフォS14Wに対してV操作を行う。
 図27において「畳み込み演算10」と記載された畳み込み演算を畳み込み演算回路4が開始する際、第四リードセマフォS14Rが「0」であるため、畳み込み演算回路4は第四リードセマフォS14Rが「1」以上となるまで待たされる(デコードステートST2におけるWait)。量子化演算回路5によるV操作により第四リードセマフォS14Rが「1」以上となると、畳み込み演算回路4は畳み込み演算を開始する。
 第二NN演算コア10Bの量子化演算回路5と第一NN演算コア10Aの畳み込み演算回路4とは、第四セマフォS14を使用することで、第四データフローF14において第一メモリ1に対するアクセス競合を防止できる。また、第二NN演算コア10Bの量子化演算回路5と第一NN演算コア10Aの畳み込み演算回路4とは、第四セマフォS14を使用することで、第四データフローF14における複数のNN演算コア10間のデータ転送の同期を取りつつ、独立して並列に動作できる。
 第一NN演算コア10Aの第一メモリ1は、3つのデータフロー(第一データフローF11、第三データフローF13および第四データフローF14)において共有される。NN回路100は、第一セマフォS11と第三セマフォS13と第四セマフォS14とを別途設けることで、第一データフローF11と第三データフローF13と第四データフローF14とを区別してデータ転送の同期を取ることができる。
[第二NN演算コア10Bの第一データフローF21]
 第二NN演算コア10Bの第一データフローF21は、第一NN演算コア10Aの第一データフローF11と同等である。第一DMAC3と第二NN演算コア10Bの畳み込み演算回路4とは、第一セマフォS21を使用することで、第一データフローF21において第一メモリ1に対するアクセス競合を防止できる。また、第一DMAC3と第二NN演算コア10Bの畳み込み演算回路4とは、第一セマフォS21を使用することで、第二NN演算コア10Bの第一データフローF21におけるデータ転送の同期を取りつつ、独立して並列に動作できる。
[第二NN演算コア10Bの第二データフローF22]
 第二NN演算コア10Bの第二データフローF22は、第一NN演算コア10Aの第二データフローF12と同等である。第二NN演算コア10Bの畳み込み演算回路4と第二NN演算コア10Bの量子化演算回路5とは、第二セマフォS22を使用することで、第二データフローF22において第二メモリ2に対するアクセス競合を防止できる。また、第二NN演算コア10Bの畳み込み演算回路4と第二NN演算コア10Bの量子化演算回路5とは、第二セマフォS22を使用することで、第二データフローF22におけるデータ転送の同期を取りつつ、独立して並列に動作できる。
[第二NN演算コア10Bの第三データフローF23]
 第二NN演算コア10Bの第三データフローF23は、第一NN演算コア10Aの第三データフローF13と同等である。第二NN演算コア10Bの量子化演算回路5と第二NN演算コア10Bの畳み込み演算回路4とは、第三セマフォS23を使用することで、第三データフローF23において第一メモリ1に対するアクセス競合を防止できる。また、第二NN演算コア10Bの量子化演算回路5と第二NN演算コア10Bの畳み込み演算回路4とは、第三セマフォS23を使用することで、第三データフローF23におけるデータ転送の同期を取りつつ、独立して並列に動作できる。
[第二NN演算コア10Bの第四データフローF24]
 第二NN演算コア10Bの第四データフローF24は、第一NN演算コア10Aの第四データフローF14と同等である。第一NN演算コア10Aの量子化演算回路5と第二NN演算コア10Bの畳み込み演算回路4とは、第四セマフォS24を使用することで、第四データフローF24において第一メモリ1に対するアクセス競合を防止できる。また、第一NN演算コア10Aの量子化演算回路5と第二NN演算コア10Bの畳み込み演算回路4とは、第四セマフォS24を使用することで、第四データフローF24における複数数のNN演算コア10間のデータ転送の同期を取りつつ、独立して並列に動作できる。
[第一NN演算コア10Aの畳み込み演算回路4の動作]
 第一NN演算コア10Aの畳み込み演算回路4は、畳み込み演算を行う際、第一NN演算コア10Aの第一メモリ1から読み出しを行い、第一NN演算コア10Aの第二メモリ2に対して書き込みを行う。すなわち、畳み込み演算回路4は、3つのデータフロー(第一データフローF11、第三データフローF13および第四データフローF14)においてはConsumerであり、第二データフローF12においてはProducerである。そのため、畳み込み演算回路4は、畳み込み演算を開始する際、データフローに対応するリードセマフォ(第一リードセマフォS11R、第三リードセマフォS13Rまたは第四リードセマフォS14R)に対してP操作を行い(図24、図26、図27参照)、第二ライトセマフォS12Wに対してP操作を行う(図24参照)。畳み込み演算回路4は、畳み込み演算の完了後に、データフローに対応するライトセマフォ(第一ライトセマフォS11W、第三ライトセマフォS13W、第四ライトセマフォS14W)に対してV操作を行い(図24、図26、図27参照)、第二リードセマフォS12Rに対してV操作を行う(図25参照)。
 第一NN演算コア10Aの畳み込み演算回路4は、畳み込み演算を開始する際、データフローに対応するリードセマフォ(第一リードセマフォS11R、第三リードセマフォS13Rまたは第四リードセマフォS14R)が「1」以上、かつ、第二ライトセマフォS12Wが「1」以上となるまで待たされる(デコードステートST2におけるWait)。
[第一NN演算コア10Aの量子化演算回路5の動作]
 第一NN演算コア10Aの量子化演算回路5は、量子化演算を行う際、第一NN演算コア10Aの第二メモリ2から読み出しを行い、第一NN演算コア10Aの第一メモリ1または第二NN演算コア10Bの第一メモリ1に対して書き込みを行う。すなわち、量子化演算回路5は、第二データフローF12においてはConsumerであり、2つのデータフロー(第三データフローF13および第四データフローF24)においてはProducerである。そのため、量子化演算回路5は、量子化演算を開始する際、第二リードセマフォS12Rに対してP操作を行い(図25参照)、データフローに対応するライトセマフォ(第三ライトセマフォS13Wまたは第四ライトセマフォS24W)に対してP操作を行う(図26参照)。量子化演算回路5は量子化演算の完了後に、第二ライトセマフォS12Wに対してV操作を行い(図25参照)、データフローに対応するリードセマフォ(第三リードセマフォS13Rまたは第四リードセマフォS24R)に対してV操作を行う(図26参照)。
 第一NN演算コア10Aの量子化演算回路5は、量子化演算を開始する際、第二リードセマフォS12Rが「1」以上、かつ、データフローに対応するライトセマフォ(第三ライトセマフォS13Wまたは第四ライトセマフォS24W)が「1」以上となるまで待たされる(デコードステートST2におけるWait)。
 第一NN演算コア10Aの量子化演算回路5は、第三データフローF13と第四データフローF24とを切り替えて、量子化演算出力データを格納する第一メモリ1を変更できる。第二NN演算コア10Bの量子化演算回路5は、同様に、第三データフローF23と第四データフローF14とを切り替えて、量子化演算出力データを格納する第一メモリ1を変更できる。
 本実施形態に係るニューラルネットワーク回路100によれば、IoT機器などの組み込み機器に組み込み可能なNN回路100を高性能に動作させることができる。複数のNN演算コア10を接続することで、より多くのニューラルネットワーク演算を効率的かつ高速に実施することができる。
 以上、本発明の第一実施形態について図面を参照して詳述したが、具体的な構成はこの実施形態に限られるものではなく、本発明の要旨を逸脱しない範囲の設計変更等も含まれる。また、上述の実施形態および変形例において示した構成要素は適宜に組み合わせて構成することが可能である。
(第二実施形態)
 本発明の第二実施形態について、図28から図31を参照して説明する。以降の説明において、既に説明したものと共通する構成については、同一の符号を付して重複する説明を省略する。第二実施形態に係るニューラルネットワーク回路100B(以下、「NN回路100B」という)は、第一実施形態に係るニューラルネットワーク回路100と比較して、畳み込み演算回路4が異なる。
[NN回路100B]
 NN回路100Bは、第一DMAC3、コントローラ6と、IFU7と、共有メモリ8と、第二DMAC9と、少なくとも一つのニューラルネットワーク演算コア10E(以下、「NN演算コア10E」ともいう)と、を備える。
[NN演算コア10E]
 NN演算コア10Eは、第一メモリ1と、第二メモリ2と、畳み込み演算回路4Bと、量子化演算回路5と、を備える。
[畳み込み演算回路4B]
 畳み込み演算回路4Bは、学習済みのCNN200の畳み込み層210における畳み込み演算を行う回路である。畳み込み演算回路4Bは、第一メモリ1に格納された入力データaを読み出し、入力データaに対して畳み込み演算を実施する。畳み込み演算回路4Bは畳み込み演算出力データを第二メモリ2に書き込む。
 図28は、畳み込み演算回路4Bの内部ブロック図である。
 畳み込み演算回路4Bは、重みメモリ41と、乗算器42Bと、アキュムレータ回路43と、ステートコントローラ44と、を有する。
 図29は、乗算器42の内部ブロック図である。
 乗算器(演算器アレイ)42Bは、分割入力データa(x+i,y+j,co)の各要素a(x+i,y+j,ci)と、分割重みw(i,j,co,do)の各要素w(i,j,ci,di)と、を乗算する。乗算器42は、Bc×Bd個の積和演算ユニットアレイ42Aを有し、分割入力データa(x+i,y+j,co)の要素a(x+i,y+j,ci)と分割重みw(i,j,co,do)の要素w(i,j,ci,di)との乗算を並列して実施できる。
 乗算器(演算器アレイ)42Bは、乗算に必要な要素aと要素wを、第一メモリ1および重みメモリ41から読み出して乗算を実施する。乗算器42は、Bd個の積和演算結果O(x+i,y+j,di)を出力する。
 なお、乗算器42に含まれる積和演算ユニットアレイ42Aの数はBc×Bd個に限定されない。例えば、積和演算ユニットアレイ42Aの数は、(Bc/P)×Bd個(PはBcまたはBcの約数)であってもよい。この場合、積和演算ユニットアレイ42Aは、分割入力データa(x+i,y+j,co)をc軸方向においてP個ごとに分割する。
 乗算器(演算器アレイ)42Bは、要素a(x+i,y+j,ci)と、要素a(x+i,y+y1+j,ci)と、要素a(x+i,y+y2+j,ci)と、を第一メモリ1から読み出す(0<y1<y2)。y1=1、y2=2の場合、3組の要素aは、xy軸平面におけるy軸方向に連続するラインデータである。y1=1+ST、y2=2+2STの場合、3組の要素aは、y軸方向に所定のライン数STだけ離れたラインデータである(STはy軸方向のストライド)。乗算器(演算器アレイ)42Bは、要素aを格納するラインメモリを有してもよい。
 第一メモリ1は、マルチバンクメモリであることが望ましい。この場合、要素a(x+i,y+j,ci)と、要素a(x+i,y+y1+j,ci)と、要素a(x+i,y+y2+j,ci)とは異なるバンクに格納され、各要素は独立して高速に読み出される。
 図30は、積和演算ユニットアレイ42Aの内部ブロック図である。
 積和演算ユニットアレイ42Aは、要素aと、要素wとを乗算する。積和演算ユニットアレイ42Aは、3個の積和演算ユニット47Bを有する。以降の説明において、3個の積和演算ユニット47Bを、第一積和演算ユニット471、第二積和演算ユニット472、第三積和演算ユニット473という。
 図31は、積和演算ユニット47Bの内部ブロック図である。
 積和演算ユニット47Bは、入力ベクトルAの要素A(ci)と、重みマトリクスWの要素W(ci,di)とを乗算する。積和演算ユニット47は、乗算結果s(ci)を出力する。要素A(ci)は、2ビットの符号なし整数(0,1,2,3)である。要素W(ci,di)は、1ビットの符号付整数(0,1)であり、値「0」は+1を表し、値「1」は-1を表す。
 積和演算ユニット47Bは、反転器(インバータ)47aと、セレクタ47bと、加算器47cと、を有する。積和演算ユニット47は、乗算器を用いず、反転器47aおよびセレクタ47bのみを用いて乗算を行う。セレクタ47bは、要素W(ci,di)が「0」の場合、要素A(ci)の入力を選択する。セレクタ47bは、要素W(ci,di)が「1」の場合、要素A(ci)を反転器により反転させた補数を選択する。要素W(ci,di)は、加算器47cのCarry-inにも入力される。加算器47cは、要素W(ci,di)が「0」のとき、m(ci,di)に要素A(ci)を加算した値を出力する。加算器47cは、W(ci,di)が「1」のとき、m(ci,di)から要素A(ci)を減算した値を出力する。
 第一積和演算ユニット471は、要素a(X,Y,ci)と要素w(i,j,ci,di)とを乗算する(Xは入力データaに含まれる任意のx座標、Yは入力データaに含まれる任意のy座標)。第一積和演算ユニット471は、出力m(i,j,ci,di)を加算器47Aに出力する。
 第二積和演算ユニット472は、要素a(X,Y+y1,ci)と要素w(i,j+1,ci,di)とを乗算する。第二積和演算ユニット472は、出力m(i,j+1,ci,di)を加算器47Aに出力する。
 第三積和演算ユニット473は、要素a(X,Y+y2,ci)と要素w(i,j+2,ci,di)とを乗算する。第三積和演算ユニット473は、出力m(i,j+2、ci,di)を加算器47Aに出力する。
 加算器47Aは、出力m(i,j,ci,di)と、出力m(i,j+1,ci,di)と、出力m(i,j+2,ci,di)と、他の積和演算ユニット47Bの乗算結果S(x+i,y+j,ci,di)と、を加算して、加算結果S(x+i,y+j,ci+1,di)を出力する。
 本実施形態に係るニューラルネットワーク回路100Bによれば、積和演算ユニットアレイ42Aにより演算を並列化でき、畳み込み演算を高速化できる。ニューラルネットワーク回路100Bは、畳み込み演算におけるy軸方向のストライドSTが2以上であっても好適に畳み込み演算を実施できる。
 以上、本発明の第二実施形態について図面を参照して詳述したが、具体的な構成はこの実施形態に限られるものではなく、本発明の要旨を逸脱しない範囲の設計変更等も含まれる。また、上述の実施形態および変形例において示した構成要素は適宜に組み合わせて構成することが可能である。
(第三実施形態)
 本発明の第三実施形態について、図32から図36を参照して説明する。以降の説明において、既に説明したものと共通する構成については、同一の符号を付して重複する説明を省略する。第三実施形態に係るニューラルネットワーク回路100G(以下、「NN回路100G」という)は、第一実施形態に係るニューラルネットワーク回路100と比較して、クロックゲーティング機能やパワーゲーティング機能をさらに有する。
[NN回路100G]
 図32は、本実施形態に係るNN回路100Gの全体構成を示す図である。
 NN回路100Gは、第一DMAC3G、コントローラ6と、IFU7と、共有メモリ8と、第二DMAC9と、少なくとも一つのニューラルネットワーク演算コア10G(以下、「NN演算コア10G」ともいう)と、を備える。なお、NN回路100Gは、共有メモリ8および第二DMAC9を有していなくてもよい。
 NN回路100Gは、複数のNN演算コア10Gを実装可能である。図32に例示するNN回路100Gは、NN演算コア10Gを最大4つまで実装可能である。複数のNN演算コア10Gは、第一実施形態のNN演算コア10と同様に、NN200の少なくとの一部の演算を連携して実行する「NN演算マルチコア10M」を構成する。複数のNN演算コア10Gは、第一実施形態と同様にデイジーチェーン接続されている。なお、NN回路100Gに実装可能なNN演算コア10の数は4個に限定されない。
[第一DMAC3G]
 図33は、第一DMAC3Gの内部ブロック図である。
 第一DMAC3Gは、第一実施形態の第一DMAC3と同様に、外部バスEBに接続されており、DRAMなどの外部メモリ120とNN演算コア10Gとの間のデータ転送を行う。第一DMAC3Gは、データ転送回路31と、ステートコントローラ32と、クロック制御部39と、を有する。
 図34は、クロック制御部39の動作を示すタイミングチャートである。
 クロック制御部39は、NN回路100Gに供給されるクロックCKから、クロックイネーブル信号CE3に基づいて、ゲーティッドクロック(第三クロック)GC3を生成する。クロックイネーブル信号CE3がネゲートされて無効(Disable、図34においてLow)に設定されると、ゲーティッドクロックGC3のトグルが停止される。クロックイネーブル信号CE3がアサートされて有効(Enable、図34においてHigh)に設定されると、ゲーティッドクロックGC3のトグルが開始される。ゲーティッドクロックGC3の生成回路は、公知のクロックゲーティング用回路から適宜選択された回路である。
 クロックイネーブル信号CE3は、ステートコントローラ32によって制御される。ステートコントローラ32の制御回路34は、デコードステートST2において、命令コマンドC3において指示されたデータ転送回路31の動作が実行不能であると判定した場合、実行可能となるまで待つ(Wait)。制御回路34は、上記の動作が実行可能となるまで待つ期間において、クロックイネーブル信号CE3をネゲートして無効(Disable)に設定する。その結果、ゲーティッドクロックGC3のトグルが停止される。ステートコントローラ32の制御回路34は、上記の動作が実行可能となりデコードステートST2から実行ステートST3に遷移するときに、クロックイネーブル信号CE3をアサートして有効(Enable)に設定する。その結果、制御回路34が実行ステートST3であるとき、ゲーティッドクロックGC3のトグルが再開される。
 生成されたゲーティッドクロックGC3は、図33に示すように、ステートコントローラ32の一部と、データ転送回路31とに対して出力され、動作クロックとして使用される。
 クロック制御部39は、アイドルステートST1において、クロックイネーブル信号CE3をネゲートして無効に設定してもよい。さらに、制御回路34は、アイドルステートST1において、ゲーティッドクロックGC3が提供される回路に対する電力提供を停止(パワーゲーティング)して、省電力モードに遷移してもよい。
[NN演算コア10G]
 NN演算コア10Gは、第一メモリ1と、第二メモリ2と、畳み込み演算回路4Gと、量子化演算回路5Gと、を備える。
[畳み込み演算回路4G]
 図35は、畳み込み演算回路4Gの内部ブロック図である。
 畳み込み演算回路4Gは、重みメモリ41と、乗算器42と、アキュムレータ回路43と、ステートコントローラ44と、クロック制御部49と、を有する。
 クロック制御部49は、NN回路100Gに供給されるクロックCKから、クロックイネーブル信号CE4に基づいて、ゲーティッドクロック(第一クロック)GC4を生成する。図34に示すように、クロックイネーブル信号CE4がネゲートされて無効(Disable)に設定されると、ゲーティッドクロックGC4のトグルが停止される。クロックイネーブル信号CE4がアサートされて有効(Enable)に設定されると、ゲーティッドクロックGC4のトグルが開始される。クロック制御部49は、第一DMAC3Gのクロック制御部39と同様の構成である。
 クロックイネーブル信号CE4は、ステートコントローラ44によって制御される。ステートコントローラ44の制御回路46は、デコードステートST2において、命令コマンドC4において指示された乗算器42やアキュムレータ回路43等の動作が実行不能であると判定した場合、実行可能となるまで待つ(Wait)。制御回路46は、上記の動作が実行可能となるまで待つ期間において、クロックイネーブル信号CE4をネゲートして無効(Disable)に設定する。その結果、ゲーティッドクロックGC4のトグルが停止される。ステートコントローラ44の制御回路46は、上記の動作が実行可能となりデコードステートST2から実行ステートST3に遷移するときに、クロックイネーブル信号CE4をアサートして有効(Enable)に設定する。その結果、制御回路46が実行ステートST3であるとき、ゲーティッドクロックGC4のトグルが再開される。
 生成されたゲーティッドクロックGC4は、図35に示すように、ステートコントローラ44の一部と、重みメモリ41と、乗算器42と、アキュムレータ回路43とに対して出力され、動作クロックとして使用される。
 クロック制御部49は、アイドルステートST1において、クロックイネーブル信号CE4をネゲートして無効に設定してもよい。さらに、制御回路46は、アイドルステートST1において、ゲーティッドクロックGC4が提供される回路に対する電力提供を停止(パワーゲーティング)して、省電力モードに遷移してもよい。
[量子化演算回路5G]
 図36は、量子化演算回路5Gの内部ブロック図である。
 量子化演算回路5Gは、量子化パラメータメモリ51と、ベクトル演算回路52と、量子化回路53と、ステートコントローラ54と、クロック制御部59と、を有する。
 クロック制御部59は、NN回路100Gに供給されるクロックCKから、クロックイネーブル信号CE5に基づいて、ゲーティッドクロック(第三クロック)GC5を生成する。図34に示すように、クロックイネーブル信号CE5がネゲートされて無効(Disable)に設定されると、ゲーティッドクロックGC5のトグルが停止される。クロックイネーブル信号CE5がアサートされて有効(Enable)に設定されると、ゲーティッドクロックGC5のトグルが開始される。クロック制御部59は、第一DMAC3Gのクロック制御部39と同様の構成である。
 クロックイネーブル信号CE5は、ステートコントローラ54によって制御される。ステートコントローラ54の制御回路56は、デコードステートST2において、命令コマンドC5において指示されたベクトル演算回路52や量子化回路53等の動作が実行不能であると判定した場合、実行可能となるまで待つ(Wait)。制御回路56は、上記の動作が実行可能となるまで待つ期間において、クロックイネーブル信号CE5をネゲートして無効(Disable)に設定する。その結果、ゲーティッドクロックGC5のトグルが停止される。ステートコントローラ54の制御回路56は、上記の動作が実行可能となりデコードステートST2から実行ステートST3に遷移するときに、クロックイネーブル信号CE5をアサートして有効(Enable)に設定する。その結果、制御回路56が実行ステートST3であるとき、ゲーティッドクロックGC5のトグルが再開される。
 生成されたゲーティッドクロックGC5は、図36に示すように、ステートコントローラ54の一部と、量子化パラメータメモリ51と、ベクトル演算回路52と、量子化回路53とに対して出力され、動作クロックとして使用される。
 クロック制御部59は、アイドルステートST1において、クロックイネーブル信号CE5をネゲートして無効に設定してもよい。さらに、制御回路56は、アイドルステートST1において、ゲーティッドクロックGC5が提供される回路に対する電力提供を停止(パワーゲーティング)して、省電力モードに遷移してもよい。
 本実施形態に係るニューラルネットワーク回路100Gによれば、クロックゲーティングやパワーゲーティングにより消費電力を削減することができる。第一DMAC3Gと畳み込み演算回路4Gと量子化演算回路5Gとは、それぞれ独立してクロックゲーティングやパワーゲーティングを実施する。
 以上、本発明の第三実施形態について図面を参照して詳述したが、具体的な構成はこの実施形態に限られるものではなく、本発明の要旨を逸脱しない範囲の設計変更等も含まれる。また、上述の実施形態および変形例において示した構成要素は適宜に組み合わせて構成することが可能である。
(第四実施形態)
 本発明の第四実施形態について、図37を参照して説明する。以降の説明において、既に説明したものと共通する構成については、同一の符号を付して重複する説明を省略する。第四実施形態に係るニューラルネットワーク回路100H(以下、「NN回路100H」という)は、第一実施形態に係るニューラルネットワーク回路100と比較して、マルチコア管理部11をさらに有する。
[NN回路100H]
 図37は、本実施形態に係るNN回路100Hの全体構成を示す図である。
 NN回路100Hは、第一DMAC3と、コントローラ6と、IFU7と、共有メモリ8と、第二DMAC9と、少なくとも一つのNN演算コア10と、マルチコア管理部11と、を備える。
 マルチコア管理部11は、NN演算マルチコア10Mの状態を監視して、NN演算コア10に供給するクロックや電力を管理する。NN演算マルチコア10Mのうち動作しているNN演算コア10に対してクロックや電力を供給し、動作していないNN演算コア10の少なくとも一部に対してクロックや電力を供給しない。すなわち、マルチコア管理部11は、NN演算コア10の動作状況に応じて、クロックゲーティングとパワーゲーティングの少なくとも一方をNN演算コア10ごとに実施する。NN回路100Hは、NN演算コア10を複数搭載することで演算性能を向上させることができ、かつ、回路規模増大に伴う消費電力の増加を好適に抑制できる。
 マルチコア管理部11は、動作可能なNN演算コア10を強制的に選択可能であってもよい。例えば、マルチコア管理部11は、一部のNN演算コア10を動作可能とし、他のNN演算コア10を動作不可と設定する。マルチコア管理部11は、動作不可と設定されたNN演算コア10に対してクロックと電力の提供を停止する。マルチコア管理部11は、動作可能なNN演算コア10を限定することで、演算性能の低下を伴うものの消費電力を低減できる。また、マルチコア管理部11は、全てのNN演算コア10を動作可能に設定することで、消費電力の増加を伴うものの演算性能を向上させることができる。
 本実施形態に係るニューラルネットワーク回路100Hによれば、クロックゲーティングやパワーゲーティングにより消費電力を削減することができる。マルチコア管理部11は、NN演算コア10ごとに独立してクロックゲーティングやパワーゲーティングを実施する。
 NN回路100Hは、第三実施形態における第一DMAC3G、畳み込み演算回路4Gおよび量子化演算回路5Gが実施するクロックゲーゲーティングやパワーゲーティングを併せて実施してもよい。
 以上、本発明の第四実施形態について図面を参照して詳述したが、具体的な構成はこの実施形態に限られるものではなく、本発明の要旨を逸脱しない範囲の設計変更等も含まれる。また、上述の実施形態および変形例において示した構成要素は適宜に組み合わせて構成することが可能である。
(変形例1)
 上記実施形態において、複数のNN演算コア10はデイジーチェーン接続されていたが、複数のNN演算コア10の接続態様はこれに限定されない。NN演算コア10は、少なくとも一つの他のNN演算コア10とデータ入出力可能に接続されていればよい。複数のNN演算コア10の接続態様が異なる場合も、NN回路100はデータフローごとに設けられたセマフォSを用いて制御される。
(変形例2)
 上記実施形態において、第一メモリ1と第二メモリ2は別のメモリであったが、第一メモリ1と第二メモリ2の態様はこれに限定されない。第一メモリ1と第二メモリ2は、例えば、同一メモリにおける第一メモリ領域と第二メモリ領域であってもよい。
(変形例3)
 上記実施形態において、セマフォSは第一データフロー(F11,F21)、第二データフロー(F12,F22)、第三データフロー(F13,F23)および第四データフロー(F14,F24)に対して設けられていたが、セマフォSの態様はこれに限定されない。セマフォSは、例えば、第一DMAC3が重みwを重みメモリ41に書き込み、乗算器42が重みwを読み出すデータフローに設けられていてもよい。セマフォSは、例えば、第一DMAC3が量子化パラメータqを量子化パラメータメモリ51に書き込み、量子化回路53が量子化パラメータqを読み出すデータフローに設けられていてもよい。
(変形例4)
 例えば、上記実施形態に記載のNN回路100に入力されるデータは単一の形式に限定されず、静止画像、動画像、音声、文字、数値およびこれらの組み合わせで構成することが可能である。なお、NN回路100に入力されるデータは、NN回路100が設けられるエッジデバイスに搭載され得る、光センサ、温度計、Global Positioning System(GPS)計測器、角速度計測器、風速計などの物理量測定器における測定結果に限られない。周辺機器から有線または無線通信経由で受信する基地局情報、車両・船舶等の情報、天候情報、混雑状況に関する情報などの周辺情報や金融情報や個人情報等の異なる情報を組み合わせてもよい。
(変形例5)
 NN回路100が設けられるエッジデバイスは、バッテリー等で駆動する携帯電話などの通信機器、パーソナルコンピュータなどのスマートデバイス、デジタルカメラ、ゲーム機器、ロボット製品などのモバイル機器を想定するが、これに限られるものではない。Power on Ethernet(PoE)などでの供給可能なピーク電力制限、製品発熱の低減または長時間駆動の要請が高い製品に利用することでも他の先行例にない効果を得ることができる。例えば、車両や船舶などに搭載される車載カメラや、公共施設や路上などに設けられる監視カメラ等に適用することで長時間の撮影を実現できるだけでなく、軽量化や高耐久化にも寄与する。また、テレビやディスプレイ等の表示デバイス、医療カメラや手術ロボット等の医療機器、製造現場や建築現場で使用される作業ロボットなどにも適用することで同様の効果を奏することができる。
(変形例6)
 NN回路100は、NN回路100の一部または全部を一つ以上のプロセッサを用いて実現してもよい。例えば、NN回路100は、入力層または出力層の一部または全部をプロセッサによるソフトウェア処理により実現してもよい。ソフトウェア処理により実現する入力層または出力層の一部は、例えば、データの正規化や変換である。これにより、様々な形式の入力形式または出力形式に対応できる。なお、プロセッサで実行するソフトウェアは、通信手段や外部メディアを用いて書き換え可能に構成してもよい。
(変形例7)
 NN回路100は、CNN200における処理の一部をクラウド上のGraphics Processing Unit(GPU)等を組み合わせることで実現してもよい。NN回路100は、NN回路100が設けられるエッジデバイスで行った処理に加えて、クラウド上でさらに処理を行ったり、クラウド上での処理に加えてエッジデバイス上で処理を行ったりすることで、より複雑な処理を少ないリソースで実現できる。このような構成によれば、NN回路100は、処理分散によりエッジデバイスとクラウドとの間の通信量を低減できる。
 また、本明細書に記載された効果は、あくまで説明的または例示的なものであって限定的ではない。つまり、本開示に係る技術は、上記の効果とともに、または上記の効果に代えて、本明細書の記載から当業者には明らかな他の効果を奏しうる。
 本発明は、ニューラルネットワークの演算に適用することができる。
200 畳み込みニューラルネットワーク
100,100B,100G,100H ニューラルネットワーク回路(NN回路)
10,10G ニューラルネットワーク演算コア(NN演算コア)
10A 第一ニューラルネットワーク演算コア(第一NN演算コア)
10B 第二ニューラルネットワーク演算コア(第二NN演算コア)
10M ニューラルネットワーク演算マルチコア(NN演算マルチコア)
11 マルチコア管理部
1 第一メモリ
2 第二メモリ
3,3G 第一DMAコントローラ(第一DMAC)
4,4B,4G 畳み込み演算回路
42,42B 乗算器
43 アキュムレータ回路
49 クロック制御部
5,5G 量子化演算回路
52 ベクトル演算回路
53 量子化回路
59 クロック制御部
6 コントローラ
61 レジスタ
7 IFU
8 共有メモリ
9 第二DMAコントローラ(第二DMAC)
S セマフォ
S1 第一セマフォ
S11R,S21R 第一リードセマフォ
S11W,S21W 第一ライトセマフォ
S2 第二セマフォ
S12R,S22R 第二リードセマフォ
S12W,S22W 第二ライトセマフォ
S3 第三セマフォ
S13R,S23R 第三リードセマフォ
S13W,S23W 第三ライトセマフォ
S4 第四セマフォ
S14R,S24R 第四リードセマフォ
S14W,S24W 第四ライトセマフォ
F11,F21 第一データフロー
F12,F22 第二データフロー
F13,F23 第三データフロー(ループバックデータフロー)
F14,F24 第四データフロー(バイパスデータフロー)

Claims (12)

  1.  畳み込み演算を行う畳み込み演算回路と、量子化演算を行う量子化演算回路と、を有するニューラルネットワーク演算コアを複数有し、
     前記複数のニューラルネットワーク演算コアは、データ入出力可能に接続されている、
     ニューラルネットワーク回路。
  2.  前記複数のニューラルネットワーク演算コアは、デイジーチェーン接続されている、
     請求項1に記載のニューラルネットワーク回路。
  3.  最終段以外の前記ニューラルネットワーク演算コアは、後段の前記ニューラルネットワーク演算コアに接続され、
     最終段の前記ニューラルネットワーク演算コアは、最初段の前記ニューラルネットワーク演算コアに接続されている、
     請求項1に記載のニューラルネットワーク回路。
  4.  前記ニューラルネットワーク演算コアは、
      前記畳み込み演算回路に入力される入力データを格納する第一メモリと、
      前記畳み込み演算回路の畳み込み演算出力データを格納する第二メモリと、
     を備え、
     前記量子化演算回路の量子化演算出力データは、前記第一メモリに格納されて、
     前記第一メモリに格納された前記量子化演算出力データは、前記畳み込み演算回路に前記入力データとして入力される、
     請求項1から請求項3のいずれか一項に記載のニューラルネットワーク回路。
  5.  前記ニューラルネットワーク演算コアである第一ニューラルネットワーク演算コアと第二ニューラルネットワーク演算コアにおいて、
     前記第一ニューラルネットワーク演算コアの前記量子化演算回路の前記量子化演算出力データは、前記第二ニューラルネットワーク演算コアの前記第一メモリに格納可能である、
     請求項4に記載のニューラルネットワーク回路。
  6.  前記ニューラルネットワーク演算コアにおいて、前記第一メモリと、前記畳み込み演算回路と、前記第二メモリと、前記量子化演算回路とは、ループ状に形成されている、
     請求項5に記載のニューラルネットワーク回路。
  7.  前記第一メモリと、前記畳み込み演算回路と、前記第二メモリと、前記量子化演算回路とは、同じ順番で繰り返し配列するよう接続されている、
     請求項6に記載のニューラルネットワーク回路。
  8.  前記第一ニューラルネットワーク演算コアの前記量子化演算回路が前記量子化演算出力データを前記第一ニューラルネットワーク演算コアの前記第一メモリに書き込み、前記第一ニューラルネットワーク演算コアの前記畳み込み演算回路が前記量子化演算出力データを読み出すデータフローを制御する第三セマフォと、
     前記第二ニューラルネットワーク演算コアの前記量子化演算回路が前記量子化演算出力データを前記第一ニューラルネットワーク演算コアの前記第一メモリに書き込み、前記第一ニューラルネットワーク演算コアの前記畳み込み演算回路が前記量子化演算出力データを読み出すデータフローを制御する第四セマフォと、
     を備える、
     請求項6に記載のニューラルネットワーク回路。
  9.  前記畳み込み演算回路は、前記畳み込み演算の実行を待ち合わせるとき、前記畳み込み演算回路の少なくとも一部に供給される第一クロックのクロックゲーティングを有効にする、
     請求項1に記載のニューラルネットワーク回路。
  10.  前記量子化演算回路は、前記量子化演算の実行を待ち合わせるとき、前記量子化演算回路の少なくとも一部に供給される第二クロックのクロックゲーティングを有効にする、
     請求項1に記載のニューラルネットワーク回路。
  11.  前記複数のニューラルネットワーク演算コアのそれぞれに供給するクロックを管理するマルチコア管理部をさらに有する、
     請求項1に記載のニューラルネットワーク回路。
  12.  第一ニューラルネットワーク演算コアと第二ニューラルネットワーク演算コアを用いるニューラルネットワーク演算方法であって、
     前記第一ニューラルネットワーク演算コアの出力データを、前記第一ニューラルネットワーク演算コアにループバックさせるループバックデータフローと、第二ニューラルネットワーク演算コアにバイパスさせるバイパスデータデータフローと、を切り替える、
     ニューラルネットワーク演算方法。
PCT/JP2022/046214 2022-01-24 2022-12-15 ニューラルネットワーク回路およびニューラルネットワーク演算方法 WO2023139990A1 (ja)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2022008692 2022-01-24
JP2022-008692 2022-01-24

Publications (1)

Publication Number Publication Date
WO2023139990A1 true WO2023139990A1 (ja) 2023-07-27

Family

ID=87348091

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2022/046214 WO2023139990A1 (ja) 2022-01-24 2022-12-15 ニューラルネットワーク回路およびニューラルネットワーク演算方法

Country Status (1)

Country Link
WO (1) WO2023139990A1 (ja)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2018133016A (ja) * 2017-02-17 2018-08-23 株式会社半導体エネルギー研究所 ニューラルネットワークシステム
JP2019047046A (ja) * 2017-09-06 2019-03-22 株式会社半導体エネルギー研究所 集積回路、コンピュータ及び電子機器
JP2020532780A (ja) * 2017-08-11 2020-11-12 グーグル エルエルシー チップ上に常駐するパラメータを用いたニューラルネットワークアクセラレータ
JP2021168095A (ja) * 2020-04-13 2021-10-21 LeapMind株式会社 ニューラルネットワーク回路、エッジデバイスおよびニューラルネットワーク演算方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2018133016A (ja) * 2017-02-17 2018-08-23 株式会社半導体エネルギー研究所 ニューラルネットワークシステム
JP2020532780A (ja) * 2017-08-11 2020-11-12 グーグル エルエルシー チップ上に常駐するパラメータを用いたニューラルネットワークアクセラレータ
JP2019047046A (ja) * 2017-09-06 2019-03-22 株式会社半導体エネルギー研究所 集積回路、コンピュータ及び電子機器
JP2021168095A (ja) * 2020-04-13 2021-10-21 LeapMind株式会社 ニューラルネットワーク回路、エッジデバイスおよびニューラルネットワーク演算方法

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
NAKAHARA YASUHIRO, AMAGASAKI MOTOKI, ZHAO QIAN, KIYAMA MASATO, IIDA MASAHIRO: "ReNA: A Reconfigurable Neural-Network Accelerator for AI Edge Computing", SASIMI 2021 PROCEEDINGS, 1 January 2021 (2021-01-01), pages 201 - 206, XP093079905 *

Similar Documents

Publication Publication Date Title
CN106228238B (zh) 现场可编程门阵列平台上加速深度学习算法的方法和系统
JP5089776B2 (ja) 浮動小数点演算のための再構成アレイプロセッサ
JP2001256199A (ja) データプロセッサ及びデータ処理システム
WO2021210527A1 (ja) ニューラルネットワーク回路の制御方法
TWI773245B (zh) 神經網路電路、網路終端設備及神經網路運算方法
US20240095522A1 (en) Neural network generation device, neural network computing device, edge device, neural network control method, and software generation program
US7769981B2 (en) Row of floating point accumulators coupled to respective PEs in uppermost row of PE array for performing addition operation
WO2023139990A1 (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
CN117112165A (zh) 虚拟现实应用任务的处理方法、装置、虚拟现实系统
CN116795324A (zh) 混合精度浮点乘法装置和混合精度浮点数处理方法
WO2023058422A1 (ja) ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法
WO2024111644A1 (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
KR102667790B1 (ko) 뉴럴 네트워크 회로, 에지 디바이스 및 뉴럴 네트워크 연산 방법
WO2024038662A1 (ja) ニューラルネットワーク学習装置およびニューラルネットワーク学習方法
JP2024075106A (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
JP2022183833A (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
WO2022085661A1 (ja) ニューラルネットワーク生成装置、ニューラルネットワーク制御方法およびソフトウェア生成プログラム
JP2022105437A (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
JP6931252B1 (ja) ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法
WO2022004815A1 (ja) ニューラルネットワーク生成装置、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラム
WO2022230906A1 (ja) ニューラルネットワーク生成装置、ニューラルネットワーク演算装置、エッジデバイス、ニューラルネットワーク制御方法およびソフトウェア生成プログラム
JP2022114698A (ja) ニューラルネットワーク生成装置、ニューラルネットワーク制御方法およびソフトウェア生成プログラム
JP2023154880A (ja) ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラム
JP2023006509A (ja) ソフトウェア生成装置およびソフトウェア生成方法
JP2023506343A (ja) 共有スクラッチパッドメモリを用いたベクトル縮小

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

Country of ref document: EP

Kind code of ref document: A1