WO2022004815A1 - ニューラルネットワーク生成装置、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラム - Google Patents

ニューラルネットワーク生成装置、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラム Download PDF

Info

Publication number
WO2022004815A1
WO2022004815A1 PCT/JP2021/024836 JP2021024836W WO2022004815A1 WO 2022004815 A1 WO2022004815 A1 WO 2022004815A1 JP 2021024836 W JP2021024836 W JP 2021024836W WO 2022004815 A1 WO2022004815 A1 WO 2022004815A1
Authority
WO
WIPO (PCT)
Prior art keywords
neural network
execution model
quantization
memory
data
Prior art date
Application number
PCT/JP2021/024836
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/013,162 priority Critical patent/US20230316071A1/en
Priority to CN202180044360.XA priority patent/CN115702426A/zh
Priority to JP2022534096A priority patent/JPWO2022004815A1/ja
Publication of WO2022004815A1 publication Critical patent/WO2022004815A1/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/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0495Quantised networks; Sparse networks; Compressed networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/048Activation functions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent

Definitions

  • the present invention relates to a neural network generator, a neural network generation method, and a neural network generation program.
  • 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).
  • embedded devices such as IoT devices also use image recognition using convolutional neural networks.
  • a generation method for generating a neural network (model or circuit) that matches the hardware configuration of the embedded device is desired.
  • a learning method of a neural network that operates the neural network with high performance with limited hardware resources of an embedded device is desired.
  • the present invention provides a neural network generation device, a neural network generation method, and a neural network generation program that can be incorporated into an embedded device such as an IoT device and can operate with high performance.
  • the purpose is to do.
  • the neural network generation device is a neural network generation device that generates a neural network execution model that calculates a neural network, and the hardware on which the neural network execution model operates.
  • An execution model generation unit that generates the neural network execution model based on the hardware information of the wear and the network information of the neural network, and a learning unit that generates the trained parameters of the generated neural network execution model. , Equipped with.
  • the neural network generation method is a neural network generation method for generating a neural network execution model that calculates a neural network, and obtains hardware information of the hardware on which the neural network execution model operates.
  • the neural network generation program is a neural network generation program that causes a computer to generate a neural network execution model that calculates a neural network, and is hardware of the hardware on which the neural network execution model operates. Based on the hardware information acquisition process that causes the computer to acquire information, the network information acquisition process that causes the computer to set the network information of the neural network, and the hardware information and the network information, the neural network execution model is computerized. It is provided with an execution model generation step of causing the computer to learn the learning parameters of the generated execution model of the neural network execution model.
  • the neural network generation device, neural network generation method, and neural network generation program of the present invention can be incorporated into an embedded device such as an IoT device, and can generate a neural network that can be operated with high performance.
  • FIG. 1 is a diagram showing a neural network generation device 300 according to the present embodiment.
  • the neural network generation device 300 is a device that generates a trained neural network execution model 100 that can be incorporated into an embedded device such as an IoT device.
  • the neural network execution model 100 is a software or hardware model generated for operating a convolutional neural network 200 (hereinafter referred to as “CNN200”) in an embedded device.
  • CNN200 convolutional neural network 200
  • the neural network generation device 300 is a program-executable device (computer) equipped with a processor such as a CPU (Central Processing Unit) and hardware such as a memory.
  • the function of the neural network generation device 300 is realized by executing the neural network generation program in the neural network generation device 300.
  • the neural network generation device 300 includes a storage unit 310, a calculation unit 320, a data input unit 330, a data output unit 340, a display unit 350, and an operation input unit 360.
  • the storage unit 310 stores the hardware information HW, the network information NW, the learning data set DS, the neural network execution model 100 (hereinafter referred to as “NN execution model 100”), and the learned parameter PM.
  • the hardware information HW, the learning data set DS, and the network information NW are input data input to the neural network generator 300.
  • the NN execution model 100 and the trained parameter PM are output data output by the neural network generator 300.
  • the "trained NN execution model 100" includes the NN execution model 100 and the trained parameter PM.
  • Hardware information HW is information on an embedded device (hereinafter referred to as "operation target hardware") that operates the NN execution model 100.
  • the hardware information HW is, for example, a device type, device constraint, memory configuration, bus configuration, operating frequency, power consumption, manufacturing process type, etc. of the operation target hardware.
  • the device type is, for example, an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array), or the like.
  • Device constraints include the upper limit of the number of arithmetic units included in the operation target device and the upper limit of the circuit scale.
  • the memory configuration is a memory type, the number of memories, a memory capacity, and an input / output data width.
  • the bus configuration includes bus type, bus width, bus communication standard, connection devices on the same bus, and the like. Further, when there are a plurality of variations in the NN execution model 100, the hardware information HW includes information regarding the variations of the NN execution model 100 to be used.
  • Network information NW is the basic information of CNN200.
  • the network information NW is, for example, the network configuration of the CNN200, input data information, output data information, quantization information, and the like.
  • the input data information includes an input data type such as an image and a sound, and an input data size.
  • the learning data set DS has training data D1 used for learning and test data D2 used for inference test.
  • FIG. 2 is a diagram showing input / output of the calculation unit 320.
  • the calculation unit 320 includes an execution model generation unit 321, a learning unit 322, an inference unit 323, and a hardware generation unit 324.
  • the NN execution model 100 input to the arithmetic unit 320 may be generated by a device other than the neural network generation device 300.
  • the execution model generation unit 321 generates the NN execution model 100 based on the hardware information HW and the network information NW.
  • the learning unit 322 generates the learned parameter PM by using the NN execution model 100 and the learning data D1.
  • the inference unit 323 carries out an inference test using the NN execution model 100 and the test data D2.
  • the hardware generation unit 324 generates the neural network hardware model 400 based on the hardware information HW and the NN execution model 100.
  • the neural network hardware model 400 is a hardware model that can be implemented in the operating target hardware.
  • the neural network hardware model 400 is optimized for the operating target hardware based on the hardware information HW.
  • the neural network hardware model 400 may be an RTL (Register Transfer Level), a netlist representing a connection between a gate or a circuit module, or a combination thereof.
  • the neural network hardware model 400 may be a parameter list or a configuration file necessary for implementing the NN execution model 100 in the hardware. The parameter list and configuration file are used in combination with the separately generated NN execution model 100.
  • the hardware information HW, network information NW, etc. necessary for generating the trained NN execution model 100 are input to the data input unit 330.
  • the hardware information HW, network information NW, and the like are input as data described in, for example, a predetermined data format.
  • the input hardware information HW, network information NW, and the like are stored in the storage unit 310.
  • the hardware information HW, the network information NW, and the like may be input or changed by the user from the operation input unit 360.
  • the generated trained NN execution model 100 is output to the data output unit 340.
  • the generated NN execution model 100 and the learned parameter PM are output to the data output unit 340.
  • the display unit 350 has a known monitor such as an LCD display.
  • the display unit 350 can display a console screen for receiving GUI (Graphical User Interface) images, commands, and the like generated by the calculation unit 320. Further, when the calculation unit 320 requires information input from the user, the display unit 350 can display a message prompting the user to input information from the operation input unit 360 or a GUI image necessary for information input.
  • GUI Graphic User Interface
  • the operation input unit 360 is a device in which the user inputs an instruction to the calculation unit 320 or the like.
  • the operation input unit 360 is a known input device such as a touch panel, a keyboard, and a mouse. The input of the operation input unit 360 is transmitted to the calculation unit 320.
  • All or part of the functions of the arithmetic unit 320 are realized by executing a program stored in the program memory by one or more processors such as a CPU (Central Processing Unit) and a GPU (Graphics Processing Unit). ..
  • processors such as a CPU (Central Processing Unit) and a GPU (Graphics Processing Unit).
  • all or part of the functions of the arithmetic unit 320 are hardware such as LSI (Large Scale Integration), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array), PLD (Programmable Logic Device) (for example). It may be realized by a circuit unit; circuity). Further, all or a part of the functions of the arithmetic unit 320 may be realized by a combination of software and hardware.
  • All or part of the functions of the arithmetic unit 320 may be realized by using an external accelerator such as a CPU, GPU, or hardware provided in an external device such as a cloud server.
  • the arithmetic unit 320 can improve the arithmetic speed of the arithmetic unit 320 by using, for example, a GPU having high arithmetic performance on a cloud server or dedicated hardware in combination.
  • the storage unit 310 is realized by a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), a ROM (Read-Only Memory), a RAM (Random Access Memory), or the like. All or part of the storage unit 310 may be provided in an external device such as a cloud server and may be connected to the arithmetic unit 320 or the like by a communication line.
  • EEPROM Electrically Erasable Programmable Read-Only Memory
  • ROM Read-Only Memory
  • RAM Random Access Memory
  • FIG. 3 is a diagram showing an example of CNN200.
  • the network information NW of the CNN200 is information regarding the configuration of the CNN200 described below.
  • the CNN200 uses a low bit weight w and quantized input data a, and is easy to incorporate into an embedded device.
  • 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. 4 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. 4 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 sign “ ⁇ ” 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. ..
  • FIG. 5 is a diagram showing an example of the NN execution model 100.
  • the NN execution model 100 is software or a hardware model generated for operating the CNN 200 in the operation target hardware.
  • Software includes software that controls the hardware model.
  • the hardware model may be behavior level, RTL (Register Transfer Level), netlist representing connections between gates and circuit modules, or a combination thereof. ..
  • the NN execution model 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. Be prepared.
  • the NN execution model 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 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 can input / output data to / from the NN execution model 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 can input / output data to / from the NN execution model 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 an external memory such as a DRAM and the first memory 1. Further, the DMAC 3 transfers data between an external memory such as a DRAM and the second memory 2. Further, the DMAC 3 transfers data between an external memory such as a DRAM and the convolution calculation circuit 4. Further, the DMAC 3 transfers data between an external memory such as a DRAM 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 slave of the external host CPU.
  • the controller 6 has a register 61 including a parameter register and a status register.
  • the parameter register is a register that controls the operation of the NN execution model 100.
  • the status register is a register indicating the status of the NN execution model 100 including the semaphore S.
  • the external host CPU can access the register 61 via the controller 6.
  • the controller 6 is connected to the first memory 1, the second memory 2, the DMAC 3, the convolution calculation circuit 4, and the quantization calculation circuit 5 via the internal bus IB.
  • the external host CPU can access each block via the controller 6. For example, the external host CPU can instruct instructions to the DMAC 3, the convolution calculation circuit 4, and the quantization calculation circuit 5 via the controller 6. Further, 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 execution model 100 has a first memory 1, a second memory 2, and the like, it is possible to reduce the number of times of data transfer of duplicate data in data transfer by DMAC3 from an external memory such as a DRAM. As a result, the power consumption generated by the memory access can be significantly reduced.
  • step S10 the operation of the neural network generation device 300 (neural network generation method) will be described with reference to the control flowchart of the neural network generation device 300 shown in FIG. After performing the initialization process (step S10), the neural network generation device 300 executes step S11.
  • step S11 the neural network generation device 300 acquires the hardware information HW of the operation target hardware (hardware information acquisition step).
  • the neural network generation device 300 acquires, for example, the hardware information HW input to the data input unit 330.
  • the neural network generation device 300 acquires the hardware information HW by displaying the GUI image necessary for inputting the hardware information HW on the display unit 350 and causing the user to input the hardware information HW from the operation input unit 360. You may.
  • the hardware information HW has a memory type, a memory capacity, and an input / output data width of the memory allocated as the first memory 1 and the second memory 2.
  • the acquired hardware information HW is stored in the storage unit 310.
  • the neural network generation device 300 executes step S12.
  • step S12 the neural network generation device 300 acquires the network information NW of the CNN 200 (network information acquisition step).
  • the neural network generation device 300 acquires, for example, the network information NW input to the data input unit 330.
  • the neural network generation device 300 may acquire the network information NW by displaying the GUI image necessary for inputting the network information NW on the display unit 350 and having the user input the network information NW from the operation input unit 360. ..
  • the network information NW includes a network configuration including an input layer and an output layer 230, a configuration of a convolution layer 210 including a weight w and a bit width of input data a, and a quantization calculation layer 220 including quantization information.
  • a network configuration including an input layer and an output layer 230, a configuration of a convolution layer 210 including a weight w and a bit width of input data a, and a quantization calculation layer 220 including quantization information.
  • the acquired network information NW is stored in the storage unit 310.
  • the neural network generation device 300 executes step S13.
  • step S13 the execution model generation unit 321 of the neural network generation device 300 generates the NN execution model 100 based on the hardware information HW and the network information NW (neural network execution model generation step).
  • the neural network execution model generation step is, for example, a layer mapping step (S13-1), a convolution calculation circuit generation step (S13-2), and a quantization calculation circuit generation step (S13-3). And a DMAC generation step (S13-4).
  • the execution model generation unit 321 maps each layer of the CNN 200 to the convolution calculation circuit 4 and the quantization calculation circuit 5 formed in a loop shape (layer mapping step).
  • the execution model generation unit 321 generates sequence data and software for sequentially executing each layer of the CNN 200 in the NN execution model 100.
  • a software module that can be executed by an external calculation device such as an external host CPU that is different from the NN execution model 100 is generated.
  • FIG. 7 is a timing chart showing an operation example of the NN execution model 100.
  • the execution model generation unit 321 generates sequence data and software that enable the operation of the NN execution model 100 shown in FIG. 7, for example.
  • an operation example of the NN execution model 100 shown in FIG. 7 will be described.
  • the DMAC 3 stores the input data a of the layer 1 (see FIG. 3) 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 out the input data a of the layer 1 (see FIG. 3) stored in the first memory 1.
  • the convolution calculation circuit 4 performs a layer 1 convolution operation on the layer 1 input data a.
  • the output data f of the layer 1 convolution operation is stored in the second memory 2.
  • the quantization 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 quantization calculation of the layer 2M-2 and the layer 2M by time division. Therefore, the circuit scale of the NN execution model 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 execution model 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 execution model 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 execution model 100 transfers intermediate data to an external calculation device such as an external host CPU. 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 execution model 100 restarts the calculation on the calculation result by the external calculation device.
  • an external calculation device such as an external host CPU.
  • the execution model generation unit 321 generates the convolution calculation circuit 4 of the NN execution model 100 based on the hardware information HW and the network information NW (convolution calculation circuit generation step).
  • the execution model generation unit 321 divides the data of the convolution operation of the convolution layer 210 based on the memory capacity of the memory allocated as the first memory 1 and the second memory 2.
  • the generated convolution calculation circuit 4 has a configuration capable of calculating the data of the divided convolution calculation. If the size (Bc or Bd) of the block that divides the data of the convolution calculation of the convolution layer 210 is reduced, the hardware scale of the convolution calculation circuit 4 is reduced, but the calculation efficiency of the convolution calculation of the convolution layer 210 is lowered.
  • FIG. 8 is a diagram illustrating data division and data expansion of the convolution operation.
  • the convolution calculation circuit 4 of the NN execution model 100 divides the input data of the convolution calculation (Equation 1) of the convolution layer 210 into partial tensors and calculates.
  • 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 convolution calculation circuit 4 of the NN execution model 100 can also calculate the input data of the convolution calculation (Equation 1) of the convolution layer 210 without dividing it.
  • ⁇ Convolution operation circuit generation process Data division of convolution operation>
  • the variable c in the equation 1 is divided into blocks of size Bc as shown in the equation 7.
  • 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 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.
  • the size (Bc or Bd) of the block that divides the data of the convolution operation is set to, for example, a size that can store a predetermined number of division input data a and a predetermined number of division weights w in the first memory 1. ..
  • the size of the input data a is X ⁇ Y ⁇ C
  • the size of the weight w is K ⁇ K ⁇ C ⁇ D
  • the size of the output data f is X ⁇ Y ⁇ D.
  • the output data f (x, y, do) divided by the size Bd in the d-axis direction is divided by the input data a (x + i, y + j, co) divided by the size Bc in the c-axis direction and the sizes Bc and Bd. It can be calculated by convolving the weight w (i, j, co, do) for each i, j, co and adding them together.
  • the size of the output data f (x, y, do) divided by the size Bd in the d-axis direction is 16 ⁇ X ⁇ Y ⁇ Bd bits.
  • the size of the input data a required to calculate the output data f divided by Bd is 2, X, Y, Bc bits.
  • the size of the weight w required to calculate the output data f divided by Bd is 1 ⁇ K ⁇ K ⁇ Bc ⁇ Bd bit.
  • the output data f (x, y, do) divided by Bd can be stored in the second memory 2.
  • the memory capacity of the first memory 1 is larger than the (2, X, Y, Bc + 1, K, K, Bc, Bd) bits, the input required for calculating the output data f divided by Bd.
  • the data a and the weight w can be stored in the first memory 1.
  • the size of the block to be divided (Bc or Bd) can be calculated from the upper limit of the memory capacity of the first memory 1 and the second memory 2. Further, the memory capacities of the first memory 1 and the second memory 2 can be calculated from the size of the block to be divided (Bc or Bd).
  • the memory capacities of the first memory 1 and the second memory 2 are at least twice the above-mentioned memory capacities, and double buffering can be performed. Is desirable.
  • the above example is an example of means for determining the size of the block to be divided (Bc or Bd) and the memory capacity of the first memory 1 and the second memory 2.
  • the size of the block to be divided (Bc or Bd) and the memory capacity of the first memory 1 and the second memory 2 are appropriately changed according to the memory usage mode, the number of parallel operations, and the like.
  • FIG. 9 is a timing chart showing another operation example of the NN execution model 100.
  • the NN execution model 100 may divide the input data a into partial tensors and perform operations on the partial tensors by time division.
  • FIG. 9 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 ".
  • convolution Layer 2M-1 can (9, “Layer 2M-1 (a 1)” hereinafter) convolution operation corresponding to the first portion tensor a 1 and, corresponding to the second portion tensor a 2 It is decomposed into a convolution operation (denoted as “Layer 2M-1 (a 2)" in FIG. 7).
  • 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.
  • Convolution operation circuit 4 (in FIG. 9, the operation indicated by the layer 2M-1 (a 1)) convolution Layer 2M-1 corresponding to the first portion tensor a 1 performs. Thereafter, the convolution operation circuit 4, the layer 2M-1 of the convolution operation corresponding to the second portion tensor a 2 (in FIG. 9, the layer 2M-1 (operation indicated by a 2)) performing.
  • the quantization arithmetic circuit 5 (in FIG. 9, the operation indicated by the layer 2M (a 1)) quantization operation layer 2M corresponding to the first portion tensor a 1 performs.
  • NN execution model 100 may be implemented with convolution Layer 2M-1 corresponding to the second portion tensor a 2, quantization and calculation of the layer 2M corresponding to the first portion tensor a 1, a parallel.
  • the convolution calculation circuit 4 performs a convolution operation of the layer 2M + 1 corresponding to the first partial tensor a 1 (the operation shown by the layer 2M + 1 (a 1 ) in FIG. 9). Further, the quantization calculation circuit 5 performs a layer 2M quantization operation (operation shown by layer 2M (a 2 ) in FIG. 9) corresponding to the second partial tensor a 2. As described above, the NN execution model 100 can execute 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 execution model 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 execution model 100 is improved.
  • the number of divisions into the partial tensor was 2, but similarly, when the number of divisions is larger than 2, the NN execution model 100 arranges the convolution operation circuit 4 and the quantization operation circuit 5 in parallel. Can be operated.
  • FIG. 10 is a diagram showing a partial tensor ft in which the output data f of the convolution operation is tiled.
  • the input data at is obtained by dividing the input data a into tiles (blocks) having a predetermined size in the x-axis direction and the y-axis direction.
  • the partial tensor ft is obtained by dividing the output data f into tiles (blocks) of size T in the x-axis direction and the y-axis direction, respectively.
  • the size of the input data a is X ⁇ Y ⁇ C
  • the size of the weight w is K ⁇ K ⁇ C ⁇ D
  • the size of the output data f is X ⁇ Y ⁇ D.
  • the convolution calculation circuit 4 reads a part of the input data at from the first memory 1 and performs the convolution calculation of the layer 2M-1 with the partial tensor ft (referred to as the first partial tensor ft 1) as an output.
  • the first partial tensor ft 1 is written to the second memory 2.
  • the quantization operation circuit 5 is a layer 2M quantum corresponding to the first partial tensor ft 1 stored in the second memory 2. Perform the conversion operation.
  • the output data of the layer 2M quantization operation is written in the first memory 1.
  • the first partial tensor ft 1 written in the second memory 2 becomes unnecessary.
  • the convolution calculation circuit 4 reads the other part of the input data at from the first memory 1, and performs the convolution calculation of the layer 2M-1 with the partial tensor ft (referred to as the second partial tensor ft 2) as an output. conduct.
  • the second partial tensor ft 2 is written to the second memory 2.
  • the second partial tensor ft 2 overwrites the first partial tensor ft 1.
  • the quantization operation circuit 5 Before performing the convolution operation on the rest of the input data a stored in the first memory 1, the quantization operation circuit 5 has a layer 2M quantum corresponding to the second partial tensor ft 2 stored in the second memory 2. Perform the conversion operation.
  • the output data of the layer 2M quantization operation is written in the first memory 1.
  • the second partial tensor ft 2 written in the second memory 2 becomes unnecessary.
  • the convolution operation of the layer 2M-1 and the quantization operation of the layer 2M are completed.
  • the size of the second memory 2 can be reduced to a memory size that can store one partial tensor ft.
  • the output data f is 16 bits.
  • the second memory 2 needs to store the output data f, and the required memory size is 16, X, Y, and D bits.
  • the second memory 2 only needs to be able to store one partial tensor ft, and the required memory size is reduced to 16 ⁇ T 2 ⁇ D bits.
  • ⁇ Convolution operation circuit generation process (S13-2): Division into partial tensors (3)> 11 to 13 are diagrams showing partial tensors ass obtained by slicing and dividing the input data a.
  • the partial tensor as is obtained by dividing the input data a into slices (blocks) having a predetermined size in the y-axis direction.
  • the convolution operation circuit 4 reads a part of the partial tensor as (first partial tensor as 1 ) from the first memory 1 and uses the partial tensor ft (referred to as the first partial tensor ft 1 ).
  • the convolution operation of the layer 2M-1 to be output is performed.
  • the first partial tensor ft 1 is written to the second memory 2.
  • the quantization operation circuit 5 Before performing the convolution operation on the rest of the first partial tensor as 1 stored in the first memory 1, the quantization operation circuit 5 corresponds to the first partial tensor ft 1 stored in the second memory 2.
  • the layer 2M quantization operation is performed.
  • the output data of the layer 2M quantization operation is written in the first memory 1.
  • the first partial tensor ft 1 written in the second memory 2 becomes unnecessary.
  • convolution operation circuit 4 the layer 2M-1 from the first memory 1 reads out a different part of the first portion tensor the as 1, and outputs the partial tensor ft (referred to as a second portion tensor ft 2) Performs the convolution operation of.
  • the second partial tensor ft 2 is written to the second memory 2.
  • the second partial tensor ft 2 overwrites the first partial tensor ft 1.
  • the quantization operation circuit 5 corresponds to the second partial tensor ft 2 stored in the second memory 2.
  • the layer 2M quantization operation is performed.
  • the output data of the layer 2M quantization operation is written in the first memory 1.
  • the second partial tensor ft 2 written in the second memory 2 becomes unnecessary.
  • the convolution operation circuit 4 and the quantization operation circuit 5 similarly perform a convolution operation from the first memory 1 to another partial tensor as (second partial tensor as 2). Perform the quantization operation.
  • the first partial tensor as 1 written in the first memory 1 is unnecessary and may be overwritten with the output data of the quantization operation of the layer 2M.
  • second portion tensor the as 2 written in the first memory 1 is not required.
  • the convolution operation circuit 4 and the quantization operation circuit 5 similarly perform a convolution operation from the first memory 1 to another partial tensor as (third partial tensor as 3). Perform the quantization operation.
  • the first partial tensor as 1 and the second partial tensor as 2 written in the first memory 1 are unnecessary and may be overwritten with the output data of the quantization operation of the layer 2M.
  • third part tensor the as 3 written in the first memory 1 is not required.
  • FIG. 14 is a diagram showing another partial tensor required to output the partial tensor ft by the convolution operation of the layer 2M + 1.
  • the partial tensor of the input of the quantization operation of layer 2M is required. Further, a partial tensor for inputting the convolution operation of layer 2M-1 is required. In this way, there is a dependency on the partial tensor required to output the partial tensor ft.
  • the partial tensor ft may be calculated by sequentially calculating the partial tensors required to output the partial tensor ft based on this dependency.
  • the memory size of the first memory 1 and the second memory 2 may be a size that can store a partial tensor, and the entire memory capacity of the first memory 1 and the second memory 2 can be reduced.
  • the sizes of the various partial tensors described above are set to a size such that a predetermined number of partial tensors can be stored in the first memory 1 and the second memory 2.
  • the memory capacity of the first memory 1 and the second memory 2 may be calculated from the size of the partial tensor.
  • ⁇ Convolution operation circuit generation process (S13-2): Hardware model generation>
  • the execution model generation unit 321 generates a hardware model of the convolution calculation circuit 4 from information such as the weight w input as the network information NW and the bit width of the input data a.
  • the hardware model may be behavior level, RTL (Register Transfer Level), netlist representing connections between gates and circuit modules, or a combination thereof. ..
  • RTL Registered Transfer Level
  • netlist representing connections between gates and circuit modules
  • FIG. 15 is an internal block diagram of the generated convolution calculation circuit 4.
  • the convolution operation circuit 4 includes 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 the need for an external controller.
  • the weight memory 41 is a memory in which the weight W used for the convolution operation is stored, and is a rewritable memory such as a volatile memory composed of, for example, a SRAM (Static RAM).
  • the DMAC 3 writes the weight W required for the convolution operation to the weight memory 41 by DMA transfer.
  • FIG. 16 is an internal block diagram of the multiplier 42.
  • the multiplier 42 multiplies the input vector A and the weight matrix W.
  • the input vector A is vector data having Bc elements in which the divided input data a (x + i, y + j, co) is expanded.
  • the weight matrix W is matrix data having Bc ⁇ Bd elements in which the division weight w (i, j, co, do) is expanded.
  • the multiplier 42 has Bc ⁇ Bd product-sum calculation units 47, and can perform multiplication of the input vector A and the weight matrix W in parallel.
  • the multiplier 42 reads the input vector A and the weight matrix W necessary for multiplication from the first memory 1 and the weight memory 41, and performs multiplication.
  • the multiplier 42 outputs Bd product-sum operation results O (di).
  • FIG. 17 is an internal block diagram of the product-sum calculation unit 47.
  • the product-sum calculation unit 47 performs multiplication of the element A (ci) of the input vector A and the element W (ci, di) of the weight matrix W. Further, the product-sum calculation unit 47 adds the multiplication result and the multiplication result S (ci, di) of another product-sum calculation unit 47.
  • the product-sum calculation unit 47 outputs the 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 the value "0" represents +1 and the value "1" represents -1.
  • the product-sum calculation unit 47 has an inverter (inverter) 47a, a selector 47b, and an adder 47c.
  • the multiply-accumulate unit 47 does not use a multiplier, but uses only the inverter 47a and the selector 47b to perform multiplication.
  • the selector 47b selects the input of the element A (ci) when the element W (ci, di) is “0”. When the element W (ci, di) is "1", the selector 47b selects the complement in which the element A (ci) is inverted by the inversion device.
  • the element W (ci, di) is also input to the Carry-in of the adder 47c.
  • the adder 47c outputs a value obtained by adding the element A (ci) to the S (ci, di) when the element W (ci, di) is “0”.
  • the adder 47c outputs a value obtained by subtracting the element A (ci) from S (ci, di) when W (ci, di) is “1”.
  • FIG. 18 is an internal block diagram of the accumulator circuit 43.
  • the accumulator circuit 43 accumulates the product-sum operation result O (di) of the multiplier 42 into the second memory 2.
  • the accumulator circuit 43 has Bd accumulator units 48, and can accumulate Bd product-sum operation results O (di) in parallel to the second memory 2.
  • FIG. 19 is an internal block diagram of the accumulator unit 48.
  • the accumulator unit 48 has an adder 48a and a mask portion 48b.
  • the adder 48a adds the element O (di) of the product-sum operation result O and the partial sum stored in the second memory 2 which is an intermediate process of the convolution operation shown in the equation 1.
  • the addition result is 16 bits per element.
  • the addition result is not limited to 16 bits per element, and may be, for example, 15 bits or 17 bits per element.
  • the adder 48a writes the addition result to the same address in the second memory 2.
  • the mask unit 48b masks the output from the second memory 2 and sets the addition target for the element O (di) to zero.
  • the initialization signal clear is asserted when the partial sum of the progress is not stored in the second memory 2.
  • the output data f (x, y, do) is stored in the second memory.
  • the state controller 44 controls the states of the multiplier 42 and the accumulator circuit 43. Further, the state controller 44 is connected to the controller 6 via the internal bus IB.
  • the state controller 44 has an instruction queue 45 and a control circuit 46.
  • the instruction queue 45 is a queue in which the instruction command C4 for the convolution operation circuit 4 is stored, and is composed of, for example, a FIFO memory.
  • the instruction command C4 is written in the instruction queue 45 via the internal bus IB.
  • the control circuit 46 is a state machine that decodes the instruction command C4 and controls the multiplier 42 and the accumulator circuit 43 based on the instruction command C4.
  • the control circuit 46 may be implemented by a logic circuit or by a CPU controlled by software.
  • FIG. 20 is a state transition diagram of the control circuit 46.
  • the control circuit 46 transitions from the idle state S1 to the decode state S2.
  • the control circuit 46 decodes the instruction command C3 output from the instruction queue 45 in the decode state S2. Further, the control circuit 46 reads the semaphore S stored in the register 61 of the controller 6 and determines whether or not the operation of the multiplier 42 or the accumulator circuit 43 instructed by the instruction command C4 can be executed. If it is infeasible (Not ready), the control circuit 46 waits until it becomes executable (Wait). When it is executable (ready), the control circuit 46 transitions from the decode state S2 to the execution state S3.
  • the control circuit 46 controls the multiplier 42 and the accumulator circuit 43 in the execution state S3, and causes the multiplier 42 and the accumulator circuit 43 to perform the operation instructed by the instruction command C4.
  • the control circuit 46 removes the executed instruction command C4 from the instruction queue 45 and updates the semaphore S stored in the register 61 of the controller 6.
  • the control circuit 46 transitions from the execution state S3 to the decode state S2.
  • the control circuit 46 transitions from the execution state S3 to the idle state S1.
  • the execution model generation unit 321 associates the size of the block (Bc or Bd) for dividing the data of the convolution operation with the number of the product-sum operation unit 47 (Bc ⁇ Bd) as shown in FIG. If the size (Bc or Bd) of the block that divides the data of the convolution operation of the convolution layer 210 is reduced, the hardware scale of the multiplier 42 is reduced, but the calculation speed of the multiplier 42 is reduced.
  • an input vector A having Bc elements and a weight matrix W having Bc ⁇ Bd elements are input to the multiplier 42. Therefore, even if the number of the product-sum calculation unit 47 is larger than the number of Bc ⁇ Bd, the product-sum calculation unit 47 cannot be effectively utilized.
  • the size of the input data a and the weight w in the c-axis direction and the d-axis direction and the block size (Bc and Bd) are powers of 2 such as 64, 128, and 256 in order to efficiently perform division and data integration. Desirably the size.
  • the hardware scale of the multiplier 42 and the accumulator circuit 43 can be reduced. Further, if the weight w and the bit width of the input data a are reduced, the memory capacities of the first memory 1 and the second memory 2 for storing these can be reduced. Further, the data transfer time to the first memory 1 and the second memory 2 by the DMAC 3 can be shortened.
  • the execution model generation unit 321 generates the quantization calculation circuit 5 of the NN execution model 100 based on the hardware information HW and the network information NW (quantization calculation circuit generation step).
  • the execution model generation unit 321 generates a hardware model of the quantization calculation circuit 5 from the quantization information input as the network information NW.
  • the hardware model may be behavior level, RTL (Register Transfer Level), netlist representing connections between gates and circuit modules, or a combination thereof. ..
  • RTL Registered Transfer Level
  • FIG. 21 is an internal block diagram of the generated quantization calculation circuit 5.
  • the quantization calculation circuit 5 includes a quantization parameter memory 51, a vector calculation circuit 52, a quantization circuit 53, and a state controller 54, and the quantization calculation circuit 5 has a reference to the vector calculation circuit 52 and the quantization circuit 53. It has a dedicated state controller 54, and when an instruction command is input, the quantization operation can be performed without the need for an external controller.
  • the quantization parameter memory 51 is a memory in which the quantization parameter q used for the quantization operation is stored, and is a rewritable memory such as a volatile memory composed of, for example, a SRAM (Static RAM).
  • the DMAC 3 writes the quantization parameter q required for the quantization operation to the quantization parameter memory 51 by DMA transfer.
  • FIG. 22 is an internal block diagram of the vector calculation circuit 52 and the quantization circuit 53.
  • the vector calculation circuit 52 performs a calculation on the output data f (x, y, do) stored in the second memory 2.
  • the vector calculation circuit 52 has Bd calculation units 57, and performs SIMD calculation in parallel with the output data f (x, y, do).
  • FIG. 23 is a block diagram of the arithmetic unit 57.
  • the arithmetic unit 57 has, for example, an ALU 57a, a first selector 57b, a second selector 57c, a register 57d, and a shifter 57e.
  • the arithmetic unit 57 may further include another arithmetic unit or the like included in a known general-purpose SIMD arithmetic circuit.
  • the vector arithmetic circuit 52 can be used with the pooling layer 221 in the quantization arithmetic layer 220, the Batch Normalization layer 222, and the output data f (x, y, do). At least one of the operations of the activation function layer 223 is performed.
  • 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 ALU57a.
  • the arithmetic unit 57 can store the addition result by ALU57a in the register 57d.
  • the arithmetic unit 57 can initialize the addition result by inputting "0" to the ALU 57a instead of the data stored in the register 57d by selecting the first selector 57b. For example, when the pooling area is 2 ⁇ 2, the shifter 57e can output the average value of the addition results by shifting the output of the ALU 57a to the right by 2 bits.
  • the vector calculation circuit 52 can perform the calculation of the average pooling shown in Equation 2 by repeating the above calculation and the like by the Bd calculation units 57.
  • the arithmetic unit 57 can compare the data stored in the register 57d with the element f (di) of the output data f (x, y, do) read from the second memory 2 by the ALU57a.
  • the arithmetic unit 57 can control the second selector 57c according to the comparison result by the ALU 57a to select the larger of the data stored in the register 57d and the element f (di).
  • the calculation 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) into the ALU 57a by selecting the first selector 57b.
  • the vector calculation circuit 52 can perform the MAX pooling calculation of the formula 3 by repeating the above calculation and the like by the Bd calculation units 57. In the MAX pooling operation, the shifter 57e does not shift the output of the second selector 57c.
  • the arithmetic unit 57 can subtract the data stored in the register 57d and the element f (di) of the output data f (x, y, do) read from the second memory 2 by the ALU57a.
  • the shifter 57e can shift the output of the ALU57a to the left (ie, multiply) or to the right (ie, divide).
  • the vector calculation circuit 52 can perform the Batch Normalization calculation of the formula 4 by repeating the above calculation and the like by the Bd calculation units 57.
  • 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 ALU57a.
  • the arithmetic unit 57 can select and output either the element f (di) or the constant value “0” stored in the register 57d in advance according to the comparison result by the ALU 57a.
  • the vector calculation circuit 52 can perform the ReLU calculation of the equation 5 by repeating the above calculation and the like by the Bd calculation units 57.
  • the vector calculation circuit 52 can perform average pooling, MAX pooling, Batch Normalization, activation function calculation, and a combination of these calculations. Since the vector calculation circuit 52 can perform a general-purpose SIMD calculation, other calculations necessary for the calculation in the quantization calculation layer 220 may be performed. Further, the vector calculation circuit 52 may perform a calculation other than the calculation in the quantization calculation layer 220.
  • the quantization calculation circuit 5 does not have to have the vector calculation circuit 52.
  • the output data f (x, y, do) is input to the quantization circuit 53.
  • the quantization circuit 53 quantizes the output data of the vector calculation circuit 52. As shown in FIG. 22, the quantization circuit 53 has Bd quantization units 58, and performs operations in parallel with respect to the output data of the vector operation circuit 52.
  • FIG. 24 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 calculation circuit 52.
  • the quantization unit 58 includes a comparator 58a and an encoder 58b.
  • the quantization unit 58 performs an operation (Equation 6) of the quantization layer 224 in the quantization operation layer 220 on the output data (16 bits / element) of the vector calculation circuit 52.
  • the quantization unit 58 reads out the required quantization parameter 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 into 2 bits / element by the encoder 58b. Since ⁇ (c) and ⁇ (c) in Equation 4 are different parameters for each variable c, the quantization parameters q (th0, th1, th2) reflecting ⁇ (c) and ⁇ (c) are in ( This is a different parameter for each di).
  • the quantization unit 58 By comparing the input in (di) with the three thresholds th0, th1, th2, the quantization unit 58 sets the input in (di) in four regions (for example, in ⁇ th0, th0 ⁇ in ⁇ th1, th1 ⁇ in. Classify into ⁇ th2, th2 ⁇ in), and the classification result is encoded into 2 bits and output.
  • the quantization unit 58 can also perform Batch Normalization and activation function operations together with the quantization.
  • the quantization unit 58 sets the threshold value th0 as ⁇ (c) of the equation 4, the difference between the thresholds (th1-th0) and (th2-th1) as ⁇ (c) of the equation 4, and performs the quantization.
  • the Butch Normalization operation shown in Equation 4 can be performed together with the quantization.
  • ⁇ (c) can be reduced by increasing (th1-th0) and (th2-th1). By reducing (th1-th0) and (th2-th1), ⁇ (c) can be increased.
  • the quantization unit 58 can perform the ReLU operation of the activation function together with the quantization of the input in (di). For example, the quantization unit 58 saturates the output value in the region where in (di) ⁇ th0 and th2 ⁇ in (di). The quantization unit 58 can perform the operation of the activation function together with the quantization by setting the quantization parameter q so that the output is non-linear.
  • the state controller 54 controls the states of the vector calculation circuit 52 and the quantization circuit 53. Further, 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.
  • the instruction queue 55 is a queue in which the 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 in the instruction queue 55 via the internal bus IB.
  • 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 the same configuration as the control circuit 46 of the state controller 44 of the convolution calculation circuit 4.
  • the quantization calculation circuit 5 writes the quantization calculation output data having Bd elements to the first memory 1.
  • the preferable relationship between Bd and Bc is shown in Equation 10.
  • Equation 10 n is an integer.
  • the execution model generation unit 321 From the quantization information input as the network information NW, the execution model generation unit 321 has the presence / absence and method of the pooling operation in the quantization calculation circuit 5, the presence / absence and method of the Batch Normalization calculation, and the presence / absence of the activation function calculation. And the method, the method of quantization, and the presence or absence of other operations.
  • the execution model generation unit 321 when performing a pooling operation in the quantization calculation circuit 5, the execution model generation unit 321 generates a calculation unit 57 optimized for the type of pooling (average pooling, MAX pooling, etc.) to be calculated.
  • the execution model generation unit 321 when the activation function is calculated in the quantization calculation circuit 5, the execution model generation unit 321 generates a calculation unit 57 and a quantization unit 58 optimized for the activation function (ReLU calculation, etc.) for the calculation. ..
  • the execution model generation unit 321 when the Batch Normalization calculation is performed in the quantization calculation circuit 5, the execution model generation unit 321 generates the calculation unit 57 in accordance with the Batch Normalization calculation. Further, the execution model generation unit 321 adjusts the quantization parameter q (th0, th1, th2) according to the operation of Batch Normalization.
  • the execution model generation unit 321 when the quantization by the quantization calculation circuit 5 is a quantization of 3 bits or more, the execution model generation unit 321 generates a vector calculation circuit 52 capable of performing pooling, Batch Nomalization, and scaling for quantization.
  • the normalization calculation of Batch Normalization may be streamlined. Specifically, in order to use bit shift in the normalization process of Batch Normalization, each element of the input tensor is raised to the power of 2. As a result, the normalization operation of Batch Normalization can be realized only by bit shift.
  • an additional arithmetic circuit for converting each element of the input tensor into a power of 2 may be added to the quantization arithmetic circuit 5 or the convolution arithmetic circuit 4.
  • the execution model generation unit 321 generates DMAC3 of the NN execution model 100 based on the hardware information HW and the network information NW (DMAC generation step).
  • the execution model generation unit 321 generates a hardware model of the DMAC3 from the information input as the network information NW.
  • the hardware model may be behavior level, RTL (Register Transfer Level), netlist representing connections between gates and circuit modules, or a combination thereof. ..
  • RTL Registered Transfer Level
  • FIG. 25 is an internal block diagram of the generated DMAC3.
  • the DMAC 3 has a data transfer circuit 31 and a state controller 32.
  • the DMAC 3 has a state controller 32 dedicated to the data transfer circuit 31, and when an instruction command is input, DMA data transfer can be performed without the need for an external controller.
  • the data transfer circuit 31 is connected to the external bus EB and transfers DMA data between an external memory such as a DRAM and the first memory 1. Further, the data transfer circuit 31 transfers DMA data between an external memory such as a DRAM and the second memory 2. Further, the data transfer circuit 31 transfers data between an external memory such as a DRAM and the convolution calculation circuit 4. Further, the data transfer circuit 31 transfers data between an external memory such as a DRAM and the quantization calculation circuit 5.
  • the number of DMA channels in the data transfer circuit 31 is not limited. For example, each of the first memory 1 and the second memory 2 may have a dedicated DMA channel.
  • the state controller 32 controls the state of the data transfer circuit 31. Further, the state controller 32 is connected to the controller 6 via the internal bus IB.
  • the state controller 32 has an instruction queue 33 and a control circuit 34.
  • the instruction queue 33 is a queue in which the instruction command C3 for 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.
  • 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 has the same configuration as the control circuit 46 of the state controller 44 of the convolution calculation circuit 4.
  • the execution model generation unit 321 determines the number of DMA channels, the data bus width, etc. in the DMAC3 from the information input as the network information NW.
  • the execution model generation unit 321 generates a DMAC3 having specifications (data bus width, etc.) that match the specifications of the external bus EB on the host side.
  • the data bus width and the number of DMA channels By increasing the data bus width and the number of DMA channels, the data transmission speed between the external memory and the first memory 1 or the second memory 2 can be improved.
  • step S14 the learning unit 322 and the inference unit 323 of the neural network generation device 300 learn the learning parameters of the generated NN execution model 100 using the learning data set DS (learning step).
  • the learning step (S14) includes, for example, a learned parameter generation step (S14-1) and an inference test step (S14-2).
  • the learning unit 322 generates the learned parameter PM by using the NN execution model 100 and the learning data D1.
  • the trained parameter PM is a trained weight w, a quantization parameter q, and the like.
  • the training data D1 is a combination of the input image and the teacher data T.
  • the input image is the input data a input to the CNN 200.
  • the teacher data T is the type of the subject captured in the image, the presence / absence of the detection target object in the image, the coordinate value of the detection target object in the image, and the like.
  • the learning unit 322 generates a learned parameter PM by supervised learning using a known technique such as an error back propagation method.
  • the learning unit 322 obtains the difference E between the output of the NN execution model 100 for the input image and the teacher data T corresponding to the input image by a loss function (error function), and the weight w and the quantum so that the difference E becomes small.
  • the conversion parameter q (th0, th1, th2) is updated.
  • the gradient of the loss function with respect to the weight w is used.
  • the gradient is calculated, for example, by differentiating the loss function.
  • the gradient is calculated by backpropagation.
  • the learning unit 322 makes the operations related to the convolution operation, the operations related to the quantization operation, and the like more accurate than the operations performed by the NN execution model 100.
  • the learning unit 322 improves the accuracy of the operation related to the convolution operation when calculating the gradient and updating the weight w. Specifically, a 32-bit floating-point type weight w that is more accurate than the low-bit weight w (for example, 1 bit) used by the NN execution model 100 is used for learning. Further, the convolution calculation performed in the convolution calculation circuit 4 of the NN execution model 100 is improved in accuracy.
  • the learning unit 322 improves the accuracy of the calculation related to the activation function when calculating the gradient and updating the weight w. Specifically, a sigmond function with higher accuracy than an activation function such as the ReLU function implemented in the quantization calculation circuit 5 of the NN execution model 100 is used for learning.
  • the learning unit 322 calculates the output data for the input image by forward propagation (f Cincinnatirward)
  • the operation related to the convolution operation and the activation function is not made highly accurate, and the operation is based on the NN execution model 100.
  • the highly accurate weight w used when updating the weight w is reduced in bits by a look-up table or the like.
  • the learning unit 322 calculates the gradient and updates the weight w
  • the learning unit 322 improves the accuracy of the operation related to the convolution operation and the activation function, thereby preventing the accuracy of the intermediate data in the operation from deteriorating and making a high inference. It is possible to generate a trained parameter PM that can achieve accuracy.
  • the learning unit 322 when calculating the output data for the input image, the learning unit 322 does not improve the accuracy of the forward propagation calculation, but performs the calculation based on the NN execution model 100. Therefore, the output data calculated by the learning unit 322 and the output data of the NN execution model 100 using the generated learned parameter PM match.
  • the inference unit 323 carries out an inference test using the learned parameters PM, the NN execution model 100, and the test data D2 generated by the learning unit 322.
  • the NN execution model 100 is an execution model of the CNN 200 that performs image recognition
  • the test data D2 is a combination of the input image and the teacher data T as in the training data D1.
  • the inference unit 323 displays the progress and result of the inference test on the display unit 350.
  • the result of the inference test is, for example, the correct answer rate for the test data D2.
  • step S15 the inference unit 323 of the neural network generation device 300 causes the display unit 350 to display a message prompting the user to input confirmation regarding the result from the operation input unit 360 and a GUI image necessary for information input.
  • the user inputs from the operation input unit 360 whether or not the result of the inference test is allowed.
  • the neural network generator 300 then performs step S16.
  • the neural network generation device 300 performs step S12 again.
  • the neural network generation device 300 may return to step S11 and have the user re-input the hardware information HW.
  • step S16 the hardware generation unit 324 of the neural network generation device 300 generates the neural network hardware model 400 based on the hardware information HW and the NN execution model 100.
  • step S17 the neural network generation device 300 executes step S17 to end the process.
  • the neural network generation device 300 can be incorporated into an embedded device such as an IoT device, and can be operated with high performance.
  • a neural network execution model 100 and a neural network hardware model 400 can be generated.
  • the neural network generation device 300B differs from the neural network generation device 300 of the first embodiment only in the learning step (S14-1).
  • the learning step (S14-1) in the present embodiment will be described below.
  • the learning unit 322 generates the learned parameter PM by using the NN execution model 100 and the learning data D1.
  • the trained parameter PM is a trained weight w, a quantization parameter q, a scaling coefficient sf, and the like.
  • the learning unit 322 learns the quantization parameter q (th0, th1, th2) and also learns the scaling coefficient sf (also referred to as a scaling factor or step size).
  • the scaling coefficient sf is a coefficient indicating the scale of the quantized quantized operation output data, and specifically, is a coefficient multiplied by the quantized operation output data.
  • 26 to 28 are diagrams for explaining the scaling coefficient sf in the quantization operation.
  • the quantization operation outputs the quantization operation output data quantized into 2 bits (0, 1, 2, 3) based on the quantization parameter q (th0, th1, th2). ..
  • the scaling coefficient sf is a coefficient to be multiplied with respect to the quantized operation output data, as shown in FIGS. 27 and 28.
  • the quantization parameter q (th0, th1, th2) is a parameter suitable for the range of input data in the quantization operation, and is, for example, a multi-bit parameter having 8 bits or more.
  • the learning unit 322 learns the scaling coefficient sf so that, for example, the range of the input data in the quantization operation and the range of the data obtained by multiplying the quantization operation output data by the scaling coefficient sf come close to each other. For example, when the range of input data is narrow, the scaling coefficient sf becomes small. Further, when the range of the input data is wide, the scaling coefficient sf becomes large. By multiplying the scaling coefficient sf learned in this way by the quantization calculation output data, the learning unit 322 can reduce the decrease in accuracy due to the quantization calculation.
  • the scaling coefficient sf is a parameter learned for each layer, for example.
  • the learning unit 322 can learn the optimal scaling coefficient sf for the range of the input data in the quantization operation for each layer.
  • the scaling coefficient sf is not limited to the mode of learning for each layer, and may be learned for each element O (di), for example.
  • the learning unit 322 improves the accuracy of the operation related to the convolution operation when generating the learned parameter.
  • the learning unit 322 uses the data obtained by multiplying the quantization calculation output data by the scaling coefficient sf as the input data of the convolution calculation.
  • the learning unit 322 generates a trained parameter PM that can prevent the accuracy of the intermediate data in the operation from deteriorating and realize higher inference accuracy. can.
  • the quantization operation output data is 2 bits
  • the scaling coefficient sf is not directly multiplied by the quantization operation output data. Therefore, in the trained NN execution model 100 (including the NN execution model 100 and the trained parameter PM) used at the time of inference rather than at the time of training, the trained scaling coefficient sf is incorporated into the parameters of other operations.
  • the parameters of other operations are the learned parameters PM and the parameters of the software that controls the NN execution model 100, and are, for example, the quantization parameter q (th0, th1, th2), the threshold value of the activation function, and the parameter of Batch Normalization. , Weight w, etc.
  • the learned scaling coefficient sf is incorporated into the quantization parameter q (th0, th1, th2). Specifically, the quantization parameter q (th0, th1, th2) is replaced with a value obtained by dividing the quantization parameter q (th0, th1, th2) by the scaling coefficient sf.
  • the learned scaling coefficient sf is incorporated into the parameters of Batch Normalization. Specifically, ⁇ (c) shown in Equation 4 is replaced with a value obtained by dividing ⁇ (c) by the scaling coefficient sf.
  • CNN200 may have different types of operations to be performed for each layer. Therefore, the learned scaling coefficient sf is incorporated as a parameter of an operation appropriately selected from the operations performed by each layer.
  • the learning unit 332 learns the scaling coefficient sf for the quantized quantized operation output data.
  • the learning unit 332 may use the scaling coefficient for the quantized weight w when the highly accurate weight w learned in the learning process is quantized by a look-up table or the like.
  • the learning unit 332 can learn the scaling coefficient for the weight w by the same method as the method for learning the scaling coefficient sf for the quantized operation output data.
  • the scaling coefficient for the weight w is incorporated into the parameters of other operations in the same manner as the scaling coefficient sf for the quantized operation output data.
  • the neural network generation device 300B can be incorporated into an embedded device such as an IoT device, and can be operated with high performance.
  • a neural network execution model 100 and a neural network hardware model 400 can be generated.
  • 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 execution model 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 execution model 100 can be mounted on an edge device provided with the neural network hardware model 400, such as an optical sensor, a thermometer, a Global Positioning System (GPS) measuring instrument, an angular velocity measuring instrument, and an anemometer. It is not limited to the measurement result in the physical quantity measuring instrument such as.
  • 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 execution model 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 is not something that can be done. 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
  • a computer-readable recording medium includes hardware such as an OS and peripheral devices.
  • the "computer-readable recording medium” refers to a portable medium such as a flexible disk, a magneto-optical disk, a ROM, or a CD-ROM, and a storage device such as a hard disk built in a computer system.
  • a "computer-readable recording medium” is a communication line for transmitting a program via a network such as the Internet or a communication line such as a telephone line, and dynamically holds the program for a short period of time.
  • It may also include a program that holds a program for a certain period of time, such as a volatile memory inside a computer system that is a server or a client in that case.
  • the above-mentioned program may be for realizing a part of the above-mentioned functions, and may be further realized for realizing the above-mentioned functions in combination with a program already recorded in the computer system.
  • the present invention can be applied to the generation of neural networks.
  • Neural network generator 200 Convolutional neural network (CNN) 100 Neural network execution model (NN execution model) 400 Neural network hardware model 1 1st memory 2 2nd memory 3 DMA controller (DMAC) 4 Convolution operation circuit 42 Multiplier 43 Accumulator circuit 5 Quantization operation circuit 52 Vector operation circuit 53 Quantization circuit 6 Controller 61 Register PM Learned parameter DS Learning data set HW Hardware information NW Network information

Landscapes

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

Abstract

ニューラルネットワーク生成装置は、ニューラルネットワークを演算するニューラルネットワーク実行モデルを生成するニューラルネットワーク生成装置であって、前記ニューラルネットワーク実行モデルが動作するハードウェアのハードウェア情報と、前記ニューラルネットワークのネットワーク情報と、に基づいて前記ニューラルネットワーク実行モデルを生成する実行モデル生成部と、生成された前記ニューラルネットワーク実行モデルの学習済みパラメータを生成する学習部と、を備える。

Description

ニューラルネットワーク生成装置、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラム
 本発明は、ニューラルネットワーク生成装置、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラムに関する。本願は、2020年06月30日に、日本国に出願された特願2020-113315号に基づき優先権を主張し、その内容をここに援用する。
 近年、畳み込みニューラルネットワーク(Convolutional Neural Network:CNN)が画像認識等のモデルとして用いられている。畳み込みニューラルネットワークは、畳み込み層やプーリング層を有する多層構造であり、畳み込み演算等の多数の演算を必要とする。畳み込みニューラルネットワークによる演算を高速化する演算手法が様々考案されている(特許文献1など)。
特開2018-077829号公報
 一方で、IoT機器などの組み込み機器においても畳み込みニューラルネットワークを利用した画像認識等が使用されている。組み込み機器において畳み込みニューラルネットワークを効率的に動作させるため、組み込み機器のハードウェア構成に合わせたニューラルネットワーク(モデルや回路)を生成する生成方法が望まれている。また、ニューラルネットワークを生成する過程において、組み込み機器の限られたハードウェア資源においてニューラルネットワークを高性能に動作させるニューラルネットワークの学習方法が望まれている。
 上記事情を踏まえ、本発明は、IoT機器などの組み込み機器に組み込み可能であり、高性能に動作させることができるニューラルネットワークを生成するニューラルネットワーク生成装置、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラムを提供することを目的とする。
 上記課題を解決するために、この発明は以下の手段を提案している。
 本発明の第一の態様に係るニューラルネットワーク生成装置は、ニューラルネットワーク生成装置は、ニューラルネットワークを演算するニューラルネットワーク実行モデルを生成するニューラルネットワーク生成装置であって、前記ニューラルネットワーク実行モデルが動作するハードウェアのハードウェア情報と、前記ニューラルネットワークのネットワーク情報と、に基づいて前記ニューラルネットワーク実行モデルを生成する実行モデル生成部と、生成された前記ニューラルネットワーク実行モデルの学習済みパラメータを生成する学習部と、を備える。
 本発明の第二の態様に係るニューラルネットワーク生成方法は、ニューラルネットワークを演算するニューラルネットワーク実行モデルを生成するニューラルネットワーク生成方法であって、前記ニューラルネットワーク実行モデルが動作するハードウェアのハードウェア情報を取得するハードウェア情報取得工程と、前記ニューラルネットワークのネットワーク情報を設定するネットワーク情報取得工程と、前記ハードウェア情報と前記ネットワーク情報とに基づいて、前記ニューラルネットワーク実行モデルを生成する実行モデル生成工程と、生成された前記ニューラルネットワーク実行モデルの学習パラメータを学習する学習工程と、を備える。
 本発明の第三の態様に係るニューラルネットワーク生成プログラムは、ニューラルネットワークを演算するニューラルネットワーク実行モデルをコンピュータに生成させるニューラルネットワーク生成プログラムであって、前記ニューラルネットワーク実行モデルが動作するハードウェアのハードウェア情報をコンピュータに取得させるハードウェア情報取得工程と、前記ニューラルネットワークのネットワーク情報をコンピュータに設定させるネットワーク情報取得工程と、前記ハードウェア情報と前記ネットワーク情報とに基づいて、前記ニューラルネットワーク実行モデルをコンピュータに生成させる実行モデル生成工程と、生成された前記ニューラルネットワーク実行モデルの学習パラメータをコンピュータに学習させる学習工程と、を備える。
 本発明のニューラルネットワーク生成装置、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラムは、IoT機器などの組み込み機器に組み込み可能であり、高性能に動作させることができるニューラルネットワークを生成できる。
第一実施形態に係るニューラルネットワーク生成装置を示す図である。 同ニューラルネットワーク生成装置の演算部の入出力を示す図である。 畳み込みニューラルネットワークの一例を示す図である。 同畳み込みニューラルネットワークの畳み込み層が行う畳み込み演算を説明する図である。 ニューラルネットワーク実行モデルの一例を示す図である。 同ニューラルネットワーク生成装置の制御フローチャートである。 同ニューラルネットワーク実行モデルの動作例を示すタイミングチャートである。 同畳み込み演算のデータ分割やデータ展開を説明する図である。 同ニューラルネットワーク実行モデルの他の動作例を示すタイミングチャートである。 畳み込み演算の出力データをタイル分割した部分テンソルを示す図である。 入力データをスライス分割した部分テンソルを示す図である。 入力データをスライス分割した部分テンソルを示す図である。 入力データをスライス分割した部分テンソルを示す図である。 レイヤ2M+1の畳み込み演算により部分テンソルを出力するために必要な他の部分テンソルを示す図である。 生成される畳み込み演算回路の内部ブロック図である。 同畳み込み演算回路の乗算器の内部ブロック図である。 同乗算器の積和演算ユニットの内部ブロック図である。 同畳み込み演算回路のアキュムレータ回路の内部ブロック図である。 同アキュムレータ回路のアキュムレータユニットの内部ブロック図である。 同畳み込み演算回路の制御回路のステート遷移図である。 生成される量子化演算回路の内部ブロック図である。 同量子化演算回路のベクトル演算回路と量子化回路の内部ブロック図である。 同ベクトル演算回路の演算ユニットのブロック図である。 同量子化回路の量子化ユニットの内部ブロック図である。 生成されるDMACの内部ブロック図である。 量子化演算におけるスケーリング係数を説明する図である。 量子化演算におけるスケーリング係数を説明する図である。 量子化演算におけるスケーリング係数を説明する図である。
(第一実施形態)
 本発明の第一実施形態について、図1から図25を参照して説明する。
 図1は、本実施形態に係るニューラルネットワーク生成装置300を示す図である。
[ニューラルネットワーク生成装置300]
 ニューラルネットワーク生成装置300は、IoT機器などの組み込み機器に組み込み可能な学習済みのニューラルネットワーク実行モデル100を生成する装置である。ニューラルネットワーク実行モデル100は、畳み込みニューラルネットワーク200(以下、「CNN200」という)を組み込み機器において演算させるために生成されたソフトウェアやハードウェアモデルである。
 ニューラルネットワーク生成装置300は、CPU(Central Processing Unit)等のプロセッサとメモリ等のハードウェアを備えたプログラム実行可能な装置(コンピュータ)である。ニューラルネットワーク生成装置300の機能は、ニューラルネットワーク生成装置300においてニューラルネットワーク生成プログラムを実行することにより実現される。ニューラルネットワーク生成装置300は、記憶部310と、演算部320と、データ入力部330と、データ出力部340と、表示部350と、操作入力部360と、を備える。
 記憶部310は、ハードウェア情報HWと、ネットワーク情報NWと、学習データセットDSと、ニューラルネットワーク実行モデル100(以下、「NN実行モデル100」という)と、学習済みパラメータPMと、を記憶する。ハードウェア情報HW、学習データセットDSおよびネットワーク情報NWは、ニューラルネットワーク生成装置300に入力される入力データである。NN実行モデル100および学習済みパラメータPMは、ニューラルネットワーク生成装置300が出力する出力データである。なお、「学習済みのNN実行モデル100」は、NN実行モデル100および学習済みパラメータPMを含む。
 ハードウェア情報HWは、NN実行モデル100を動作させる組み込み機器(以降、「動作対象ハードウェア」という)の情報である。ハードウェア情報HWは、例えば、動作対象ハードウェアのデバイス種別、デバイス制約、メモリ構成、バス構成、動作周波数、消費電力、製造プロセス種別などである。デバイス種別は、例えば、ASIC(Application Specific Integrated Circuit)、FPGA(Field-Programmable Gate Array)などの種別である。デバイス制約は、動作対象デバイスに含まれる演算器数の上限や回路規模の上限などである。メモリ構成は、メモリ種別やメモリ個数やメモリ容量や入出力データ幅である。バス構成は、バス種類、バス幅、バス通信規格、同一バス上の接続デバイスなどである。また、NN実行モデル100に複数のバリエーションが存在する場合、ハードウェア情報HWには使用するNN実行モデル100のバリエーションに関する情報が含まれる。
 ネットワーク情報NWは、CNN200の基本情報である。ネットワーク情報NWは、例えば、CNN200のネットワーク構成、入力データ情報、出力データ情報、量子化情報などである。入力データ情報は、画像や音声などの入力データ種別と、入力データサイズなどである。
 学習データセットDSは、学習に用いる学習データD1と、推論テストに用いるテストデータD2と、を有する。
 図2は、演算部320の入出力を示す図である。
 演算部320は、実行モデル生成部321と、学習部322と、推論部323と、ハードウェア生成部324と、を有する。演算部320に入力されるNN実行モデル100は、ニューラルネットワーク生成装置300以外の装置で生成されたものであってもよい。
 実行モデル生成部321は、ハードウェア情報HWおよびネットワーク情報NWに基づいてNN実行モデル100を生成する。
 学習部322は、NN実行モデル100および学習データD1を用いて、学習済みパラメータPMを生成する。推論部323は、NN実行モデル100およびテストデータD2を用いて推論テストを実施する。
 ハードウェア生成部324は、ハードウェア情報HWおよびNN実行モデル100に基づいてニューラルネットワークハードウェアモデル400を生成する。ニューラルネットワークハードウェアモデル400は、動作対象ハードウェアに実装可能なハードウェアモデルである。ニューラルネットワークハードウェアモデル400は、ハードウェア情報HWに基づいて、動作対象ハードウェアに最適化されている。ニューラルネットワークハードウェアモデル400は、RTL(Register Transfer Level)であってもよく、ゲートや回路モジュール間の接続を表すネットリストであってもよく、それらの組み合わせであってもよい。ニューラルネットワークハードウェアモデル400は、NN実行モデル100をハードウェアに実装するために必要なパラメータリストやコンフィグレーションファイルであってもよい。パラメータリストやコンフィグレーションファイルは別途生成されたNN実行モデル100と組み合わせて使用される。
 データ入力部330には、学習済みのNN実行モデル100を生成するために必要なハードウェア情報HWやネットワーク情報NW等が入力される。ハードウェア情報HWやネットワーク情報NW等は、例えば所定のデータフォーマットで記載されたデータとして入力される。入力されたハードウェア情報HWやネットワーク情報NW等は、記憶部310に記憶される。ハードウェア情報HWやネットワーク情報NW等は、操作入力部360から使用者により入力または変更されてもよい。
 データ出力部340には、生成された学習済みのNN実行モデル100が出力される。例えば、生成されたNN実行モデル100と、学習済みパラメータPMとがデータ出力部340に出力される。
 表示部350は、LCDディスプレイ等の公知のモニタを有する。表示部350は、演算部320が生成したGUI(Graphical User Interface)画像やコマンド等を受け付けるためのコンソール画面などを表示できる。また、演算部320が使用者からの情報入力を必要とする場合、表示部350は操作入力部360から情報を入力することを使用者に促すメッセージや情報入力に必要なGUI画像を表示できる。
 操作入力部360は、使用者が演算部320等に対しての指示を入力する装置である。操作入力部360は、タッチパネル、キーボード、マウス等の公知の入力デバイスである。操作入力部360の入力は、演算部320に送信される。
 演算部320の機能の全部または一部は、例えばCPU(Central Processing Unit)やGPU(Graphics Processing Unit)のような1つ以上のプロセッサがプログラムメモリに記憶されたプログラムを実行することにより実現される。ただし、演算部320の機能の全部または一部は、LSI(Large Scale Integration)、ASIC(Application Specific Integrated Circuit)、FPGA(Field-Programmable Gate Array)、PLD(Programmable Logic Device)等のハードウェア(例えば回路部;circuity)により実現されてもよい。また、演算部320の機能の全部または一部は、ソフトウェアとハードウェアとの組み合わせにより実現されてもよい。
 演算部320の機能の全部または一部は、クラウドサーバ等の外部機器に設けられたCPUやGPUやハードウェア等の外部アクセラレータを用いて実現されてもよい。演算部320は、例えばクラウドサーバ上の演算性能が高いGPUや専用ハードウェアを併用することで、演算部320の演算速度を向上させることができる。
 記憶部310は、フラッシュメモリ、EEPROM(Electrically Erasable Programmable Read-Only Memory)、ROM(Read-Only Memory)、またRAM(Random Access Memory)等により実現される。記憶部310の全部または一部はクラウドサーバ等の外部機器に設けられ、通信回線により演算部320等と接続させてもよい。
[畳み込みニューラルネットワーク(CNN)200]
 次に、CNN200について説明する。図3は、CNN200の一例を示す図である。CNN200のネットワーク情報NWは、以下で説明するCNN200の構成に関する情報である。CNN200は、低ビットの重みwや量子化された入力データaを用いており、組み込み機器に組み込みやすい。
 CNN200は、畳み込み演算を行う畳み込み層210と、量子化演算を行う量子化演算層220と、出力層230と、を含む多層構造のネットワークである。CNN200の少なくとも一部において、畳み込み層210と量子化演算層220とが交互に連結されている。CNN200は、画像認識や動画認識に広く使われるモデルである。CNN200は、全結合層などの他の機能を有する層(レイヤ)をさらに有してもよい。
 図4は、畳み込み層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はストライドを示す。図4において点線で示された領域は、入力データ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の畳み込み演算の負荷が小さい。
[ニューラルネットワーク実行モデル100(NN実行モデル)100]
 次に、NN実行モデル100について説明する。図5は、NN実行モデル100の一例を示す図である。NN実行モデル100は、CNN200を動作対象ハードウェアにおいて演算させるために生成されたソフトウェアやハードウェアモデルである。ソフトウェアは、ハードウェアモデルを制御するソフトウェアを含む。ハードウェアモデルは、ビヘイビアレベルであってもよく、RTL(Register Transfer Level)であってもよく、ゲートや回路モジュール間の接続を表すネットリストであってもよく、それらの組み合わせであってもよい。
 NN実行モデル100は、第一メモリ1と、第二メモリ2と、DMAコントローラ3(以下、「DMAC3」ともいう)と、畳み込み演算回路4と、量子化演算回路5と、コントローラ6と、を備える。NN実行モデル100は、第一メモリ1および第二メモリ2を介して、畳み込み演算回路4と量子化演算回路5とがループ状に形成されていることを特徴とする。
 第一メモリ1は、例えばSRAM(Static RAM)などで構成された揮発性のメモリ等の書き換え可能なメモリである。第一メモリ1には、DMAC3やコントローラ6を介してデータの書き込みおよび読み出しが行われる。第一メモリ1は、畳み込み演算回路4の入力ポートと接続されており、畳み込み演算回路4は第一メモリ1からデータを読み出すことができる。また、第一メモリ1は、量子化演算回路5の出力ポートと接続されており、量子化演算回路5は第一メモリ1にデータを書き込むことができる。外部ホストCPUは、第一メモリ1に対するデータの書き込みや読み出しにより、NN実行モデル100に対するデータの入出力を行うことができる。
 第二メモリ2は、例えばSRAM(Static RAM)などで構成された揮発性のメモリ等の書き換え可能なメモリである。第二メモリ2には、DMAC3やコントローラ6を介してデータの書き込みおよび読み出しが行われる。第二メモリ2は、量子化演算回路5の入力ポートと接続されており、量子化演算回路5は第二メモリ2からデータを読み出すことができる。また、第二メモリ2は、畳み込み演算回路4の出力ポートと接続されており、畳み込み演算回路4は第二メモリ2にデータを書き込むことができる。外部ホストCPUは、第二メモリ2に対するデータの書き込みや読み出しにより、NN実行モデル100に対するデータの入出力を行うことができる。
 DMAC3は、外部バスEBに接続されており、DRAMなどの外部メモリと第一メモリ1との間のデータ転送を行う。また、DMAC3は、DRAMなどの外部メモリと第二メモリ2との間のデータ転送を行う。また、DMAC3は、DRAMなどの外部メモリと畳み込み演算回路4との間のデータ転送を行う。また、DMAC3は、DRAMなどの外部メモリと量子化演算回路5との間のデータ転送を行う。
 畳み込み演算回路4は、学習済みのCNN200の畳み込み層210における畳み込み演算を行う回路である。畳み込み演算回路4は、第一メモリ1に格納された入力データaを読み出し、入力データaに対して畳み込み演算を実施する。畳み込み演算回路4は、畳み込み演算の出力データf(以降、「畳み込み演算出力データ」ともいう)を第二メモリ2に書き込む。
 量子化演算回路5は、学習済みのCNN200の量子化演算層220における量子化演算の少なくとも一部を行う回路である。量子化演算回路5は、第二メモリ2に格納された畳み込み演算の出力データfを読み出し、畳み込み演算の出力データfに対して量子化演算(プーリング、Batch Normalization、活性化関数、および量子化のうち少なくとも量子化を含む演算)を行う。量子化演算回路5は、量子化演算の出力データ(以降、「量子化演算出力データ」ともいう)を第一メモリ1に書き込む。
 コントローラ6は、外部バスEBに接続されており、外部のホストCPUのスレーブとして動作する。コントローラ6は、パラメータレジスタや状態レジスタを含むレジスタ61を有している。パラメータレジスタは、NN実行モデル100の動作を制御するレジスタである。状態レジスタはセマフォSを含むNN実行モデル100の状態を示すレジスタである。外部ホストCPUは、コントローラ6を経由して、レジスタ61にアクセスできる。
 コントローラ6は、内部バスIBを介して、第一メモリ1と、第二メモリ2と、DMAC3と、畳み込み演算回路4と、量子化演算回路5と、接続されている。外部ホストCPUは、コントローラ6を経由して、各ブロックに対してアクセスできる。例えば、外部ホストCPUは、コントローラ6を経由して、DMAC3や畳み込み演算回路4や量子化演算回路5に対する命令を指示することができる。また、DMAC3や畳み込み演算回路4や量子化演算回路5は、内部バスIBを介して、コントローラ6が有する状態レジスタ(セマフォSを含む)を更新できる。状態レジスタ(セマフォSを含む)は、DMAC3や畳み込み演算回路4や量子化演算回路5と接続された専用配線を介して更新されるように構成されていてもよい。
 NN実行モデル100は、第一メモリ1や第二メモリ2等を有するため、DRAMなどの外部メモリからのDMAC3によるデータ転送において、重複するデータのデータ転送の回数を低減できる。これにより、メモリアクセスにより発生する消費電力を大幅に低減することができる。
[ニューラルネットワーク生成装置300の動作]
 次に、ニューラルネットワーク生成装置300の動作(ニューラルネットワーク生成方法)を、図6に示すニューラルネットワーク生成装置300の制御フローチャートに沿って説明する。ニューラルネットワーク生成装置300は初期化処理(ステップS10)を実施した後、ステップS11を実行する。
<ハードウェア情報取得工程(S11)>
 ステップS11において、ニューラルネットワーク生成装置300は、動作対象ハードウェアのハードウェア情報HWを取得する(ハードウェア情報取得工程)。ニューラルネットワーク生成装置300は、例えば、データ入力部330に入力されたハードウェア情報HWを取得する。ニューラルネットワーク生成装置300は、表示部350にハードウェア情報HWの入力に必要なGUI画像を表示させ、使用者にハードウェア情報HWを操作入力部360から入力させることでハードウェア情報HWを取得してもよい。
 ハードウェア情報HWは、具体的には、第一メモリ1および第二メモリ2として割り当てるメモリのメモリ種別やメモリ容量や入出力データ幅を有する。
 取得されたハードウェア情報HWは、記憶部310に記憶される。次に、ニューラルネットワーク生成装置300は、ステップS12を実行する。
<ネットワーク情報取得工程(S12)>
 ステップS12において、ニューラルネットワーク生成装置300は、CNN200のネットワーク情報NWを取得する(ネットワーク情報取得工程)。ニューラルネットワーク生成装置300は、例えば、データ入力部330に入力されたネットワーク情報NWを取得する。ニューラルネットワーク生成装置300は、表示部350にネットワーク情報NWの入力に必要なGUI画像を表示させ、使用者にネットワーク情報NWを操作入力部360から入力させることでネットワーク情報NWを取得してもよい。
 ネットワーク情報NWは、具体的には、入力層や出力層230を含むネットワーク構成と、重みwや入力データaのビット幅を含む畳み込み層210の構成と、量子化情報を含む量子化演算層220の構成と、を有する。
 取得されたネットワーク情報NWは、記憶部310に記憶される。次に、ニューラルネットワーク生成装置300は、ステップS13を実行する。
<ニューラルネットワーク実行モデル生成工程(S13)>
 ステップS13において、ニューラルネットワーク生成装置300の実行モデル生成部321は、ハードウェア情報HWとネットワーク情報NWとに基づいてNN実行モデル100を生成する(ニューラルネットワーク実行モデル生成工程)。
 ニューラルネットワーク実行モデル生成工程(NN実行モデル生成工程)は、例えば、レイヤマッピング工程(S13-1)と、畳み込み演算回路生成工程(S13-2)と、量子化演算回路生成工程(S13-3)と、DMAC生成工程(S13-4)と、を有する。
<レイヤマッピング工程(S13-1)>
 実行モデル生成部321は、CNN200の各レイヤを、ループ状に形成された畳み込み演算回路4と量子化演算回路5とにマッピングする(レイヤマッピング工程)。実行モデル生成部321は、CNN200の各レイヤをNN実行モデル100において順番に実行するためのシーケンスデータやソフトウェアを生成する。入力層や出力層230などのNN実行モデル100により実施できない演算が含まれるレイヤに関しては、NN実行モデル100とは別の外部ホストCPUなどの外部演算デバイスが実行可能なソフトウェアモジュールが生成される。
 図7は、NN実行モデル100の動作例を示すタイミングチャートである。実行モデル生成部321は、例えば図7に示すNN実行モデル100の動作を実施可能とするシーケンスデータやソフトウェアを生成する。以下、図7に示すNN実行モデル100の動作例を説明する。
 DMAC3は、レイヤ1(図3参照)の入力データaを第一メモリ1に格納する。DMAC3は、畳み込み演算回路4が行う畳み込み演算の順序にあわせて、レイヤ1の入力データaを分割して第一メモリ1に転送してもよい。
 畳み込み演算回路4は、第一メモリ1に格納されたレイヤ1(図3参照)の入力データaを読み出す。畳み込み演算回路4は、レイヤ1の入力データaに対してレイヤ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とが交互に演算を行い、図3に示す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は外部ホストCPUなどの外部演算デバイスに中間データを転送する。外部演算デバイスが中間データに対して演算を行った後、外部演算デバイスによる演算結果は第一メモリ1や第二メモリ2に入力される。NN実行モデル100は、外部演算デバイスによる演算結果に対する演算を再開する。
<畳み込み演算回路生成工程(S13-2)>
 実行モデル生成部321は、ハードウェア情報HWとネットワーク情報NWとに基づいてNN実行モデル100の畳み込み演算回路4を生成する(畳み込み演算回路生成工程)。実行モデル生成部321は、第一メモリ1および第二メモリ2として割り当てるメモリのメモリ容量などに基づいて、畳み込み層210の畳み込み演算のデータを分割する。生成される畳み込み演算回路4は、分割された畳み込み演算のデータを演算可能な構成を備える。畳み込み層210の畳み込み演算のデータを分割するブロックのサイズ(BcやBd)を小さくすれば、畳み込み演算回路4のハードウェア規模は小さくなるが、畳み込み層210の畳み込み演算の演算効率は低下する。
 図8は、畳み込み演算のデータ分割やデータ展開を説明する図である。
 NN実行モデル100の畳み込み演算回路4は、畳み込み層210の畳み込み演算(式1)の入力データを部分テンソルに分割して演算する。部分テンソルへの分割方法や分割数は特に限定されない。部分テンソルは、例えば、入力データa(x+i,y+j,c)をa(x+i,y+j,co)に分割することにより形成される。なお、NN実行モデル100の畳み込み演算回路4は、畳み込み層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
<畳み込み演算回路生成工程(S13-2):データ展開>
 NN実行モデル100の畳み込み演算回路4は、畳み込み層210の畳み込み演算における入力データaおよび重みwを展開して畳み込み演算を行う。
 分割入力データ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の畳み込み演算を、ベクトルデータとマトリクスデータとの乗算により実施できる。
 畳み込み演算のデータを分割するブロックのサイズ(BcやBd)は、例えば、所定の数の分割入力データaおよび所定の数の分割重みwが第一メモリ1に格納できるようなサイズに設定される。
 例えば、入力データaの大きさがX×Y×Cであり、重みwの大きさをK×K×C×Dであり、出力データfの大きさがX×Y×Dであるとする。d軸方向にサイズBdで分割された出力データf(x,y,do)は、c軸方向にサイズBcで分割された入力データa(x+i,y+j,co)と、サイズBcおよびBdにより分割された重みw(i,j,co,do)とを、i,j,coごとに畳み込み演算して、足し合わせることで算出できる。
 出力データfの要素が16ビットである場合、d軸方向にサイズBdで分割された出力データf(x,y,do)のサイズは、16・X・Y・Bdビットである。一方、入力データaの要素が2ビットである場合、Bdで分割された出力データfを算出するために必要な入力データaのサイズは2・X・Y・Bcビットである。また、重みwの要素が1ビットである場合、Bdで分割された出力データfを算出するために必要な重みwのサイズは1・K・K・Bc・Bdビットである。
 第二メモリ2のメモリ容量が16・X・Y・Bdビットより大きければ、Bdで分割された出力データf(x,y,do)を第二メモリ2に格納できる。一方、第一メモリ1のメモリ容量が(2・X・Y・Bc+1・K・K・Bc・Bd)ビットより大きければ、Bdで分割された出力データfを算出するために必要な入力データaおよび重みwを第一メモリ1に格納できる。
 上述した関係に基づいて、ハードウェア情報HWにおいて制約として指定された場合において、第一メモリ1および第二メモリ2のメモリ容量の上限から、分割するブロックのサイズ(BcやBd)を算出できる。また、分割するブロックのサイズ(BcやBd)から、第一メモリ1および第二メモリ2のメモリ容量を算出することもできる。
 なお、例えば畳み込み演算回路4とDMAC3との並列動作を可能とするために、第一メモリ1および第二メモリ2のメモリ容量が上述したメモリ容量の少なくとも2倍であり、ダブルバッファリングを実施できることが望ましい。
 以上の例は分割するブロックのサイズ(BcやBd)や第一メモリ1および第二メモリ2のメモリ容量の決定手段の一例である。分割するブロックのサイズ(BcやBd)や第一メモリ1および第二メモリ2のメモリ容量の決定は、メモリ使用態様や並列動作数などに応じて適宜変更される。
<畳み込み演算回路生成工程(S13-2):部分テンソルへの分割(1)>
 図9は、NN実行モデル100の他の動作例を示すタイミングチャートである。
 NN実行モデル100は、入力データaを部分テンソルに分割して、時分割により部分テンソルに対する演算を行ってもよい。
 図9は、入力データaを二つの部分テンソルに分解した場合の動作例を示している。分解された部分テンソルを、「第一部分テンソルa1」、「第二部分テンソルa2」とする。例えば、レイヤ2M-1の畳み込み演算は、第一部分テンソルa1に対応する畳み込み演算(図9において、「レイヤ2M-1(a1)」と表記)と、第二部分テンソルa2に対応する畳み込み演算(図7において、「レイヤ2M-1(a2)」と表記)と、に分解される。
 第一部分テンソルa1に対応する畳み込み演算および量子化演算と、第二部分テンソルa2に対応する畳み込み演算および量子化演算とは、図9に示すように、独立して実施することができる。
 畳み込み演算回路4は、第一部分テンソルa1に対応するレイヤ2M-1の畳み込み演算(図9において、レイヤ2M-1(a1)で示す演算)を行う。その後、畳み込み演算回路4は、第二部分テンソルaに対応するレイヤ2M-1の畳み込み演算(図9において、レイヤ2M-1(a)で示す演算)を行う。また、量子化演算回路5は、第一部分テンソルa1に対応するレイヤ2Mの量子化演算(図9において、レイヤ2M(a1)で示す演算)を行う。このように、NN実行モデル100は、第二部分テンソルaに対応するレイヤ2M-1の畳み込み演算と、第一部分テンソルa1に対応するレイヤ2Mの量子化演算と、を並列に実施できる。
 次に、畳み込み演算回路4は、第一部分テンソルa1に対応するレイヤ2M+1の畳み込み演算(図9において、レイヤ2M+1(a1)で示す演算)を行う。また、量子化演算回路5は、第二部分テンソルaに対応するレイヤ2Mの量子化演算(図9において、レイヤ2M(a)で示す演算)を行う。このように、NN実行モデル100は、第一部分テンソルa1に対応するレイヤ2M+1の畳み込み演算と、第二部分テンソルaに対応するレイヤ2Mの量子化演算と、を並列に実施できる。
 入力データaを部分テンソルに分割することで、NN実行モデル100は畳み込み演算回路4と量子化演算回路5とを並列して動作させることができる。その結果、畳み込み演算回路4と量子化演算回路5が待機する時間が削減され、NN実行モデル100の演算処理効率が向上する。図9に示す動作例において部分テンソルへの分割数は2であったが、分割数が2より大きい場合も同様に、NN実行モデル100は畳み込み演算回路4と量子化演算回路5とを並列して動作させることができる。
<畳み込み演算回路生成工程(S13-2):部分テンソルへの分割(2)>
 図10は、畳み込み演算の出力データfをタイル分割した部分テンソルftを示す図である。入力データatは、入力データaをx軸方向およびy軸方向において所定のサイズのタイル(ブロック)に分割したものである。部分テンソルftは、出力データfをx軸方向およびy軸方向においてそれぞれサイズTのタイル(ブロック)に分割したものである。上述した例と同様に、入力データaの大きさがX×Y×Cであり、重みwの大きさをK×K×C×Dであり、出力データfの大きさがX×Y×Dであるとする。部分テンソルftのサイズは、T・T・Dである。
 畳み込み演算回路4は、第一メモリ1から入力データatの一部を読み出し、部分テンソルft(第一の部分テンソルftという)を出力とするレイヤ2M-1の畳み込み演算を行う。第一の部分テンソルftは、第二メモリ2に書き込まれる。第一メモリ1に格納された入力データaの残部に対する畳み込み演算を実施する前に、量子化演算回路5は第二メモリ2に格納された第一の部分テンソルftに対応するレイヤ2Mの量子化演算を行う。レイヤ2Mの量子化演算の出力データは第一メモリ1に書き込まれる。その結果、第二メモリ2に書き込まれた第一の部分テンソルftは不要となる。
 次に、畳み込み演算回路4は、第一メモリ1から入力データatの他の一部を読み出し、部分テンソルft(第二の部分テンソルftという)を出力とするレイヤ2M-1の畳み込み演算を行う。第二の部分テンソルftは、第二メモリ2に書き込まれる。第二の部分テンソルftは、第一の部分テンソルftを上書きする。第一メモリ1に格納された入力データaの残部に対する畳み込み演算を実施する前に、量子化演算回路5は第二メモリ2に格納された第二の部分テンソルftに対応するレイヤ2Mの量子化演算を行う。レイヤ2Mの量子化演算の出力データは第一メモリ1に書き込まれる。その結果、第二メモリ2に書き込まれた第二の部分テンソルftは不要となる。
 上記の演算を第一メモリ1から入力データaの残部に対して行うことで、レイヤ2M-1の畳み込み演算とレイヤ2Mの量子化演算を完了する。このように畳み込み演算の出力データfをタイル分割することで、第二メモリ2のサイズを一つの部分テンソルftを格納できるメモリサイズまで削減できる。例えば出力データfを16ビットとする。タイル分割を行わない場合、第二メモリ2は出力データfを格納する必要があり、必要なメモリサイズは16・X・Y・Dビットである。一方、タイル分割を行う場合、第二メモリ2は一つの部分テンソルftを格納できればよく、必要なメモリサイズは16・T・Dビットまで削減される。
 一方、タイル分割を用いる場合、レイヤ2M-1の畳み込み演算の入力データaと、レイヤ2Mの量子化演算の出力データと、を第一メモリ1に別々に保持する必要がある。しかしながら、TのサイズをXやYに比べて十分小さくすることで、第一メモリ1および第二メモリ2のメモリ容量全体を削減できる。
<畳み込み演算回路生成工程(S13-2):部分テンソルへの分割(3)>
 図11から図13は、入力データaをスライス分割した部分テンソルasを示す図である。部分テンソルasは、入力データaをy軸方向において所定のサイズのスライス(ブロック)に分割したものである。
 図11に示すように、畳み込み演算回路4は、第一メモリ1から部分テンソルas(第一の部分テンソルas)の一部を読み出し、部分テンソルft(第一の部分テンソルftという)を出力とするレイヤ2M-1の畳み込み演算を行う。第一の部分テンソルftは、第二メモリ2に書き込まれる。第一メモリ1に格納された第一の部分テンソルasの残部に対する畳み込み演算を実施する前に、量子化演算回路5は第二メモリ2に格納された第一の部分テンソルftに対応するレイヤ2Mの量子化演算を行う。レイヤ2Mの量子化演算の出力データは第一メモリ1に書き込まれる。その結果、第二メモリ2に書き込まれた第一の部分テンソルftは不要となる。
 次に、畳み込み演算回路4は、第一メモリ1から第一の部分テンソルasの他の一部を読み出し、部分テンソルft(第二の部分テンソルftという)を出力とするレイヤ2M-1の畳み込み演算を行う。第二の部分テンソルftは、第二メモリ2に書き込まれる。第二の部分テンソルftは、第一の部分テンソルftを上書きする。第一メモリ1に格納された第一の部分テンソルasの残部に対する畳み込み演算を実施する前に、量子化演算回路5は第二メモリ2に格納された第二の部分テンソルftに対応するレイヤ2Mの量子化演算を行う。レイヤ2Mの量子化演算の出力データは第一メモリ1に書き込まれる。その結果、第二メモリ2に書き込まれた第二の部分テンソルftは不要となる。
 上記の演算を第一メモリ1から第一の部分テンソルasの残部に対して行うことで、第一の部分テンソルasに対するレイヤ2M-1の畳み込み演算とレイヤ2Mの量子化演算を完了する。その結果、第一メモリ1に書き込まれた第一の部分テンソルasは不要となる。
 次に、図12に示すように、畳み込み演算回路4および量子化演算回路5は、第一メモリ1から他の部分テンソルas(第二の部分テンソルas)に対して、同様に畳み込み演算と量子化演算を実施する。第一メモリ1に書き込まれた第一の部分テンソルasは不要であり、レイヤ2Mの量子化演算の出力データで上書きしてもよい。第二の部分テンソルasに対するレイヤ2M-1の畳み込み演算とレイヤ2Mの量子化演算を完了すると、第一メモリ1に書き込まれた第二の部分テンソルasは不要となる。
 次に、図13に示すように、畳み込み演算回路4および量子化演算回路5は、第一メモリ1から他の部分テンソルas(第三の部分テンソルas)に対して、同様に畳み込み演算と量子化演算を実施する。第一メモリ1に書き込まれた第一の部分テンソルasおよび第二の部分テンソルasは不要であり、レイヤ2Mの量子化演算の出力データで上書きしてもよい。第三の部分テンソルasに対するレイヤ2M-1の畳み込み演算とレイヤ2Mの量子化演算を完了すると、第一メモリ1に書き込まれた第三の部分テンソルasは不要となる。
 上記の演算を第一メモリ1から入力データaの残部に対して行うことで、レイヤ2M-1の畳み込み演算とレイヤ2Mの量子化演算の全てを完了する。このように入力データaをスライス分割することで、第一メモリ1のサイズを図10に示した例と比べて削減できる。
<畳み込み演算回路生成工程(S13-2):部分テンソルへの分割(4)>
 図14は、レイヤ2M+1の畳み込み演算により部分テンソルftを出力するために必要な他の部分テンソルを示す図である。
 レイヤ2M+1の畳み込み演算を行い部分テンソルftを出力するために、レイヤ2Mの量子化演算の入力の部分テンソルが必要となる。さらに、レイヤ2M-1の畳み込み演算の入力の部分テンソルが必要となる。このように、部分テンソルftを出力するために必要な部分テンソルには依存関係がある。この依存関係に基づき部分テンソルftを出力するために必要な部分テンソルを順番に演算することにより、部分テンソルftを算出してもよい。第一メモリ1および第二メモリ2のメモリサイズは部分テンソルを格納できるサイズであればよく、第一メモリ1および第二メモリ2のメモリ容量全体を削減できる。
 上述した様々な部分テンソルのサイズは、例えば、所定の数の部分テンソルが第一メモリ1や第二メモリ2に格納できるようなサイズに設定される。部分テンソルのサイズから第一メモリ1や第二メモリ2のメモリ容量を算出してもよい。
<畳み込み演算回路生成工程(S13-2):ハードウェアモデル生成>
 次に、実行モデル生成部321は、ネットワーク情報NWとして入力された重みwや入力データaのビット幅などの情報から、畳み込み演算回路4のハードウェアモデルを生成する。ハードウェアモデルは、ビヘイビアレベルであってもよく、RTL(Register Transfer Level)であってもよく、ゲートや回路モジュール間の接続を表すネットリストであってもよく、それらの組み合わせであってもよい。以下、生成される畳み込み演算回路4のハードウェアモデルの一例を説明する。
 図15は、生成される畳み込み演算回路4の内部ブロック図である。
 畳み込み演算回路4は、重みメモリ41と、乗算器42と、アキュムレータ回路43と、ステートコントローラ44と、を有する。畳み込み演算回路4は、乗算器42およびアキュムレータ回路43に対する専用のステートコントローラ44を有しており、命令コマンドが入力されると、外部のコントローラを必要とせずに畳み込み演算を実施できる。
 重みメモリ41は、畳み込み演算に用いる重みWが格納されるメモリであり、例えばSRAM(Static RAM)などで構成された揮発性のメモリ等の書き換え可能なメモリである。DMAC3は、DMA転送により、畳み込み演算に必要な重みWを重みメモリ41に書き込む。
 図16は、乗算器42の内部ブロック図である。
 乗算器42は、入力ベクトルAと重みマトリクスWとを乗算する。入力ベクトルAは、上述したように、分割入力データa(x+i,y+j,co)が展開されたBc個の要素を持つベクトルデータである。また、重みマトリクスWは、分割重みw(i,j,co,do)が展開されたBc×Bd個の要素を持つマトリクスデータである。乗算器42は、Bc×Bd個の積和演算ユニット47を有し、入力ベクトルAと重みマトリクスWとを乗算を並列して実施できる。
 乗算器42は、乗算に必要な入力ベクトルAと重みマトリクスWを、第一メモリ1および重みメモリ41から読み出して乗算を実施する。乗算器42は、Bd個の積和演算結果O(di)を出力する。
 図17は、積和演算ユニット47の内部ブロック図である。
 積和演算ユニット47は、入力ベクトルAの要素A(ci)と、重みマトリクスWの要素W(ci,di)との乗算を実施する。また、積和演算ユニット47は、乗算結果と他の積和演算ユニット47の乗算結果S(ci,di)と加算する。積和演算ユニット47は、加算結果S(ci+1,di)を出力する。要素A(ci)は、2ビットの符号なし整数(0,1,2,3)である。要素W(ci,di)は、1ビットの符号付整数(0,1)であり、値「0」は+1を表し、値「1」は-1を表す。
 積和演算ユニット47は、反転器(インバータ)47aと、セレクタ47bと、加算器47cと、を有する。積和演算ユニット47は、乗算器を用いず、反転器47aおよびセレクタ47bのみを用いて乗算を行う。セレクタ47bは、要素W(ci,di)が「0」の場合、要素A(ci)の入力を選択する。セレクタ47bは、要素W(ci,di)が「1」の場合、要素A(ci)を反転器により反転させた補数を選択する。要素W(ci,di)は、加算器47cのCarry-inにも入力される。加算器47cは、要素W(ci,di)が「0」のとき、S(ci,di)に要素A(ci)を加算した値を出力する。加算器47cは、W(ci,di)が「1」のとき、S(ci,di)から要素A(ci)を減算した値を出力する。
 図18は、アキュムレータ回路43の内部ブロック図である。
 アキュムレータ回路43は、乗算器42の積和演算結果O(di)を第二メモリ2にアキュムレートする。アキュムレータ回路43は、Bd個のアキュムレータユニット48を有し、Bd個の積和演算結果O(di)を並列して第二メモリ2にアキュムレートできる。
 図19は、アキュムレータユニット48の内部ブロック図である。
 アキュムレータユニット48は、加算器48aと、マスク部48bとを有している。加算器48aは、積和演算結果Oの要素O(di)と、第二メモリ2に格納された式1に示す畳み込み演算の途中経過である部分和と、を加算する。加算結果は、要素あたり16ビットである。加算結果は、要素あたり16ビットに限定されず、例えば要素あたり15ビットや17ビットであってもよい。
 加算器48aは、加算結果を第二メモリ2の同一アドレスに書き込む。マスク部48bは、初期化信号clearがアサートされた場合に、第二メモリ2からの出力をマスクし、要素O(di)に対する加算対象をゼロにする。初期化信号clearは、第二メモリ2に途中経過の部分和が格納されていない場合にアサートされる。
 乗算器42およびアキュムレータ回路43による畳み込み演算が完了すると、第二メモリに、出力データf(x,y,do)が格納される。
 ステートコントローラ44は、乗算器42およびアキュムレータ回路43のステートを制御する。また、ステートコントローラ44は、内部バスIBを介してコントローラ6と接続されている。ステートコントローラ44は、命令キュー45と制御回路46とを有する。
 命令キュー45は、畳み込み演算回路4用の命令コマンドC4が格納されるキューであり、例えばFIFOメモリで構成される。命令キュー45には、内部バスIB経由で命令コマンドC4が書き込まれる。
 制御回路46は、命令コマンドC4をデコードし、命令コマンドC4に基づいて乗算器42およびアキュムレータ回路43を制御するステートマシンである。制御回路46は、論理回路により実装されていてもよいし、ソフトウェアによって制御されるCPUによって実装されていてもよい。
 図20は、制御回路46のステート遷移図である。
 制御回路46は、命令キュー45に命令コマンドC4が入力されると(Not empty)、アイドルステートS1からデコードステートS2に遷移する。
 制御回路46は、デコードステートS2において、命令キュー45から出力される命令コマンドC3をデコードする。また、制御回路46は、コントローラ6のレジスタ61に格納されたセマフォSを読み出し、命令コマンドC4において指示された乗算器42やアキュムレータ回路43の動作を実行可能であるかを判定する。実行不能である場合(Not ready)、制御回路46は実行可能となるまで待つ(Wait)。実行可能である場合(ready)、制御回路46はデコードステートS2から実行ステートS3に遷移する。
 制御回路46は、実行ステートS3において、乗算器42やアキュムレータ回路43を制御して、乗算器42やアキュムレータ回路43に命令コマンドC4において指示された動作を実施させる。制御回路46は、乗算器42やアキュムレータ回路43の動作が終わると、命令キュー45から実行を終えた命令コマンドC4を取り除くとともに、コントローラ6のレジスタ61に格納されたセマフォSを更新する。制御回路46は、命令キュー45に命令がある場合(Not empty)、実行ステートS3からデコードステートS2に遷移する。制御回路46は、命令キュー45に命令がない場合(empty)、実行ステートS3からアイドルステートS1に遷移する。
 実行モデル生成部321は、畳み込み演算のデータを分割するブロックのサイズ(BcやBd)を、図16に示すように、積和演算ユニット47の個数(Bc×Bd個)に関連付ける。畳み込み層210の畳み込み演算のデータを分割するブロックのサイズ(BcやBd)を小さくすれば、乗算器42のハードウェア規模は小さくなるが、乗算器42の演算速度は低下する。
 図16に示すように、乗算器42にはBc個の要素を持つ入力ベクトルAとBc×Bd個の要素を持つ重みマトリクスWとが入力される。そのため、積和演算ユニット47の個数をBc×Bd個よりも多くしても、積和演算ユニット47を有効に活用できない。
 入力データaや重みwのc軸方向およびd軸方向のサイズやブロックのサイズ(BcやBd)は、除算やデータ統合などを効率よく実施するため、64や128や256などの2のべき乗のサイズであることが望ましい。
 ネットワーク情報NWとして入力された重みwや入力データaのビット幅を小さくすれば、乗算器42やアキュムレータ回路43のハードウェア規模を低減できる。また、重みwや入力データaのビット幅を小さくすれば、これらを格納する第一メモリ1と第二メモリ2のメモリ容量を小さくできる。また、DMAC3による第一メモリ1と第二メモリ2へのデータ転送時間を短縮できる。
<量子化演算回路生成工程(S13-3)>
 実行モデル生成部321は、ハードウェア情報HWとネットワーク情報NWとに基づいてNN実行モデル100の量子化演算回路5を生成する(量子化演算回路生成工程)。実行モデル生成部321は、ネットワーク情報NWとして入力された量子化情報から、量子化演算回路5のハードウェアモデルを生成する。ハードウェアモデルは、ビヘイビアレベルであってもよく、RTL(Register Transfer Level)であってもよく、ゲートや回路モジュール間の接続を表すネットリストであってもよく、それらの組み合わせであってもよい。以下、生成される量子化演算回路5のハードウェアモデルの一例を説明する。
 図21は、生成される量子化演算回路5の内部ブロック図である。
 量子化演算回路5は、量子化パラメータメモリ51と、ベクトル演算回路52と、量子化回路53と、ステートコントローラ54と、を有する量子化演算回路5は、ベクトル演算回路52および量子化回路53に対する専用のステートコントローラ54を有しており、命令コマンドが入力されると、外部のコントローラを必要とせずに量子化演算を実施できる。
 量子化パラメータメモリ51は、量子化演算に用いる量子化パラメータqが格納されるメモリであり、例えばSRAM(Static RAM)などで構成された揮発性のメモリ等の書き換え可能なメモリである。DMAC3は、DMA転送により、量子化演算に必要な量子化パラメータqを量子化パラメータメモリ51に書き込む。
 図22は、ベクトル演算回路52と量子化回路53の内部ブロック図である。
 ベクトル演算回路52は、第二メモリ2に格納された出力データf(x,y,do)に対して演算を行う。ベクトル演算回路52は、Bd個の演算ユニット57を有し、出力データf(x,y,do)に対して並列にSIMD演算を行う。
 図23は、演算ユニット57のブロック図である。
 演算ユニット57は、例えば、ALU57aと、第一セレクタ57bと、第二セレクタ57cと、レジスタ57dと、シフタ57eと、を有する。演算ユニット57は、公知の汎用SIMD演算回路が有する他の演算器等をさらに有してもよい。
 ベクトル演算回路52は、演算ユニット57が有する演算器等を組み合わせることで、出力データf(x,y,do)に対して、量子化演算層220におけるプーリング層221や、Batch Normalization層222や、活性化関数層223の演算のうち少なくとも一つの演算を行う。
 演算ユニット57は、レジスタ57dに格納されたデータと第二メモリ2から読み出した出力データf(x,y,do)の要素f(di)とをALU57aにより加算できる。演算ユニット57は、ALU57aによる加算結果をレジスタ57dに格納できる。演算ユニット57は、第一セレクタ57bの選択によりレジスタ57dに格納されたデータに代えて「0」をALU57aに入力することで加算結果を初期化できる。例えばプーリング領域が2×2である場合、シフタ57eはALU57aの出力を2bit右シフトすることで加算結果の平均値を出力できる。ベクトル演算回路52は、Bd個の演算ユニット57による上記の演算等を繰り返すことで、式2に示す平均プーリングの演算を実施できる。
 演算ユニット57は、レジスタ57dに格納されたデータと第二メモリ2から読み出した出力データf(x,y,do)の要素f(di)とをALU57aにより比較できる。
演算ユニット57は、ALU57aによる比較結果に応じて第二セレクタ57cを制御して、レジスタ57dに格納されたデータと要素f(di)の大きい方を選択できる。演算ユニット57は、第一セレクタ57bの選択により要素f(di)の取りうる値の最小値をALU57aに入力することで比較対象を最小値に初期化できる。本実施形態において要素f(di)は16bit符号付き整数であるので、要素f(di)の取りうる値の最小値は「0x8000」である。ベクトル演算回路52は、Bd個の演算ユニット57による上記の演算等を繰り返すことで、式3のMAXプーリングの演算を実施できる。なお、MAXプーリングの演算ではシフタ57eは第二セレクタ57cの出力をシフトしない。
 演算ユニット57は、レジスタ57dに格納されたデータと第二メモリ2から読み出した出力データf(x,y,do)の要素f(di)とをALU57aにより減算できる。シフタ57eはALU57aの出力を左シフト(すなわち乗算)もしくは右シフト(すなわち除算)できる。ベクトル演算回路52は、Bd個の演算ユニット57による上記の演算等を繰り返すことで、式4のBatch Normalizationの演算を実施できる。
 演算ユニット57は、第二メモリ2から読み出した出力データf(x,y,do)の要素f(di)と第一セレクタ57bにより選択された「0」とをALU57aにより比較できる。演算ユニット57は、ALU57aによる比較結果に応じて要素f(di)と予めレジスタ57dに格納された定数値「0」のいずれかを選択して出力できる。ベクトル演算回路52は、Bd個の演算ユニット57による上記の演算等を繰り返すことで、式5のReLU演算を実施できる。
 ベクトル演算回路52は、平均プーリング、MAXプーリング、Batch Normalization、活性化関数の演算およびこれらの演算の組み合わせを実施できる。ベクトル演算回路52は、汎用SIMD演算を実施できるため、量子化演算層220における演算に必要な他の演算を実施してもよい。また、ベクトル演算回路52は、量子化演算層220における演算以外の演算を実施してもよい。
 なお、量子化演算回路5は、ベクトル演算回路52を有してなくてもよい。量子化演算回路5がベクトル演算回路52を有していない場合、出力データf(x,y,do)は量子化回路53に入力される。
 量子化回路53は、ベクトル演算回路52の出力データに対して、量子化を行う。量子化回路53は、図22に示すように、Bd個の量子化ユニット58を有し、ベクトル演算回路52の出力データに対して並列に演算を行う。
 図24は、量子化ユニット58の内部ブロック図である。
 量子化ユニット58は、ベクトル演算回路52の出力データの要素in(di)に対して量子化を行う。量子化ユニット58は、比較器58aと、エンコーダ58bと、を有する。量子化ユニット58はベクトル演算回路52の出力データ(16ビット/要素)に対して、量子化演算層220における量子化層224の演算(式6)を行う。量子化ユニット58は、量子化パラメータメモリ51から必要な量子化パラメータq(th0,th1,th2)を読み出し、比較器58aにより入力in(di)と量子化パラメータqとの比較を行う。量子化ユニット58は、比較器58aによる比較結果をエンコーダ58bにより2ビット/要素に量子化する。式4におけるα(c)とβ(c)は、変数cごとに異なるパラメータであるため、α(c)とβ(c)を反映する量子化パラメータq(th0,th1,th2)はin(di)ごとに異なるパラメータである。
 量子化ユニット58は、入力in(di)を3つの閾値th0,th1,th2と比較することにより、入力in(di)を4領域(例えば、in≦th0,th0<in≦th1,th1<in≦th2,th2<in)に分類し、分類結果を2ビットにエンコードして出力する。量子化ユニット58は、量子化パラメータq(th0,th1,th2)の設定により、量子化と併せてBatch Normalizationや活性化関数の演算を行うこともできる。
 量子化ユニット58は、閾値th0を式4のβ(c)、閾値の差(th1―th0)および(th2―th1)を式4のα(c)として設定して量子化を行うことで、式4に示すBatch Normalizationの演算を量子化と併せて実施できる。(th1―th0)および(th2―th1)を大きくすることでα(c)を小さくできる。(th1―th0)および(th2―th1)を小さくすることで、α(c)を大きくできる。
 量子化ユニット58は、入力in(di)の量子化と併せて活性化関数のReLU演算を実施できる。例えば、量子化ユニット58は、in(di)≦th0およびth2<in(di)となる領域では出力値を飽和させる。量子化ユニット58は、出力が非線形となるように量子化パラメータqを設定することで活性化関数の演算を量子化と併せて実施できる。
 ステートコントローラ54は、ベクトル演算回路52および量子化回路53のステートを制御する。また、ステートコントローラ54は、内部バスIBを介してコントローラ6と接続されている。ステートコントローラ54は、命令キュー55と制御回路56とを有する。
 命令キュー55は、量子化演算回路5用の命令コマンドC5が格納されるキューであり、例えばFIFOメモリで構成される。命令キュー55には、内部バスIB経由で命令コマンドC5が書き込まれる。
 制御回路56は、命令コマンドC5をデコードし、命令コマンドC5に基づいてベクトル演算回路52および量子化回路53を制御するステートマシンである。制御回路56は、畳み込み演算回路4のステートコントローラ44の制御回路46と同様の構成である。
 量子化演算回路5は、Bd個の要素を持つ量子化演算出力データを第一メモリ1に書き込む。なお、BdとBcの好適な関係を式10に示す。式10においてnは整数である。
Figure JPOXMLDOC01-appb-M000010
 実行モデル生成部321は、ネットワーク情報NWとして入力された量子化情報から、量子化演算回路5における、プーリングの演算の有無および方式、Batch Normalizationの演算の有無および方式、活性化関数の演算の有無および方式、量子化の方式、およびその他の演算の有無を決定する。
 例えば量子化演算回路5においてプーリングの演算を行う場合、実行モデル生成部321は、演算を行うプーリングの種類(平均プーリング、MAXプーリングなど)に最適化された演算ユニット57を生成する。
 例えば量子化演算回路5において活性化関数の演算を行う場合、実行モデル生成部321は、演算を行う活性化関数(ReLU演算など)に最適化された演算ユニット57や量子化ユニット58を生成する。
 例えば量子化演算回路5においてBatch Normalizationの演算を行う場合、実行モデル生成部321はBatch Normalizationの演算にあわせて演算ユニット57を生成する。また、実行モデル生成部321はBatch Normalizationの演算にあわせて量子化パラメータq(th0,th1,th2)を調整する。
 例えば量子化演算回路5による量子化が3ビット以上の量子化である場合、実行モデル生成部321はプーリングとBatch Normalizationと量子化のためのスケーリングとを実施可能なベクトル演算回路52を生成する。
 例えば量子化演算回路5の演算負荷を低減するために、Batch Normalizationの正規化の演算を効率化してもよい。具体的には、Batch Normalizationの正規化処理においてビットシフトを用いるために、入力テンソルの各要素を2のべき乗にする。これによりBatch Normalizationの正規化の演算をビットシフトのみで実現できる。ここで、入力テンソルの各要素を2のべき乗に変換するための追加の演算回路は量子化演算回路5に追加されてもよいし、畳み込み演算回路4に追加されてもよい。
<DMAC生成工程(S13-4)>
 実行モデル生成部321は、ハードウェア情報HWとネットワーク情報NWとに基づいてNN実行モデル100のDMAC3を生成する(DMAC生成工程)。実行モデル生成部321は、ネットワーク情報NWとして入力された情報から、DMAC3のハードウェアモデルを生成する。ハードウェアモデルは、ビヘイビアレベルであってもよく、RTL(Register Transfer Level)であってもよく、ゲートや回路モジュール間の接続を表すネットリストであってもよく、それらの組み合わせであってもよい。以下、生成されるDMAC3のハードウェアモデルの一例を説明する。
 図25は、生成されるDMAC3の内部ブロック図である。
 DMAC3は、データ転送回路31と、ステートコントローラ32と、を有する。DMAC3は、データ転送回路31に対する専用のステートコントローラ32を有しており、命令コマンドが入力されると、外部のコントローラを必要とせずにDMAデータ転送を実施できる。
 データ転送回路31は、外部バスEBに接続されており、DRAMなどの外部メモリと第一メモリ1との間のDMAデータ転送を行う。また、データ転送回路31は、DRAMなどの外部メモリと第二メモリ2との間のDMAデータ転送を行う。また、データ転送回路31は、DRAMなどの外部メモリと畳み込み演算回路4との間のデータ転送を行う。また、データ転送回路31は、DRAMなどの外部メモリと量子化演算回路5との間のデータ転送を行う。データ転送回路31のDMAチャンネル数は限定されない。例えば、第一メモリ1と第二メモリ2のそれぞれに専用のDMAチャンネルを有していてもよい。
 ステートコントローラ32は、データ転送回路31のステートを制御する。また、ステートコントローラ32は、内部バスIBを介してコントローラ6と接続されている。ステートコントローラ32は、命令キュー33と制御回路34とを有する。
 命令キュー33は、DMAC3用の命令コマンドC3が格納されるキューであり、例えばFIFOメモリで構成される。命令キュー33には、内部バスIB経由で1つ以上の命令コマンドC3が書き込まれる。
 制御回路34は、命令コマンドC3をデコードし、命令コマンドC3に基づいて順次データ転送回路31を制御するステートマシンである。制御回路34は、畳み込み演算回路4のステートコントローラ44の制御回路46と同様の構成である。
 実行モデル生成部321は、ネットワーク情報NWとして入力された情報から、DMAC3における、DMAチャンネル数やデータバス幅などを決定する。
 例えば、実行モデル生成部321は、ホスト側の外部バスEBの仕様にあわせた仕様(データバス幅等)のDMAC3を生成する。データバス幅やDMAチャンネル数を増やすことで外部メモリと第一メモリ1や第二メモリ2とのデータ伝送速度を向上させることができる。
<学習工程(S14)>
 ステップS14において、ニューラルネットワーク生成装置300の学習部322および推論部323は、学習データセットDSを用いて、生成されたNN実行モデル100の学習パラメータを学習する(学習工程)。学習工程(S14)は、例えば、学習済みパラメータ生成工程(S14-1)と、推論テスト工程(S14-2)と、を有する。
<学習工程:学習済みパラメータ生成工程(S14-1)>
 学習部322は、NN実行モデル100および学習データD1を用いて、学習済みパラメータPMを生成する。学習済みパラメータPMは、学習済みの重みwおよび量子化パラメータq等である。
 例えば、NN実行モデル100が画像認識を実施するCNN200の実行モデルである場合、学習データD1は入力画像と教師データTとの組み合わせである。入力画像は、CNN200に入力される入力データaである。教師データTは、画像に撮像された被写体の種類や、画像における検出対象物の有無や、画像における検出対象物の座標値などである。
 学習部322は、公知の技術である誤差逆伝播法などを用いた教師あり学習によって、学習済みパラメータPMを生成する。学習部322は、入力画像に対するNN実行モデル100の出力と、入力画像に対応する教師データTと、の差分Eを損失関数(誤差関数)により求め、差分Eが小さくなるように重みwおよび量子化パラメータq(th0,th1,th2)を更新する。
 例えば重みwを更新する場合、重みwに関する損失関数の勾配が用いられる。勾配は、例えば損失関数を微分することにより算出される。誤差逆伝播法を用いる場合、勾配は逆伝番(backward)により算出される。
 学習部322は、学習済みパラメータPMを生成する際に、畳み込み演算に関連する演算や量子化演算に関連する演算等をNN実行モデル100が実施する演算より高精度化する。
 学習部322は、勾配を算出して重みwを更新する際において、畳み込み演算に関連する演算を高精度化する。具体的には、NN実行モデル100が使用する低ビットの重みw(例えば1ビット)より高精度な32ビットの浮動小数点型の重みwが学習に使用される。また、NN実行モデル100の畳み込み演算回路4において実施する畳み込み演算が高精度化される。
 学習部322は、勾配を算出して重みwを更新する際において、活性化関数に関連する演算を高精度化する。具体的には、NN実行モデル100の量子化演算回路5において実施するReLU関数などの活性化関数より高精度なシグモンド関数が学習に使用される。
 一方、学習部322は、順伝搬(fоrward)により入力画像に対する出力データを算出する際においては、畳み込み演算および活性化関数に関連する演算を高精度化せず、NN実行モデル100に基づいた演算を実施する。重みwを更新する際に用いられた高精度な重みwは、ルックアップテーブル等により低ビット化される。
 学習部322は、勾配を算出して重みwを更新する際において、畳み込み演算および活性化関数に関連する演算を高精度化することにより、演算における中間データの精度低下を防止して、高い推論精度を実現できる学習済みパラメータPMを生成できる。
 一方、学習部322は、入力画像に対する出力データを算出する際において、順伝搬(fоrward)の演算を高精度化せず、NN実行モデル100に基づいた演算を実施する。そのため、学習部322が算出した出力データと、生成された学習済みパラメータPMを用いたNN実行モデル100の出力データと、が一致する。
<学習工程:推論テスト工程(S14-2)>
 推論部323は、学習部322が生成した学習済みパラメータPM、NN実行モデル100およびテストデータD2を用いて推論テストを実施する。例えば、NN実行モデル100が画像認識を実施するCNN200の実行モデルである場合、テストデータD2は、学習データD1同様に入力画像と教師データTとの組み合わせである。
 推論部323は、推論テストの進捗および結果を表示部350に表示する。推論テストの結果は、例えばテストデータD2に対する正解率である。
<確認工程(S15)>
 ステップS15において、ニューラルネットワーク生成装置300の推論部323は、操作入力部360から結果に関する確認を入力することを使用者に促すメッセージや情報入力に必要なGUI画像を表示部350に表示させる。使用者は、推論テストの結果を許容するかを、操作入力部360から入力する。使用者が推論テストの結果を許容することを示す入力が操作入力部360から入力された場合、ニューラルネットワーク生成装置300は、次にステップS16を実施する。使用者が推論テストの結果を許容しないことを示す入力が操作入力部360から入力された場合、ニューラルネットワーク生成装置300は、再度ステップS12を実施する。なお、ニューラルネットワーク生成装置300はステップS11まで戻って、ハードウェア情報HWを使用者に再入力させてもよい。
<出力工程(S16)>
 ステップS16において、ニューラルネットワーク生成装置300のハードウェア生成部324は、ハードウェア情報HWおよびNN実行モデル100に基づいてニューラルネットワークハードウェアモデル400を生成する。次に、ニューラルネットワーク生成装置300はステップS17を実施して処理を終了する。
 以上説明したように、本実施形態に係るニューラルネットワーク生成装置300、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラムによれば、IoT機器などの組み込み機器に組み込み可能であり、高性能に動作させることができるニューラルネットワーク実行モデル100およびニューラルネットワークハードウェアモデル400を生成できる。
 以上、本発明の第一実施形態について図面を参照して詳述したが、具体的な構成はこの実施形態に限られるものではなく、本発明の要旨を逸脱しない範囲の設計変更等も含まれる。また、上述の実施形態および変形例において示した構成要素は適宜に組み合わせて構成することが可能である。
(第二実施形態)
 本発明の第二実施形態に係るニューラルネットワーク生成装置300Bについて、図26から図28を参照して説明する以降の説明において、既に説明したものと共通する構成については、同一の符号を付して重複する説明を省略する。ニューラルネットワーク生成装置300Bは、第一実施形態のニューラルネットワーク生成装置300と比較して、学習工程(S14-1)のみが異なる。以下、以下の本実施形態における学習工程(S14-1)を説明する。
<学習工程:学習済みパラメータ生成工程(S14-1)>
 学習部322は、NN実行モデル100および学習データD1を用いて、学習済みパラメータPMを生成する。学習済みパラメータPMは、学習済みの重みw、量子化パラメータq、およびスケーリング係数sf等である。
 学習部322は、量子化パラメータq(th0,th1,th2)を学習するとともに、スケーリング係数sf(スケーリングファクタまたはステップサイズともいう)を学習する。スケーリング係数sfは、量子化された量子化演算出力データのスケールを示す係数であり、具体的には量子化演算出力データに対して乗算される係数である。
 図26から図28は、量子化演算におけるスケーリング係数sfを説明する図である。
 量子化演算は、図26に示すように、量子化パラメータq(th0,th1,th2)に基づいて2ビット(0,1,2,3)に量子化された量子化演算出力データを出力する。スケーリング係数sfは、図27および図28に示すように、量子化演算出力データに対して乗算される係数である。なお、量子化パラメータq(th0,th1,th2)は、量子化演算における入力データの範囲に適したパラメータであって、例えば8ビット以上の多ビットのパラメータである。
 学習部322は、例えば、量子化演算における入力データの範囲と量子化演算出力データにスケーリング係数sfを乗算したデータの範囲とが近付くようにスケーリング係数sfを学習する。例えば、入力データの範囲が狭い場合、スケーリング係数sfは小さくなる。また、入力データの範囲が広い場合、スケーリング係数sfは大きくなる。このように学習したスケーリング係数sfを量子化演算出力データに乗算することにより、学習部322は量子化演算に伴う精度低下を低減できる。
 スケーリング係数sfは、例えばレイヤごとに学習されるパラメータである。この場合、学習部322は、量子化演算における入力データの範囲に最適なスケーリング係数sfをレイヤごとに学習できる。なお、スケーリング係数sfは、レイヤごとに学習される態様に限定されず、例えば要素O(di)ごとに学習されてもよい。
 学習部322は、第一実施形態と同様に、学習済みパラメータを生成する際に畳み込み演算に関連する演算を高精度化する。本実施形態において、学習部322は、量子化演算出力データに対してスケーリング係数sfを乗算したデータを畳み込み演算の入力データとして使用する。畳み込み演算の高精度化および量子化演算出力データに対するスケーリング係数sfの適用により、学習部322は、演算における中間データの精度低下を防止して、より高い推論精度を実現できる学習済みパラメータPMを生成できる。
 一方、NN実行モデル100において、量子化演算出力データは2ビットであり、スケーリング係数sfは量子化演算出力データに対して直接乗算されない。そのため、学習時ではなく推論時に用いられる学習済みのNN実行モデル100(NN実行モデル100および学習済みパラメータPMを含む)においては、学習済みのスケーリング係数sfは、他の演算のパラメータに組み込まれる。他の演算のパラメータは、学習済みパラメータPMやNN実行モデル100を制御するソフトウェアのパラメータであって、例えば、量子化パラメータq(th0,th1,th2)、活性化関数の閾値、Batch Normalizationのパラメータ、重みwなどである。
 例えば、学習済みのスケーリング係数sfは、量子化パラメータq(th0,th1,th2)に組み込まれる。具体的には、量子化パラメータq(th0,th1,th2)は、量子化パラメータq(th0,th1,th2)をスケーリング係数sfにより除算した値に置換される。
 例えば、学習済みのスケーリング係数sfは、Batch Normalizationのパラメータに組み込まれる。具体的には、式4に示すα(c)は、α(c)をスケーリング係数sfにより除算した値に置換される。
 CNN200は、レイヤごとに実施する演算の種類が異なる場合がある。そのため、学習済みのスケーリング係数sfは、各レイヤが実施する演算から適宜選択された演算のパラメータとして組み込まれる。
 本実施形態においては、学習部332が量子化された量子化演算出力データに対するスケーリング係数sfを学習する例を示した。学習部332は、学習工程で学習される高精度化された重みwをルックアップテーブル等により量子化する際に、量子化された重みwに対するスケーリング係数を利用してもよい。学習部332は、量子化演算出力データに対するスケーリング係数sfを学習する方法と同様の方法により、重みwに対するスケーリング係数を学習できる。重みwに対するスケーリング係数は、量子化演算出力データに対するスケーリング係数sfと同様に、他の演算のパラメータに組み込まれる。
 以上説明したように、本実施形態に係るニューラルネットワーク生成装置300B、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラムによれば、IoT機器などの組み込み機器に組み込み可能であり、高性能に動作させることができるニューラルネットワーク実行モデル100およびニューラルネットワークハードウェアモデル400を生成できる。
 以上、本発明の第二実施形態について図面を参照して詳述したが、具体的な構成はこの実施形態に限られるものではなく、本発明の要旨を逸脱しない範囲の設計変更等も含まれる。また、上述の実施形態および変形例において示した構成要素は適宜に組み合わせて構成することが可能である。
(変形例1)
 上記実施形態において、第一メモリ1と第二メモリ2は別のメモリであったが、第一メモリ1と第二メモリ2の態様はこれに限定されない。第一メモリ1と第二メモリ2は、例えば、同一メモリにおける第一メモリ領域と第二メモリ領域であってもよい。
(変形例2)
 例えば、上記実施形態に記載のNN実行モデル100に入力されるデータは単一の形式に限定されず、静止画像、動画像、音声、文字、数値およびこれらの組み合わせで構成することが可能である。なお、NN実行モデル100に入力されるデータは、ニューラルネットワークハードウェアモデル400が設けられるエッジデバイスに搭載され得る、光センサ、温度計、Global Positioning System(GPS)計測器、角速度計測器、風速計などの物理量測定器における測定結果に限られない。周辺機器から有線または無線通信経由で受信する基地局情報、車両・船舶等の情報、天候情報、混雑状況に関する情報などの周辺情報や金融情報や個人情報等の異なる情報を組み合わせてもよい。
(変形例3)
 NN実行モデル100が設けられるエッジデバイスは、バッテリー等で駆動する携帯電話などの通信機器、パーソナルコンピュータなどのスマートデバイス、デジタルカメラ、ゲーム機器、ロボット製品などのモバイル機器を想定するが、これに限られるものではない。Power on Ethernet(PoE)などでの供給可能なピーク電力制限、製品発熱の低減または長時間駆動の要請が高い製品に利用することでも他の先行例にない効果を得ることができる。例えば、車両や船舶などに搭載される車載カメラや、公共施設や路上などに設けられる監視カメラ等に適用することで長時間の撮影を実現できるだけでなく、軽量化や高耐久化にも寄与する。また、テレビやディスプレイ等の表示デバイス、医療カメラや手術ロボット等の医療機器、製造現場や建築現場で使用される作業ロボットなどにも適用することで同様の効果を奏することができる。
 上述した実施形態におけるプログラムをコンピュータ読み取り可能な記録媒体に記録して、この記録媒体に記録されたプログラムをコンピュータシステムに読み込ませ、実行することによって実現してもよい。なお、ここでいう「コンピュータシステム」とは、OSや周辺機器等のハードウェアを含むものとする。また、「コンピュータ読み取り可能な記録媒体」とは、フレキシブルディスク、光磁気ディスク、ROM、CD-ROM等の可搬媒体、コンピュータシステムに内蔵されるハードディスク等の記憶装置のことをいう。さらに「コンピュータ読み取り可能な記録媒体」とは、インターネット等のネットワークや電話回線等の通信回線を介してプログラムを送信する場合の通信線のように、短時間の間、動的にプログラムを保持するもの、その場合のサーバやクライアントとなるコンピュータシステム内部の揮発性メモリのように、一定時間プログラムを保持しているものも含んでもよい。また上記プログラムは、前述した機能の一部を実現するためのものであってもよく、さらに前述した機能をコンピュータシステムにすでに記録されているプログラムとの組み合わせで実現できるものであってもよい。
 また、本明細書に記載された効果は、あくまで説明的または例示的なものであって限定的ではない。つまり、本開示に係る技術は、上記の効果とともに、または上記の効果に代えて、本明細書の記載から当業者には明らかな他の効果を奏しうる。
 本発明は、ニューラルネットワークの生成に適用することができる。
300,300B ニューラルネットワーク生成装置
200 畳み込みニューラルネットワーク(CNN)
100 ニューラルネットワーク実行モデル(NN実行モデル)
400 ニューラルネットワークハードウェアモデル
1 第一メモリ
2 第二メモリ
3 DMAコントローラ(DMAC)
4 畳み込み演算回路
42 乗算器
43 アキュムレータ回路
5 量子化演算回路
52 ベクトル演算回路
53 量子化回路
6 コントローラ
61 レジスタ
PM 学習済みパラメータ
DS 学習データセット
HW ハードウェア情報
NW ネットワーク情報

Claims (16)

  1.  ニューラルネットワークを演算するニューラルネットワーク実行モデルを生成するニューラルネットワーク生成装置であって、
     前記ニューラルネットワーク実行モデルが動作するハードウェアのハードウェア情報と、前記ニューラルネットワークのネットワーク情報と、に基づいて前記ニューラルネットワーク実行モデルを生成する実行モデル生成部と、
     生成された前記ニューラルネットワーク実行モデルの学習済みパラメータを生成する学習部と、
     を備える、
     ニューラルネットワーク生成装置。
  2.  前記ハードウェア情報および前記ニューラルネットワーク実行モデルに基づいて、ニューラルネットワークハードウェアモデルを生成するハードウェア生成部をさらに備える、
     請求項1に記載のニューラルネットワーク生成装置。
  3.  前記実行モデル生成部は、生成した前記ニューラルネットワーク実行モデルに基づいて、前記ニューラルネットワーク実行モデルにおいて実施する畳み込み演算を分割する、
     請求項1または請求項2に記載のニューラルネットワーク生成装置。
  4.  前記学習部は、前記学習済みパラメータを生成する際に実施する関連する演算を、前記ニューラルネットワーク実行モデルが実施する演算より高精度化する、
     請求項1から請求項3のいずれか一項に記載のニューラルネットワーク生成装置。
  5.  前記ニューラルネットワーク実行モデルは、畳み込み演算を実施する畳み込み演算回路と、量子化演算を実施する量子化演算回路と、を備える、
     請求項1から請求項3のいずれか一項に記載のニューラルネットワーク生成装置。
  6.  前記学習部は、前記学習済みパラメータを生成する際に実施する畳み込み演算を、前記畳み込み演算回路が実施する畳み込み演算より高精度化する、
     請求項5に記載のニューラルネットワーク生成装置。
  7.  前記学習部は、前記量子化演算回路が前記量子化演算に用いる量子化パラメータを学習する、
     請求項5に記載のニューラルネットワーク生成装置。
  8.  前記学習部は、前記量子化パラメータを学習する際に、前記量子化パラメータにより量子化された量子化演算出力データに対するスケーリング係数を学習する、
     請求項7に記載のニューラルネットワーク生成装置。
  9.  ニューラルネットワークを演算するニューラルネットワーク実行モデルを生成するニューラルネットワーク生成方法であって、
     前記ニューラルネットワーク実行モデルが動作するハードウェアのハードウェア情報を取得するハードウェア情報取得工程と、
     前記ニューラルネットワークのネットワーク情報を設定するネットワーク情報取得工程と、
     前記ハードウェア情報と前記ネットワーク情報とに基づいて、前記ニューラルネットワーク実行モデルを生成する実行モデル生成工程と、
     生成された前記ニューラルネットワーク実行モデルの学習パラメータを学習する学習工程と、
     を備える、
     ニューラルネットワーク生成方法。
  10.  前記ハードウェア情報および前記ニューラルネットワーク実行モデルに基づいて、ニューラルネットワークハードウェアモデルを生成する出力工程をさらに備える、
     請求項9に記載のニューラルネットワーク生成方法。
  11.  前記実行モデル生成工程は、生成した前記ニューラルネットワーク実行モデルに基づいて、前記ニューラルネットワーク実行モデルにおいて実施する畳み込み演算を分割する、
     請求項9または請求項10に記載のニューラルネットワーク生成方法。
  12.  前記学習工程は、前記学習パラメータを学習する際に実施する関連する演算を、前記ニューラルネットワーク実行モデルが実施する演算より高精度化する、
     請求項9から請求項11のいずれか一項に記載のニューラルネットワーク生成方法。
  13.  ニューラルネットワークを演算するニューラルネットワーク実行モデルをコンピュータに生成させるニューラルネットワーク生成プログラムであって、
     前記ニューラルネットワーク実行モデルが動作するハードウェアのハードウェア情報をコンピュータに取得させるハードウェア情報取得工程と、
     前記ニューラルネットワークのネットワーク情報をコンピュータに設定させるネットワーク情報取得工程と、
     前記ハードウェア情報と前記ネットワーク情報とに基づいて、前記ニューラルネットワーク実行モデルをコンピュータに生成させる実行モデル生成工程と、
     生成された前記ニューラルネットワーク実行モデルの学習パラメータをコンピュータに学習させる学習工程と、
     を備える、
     ニューラルネットワーク生成プログラム。
  14.  前記ハードウェア情報および前記ニューラルネットワーク実行モデルに基づいて、ニューラルネットワークハードウェアモデルをコンピュータに生成させる出力工程をさらに備える、
     請求項13に記載のニューラルネットワーク生成プログラム。
  15.  前記実行モデル生成工程は、生成した前記ニューラルネットワーク実行モデルに基づいて、前記ニューラルネットワーク実行モデルにおいて実施する畳み込み演算を分割する、
     請求項13または請求項14に記載のニューラルネットワーク生成プログラム。
  16.  前記学習工程は、前記学習パラメータを学習する際に実施する関連する演算を、前記ニューラルネットワーク実行モデルが実施する演算より高精度化する、
     請求項13から請求項15のいずれか一項に記載のニューラルネットワーク生成プログラム。
PCT/JP2021/024836 2020-06-30 2021-06-30 ニューラルネットワーク生成装置、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラム WO2022004815A1 (ja)

Priority Applications (3)

Application Number Priority Date Filing Date Title
US18/013,162 US20230316071A1 (en) 2020-06-30 2021-06-30 Neural network generating device, neural network generating method, and neural network generating program
CN202180044360.XA CN115702426A (zh) 2020-06-30 2021-06-30 神经网络生成装置、神经网络生成方法以及神经网络生成程序
JP2022534096A JPWO2022004815A1 (ja) 2020-06-30 2021-06-30

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2020-113315 2020-06-30
JP2020113315 2020-06-30

Publications (1)

Publication Number Publication Date
WO2022004815A1 true WO2022004815A1 (ja) 2022-01-06

Family

ID=79316336

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2021/024836 WO2022004815A1 (ja) 2020-06-30 2021-06-30 ニューラルネットワーク生成装置、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラム

Country Status (4)

Country Link
US (1) US20230316071A1 (ja)
JP (1) JPWO2022004815A1 (ja)
CN (1) CN115702426A (ja)
WO (1) WO2022004815A1 (ja)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2019139747A (ja) * 2018-02-13 2019-08-22 北京曠視科技有限公司Beijing Kuangshi Technology Co., Ltd. 演算装置、演算実行設備及び演算実行方法
WO2019216404A1 (ja) * 2018-05-10 2019-11-14 パナソニックIpマネジメント株式会社 ニューラルネットワーク構築装置、情報処理装置、ニューラルネットワーク構築方法及びプログラム
WO2020075433A1 (ja) * 2018-10-10 2020-04-16 LeapMind株式会社 ニューラルネットワーク処理装置、ニューラルネットワーク処理方法、およびニューラルネットワーク処理プログラム
US20200151088A1 (en) * 2018-11-14 2020-05-14 The Mathworks, Inc. Systems and methods for configuring programmable logic devices for deep learning networks

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2019139747A (ja) * 2018-02-13 2019-08-22 北京曠視科技有限公司Beijing Kuangshi Technology Co., Ltd. 演算装置、演算実行設備及び演算実行方法
WO2019216404A1 (ja) * 2018-05-10 2019-11-14 パナソニックIpマネジメント株式会社 ニューラルネットワーク構築装置、情報処理装置、ニューラルネットワーク構築方法及びプログラム
WO2020075433A1 (ja) * 2018-10-10 2020-04-16 LeapMind株式会社 ニューラルネットワーク処理装置、ニューラルネットワーク処理方法、およびニューラルネットワーク処理プログラム
US20200151088A1 (en) * 2018-11-14 2020-05-14 The Mathworks, Inc. Systems and methods for configuring programmable logic devices for deep learning networks

Also Published As

Publication number Publication date
CN115702426A (zh) 2023-02-14
US20230316071A1 (en) 2023-10-05
JPWO2022004815A1 (ja) 2022-01-06

Similar Documents

Publication Publication Date Title
TWI818944B (zh) 神經網路處理單元及系統晶片
US11429838B2 (en) Neural network device for neural network operation, method of operating neural network device, and application processor including the neural network device
WO2022163861A1 (ja) ニューラルネットワーク生成装置、ニューラルネットワーク演算装置、エッジデバイス、ニューラルネットワーク制御方法およびソフトウェア生成プログラム
EP3709225A1 (en) System and method for efficient utilization of multipliers in neural-network computations
WO2021210527A1 (ja) ニューラルネットワーク回路の制御方法
US20220092399A1 (en) Area-Efficient Convolutional Block
KR102667790B1 (ko) 뉴럴 네트워크 회로, 에지 디바이스 및 뉴럴 네트워크 연산 방법
WO2022004815A1 (ja) ニューラルネットワーク生成装置、ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラム
WO2022085661A1 (ja) ニューラルネットワーク生成装置、ニューラルネットワーク制御方法およびソフトウェア生成プログラム
CN117112165A (zh) 虚拟现实应用任务的处理方法、装置、虚拟现实***
WO2022230906A1 (ja) ニューラルネットワーク生成装置、ニューラルネットワーク演算装置、エッジデバイス、ニューラルネットワーク制御方法およびソフトウェア生成プログラム
JP6931252B1 (ja) ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法
WO2024038662A1 (ja) ニューラルネットワーク学習装置およびニューラルネットワーク学習方法
JP2023154880A (ja) ニューラルネットワーク生成方法およびニューラルネットワーク生成プログラム
US11335045B2 (en) Combining feature maps in an artificial intelligence semiconductor solution
JP2023006509A (ja) ソフトウェア生成装置およびソフトウェア生成方法
JP2022114698A (ja) ニューラルネットワーク生成装置、ニューラルネットワーク制御方法およびソフトウェア生成プログラム
WO2023058422A1 (ja) ニューラルネットワーク回路およびニューラルネットワーク回路の制御方法
JP2022183833A (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
CN114692865A (zh) 一种神经网络量化训练方法、装置及相关产品
JP2022105437A (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
WO2024111644A1 (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
WO2023139990A1 (ja) ニューラルネットワーク回路およびニューラルネットワーク演算方法
JP2024026993A (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: 21833223

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2022534096

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21833223

Country of ref document: EP

Kind code of ref document: A1