Neural network circuit and neural network operation method

The neural network circuit and method optimize convolutional neural networks for embedded devices by incorporating a convolution operation circuit and DMA controller, addressing hardware limitations and enhancing computational performance.

JP2024118195APending Publication Date: 2024-08-30LEAPMIND INC
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
JP2023024486
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-02-20
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

Convolutional neural networks are difficult to implement in embedded devices like IoT devices due to limited hardware resources, and software alone cannot achieve sufficient computational performance.

Method used

A neural network circuit with a convolution operation circuit, instruction memory, DMA controller, and instruction provision unit, along with a neural network calculation method that includes convolution and quantization operations, optimized for embedded devices.

Benefits of technology

The solution enables high-performance neural network operations in embedded devices, reducing hardware requirements and improving computational efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2024118195000001
    Figure 2024118195000001
Patent Text Reader

Abstract

To provide a high-performance neural network circuit that can be incorporated into embedded devices such as IoT devices, and a neural network operation method.SOLUTION: A neural network circuit includes: a neural network operation core having a convolution operation circuit that performs a convolution operation based on a first instruction command; an instruction providing unit having an instruction memory that stores the first instruction command and providing the first instruction command to the convolution operation circuit; and a DMA controller transferring data between the neural network operation core and an external memory.SELECTED DRAWING: Figure 20
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present invention relates to a neural network circuit and a neural network operation method. [Background technology]

[0002] In recent years, convolutional neural networks (CNNs) have been used as models for image recognition and the like. Convolutional neural networks have a multi-layer structure with convolutional layers and pooling layers, and require a large number of calculations, such as convolutional calculations. Various calculation methods have been devised to speed up calculations by convolutional neural networks (Patent Document 1, etc.). [Prior art documents] [Patent documents]

[0003] [Patent Document 1] JP 2018-077829 A Summary of the Invention [Problem to be solved by the invention]

[0004] On the other hand, it is desired to realize image recognition using a convolutional neural network in embedded devices such as IoT devices. It is difficult to incorporate a large-scale dedicated circuit such as that described in Patent Document 1 into an embedded device. Also, in an embedded device with limited hardware resources such as a CPU and memory, it is difficult to realize sufficient computing performance of a convolutional neural network by software alone.

[0005] In consideration of the above circumstances, an object of the present invention is to provide a high-performance neural network circuit and neural network operation method that can be incorporated into embedded devices such as IoT devices. [Means for solving the problem]

[0006] In order to solve the above problems, the present invention proposes the following means. A neural network circuit according to a first aspect of the present invention comprises a neural network calculation core having a convolution calculation circuit that performs a convolution calculation based on a first instruction command, an instruction providing unit having an instruction memory that stores the first instruction command and that provides the first instruction command to the convolution calculation circuit, and a DMA controller that transfers data between the neural network calculation core and an external memory.

[0007] A neural network calculation method according to a second aspect of the present invention is a neural network calculation method using a convolution calculation circuit that performs a convolution calculation based on a first instruction command and an instruction providing unit having an instruction memory that stores the first instruction command, and includes a first step of storing the first instruction command in the instruction memory, and a second step of providing the first instruction command stored in the instruction memory to the convolution calculation circuit after the first step is completed. Effect of the Invention

[0008] The neural network circuit and neural network operation method of the present invention can be incorporated into embedded devices such as IoT devices and have high performance. [Brief description of the drawings]

[0009] [Figure 1] FIG. 1 illustrates a convolutional neural network. [Diagram 2] FIG. 2 is a diagram for explaining a convolution operation performed by a convolution layer. [Diagram 3] FIG. 13 is a diagram for explaining data expansion in a convolution operation. [Figure 4] 1 is a diagram showing an overall configuration of a neural network circuit according to a first embodiment; [Diagram 5] FIG. 2 is a diagram showing the overall configuration of an NN processing core. [Figure 6]10 is a timing chart showing an example of the operation of the NN processing core. [Figure 7] 13 is a timing chart showing another example of the operation of the same NN processing core. [Figure 8] FIG. 1 is a diagram illustrating a NN computing multi-core. [Figure 9] FIG. 2 is an internal block diagram of the DMAC of the neural network circuit. [Figure 10] FIG. 2 is a state transition diagram of a control circuit of the DMAC. [Figure 11] FIG. 2 is an internal block diagram of a convolution operation circuit of the neural network circuit. [Figure 12] FIG. 2 is an internal block diagram of a multiplier in the convolution operation circuit. [Figure 13] FIG. 2 is an internal block diagram of a multiply-and-accumulate unit of the multiplier. [Figure 14] FIG. 2 is an internal block diagram of an accumulator circuit of the convolution operation circuit. [Figure 15] FIG. 2 is an internal block diagram of an accumulator unit of the accumulator circuit. [Figure 16] FIG. 2 is an internal block diagram of an instruction decompressor of the convolution operation circuit. [Figure 17] FIG. 2 is an internal block diagram of a vector operation circuit and a quantization circuit of the quantization operation circuit. [Figure 18] FIG. 2 is a block diagram of a computing unit. [Figure 19] FIG. 2 is an internal block diagram of a vector quantization unit of the quantization circuit. [Figure 20] FIG. 2 is a block diagram of an instruction supply unit of the neural network circuit. [Figure 21] FIG. 2 is a diagram showing a memory map of the instruction memory of the instruction supply unit; [Figure 22] 4 is a control flowchart of the neural network circuit. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0010] First embodiment A first embodiment of the present invention will be described with reference to FIGS. 1 is a diagram showing a convolutional neural network 200 (hereinafter, referred to as "CNN 200"). The calculations performed by the neural network circuit 100 (hereinafter, referred to as "NN circuit 100") according to the first embodiment are at least a part of the trained CNN 200 used during inference.

[0011] [CNN200] The CNN 200 is a network with a multi-layer structure including a convolution layer 210 that performs a convolution operation, a quantization operation layer 220 that performs a quantization operation, and an output layer 230. In at least a part of the CNN 200, the convolution layer 210 and the quantization operation layer 220 are alternately connected. The CNN 200 is a model that is widely used for image recognition and video recognition. The CNN 200 may further include a layer having other functions, such as a fully connected layer.

[0012] FIG. 2 is a diagram illustrating the convolution operation performed by the convolution layer 210. The convolution layer 210 performs a convolution operation on the input data a using a weight w. The convolution layer 210 performs a multiply-and-accumulate operation on the input data a and the weight w.

[0013] The input data a (also called activation data or feature map) to the convolutional layer 210 is multidimensional data such as image data. In this embodiment, the input data a is a three-dimensional tensor consisting of elements (x, y, c). The convolutional layer 210 of the CNN 200 performs a convolution operation on the low-bit input data a. In this embodiment, the elements of the input data a are 2-bit unsigned integers (0, 1, 2, 3). The elements of the input data a may be, for example, 4-bit or 8-bit unsigned integers.

[0014] If the input data input to the CNN 200 has a different format from the input data a to the convolutional layer 210, such as a 32-bit floating-point type, the CNN 200 may further have an input layer before the convolutional layer 210 that performs type conversion and quantization.

[0015] The weight w (also called a filter or kernel) of the convolutional layer 210 is multidimensional data having elements that are learnable parameters. In this embodiment, the weight w is a four-dimensional tensor consisting of elements (i, j, c, d). The weight w has d three-dimensional tensors (hereinafter referred to as "weights wo") consisting of elements (i, j, c). The weight w in the trained CNN 200 is trained data. The convolutional layer 210 of the CNN 200 performs a convolution operation using a low-bit weight w. In this embodiment, the element of the weight w is a 1-bit signed integer (0, 1), where a value "0" represents +1 and a value "1" represents -1.

[0016] The convolution layer 210 performs the convolution operation shown in Equation 1 and outputs output data f. In Equation 1, s indicates the stride. The area indicated by the dotted line in Fig. 2 indicates one of the areas ao (hereinafter referred to as "application area ao") where the weight wo is applied to the input data a. The elements of the application area ao are represented by (x+i, y+j, c).

[0017]

number

[0018] The quantization operation layer 220 performs quantization and the like on the output of the convolution operation output by the convolution layer 210. The quantization operation layer 220 includes a pooling layer 221, a batch normalization layer 222, an activation function layer 223, and a quantization layer 224.

[0019] The pooling layer 221 compresses the output data f of the convolutional operation output by the convolutional layer 210 by performing calculations such as average pooling (Equation 2) and MAX pooling (Equation 3) on the output data f of the convolutional operation output by the convolutional layer 210. In Equations 2 and 3, u indicates an input tensor, v indicates an output tensor, and T indicates the size of the pooling region. In Equation 3, max is a function that outputs the maximum value of u for the combination of i and j included in T.

[0020]

number

[0021]

number

[0022] The batch normalization layer 222 normalizes the data distribution of the output data of the quantization operation layer 220 and the pooling layer 221, for example, by the operation shown in Equation 4. In Equation 4, u represents an input tensor, v represents an output tensor, α represents a scale, and β represents a bias. In the trained CNN 200, α and β are trained constant vectors.

[0023]

number

[0024] The activation function layer 223 performs an activation function operation such as ReLU (Equation 5) on the output of the quantization operation layer 220, the pooling layer 221, and the batch normalization layer 222. In Equation 5, u is an input tensor and v is an output tensor. In Equation 5, max is a function that outputs the largest numerical value among arguments.

[0025]

number

[0026] The quantization layer 224 performs quantization on the output of the pooling layer 221 and the activation function layer 223 based on the quantization parameter, for example, as shown in Equation 6. The quantization shown in Equation 6 reduces the input tensor u to 2 bits. In Equation 6, q(c) is a vector of quantization parameters. In the trained CNN 200, q(c) is a trained constant vector. The inequality sign "≦" in Equation 6 may be "<".

[0027]

number

[0028] The output layer 230 is a layer that outputs the result of the CNN 200 using an identity function, a softmax function, etc. The layer preceding the output layer 230 may be the convolution layer 210 or the quantization operation layer 220.

[0029] In the CNN 200, the quantized output data of the quantization layer 224 is input to the convolution layer 210, so the load of the convolution calculation in the convolution layer 210 is smaller than that of other convolution neural networks that do not perform quantization.

[0030] [Split convolution operations] The NN circuit 100 divides the input data of the convolution operation (Equation 1) of the convolution layer 210 into partial tensors and performs the operation. The method of division into the partial tensors and the number of divisions are not particularly limited. A partial tensor is formed, for example, by dividing the input data a(x+i, y+j, c) into a(x+i, y+j, co). Note that the NN circuit 100 can also perform the operation without dividing the input data of the convolution operation (Equation 1) of the convolution layer 210.

[0031] In input data division for a convolution operation, the variable c in Equation 1 is divided into blocks of size Bc, as shown in Equation 7. Also, the variable d in Equation 1 is divided into blocks of size Bd, as shown in Equation 8. In Equation 7, co is an offset, and ci is an index from 0 to (Bc-1). In Equation 8, do is an offset, and di is an index from 0 to (Bd-1). Note that size Bc and size Bd may be the same.

[0032]

number

[0033] [Number]

[0034] The input data a(x+i, y+j, c) in Equation 1 is divided in the c-axis direction by size Bc and is represented by the divided input data a(x+i, y+j, co). In the following description, the divided input data a is also referred to as the "divided input data a".

[0035] The weight w(i, j, c, d) in Equation 1 is divided in the c-axis direction by size Bc and in the d-axis direction by size Bd and is represented by the divided weight w(i, j, co, do). In the following description, the divided weight w is also referred to as the "divided weight w".

[0036] The output data f(x, y, do) divided by size Bd is obtained by Equation 9. By combining the divided output data f(x, y, do), the final output data f(x, y, d) can be calculated.

[0037] [Number]

[0038] [Expansion of Data in Convolution Operation] The NN circuit 100 expands the input data a and the weight w in the convolution operation of the convolutional layer 210 and performs the convolution operation.

[0039] Figure 3 is a diagram for explaining 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 elements of the divided input data a are indexed by ci (0 ≦ ci < Bc). In the following description, the divided input data a expanded into vector data for each i and j is also referred to as the "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)).

[0040] The segmentation weight w(i, j, co, do) is expanded into matrix data having Bc × Bd elements. The elements of the segmentation weight w expanded into matrix data are indexed by ci and di (0 ≦ di < Bd). In the following description, the segmentation weight w expanded into matrix data for each i and j is also referred to as a "weight matrix W". The weight matrix W has elements from the segmentation weight w(i, j, co × Bc, do × Bd) to the segmentation weight w(i, j, co × Bc+(Bc - 1), do × Bd+(Bd - 1)).

[0041] By multiplying the input vector A and the weight matrix W, vector data is calculated. By shaping the vector data calculated for each i, j, and co into a three-dimensional tensor, output data f(x, y, do) can be obtained. By performing such data expansion, the convolution operation of the convolutional layer 210 can be implemented by multiplying vector data and matrix data.

[0042] [NN Circuit 100] 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 DMA controller 3 (hereinafter also referred to as "DMAC3"), a controller 6, an instruction supply unit 7, and at least one neural network arithmetic core 10 (hereinafter also referred to as "NN arithmetic core 10").

[0043] The NN circuit 100 can implement a plurality of NN arithmetic cores 10. The NN circuit 100 illustrated in FIG. 4 can implement up to four NN arithmetic cores 10 at most. The plurality of NN arithmetic cores 10 constitute a "neural network arithmetic multi-core 10M (hereinafter also referred to as "NN arithmetic multi-core 10M")" that executes at least some of the operations of the NN200 in cooperation. The plurality of NN arithmetic cores 10 are daisy-chain connected in the present embodiment. Note that the number of NN arithmetic cores 10 that can be implemented in the NN circuit 100 may be five or more.

[0044] The DMAC 3 is connected to the external bus EB, and transfers data between the instruction supply unit 7 and an external memory 120 such as a DRAM. The DMAC 3 also transfers data between the external memory 120 such as a DRAM and the NN processing core 10. The DMAC 3 transfers data read from the external memory 120 to any one of the multiple NN processing cores 10. The DMAC 3 may be capable of transferring the same data read from the external memory 120 to the multiple NN processing cores 10, or may be capable of broadcasting the data.

[0045] The controller 6 is connected to an external bus EB, and operates as a slave to the external host CPU 110. The controller 6 includes a bus bridge 60 and a register 61.

[0046] The bus bridge 60 relays bus access from the external bus EB to the internal bus IB, and also relays write and read requests from the external host CPU 110 to the register 61.

[0047] 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 includes a pointer to the instruction sequence of each module, the number of instructions, and the like, and indicates the status of the NN circuit 100. The status register may also be configured to include a semaphore S. The external host CPU 110 can access the register 61 via the bus bridge 60 of the controller 6.

[0048] The controller 6 is connected to each block of the NN circuit 100 (DMAC 3, instruction supply unit 7, NN calculation core 10) via the internal bus IB. The external host CPU 110 can access each block of the NN circuit 100 via the controller 6. For example, the external host CPU 110 can issue instructions to the NN calculation core 10 via the controller 6. Furthermore, each block can update a status register (which may include a semaphore S) held by the controller 6 via the internal bus IB. The status register may be configured to be updated via a dedicated wiring connected to each block.

[0049] An instruction supply unit (ISU) 7 stores instruction commands for the operation blocks (DMAC 3, the convolution operation circuit 4 of the NN operation core 10, and the quantization operation circuit 5). The instruction supply unit 7 also transfers the stored instruction commands to the operation blocks (DMAC 3, the convolution operation circuit 4 of the NN operation core 10, and the quantization operation circuit 5) of the corresponding NN circuit 100.

[0050] [NN circuit 100: operation mode] The NN circuit 100 has two operation modes: a preload mode and a normal mode. In this embodiment, the NN circuit 100 operates by switching exclusively between the preload mode and the normal mode. The NN circuit 100 may also have other operation modes. The operation mode of the NN circuit 100 may also be switchable by rewriting an "operation mode setting register" included in the register 61.

[0051] When the operation mode is the preload mode (first mode), the DMAC 3 transfers the instruction commands of the operation blocks (DMAC 3, the convolution operation circuit 4 and the quantization operation circuit 5 of the NN operation core 10) stored in the external memory 120 to the instruction supply unit. At this time, the DMAC 3 may transfer the weight w stored in the external memory 120 to the weight memory 41. The DMAC 3 may also transfer the quantization parameter q stored in the external memory 120 to the quantization parameter memory 51.

[0052] When the operation mode is the normal mode (second mode), the instruction supply unit 7 supplies the stored instruction commands of the operation blocks (DMAC 3, the convolution operation circuit 4 of the NN operation core 10, and the quantization operation circuit 5) to the operation blocks (DMAC 3, the convolution operation circuit 4 of the NN operation core 10, and the quantization operation circuit 5). The operation blocks (DMAC 3, the convolution operation circuit 4 of the NN operation core 10, and the quantization operation circuit 5) execute the supplied instruction commands.

[0053] [NN calculation core 10] FIG. 5 is a diagram showing the overall configuration of the NN processing core 10. As shown in FIG. The NN calculation core 10 includes a first memory 1, a second memory 2, a convolution calculation circuit 4, and a quantization calculation circuit 5. The NN calculation core 10 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.

[0054] The first memory 1 is a rewritable memory such as a volatile memory constituted by, for example, SRAM (Static RAM). Data is written to and read from the first memory 1 via the DMAC 3 and the internal bus IB. The external host CPU 110 can input and output data to and from the NN calculation core 10 by writing and reading data to and from the first memory 1.

[0055] The first memory 1 is connected to an input port of the convolution operation circuit 4, and the convolution operation circuit 4 can read data from the first memory 1. The first memory 1 is also loop-connected (C1) to an output port of the quantization operation circuit 5, and the quantization operation circuit 5 can write data to the first memory 1. The first memory 1 is also capable of data transfer via an inter-core connection (C2) between the first memory 1 and another NN operation core 10, and the other NN operation core 10 connected to the inter-core connection (C2) can write data to the first memory 1. In this embodiment, a daisy-chain connection is used as an example of the inter-core connection (C2).

[0056] The second memory 2 is a rewritable memory such as a volatile memory constituted by, for example, SRAM (Static RAM). Data is written to and read from the second memory 2 via the DMAC 3 and the internal bus IB. The external host CPU 110 can input and output data to and from the NN calculation core 10 by writing and reading data to and from the second memory 2.

[0057] The second memory 2 is connected to an input port of the quantization operation circuit 5, and the quantization operation circuit 5 can read data from the second memory 2. In addition, the second memory 2 is connected to an output port of the convolution operation circuit 4, and the convolution operation circuit 4 can write data to the second memory 2.

[0058] The convolution operation circuit 4 is a circuit that performs a convolution operation in the convolution layer 210 of the trained CNN 200. The convolution operation circuit 4 reads the input data a stored in the first memory 1, and performs a convolution operation on the input data a. The convolution operation circuit 4 writes output data f of the convolution operation (hereinafter, also referred to as “convolution operation output data”) to the second memory 2.

[0059] The quantization operation circuit 5 is a circuit that performs at least a part of the quantization operation in the quantization operation layer 220 of the trained CNN 200. The quantization operation circuit 5 reads the output data f of the convolution operation stored in the second memory 2, and performs a quantization operation (an operation including at least quantization among pooling, batch normalization, activation function, and quantization) on the output data f of the convolution operation.

[0060] The quantization calculation circuit 5 writes output data of the quantization calculation (hereinafter also referred to as "quantization calculation output data") to the first memory 1 with which it is loop-connected (C1). In addition, the quantization calculation circuit 5 can transfer data to other NN calculation cores 10 via the inter-core connection (C2), and the quantization calculation circuit 5 can output the quantization calculation output data to other NN calculation cores 10 with which it is inter-core-connected (C2).

[0061] Since the NN processing core 10 has the first memory 1, the second memory 2, etc., it is possible to reduce the number of times that duplicate data is transferred in data transfer from an external memory such as a DRAM by the DMAC 3. This makes it possible to significantly reduce the power consumption or processing load caused by memory access.

[0062] [NN calculation core 10 operation example 1] FIG. 6 is a timing chart showing an example of the operation of the NN processing core 10. In FIG. 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 operation performed by the convolution operation circuit 4.

[0063] The convolution operation circuit 4 reads out the input data a of layer 1 stored in the first memory 1. The convolution operation circuit 4 performs the convolution operation of layer 1 shown in FIG.

[0064] The quantization calculation circuit 5 reads the output data f of layer 1 stored in the second memory 2. The quantization calculation circuit 5 performs a quantization calculation of layer 2 on the output data f of layer 1. The output data of the quantization calculation of layer 2 is stored in the first memory 1.

[0065] The convolution operation circuit 4 reads the output data of the quantization operation of the layer 2 stored in the first memory 1. The convolution operation circuit 4 performs a convolution operation of the layer 3 using the output data of the quantization operation of the layer 2 as input data a. The output data f of the convolution operation of the layer 3 is stored in the second memory 2.

[0066] The convolution operation circuit 4 reads the output data of the quantization operation of the layer 2M-2 (M is a natural number) stored in the first memory 1. The convolution operation circuit 4 performs the convolution operation of the layer 2M-1 using the output data of the quantization operation of the layer 2M-2 as input data a. The output data f of the convolution operation of the layer 2M-1 is stored in the second memory 2.

[0067] The quantization calculation circuit 5 reads the output data f of the layer 2M-1 stored in the second memory 2. The quantization calculation circuit 5 performs the quantization calculation of the layer 2M on the output data f of the 2M-1 layer. The output data of the quantization calculation of the layer 2M is stored in the first memory 1.

[0068] The convolution operation circuit 4 reads the output data of the quantization operation of the layer 2M stored in the first memory 1. The convolution operation circuit 4 performs a convolution operation of the layer 2M+1 using the output data of the quantization operation of the layer 2M as input data a. The output data f of the convolution operation of the layer 2M+1 is stored in the second memory 2.

[0069] The convolution calculation circuit 4 and the quantization calculation circuit 5 alternately perform calculations to advance the calculations of the CNN 200 shown in Fig. 1. In the NN calculation core 10, the convolution calculation circuit 4 performs the convolution calculations of layers 2M-1 and 2M+1 by time sharing. In the NN calculation core 10, the quantization calculation circuit 5 performs the quantization calculations of layers 2M-2 and 2M by time sharing. Therefore, the circuit scale of the NN calculation core 10 is significantly smaller than when a separate convolution calculation circuit 4 and quantization calculation circuit 5 are implemented for each layer.

[0070] The NN processing core 10 performs the calculations of the CNN 200, which is a multi-layer structure of multiple layers, using a circuit formed in a loop. The NN processing core 10 can efficiently use hardware resources due to the loop circuit configuration. Since the NN processing core 10 forms a circuit in a loop, the parameters in the convolution processing circuit 4 and the quantization processing circuit 5, which change in each layer, are updated appropriately.

[0071] When the calculations of the CNN 200 include calculations that cannot be performed by the NN calculation core 10, the NN calculation core 10 transfers intermediate data to an external calculation device such as an external host CPU 110. After the external calculation device performs calculations on the intermediate data, the calculation results by the external calculation device are input to the first memory 1 and / or the second memory 2. The NN calculation core 10 resumes calculations on the calculation results by the external calculation device.

[0072] [NN calculation core 10 operation example 2] FIG. 7 is a timing chart showing another example of the operation of the NN processing core 10. In FIG. The NN processing core 10 may divide the input data a into partial tensors and perform operations on the partial tensors by time division. The method of division into the partial tensors and the number of divisions are not particularly limited.

[0073] 7 shows an example of operation when input data a is decomposed into two partial tensors. The decomposed partial tensors are called "first partial tensor a1" and "second partial tensor a2". For example, the convolution operation of layer 2M-1 is decomposed into a convolution operation corresponding to the first partial tensor a1 (indicated as "layer 2M-1(a1)" in FIG. 7) and a convolution operation corresponding to the second partial tensor a2 (indicated as "layer 2M-1(a2)" in FIG. 7).

[0074] The convolution operation and quantization operation corresponding to the first partial tensor a1 and the convolution operation and quantization operation corresponding to the second partial tensor a2 can be performed independently, as shown in FIG.

[0075] The convolution operation circuit 4 performs a convolution operation of the layer 2M-1 corresponding to the first partial tensor a1 (operation shown as layer 2M-1(a1) in FIG. 7). After that, the convolution operation circuit 4 performs a convolution operation of the layer 2M-1 corresponding to the second partial tensor a2 (operation shown as layer 2M-1(a2) in FIG. 7). In addition, the quantization operation circuit 5 performs a quantization operation of the layer 2M corresponding to the first partial tensor a1 (operation shown as layer 2M(a1) in FIG. 7). In this way, the NN operation core 10 can perform the convolution operation of the layer 2M-1 corresponding to the second partial tensor a2 and the quantization operation of the layer 2M corresponding to the first partial tensor a1 in parallel.

[0076] Next, the convolution operation circuit 4 performs a convolution operation of layer 2M+1 corresponding to the first partial tensor a1 (operation shown as layer 2M+1(a1) in FIG. 7). Moreover, the quantization operation circuit 5 performs a quantization operation of layer 2M corresponding to the second partial tensor a2 (operation shown as layer 2M(a2) in FIG. 7). In this way, the NN operation core 10 can perform, in parallel, the convolution operation of layer 2M+1 corresponding to the first partial tensor a1 and the quantization operation of layer 2M corresponding to the second partial tensor a2.

[0077] The convolution operation and quantization operation corresponding to the first partial tensor a1 and the convolution operation and quantization operation corresponding to the second partial tensor a2 can be performed independently. Therefore, the NN processing core 10 may perform, for example, the convolution operation of the layer 2M-1 corresponding to the first partial tensor a1 and the quantization operation of the layer 2M+2 corresponding to the second partial tensor a2 in parallel. In other words, the convolution operation and quantization operation that the NN processing core 10 performs in parallel are not limited to the operations of consecutive layers.

[0078] By dividing the input data a into partial tensors, the NN processing core 10 can operate the convolution processing circuit 4 and the quantization processing circuit 5 in parallel. As a result, the waiting time of the convolution processing circuit 4 and the quantization processing circuit 5 is reduced, improving the processing efficiency of the NN processing core 10. In the operation example shown in FIG. 7, the number of divisions is 2, but even when the number of divisions is greater than 2, the NN processing core 10 can similarly operate the convolution processing circuit 4 and the quantization processing circuit 5 in parallel.

[0079] For example, when the input data a is divided into a “first partial tensor a1”, a “second partial tensor a2”, and a “third partial tensor a3”, the NN processing core 10 may perform a convolution operation of the layer 2M-1 corresponding to the second partial tensor a2 and a quantization operation of the layer 2M corresponding to the third partial tensor a3 in parallel. The order of the operations is appropriately changed depending on the storage status of the input data a in the first memory 1 and the second memory 2.

[0080] As an example of a method of computing partial tensors, an example (method 1) has been shown in which a partial tensor in the same layer is computed by the convolution computation circuit 4 or the quantization computation circuit 5, and then a partial tensor in the next layer is computed. For example, as shown in Fig. 7, in the convolution computation circuit 4, a convolution computation of layer 2M-1 corresponding to the first partial tensor a1 and the second partial tensor a2 (computation shown by layer 2M-1(a1) and layer 2M-1(a2) in Fig. 7) is performed, and then a convolution computation of layer 2M+1 corresponding to the first partial tensor a1 and the second partial tensor a2 (computation shown by layer 2M+1(a1) and layer 2M+1(a2) in Fig. 7).

[0081] However, the method of operation on the partial tensors is not limited to this. The method of operation on the partial tensors may be a method of performing an operation on some of the partial tensors in multiple layers and then performing an operation on the remaining partial tensors (method 2). For example, in the convolution operation circuit 4, after performing a convolution operation on the layer 2M-1 corresponding to the first partial tensor a1 and the layer 2M+1 corresponding to the first partial tensor a1, a convolution operation on the layer 2M-1 corresponding to the second partial tensor a2 and the layer 2M+1 corresponding to the second partial tensor a2 may be performed.

[0082] Furthermore, the method of computing partial tensors may be a method of computing partial tensors by combining method 1 and method 2. However, when using method 2, it is necessary to perform the computation in accordance with the dependency relationship regarding the computation order of the partial tensors.

[0083] [NN calculation multi-core 10M] FIG. 8 is a diagram showing the NN calculation multi-core 10M. The NN processing multi-core 10M illustrated in Fig. 8 includes two daisy-chained NN processing cores 10. When distinguishing between the two NN processing cores 10, the two NN processing cores 10 are referred to as a "first NN processing core 10A" and a "second NN processing core 10B." In Fig. 8, the first memory 1 is abbreviated as "A," the convolution processing circuit 4 as "C," the second memory 2 as "F," and the quantization processing circuit 5 as "Q."

[0084] Specifically, the quantization calculation circuit 5 of the first NN arithmetic core 10A and the first memory 1 of the second NN arithmetic core 10B are daisy-chain connected (C2). The quantization calculation circuit 5 of the first NN arithmetic core 10A can write quantization calculation output data to the first memory 1 of the first NN arithmetic core 10A connected in a loop (C1) and / or the first memory 1 of the second NN arithmetic core 10B connected in a daisy chain (C2).

[0085] Specifically, the quantization calculation circuit 5 of the second NN calculation core 10B and the first memory 1 of the first NN calculation core 10A are daisy-chain connected (C2). The quantization calculation circuit 5 of the second NN calculation core 10B can write the quantization calculation output data to the first memory 1 of the second NN calculation core 10B connected in a loop (C1) and / or the first memory 1 of the first NN calculation core 10A connected in a daisy chain (C2).

[0086] Similarly, when the NN processing multi-core 10M has three or more NN processing cores 10, the multiple NN processing cores 10 are connected in a daisy chain. The quantization processing circuit 5 of the NN processing cores 10 other than the final stage NN processing core 10 is connected in a daisy chain (C2) with the first memory 1 of the subsequent stage NN processing core 10B. The quantization processing circuit 5 of the final stage NN processing core 10 is connected in a daisy chain (C2) with the first memory 1 of the first stage NN processing core 10. The multiple NN processing cores 10 are characterized by being formed in a daisy chain loop (linked together).

[0087] In one NN calculation core 10, the first memory (A) 1, the convolution calculation circuit (C) 4, the second memory (F) 2, and the quantization calculation circuit (Q) 5 are connected in a loop. On the other hand, in the NN calculation multi-core 10M, the first memory (A) 1, the convolution calculation circuit (C) 4, the second memory (F) 2, and the quantization calculation circuit (Q) 5 are connected in a daisy chain loop (linked together) so that the first memory (A) 1, the convolution calculation circuit (C) 4, the second memory (F) 2, and the quantization calculation circuit (Q) 5 are repeatedly arranged in the same order.

[0088] The multiple NN calculation cores 10 constituting the NN calculation multi-core 10M do not need to have the same hardware configuration. For example, the capacity and configuration of the first memory 1 of the first NN calculation core 10A may be different from the capacity and configuration of the first memory 1 of the second NN calculation core 10B. For example, the configuration of the quantization calculation circuit 5 of the first NN calculation core 10A may be different from the configuration of the quantization calculation circuit 5 of the second NN calculation core 10B.

[0089] Next, each component of the NN circuit 100 will be described in detail.

[0090] [DMAC3] FIG. 9 is an internal block diagram of the DMAC3. The DMAC 3 has a data transfer circuit 31, a state controller 32, and a preload command generator 35. The DMAC 3 has a state controller 32 dedicated to the data transfer circuit 31, and when a command is input, it can perform DMA data transfer without requiring an external controller.

[0091] The data transfer circuit 31 is connected to the external bus EB, and transfers data between an external memory 120 such as a DRAM and the NN processing core 10. There is no limit to the number of DMA channels of the data transfer circuit 31. For example, the first NN processing core 10A and the second NN processing core 10B may each have a dedicated DMA channel.

[0092] The state controller 32 controls the state of the data transfer circuit 31. The state controller 32 is also connected to the controller 6 via an internal bus IB. The state controller 32 has an instruction queue 33 and a control circuit .

[0093] The instruction queue 33 is a queue that stores instruction commands C3 for the DMAC 3, and is configured, for example, by a FIFO memory. One or more instruction commands C3 are written to the instruction queue 33 via the instruction supply unit 7 or the internal bus IB.

[0094] The control circuit 34 is a state machine that decodes the instruction command C3 and sequentially controls the data transfer circuit 31 based on the instruction command C3. The control circuit 34 may be implemented by a logic circuit or a CPU controlled by software.

[0095] FIG. 10 is a state transition diagram of the control circuit 34. When an instruction command C3 is input to the instruction queue 33 (Not empty), the control circuit 34 transitions from the idle state ST1 to the decode state ST2.

[0096] In the decode state ST2, the control circuit 34 decodes the instruction command C3 output from the instruction queue 33. The control circuit 34 also reads the semaphore S stored in the register 61 of the controller 6, and determines whether the operation of the data transfer circuit 31 instructed in the instruction command C3 is executable. If it is not executable (Not ready), the control circuit 34 waits until it is executable (Wait). If it is executable (Ready), the control circuit 34 transitions from the decode state ST2 to the execution state ST3.

[0097] In the execution state ST3, the control circuit 34 controls the data transfer circuit 31 to cause the data transfer circuit 31 to perform the operation instructed in the instruction command C3. When the operation of the data transfer circuit 31 is completed, the control circuit 34 removes the executed instruction command C3 from the instruction queue 33 and updates the semaphore S stored in the register 61 of the controller 6. If there are instructions in the instruction queue 33 (Not empty), the control circuit 34 transitions from the execution state ST3 to the decode state ST2. If there are no instructions in the instruction queue 33 (Empty), the control circuit 34 transitions from the execution state ST3 to the idle state ST1.

[0098] The preload command generator 35 generates an instruction command C3 for causing the data transfer circuit 31 to execute the set data transfer based on the setting values ​​(source address, destination address, amount of data transfer) set in the "preload mode register" included in the register 61 of the controller 6, and inputs the generated command to the instruction queue 33. Note that the preload command generator 35 may be disposed in the controller 6 instead of in the DMAC 3.

[0099] [DMAC3: Operation in preload mode] When the operation mode of the NN circuit 100 is the preload mode, the data transfer circuit 31 performs a DMA transfer (hereinafter also referred to as "preload") from the external memory 120 to the instruction supply unit 7 based on a parameter register (preload mode register) related to the setting of the preload mode included in the register 61. The state controller 32 operates based on the instruction command C3 supplied by the preload instruction generator 35.

[0100] [DMAC3: Operation in normal mode] When the operation mode of the NN circuit 100 is the normal mode, the instruction supply unit 7 supplies an instruction command C3 to the instruction queue 33. The state controller 32 operates based on the instruction command C3 supplied by the instruction supply unit 7.

[0101] [Convolution circuit 4] FIG. 11 is an internal block diagram of the convolution operation circuit 4. As shown in FIG. The convolution operation circuit 4 has a weight memory 41, a multiplier 42, an accumulator circuit 43, and a state controller 44. The convolution operation circuit 4 has a state controller 44 dedicated to the multiplier 42 and the accumulator circuit 43, and when an instruction command is input, the convolution operation can be performed without requiring an external controller.

[0102] The weight memory 41 is a memory in which the weight w used in the convolution calculation is stored, and is a rewritable memory such as a volatile memory constituted by, for example, an SRAM (Static RAM), etc. The DMAC 3 writes the weight w required for the convolution calculation into the weight memory 41 by DMA transfer.

[0103] FIG. 12 is an internal block diagram of the multiplier 42. The multiplier 42 multiplies the input vector A by the weight matrix W. As described above, the input vector A is vector data having Bc elements in which the divided input data a(x+i, y+j, co) is expanded for each i and j. The weight matrix W is matrix data having Bc×Bd elements in which the divided weights w(i,j,co,do) are expanded for each i and j. The multiplier 42 has Bc×Bd product-sum operation units 47 and can multiply the input vector A by the weight matrix W in parallel.

[0104] The multiplier 42 reads out the input vector A and the weight matrix W required for the multiplication from the first memory 1 and the weight memory 41, and performs the multiplication. The multiplier 42 outputs Bd product-sum operation results O(di).

[0105] FIG. 13 is an internal block diagram of the product-sum calculation unit 47. As shown in FIG. The multiply-add unit 47 multiplies an element A(ci) of an input vector A by an element W(ci,di) of a weight matrix W. The multiply-add unit 47 also adds the multiplication result to a multiplication result S(ci,di) of another multiply-add unit 47. The multiply-add unit 47 outputs an addition result S(ci+1,di). The element A(ci) is a 2-bit unsigned integer (0,1,2,3). The element W(ci,di) is a 1-bit signed integer (0,1), where a value "0" represents +1 and a value "1" represents -1.

[0106] The multiply-and-accumulate unit 47 has an inverter 47a, a selector 47b, and an adder 47c. The multiply-and-accumulate unit 47 performs multiplication using only the inverter 47a and the selector 47b, without using a multiplier. When the element W(ci,di) is "0", the selector 47b selects the input of the element A(ci). When the element W(ci,di) is "1", the selector 47b selects the complement of the element A(ci) inverted by the inverter. The element W(ci,di) is also input to the carry-in of the adder 47c. When the element W(ci,di) is "0", the adder 47c outputs a value obtained by adding the element A(ci) to S(ci,di). When W(ci,di) is "1", the adder 47c outputs a value obtained by subtracting the element A(ci) from S(ci,di).

[0107] FIG. 14 is an internal block diagram of the accumulator circuit 43. The accumulator circuit 43 accumulates the product-sum operation results O(di) of the multiplier 42 in the second memory 2. The accumulator circuit 43 has Bd accumulator units 48 and can accumulate the Bd product-sum operation results O(di) in parallel in the second memory 2.

[0108] FIG. 15 is an internal block diagram of the accumulator unit 48. The accumulator unit 48 has an adder 48a and a mask section 48b. The adder 48a adds an element O(di) of the multiply-and-accumulate result O to a partial sum that is an intermediate result of the convolution operation shown in Equation 1 and stored in the second memory 2. The addition result is 16 bits per element. The addition result is not limited to 16 bits per element, and may be, for example, 15 bits or 17 bits per element.

[0109] The adder 48a writes the addition result to the same address in the second memory 2. When the initialization signal clear is asserted, the masking unit 48b masks the output from the second memory 2 and sets the addition target for the element O(di) to zero. The initialization signal clear is asserted when no intermediate partial sums are stored in the second memory 2.

[0110] When the convolution operation by the multiplier 42 and the accumulator circuit 43 is completed, the output data f(x, y, do) is stored in the second memory 2.

[0111] The state controller 44 controls the states of the multiplier 42 and the accumulator circuit 43. The state controller 44 is also connected to the controller 6 via an internal bus IB. The state controller 44 has an instruction queue 45 and a control circuit 46.

[0112] The instruction queue 45 is a queue in which the instruction commands C4 for the convolution operation circuit 4 are stored, and is configured by, for example, a FIFO memory. The instruction commands C4 are written to the instruction queue 45 via the instruction supply unit 7 or the internal bus IB.

[0113] The control circuit 46 is a state machine that decodes the instruction command C4 and controls the multiplier 42 and the accumulator circuit 43 based on the instruction command C4. The control circuit 46 has a similar configuration to the control circuit 34 of the state controller 32 of the DMAC 3.

[0114] [Convolution circuit 4: Operation in preload mode] When the operation mode of the NN circuit 100 is the preload mode, the state controller 44 does not operate. When the weight w is included in the data to be preloaded, the DMAC 3 writes the weight w read from the external memory 120 into the weight memory 41.

[0115] [Convolution circuit 4: Operation in normal mode] When the operation mode of the NN circuit 100 is the normal mode, the instruction supply unit 7 supplies an instruction command C4 to the instruction queue 45. The state controller 44 controls the multiplier 42 and the accumulator circuit 43 based on the instruction command C4 stored in the instruction queue 45.

[0116] [Quantization operation circuit 5] FIG. 16 is an internal block diagram of the quantization calculation circuit 5. As shown in FIG. The quantization calculation circuit 5 has a quantization parameter memory 51, a vector calculation circuit 52, a quantization circuit 53, and a state controller 54. The quantization calculation circuit 5 has a state controller 54 dedicated to the vector calculation circuit 52 and the quantization circuit 53, and when an instruction command is input, the quantization calculation can be performed without requiring an external controller.

[0117] The quantization parameter memory 51 is a memory in which the quantization parameter q used in the quantization operation is stored, and is a rewritable memory such as a volatile memory constituted by, for example, an SRAM (Static RAM), etc. The DMAC 3 writes the quantization parameter q required for the quantization operation into the quantization parameter memory 51 by DMA transfer.

[0118] FIG. 17 is an internal block diagram of the vector calculation circuit 52 and the quantization circuit 53. The vector operation circuit 52 performs an operation on the output data f(x, y, do) stored in the second memory 2. The vector operation circuit 52 has Bd operation units 57, and performs SIMD operations in parallel on the output data f(x, y, do).

[0119] FIG. 18 is a block diagram of the arithmetic unit 57. The arithmetic unit 57 includes, for example, an ALU 57a, a first selector 57b, a second selector 57c, a register 57d, and a shifter 57e. The arithmetic unit 57 may further include other arithmetic units included in a known general-purpose SIMD arithmetic circuit.

[0120] The vector calculation circuit 52 performs at least one of the calculations of the pooling layer 221, the batch normalization layer 222, and the activation function layer 223 in the quantization calculation layer 220 on the output data f(x, y, do) by combining the calculation units and the like contained in the calculation unit 57.

[0121] The arithmetic unit 57 can add the data stored in the register 57d and the element f(di) of the output data f(x, y, do) read from the second memory 2 by the ALU 57a. The arithmetic unit 57 can store the addition result by the ALU 57a in the register 57d. The arithmetic unit 57 can initialize the addition result by inputting "0" to the ALU 57a instead of the data stored in the register 57d by the selection of the first selector 57b. For example, when the pooling area is 2×2, the shifter 57e can output the average value of the addition result by shifting the output of the ALU 57a to the right by 2 bits. The vector arithmetic circuit 52 can perform the average pooling calculation shown in Equation 2 by repeating the above calculations by the Bd arithmetic units 57.

[0122] The arithmetic unit 57 can compare the data stored in the register 57d with the element f(di) of the output data f(x, y, do) read from the second memory 2 by the ALU 57a. The arithmetic unit 57 controls the second selector 57c according to the comparison result by the ALU 57a, and can select the larger of the data stored in the register 57d and the element f(di). The arithmetic unit 57 can initialize the comparison target to the minimum value by inputting the minimum value of the possible values ​​of the element f(di) to the ALU 57a by the selection of the first selector 57b. In this embodiment, the element f(di) is a 16-bit signed integer, so the minimum value of the possible values ​​of the element f(di) is "0x8000". The vector arithmetic circuit 52 can perform the MAX pooling calculation of Equation 3 by repeating the above calculations by the Bd arithmetic units 57. Note that in the MAX pooling calculation, the shifter 57e does not shift the output of the second selector 57c.

[0123] The arithmetic unit 57 can subtract data stored in the register 57d and an element f(di) of the output data f(x, y, do) read from the second memory 2 by the ALU 57a. The shifter 57e can shift the output of the ALU 57a to the left (i.e., multiplication) or to the right (i.e., division). The vector arithmetic circuit 52 can perform the batch normalization calculation of Equation 4 by repeating the above calculations by the Bd arithmetic units 57.

[0124] The arithmetic unit 57 can compare the element f(di) of the output data f(x, y, do) read from the second memory 2 with "0" selected by the first selector 57b by the ALU 57a. The arithmetic unit 57 can select and output either the element f(di) or a constant value "0" previously stored in the register 57d according to the comparison result by the ALU 57a. The vector arithmetic circuit 52 can perform the ReLU arithmetic of Equation 5 by repeating the above arithmetic operations by the Bd arithmetic units 57.

[0125] The vector operation circuit 52 can perform average pooling, MAX pooling, batch normalization, activation function operations, and combinations of these operations. Since the vector operation circuit 52 can perform general-purpose SIMD operations, it may perform other operations necessary for the operations in the quantization operation layer 220. In addition, the vector operation circuit 52 may perform operations other than those in the quantization operation layer 220.

[0126] It is to be noted that the quantization calculation circuit 5 does not have to include the vector calculation circuit 52. When the quantization calculation circuit 5 does not include the vector calculation circuit 52, the output data f(x, y, do) is input to the quantization circuit 53.

[0127] The quantization circuit 53 quantizes the output data of the vector operation circuit 52. The quantization circuit 53 has Bd quantization units 58, as shown in FIG.

[0128] FIG. 19 is an internal block diagram of the quantization unit 58. The quantization unit 58 quantizes the element in(di) of the output data of the vector operation circuit 52. The quantization unit 58 has a comparator 58a and an encoder 58b. The quantization unit 58 performs the operation (Equation 6) of the quantization layer 224 in the quantization operation layer 220 on the output data (16 bits / element) of the vector operation circuit 52. The quantization unit 58 reads out the necessary quantization parameters q(th0, th1, th2) from the quantization parameter memory 51, and compares the input in(di) with the quantization parameter q by the comparator 58a. The quantization unit 58 quantizes the comparison result by the comparator 58a to 2 bits / element by the encoder 58b. Since α(c) and β(c) in Equation 4 are parameters that differ for each variable c, the quantization parameters q(th0, th1, th2) that reflect α(c) and β(c) are parameters that differ for each in(di).

[0129] The quantization unit 58 classifies the input in(di) into four regions (for example, in≦th0, th0<in≦th1, th1<in≦th2, th2<in) by comparing the input in(di) with three thresholds th0, th1, and th2, encodes the classification result into 2 bits, and outputs it. The quantization unit 58 can also perform operations of Batch Normalization and activation functions together with quantization by setting the quantization parameters q(th0, th1, th2).

[0130] The quantization unit 58 can perform the operation of Batch Normalization shown in Equation 4 together with quantization by setting the threshold th0 as β(c) in Equation 4 and the threshold differences (th1−th0) and (th2−th1) as α(c) in Equation 4. By increasing (th1−th0) and (th2−th1), α(c) can be decreased. By decreasing (th1−th0) and (th2−th1), α(c) can be increased.

[0131] The quantization unit 58 can perform an activation function together with quantization of the input in(di). For example, the quantization unit 58 saturates the output value in the regions where in(di)≦th0 and th2<in(di). The quantization unit 58 can perform the operation of the activation function together with quantization by setting the quantization parameter q so that the output is non-linear.

[0132] The state controller 54 controls the states of the vector operation circuit 52 and the quantization circuit 53. Also, the state controller 54 is connected to the controller 6 via the internal bus IB. The state controller 54 has an instruction queue 55 and a control circuit 56.

[0133] The instruction queue 55 is a queue in which the instruction command C5 for the quantization operation circuit 5 is stored, and is composed of, for example, a FIFO memory. The instruction command C5 is written into the instruction queue 55 via the instruction supply unit 7 or the internal bus IB.

[0134] The control circuit 56 is a state machine that decodes the instruction command C5 and controls the vector calculation circuit 52 and the quantization circuit 53 based on the instruction command C5. The control circuit 56 has a similar configuration to the control circuit 34 of the state controller 32 of the DMAC 3.

[0135] [Quantization Calculation Circuit 5: Operation in Preload Mode] When the operation mode of the NN circuit 100 is the preload mode, the state controller 54 does not operate. When the quantization parameter q is included in the data to be preloaded, the DMAC 3 writes the quantization parameter q read from the external memory 120 into the quantization parameter memory 51.

[0136] [Quantization operation circuit 5: operation in normal mode] When the operation mode of the NN circuit 100 is the normal mode, the instruction supply unit 7 supplies an instruction command C5 to the instruction queue 55. The state controller 54 controls the vector operation circuit 52 and the quantization circuit 53 based on the instruction command C5 stored in the instruction queue 55.

[0137] The quantization calculation circuit 5 writes the quantization calculation output data having Bd elements into the first memory 1. A suitable relationship between Bd and Bc is shown in Equation 10. In Equation 10, n is an integer.

[0138]

number

[0139] [Controller 6] The controller 6 transfers the instruction command transferred from the external host CPU 110 to the instruction queues of the DMAC 3, the convolution operation circuit 4, and the quantization operation circuit 5 via the internal bus IB.

[0140] The controller 6 is connected to an external bus EB, and operates as a slave to the external host CPU 110. The controller 6 has registers 61 including 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 that indicates the status of the NN circuit 100, including the semaphore S.

[0141] The register 61 has a parameter register (hereinafter, also referred to as a "preload mode register") related to the setting of the preload mode. The preload mode register includes a preload start register, a top address of the external memory 120 which is the transfer source of the preload, an address of the transfer destination of the preload, and a data transfer amount to be preloaded. The preload mode register can hold a plurality of set values ​​related to data transfer (combinations of a transfer source address, a transfer destination address, and a data transfer amount). By setting the preload mode register, the NN circuit 100 changes the operation mode to the preload mode and starts the operation in the preload mode. When the operation in the preload mode is completed, the NN circuit 100 changes the operation mode to the normal mode and starts the operation in the normal mode. The operation mode of the NN circuit 100 is not automatically changed to the normal mode even when the operation in the preload mode is completed, and may be changed from the preload mode to the normal mode by explicitly rewriting the operation mode setting register included in the register 61.

[0142] The register 61 has a parameter register related to settings for instruction supply by the instruction supply unit 7 (hereinafter, also referred to as an “instruction supply register”).

[0143] [Command Supply Unit 7] FIG. 20 is a block diagram of the instruction supply unit 7. The instruction supply unit (ISU) 7 has an instruction memory 71 and an instruction supply circuit 72. The instruction memory 71 stores instruction commands for the DMAC 3, the convolution operation circuit 4, and the quantization operation circuit 5. The instruction supply circuit 72 supplies the instruction commands stored in the instruction memory 71 to the DMAC 3, the convolution operation circuit 4, and the quantization operation circuit 5.

[0144] [Instruction supply unit 7: Operation in preload mode] When the operation mode of the NN circuit 100 is the preload mode, the instruction supply circuit 72 does not operate. The data transfer circuit 31 of the DMAC 3 writes an instruction command into the instruction memory 71.

[0145] [Command supply unit 7: Operation in normal mode] When the operation mode of the NN circuit 100 is the normal mode, the instruction supply circuit 72 supplies the instruction commands stored in the instruction memory 71 to the DMAC 3, the convolution operation circuit 4, and the quantization operation circuit 5. The instruction supply circuit 72 supplies the corresponding instruction commands to the instruction queues 33, 45, and 55 at any time based on the status flags such as the full flags of the instruction queues 33, 45, and 55.

[0146] FIG. 21 is a diagram showing a memory map of the instruction memory 71. As shown in FIG. The instruction supply register stores the start address of a memory area in which an instruction command C3 to be supplied to the DMAC 3 is stored, the start address of a memory area in which an instruction command C4 to be supplied to the convolution operation circuit 4 is stored, and the start address of a memory area in which an instruction command C5 to be supplied to the quantization operation circuit 5 is stored. The instruction supply circuit 72 executes supply of an instruction command based on the start address stored in the instruction supply register. When the NN operation multi-core 10M includes two or more NN operation cores 10, a start address is set for each of the convolution operation circuit 4 and the quantization operation circuit 5 of the NN operation core 10.

[0147] For example, when the instruction commands are stored in the instruction memory 71 as shown in the memory map of Fig. 21, the instruction commands used by the second application different from the first application are stored in the memory areas whose top addresses start from addresses A1, A2, and A3. Also, the instruction commands used by the second application different from the first application are stored in the memory areas whose top addresses start from addresses A4, A5, and A6. When the first application is executed, the top addresses of the instruction supply register are set to addresses A1, A2, and A3. When the application to be executed is changed from the first application to the second application, the top addresses of the instruction supply register are set to addresses A4, A5, and A6.

[0148] [Operation of NN circuit 100] Next, the operation of the NN circuit 100 (neural network operation method) will be described with reference to the control flowchart of the NN circuit 100 shown in Fig. 22. After performing an initialization process (step S100), the NN circuit 100 executes step S110 based on the setting of the preload mode register.

[0149] <Step S110: Preload Mode (First Mode)> In step S110, the DMAC 3 of the NN circuit 100 performs preloading based on the setting of the preload mode register (first step). Specifically, the data transfer circuit 31 of the DMAC 3 performs DMA transfer (preloading) of an instruction command from the external memory 120 to the instruction supply unit 7 based on the setting of the preload mode register. If the data to be preloaded includes a weight w, the data transfer circuit 31 performs DMA transfer (preloading) of the weight w to the weight memory 41. If the data to be preloaded includes a quantum parameter q, the data transfer circuit 31 performs DMA transfer (preloading) of the quantum parameter q to the quantization parameter memory 51. When the preloading set in the preload mode register is completed, the NN circuit 100 changes the operation mode to normal mode and executes step S120.

[0150] If the calculation related to the CNN 200 is large-scale, the number of instruction commands to be transferred to the instruction supply unit 7 increases, and the data transfer period in preload and the memory capacity required for the instruction memory 71 increase. In this case, the DMAC 3 of the NN circuit 100 may divide the instruction commands and transfer them to the instruction memory 71 in the preload mode. For example, if the instruction memory 71 has a memory capacity sufficient to store all the instruction commands, the DMAC 3 of the NN circuit 100 supplies all the instruction commands to the instruction memory 71. If not, the DMAC 3 of the NN circuit 100 may supply only a portion of the instruction commands that the instruction memory 71 can store to the instruction memory 71, rather than transferring all the instruction commands.

[0151] <Step S120: Normal mode (second mode)> In step S120, the instruction supply unit 7 of the NN circuit 100 supplies an instruction command based on the setting of the instruction supply register (second step). Specifically, the instruction supply circuit 72 supplies the instruction command C3 stored in the instruction memory 71 to the instruction queue 33 of the DMAC 3, supplies the instruction command C4 to the instruction queue 45 of the convolution operation circuit 4, and supplies the instruction command C5 to the instruction queue 55 of the quantization operation circuit 5. The DMAC 3, the convolution operation circuit 4, and the quantization operation circuit 5 start operating based on the supplied instruction commands. When all or part of the instruction commands stored in the instruction memory 71 have been executed, the NN circuit 100 next executes step S130.

[0152] <Step S130> In step S130, the NN circuit 100 determines whether to end the control flow shown in Fig. 22. If the control flow is not to be ended, the NN circuit 100 executes step S120 again. Note that the NN circuit 100 may resume the control flow from step S110. If the control is to be ended, the NN circuit 100 next executes step S140 to end the control flow.

[0153] According to the neural network circuit 100 of this embodiment, the NN circuit 100 that can be embedded in an embedded device such as an IoT device can be operated with high performance. When the operation mode is the preload mode, an instruction command is read from the external memory 120. When the operation mode is the normal mode, DMA transfer of data other than the instruction command (input data a, weight w, quantization parameter q, intermediate data) is executed between the external memory 120 and the NN processing core 10. Therefore, reading of the instruction command from the external memory 120 and DMA transfer of data other than the instruction command do not occur simultaneously. Therefore, the NN circuit 100 can prevent the bandwidth of the external bus EB from being compressed due to simultaneous occurrence of reading of the instruction command and DMA transfer of data other than the instruction command.

[0154] Writing of an instruction command to the instruction memory 71 in the preload mode and reading of an instruction command from the instruction memory 71 in the normal mode do not occur simultaneously. Therefore, the instruction memory 71 does not need to be implemented as a two-port RAM. The instruction memory 71 can be implemented as a single-port RAM, which has a smaller circuit scale than a two-port RAM.

[0155] If the weight w is included in the data to be preloaded, the weight w is read from the external memory 120 when the operation mode is the preload mode. Therefore, when the operation mode is the normal mode, reading of the weight w from the external memory 120 can be omitted. As a result, the bandwidth of the external bus EB when the operation mode is the normal mode can be further reduced. Also, the weight memory 41 can be implemented with a single-port RAM, which has a smaller circuit scale than a two-port RAM.

[0156] If the preloaded data includes a quantum parameter q, when the operation mode is the preload mode, the quantum parameter q is read from the external memory 120. Therefore, when the operation mode is the normal mode, reading of the quantum parameter q from the external memory 120 can be omitted. As a result, the bandwidth of the external bus EB can be further reduced when the operation mode is the normal mode. In addition, the quantization parameter memory 51 can also be implemented by a single-port RAM, which has a smaller circuit scale than a two-port RAM.

[0157] Although the first embodiment of the present invention has been described above in detail with reference to the drawings, the specific configuration is not limited to this embodiment, and design modifications and the like that do not depart from the gist of the present invention are also included. Also, the components shown in the above embodiment and modified examples can be appropriately combined to form a configuration.

[0158] (Variation 1) Although the instruction supply unit 7 in the above embodiment has one instruction memory 71, the form of the instruction memory 71 is not limited to this. The instruction supply unit 7 may have multiple instruction memories 71. The instruction supply unit 7 may have, for example, a first instruction memory that stores an instruction command C3, a second instruction memory that stores an instruction command C4, and a third instruction memory that stores an instruction command C5.

[0159] (Variation 2) In the above embodiment, the first memory 1 and the second memory 2 are separate memories, but the aspects of the first memory 1 and the second memory 2 are 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.

[0160] (Variation 3) For example, 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, numbers, or combinations of these. The data input to the NN circuit 100 is not limited to the measurement results of physical quantity measuring instruments such as optical sensors, thermometers, Global Positioning System (GPS) measuring instruments, angular velocity measuring instruments, and anemometers that may be mounted on the edge device in which the NN circuit 100 is provided. Different information such as base station information received from peripheral devices via wired or wireless communication, information on vehicles and ships, weather information, and congestion information, as well as peripheral information, financial information, and personal information may also be combined.

[0161] (Variation 4) The edge device in which the NN circuit 100 is provided is assumed to be a communication device such as a battery-powered mobile phone, a smart device such as a personal computer, a digital camera, a game device, a robot product, and other mobile devices, but is not limited thereto. By using the NN circuit 100 in products that have a high demand for limiting the peak power that can be supplied by Power on Ethernet (PoE), reducing heat generation of the product, or long-term operation, it is possible to obtain effects not seen in other prior art. For example, by applying the NN circuit 100 to an in-vehicle camera mounted on a vehicle or ship, or a surveillance camera installed in a public facility or on the road, it is possible to realize long-term shooting, and it also contributes to weight reduction and high durability. In addition, the same effect can be obtained by applying the NN circuit 100 to a display device such as a television or a display, medical equipment such as a medical camera or a surgical robot, and a work robot used in a manufacturing site or a construction site.

[0162] (Variation 5) The NN circuit 100 may be realized in part or in whole by using one or more processors. For example, the NN circuit 100 may realize in part or in whole the input layer or the output layer by software processing by a processor. A part of the input layer or the output layer realized by software processing is, for example, data normalization or conversion. This makes it possible to support various types of input formats or output formats. Note that the software executed by the processor may be configured to be rewritable using communication means or external media.

[0163] (Variation 6) The NN circuit 100 may implement part of the processing in the CNN 200 by combining a graphics processing unit (GPU) or the like on the cloud. The NN circuit 100 can implement more complex processing with fewer resources by performing further processing on the cloud in addition to the processing performed on the edge device on which the NN circuit 100 is installed, or by performing processing on the edge device in addition to the processing on the cloud. With such a configuration, the NN circuit 100 can reduce the amount of communication between the edge device and the cloud by distributing processing.

[0164] In addition, the effects described in this specification are merely descriptive or exemplary and are not limiting. In other words, the technology according to the present disclosure may achieve other effects that are apparent to a person skilled in the art from the description of this specification, in addition to or in place of the above effects. [Industrial Applicability]

[0165] The present invention can be applied to neural network operations. [Explanation of symbols]

[0166] 200 Convolutional Neural Networks 100 Neural network circuit (NN circuit) 10 Neural network calculation core (NN calculation core) 10A First Neural Network Calculation Core (First NN Calculation Core) 10B Second Neural Network Calculation Core (Second NN Calculation Core) 10M Neural network calculation multi-core (NN calculation multi-core) 1. First Memory 2 Second Memory 3. DMA Controller (DMAC) 4. Convolution Circuit 42 Multiplier 43 Accumulator Circuit 5 Quantization operation circuit 52 Vector arithmetic circuit 53 Quantization circuit 6 Controller 61 Registers 7. Command Supply Unit 71 Instruction Memory 72 Instruction supply circuit C3 Command (third command) C4 Command (First Command) C5 Command (Second Command)

Claims

1. a neural network calculation core having a convolution calculation circuit that executes a convolution calculation based on a first instruction command; an instruction providing unit having an instruction memory for storing the first instruction command and providing the first instruction command to the convolution operation circuit; a DMA controller for transferring data between the neural network computing core and an external memory; Equipped with Neural network circuit.

2. When the operation mode of the neural network circuit is in a first mode, the DMA controller transfers the first instruction command from the external memory to the instruction memory.

2. The neural network circuit of claim 1.

3. When the operation mode of the neural network circuit is the second mode, the instruction providing unit supplies the first instruction command stored in the instruction memory to the convolution operation circuit.

3. The neural network circuit of claim 2.

4. The neural network operation core further includes a quantization operation circuit that performs a quantization operation on the convolution operation output data of the convolution operation circuit based on a second command; the instruction memory stores the second instruction command; when the operation mode of the neural network circuit is the first mode, the DMA controller transfers the second instruction command from the external memory to the instruction memory; 3. The neural network circuit of claim 2.

5. When the operation mode of the neural network circuit is a second mode, the instruction providing unit supplies the second instruction command stored in the instruction memory to the quantization operation circuit.

5. The neural network circuit of claim 4.

6. The DMA controller transfers the data based on a third instruction command; the instruction memory stores the third instruction command; when the operation mode of the neural network circuit is the first mode, the DMA controller transfers the third instruction command from the external memory to the instruction memory; 3. The neural network circuit of claim 2.

7. when the operation mode of the neural network circuit is the second mode, the instruction providing unit supplies the third instruction command stored in the instruction memory to the DMA controller; 7. The neural network circuit of claim 6.

8. The instruction memory is implemented as a single-ported RAM.

2. The neural network circuit of claim 1.

9. the instruction memory stores the first instruction command to be used for a first application and the first instruction command to be used for a second application different from the first application; 2. The neural network circuit of claim 1.

10. The neural network computing core includes a plurality of the neural network computing cores, The plurality of neural network calculation cores are connected to each other so as to be capable of inputting and outputting data.

2. The neural network circuit of claim 1.

11. A neural network operation method using a convolution operation circuit that performs a convolution operation based on a first instruction command, and an instruction providing unit having an instruction memory that stores the first instruction command, comprising: a first step of storing the first instruction command in the instruction memory; a second step of providing the first instruction command stored in the instruction memory to the convolution operation circuit after the first step is completed; Equipped with Neural network calculation method.

Citation Information

Patent Citations

  • Neural network circuit and method for controlling neural network circuit

    JP2022030486A

  • Neural network accelerator with parameters resident on chip

    US20190050717A1

  • Information processing method, information processing device and program

    JP2018077829A