WO2022030037A1 - ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法 - Google Patents

ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法 Download PDF

Info

Publication number
WO2022030037A1
WO2022030037A1 PCT/JP2021/005610 JP2021005610W WO2022030037A1 WO 2022030037 A1 WO2022030037 A1 WO 2022030037A1 JP 2021005610 W JP2021005610 W JP 2021005610W WO 2022030037 A1 WO2022030037 A1 WO 2022030037A1
Authority
WO
WIPO (PCT)
Prior art keywords
circuit
quantization
memory
convolution
instruction
Prior art date
Application number
PCT/JP2021/005610
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株式会社
Priority to US18/019,365 priority Critical patent/US20230289580A1/en
Priority to CN202180057849.0A priority patent/CN116113926A/zh
Publication of WO2022030037A1 publication Critical patent/WO2022030037A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0464Convolutional networks [CNN, ConvNet]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/06Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
    • G06N3/063Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3836Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution
    • G06F9/3842Speculative instruction execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0495Quantised networks; Sparse networks; Compressed networks

Definitions

  • the present invention relates to a neural network circuit and a method for controlling a neural network circuit.
  • a convolutional neural network has been used as a model for image recognition and the like.
  • a convolutional neural network has a multi-layered structure having a convolutional layer and a pooling layer, and requires a large number of operations such as a convolutional operation.
  • Various arithmetic methods have been devised to speed up the arithmetic by the convolutional neural network (Patent Document 1 and the like).
  • the neural network circuit includes a convolution operation circuit that performs a convolution operation on input data, and a quantization operation circuit that performs a quantization operation on the convolution operation output data of the convolution operation circuit.
  • An instruction fetch unit that reads an instruction command for operating the convolution operation circuit or the quantization operation circuit from an external memory.
  • the control method of the neural network circuit is a convolution operation circuit that performs a convolution operation on input data and a quantization operation that performs a quantization operation on the convolution operation output data of the convolution operation circuit. It is a control method of a neural network circuit including an arithmetic circuit and an instruction fetch unit for reading an instruction command for operating the convolution arithmetic circuit or the quantization arithmetic circuit from a memory, and the instruction command is transmitted to the instruction fetch unit. The step of reading from the memory and supplying the instruction command to the convolution operation circuit or the quantization operation circuit, and the convolution operation circuit or the quantization operation circuit based on the supplied instruction command. It has steps to operate.
  • the neural network circuit of the present invention can be incorporated into an embedded device such as an IoT device and has high performance.
  • the control method of the neural network circuit of the present invention can improve the arithmetic processing capacity of the neural network circuit.
  • FIG. 1 is a diagram showing a convolutional neural network 200 (hereinafter referred to as “CNN200”).
  • CNN200 convolutional neural network 200
  • the CNN 200 is a multi-layered network including a convolution layer 210 for performing a convolution operation, a quantization calculation layer 220 for performing a quantization calculation, and an output layer 230. In at least a part of the CNN 200, the convolution layer 210 and the quantization calculation layer 220 are alternately connected.
  • the CNN200 is a model widely used for image recognition and video recognition.
  • the CNN 200 may further have a layer having other functions such as a fully bonded layer.
  • FIG. 2 is a diagram illustrating a convolution operation performed by the convolution layer 210.
  • the convolution layer 210 performs a convolution operation using the weight w on the input data a.
  • the convolution layer 210 performs a product-sum operation with the input data a and the weight w as inputs.
  • the input data a (also referred to as 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 composed of elements (x, y, c).
  • the convolution layer 210 of the CNN 200 performs a convolution operation on the low-bit input data a.
  • the element of the input data a is a 2-bit unsigned integer (0, 1, 2, 3).
  • the element of the input data a may be, for example, a 4-bit or 8-bit unsigned integer.
  • the CNN200 When the input data input to the CNN200 has a different format from the input data a to the convolutional layer 210, for example, a 32-bit floating point type, the CNN200 inserts an input layer for type conversion or quantization before the convolutional layer 210. You may also have more.
  • the weight w (also referred to as a filter or kernel) of the convolution layer 210 is multidimensional data having elements that are learnable parameters.
  • the weight w is a four-dimensional tensor composed of elements (i, j, c, d).
  • the weight w has d three-dimensional tensors (hereinafter referred to as “weight w”) composed of elements (i, j, c).
  • the weight w in the trained CNN 200 is the trained data.
  • the convolution layer 210 of the CNN 200 performs a convolution operation using a low bit weight w.
  • the element of the weight w is a 1-bit signed integer (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 the output data f.
  • s represents a stride.
  • the area shown by the dotted line in FIG. 2 indicates one of the areas ao (hereinafter referred to as “applicable area ao”) to which the weight wo is applied to the input data a.
  • the element of the application area ao is represented by (x + i, y + j, c).
  • the quantization calculation layer 220 performs quantization or the like on the output of the convolution calculation output by the convolution layer 210.
  • the quantization calculation layer 220 includes a pooling layer 221, a Batch Normalization layer 222, an activation function layer 223, and a quantization layer 224.
  • the pooling layer 221 performs operations such as average pooling (Equation 2) and MAX pooling (Equation 3) on the output data f of the convolution operation output by the convolution layer 210, and compresses the output data f of the convolution layer 210. do.
  • Equations 2 and 3 u indicates an input tensor, v indicates an output tensor, and T indicates the size of the pooling region.
  • max is a function that outputs the maximum value of u for the combination of i and j contained in T.
  • the Batch Normalization layer 222 normalizes the data distribution of the output data of the quantization calculation layer 220 and the pooling layer 221 by, for example, the calculation shown in Equation 4.
  • Equation 4 u represents an input tensor, v represents an output tensor, ⁇ represents a scale, and ⁇ represents a bias.
  • ⁇ and ⁇ are trained constant vectors.
  • the activation function layer 223 performs an activation function calculation such as ReLU (Equation 5) on the outputs of the quantization calculation layer 220, the pooling layer 221 and the Batch rectification layer 222.
  • ReLU Error 5
  • u is the input tensor and v is the output tensor.
  • max is a function that outputs the largest numerical value among the arguments.
  • the quantization layer 224 quantizes the outputs of the pooling layer 221 and the activation function layer 223, for example, as shown in Equation 6 based on the quantization parameters.
  • the quantization shown in Equation 6 reduces the input tensor u to 2 bits.
  • q (c) is a vector of quantization parameters.
  • q (c) is a trained constant vector.
  • the inequality “ ⁇ ” in Equation 6 may be “ ⁇ ”.
  • the output layer 230 is a layer that outputs the result of CNN200 by an identity function, a softmax function, or the like.
  • the layer in front of the output layer 230 may be a convolution layer 210 or a quantization calculation layer 220.
  • the load of the convolutional operation of the convolutional layer 210 is smaller than that of other convolutional neural networks that do not perform quantization. ..
  • the NN circuit 100 divides the input data of the convolution calculation (Equation 1) of the convolution layer 210 into partial tensors and performs the calculation.
  • the method of dividing into partial tensors and the number of divisions are not particularly limited.
  • the partial tensor is formed, for example, by dividing the input data a (x + i, y + j, c) into a (x + i, y + j, co).
  • the NN circuit 100 can also perform calculations without dividing the input data of the convolution calculation (Equation 1) of the convolution layer 210.
  • the variable c in the equation 1 is divided into blocks of size Bc as shown in the equation 7. Further, the variable d in the equation 1 is divided into blocks of size Bd as shown in the equation 8.
  • co is an offset and ci is an index from 0 to (Bc-1).
  • do is the offset and di is the index from 0 to (Bd-1).
  • 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 is 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 the 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). To. In the following description, the divided weight w is also referred to as “divided weight w”.
  • the output data f (x, y, do) divided by the size Bd can be obtained by Equation 9.
  • the final output data f (x, y, d) can be calculated.
  • the NN circuit 100 expands the input data a and the weight w in the convolution operation of the convolution layer 210 to perform the convolution operation.
  • FIG. 3 is a diagram illustrating the expansion of data in the convolution operation.
  • the divided input data a (x + i, y + j, co) is expanded into vector data having Bc elements.
  • the element of the divided input data a is indexed by ci (0 ⁇ ci ⁇ Bc).
  • the divided input data a expanded into vector data for each i and j is also referred to as “input vector A”.
  • the input vector A has elements from the divided input data a (x + i, y + j, co ⁇ Bc) to the divided input data a (x + i, y + j, co ⁇ Bc + (Bc-1)).
  • the division weight w (i, j, co, do) is expanded into matrix data having Bc ⁇ Bd elements.
  • the element of the division weight w expanded in the matrix data is indexed by ci and di (0 ⁇ di ⁇ Bd).
  • the division weight w expanded in the matrix data for each i and j is also referred to as “weight matrix W”.
  • the weight matrix W has a division weight w (i, j, co ⁇ Bc, do ⁇ Bd) to a division weight w (i, j, co ⁇ Bc + (Bc-1), do ⁇ Bd + (Bd-1)). Make it an element.
  • Vector data is calculated by multiplying the input vector A and the weight matrix W.
  • the output data f (x, y, do) can be obtained by shaping the vector data calculated for each i, j, and co into a three-dimensional tensor. By expanding such data, 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 the present embodiment.
  • the NN circuit 100 includes a first memory 1, a second memory 2, a DMA controller 3 (hereinafter, also referred to as “DMAC3”), a convolution calculation circuit 4, a quantization calculation circuit 5, and a controller 6. ..
  • the NN circuit 100 is characterized in that the convolution calculation circuit 4 and the quantization calculation circuit 5 are formed in a loop shape via the first memory 1 and the second memory 2.
  • the NN circuit 100 is connected to the external host CPU 110 and the external memory 120 via the external bus EB.
  • the external host CPU 110 includes a general-purpose CPU.
  • the external memory 120 includes a memory such as a DRAM and a control circuit thereof.
  • the external memory 120 stores a program executed by the external host CPU 110 and various data.
  • the external bus EB connects the external host CPU 110, the external memory 120, and the NN circuit 100.
  • 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 DMAC 3 and the controller 6.
  • the first memory 1 is connected to the input port of the convolution calculation circuit 4, and the convolution calculation circuit 4 can read data from the first memory 1. Further, the first memory 1 is connected to the output port of the quantization calculation circuit 5, and the quantization calculation circuit 5 can write data to the first memory 1.
  • the external host CPU 110 can input / output data to / from the NN circuit 100 by writing / reading data to / from the first memory 1.
  • 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 DMAC 3 and the controller 6.
  • the second memory 2 is connected to the input port of the quantization calculation circuit 5, and the quantization calculation circuit 5 can read data from the second memory 2. Further, the second memory 2 is connected to the output port of the convolution calculation circuit 4, and the convolution calculation circuit 4 can write data to the second memory 2.
  • the external host CPU 110 can input / output data to / from the NN circuit 100 by writing / reading data to / from the second memory 2.
  • the DMAC 3 is connected to the external bus EB and transfers data between the external memory 120 and the first memory 1. Further, the DMAC 3 transfers data between the external memory 120 and the second memory 2. Further, the DMAC 3 transfers data between the external memory 120 and the convolution calculation circuit 4. Further, the DMAC 3 transfers data between the external memory 120 and the quantization calculation circuit 5.
  • the convolution calculation circuit 4 is a circuit that performs a convolution calculation in the convolution layer 210 of the trained CNN 200.
  • the convolution calculation circuit 4 reads the input data a stored in the first memory 1 and performs the convolution calculation on the input data a.
  • the convolution calculation circuit 4 writes the output data f of the convolution operation (hereinafter, also referred to as “convolution operation output data”) to the second memory 2.
  • the quantization calculation circuit 5 is a circuit that performs at least a part of the quantization calculation in the quantization calculation layer 220 of the trained CNN200.
  • the quantization operation circuit 5 reads out the output data f of the convolution operation stored in the second memory 2, and for the output data f of the convolution operation, the quantization operation (pooling, Batch Nomalization, activation function, and quantization). Of these, at least operations including quantization) are performed.
  • the quantization calculation circuit 5 writes the output data of the quantization calculation (hereinafter, also referred to as “quantization calculation output data”) to the first memory 1.
  • the controller 6 is connected to the external bus EB and operates as a master and a slave to the external bus EB.
  • the controller 6 has a bus bridge 60, a register 61, and an IFU 62.
  • the register 61 has a parameter register and a status register.
  • the parameter register is a register that controls the operation of the NN circuit 100.
  • the status register is a register indicating the state of the NN circuit 100 including the semaphore S.
  • the external host CPU 110 can access the register 61 via the bus bridge 60 of the controller 6.
  • the IFU (Instruction Fetch Unit, instruction fetch unit) 62 reads instruction commands for the DMAC 3, the convolution operation circuit 4, and the quantization operation circuit 5 from the external memory 120 via the external bus EB based on the instruction of the external host CPU 110. .. Further, the IFU 62 transfers the read instruction command to the corresponding DMAC3, the convolution calculation circuit 4, and the quantization calculation circuit 5.
  • the controller 6 includes the first memory 1, the second memory 2, the DMAC 3, the convolution operation circuit 4, and the convolution operation circuit 4 via the internal bus IB (see FIG. 4) and the dedicated wiring connected to the IFU 62 (see FIG. 7). It is connected to the quantization calculation circuit 5.
  • the external host CPU 110 can access each block via the controller 6. For example, the external host CPU 110 can instruct instructions to the DMAC 3, the convolution calculation circuit 4, and the quantization calculation circuit 5 via the controller 6.
  • the DMAC 3, the convolution calculation circuit 4, and the quantization calculation circuit 5 can update the state registers (including the semaphore S) of the controller 6 via the internal bus IB.
  • the state register (including the semaphore S) may be configured to be updated via a dedicated wiring connected to the DMAC 3, the convolution calculation circuit 4, and the quantization calculation circuit 5.
  • the NN circuit 100 Since the NN circuit 100 has the first memory 1, the second memory 2, and the like, the number of times of data transfer of duplicated data can be reduced in the data transfer by the DMAC 3 from the external memory 120. As a result, the power consumption generated by the memory access can be significantly reduced.
  • FIG. 5 is a timing chart showing an operation example of the NN circuit 100.
  • the DMAC 3 stores the input data a of the layer 1 in the first memory 1.
  • the DMAC 3 may divide the input data a of the layer 1 and transfer it to the first memory 1 in accordance with the order of the convolution operations performed by the convolution operation circuit 4.
  • the convolution calculation circuit 4 reads the input data a of the layer 1 stored in the first memory 1.
  • the convolution calculation circuit 4 performs the layer 1 convolution operation shown in FIG. 1 with respect to 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 calculation circuit 5 reads out the output data f of the layer 1 stored in the second memory 2.
  • the quantization calculation circuit 5 performs a layer 2 quantization calculation on the output data f of the layer 1.
  • the output data of the layer 2 quantization operation is stored in the first memory 1.
  • the convolution operation circuit 4 reads out the output data of the layer 2 quantization operation stored in the first memory 1.
  • the convolution operation circuit 4 performs the convolution operation of the layer 3 by using the output data of the quantization operation of the layer 2 as the 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 out 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 by using the output data of the quantization operation of the layer 2M-2 as the input data a.
  • the output data f of the convolution operation of the layer 2M-1 is stored in the second memory 2.
  • the quantization calculation circuit 5 reads out the output data f of the layer 2M-1 stored in the second memory 2.
  • the quantization calculation circuit 5 performs a layer 2M quantization calculation on the output data f of the 2M-1 layer.
  • the output data of the layer 2M quantization operation is stored in the first memory 1.
  • the convolution operation circuit 4 reads out the output data of the layer 2M quantization operation stored in the first memory 1.
  • the convolution operation circuit 4 performs the convolution operation of the layer 2M + 1 by using the output data of the quantization operation of the layer 2M as the input data a.
  • the output data f of the convolution operation of the layer 2M + 1 is stored in the second memory 2.
  • the convolution calculation circuit 4 and the quantization calculation circuit 5 alternately perform calculations, and proceed with the calculation of CNN200 shown in FIG.
  • the convolution calculation circuit 4 performs the convolution calculation of the layer 2M-1 and the layer 2M + 1 by time division.
  • the quantization calculation circuit 5 performs the convolution calculation of the layer 2M-2 and the layer 2M by time division. Therefore, the circuit scale of the NN circuit 100 is significantly smaller than that in the case where the convolution calculation circuit 4 and the quantization calculation circuit 5 are separately mounted for each layer.
  • the NN circuit 100 calculates the operation of the CNN 200, which is a multi-layer structure of a plurality of layers, by a circuit formed in a loop shape.
  • the NN circuit 100 can efficiently use hardware resources due to the loop-shaped circuit configuration.
  • the parameters in the convolution calculation circuit 4 and the quantization calculation circuit 5 that change in each layer are updated as appropriate.
  • the NN circuit 100 transfers intermediate data to an external calculation device such as an external host CPU 110. After the external arithmetic device performs the 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 circuit 100 restarts the calculation on the calculation result by the external calculation device.
  • an external calculation device such as an external host CPU 110.
  • FIG. 6 is a timing chart showing another operation example of the NN circuit 100.
  • the NN circuit 100 may divide the input data a into partial tensors and perform operations on the partial tensors by time division.
  • the method of dividing into partial tensors and the number of divisions are not particularly limited.
  • FIG. 6 shows an operation example when the input data a is decomposed into two partial tensors.
  • the decomposed partial tensors are referred to as "first partial tensor a 1 " and "second partial tensor a 2 ".
  • the convolution operation of the layer 2M-1 corresponds to the convolution operation corresponding to the first partial tensor a 1 (denoted as “Layer 2M-1 (a 1 )" in FIG. 6) and the second partial tensor a 2 . It is decomposed into a convolution operation (denoted as "Layer 2M-1 (a 2 )" in FIG. 6).
  • the convolution operation and the quantization operation corresponding to the first part tensor a 1 and the convolution operation and the quantization operation corresponding to the second part tensor a 2 can be performed independently.
  • the convolution calculation circuit 4 performs a convolution operation of the layer 2M- 1 corresponding to the first partial tensor a1 (the operation shown by the layer 2M-1 (a 1 ) in FIG. 6). After that, the convolution calculation circuit 4 performs the convolution operation of the layer 2M-1 corresponding to the second partial tensor a2 (the operation shown by the layer 2M-1 ( a2 ) in FIG. 6). Further, the quantization calculation circuit 5 performs a layer 2M quantization operation (operation shown by layer 2M (a 1 ) in FIG. 6) corresponding to the first partial tensor a1. As described above, the NN circuit 100 can perform the convolution operation of the layer 2M-1 corresponding to the second partial tensor a 2 and the quantization operation of the layer 2M corresponding to the first partial tensor a 1 in parallel.
  • the convolution calculation circuit 4 performs a convolution operation of layer 2M + 1 corresponding to the first partial tensor a 1 (operation shown by layer 2M + 1 (a 1 ) in FIG. 6). Further, the quantization calculation circuit 5 performs a layer 2M quantization operation (operation shown by layer 2M (a 2 ) in FIG. 6) corresponding to the second partial tensor a 2 . As described above, the NN circuit 100 can perform the convolution operation of the layer 2M + 1 corresponding to the first partial tensor a 1 and the quantization operation of the layer 2M corresponding to the second partial tensor a 2 in parallel.
  • the NN circuit 100 can operate the convolution calculation circuit 4 and the quantization calculation circuit 5 in parallel. As a result, the waiting time of the convolution calculation circuit 4 and the quantization calculation circuit 5 is reduced, and the calculation processing efficiency of the NN circuit 100 is improved.
  • the number of divisions is 2, but similarly, when the number of divisions is larger than 2, the NN circuit 100 can operate the convolution operation circuit 4 and the quantization operation circuit 5 in parallel. can.
  • an example (method 1) in which the operation of the partial tensor in the same layer is performed by the convolution operation circuit 4 or the quantization operation circuit 5 and then the operation of the partial tensor in the next layer is shown. ..
  • the convolution operation of the layer 2M-1 corresponding to the first partial tensor a 1 and the second partial tensor a 2 in FIG. 6, layer 2M-1 (a 1 )).
  • the operation shown by layer 2 M-1 (a 2 )) and then the convolution operation of layer 2 M + 1 corresponding to the first partial tensor a 1 and the second partial tensor a 2 (in FIG. 6, layer 2 M + 1 (a 1 ) and The operation shown by layer 2M + 1 (a 2 )) is performed.
  • the calculation method for the partial tensor is not limited to this.
  • the calculation method for the partial tensor may be a method in which the calculation of the partial tensor in a plurality of layers is performed and then the calculation of the remaining partial tensor is performed (method 2).
  • method 2 For example, in the convolution operation circuit 4, after performing the convolution operation of the layer 2M- 1 corresponding to the first partial tensor a1 and the layer 2M + 1 corresponding to the first partial tensor a1, the layer 2M corresponding to the second partial tensor a2.
  • the convolution operation of the layer 2M + 1 corresponding to -1 and the second partial tensor a 2 may be performed.
  • the calculation method for the partial tensor may be a method of calculating the partial tensor by combining the method 1 and the method 2.
  • the method 2 it is necessary to perform the operation according to the dependency on the operation order of the partial tensors.
  • FIG. 7 is a diagram showing a dedicated wiring for connecting the IFU 62 of the controller 6 and the DMAC3 and the like.
  • the DMAC 3 includes a data transfer circuit (not shown) and a state controller 32.
  • the DMAC 3 has a state controller 32 dedicated to the data transfer circuit, and when the instruction command C3 is input, the DMA data transfer can be performed without the need for an external controller.
  • the state controller 32 controls the state of the data transfer circuit. Further, the state controller 32 is connected to the controller 6 via the internal bus IB (see FIG. 4) and the dedicated wiring connected to the IFU 62 (see FIG. 7).
  • the state controller 32 has an instruction queue 33 and a control circuit 34.
  • the instruction queue 33 is a queue in which an instruction command (third instruction command) C3 for DMAC3 is stored, and is composed of, for example, a FIFO memory.
  • One or more instruction commands C3 are written to the instruction queue 33 via the internal bus IB or IFU62.
  • the instruction queue 33 outputs an empty flag indicating that the number of instruction commands C3 to be stored is "0" and a full flag indicating that the number of instruction commands C3 to be stored is the maximum value.
  • the instruction queue 33 may output a half-empty flag or the like indicating that the number of instruction commands C3 to be stored is half or less of the maximum value.
  • the impty flag and full flag of the instruction queue 33 are stored as the status register of the register 61.
  • the external host CPU 110 can confirm the status of flags such as the empty flag and the full flag by reading the status register of the register 61.
  • the control circuit 34 is a state machine that decodes the instruction command C3 and controls the data transfer circuit 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. 8 is a state transition diagram of the control circuit 34.
  • the control circuit 34 detects that the instruction command C3 has been input to the instruction queue 33 based on the impty flag of the instruction queue 33 (Not expense), the control circuit 34 transitions from the idle state S1 to the decode state S2.
  • the control circuit 34 decodes the instruction command C3 output from the instruction queue 33 in the decode state S2. Further, the control circuit 34 reads the semaphore S stored in the register 61 of the controller 6 and determines whether or not the operation of the data transfer circuit instructed by the instruction command C3 can be executed. If it is infeasible (Not ready), the control circuit 34 waits until it becomes executable (Wait). If it is executable, the control circuit 34 transitions from the decode state S2 to the execution state S3.
  • the control circuit 34 controls the data transfer circuit in the execution state S3, and causes the data transfer circuit to perform the operation instructed by the instruction command C3.
  • the control circuit 34 sends a p Moderatorp command to the instruction queue 33, removes the instruction command C3 that has been executed from the instruction queue 33, and has a semaphore stored in the register 61 of the controller 6.
  • Update S When the control circuit 34 detects that there is an instruction in the instruction queue 33 based on the impty flag of the instruction queue 33 (Not expense), the control circuit 34 transitions from the execution state S3 to the decode state S2. When the control circuit 34 detects that there is no instruction in the instruction queue 33 (empty), the control circuit 34 transitions from the execution state S3 to the idle state S1.
  • the convolution operation circuit 4 includes an operation circuit (not shown) such as a multiplier and a state controller 44.
  • the convolution calculation circuit 4 has a state controller 44 dedicated to a calculation circuit such as a multiplier, and when the instruction command C4 is input, the convolution calculation can be performed without the need for an external controller.
  • the state controller 44 controls the state of an arithmetic circuit such as a multiplier. Further, the state controller 44 is connected to the controller 6 via the internal bus IB (see FIG. 4) and the dedicated wiring connected to the IFU 62 (see FIG. 7). 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 (first instruction command) C4 for the convolution operation circuit 4 is stored, and is composed of, for example, a FIFO memory.
  • the instruction command C4 is written to the instruction queue 45 via the internal bus IB or IFU62.
  • the instruction queue 45 has the same configuration as the instruction queue 33 of the state controller 32 of the DMAC3.
  • the control circuit 46 is a state machine that decodes the instruction command C4 and controls an arithmetic circuit such as a multiplier 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 DMAC3.
  • the quantization calculation circuit 5 includes a quantization circuit and the like (not shown) and a state controller 54.
  • the quantization calculation circuit 5 has a state controller 54 dedicated to the quantization circuit and the like, and when the instruction command C5 is input, the quantization calculation can be performed without the need for an external controller.
  • the state controller 54 controls the state of the quantization circuit or the like. Further, the state controller 54 is connected to the controller 6 via the internal bus IB (see FIG. 4) and the dedicated wiring connected to the IFU 62 (see FIG. 7).
  • 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 (second instruction command) C5 for the quantization calculation circuit 5 is stored, and is composed of, for example, a FIFO memory.
  • the instruction command C5 is written to the instruction queue 55 via the internal bus IB or IFU62.
  • the instruction queue 55 has the same configuration as the instruction queue 33 of the state controller 32 of the DMAC3.
  • the control circuit 56 is a state machine that decodes the instruction command C5 and controls the quantization circuit or the like 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 DMAC3.
  • the controller 6 is connected to the external bus EB and operates as a master and a slave to the external bus EB.
  • the controller 6 has a bus bridge 60, a register 61 including a parameter register and a status register, and an IFU 62.
  • the parameter register is a register that controls the operation of the NN circuit 100.
  • the status register is a register indicating the state of the NN circuit 100 including the semaphore S.
  • the bus bridge 60 relays bus access from the external bus EB to the internal bus IB. Further, the bus bridge 60 relays a write request and a read request from the external host CPU 110 to the register 61. Further, the bus bridge 60 relays the read request from the IFU 62 to the external memory 120 to the external bus EB.
  • the external bus EB is an interconnect compliant with a standard such as AXI (registered trademark).
  • AXI registered trademark
  • the external bus EB is a standard-compliant interconnect such as PCI-Express®.
  • the bus bridge 60 has a protocol conversion circuit corresponding to the standard of the external bus EB to be connected.
  • the controller 6 transfers an instruction command to the instruction queue of the DMAC 3, the convolution operation circuit 4, and the quantization operation circuit 5 by two methods.
  • the first method is a method of transferring an instruction command transferred from the external host CPU 110 to the controller 6 via the internal bus IB (see FIG. 4).
  • the second method is a method in which the IFU 62 reads the instruction command from the external memory 120 and transfers the instruction command via the dedicated wiring (see FIG. 7) connected to the IFU 62.
  • the IFU (Instruction Fetch Unit) 62 has a plurality of fetch units 63 and an interrupt generation circuit 64.
  • the fetch unit 63 reads an instruction command from the external memory 120 via the external bus EB based on the instruction of the external host CPU 110. Further, the fetch unit 63 supplies the read instruction command to the corresponding instruction queue such as DMAC3.
  • the fetch unit 63 has an instruction pointer 65 and an instruction counter 66.
  • the external host CPU 110 can write and read to the instruction pointer 65 and the instruction counter 66 via the external bus EB.
  • the instruction pointer 65 holds the memory address of the external host CPU 110 in which the instruction command is stored.
  • the instruction counter 66 holds the number of commands of the stored instruction command.
  • the instruction counter 66 is initialized to "0".
  • the fetch unit 63 refers to the instruction pointer 65 and reads an instruction command from the external memory 120.
  • the controller 6 operates as a master for the external bus EB.
  • the fetch unit 63 updates the instruction pointer 65 and the instruction counter 66 each time the instruction command is read.
  • the instruction counter 66 is decremented each time an instruction command is read.
  • the fetch unit 63 reads an instruction command until the instruction counter 66 becomes “0”.
  • the fetch unit 63 sends a push command to the corresponding instruction queue such as DMAC3, and writes the read instruction command to the corresponding instruction queue such as DMAC3. However, when the full flag of the instruction queue is "1 (true)", the fetch unit 63 does not write to the instruction queue until the full flag becomes "0 (false)".
  • the fetch unit 63 can efficiently read the instruction command via the external bus EB by referring to the instruction queue flag and the instruction counter 66 and using burst transfer as needed.
  • the fetch unit 63 is provided for each instruction queue.
  • the fetch unit 63 for the instruction queue 33 of the DMAC3 is referred to as the “fetch unit 63A (third fetch unit)”
  • the fetch unit 63 for the instruction queue 45 of the convolution arithmetic circuit 4 is referred to as the “fetch unit 63B (first fetch unit)”.
  • the fetch unit 63 for the instruction queue 55 of the quantization operation circuit 5 is referred to as“ fetch unit 63C (second fetch unit) ”.
  • the reading of instruction commands by the fetch unit 63A, the fetch unit 63B, and the fetch unit 63C via the external bus EB is arbitrated by the bus bridge 60, for example, by the priority control of the round robin method.
  • the interrupt generation circuit 64 monitors the instruction counter 66 of the fetch unit 63, and when the instruction counter 66 of all the fetch units 63 becomes "0", an interrupt may be generated to the external host CPU 110. can.
  • the external host CPU 110 can detect the completion of reading the instruction command by the IFU 62 by the above interrupt without polling the status register of the register 61.
  • FIG. 9 is a diagram illustrating control of the NN circuit 100 by the semaphore S.
  • the semaphore S has a first semaphore S1, a second semaphore S2, and a third semaphore S3.
  • the semaphore S is decremented by the P operation and incremented by the V operation.
  • the P operation and V operation by the 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.
  • the first semaphore S1 is used to control the first data flow F1.
  • the first data flow F1 is a data flow in which the DMAC3 (Producer) writes the input data a to the first memory 1 and the convolution calculation circuit 4 (Consumer) reads the input data a.
  • the first semaphore S1 has a first light semaphore S1W and a first lead semaphore S1R.
  • the second semaphore S2 is used to control the second data flow F2.
  • the second data flow F2 is a data flow in which the convolution calculation circuit 4 (Producer) writes the output data f to the second memory 2, and the quantization calculation circuit 5 (Consumer) reads the output data f.
  • the second semaphore S2 has a second light semaphore S2W and a second lead semaphore S2R.
  • the third semaphore S3 is used to control the third data flow F3.
  • the quantization calculation circuit 5 (Producer) writes the quantization calculation output data to the first memory 1
  • the convolution calculation circuit 4 (Consumer) reads the quantization calculation output data of the quantization calculation circuit 5. It is a data flow.
  • the third semaphore S3 has a third light semaphore S3W and a third lead semaphore S3R.
  • FIG. 10 is a timing chart of the first data flow F1.
  • the first write semaphore S1W is a semaphore that limits writing to the first memory 1 by DMAC3 in the first data flow F1.
  • the first write semaphore S1W determines the number of memory areas in the first memory 1 that can store data of a predetermined size, such as an input vector A, for which data has already been read and other data can be written. Shows.
  • the DMAC3 cannot write to the first memory 1 in the first data flow F1, and waits until the first write semaphore S1W becomes "1" or more.
  • the first read semaphore S1R is a semaphore that limits reading from the first memory 1 by the convolution operation circuit 4 in the first data flow F1.
  • the first read semaphore S1R indicates the number of memory areas in the first memory 1 that can store data of a predetermined size, such as an input vector A, in which the data has been written and can be read.
  • the convolution calculation circuit 4 cannot read from the first memory 1 in the first data flow F1, and waits until the first read semaphore S1R becomes "1" or more.
  • DMAC3 starts DMA transfer when the instruction command C3 is stored in the instruction queue 33. As shown in FIG. 10, since the first light semaphore S1W is not "0", the DMAC3 starts the DMA transfer (DMA transfer 1). The DMAC3 performs a P operation on the first light semaphore S1W when starting the DMA transfer. The DMAC3 sends a p réellep command to the instruction queue 33 after the completion of the DMA transfer instructed by the instruction command C3, removes the instruction command C3 that has been executed from the instruction queue 33, and sends the instruction command C3 to the first read semaphore S1R. Perform V operation.
  • the convolution calculation circuit 4 starts the convolution operation by storing the instruction command C4 in the instruction queue 45. As shown in FIG. 10, since the first read semaphore S1R is “0”, the convolution calculation circuit 4 is waited until the first read semaphore S1R becomes “1” or more (wait in the decode state S2). When the first read semaphore S1R becomes "1” by the V operation by the DMAC3, the convolution calculation circuit 4 starts the convolution calculation (convolution calculation 1). The convolution calculation circuit 4 performs a P operation on the first read semaphore S1R when starting the convolution calculation.
  • the convolution calculation circuit 4 sends a p réellep command to the instruction queue 45 after the completion of the convolution operation instructed by the instruction command C4, removes the instruction command C4 that has been executed from the instruction queue 45, and removes the instruction command C4 that has been executed, and also removes the instruction command C4 from the instruction queue 45.
  • V operation is performed for.
  • the state controller 44 of the convolution operation circuit 4 detects that the instruction queue 45 has the next instruction (Not expense) based on the expense flag of the instruction queue 45, the state controller 44 transitions from the execution state S3 to the decode state S2.
  • the DMAC3 When the DMAC3 starts the DMA transfer described as "DMA transfer 3" in FIG. 10, since the first light semaphore S1W is "0", the DMAC3 waits until the first light semaphore S1W becomes "1" or more. (Wait in decode state S2). When the first light semaphore S1W becomes "1" or more by the V operation by the convolution calculation circuit 4, the DMAC3 starts the DMA transfer.
  • the DMAC 3 and the convolution calculation circuit 4 can prevent an access conflict with respect to the first memory 1 in the first data flow F1. Further, the DMAC 3 and the convolution calculation circuit 4 can operate independently and in parallel while synchronizing the data transfer in the first data flow F1 by using the semaphore S1.
  • FIG. 11 is a timing chart of the second data flow F2.
  • the second write semaphore S2W is a semaphore that limits writing to the second memory 2 by the convolution operation circuit 4 in the second data flow F2.
  • the second write semaphore S2W determines the number of memory areas in the second memory 2 that can store data of a predetermined size, such as output data f, for which data has already been read and other data can be written. Shows.
  • the convolution arithmetic circuit 4 cannot write to the second memory 2 in the second data flow F2, and is waited until the second write semaphore S2W becomes "1" or more. ..
  • the second read semaphore S2R is a semaphore that limits reading from the second memory 2 by the quantization calculation circuit 5 in the second data flow F2.
  • the second read semaphore S2R indicates the number of memory areas in the second memory 2 that can store data of a predetermined size, such as output data f, in which the data has been written and can be read.
  • the quantization arithmetic circuit 5 cannot read from the second memory 2 in the second data flow F2, and waits until the first read semaphore S1R becomes "1" or more. ..
  • the convolution calculation circuit 4 performs a P operation on the second light semaphore S2W when starting the convolution calculation.
  • the convolution calculation circuit 4 sends a p réellep command to the instruction queue 45 after the completion of the convolution operation instructed by the instruction command C4, removes the instruction command C4 that has been executed from the instruction queue 45, and removes the instruction command C4 that has been executed, and also removes the instruction command C4 from the instruction queue 45.
  • V operation is performed for.
  • the quantization calculation circuit 5 starts the quantization calculation by storing the instruction command C5 in the instruction queue 55. As shown in FIG. 11, since the second read semaphore S2R is “0”, the quantization operation circuit 5 is waited until the second read semaphore S2R becomes “1” or more (wait in the decode state S2). When the second read semaphore S2R becomes “1” by the V operation by the convolution operation circuit 4, the quantization operation circuit 5 starts the convolution operation (quantization operation 1). When the quantization calculation circuit 5 starts the quantization calculation, the P operation is performed on the second read semaphore S2R.
  • the quantization operation circuit 5 sends a p réellep command to the instruction queue 55 after the completion of the quantization operation instructed by the instruction command C5, removes the instruction command C5 that has been executed from the instruction queue 55, and removes the second write. Perform V operation on the semaphore S2W.
  • the state controller 54 of the quantization calculation circuit 5 detects that the next instruction is in the instruction queue 55 based on the expense flag of the instruction queue 55 (Not expense), the state controller 54 transitions from the execution state S3 to the decode state S2.
  • the quantization operation circuit 5 Since the second read semaphore S2R is "0" when the quantization operation circuit 5 starts the quantization operation described as "quantization operation 2" in FIG. 11, the quantization operation circuit 5 is the second read semaphore. It is waited until S2R becomes "1" or more (Wait in the decode state S2). When the second read semaphore S2R becomes "1" or more by the V operation by the convolution operation circuit 4, the quantization operation circuit 5 starts the quantization operation.
  • the convolution calculation circuit 4 and the quantization calculation circuit 5 can operate independently and in parallel while synchronizing the data transfer in the second data flow F2 by using the semaphore S2.
  • the third write semaphore S3W is a semaphore that limits writing to the first memory 1 by the quantization calculation circuit 5 in the third data flow F3.
  • the third write semaphore S3W reads other data in the first memory 1 from the memory area capable of storing data of a predetermined size such as the quantization calculation output data of the quantization calculation circuit 5. Shows the number of writable memory areas.
  • the quantization calculation circuit 5 cannot write to the first memory 1 in the third data flow F3, and waits until the third light semaphore S3W becomes "1" or more. Is done.
  • the third read semaphore S3R is a semaphore that limits reading from the first memory 1 by the convolution operation circuit 4 in the third data flow F3.
  • the third read semafo S3R is a memory in which the data has been written and can be read out of the memory area in which the data of a predetermined size such as the quantization operation output data of the quantization operation circuit 5 can be stored in the first memory 1. Shows the number of regions.
  • the third read semaphore S1R is "0"
  • the convolution arithmetic circuit 4 cannot read from the first memory 1 in the third data flow F3, and waits until the third read semaphore S1R becomes "1" or more.
  • the quantization calculation circuit 5 and the convolution calculation circuit 4 can operate independently and in parallel while synchronizing the data transfer in the third data flow F3 by using the semaphore S3.
  • the first memory 1 is shared by the first data flow F1 and the third data flow F3.
  • the NN circuit 100 can distinguish between the first data flow F1 and the third data flow F3 and synchronize the data transfer.
  • the external host CPU stores instruction commands necessary for a series of operations to be executed by the NN circuit 100 in a memory such as the external memory 120. Specifically, the external host CPU stores a plurality of instruction commands C3 for the DMAC3, a plurality of instruction commands C4 for the convolution operation circuit 4, and a plurality of instruction commands C5 for the quantization operation circuit 5 in an external memory. Store in 120.
  • the external host CPU 110 stores the start address of the external memory 120 in which the instruction command C3 is stored in the instruction pointer 65 of the fetch unit 63A. Further, the external host CPU 110 stores the start address of the external memory 120 in which the instruction command C4 is stored in the instruction pointer 65 of the fetch unit 63B. Further, the external host CPU 110 stores the start address of the external memory 120 in which the instruction command C5 is stored in the instruction pointer 65 of the fetch unit 63C.
  • the external host CPU 110 sets the number of commands of the instruction command C3 in the instruction counter 66 of the fetch unit 63A. Further, the external host CPU 110 sets the number of commands of the instruction command C4 in the instruction counter 66 of the fetch unit 63B. Further, the external host CPU 110 sets the number of commands of the instruction command C5 in the instruction counter 66 of the fetch unit 63C.
  • the IFU 62 reads an instruction command from the external memory 120 and writes the read instruction command in the instruction queue of the corresponding DMAC3, the convolution operation circuit 4, and the quantization operation circuit 5.
  • the DMAC 3, the convolution calculation circuit 4, and the quantization calculation circuit 5 start operating in parallel based on the instruction commands stored in the instruction queue. Since the DMAC 3, the convolution calculation circuit 4, and the quantization calculation circuit 5 are controlled by the semaphore S, they can operate independently and in parallel while synchronizing the data transfer. Further, since the DMAC 3, the convolution calculation circuit 4, and the quantization calculation circuit 5 are controlled by the semaphore S, access contention to the first memory 1 and the second memory 2 can be prevented.
  • the convolution operation circuit 4 reads from the first memory 1 and writes to the second memory 2 when performing the convolution operation based on the instruction command C4.
  • the convolution operation circuit 4 is a Consumer in the first data flow F1 and a Producer in the second data flow F2. Therefore, when the convolution operation circuit 4 starts the convolution operation based on the instruction command C4, the convolution operation circuit 4 performs a P operation on the first read semaphore S1R (see FIG. 10) and a P operation on the second write semaphore S2W. (See FIG. 11). After the convolution calculation is completed, the convolution calculation circuit 4 performs a V operation on the first write semaphore S1W (see FIG. 10) and a V operation on the second read semaphore S2R (see FIG. 11).
  • the convolution operation circuit 4 When the convolution operation circuit 4 starts the convolution operation based on the instruction command C4, the convolution operation circuit 4 waits until the first read semaphore S1R becomes “1" or more and the second write semaphore S2W becomes “1" or more (decode state). Wait in S2).
  • the quantization calculation circuit 5 reads from the second memory 2 and writes to the first memory 1 when performing the quantization calculation based on the instruction command C5. That is, the quantization calculation circuit 5 is a Consumer in the second data flow F2 and a Producer in the third data flow F3. Therefore, when the quantization calculation circuit 5 starts the quantization calculation based on the instruction command C5, the P operation is performed on the second read semaphore S2R and the P operation is performed on the third write semaphore S3W. After the quantization calculation is completed, the quantization calculation circuit 5 performs a V operation on the second write semaphore S2W and a V operation on the third read semaphore S3R.
  • the quantization calculation circuit 5 When the quantization calculation circuit 5 starts the quantization calculation based on the instruction command C5, it waits until the second read semaphore S2R becomes “1" or more and the third write semaphore S3W becomes "1" or more (1). Wait in the decode state S2).
  • the input data read from the first memory 1 by the convolution calculation circuit 4 may be the data written by the quantization calculation circuit 5 in the third data flow.
  • the convolution calculation circuit 4 is a Consumer in the third data flow F3 and a Producer in the second data flow F2. Therefore, when the convolution operation circuit 4 starts the convolution operation based on the instruction command C4, the convolution operation circuit 4 performs a P operation on the third read semaphore S3R and a P operation on the second write semaphore S2W. After the convolution calculation is completed, the convolution calculation circuit 4 performs a V operation on the third write semaphore S3W and a V operation on the second read semaphore S2R.
  • the convolution operation circuit 4 When the convolution operation circuit 4 starts the convolution operation based on the instruction command C4, the convolution operation circuit 4 waits until the third read semaphore S3R becomes “1" or more and the second write semaphore S2W becomes "1" or more (decode state). Wait in S2).
  • the IFU 62 can use the interrupt generation circuit 64 to generate an interrupt indicating the completion of reading a series of instruction commands by the IFU 62 to the external host CPU 110. After detecting the completion of reading the instruction command by the IFU 62, the external host CPU 110 stores the instruction command necessary for a series of operations to be executed by the NN circuit 100 in the external memory 120, and reads the next instruction command to the IFU 62. Instruct.
  • the external host CPU 110 changes the instruction command to be read by the IFU 62 to the instruction command corresponding to the second application.
  • the change to the instruction command corresponding to the second application is carried out by a method A for rewriting the instruction command stored in the external memory 120, a method B for rewriting the instruction pointer 65 and the instruction counter 66, and the like.
  • the method B is used, if the instruction command corresponding to the second application is stored in an area different from the area of the external memory 120 in which the instruction command corresponding to the first application is stored, the instruction pointer 65 and the instruction counter 66 are stored. Just by rewriting, the instruction command read by IFU62 is changed immediately.
  • the change from the first application to the second application occurs due to the change of the object to be detected.
  • the change from the first application to the second application may be updated in synchronization with the video synchronization signal.
  • the NN circuit 100 that can be incorporated into an embedded device such as an IoT device can be operated with high performance.
  • the DMAC 3, the convolution calculation circuit 4, and the quantization calculation circuit 5 can operate in parallel.
  • the NN circuit 100 can read an instruction command from the external memory 120 and supply the instruction command to the instruction queue of the corresponding instruction execution module (DMAC3, convolution operation circuit 4 and quantization operation circuit 5). Since the instruction execution module is controlled by the semaphore S, it can operate independently and in parallel while synchronizing the data transfer. Further, since the instruction execution module is controlled by the semaphore S, it is possible to prevent access conflicts with respect to the first memory 1 and the second memory 2. Therefore, the NN circuit 100 can improve the arithmetic processing efficiency of the instruction execution module.
  • the first memory 1 and the second memory 2 are different memories, but the embodiment 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 data input to the NN circuit 100 described in the above embodiment is not limited to a single format, and can be composed of still images, moving images, sounds, characters, numerical values, and combinations thereof.
  • the data input to the NN circuit 100 is a physical quantity measurement such as an optical sensor, a thermometer, a Global Positioning System (GPS) measuring instrument, an angular velocity measuring instrument, and an anemometer, which can be mounted on an edge device provided with the NN circuit 100. It is not limited to the measurement result in the vessel.
  • Peripheral information such as base station information, vehicle / ship information, weather information, congestion status information, etc. received from peripheral devices via wired or wireless communication, and different information such as financial information and personal information may be combined.
  • the edge device provided with the NN circuit 100 is assumed to be a communication device such as a mobile phone driven by a battery, a smart device such as a personal computer, a digital camera, a game device, a mobile device such as a robot product, but is limited to this. It's not a thing. It is also possible to obtain unprecedented effects by using it for products that have a high demand for peak power supply limit, reduction of product heat generation, or long-term driving by Power on Ethernet (PoE). For example, by applying it to in-vehicle cameras mounted on 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 high durability. .. Further, the same effect can be obtained by applying it to display devices such as televisions and displays, medical devices such as medical cameras and surgical robots, and work robots used at manufacturing sites and construction sites.
  • display devices such as televisions and displays, medical devices such as medical cameras and surgical robots, and work robots used at manufacturing sites and
  • the NN circuit 100 may realize a part or all of the NN circuit 100 by using one or more processors.
  • the NN circuit 100 may realize a part or all of an input layer or an 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 or conversion. This makes it possible to support various types of input or output formats.
  • the software executed by the processor may be rewritable by using a communication means or an external medium.
  • the NN circuit 100 may be realized by combining a part of the processing in the CNN 200 with a Graphics Processing Unit (GPU) or the like on the cloud.
  • the NN circuit 100 performs further processing on the cloud in addition to the processing performed on the edge device provided with the NN circuit 100, and processing on the edge device in addition to the processing on the cloud. More complicated processing can be realized with less resources. According to such a configuration, the NN circuit 100 can reduce the amount of communication between the edge device and the cloud by processing distribution.
  • the calculation performed by the NN circuit 100 was at least a part of the learned CNN200, but the target of the calculation performed by the NN circuit 100 is not limited to this.
  • the operation performed by the NN circuit 100 may be at least a part of a trained neural network that repeats two types of operations, such as a convolution operation and a quantization operation.
  • the present invention can be applied to the calculation of a neural network.
  • Convolutional Neural Network 100 Neural Network Circuit (NN Circuit) 1 1st memory 2 2nd memory 3 DMA controller (DMAC) 4 Convolution operation circuit 5 Quantization operation circuit 6 Controller 61 Register 62 IFU (instruction fetch unit) 63 Fetch unit 62A Fetch unit (third fetch unit) 62B fetch unit (first fetch unit) 62C fetch unit (second fetch unit) 64 Interruption generation circuit S Semafo F1 First data flow F2 Second data flow F3 Third data flow C3 Instruction command (third instruction command) C4 instruction command (first instruction command) C5 instruction command (second instruction command)

Landscapes

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

Abstract

ニューラルネットワーク回路は、入力データに対して畳み込み演算を行う畳み込み演算回路と、前記畳み込み演算回路の畳み込み演算出力データに対して量子化演算を行う量子化演算回路と、前記畳み込み演算回路または前記量子化演算回路を動作させる命令コマンドを外部メモリから読み出す命令フェッチユニットと、を備える。

Description

ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法
 本発明は、ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法に関する。
 近年、畳み込みニューラルネットワーク(Convolutional Neural Network:CNN)が画像認識等のモデルとして用いられている。畳み込みニューラルネットワークは、畳み込み層やプーリング層を有する多層構造であり、畳み込み演算等の多数の演算を必要とする。畳み込みニューラルネットワークによる演算を高速化する演算手法が様々考案されている(特許文献1など)。
特開2018-077829号公報
 一方で、IoT機器などの組み込み機器においても畳み込みニューラルネットワークを利用した画像認識等を実現することが望まれている。組み込み機器においては、特許文献1等に記載された大規模な専用回路を組み込むことは難しい。また、CPUやメモリ等のハードウェアリソースが限られた組み込み機器においては、畳み込みニューラルネットワークの十分な演算性能をソフトウェアのみにより実現することは難しい。
 上記事情を踏まえ、本発明は、IoT機器などの組み込み機器に組み込み可能かつ高性能なニューラルネットワーク回路およびニューラルネットワーク回路の制御方法を提供することを目的とする。
 上記課題を解決するために、この発明は以下の手段を提案している。
 本発明の第一の態様に係るニューラルネットワーク回路は、入力データに対して畳み込み演算を行う畳み込み演算回路と、前記畳み込み演算回路の畳み込み演算出力データに対して量子化演算を行う量子化演算回路と、前記畳み込み演算回路または前記量子化演算回路を動作させる命令コマンドを外部メモリから読み出す命令フェッチユニットと、を備える。
 本発明の第二の態様に係るニューラルネットワーク回路の制御方法は、入力データに対して畳み込み演算を行う畳み込み演算回路と、前記畳み込み演算回路の畳み込み演算出力データに対して量子化演算を行う量子化演算回路と、前記畳み込み演算回路または前記量子化演算回路を動作させる命令コマンドをメモリから読み出す命令フェッチユニットと、を備えるニューラルネットワーク回路の制御方法であって、前記命令フェッチユニットに、前記命令コマンドを前記メモリから読み出させて、前記畳み込み演算回路または前記量子化演算回路に対して前記命令コマンドを供給させるステップと、供給された前記命令コマンドに基づいて前記畳み込み演算回路または前記量子化演算回路を動作させるステップと、を有する。
 本発明のニューラルネットワーク回路は、IoT機器などの組み込み機器に組み込み可能かつ高性能である。本発明のニューラルネットワーク回路の制御方法は、ニューラルネットワーク回路の演算処理能力を向上できる。
畳み込みニューラルネットワークを示す図である。 畳み込み層が行う畳み込み演算を説明する図である。 畳み込み演算のデータの展開を説明する図である。 第一実施形態に係るニューラルネットワーク回路の全体構成を示す図である。 同ニューラルネットワーク回路の動作例を示すタイミングチャートである。 同ニューラルネットワーク回路の他の動作例を示すタイミングチャートである。 同ニューラルネットワーク回路のコントローラのIFUとDMAC等とを接続する専用配線を示す図である。 同DMACの制御回路のステート遷移図である。 セマフォによる同ニューラルネットワーク回路の制御を説明する図である。 第一データフローのタイミングチャートである。 第二データフローのタイミングチャートである。
(第一実施形態)
 本発明の第一実施形態について、図1から図11を参照して説明する。
 図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は、第一メモリ1と、第二メモリ2と、DMAコントローラ3(以下、「DMAC3」ともいう)と、畳み込み演算回路4と、量子化演算回路5と、コントローラ6と、を備える。NN回路100は、第一メモリ1および第二メモリ2を介して、畳み込み演算回路4と量子化演算回路5とがループ状に形成されていることを特徴とする。
 NN回路100は、外部バスEBを介して外部ホストCPU110および外部メモリ120と接続されている。外部ホストCPU110は汎用CPUを含む。外部メモリ120はDRAM等のメモリとその制御回路を含む。外部メモリ120には、外部ホストCPU110が実行するプログラムと各種データとが格納される。外部バスEBは、外部ホストCPU110と外部メモリ120とNN回路100とを接続する。
 第一メモリ1は、例えばSRAM(Static RAM)などで構成された揮発性のメモリ等の書き換え可能なメモリである。第一メモリ1には、DMAC3やコントローラ6を介してデータの書き込みおよび読み出しが行われる。第一メモリ1は、畳み込み演算回路4の入力ポートと接続されており、畳み込み演算回路4は第一メモリ1からデータを読み出すことができる。また、第一メモリ1は、量子化演算回路5の出力ポートと接続されており、量子化演算回路5は第一メモリ1にデータを書き込むことができる。外部ホストCPU110は、第一メモリ1に対するデータの書き込みや読み出しにより、NN回路100に対するデータの入出力を行うことができる。
 第二メモリ2は、例えばSRAM(Static RAM)などで構成された揮発性のメモリ等の書き換え可能なメモリである。第二メモリ2には、DMAC3やコントローラ6を介してデータの書き込みおよび読み出しが行われる。第二メモリ2は、量子化演算回路5の入力ポートと接続されており、量子化演算回路5は第二メモリ2からデータを読み出すことができる。また、第二メモリ2は、畳み込み演算回路4の出力ポートと接続されており、畳み込み演算回路4は第二メモリ2にデータを書き込むことができる。外部ホストCPU110は、第二メモリ2に対するデータの書き込みや読み出しにより、NN回路100に対するデータの入出力を行うことができる。
 DMAC3は、外部バスEBに接続されており、外部メモリ120と第一メモリ1との間のデータ転送を行う。また、DMAC3は、外部メモリ120と第二メモリ2との間のデータ転送を行う。また、DMAC3は、外部メモリ120と畳み込み演算回路4との間のデータ転送を行う。また、DMAC3は、外部メモリ120と量子化演算回路5との間のデータ転送を行う。
 畳み込み演算回路4は、学習済みのCNN200の畳み込み層210における畳み込み演算を行う回路である。畳み込み演算回路4は、第一メモリ1に格納された入力データaを読み出し、入力データaに対して畳み込み演算を実施する。畳み込み演算回路4は、畳み込み演算の出力データf(以降、「畳み込み演算出力データ」ともいう)を第二メモリ2に書き込む。
 量子化演算回路5は、学習済みのCNN200の量子化演算層220における量子化演算の少なくとも一部を行う回路である。量子化演算回路5は、第二メモリ2に格納された畳み込み演算の出力データfを読み出し、畳み込み演算の出力データfに対して量子化演算(プーリング、Batch Normalization、活性化関数、および量子化のうち少なくとも量子化を含む演算)を行う。量子化演算回路5は、量子化演算の出力データ(以降、「量子化演算出力データ」ともいう)を第一メモリ1に書き込む。
 コントローラ6は、外部バスEBに接続されており、外部バスEBに対してマスタおよびスレーブとして動作する。コントローラ6は、バスブリッジ60と、レジスタ61と、IFU62と、を有する。
 レジスタ61は、パラメータレジスタや状態レジスタを有する。パラメータレジスタは、NN回路100の動作を制御するレジスタである。状態レジスタはセマフォSを含むNN回路100の状態を示すレジスタである。外部ホストCPU110は、コントローラ6のバスブリッジ60を経由して、レジスタ61にアクセスできる。
 IFU(Instruction Fetch Unit、命令フェッチユニット)62は、外部ホストCPU110の指示に基づいて、外部バスEBを経由してDMAC3、畳み込み演算回路4および量子化演算回路5に対する命令コマンドを外部メモリ120から読み出す。また、IFU62は、読み出した命令コマンドを対応するDMAC3、畳み込み演算回路4および量子化演算回路5に転送する。
 コントローラ6は、内部バスIB(図4参照)およびIFU62と接続された専用配線(図7参照)を介して、第一メモリ1と、第二メモリ2と、DMAC3と、畳み込み演算回路4と、量子化演算回路5と、接続されている。外部ホストCPU110は、コントローラ6を経由して、各ブロックに対してアクセスできる。例えば、外部ホストCPU110は、コントローラ6を経由して、DMAC3や畳み込み演算回路4や量子化演算回路5に対する命令を指示することができる。
 DMAC3や畳み込み演算回路4や量子化演算回路5は、内部バスIBを介して、コントローラ6が有する状態レジスタ(セマフォSを含む)を更新できる。状態レジスタ(セマフォSを含む)は、DMAC3や畳み込み演算回路4や量子化演算回路5と接続された専用配線を介して更新されるように構成されていてもよい。
 NN回路100は、第一メモリ1や第二メモリ2等を有するため、外部メモリ120からのDMAC3によるデータ転送において、重複するデータのデータ転送の回数を低減できる。これにより、メモリアクセスにより発生する消費電力を大幅に低減することができる。
[NN回路100の動作例1]
 図5は、NN回路100の動作例を示すタイミングチャートである。
 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回路100は、畳み込み演算回路4が時分割によりレイヤ2M-1の畳み込み演算とレイヤ2M+1を実施する。また、NN回路100は、量子化演算回路5が時分割によりレイヤ2M-2の畳み込み演算とレイヤ2Mを実施する。そのため、NN回路100は、レイヤごとに別々の畳み込み演算回路4と量子化演算回路5を実装する場合と比較して、回路規模が著しく小さい。
 NN回路100は、複数のレイヤの多層構造であるCNN200の演算を、ループ状に形成された回路により演算する。NN回路100は、ループ状の回路構成により、ハードウェア資源を効率的に利用できる。なお、NN回路100は、ループ状に回路を形成するために、各レイヤで変化する畳み込み演算回路4や量子化演算回路5におけるパラメータは適宜更新される。
 CNN200の演算にNN回路100により実施できない演算が含まれる場合、NN回路100は外部ホストCPU110などの外部演算デバイスに中間データを転送する。外部演算デバイスが中間データに対して演算を行った後、外部演算デバイスによる演算結果は第一メモリ1や第二メモリ2に入力される。NN回路100は、外部演算デバイスによる演算結果に対する演算を再開する。
[NN回路100の動作例2]
 図6は、NN回路100の他の動作例を示すタイミングチャートである。
 NN回路100は、入力データaを部分テンソルに分割して、時分割により部分テンソルに対する演算を行ってもよい。部分テンソルへの分割方法や分割数は特に限定されない。
 図6は、入力データaを二つの部分テンソルに分解した場合の動作例を示している。分解された部分テンソルを、「第一部分テンソルa1」、「第二部分テンソルa2」とする。例えば、レイヤ2M-1の畳み込み演算は、第一部分テンソルa1に対応する畳み込み演算(図6において、「レイヤ2M-1(a1)」と表記)と、第二部分テンソルa2に対応する畳み込み演算(図6において、「レイヤ2M-1(a2)」と表記)と、に分解される。
 第一部分テンソルa1に対応する畳み込み演算および量子化演算と、第二部分テンソルa2に対応する畳み込み演算および量子化演算とは、図6に示すように、独立して実施することができる。
 畳み込み演算回路4は、第一部分テンソルa1に対応するレイヤ2M-1の畳み込み演算(図6において、レイヤ2M-1(a1)で示す演算)を行う。その後、畳み込み演算回路4は、第二部分テンソルaに対応するレイヤ2M-1の畳み込み演算(図6において、レイヤ2M-1(a)で示す演算)を行う。また、量子化演算回路5は、第一部分テンソルa1に対応するレイヤ2Mの量子化演算(図6において、レイヤ2M(a1)で示す演算)を行う。このように、NN回路100は、第二部分テンソルaに対応するレイヤ2M-1の畳み込み演算と、第一部分テンソルa1に対応するレイヤ2Mの量子化演算と、を並列に実施できる。
 次に、畳み込み演算回路4は、第一部分テンソルa1に対応するレイヤ2M+1の畳み込み演算(図6において、レイヤ2M+1(a1)で示す演算)を行う。また、量子化演算回路5は、第二部分テンソルaに対応するレイヤ2Mの量子化演算(図6において、レイヤ2M(a)で示す演算)を行う。このように、NN回路100は、第一部分テンソルa1に対応するレイヤ2M+1の畳み込み演算と、第二部分テンソルaに対応するレイヤ2Mの量子化演算と、を並列に実施できる。
 入力データaを部分テンソルに分割することで、NN回路100は畳み込み演算回路4と量子化演算回路5とを並列して動作させることができる。その結果、畳み込み演算回路4と量子化演算回路5が待機する時間が削減され、NN回路100の演算処理効率が向上する。図6に示す動作例において分割数は2であったが、分割数が2より大きい場合も同様に、NN回路100は畳み込み演算回路4と量子化演算回路5とを並列して動作させることができる。
 なお、部分テンソルに対する演算方法としては、同一レイヤにおける部分テンソルの演算を畳み込み演算回路4または量子化演算回路5で行った後に次のレイヤにおける部分テンソルの演算を行う例(方法1)を示した。例えば、図6に示すように、畳み込み演算回路4において、第一部分テンソルa1および第二部分テンソルaに対応するレイヤ2M-1の畳み込み演算(図6において、レイヤ2M-1(a1)およびレイヤ2M-1(a)で示す演算)を行った後に、第一部分テンソルa1および第二部分テンソルaに対応するレイヤ2M+1の畳み込み演算(図6において、レイヤ2M+1(a1)およびレイヤ2M+1(a)で示す演算)を実施している。
 しかしながら、部分テンソルに対する演算方法はこれに限られない。部分テンソルに対する演算方法は、複数レイヤにおける一部の部分テンソルの演算をした後に残部の部分テンソルの演算を実施する方法でもよい(方法2)。例えば、畳み込み演算回路4において、第一部分テンソルa1に対応するレイヤ2M-1および第一部分テンソルa1に対応するレイヤ2M+1の畳み込み演算を行った後に、第二部分テンソルaに対応するレイヤ2M-1および第二部分テンソルaに対応するレイヤ2M+1の畳み込み演算を実施してもよい。
 また、部分テンソルに対する演算方法は、方法1と方法2とを組み合わせて部分テンソルを演算する方法でもよい。ただし、方法2を用いる場合は、部分テンソルの演算順序に関する依存関係に従って演算を実施する必要がある。
 次に、NN回路100の各構成に関して詳しく説明する。図7は、コントローラ6のIFU62とDMAC3等とを接続する専用配線を示す図である。
[DMAC3]
 DMAC3は、データ転送回路(不図示)と、ステートコントローラ32と、を有する。DMAC3は、データ転送回路に対する専用のステートコントローラ32を有しており、命令コマンドC3が入力されると、外部のコントローラを必要とせずにDMAデータ転送を実施できる。
 ステートコントローラ32は、データ転送回路のステートを制御する。また、ステートコントローラ32は、内部バスIB(図4参照)およびIFU62と接続された専用配線(図7参照)を介してコントローラ6と接続されている。ステートコントローラ32は、命令キュー33と制御回路34とを有する。
 命令キュー33は、DMAC3用の命令コマンド(第三命令コマンド)C3が格納されるキューであり、例えばFIFOメモリで構成される。命令キュー33には、内部バスIBまたはIFU62経由で1つ以上の命令コマンドC3が書き込まれる。
 命令キュー33は、格納される命令コマンドC3の数が「0」であることを示すemptyフラグと、格納される命令コマンドC3の数が最大値であることを示すfullフラグと、を出力する。命令キュー33は、格納される命令コマンドC3の数が最大値の半分以下であることを示すhalf emptyフラグなどを出力してもよい。
 命令キュー33のemptyフラグやfullフラグは、レジスタ61の状態レジスタとして格納される。外部ホストCPU110は、レジスタ61の状態レジスタを読み出すことで、emptyフラグやfullフラグなどのフラグの状態を確認できる。
 制御回路34は、命令コマンドC3をデコードし、命令コマンドC3に基づいてデータ転送回路を制御するステートマシンである。制御回路34は、論理回路により実装されていてもよいし、ソフトウェアによって制御されるCPUによって実装されていてもよい。
 図8は、制御回路34のステート遷移図である。
 制御回路34は、命令キュー33のemptyフラグに基づいて、命令キュー33に命令コマンドC3が入力されたことを検知すると(Not empty)、アイドルステートS1からデコードステートS2に遷移する。
 制御回路34は、デコードステートS2において、命令キュー33から出力される命令コマンドC3をデコードする。また、制御回路34は、コントローラ6のレジスタ61に格納されたセマフォSを読み出し、命令コマンドC3において指示されたデータ転送回路の動作を実行可能であるかを判定する。実行不能である場合(Not ready)、制御回路34は実行可能となるまで待つ(Wait)。実行可能である場合(ready)、制御回路34はデコードステートS2から実行ステートS3に遷移する。
 制御回路34は、実行ステートS3において、データ転送回路を制御して、データ転送回路に命令コマンドC3において指示された動作を実施させる。制御回路34は、データ転送回路の動作が終わると、命令キュー33に対してpоpコマンドを送り、命令キュー33から実行を終えた命令コマンドC3を取り除くとともに、コントローラ6のレジスタ61に格納されたセマフォSを更新する。制御回路34は、命令キュー33のemptyフラグに基づいて、命令キュー33に命令があることを検知すると(Not empty)、実行ステートS3からデコードステートS2に遷移する。制御回路34は、命令キュー33に命令がないことを検知すると(empty)、実行ステートS3からアイドルステートS1に遷移する。
[畳み込み演算回路4]
 畳み込み演算回路4は、乗算器などの演算回路(不図示)と、ステートコントローラ44と、を有する。畳み込み演算回路4は、乗算器などの演算回路等に対する専用のステートコントローラ44を有しており、命令コマンドC4が入力されると、外部のコントローラを必要とせずに畳み込み演算を実施できる。
 ステートコントローラ44は、乗算器などの演算回路のステートを制御する。また、ステートコントローラ44は、内部バスIB(図4参照)およびIFU62と接続された専用配線(図7参照)を介してコントローラ6と接続されている。ステートコントローラ44は、命令キュー45と制御回路46とを有する。
 命令キュー45は、畳み込み演算回路4用の命令コマンド(第一命令コマンド)C4が格納されるキューであり、例えばFIFOメモリで構成される。命令キュー45には、内部バスIBまたはIFU62経由で命令コマンドC4が書き込まれる。命令キュー45は、DMAC3のステートコントローラ32の命令キュー33と同様の構成である。
 制御回路46は、命令コマンドC4をデコードし、命令コマンドC4に基づいて乗算器などの演算回路を制御するステートマシンである。制御回路46は、DMAC3のステートコントローラ32の制御回路34と同様の構成である。
[量子化演算回路5]
 量子化演算回路5は、量子化回路等(不図示)と、ステートコントローラ54と、を有する。量子化演算回路5は、量子化回路等に対する専用のステートコントローラ54を有しており、命令コマンドC5が入力されると、外部のコントローラを必要とせずに量子化演算を実施できる。
 ステートコントローラ54は、量子化回路等のステートを制御する。また、ステートコントローラ54は、内部バスIB(図4参照)およびIFU62と接続された専用配線(図7参照)を介してコントローラ6と接続されている。ステートコントローラ54は、命令キュー55と制御回路56とを有する。
 命令キュー55は、量子化演算回路5用の命令コマンド(第二命令コマンド)C5が格納されるキューであり、例えばFIFOメモリで構成される。命令キュー55には、内部バスIBまたはIFU62経由で命令コマンドC5が書き込まれる。命令キュー55は、DMAC3のステートコントローラ32の命令キュー33と同様の構成である。
 制御回路56は、命令コマンドC5をデコードし、命令コマンドC5に基づいて量子化回路等を制御するステートマシンである。制御回路56は、DMAC3のステートコントローラ32の制御回路34と同様の構成である。
[コントローラ6]
 コントローラ6は、外部バスEBに接続されており、外部バスEBに対してマスタおよびスレーブとして動作する。コントローラ6は、バスブリッジ60と、パラメータレジスタや状態レジスタを含むレジスタ61と、IFU62と、を有している。パラメータレジスタは、NN回路100の動作を制御するレジスタである。状態レジスタは、セマフォSを含むNN回路100の状態を示すレジスタである。
 バスブリッジ60は、外部バスEBから内部バスIBへのバスアクセスを中継する。また、バスブリッジ60は、外部ホストCPU110からレジスタ61への書き込み要求および読み込み要求を中継する。また、バスブリッジ60は、IFU62から外部メモリ120への読み出し要求を外部バスEBに中継する。
 NN回路100と外部ホストCPU110と外部メモリ120とが同一のシリコンチップ上に集積される場合、外部バスEBは例えばAXI(登録商標)などの標準規格に準拠したインターコネクトである。NN回路100と外部ホストCPU110と外部メモリ120の少なくとも一つが異なるシリコンチップ上に集積される場合、外部バスEBは例えばPCI-Express(登録商標)などの標準規格に準拠したインターコネクトである。バスブリッジ60は、接続される外部バスEBの規格に対応したプロトコル変換回路を有する。なお、外部ホストCPU110または外部メモリ120がNN回路100と異なるシリコンチップ上に集積される場合に、通信速度による全体の演算速度の低下を抑えるために、所定量の命令コマンドを一時的に保持するバッファをNN回路100と同一のシリコンチップ上に設けてもよい。
 コントローラ6は、二つの方法により、DMAC3、畳み込み演算回路4および量子化演算回路5が有する命令キューに命令コマンドを転送する。一つ目の方法は、外部ホストCPU110からコントローラ6に転送される命令コマンドを、内部バスIB(図4参照)を介して転送する方法である。二つ目の方法は、IFU62が外部メモリ120から命令コマンドを読み出し、IFU62と接続された専用配線(図7参照)を介して命令コマンドを転送する方法である。
 IFU(Instruction Fetch Unit)62は、図7に示すように、複数のフェッチユニット63と、割り込み生成回路64と、を有する。
 フェッチユニット63は、外部ホストCPU110の指示に基づいて、外部バスEBを経由して外部メモリ120から命令コマンドを読み出す。また、フェッチユニット63は、読み出した命令コマンドを対応するDMAC3等の命令キューに供給する。
 フェッチユニット63は、命令ポインタ65と、命令カウンタ66と、を有する。外部ホストCPU110は、外部バスEBを介して、命令ポインタ65および命令カウンタ66に対する書き込みと読み出しを実施できる。
 命令ポインタ65は、命令コマンドが格納された外部ホストCPU110のメモリアドレスを保持する。命令カウンタ66は、格納された命令コマンドのコマンド数を保持する。命令カウンタ66は、「0」に初期化されている。外部ホストCPU110が命令カウンタ66に「1」以上の値を書き込むことで、フェッチユニット63が起動する。フェッチユニット63は、命令ポインタ65を参照して、外部メモリ120から命令コマンドを読み出す。この場合、コントローラ6は外部バスEBに対してマスタとして動作する。
 フェッチユニット63は、命令コマンドを読み出すごとに、命令ポインタ65および命令カウンタ66を更新する。命令カウンタ66は、命令コマンドを読み出すごとにデクリメントされる。フェッチユニット63は、命令カウンタ66が「0」になるまで命令コマンドを読み出す。
 フェッチユニット63は、対応するDMAC3等の命令キューにpushコマンドを送り、読み出した命令コマンドを対応するDMAC3等の命令キューに書き込む。ただし、命令キューのfullフラグが「1(真)」である場合、フェッチユニット63はfullフラグが「0(偽)」となるまで命令キューへの書き込みを行わない。
 フェッチユニット63は、命令キューのフラグや命令カウンタ66を参照し、必要に応じてバースト転送を用いることで、外部バスEBを介した命令コマンドの読み出しを効率よく実施できる。
 フェッチユニット63は、命令キュー毎に設けられる。以降の説明において、DMAC3の命令キュー33用のフェッチユニット63を「フェッチユニット63A(第三フェッチユニット)」、畳み込み演算回路4の命令キュー45用のフェッチユニット63を「フェッチユニット63B(第一フェッチユニット)」、量子化演算回路5の命令キュー55用のフェッチユニット63を「フェッチユニット63C(第二フェッチユニット)」という。
 フェッチユニット63A、フェッチユニット63Bおよびフェッチユニット63Cによる外部バスEBを経由した命令コマンドの読み出しは、バスブリッジ60により、例えばラウンドロビン方式の優先度制御によって調停される。
 割り込み生成回路64は、フェッチユニット63の命令カウンタ66を監視しており、全てのフェッチユニット63の命令カウンタ66が「0」になったときに、外部ホストCPU110に対して割り込みを発生させることができる。外部ホストCPU110は、レジスタ61の状態レジスタをポーリングせずとも、上記の割り込みによりIFU62による命令コマンドの読み出し完了を検知できる。
[セマフォS]
 図9は、セマフォSによるNN回路100の制御を説明する図である。
 セマフォSは、第一セマフォS1と、第二セマフォS2と、第三セマフォS3と、を有する。セマフォSは、P操作によりデクリメントされ、V操作によってインクリメントされる。DMAC3、畳み込み演算回路4および量子化演算回路5によるP操作およびV操作は、内部バスIBを経由して、コントローラ6が有するセマフォSを更新する。
 第一セマフォS1は、第一データフローF1の制御に用いられる。第一データフローF1は、DMAC3(Producer)が第一メモリ1に入力データaを書き込み、畳み込み演算回路4(Consumer)が入力データaを読み出すデータフローである。第一セマフォS1は、第一ライトセマフォS1Wと、第一リードセマフォS1Rと、を有する。
 第二セマフォS2は、第二データフローF2の制御に用いられる。第二データフローF2は、畳み込み演算回路4(Producer)が出力データfを第二メモリ2に書き込み、量子化演算回路5(Consumer)が出力データfを読み出すデータフローである。第二セマフォS2は、第二ライトセマフォS2Wと、第二リードセマフォS2Rと、を有する。
 第三セマフォS3は、第三データフローF3の制御に用いられる。第三データフローF3は、量子化演算回路5(Producer)が量子化演算出力データを第一メモリ1に書き込み、畳み込み演算回路4(Consumer)が量子化演算回路5の量子化演算出力データを読み出すデータフローである。第三セマフォS3は、第三ライトセマフォS3Wと、第三リードセマフォS3Rと、を有する。
[第一データフローF1]
 図10は、第一データフローF1のタイミングチャートである。
 第一ライトセマフォS1Wは、第一データフローF1におけるDMAC3による第一メモリ1に対する書き込みを制限するセマフォである。第一ライトセマフォS1Wは、第一メモリ1において、例えば入力ベクトルAなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが読み出し済みで他のデータを書き込み可能なメモリ領域の数を示している。第一ライトセマフォS1Wが「0」の場合、DMAC3は第一メモリ1に対して第一データフローF1における書き込みを行えず、第一ライトセマフォS1Wが「1」以上となるまで待たされる。
 第一リードセマフォS1Rは、第一データフローF1における畳み込み演算回路4による第一メモリ1からの読み出しを制限するセマフォである。第一リードセマフォS1Rは、第一メモリ1において、例えば入力ベクトルAなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが書き込み済みで読み出し可能なメモリ領域の数を示している。第一リードセマフォS1Rが「0」の場合、畳み込み演算回路4は第一メモリ1からの第一データフローF1における読み出しを行えず、第一リードセマフォS1Rが「1」以上となるまで待たされる。
 DMAC3は、命令キュー33に命令コマンドC3が格納されることにより、DMA転送を開始する。図10に示すように、第一ライトセマフォS1Wが「0」でないため、DMAC3はDMA転送を開始する(DMA転送1)。DMAC3は、DMA転送を開始する際に、第一ライトセマフォS1Wに対してP操作を行う。DMAC3は、命令コマンドC3により指示されたDMA転送の完了後に、命令キュー33に対してpоpコマンドを送り、命令キュー33から実行を終えた命令コマンドC3を取り除くとともに、第一リードセマフォS1Rに対してV操作を行う。
 畳み込み演算回路4は、命令キュー45に命令コマンドC4が格納されることにより、畳み込み演算を開始する。図10に示すように、第一リードセマフォS1Rが「0」であるため、畳み込み演算回路4は第一リードセマフォS1Rが「1」以上となるまで待たされる(デコードステートS2におけるWait)。DMAC3によるV操作により第一リードセマフォS1Rが「1」となると、畳み込み演算回路4は畳み込み演算を開始する(畳み込み演算1)。畳み込み演算回路4は、畳み込み演算を開始する際、第一リードセマフォS1Rに対してP操作を行う。畳み込み演算回路4は、命令コマンドC4により指示された畳み込み演算の完了後に、命令キュー45に対してpоpコマンドを送り、命令キュー45から実行を終えた命令コマンドC4を取り除くとともに、第一ライトセマフォS1Wに対してV操作を行う。
 畳み込み演算回路4のステートコントローラ44は、命令キュー45のemptyフラグに基づいて、命令キュー45に次の命令があることを検知すると(Not empty)、実行ステートS3からデコードステートS2に遷移する。
 図10において「DMA転送3」と記載されたDMA転送をDMAC3が開始する際、第一ライトセマフォS1Wが「0」であるため、DMAC3は第一ライトセマフォS1Wが「1」以上となるまで待たされる(デコードステートS2におけるWait)。畳み込み演算回路4によるV操作により第一ライトセマフォS1Wが「1」以上となると、DMAC3はDMA転送を開始する。
 DMAC3と畳み込み演算回路4とは、セマフォS1を使用することで、第一データフローF1において第一メモリ1に対するアクセス競合を防止できる。また、DMAC3と畳み込み演算回路4とは、セマフォS1を使用することで、第一データフローF1におけるデータ転送の同期を取りつつ、独立して並列に動作できる。
[第二データフローF2]
 図11は、第二データフローF2のタイミングチャートである。
 第二ライトセマフォS2Wは、第二データフローF2における畳み込み演算回路4による第二メモリ2に対する書き込みを制限するセマフォである。第二ライトセマフォS2Wは、第二メモリ2において、例えば出力データfなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが読み出し済みで他のデータを書き込み可能なメモリ領域の数を示している。第二ライトセマフォS2Wが「0」の場合、畳み込み演算回路4は第二メモリ2に対して第二データフローF2における書き込みを行えず、第二ライトセマフォS2Wが「1」以上となるまで待たされる。
 第二リードセマフォS2Rは、第二データフローF2における量子化演算回路5による第二メモリ2からの読み出しを制限するセマフォである。第二リードセマフォS2Rは、第二メモリ2において、例えば出力データfなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが書き込み済みで読み出し可能なメモリ領域の数を示している。第二リードセマフォS2Rが「0」の場合、量子化演算回路5は第二メモリ2からの第二データフローF2における読み出しを行えず、第一リードセマフォS1Rが「1」以上となるまで待たされる。
 畳み込み演算回路4は、図11に示すように、畳み込み演算を開始する際、第二ライトセマフォS2Wに対してP操作を行う。畳み込み演算回路4は、命令コマンドC4により指示された畳み込み演算の完了後に、命令キュー45に対してpоpコマンドを送り、命令キュー45から実行を終えた命令コマンドC4を取り除くとともに、第二リードセマフォS2Rに対してV操作を行う。
 量子化演算回路5は、命令キュー55に命令コマンドC5が格納されることにより、量子化演算を開始する。図11に示すように、第二リードセマフォS2Rが「0」であるため、量子化演算回路5は第二リードセマフォS2Rが「1」以上となるまで待たされる(デコードステートS2におけるWait)。畳み込み演算回路4によるV操作により第二リードセマフォS2Rが「1」となると、量子化演算回路5は畳み込み演算を開始する(量子化演算1)。量子化演算回路5は、量子化演算を開始する際、第二リードセマフォS2Rに対してP操作を行う。量子化演算回路5は、命令コマンドC5により指示された量子化演算の完了後に、命令キュー55に対してpоpコマンドを送り、命令キュー55から実行を終えた命令コマンドC5を取り除くとともに、第二ライトセマフォS2Wに対してV操作を行う。
 量子化演算回路5のステートコントローラ54は、命令キュー55のemptyフラグに基づいて、命令キュー55に次の命令があることを検知すると(Not empty)、実行ステートS3からデコードステートS2に遷移する。
 図11において「量子化演算2」と記載された量子化演算を量子化演算回路5が開始する際、第二リードセマフォS2Rが「0」であるため、量子化演算回路5は第二リードセマフォS2Rが「1」以上となるまで待たされる(デコードステートS2におけるWait)。畳み込み演算回路4によるV操作により第二リードセマフォS2Rが「1」以上となると、量子化演算回路5は量子化演算を開始する。
 畳み込み演算回路4と量子化演算回路5とは、セマフォS2を使用することで、第二データフローF2において第二メモリ2に対するアクセス競合を防止できる。また、畳み込み演算回路4と量子化演算回路5とは、セマフォS2を使用することで、第二データフローF2におけるデータ転送の同期を取りつつ、独立して並列に動作できる。
[第三データフローF3]
 第三ライトセマフォS3Wは、第三データフローF3における量子化演算回路5による第一メモリ1に対する書き込みを制限するセマフォである。第三ライトセマフォS3Wは、第一メモリ1において、例えば量子化演算回路5の量子化演算出力データなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが読み出し済みで他のデータを書き込み可能なメモリ領域の数を示している。第三ライトセマフォS3Wが「0」の場合、量子化演算回路5は第一メモリ1に対して第三データフローF3における書き込みを行えず、第三ライトセマフォS3Wが「1」以上となるまで待たされる。
 第三リードセマフォS3Rは、第三データフローF3における畳み込み演算回路4による第一メモリ1からの読み出しを制限するセマフォである。第三リードセマフォS3Rは、第一メモリ1において、例えば量子化演算回路5の量子化演算出力データなどの所定のサイズのデータを格納可能なメモリ領域のうち、データが書き込み済みで読み出し可能なメモリ領域の数を示している。第三リードセマフォS1Rが「0」の場合、畳み込み演算回路4は第三データフローF3における第一メモリ1からの読み出しを行えず、第三リードセマフォS1Rが「1」以上となるまで待たされる。
 量子化演算回路5と畳み込み演算回路4とは、セマフォS3を使用することで、第三データフローF3において第一メモリ1に対するアクセス競合を防止できる。また、量子化演算回路5と畳み込み演算回路4とは、セマフォS3を使用することで、第三データフローF3におけるデータ転送の同期を取りつつ、独立して並列に動作できる。
 第一メモリ1は、第一データフローF1および第三データフローF3において共有される。NN回路100は、第一セマフォS1と第三セマフォS3とを別途設けることで、第一データフローF1と第三データフローF3とを区別してデータ転送の同期を取ることができる。
[IFU62を用いたNN回路100の制御]
 外部ホストCPUは、NN回路100に実施させる一連の演算に必要な命令コマンドを外部メモリ120などのメモリに格納する。具体的には、外部ホストCPUは、DMAC3用の複数の命令コマンドC3と、畳み込み演算回路4用の複数の命令コマンドC4と、量子化演算回路5用の複数の命令コマンドC5とを、外部メモリ120に格納する。
 本実施形態では、NN回路100の回路規模を低減するために、NN回路100に実施させる一連の演算に必要な命令コマンドが外部メモリ120に格納されている例を示している。しなしながら、より高速な命令コマンドへのアクセスが必要な場合には、NN回路100に実施させる一連の演算に必要な命令コマンドを格納できる専用メモリがNN回路100内に設けられていてもよい。
 外部ホストCPU110は、フェッチユニット63Aの命令ポインタ65に、命令コマンドC3が格納された外部メモリ120の先頭アドレスを格納する。また、外部ホストCPU110は、フェッチユニット63Bの命令ポインタ65に、命令コマンドC4が格納された外部メモリ120の先頭アドレスを格納する。また、外部ホストCPU110は、フェッチユニット63Cの命令ポインタ65に、命令コマンドC5が格納された外部メモリ120の先頭アドレスを格納する。
 外部ホストCPU110は、フェッチユニット63Aの命令カウンタ66に、命令コマンドC3のコマンド数を設定する。また、外部ホストCPU110は、フェッチユニット63Bの命令カウンタ66に、命令コマンドC4のコマンド数を設定する。また、外部ホストCPU110は、フェッチユニット63Cの命令カウンタ66に、命令コマンドC5のコマンド数を設定する。
 IFU62は、外部メモリ120から命令コマンドを読み出し、読み出した命令コマンドを対応するDMAC3、畳み込み演算回路4および量子化演算回路5の命令キューに書き込む。
 DMAC3、畳み込み演算回路4および量子化演算回路5は、命令キューに格納された命令コマンドに基づいて並列に動作を開始する。DMAC3、畳み込み演算回路4および量子化演算回路5はセマフォSによって制御されるため、データ転送の同期を取りつつ、独立して並列に動作できる。また、DMAC3、畳み込み演算回路4および量子化演算回路5はセマフォSによって制御されるため、第一メモリ1および第二メモリ2に対するアクセス競合を防止できる。
 畳み込み演算回路4は、命令コマンドC4に基づいて畳み込み演算を行う際、第一メモリ1から読み出しを行い、第二メモリ2に対して書き込みを行う。畳み込み演算回路4は、第一データフローF1においてはConsumerであり、第二データフローF2においてはProducerである。そのため、畳み込み演算回路4は、命令コマンドC4に基づいて畳み込み演算を開始する際、第一リードセマフォS1Rに対してP操作を行い(図10参照)、第二ライトセマフォS2Wに対してP操作を行う(図11参照)。畳み込み演算回路4は、畳み込み演算の完了後に、第一ライトセマフォS1Wに対してV操作を行い(図10参照)、第二リードセマフォS2Rに対してV操作を行う(図11参照)。
 畳み込み演算回路4は、命令コマンドC4に基づいて畳み込み演算を開始する際、第一リードセマフォS1Rが「1」以上、かつ、第二ライトセマフォS2Wが「1」以上となるまで待たされる(デコードステートS2におけるWait)。
 量子化演算回路5は、命令コマンドC5に基づいて量子化演算を行う際、第二メモリ2から読み出しを行い、第一メモリ1に対して書き込みを行う。すなわち、量子化演算回路5は、第二データフローF2においてはConsumerであり、第三データフローF3においてはProducerである。そのため、量子化演算回路5は、命令コマンドC5に基づいて量子化演算を開始する際、第二リードセマフォS2Rに対してP操作を行い、第三ライトセマフォS3Wに対してP操作を行う。量子化演算回路5は量子化演算の完了後に、第二ライトセマフォS2Wに対してV操作を行い、第三リードセマフォS3Rに対してV操作を行う。
 量子化演算回路5は、命令コマンドC5に基づいて量子化演算を開始する際、第二リードセマフォS2Rが「1」以上、かつ、第三ライトセマフォS3Wが「1」以上となるまで待たされる(デコードステートS2におけるWait)。
 畳み込み演算回路4が第一メモリ1から読み出す入力データは、第三データフローにおいて量子化演算回路5が書き込んだデータである場合もある。この場合、畳み込み演算回路4は、第三データフローF3においてはConsumerであり、第二データフローF2においてはProducerである。そのため、畳み込み演算回路4は、命令コマンドC4に基づいて畳み込み演算を開始する際、第三リードセマフォS3Rに対してP操作を行い、第二ライトセマフォS2Wに対してP操作を行う。畳み込み演算回路4は、畳み込み演算の完了後に、第三ライトセマフォS3Wに対してV操作を行い、第二リードセマフォS2Rに対してV操作を行う。
 畳み込み演算回路4は、命令コマンドC4に基づいて畳み込み演算を開始する際、第三リードセマフォS3Rが「1」以上、かつ、第二ライトセマフォS2Wが「1」以上となるまで待たされる(デコードステートS2におけるWait)。
 IFU62は、割り込み生成回路64を用いて、IFU62による一連の命令コマンドの読み出し完了を示す割り込みを外部ホストCPU110に発生させることができる。外部ホストCPU110は、IFU62による命令コマンドの読み出し完了を検知した後、次にNN回路100に実施させる一連の演算に必要な命令コマンドを外部メモリ120に格納し、次の命令コマンドの読み出しをIFU62に指示する。
 外部ホストCPU110は、NN回路100を用いて演算を行うアプリケーションが第一アプリケーションから第二アプリケーションに変更された場合、IFU62に読み出させる命令コマンドを第二アプリケーションに対応した命令コマンドに変更する。第二アプリケーションに対応した命令コマンドへの変更は、外部メモリ120に格納された命令コマンドを書き換える方法Aや、命令ポインタ65と命令カウンタ66を書き換える方法Bなどにより実施する。方法Bを用いる場合、第二アプリケーションに対応した命令コマンドを第一アプリケーションに対応した命令コマンドが格納された外部メモリ120の領域と異なる領域に格納しておけば、命令ポインタ65と命令カウンタ66を書き換えるだけで、すぐにIFU62が読み出す命令コマンドが変更される。
 例えばNN回路100を用いて演算を行うアプリケーションが物体検出である場合、第一アプリケーションから第二アプリケーションへの変更は、検出対象物体の変更などにより発生する。例えばNN回路100への入力データが動画像データである場合、第一アプリケーションから第二アプリケーションへの変更は、映像の同期信号に同期して更新してもよい。
 本実施形態に係るニューラルネットワーク回路によれば、IoT機器などの組み込み機器に組み込み可能なNN回路100を高性能に動作させることができる。NN回路100は、DMAC3、畳み込み演算回路4および量子化演算回路5が並列に動作可能である。NN回路100は、IFU62を用いることで、外部メモリ120から命令コマンドを読み出し、対応した命令実行モジュール(DMAC3、畳み込み演算回路4および量子化演算回路5)の命令キューに命令コマンドを供給できる。命令実行モジュールはセマフォSによって制御されるため、データ転送の同期を取りつつ、独立して並列に動作できる。また、命令実行モジュールはセマフォSによって制御されるため、第一メモリ1および第二メモリ2に対するアクセス競合を防止できる。そのため、NN回路100は、命令実行モジュールの演算処理効率を向上させることができる。
 以上、本発明の第一実施形態について図面を参照して詳述したが、具体的な構成はこの実施形態に限られるものではなく、本発明の要旨を逸脱しない範囲の設計変更等も含まれる。また、上述の実施形態および変形例において示した構成要素は適宜に組み合わせて構成することが可能である。
(変形例1)
 上記実施形態において、第一メモリ1と第二メモリ2は別のメモリであったが、第一メモリ1と第二メモリ2の態様はこれに限定されない。第一メモリ1と第二メモリ2は、例えば、同一メモリにおける第一メモリ領域と第二メモリ領域であってもよい。
(変形例2)
 例えば、上記実施形態に記載のNN回路100に入力されるデータは単一の形式に限定されず、静止画像、動画像、音声、文字、数値およびこれらの組み合わせで構成することが可能である。なお、NN回路100に入力されるデータは、NN回路100が設けられるエッジデバイスに搭載され得る、光センサ、温度計、Global Positioning System(GPS)計測器、角速度計測器、風速計などの物理量測定器における測定結果に限られない。周辺機器から有線または無線通信経由で受信する基地局情報、車両・船舶等の情報、天候情報、混雑状況に関する情報などの周辺情報や金融情報や個人情報等の異なる情報を組み合わせてもよい。
(変形例3)
 NN回路100が設けられるエッジデバイスは、バッテリー等で駆動する携帯電話などの通信機器、パーソナルコンピュータなどのスマートデバイス、デジタルカメラ、ゲーム機器、ロボット製品などのモバイル機器を想定するが、これに限られるものではない。Power on Ethernet(PoE)などでの供給可能なピーク電力制限、製品発熱の低減または長時間駆動の要請が高い製品に利用することでも他の先行例にない効果を得ることができる。例えば、車両や船舶などに搭載される車載カメラや、公共施設や路上などに設けられる監視カメラ等に適用することで長時間の撮影を実現できるだけでなく、軽量化や高耐久化にも寄与する。また、テレビやディスプレイ等の表示デバイス、医療カメラや手術ロボット等の医療機器、製造現場や建築現場で使用される作業ロボットなどにも適用することで同様の効果を奏することができる。
(変形例4)
 NN回路100は、NN回路100の一部または全部を一つ以上のプロセッサを用いて実現してもよい。例えば、NN回路100は、入力層または出力層の一部または全部をプロセッサによるソフトウェア処理により実現してもよい。ソフトウェア処理により実現する入力層または出力層の一部は、例えば、データの正規化や変換である。これにより、様々な形式の入力形式または出力形式に対応できる。なお、プロセッサで実行するソフトウェアは、通信手段や外部メディアを用いて書き換え可能に構成してもよい。
(変形例5)
 NN回路100は、CNN200における処理の一部をクラウド上のGraphics Processing Unit(GPU)等を組み合わせることで実現してもよい。NN回路100は、NN回路100が設けられるエッジデバイスで行った処理に加えて、クラウド上でさらに処理を行ったり、クラウド上での処理に加えてエッジデバイス上で処理を行ったりすることで、より複雑な処理を少ないリソースで実現できる。このような構成によれば、NN回路100は、処理分散によりエッジデバイスとクラウドとの間の通信量を低減できる。
(変形例6)
 NN回路100が行う演算は、学習済みのCNN200の少なくとも一部であったが、NN回路100が行う演算の対象はこれに限定されない。NN回路100が行う演算は、例えば畳み込み演算と量子化演算のように、2種類の演算を繰り返す学習済みのニューラルネットワークの少なくとも一部であってもよい。
 また、本明細書に記載された効果は、あくまで説明的または例示的なものであって限定的ではない。つまり、本開示に係る技術は、上記の効果とともに、または上記の効果に代えて、本明細書の記載から当業者には明らかな他の効果を奏しうる。
 本発明は、ニューラルネットワークの演算に適用することができる。
200 畳み込みニューラルネットワーク
100 ニューラルネットワーク回路(NN回路)
1 第一メモリ
2 第二メモリ
3 DMAコントローラ(DMAC)
4 畳み込み演算回路
5 量子化演算回路
6 コントローラ
61 レジスタ
62 IFU(命令フェッチユニット)
63 フェッチユニット
62A フェッチユニット(第三フェッチユニット)
62B フェッチユニット(第一フェッチユニット)
62C フェッチユニット(第二フェッチユニット)
64 割り込み生成回路
S セマフォ
F1 第一データフロー
F2 第二データフロー
F3 第三データフロー
C3 命令コマンド(第三命令コマンド)
C4 命令コマンド(第一命令コマンド)
C5 命令コマンド(第二命令コマンド)

Claims (7)

  1.  入力データに対して畳み込み演算を行う畳み込み演算回路と、
     前記畳み込み演算回路の畳み込み演算出力データに対して量子化演算を行う量子化演算回路と、
     前記畳み込み演算回路または前記量子化演算回路を動作させる命令コマンドをメモリから読み出す命令フェッチユニットと、
     を備える、
     ニューラルネットワーク回路。
  2.  前記命令フェッチユニットは、
     前記畳み込み演算回路を動作させる前記命令コマンドを読み出し、前記畳み込み演算回路に供給する第一フェッチユニットと、
     前記量子化演算回路を動作させる前記命令コマンドを読み出し、前記量子化演算回路に供給する第二フェッチユニットと、
     を有する、
     請求項1に記載のニューラルネットワーク回路。
  3.  前記命令フェッチユニットは、
     前記命令コマンドが格納された前記メモリのメモリアドレスを保持する命令ポインタと、
     格納された前記命令コマンドのコマンド数を保持する命令カウンタと、
     を有する、
     請求項1または請求項2に記載のニューラルネットワーク回路。
  4.  前記入力データを格納する第一メモリと、
     前記畳み込み演算出力データを格納する第二メモリと、
     をさらに備え、
     前記量子化演算回路の量子化演算出力データは、前記第一メモリに格納されて、
     前記第一メモリに格納された前記量子化演算出力データは、前記畳み込み演算回路に前記入力データとして入力される、
     請求項1から請求項3のいずれか一項に記載のニューラルネットワーク回路。
  5.  前記第一メモリまたは前記第二メモリを経由するデータフローを制御するセマフォをさらに備え、
     前記畳み込み演算回路または前記量子化演算回路は、前記命令コマンドに基づいて動作する際に、前記セマフォを操作する、
     請求項4に記載のニューラルネットワーク回路。
  6.  入力データに対して畳み込み演算を行う畳み込み演算回路と、
     前記畳み込み演算回路の畳み込み演算出力データに対して量子化演算を行う量子化演算回路と、
     前記畳み込み演算回路または前記量子化演算回路を動作させる命令コマンドをメモリから読み出す命令フェッチユニットと、
     を備えるニューラルネットワーク回路の制御方法であって、
     前記命令フェッチユニットに、前記命令コマンドを前記メモリから読み出させて、前記畳み込み演算回路または前記量子化演算回路に対して前記命令コマンドを供給させるステップと、
     供給された前記命令コマンドに基づいて前記畳み込み演算回路または前記量子化演算回路を動作させるステップと、
     を有する、
     ニューラルネットワーク回路の制御方法。
  7.  前記ニューラルネットワーク回路は、データフローを制御するセマフォをさらに備え、
     前記命令コマンドに基づいて動作する前記畳み込み演算回路または前記量子化演算回路に、前記セマフォを操作させるステップをさらに有する、
     請求項6に記載のニューラルネットワーク回路の制御方法。
PCT/JP2021/005610 2020-08-07 2021-02-16 ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法 WO2022030037A1 (ja)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US18/019,365 US20230289580A1 (en) 2020-08-07 2021-02-16 Neural network circuit and neural network circuit control method
CN202180057849.0A CN116113926A (zh) 2020-08-07 2021-02-16 神经网络电路以及神经网络电路的控制方法

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2020134562A JP6931252B1 (ja) 2020-08-07 2020-08-07 ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法
JP2020-134562 2020-08-07

Publications (1)

Publication Number Publication Date
WO2022030037A1 true WO2022030037A1 (ja) 2022-02-10

Family

ID=77456405

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2021/005610 WO2022030037A1 (ja) 2020-08-07 2021-02-16 ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法

Country Status (4)

Country Link
US (1) US20230289580A1 (ja)
JP (1) JP6931252B1 (ja)
CN (1) CN116113926A (ja)
WO (1) WO2022030037A1 (ja)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04275603A (ja) * 1991-03-01 1992-10-01 Fuji Electric Co Ltd プログラマブル・コントローラ
JPH08339299A (ja) * 1995-04-12 1996-12-24 Matsushita Electric Ind Co Ltd パイプライン・プロセッサ
JP2006301894A (ja) * 2005-04-20 2006-11-02 Nec Electronics Corp マルチプロセッサシステム、及びマルチプロセッサシステムのメッセージ伝達方法
JP2010152926A (ja) * 2001-07-11 2010-07-08 Seiko Epson Corp データ処理装置、データ入出力装置およびデータ入出力方法
US20140025930A1 (en) * 2012-02-20 2014-01-23 Samsung Electronics Co., Ltd. Multi-core processor sharing li cache and method of operating same
JP2019139747A (ja) * 2018-02-13 2019-08-22 北京曠視科技有限公司Beijing Kuangshi Technology Co., Ltd. 演算装置、演算実行設備及び演算実行方法

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8447961B2 (en) * 2009-02-18 2013-05-21 Saankhya Labs Pvt Ltd Mechanism for efficient implementation of software pipelined loops in VLIW processors
US10733505B2 (en) * 2016-11-10 2020-08-04 Google Llc Performing kernel striding in hardware

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04275603A (ja) * 1991-03-01 1992-10-01 Fuji Electric Co Ltd プログラマブル・コントローラ
JPH08339299A (ja) * 1995-04-12 1996-12-24 Matsushita Electric Ind Co Ltd パイプライン・プロセッサ
JP2010152926A (ja) * 2001-07-11 2010-07-08 Seiko Epson Corp データ処理装置、データ入出力装置およびデータ入出力方法
JP2006301894A (ja) * 2005-04-20 2006-11-02 Nec Electronics Corp マルチプロセッサシステム、及びマルチプロセッサシステムのメッセージ伝達方法
US20140025930A1 (en) * 2012-02-20 2014-01-23 Samsung Electronics Co., Ltd. Multi-core processor sharing li cache and method of operating same
JP2019139747A (ja) * 2018-02-13 2019-08-22 北京曠視科技有限公司Beijing Kuangshi Technology Co., Ltd. 演算装置、演算実行設備及び演算実行方法

Also Published As

Publication number Publication date
JP2022030486A (ja) 2022-02-18
JP6931252B1 (ja) 2021-09-01
US20230289580A1 (en) 2023-09-14
CN116113926A (zh) 2023-05-12

Similar Documents

Publication Publication Date Title
CN111667542B (zh) 适用于人工神经网络的用于处理压缩数据的解压缩技术
US9927862B2 (en) Variable precision in hardware pipelines for power conservation
WO2021210527A1 (ja) ニューラルネットワーク回路の制御方法
JP2023021913A (ja) システム・オン・チップの性能を向上させるために、処理タスクを分離式アクセラレータにオフロードすること
JP6896306B1 (ja) ニューラルネットワーク回路、エッジデバイスおよびニューラルネットワーク演算方法
US20240095522A1 (en) Neural network generation device, neural network computing device, edge device, neural network control method, and software generation program
JP2023024945A (ja) ベクトル・プロセッサを使用して、システム・オン・チップにおいて特徴追跡動作のためのダイレクト・メモリ・アクセス・システムを設定すること
JP2023021914A (ja) システム・オン・チップのプログラム可能なビジョン・アクセラレータ用内蔵自己テスト
JP2023021912A (ja) システム・オン・チップの分離式ルックアップ・テーブル・アクセラレータを使用してテーブルのルックアップを高速化すること
US20240054014A1 (en) Shared Control Bus for Graphics Processors
WO2022030037A1 (ja) ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法
CN117112165A (zh) 虚拟现实应用任务的处理方法、装置、虚拟现实系统
US11842436B2 (en) Snapshot arbitration techniques for memory requests
CN115701597A (zh) 在片上系统中使用解耦查找表加速器来加速表查找
KR102667790B1 (ko) 뉴럴 네트워크 회로, 에지 디바이스 및 뉴럴 네트워크 연산 방법
WO2023139990A1 (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
WO2024111644A1 (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
WO2023058422A1 (ja) ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法
WO2022004815A1 (ja) ニューラルネットワーク生成装置、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラム
WO2024038662A1 (ja) ニューラルネットワーク学習装置およびニューラルネットワーク学習方法
WO2022085661A1 (ja) ニューラルネットワーク生成装置、ニューラルネットワーク制御方法およびソフトウェア生成プログラム
JP2024075106A (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
US10269091B1 (en) Re-using graphics vertex identifiers for primitive blocks across states
JP2022105437A (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
JP2022183833A (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: 21853722

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21853722

Country of ref document: EP

Kind code of ref document: A1