[go: up one dir, main page]

WO2019165940A1 - Integrated circuit chip apparatus, board card and related product - Google Patents

Integrated circuit chip apparatus, board card and related product Download PDF

Info

Publication number
WO2019165940A1
WO2019165940A1 PCT/CN2019/075979 CN2019075979W WO2019165940A1 WO 2019165940 A1 WO2019165940 A1 WO 2019165940A1 CN 2019075979 W CN2019075979 W CN 2019075979W WO 2019165940 A1 WO2019165940 A1 WO 2019165940A1
Authority
WO
WIPO (PCT)
Prior art keywords
data block
processing circuit
basic
data
processed
Prior art date
Legal status (The legal status 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 status listed.)
Ceased
Application number
PCT/CN2019/075979
Other languages
French (fr)
Chinese (zh)
Inventor
陈天石
刘少礼
王秉睿
张尧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Cambricon Information Technology Co Ltd
Original Assignee
Shanghai Cambricon Information Technology Co Ltd
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
Priority claimed from CN201810164317.7A external-priority patent/CN110197268B/en
Priority claimed from CN201810164295.4A external-priority patent/CN110197267B/en
Priority claimed from CN201810164841.4A external-priority patent/CN110197273B/en
Priority claimed from CN201810164737.5A external-priority patent/CN110197271B/en
Priority claimed from CN201810164332.1A external-priority patent/CN110197270B/en
Priority claimed from CN201810164738.XA external-priority patent/CN110197272B/en
Application filed by Shanghai Cambricon Information Technology Co Ltd filed Critical Shanghai Cambricon Information Technology Co Ltd
Publication of WO2019165940A1 publication Critical patent/WO2019165940A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/06Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons
    • G06N3/063Physical realisation, i.e. hardware implementation of neural networks, neurons or parts of neurons using electronic means

Definitions

  • the present disclosure relates to the field of neural networks, and more particularly to an integrated circuit chip device, a board, and related products.
  • ANN Artificial Neural Network
  • a neural network is an operational model consisting of a large number of nodes (or neurons) connected to each other.
  • the calculation of the existing neural network is based on a CPU (Central Processing Unit) or a GPU (Graphics Processing Unit) to implement the operation of the neural network. Such calculations have a large amount of calculation and high power consumption.
  • Embodiments of the present disclosure provide an integrated circuit chip device, a board, and related products, which can improve the processing speed of the computing device and improve efficiency.
  • an integrated circuit chip device comprising: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, wherein at least one of the plurality of basic processing circuits A circuit includes a second mapping circuit, each of the first mapping circuit and the second mapping circuit for performing compression processing of each data in a neural network operation;
  • the main processing circuit is configured to perform each successive operation in the neural network operation and transmit data with the basic processing circuit;
  • the plurality of basic processing circuits are configured to perform operations in the neural network in parallel according to data transmitted by the main processing circuit, and transmit the operation results to the main processing circuit.
  • the integrated circuit chip device further includes: a branch processing circuit disposed between the main processing circuit and the at least one basic processing circuit; the branch processing circuit for performing the main processing Forwarding data between the circuit and the at least one basic processing circuit; wherein the branch processing circuit includes a plurality of branch processing circuits, the main processing circuit and the plurality of branch processing circuits being respectively connected, each branch processing circuit and at least one The basic processing circuit is connected.
  • an integrated circuit chip device in a second aspect, includes: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, and at least the plurality of basic processing circuits A circuit includes a second mapping circuit, each of the first mapping circuit and the second mapping circuit for performing compression processing of each data in a neural network operation;
  • the main processing circuit is configured to acquire an input data block, a convolution kernel data block, and a convolution instruction, and divide the input data block into a broadcast data block according to the convolution instruction, and divide the convolution kernel data block into Generating a data block; determining, according to the operation control of the convolution instruction, starting the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and And the broadcast data block; transmitting the processed first data block to at least one of the basic processing circuits connected to the main processing circuit according to the convolution instruction;
  • the plurality of basic processing circuits are configured to determine, according to the operation control of the convolution instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block. Calculating an operation result, and transmitting the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit;
  • the second data block is the receiving the main processing circuit determined by the basic processing circuit a transmitted data block, the second data block being associated with the processed first data block;
  • the main processing circuit is configured to process the operation result to obtain an instruction result of the convolution instruction.
  • an integrated circuit chip device comprising: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, wherein at least one of the plurality of basic processing circuits A circuit includes a second mapping circuit, each of the first mapping circuit and the second mapping circuit for performing compression processing of each data in a neural network operation;
  • the main processing circuit is configured to acquire an input data block, a weight data block, and a multiplication instruction, and divide the input data block into a data block according to the multiplication instruction, and divide the weight data block into a broadcast data block. And determining, according to the operation control of the multiplication instruction, starting the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast a data block; transmitting, according to the multiplication instruction, the processed first data block to at least one of the basic processing circuits connected to the main processing circuit;
  • the plurality of basic processing circuits are configured to determine, according to the operation control of the multiplication instruction, whether to start the second mapping circuit to process the second data block, and perform the operation in the neural network in parallel according to the processed second data block. Obtaining an operation result, and transmitting the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is sent by the main processing circuit determined by the basic processing circuit Data block, the second data block is associated with the processed first data block;
  • the main processing circuit is configured to process the operation result to obtain an instruction result of the multiplication instruction.
  • an integrated circuit chip device for performing a neural network forward operation, the neural network includes n layers, and the main processing circuit includes a first mapping circuit, the plurality of At least one of the basic processing circuits includes a second mapping circuit, each of the first mapping circuit and the second mapping circuit for performing compression processing of each data in the neural network operation:
  • the main processing circuit is configured to receive a forward operation instruction, and parse the forward operation instruction to obtain a first operation instruction included in an ith layer of the forward operation instruction in the forward operation of the neural network An input data block and a weight data block required by the first operation instruction, wherein the range of i is an integer greater than or equal to 1, and less than or equal to n, and if the i is greater than or equal to 2, the input data block is Output data block of layer i-1;
  • the main processing circuit is configured to divide the input data block into a broadcast data block according to the first operation instruction, and divide the convolution kernel data block into a data block; according to the first forward instruction
  • the operation control determines to start the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast data block;
  • the product instruction sends the processed first data block to at least one of the basic processing circuits connected to the main processing circuit;
  • the plurality of basic processing circuits are configured to determine, according to the operation control of the first operation instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block.
  • the operation obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit;
  • the second data block is the receiving the main processing determined by the basic processing circuit a data block sent by the circuit, the second data block being associated with the processed first data block;
  • the main processing circuit is configured to process the operation result to obtain an instruction result of the first operation instruction, and complete an operation of the first operation instruction included in the ith layer.
  • an integrated circuit chip device for performing training of a neural network, where the neural network includes n layers, and the n value ranges from an integer greater than or equal to 2, wherein
  • the integrated circuit chip device includes: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, and at least one of the plurality of basic processing circuits includes a second mapping circuit, A mapping circuit and the second mapping circuit are both used to perform compression processing of respective data in a neural network operation;
  • the integrated circuit chip device is configured to receive a training instruction, determine first layer input data and first layer weight group data according to the training instruction, and perform a neural network on the first layer input data and the first layer weight group data.
  • the n-th layer forward operation obtains the nth output result of the forward operation:
  • the main processing circuit is further configured to obtain an nth output result gradient according to the nth output result, and obtain an nth reverse operation nth inverse operation instruction and the nth inverse operation according to the training instruction
  • the plurality of basic processing circuits are configured to determine, according to the operation control of the nth reverse operation instruction, whether to start the second mapping circuit to process the second data block, and execute the nerve in parallel according to the processed second data block
  • An operation in the network obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit;
  • the second data block is determined by the basic processing circuit to receive the a data block sent by the main processing circuit, the second data block being associated with the processed first data block;
  • the main processing circuit is further configured to process the operation result to obtain an nth layer weight group gradient and an nth layer input data gradient, and apply the nth layer weight group gradient to the nth layer weight group data.
  • the integrated circuit chip device is further configured to perform an n-1 layer inverse operation on the nth layer input data gradient as an n-1th output gradient of the n-1th layer to obtain an n-1 layer weight group gradient, and apply The n-1 layer weight group gradient updates the weight group data of the corresponding layer, and the weight group data includes at least two weights.
  • a neural network processor board includes: a neural network chip package structure, a first electrical and non-electrical connection device, and a first substrate; the neural network chip package structure The method includes: a neural network chip, a second electrical and non-electrical connection device, and a second substrate, the second substrate carries the neural network chip, and the second substrate passes the second electrical and non-electrical connection device Neural network chip connection;
  • the neural network chip includes the integrated circuit chip device provided by any of the above aspects to the fifth aspect.
  • a neural network computing device comprising the integrated circuit chip device provided by any one of the first to fifth aspects.
  • a combined processing apparatus includes: a neural network computing apparatus provided by the seventh aspect, a universal interconnection interface, and a general processing apparatus;
  • the neural network computing device is coupled to the general purpose processing device via the universal interconnect interface.
  • a chip is provided, the chip integrating the apparatus provided in any one of the first to eighth aspects above.
  • an electronic device comprising the chip of the ninth aspect.
  • a method for computing a neural network is provided, the method being applied to an integrated circuit chip device, the integrated circuit chip device comprising: the integrated circuit of any one of the first aspect to the fifth aspect A chip device for performing an operation of a neural network.
  • the compression mapping circuit is provided to compress the data block and then perform operations, thereby saving transmission resources and computing resources, so that it has the advantages of low power consumption and small calculation amount.
  • 1a is a schematic structural view of an integrated circuit chip device.
  • FIG. 1b is a schematic structural view of another integrated circuit chip device.
  • Figure 1c is a schematic structural view of a basic processing circuit.
  • Figure 2 is a schematic diagram of a matrix multiplied by a vector flow.
  • Figure 2a is a schematic diagram of a matrix multiplied by a vector.
  • Figure 2b is a schematic diagram of a matrix multiplied by a matrix flow.
  • Figure 2c is a schematic diagram of matrix Ai multiplied by vector B.
  • Figure 2d is a schematic diagram of matrix A multiplied by matrix B.
  • Figure 2e is a schematic diagram of matrix Ai multiplied by matrix B.
  • Figure 3a is a schematic diagram of neural network training.
  • Figure 3b is a schematic diagram of a convolution operation.
  • FIG. 4 is a schematic structural diagram of a neural network chip provided by the flow of the embodiment of the present disclosure.
  • 5a-5b are schematic structural diagrams of two mapping circuits provided by an embodiment of the present application.
  • Figure 6a is a schematic diagram of the forward operation of a neural network.
  • Figure 6b is a schematic diagram of a neural network operation.
  • Figure 7a is a schematic diagram of convolution input data.
  • Figure 7b is a schematic diagram of a convolution kernel.
  • Figure 7c is a schematic diagram of the operation window of a three-dimensional data block of input data.
  • Figure 7d is a schematic diagram of another operational window of a three-dimensional data block of input data.
  • Figure 7e is a schematic diagram of still another operational window of a three-dimensional data block of input data.
  • FIG. 8 is a schematic diagram of a training method of a neural network.
  • Figure 9a is a schematic diagram of neural network training.
  • Figure 9b is a schematic diagram of another neural network training.
  • Figure 9c is a schematic diagram of the forward and reverse operations of the neural network.
  • Figure 9d is a schematic diagram of a multi-layer structure of neural network training.
  • 9e is a schematic structural diagram of a neural network chip provided by the flow of the embodiment of the present disclosure.
  • FIG. 10a is a schematic structural diagram of a combined processing apparatus according to the present disclosure.
  • FIG. 10b is another schematic structural diagram of a combined processing apparatus according to the present disclosure.
  • FIG. 11 is a schematic structural diagram of a neural network processor card according to an embodiment of the present disclosure.
  • FIG. 11b is a schematic structural diagram of a neural network chip package structure according to an embodiment of the present disclosure.
  • 12a is a schematic diagram of a neural network chip package structure provided by the flow of the embodiment of the present disclosure.
  • FIG. 12b is a schematic diagram of another neural network chip package structure provided by the flow of the embodiment of the present disclosure.
  • the integrated circuit chip device includes: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, and at least one of the plurality of basic processing circuits ( That is, part or all of the basic processing circuit) includes a second mapping circuit, each of which is used to perform compression processing of each data in the neural network operation;
  • the main processing circuit is configured to perform each successive operation in the neural network operation and transmit data with the basic processing circuit;
  • the plurality of basic processing circuits are configured to perform operations in the neural network in parallel according to data transmitted by the main processing circuit, and transmit the operation results to the main processing circuit.
  • the integrated circuit chip device further includes: a branch processing circuit disposed between the main processing circuit and the at least one basic processing circuit; the branch processing circuit configured to Data is forwarded between the main processing circuit and the at least one underlying processing circuit.
  • the main processing circuit is configured to acquire a data block to be calculated and an operation instruction, and divide the data block to be calculated into a distribution data block and a broadcast data block according to the operation instruction;
  • the distribution data block and the pre-stored identification data block associated with the distribution data block are subjected to split processing to obtain a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; and the plurality of basic data are
  • the block and the identification data block associated with each of the plurality of basic data blocks are distributed to a base processing circuit connected thereto; the broadcast data block and the identification data block associated with the broadcast data block are broadcasted to a base processing circuit connected thereto.
  • the identifier data block may be specifically represented by a direct index or a step index, and an optional List of Lists (LIL), a Coordinate list (COO), and a compressed sparse line (Compressed). Sparse Row (CSR), Compressed Sparse Column (CSC), (ELL Pack, ELL), and Hybrid (HyB) are not limited in this application.
  • the identification data block is represented by a direct index
  • the identification data block may specifically be a data block composed of 0 and 1, wherein 0 represents data included in the data block (such as weight or input nerve).
  • the absolute value of the element is less than or equal to the first threshold, and 1 indicates that the absolute value of the data (such as the weight or the input neuron) contained in the data block is greater than the first threshold, and the first threshold is a custom random setting on the user side or the device side. , such as 0.05, 0, and so on.
  • the target data in the plurality of basic data blocks and the plurality of basic data may be specifically
  • the identification data blocks associated with the blocks are distributed to the basic processing circuit connected thereto; optionally, the target data in the processed broadcast data block and the identification data block associated with the broadcast data block may also be broadcasted to the base connected thereto.
  • the target data refers to data in which the absolute value of the data block is greater than the first threshold, or refers to non-zero data in the data block (here, specifically, the processed distribution data block or the processed broadcast data block).
  • the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the broadcast data block and the identification data associated with the basic data block; Processing, by the block, the broadcast data block and the basic data block to obtain a processed broadcast data block and a basic data block; performing an inner product operation on the processed broadcast data block and the basic data block to obtain an operation result, and Transmitting the result of the operation to the main processing circuit;
  • the main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result of the operation instruction.
  • the distribution data block is a matrix of M1 rows and N1 columns
  • the basic data block is a matrix of M2 rows and N2 columns, where M1>M2, N1>N2.
  • the identification data block associated with the distribution data block is also a matrix of M1 rows and N1 columns
  • the identification data block associated with the basic data block is also a matrix of M2 rows and N2 columns.
  • the first threshold is 0.05
  • the identifier data block associated with the basic data block is The processing of the data block with respect to the first mapping circuit and the second mapping circuit will be specifically described later.
  • the main processing circuit is configured to acquire a data block to be calculated and an operation instruction, and divide the data block to be calculated into a distribution data block and a broadcast data block according to the operation instruction;
  • the first mapping circuit is configured to process the distribution data block and the broadcast data block to obtain a processed distribution data block and an identification data block associated with the distribution data block, the processed broadcast data block, and the broadcast data block.
  • Associated identification data block splitting the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and identification data blocks associated with the basic data blocks, respectively
  • the plurality of basic data blocks and the identification data blocks respectively associated with the plurality of basic data blocks are distributed to the basic processing circuit connected thereto, and the broadcast data block and the identification data block associated with the broadcast data block are broadcasted to the connected Basic processing circuit;
  • the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the broadcast data block and the identification data associated with the basic data block; and according to the connection identification data block pair Processing the broadcast data block and the basic data block to obtain a processed broadcast data block and a basic data block; performing an inner product operation on the processed broadcast data block and the basic data block to obtain an operation result, and performing the operation The result is sent to the main processing circuit;
  • the main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result of the operation instruction.
  • the main processing circuit is further configured to split the broadcast data block or the processed broadcast data block and the identification data block associated with the broadcast data block to obtain a plurality of partial broadcast data. a block and an identification data block associated with each of the plurality of partial broadcast data blocks; broadcasting the plurality of partial broadcast data blocks and the identification data blocks associated with each of the plurality of partial broadcast data blocks by the one or more broadcasts to the a base processing circuit; wherein the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.
  • the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the partial broadcast data block and the identification data block associated with the basic data block;
  • the connection identification data is processed to process the partial broadcast data block and the basic data block to obtain a processed partial broadcast data block and the processed basic data block; and the processed partial broadcast data block and the processed The basic data block performs an inner product operation.
  • connection identification data block is a data block obtained by performing an element-by-element operation on the identification data block associated with the basic data block and the identification data block associated with the partial broadcast data block.
  • connection identifier data block is used to represent data in which two data blocks (specifically, a basic data block and a broadcast data block) are larger than an absolute value. The details will be described in detail later.
  • the identification data block associated with the distribution data block is a 2*3 matrix.
  • the identification data block associated with a part of the broadcast data block is a matrix of 2*2 Corresponding to the obtained connection identification data block is
  • the main processing circuit is configured to acquire a data block to be calculated and an operation instruction, and divide the data block to be calculated into a distribution data block and a broadcast data block according to the operation instruction; Initiating the first mapping circuit to process the distribution data block to obtain a processed distribution data block and an identification data block associated with the distribution data block, or to initiate the first mapping circuit to associate according to the pre-stored distribution data block
  • the identification data block processes the distribution data block to obtain the processed distribution data block; and the processed distribution data block and the identification data block associated with the distribution data block are split to obtain a plurality of basic data blocks and Identifying data blocks associated with each of the basic data blocks, distributing the plurality of basic data blocks and the identification data blocks associated with the plurality of basic data blocks to a basic processing circuit connected thereto, and broadcasting the broadcast data block To the basic processing circuit connected to it;
  • the basic processing circuit is configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, to obtain a processed broadcast data block; and the processed broadcast Performing an inner product operation on the data block and the processed basic data block to obtain an operation result, and transmitting the operation result to the main processing circuit;
  • the main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result of the operation instruction.
  • the main processing circuit is further configured to: split the broadcast data block to obtain a plurality of partial broadcast data blocks; and broadcast the plurality of partial broadcast data blocks by one or more broadcasts. Giving the basic processing circuit; wherein the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.
  • the basic processing circuit is configured to process the partial broadcast data block according to the identifier data block associated with the basic data block to obtain a processed partial broadcast data block; and to process the basic data block and the processing The latter part of the broadcast data block performs an inner product operation.
  • the main processing circuit is configured to acquire a data block to be calculated and an operation instruction, and divide the data block to be calculated into a distribution data block and a broadcast data block according to the operation instruction;
  • the first mapping circuit is configured to process the broadcast data block to obtain a processed broadcast data block and an identifier data block associated with the broadcast data block, or start the first mapping circuit according to the pre-stored broadcast data block.
  • the broadcast data block Processing, by the associated identification data block, the broadcast data block to obtain a processed broadcast data block; performing split processing on the distributed data block to obtain a plurality of basic data blocks; and distributing the plurality of basic data blocks to the connected a basic processing circuit, broadcasting the processed broadcast data block and the identification data block associated with the broadcast data block to a basic processing circuit connected thereto;
  • the basic processing circuit is configured to start, by the second mapping circuit, processing the basic data block according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and processing the processed broadcast data. Performing an inner product operation on the block and the processed basic data block to obtain an operation result, and transmitting the operation result to the main processing circuit;
  • the main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result of the operation instruction.
  • the main processing circuit is further configured to split the processed broadcast data block and the identification data block associated with the broadcast data block to obtain a plurality of partial broadcast data blocks and the And an identifier data block associated with the plurality of partial broadcast data blocks; and the identification data blocks associated with the plurality of partial broadcast data blocks and the plurality of partial broadcast data blocks are broadcast to the basic processing circuit by one or more times; And the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.
  • the basic processing circuit is configured to process the basic data block according to the identifier data block associated with the partial broadcast data block to obtain a processed basic data block; and the processed basic data block and the The partial broadcast data block performs an inner product operation.
  • the main processing circuit is specifically configured to send the broadcast data block (specifically, the broadcast data block or the processed broadcast data block) by one broadcast to the connected Basic processing circuit.
  • the basic processing circuit is specifically configured to perform inner product processing on the basic data block (which may be the basic data block or the processed basic data block) and the broadcast data block.
  • the inner product processing result is obtained, the inner product processing result is accumulated to obtain an operation result, and the operation result is sent to the main processing circuit.
  • the main processing circuit is configured to accumulate the operation result and obtain an accumulation result when the operation result is the result of the inner product processing, and arrange the accumulation result to obtain the The data block to be calculated and the instruction result of the operation instruction.
  • the main processing circuit is specifically configured to divide the broadcast data block into a plurality of partial broadcast data blocks, and broadcast the plurality of partial broadcast data blocks to the basic processing by multiple times. a circuit; the plurality of partial broadcast data blocks are combined to form the broadcast data block.
  • the basic processing circuit is specifically configured to perform an inner product of the partial broadcast data block (specifically, a partial broadcast data block or a processed partial broadcast data block) and the basic data block. After processing, an inner product processing result is obtained, and the inner product processing result is accumulated to obtain a partial operation result, and the partial operation result is sent to the main processing circuit.
  • the basic data block here takes the kernel 3*3 as an example.
  • the partial broadcast data block takes the 3*3 matrix as an example, and the *3 matrix and the core 3*3 perform the multiplication of the corresponding positions, then the corresponding inner product result is
  • the results of the three inner product processing Out0 (the inner product of the 0th row of the 3*3 matrix and the 0th row of the core 3*3), the Out1 (the inner product of the 1st row of the 3*3 matrix and the 1st row of the core 3*3), Out2 (the inner product of the 2nd line of the 3*3 matrix and the 2nd line of the 3*3 core) can be specifically:
  • r of r00 represents a partial broadcast data block
  • 00 represents a 0th column element of the 0th row.
  • K0[0] k represents the basic data block, and 0[0] represents the 0th column element of the 0th row;
  • the basic processing circuit is specifically configured to multiplex the partial broadcast data block n times to perform the inner product of the partial broadcast data block and the n basic data blocks to obtain n partial processing results (
  • the result of the n inner product operations may be corresponding to the n basic data blocks, and the n partial processing results are respectively accumulated to obtain n partial operation results, and the n partial operation results are obtained.
  • the n is an integer greater than or equal to 2.
  • the basic data block takes n cores 3*3 as an example.
  • the partial broadcast data block takes a 3*3 matrix as an example, and the n times 3*3 matrix is multiplexed with the core 3*3 to perform n times corresponding position multiplication, each time.
  • the operation is the corresponding inner product result, that is, there are three inner product results, and the three inner product results form a set of inner product operation results, and the three inner product results of each group in the n group are accumulated to obtain n partial operation results.
  • the core 3*3 may be replaced by other rules.
  • the partial input data may also be other regular data blocks.
  • the main processing circuit includes: a main register or a main on-chip buffer circuit;
  • the basic processing circuit includes a basic register or a basic on-chip buffer circuit.
  • the main processing circuit comprises: a vector operator circuit, an arithmetic logic unit circuit, an accumulator circuit, a matrix transposition circuit, a direct memory access circuit, a first mapping circuit or a data rearrangement circuit.
  • the branch processing circuit includes a plurality of branch processing circuits, the main processing circuit being respectively connected to the plurality of branch processing circuits, each branch processing circuit being connected to at least one basic processing circuit.
  • the basic processing circuit is further configured to forward the broadcast data block and the basic data block to other basic processing circuits to perform data processing and then perform an inner product operation to obtain an operation result. Transmitting the result of the operation to the main processing circuit;
  • the main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result of the operation instruction.
  • the data block may be represented by a tensor, which may specifically be one or any combination of a vector, a matrix, a three-dimensional data block, a four-dimensional data block, and an n-dimensional data block.
  • the data block may specifically include, but is not limited to, an input data block, a convolution kernel data block, and the like.
  • the operation instruction is a multiplication instruction
  • the main processing circuit determines that the multiplier data block is a broadcast data block, and the multiplicand data block is a distribution data block;
  • the main processing circuit determines that the input data block is a broadcast data block, and the convolution kernel is a distribution data block.
  • the operation of the neural network includes: a convolution operation, a matrix multiplication matrix operation, a matrix multiplication vector operation, a paranoid operation, a full connection operation, a GEMM operation, a GEMV operation, and an activation operation. Or any combination.
  • the operation instructions include, but are not limited to, a multiplication instruction, a convolution instruction, a forward operation instruction, and a training instruction.
  • the specific embodiments involved in the integrated chip device will be described below by taking the operation instructions as the multiplication instruction and the convolution instruction, respectively.
  • the operation instruction is a convolution instruction
  • the main processing circuit includes a first mapping circuit, and at least one of the plurality of basic processing circuits includes a second mapping circuit, the first mapping The circuit and the second mapping circuit are both used to perform compression processing of each data in the neural network operation:
  • the main processing circuit is configured to acquire an input data block, a convolution kernel data block, and a convolution instruction, and divide the input data block into vertical data blocks according to the convolution instruction, and the convolution kernel data block Dividing into a horizontal data block; determining, according to the operation control of the convolution instruction, starting the first mapping circuit to process the first data block, and obtaining the processed first data block; the first data block including the distribution data block And/or the broadcast data block; transmitting the processed first data block to at least one of the basic processing circuits connected to the main processing circuit according to the convolution instruction;
  • the plurality of basic processing circuits are configured to determine, according to the operation control of the convolution instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block. Calculating an operation result, and transmitting the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is the receiving the main processing circuit determined by the basic processing circuit a transmitted data block, the second data block being associated with the processed first data block; the main processing circuit configured to process the operation result to obtain an instruction result of the convolution instruction.
  • the main processing circuit is specifically configured to start the first mapping circuit, the distribution data block, and the Processing the broadcast data block to obtain the processed distribution data block, the identification data block associated with the distribution data block, the processed broadcast data block, and the identification data block associated with the broadcast data block; and distributing the processed data block and The identification data block associated with the distribution data block is split to obtain a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; and the plurality of basic data blocks and the plurality of basic data blocks are respectively And the associated identification data block is distributed to the basic processing circuit connected thereto, and the broadcast data block and the identification data block associated with the broadcast data block are broadcasted to the basic processing circuit connected thereto;
  • the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the basic data block and the identification data block associated with the broadcast data block; and identify the data block according to the connection Processing the basic data block and the broadcast data block, performing a convolution (ie inner product) operation on the processed basic data block and the processed broadcast data block to obtain an operation result, and transmitting the operation result to the The main processing circuit.
  • the main processing circuit is specifically configured to start processing, by the first mapping circuit, the processing data block to be processed. Distributing the data block and the identification data block associated with the distribution data block, or initiating the first mapping circuit to process the distribution data block according to the identifier data block associated with the pre-stored distribution data block to obtain the processed distribution data block; And dividing the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; and the plurality of basic data And the identification data block associated with each of the plurality of basic data blocks is distributed to a basic processing circuit connected thereto; the broadcast data block is broadcasted to a basic processing circuit connected thereto;
  • the basic processing circuit is configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, and execute the volume on the processed broadcast data block and the basic data block
  • the product operation obtains the operation result, and the operation result is sent to the main processing circuit.
  • the main processing circuit is specifically configured to start processing, by the first mapping circuit, the broadcast data block to be processed. And the broadcast data block and the identifier data block associated with the broadcast data block, or the first mapping circuit is configured to process the broadcast data block according to the pre-stored identifier data block associated with the broadcast data block to obtain the processed broadcast data block.
  • the basic processing circuit is configured to start, by the second mapping circuit, processing the basic data block according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and processing the processed basic data.
  • the block and the processed broadcast data block perform a convolution operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.
  • the basic processing circuit is configured to perform a convolution operation on the basic data block and the broadcast data block to obtain a convolution result, and accumulate the convolution result to obtain an operation result, where The operation result is sent to the main processing circuit; the main processing circuit is configured to obtain an accumulation result after accumulating the operation result, and arrange the accumulation result to obtain the instruction result.
  • the main processing circuit includes a first mapping circuit, and at least one of the plurality of basic processing circuits includes a second mapping circuit, the first mapping circuit And the second mapping circuit is configured to perform compression processing of each data in the neural network operation;
  • the main processing circuit is configured to acquire an input data block, a weight data block, and a multiplication instruction, and divide the input data block into a data block according to the multiplication instruction, and divide the weight data block into a broadcast data block. And determining, according to the operation control of the multiplication instruction, starting the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast a data block; transmitting, according to the multiplication instruction, the processed first data block to at least one of the basic processing circuits connected to the main processing circuit;
  • the plurality of basic processing circuits are configured to determine, according to the operation control of the multiplication instruction, whether to start the second mapping circuit to process the second data block, and perform the operation in the neural network in parallel according to the processed second data block. Obtaining an operation result, and transmitting the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is sent by the main processing circuit determined by the basic processing circuit The data block, the second data block is associated with the processed first data block; and the main processing circuit is configured to process the operation result to obtain an instruction result of the multiplication instruction.
  • the main processing circuit is specifically configured to start the first mapping circuit, the distribution data block, and the Processing the broadcast data block to obtain the processed distribution data block, the identification data block associated with the distribution data block, the processed broadcast data block, and the identification data block associated with the broadcast data block; and distributing the processed data block and The identification data block associated with the distribution data block is split to obtain a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; and the plurality of basic data blocks and the plurality of basic data blocks are respectively And the associated identification data block is distributed to the basic processing circuit connected thereto, and the broadcast data block and the identification data block associated with the broadcast data block are broadcasted to the basic processing circuit connected thereto;
  • the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the basic data block and the identification data block associated with the broadcast data block; and identify the data block according to the connection Processing the basic data block and the broadcast data block, performing a product operation on the processed basic data block and the processed broadcast data block to obtain an operation result, and transmitting the operation result to the main processing circuit.
  • the main processing circuit is specifically configured to start processing, by the first mapping circuit, the processing data block to be processed. Distributing the data block and the identification data block associated with the distribution data block, or initiating the first mapping circuit to process the distribution data block according to the identifier data block associated with the pre-stored distribution data block to obtain the processed distribution data block; And dividing the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; and the plurality of basic data And the identification data block associated with each of the plurality of basic data blocks is distributed to a basic processing circuit connected thereto; the broadcast data block is broadcasted to a basic processing circuit connected thereto;
  • the basic processing circuit is configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, and perform a product on the processed broadcast data block and the basic data block.
  • the operation obtains an operation result, and the operation result is transmitted to the main processing circuit.
  • the main processing circuit is specifically configured to start processing, by the first mapping circuit, the broadcast data block to be processed. And the broadcast data block and the identifier data block associated with the broadcast data block, or the first mapping circuit is configured to process the broadcast data block according to the pre-stored identifier data block associated with the broadcast data block to obtain the processed broadcast data block.
  • the basic processing circuit is configured to start, by the second mapping circuit, processing the basic data block according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and processing the processed basic data.
  • the block and the processed broadcast data block perform a product operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.
  • the basic processing circuit is configured to perform a product operation on the basic data block and the broadcast data block to obtain a product result, and accumulate the product result to obtain an operation result, and the operation result is obtained.
  • Sending to the main processing circuit; the main processing circuit is configured to obtain an accumulated result after accumulating the operation result, and arrange the accumulated result to obtain the instruction result.
  • FIG. 1a is a schematic structural diagram of an integrated circuit chip device.
  • the chip device includes: a main processing circuit, a basic processing circuit, and a branch processing circuit (optional). among them,
  • the main processing circuit may include a register and/or an on-chip buffer circuit, and the main processing circuit may further include: a control circuit, a vector operator circuit, an ALU (arithmetic and logic unit) circuit, an accumulator circuit, and a DMA (Direct Memory). Access, direct memory access) circuits and other circuits, of course, in practical applications, the above main processing circuit can also add, conversion circuits (such as matrix transposition circuits), data rearrangement circuits or activation circuits, and the like;
  • the main processing circuit may include: a first mapping circuit, where the first mapping circuit may be configured to process the received or sent data to obtain the processed data and the identifier mask data associated with the data, the identifier mask data It is used to indicate whether the absolute value of the data is greater than a preset threshold.
  • the mask data may be 0 or 1, where 0 indicates that the absolute value of the data is less than or equal to a preset threshold; otherwise, 1 indicates that the absolute value of the data is greater than Preset threshold.
  • the preset threshold is customized on the user side or the terminal device side, for example, 0.1 or 0.05, and the like.
  • data having a data of 0 or not greater than a preset threshold may be culled by the first mapping circuit, or the data may be set to zero.
  • a preset threshold eg, 0.1
  • the utility model has the advantages of reducing the amount of data transmitted by the main processing circuit to the basic processing circuit, reducing the calculation amount of the data operation in the basic processing circuit, and improving the data processing efficiency.
  • the invention does not limit the specific form of the first mapping circuit described above. A specific implementation of the first mapping circuit will be set forth below.
  • the input data of the main processing circuit is a matrix data block.
  • the processed matrix data block can be obtained as The identification data block associated with the matrix data block is The specific processing regarding the first mapping circuit will be described later in detail.
  • the main processing circuit distributes data to the basic processing circuit, only two data of 1 and 0.5 may be transmitted, not the processed matrix data block and 8 data; and the identifier of the matrix data block is also required to be associated.
  • the data blocks are sent together to the basic processing circuit, so that the basic processing circuit correspondingly knows that the two data are located at the position of the original matrix data block according to the received identification data block and the received two data (1 and 0.5). That is, the basic processing circuit can correspondingly restore the processed matrix data block in the main processing circuit according to the received identification data block and the received data.
  • the main processing circuit further includes a data transmitting circuit, a data receiving circuit or an interface, and the data transmitting circuit can integrate the data distributing circuit and the data broadcasting circuit.
  • the data distributing circuit and the data broadcasting circuit can also be separately set; in practical applications
  • the above data transmitting circuit and data receiving circuit may also be integrated to form a data transmitting and receiving circuit.
  • broadcast data data that needs to be sent to each of the underlying processing circuits.
  • For distributing data it is necessary to selectively send data to a part of the basic processing circuit, and the specific selection manner may be specifically determined by the main processing circuit according to the load and the calculation manner.
  • the broadcast transmission mode the broadcast data is transmitted to each of the basic processing circuits in a broadcast form.
  • the broadcast data is sent to each of the basic processing circuits by means of one broadcast, and the broadcast data may be sent to each of the basic processing circuits by means of multiple broadcasts.
  • the specific embodiment of the present application does not limit the above.
  • the number of times of broadcasting for the distribution transmission method, the distribution data is selectively transmitted to the partial basic processing circuit.
  • the control circuit of the main processing circuit transmits data to some or all of the basic processing circuits (the data may be the same or different, and specifically, if the data is transmitted by means of distribution, the basic processing circuit of each received data is received.
  • the data can be different, of course, the data received by some basic processing circuits can be the same;
  • the control circuit of the main processing circuit transmits data to some or all of the basic processing circuits, and the basic processing circuit of each received data can receive the same data.
  • the vector operator circuit of the main processing circuit may perform vector operations, including but not limited to: two vector addition, subtraction, multiplication and division, vector and constant addition, subtraction, multiplication, division, or each element in the vector.
  • the continuous operation may specifically be: vector and constant addition, subtraction, multiplication, division, activation, accumulation, and the like.
  • Each of the basic processing circuits may include a base register and/or a base on-chip buffer circuit; each of the base processing circuits may further include one or any combination of an inner product operator circuit, a vector operator circuit, an accumulator circuit, and the like.
  • the inner product operator circuit, the vector operator circuit, and the accumulator circuit may be integrated circuits, and the inner product operator circuit, the vector operator circuit, and the accumulator circuit may be separately provided circuits.
  • the chip device may further include one or more branch processing circuits, such as a branch processing circuit, wherein the main processing circuit is connected to the branch processing circuit, and the branch processing circuit is connected to the basic processing circuit, and the basic processing circuit is The product operator circuit is configured to perform an inner product operation between the data blocks, the control circuit of the main processing circuit controls the data receiving circuit or the data transmitting circuit to transmit and receive external data, and the control circuit controls the data transmitting circuit to distribute the external data to the branch processing a circuit for transmitting and receiving data of a main processing circuit or a basic processing circuit.
  • branch processing circuits such as a branch processing circuit
  • the structure shown in Figure 1a is suitable for the calculation of complex data, because for the main processing circuit, the number of connected cells is limited, so it is necessary to add a branch processing circuit between the main processing circuit and the basic processing circuit to achieve more
  • the basic processing circuit is accessed to enable calculation of complex data blocks.
  • the connection structure of the branch processing circuit and the basic processing circuit may be arbitrary, and is not limited to the H-type structure of FIG. 1a.
  • the main processing circuit to the basic processing circuit is a broadcast or distributed structure
  • the basic processing circuit to the main processing circuit is a gather structure. Broadcast, distribution and collection are defined as follows.
  • the number of basic processing circuits at this time is greater than that of the main processing circuit, that is, one main processing circuit corresponds to a plurality of basic processing circuits, that is, from the main processing circuit to a plurality of foundations.
  • the processing circuit is a broadcast or distributed structure, and conversely, the plurality of basic processing circuits to the main processing circuit may be a collection structure.
  • the basic processing circuit receives the data distributed or broadcast by the main processing circuit and stores it in the on-chip buffer of the basic processing circuit, and can perform the operation to generate the result, and can transmit the data to the main processing circuit.
  • the basic processing circuit may first process the received data, save the processed data to the on-chip buffer, and perform processing using the processed data to generate a result, and optionally the processed data. It is sent to other basic processing circuits or main processing circuits, etc., and is not limited in this application.
  • each of the basic processing circuits may include a second mapping circuit, or a second mapping circuit may be configured in the partial basic processing circuit; the second mapping circuit may be configured to process the received or transmitted data (ie, compress processing) ).
  • the present invention does not limit the specific form of the second mapping circuit described above. The specific implementation of the second mapping circuit will be described in detail below.
  • the vector operator circuit of the basic processing circuit can perform vector operations on two vectors (either one or both of the two vectors can be processed vectors), of course, in practical applications, basic processing
  • the inner product operator circuit of the circuit can perform inner product operations on the two vectors, and the accumulator circuit can also accumulate the results of the inner product operations.
  • the two vectors can be stored in on-chip buffers and/or registers, and the underlying processing circuitry can extract two vectors to perform the operations as needed for the actual computation.
  • the operations include, but are not limited to, inner product operations, multiplication operations, addition operations, or other operations.
  • the result of the inner product operation can be added to the on-chip buffer and/or the register; the advantage of the alternative is that the amount of data transfer between the basic processing circuit and the main processing circuit is reduced, and the number of data is increased. The efficiency of the operation reduces the power consumption of data transmission.
  • the result of the inner product operation is not accumulated and directly transmitted as a result; the advantage of this technical solution is that the calculation amount inside the basic processing circuit is reduced, and the operation efficiency of the basic processing circuit is improved.
  • each of the basic processing circuits may perform inner product operations of multiple sets of two vectors, or may accumulate results of multiple sets of inner product operations separately;
  • multiple sets of two vector data can be stored in an on-chip buffer and/or register
  • results of the multiple sets of inner product operations may be separately added to the on-chip buffer and/or registers
  • results of the inner product operations of each group may be directly accumulated as a result without accumulating;
  • each of the basic processing circuits may perform an inner product operation operation of the same vector and the plurality of vectors ("one-to-many" inner product, that is, two vectors of each group in the plurality of inner products. There is a vector in the shared), and the inner product results corresponding to each vector are separately accumulated.
  • the technical solution can realize the same set of weights to perform multiple calculations on different input data, increase data multiplexing, reduce data transmission amount of internal processing circuit internal data, improve calculation efficiency, and reduce power consumption.
  • the data source shared by each group and the other vector of each group may be different:
  • the vectors shared by the groups are from the broadcast or distribution of the main processing circuit or the branch processing circuit;
  • the vectors shared by each group are from an on-chip cache
  • the vectors shared by the groups are from registers
  • another non-shared vector of each group is from the broadcast or distribution of the main processing circuit or the branch processing circuit;
  • another non-shared vector of each group is from a register
  • each set of shared vectors retains any number of copies in the on-chip buffer and/or registers of the underlying processing circuitry when performing multiple sets of inner product operations;
  • the shared vector may be reserved for each inner product of each group
  • the shared vector can be kept only one copy
  • results of the multiple sets of inner product operations may be separately added to the on-chip buffer and/or the register;
  • the result of the inner product operation of each group may be directly transmitted as a result without being accumulated;
  • the vector or matrix involved in the basic processing circuit may be a vector or matrix processed by the second mapping circuit, as will be described later.
  • the device includes a main processing circuit (which can perform vector operations) and a multi-base processing circuit (which can perform inner product operations).
  • the advantage of this combination is that the device can not only perform matrix and vector multiplication operations using the basic processing circuit, but also perform other arbitrary vector operations using the main processing circuit, so that the device can be completed more quickly under the configuration of limited hardware circuits. More calculations reduce the number of data transmissions outside the device, improve computational efficiency, and reduce power consumption.
  • the chip may be configured with a first mapping circuit in the main processing circuit to perform processing of data in the neural network, such as culling the first input data that is less than or equal to the preset threshold, and simultaneously obtaining the corresponding first input data.
  • the associated mask data is used to indicate whether the absolute value of the first input data is greater than a preset threshold.
  • a second mapping circuit may be disposed in the basic processing circuit to perform processing of data in the neural network, for example, processing the second input data according to mask data associated with the first input data or mask data associated with the first input data and The mask data associated with the two input data selects the first input data whose absolute value is greater than the preset threshold and the second input data performs the corresponding arithmetic operation, and the like.
  • the specific processing of the data by the first mapping circuit and the second mapping circuit can be referred to later in detail.
  • the first mapping circuit and the second mapping circuit are both used to process data, which may be specifically designed into any one or more of the following circuits: a main processing circuit, a branch processing circuit, and Basic processing circuit, etc.
  • the chip can dynamically allocate which circuit to perform data compression according to the calculation amount (ie, the load amount) of each circuit (mainly the main processing circuit and the basic processing circuit).
  • Processing which can reduce the complexity of data calculation, reduce power consumption, and dynamic allocation of data processing can achieve the calculation efficiency without affecting the chip.
  • the manner of allocation includes, but is not limited to, load balancing, load minimum allocation, and the like.
  • the device shown in FIG. 1b is a computing device without a branch processing circuit, as shown in FIG. 1b, comprising: a main processing circuit and N basic processing circuits, wherein the main processing circuit ( The specific structure is as shown in FIG. 1c) and can be directly or indirectly connected to the N basic processing circuits.
  • an optional solution may include N/4 branch processing circuits as shown in FIG. 1a.
  • Each of the branch processing circuits is respectively connected to four basic processing circuits.
  • the basic processing circuit can also be disposed in the branch processing circuit.
  • the number of basic processing circuits connected to each branch processing circuit is not limited to four, and the manufacturer can configure according to actual needs.
  • the first processing circuit and the second basic processing circuit may be respectively configured with a first mapping circuit and a second mapping circuit.
  • the main processing circuit may include a first mapping circuit, the N basic processing circuits or A portion includes a second mapping circuit; the main processing circuit may include a first mapping circuit and a second mapping circuit, and may also mean that the N basic processing circuits or a part thereof includes a first mapping circuit and a second mapping circuit.
  • the main processing circuit may dynamically allocate an operation entity of the data compression processing step according to the neural network calculation instruction. Specifically, the main processing circuit may determine whether to perform a compression processing step on the received data according to its own load.
  • the load may be performed.
  • the value is set to a plurality of sections, and each section corresponds to an execution subject of the allocation data compression processing step. For example, taking three sections as an example, the load value of the section 1 is low, and the data compression processing steps can be performed by the N basic processing circuits.
  • the main processing circuit separately performs the data compression processing step, and the interval 2 load value is located between the interval 1 and the interval 3.
  • the main processing circuit can separately perform the data compression processing step, and the interval 3 has a high load value, which can be performed by the main processing circuit or N
  • the base processing circuit collectively performs the data compression processing steps. In this regard, it may be performed in an explicit manner.
  • the main processing circuit may be configured with a special indication or instruction.
  • the basic processing circuit When the basic processing circuit receives the special indication or instruction, it determines to perform a data compression processing step, such as the basic processing circuit does not receive When a special instruction or instruction is made, it is determined that the data compression processing step is not performed. As another example, it may be performed in an implied manner, for example, when the basic processing circuit receives the sparse data (ie, includes 0, or includes data smaller than a preset threshold greater than a preset number) and determines that an inner product operation needs to be performed, the sparse The data is compressed.
  • a data compression processing step such as the basic processing circuit does not receive
  • the data compression processing step is not performed.
  • it may be performed in an implied manner for example, when the basic processing circuit receives the sparse data (ie, includes 0, or includes data smaller than a preset threshold greater than a preset number) and determines that an inner product operation needs to be performed, the sparse The data is compressed.
  • the data compression processing involved in the present application is specifically performed in the first mapping circuit and the second mapping circuit described above. It should be understood that since the neural network is an algorithm with high computational complexity and high memory access, the more weights, the larger the calculation amount and the memory access amount. In particular, in the case where the weight is small (for example, 0, or less than the weight of the set value), in order to increase the calculation rate and reduce the overhead, it is necessary to compress the data with smaller weights. In practical applications, data compression processing is applied in sparse neural networks, and the effect is most obvious, such as reducing the workload of data calculation, reducing data overhead, and increasing data calculation rate.
  • the input data includes, but is not limited to, at least one input neuron and/or at least one weight.
  • the first mapping circuit After the first mapping circuit receives the first input data (specifically, the data block to be calculated sent by the main processing circuit, such as a distribution data block or a broadcast data block, etc.), the first mapping circuit may be the first input
  • the data is processed to obtain the processed first input data and the identifier mask data associated with the first input data, the mask data is used to indicate whether the absolute value of the first input data is greater than a first threshold, such as 0.5, 0, etc. Wait.
  • the input matrix data block is The first threshold is 0.05, and the processed matrix data block can be obtained after being processed by the first mapping circuit.
  • the identification data block also referred to as the mask matrix
  • the target data in the processed matrix data block may be transmitted (in this example, 1, 0.06) And 0.5) and the identification data block associated with the matrix data block.
  • the main processing circuit may distribute the target data in the processed matrix data block to the basic processing circuit according to a setting rule, for example, sequentially transmitting in a row order or sequentially in a column order, etc., the present application Not limited.
  • the basic processing circuit restores the target data block to the processed matrix data block according to a setting rule (for example, a row order).
  • the underlying processing circuit is based on the received data (1, 0.06, and 0.5) and the identified data block. It can be known that the matrix data block corresponding to the data (that is, the matrix data block processed by the first mapping circuit in the main processing circuit) is
  • the first input data may be a distribution data block and/or a broadcast data block.
  • the second mapping circuit can process the second input data by using the identification data associated with the first input data, thereby obtaining the processed second input data; wherein the first input data is different from the second input data.
  • the second input data may be at least one input neuron; or, when the first input data is at least one input neuron, then The second input data can be at least one weight.
  • the second input data is different from the first input data, and the second input data may be any one of: a distribution data block, a basic data block, a broadcast data block, and a partial broadcast data. Piece.
  • the second input data is a partial broadcast data block.
  • the second input data is a matrix data block
  • the processed partial broadcast data block is obtained as Since the dimension of the matrix data block involved in the input data is large in practical applications, the present application is merely illustrative and is not intended to be limiting.
  • the first mapping circuit is configured to process the first input data and the second input data to obtain the processed first input data and the first identifier mask data associated with the first input data, and the processed second Input data and second identification mask data associated with the second input data.
  • the first mask data or the second mask data is used to indicate whether the absolute value of the first or second input data is greater than a second threshold, and the second threshold is customized by the user side or the device side, for example, 0.05. 0 and so on.
  • the processed first input data or second input data may be processed input data or may be input data before processing.
  • the first input data is a distribution data block, such as the matrix data block in the above example.
  • the processed distribution data block can be obtained, and the processed distribution data block can be the original matrix data block.
  • the processed input data (such as processed basic data block or partial broadcast data block, etc.) should be after compression processing.
  • the data Preferably, the data sent by the main processing circuit to the basic processing circuit may be the target data in the processed input data, and the target data may be data with an absolute value greater than a preset threshold, or may be non-zero. Data and more.
  • the second mapping circuit may obtain connection identification data according to the first identification data associated with the first input data and the second identification data associated with the second input data; the connection identification data is used for And indicating that the absolute value of the first input data and the second input data are greater than a third threshold, wherein the third threshold is customized by the user side or the device side, such as 0.05, 0, and the like. Further, the second mapping circuit may process the received first input data and the second input data according to the connection identification data, thereby obtaining the processed first input data and the processed second input data.
  • the first input data is a matrix data block
  • the second input data block is also a matrix data block Obtaining, by the first mapping circuit, the first identification data block associated with the first input data And the processed first input data block Correspondingly obtaining the second identification data block associated with the second input data
  • the processed second input data block is Correspondingly, in order to increase the data transmission rate, only the target data 1, 0.06 and 0.5 in the processed first input data block and the first identification data block associated with the first input data block may be sent to the main processing circuit.
  • the basic processing circuit at the same time, the target data 1, 1.1, 0.6, 0.3 and 0.5 in the processed second input data block and the second identification data block associated with the second input data block are sent to the basic processing circuit.
  • the basic processing circuit may perform the element-by-element operation on the first identification data block and the second identification data block by using the second mapping circuit to obtain the connection identification data block.
  • the second mapping circuit processes the processed first input data block and the processed second input data block respectively by using the connection identification data block, so as to obtain the processed first input data block as The processed second input data block is
  • the first processing block is configured to determine, according to the first identification data block and the target data in the received first data block, the first data block corresponding to the target data (ie, the first processed by the first mapping circuit)
  • the first mapping circuit is not disposed in the main processing circuit, but the main processing circuit may send the third input data and the pre-stored third identification data associated with the third input data to the basic processing circuit connected thereto in.
  • a second mapping circuit is provided in the basic processing circuit. A specific embodiment of the data compression process involved in the second mapping circuit is explained below.
  • the third input data includes, but is not limited to, an elementary data block, a partial broadcast data block, a broadcast data block, and the like.
  • the third input data may also be at least one weight, and/or at least one input nerve, which is not limited herein.
  • the second mapping circuit may process the third input data according to the third identification data associated with the received third input data, thereby obtaining the processed third input data, so as to be subsequently
  • the processed third input data performs related arithmetic operations, such as inner product operations.
  • the third input data received by the second mapping circuit is a matrix data block.
  • the third mapping circuit processes the third input data block according to the third identification data block, and the processed third input data block is specifically
  • the input neurons and output neurons mentioned in the embodiments of the present invention do not refer to neurons in the input layer of the entire neural network and neurons in the output layer, but to any adjacent two layers in the neural network.
  • the neurons in the lower layer of the network feedforward operation are the input neurons
  • the neurons in the upper layer of the network feedforward operation are the output neurons.
  • the layer, the neurons in the layer are the above input neurons, the K+1 layer is called the output layer, and the neurons in the layer are the above-mentioned output neurons, that is, each layer can be used as an input except the top layer.
  • Layer, the next layer is the corresponding output layer.
  • a mapping circuit is not provided in the main processing circuit, and a first mapping circuit and a second mapping circuit are disposed in the basic processing circuit.
  • the mapping circuit is not disposed in the basic processing circuit, and the first mapping circuit and the second mapping circuit are both disposed in the main processing circuit, and the first mapping circuit and the second mapping circuit are
  • the main processing circuit completes the compression processing of the data, and sends the processed input data to the basic processing circuit, so that the basic processing circuit utilizes the processed input data (specifically, the processed neurons and the processed weights) Perform the corresponding arithmetic operations.
  • mapping circuit involved in the present application.
  • Two possible mapping circuits are shown in Figures 5a and 5b.
  • the mapping circuit shown in FIG. 5a includes a comparator and a selector.
  • the application is not limited.
  • a comparator and two selectors are shown in Fig. 5a, wherein the comparator is used to determine whether the input data satisfies a preset condition.
  • the preset condition may be customized for the user side or the device side. For example, the absolute value of the input data described above in the application is greater than or equal to a preset threshold.
  • the comparator may determine to allow output of the input data, the input data corresponding to the associated identification data being 1; otherwise, it may be determined that the input data is not output, or the input data is 0 by default.
  • the identification data corresponding to the input data at this time is 0. That is, after the comparator is passed, the identification data associated with the input data can be known.
  • the obtained identification data may be input to the selector, so that the selector uses the identification data to determine whether to output the corresponding input data, that is, after the processing is obtained. Input data.
  • a comparator can determine a predetermined condition for each data in the matrix data block, so that an identifier data block associated with the matrix data block can be obtained ( Mask matrix). Further, the matrix data block may be filtered by using the identifier data block in the first selector, and the data in the matrix data block whose absolute value is greater than or equal to a preset threshold (ie, a preset condition is satisfied) is reserved. The remaining data is deleted to output the processed matrix data block.
  • a preset threshold ie, a preset condition is satisfied
  • the identifier data block may also be used in the second selector to process other input data (for example, the second matrix data block), for example, performing an element-by-element AND operation to obtain an absolute value in the second matrix data block.
  • Data greater than or equal to the preset threshold is reserved to output the processed second matrix data block.
  • the specific structure of the first mapping circuit may include at least one comparator and at least one selector, such as the comparator and the first in FIG. 5a in the above example.
  • a selector such as the comparator and the first in FIG. 5a in the above example.
  • the specific result of the second mapping circuit may include one or more selectors, such as the second selector of Figure 5a in the above example.
  • the mapping circuit includes a selector, and the number of the selectors is not limited, and may be one or multiple.
  • the selector is configured to select the input data according to the identification data associated with the input data, so as to output data in which the absolute value of the input data is greater than or equal to a preset threshold, and the remaining data is deleted/ Does not output, thus obtaining processed input data.
  • the matrix data block and the identification data block associated with the matrix data block are input to the mapping circuit, and the selector may select the matrix data block according to the identification data block.
  • the data whose absolute value is greater than or equal to 0 is output, and the remaining data is not output, thereby outputting the processed matrix data block.
  • the structure shown in FIG. 5b can be applied to the second mapping circuit in the third embodiment described above, that is, the specific result of the second mapping circuit in the third embodiment described above may include at least one selector.
  • the first mapping circuit and the second mapping circuit designed in the main processing circuit and the basic processing circuit may be cross-combined or split according to the functional components shown in FIG. 5a and FIG. 5b, which is not limited in this application.
  • the following provides a method for implementing calculation using a neural network forward operation as shown in FIG. 1a, which may be a neural network calculation method, such as a neural network training, in practical applications,
  • the forward operation can perform matrix multiplication matrix, convolution operation, activation operation, transformation operation, and the like according to different input data, and the above operations can be implemented by using the apparatus shown in FIG. 1a.
  • the first mapping circuit of the main processing circuit first compresses the data and then transmits the data to the basic processing circuit for calculation.
  • the first mapping circuit of the main processing circuit can compress the data and then transmit the data to the basic processing circuit.
  • the advantage is that the amount of data transmitted data can be reduced, the total number of bits transmitted is reduced, and the basic processing circuit performs data operations more efficiently and consumes less power.
  • the main processing circuit transmits the data to be calculated to all or a part of the basic processing circuit; taking the matrix multiplication by the vector calculation as an example, the control circuit of the main processing circuit can split the matrix data into each column as a basic data, for example, m*n
  • the matrix can be split into n m rows of vectors, and the control circuit of the main processing circuit distributes the split n m rows of vectors to a plurality of basic processing circuits.
  • the control circuitry of the main processing circuit can broadcast the vector as a whole to each of the underlying processing circuits.
  • the first behavior example if the first vector of n m rows of vectors is 1000 rows, then the two vectors can be divided into 2 vectors.
  • the first 500 lines are composed of the first vector, and the last 500 lines are composed of the second vector.
  • the control circuit broadcasts 2 vectors to the plurality of basic processing circuits through 2 broadcasts.
  • the manner of data transmission may be broadcast or distribution, or any other possible transmission method
  • the basic processing circuit After receiving the data, the basic processing circuit first processes the data through the second mapping circuit, and then performs an operation to obtain an operation result;
  • the basic processing circuit transmits the operation result back to the main processing circuit
  • the operation result may be an intermediate operation result or a final operation result.
  • the tensor multiplication tensor operation can be accomplished using the apparatus shown in Figure 1a, which is the same as the data block described above, which can be a matrix, a vector, a three-dimensional data block, a four-bit data block, and a high-dimensional data block.
  • Figure 1a A combination of any one or more of the following; a specific implementation of the matrix multiplication vector and the matrix multiplication matrix operation is shown in Figures 2 and 2b, respectively.
  • the operation of the matrix multiplication vector is performed using the apparatus as shown in Fig. 1a; (the matrix multiplication vector can be an inner product of each row in the matrix with the vector, and the results are placed into a vector in the order of the corresponding rows.)
  • the neural network computing device has K basic processing circuits:
  • FIG. 2 provides a method for implementing a matrix multiplication vector, which may specifically include:
  • Step S201 the control circuit of the main processing circuit distributes each row of data in the matrix S to one of the K basic processing circuits, and the basic processing circuit saves the received distribution data in an on-chip buffer of the basic processing circuit and/or In the register;
  • the data of the matrix S is processed data.
  • the main processing circuit enables the first mapping circuit to process the matrix S, thereby obtaining the processed matrix S and a first mask matrix associated with the matrix S.
  • the first mapping circuit of the main processing circuit processes the matrix S according to the first mask matrix associated with the pre-stored matrix S to obtain the processed matrix S.
  • each row data in the processed matrix S and the row data corresponding to the identification data associated in the first mask matrix are sent to one or more of the K basic processing circuits by the control circuit.
  • the main processing circuit sends data to the basic processing circuit, the data in the processed matrix S whose absolute value is greater than the preset threshold or the non-zero data may be sent to the basic processing circuit to reduce the data transmission amount.
  • the set of rows in the matrix S processed in the i-th basic processing circuit is Ai, and the Mi rows are shared; correspondingly, the identification matrix Bi corresponding to Ai is also distributed, and Bi is the first mask matrix. Part of a total of greater than or equal to the Mi line.
  • the control circuit of the main processing circuit separately distributes one row of the S matrix to the K basic processing circuits; optionally, the corresponding row is also sent by the row.
  • the control circuitry of the main processing circuit distributes one or more rows of data in the S matrix to each of the underlying processing circuits.
  • the identifier data corresponding to the row in the first identifier matrix by the one or several rows is also sent;
  • the set of rows in S distributed to the i-th base processing circuit is Ai, sharing a total of Mi rows, as shown in Figure 2c, which is to be performed on the i-th base processing circuit.
  • the received distribution data such as the matrix Ai
  • the received distribution data may be stored in a register and/or an on-chip buffer of the i-th base processing circuit.
  • Step S202 the control circuit of the main processing circuit transmits the parts in the vector P to the K basic processing circuits in a broadcast manner;
  • the data (parts) of the vector P may be processed data.
  • the main processing circuit enables the first mapping circuit to process the vector P, thereby obtaining the processed vector P and a second mask matrix associated with the vector P.
  • the first mapping circuit of the main processing circuit processes the vector P according to the second mask matrix associated with the pre-stored vector P to obtain the processed vector P.
  • the data in the processed vector P (ie, each part) and the corresponding data corresponding to the data in the second mask matrix are sent to one or more of the K basic processing circuits by the control circuit. in.
  • the main processing circuit sends data to the basic processing circuit, the data of the processed vector P having an absolute value greater than a preset threshold or non-zero data may be specifically sent to the basic processing circuit to reduce the data transmission amount.
  • control circuit of the main processing circuit can broadcast each part of the vector P only once to the register or the on-chip buffer of each basic processing circuit, and the i-th basic processing circuit obtains the vector P of this time.
  • the data is fully multiplexed to complete the inner product operation corresponding to each row in the matrix Ai.
  • control circuit of the main processing circuit can broadcast each part of the vector P to the register or the on-chip buffer of each basic processing circuit multiple times, and the i-th basic processing circuit obtains the vector P for each time.
  • the data is not multiplexed, and the inner product operation corresponding to each row in the matrix Ai is completed in stages; the advantage is that the data transmission amount of the vector P of the single transmission inside the basic processing circuit is reduced, and the basic processing circuit buffer and the lower limit can be reduced. / or the capacity of the register to improve execution efficiency, reduce transmission power consumption, and reduce costs.
  • control circuit of the main processing circuit can broadcast each part of the vector P to the register or the on-chip buffer of each basic processing circuit multiple times, and the i-th basic processing circuit obtains the vector P for each time.
  • the data is partially multiplexed to complete the inner product operation corresponding to each row in the matrix Ai; the advantage is that the data transmission amount from the main processing circuit to the basic processing circuit is reduced, and the data transmission amount inside the basic processing circuit is also reduced, and the execution is improved. Efficiency, reducing transmission power consumption.
  • Step S203 the inner product operator circuit of the K basic processing circuits calculates an inner product of the data of the matrix S and the vector P, for example, the i-th basic processing circuit, and calculates an inner product of the data of the matrix Ai and the data of the vector P;
  • the basic processing circuit receives the data in the processed matrix S and the data corresponding to the identification data associated in the first mask matrix; and also receives the data in the processed vector P. .
  • the basic processing circuit enables the second mapping circuit to process the data of the received vector P according to the identification data in the received first mask matrix to obtain the data of the processed vector P.
  • the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the received data in the processed matrix S and the processed vector P data to obtain a result of the inner product operation.
  • the i-th basic processing circuit receives the matrix Ai, the identification matrix Bi associated with the Ai, and the vector P; at this time, the second mapping circuit can be enabled to process the vector P by using the Bi to obtain the processed vector P;
  • the product operator circuit performs an inner product operation on the matrix Ai and the processed vector P.
  • the basic processing circuit receives the data in the processed vector P and the data corresponding to the identification data associated in the second mask matrix; and also receives the data in the processed matrix S. .
  • the basic processing circuit enables the second mapping circuit to process the data of the received matrix S according to the identification data in the received second mask matrix to obtain the data of the processed matrix S.
  • the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the received data of the processed vector P and the processed data in the matrix S to obtain a result of the inner product operation.
  • the i-th basic processing circuit receives the matrix Ai, the processed vector P, and the second identification matrix associated with the vector P; at this time, the second mapping circuit can be enabled to process the Ai by using the second identification matrix.
  • the matrix Ai; the inner product operator circuit is further enabled to perform an inner product operation on the processed matrix Ai and the processed vector P.
  • the basic processing circuit receives the data in the processed matrix S and the data corresponding to the identification data associated in the first mask matrix; and also receives the data in the processed vector P. And the data corresponds to the identification data associated in the second mask matrix.
  • the basic processing circuit enables the second mapping circuit to obtain a relationship identification matrix (also referred to as a relational connection matrix) according to the identification data in the received first mask matrix and the identification data in the second mask matrix; and then use the relationship identification matrix
  • the identification data in the data is processed on the data in the received matrix S and the data in the vector P, respectively, to obtain the data of the processed matrix S and the data of the processed vector P.
  • the inner product operator circuit is enabled to perform an inner product operation on the data in the processed matrix S and the processed vector P data to obtain a result of the inner product operation.
  • the i-th basic processing circuit receives the matrix Ai, the identification matrix Bi associated with the Ai, the vector P, and the second identification matrix associated with the vector P; at this time, the second mapping circuit can be enabled to obtain the second identification matrix by using the Bi and the second identification matrix.
  • the relationship identification matrix is used to process the matrix Ai and the vector P simultaneously or separately to obtain the processed matrix Ai and the processed vector P.
  • the inner product operator circuit is enabled to perform an inner product operation on the processed matrix Ai and the processed vector P.
  • Step S204 The accumulator circuit of the K basic processing circuits accumulates the result of the inner product operation to obtain an accumulated result, and transmits the accumulated result to the main processing circuit in a fixed point type.
  • each part of the basic processing circuit may perform an inner product operation to obtain a part and (partial and part of the accumulated result, for example, the accumulated result is: F1*G1+F2*G2+F3*G3+F4 *G4+F5*G5, then the part and can be: the value of F1*G1+F2*G2+F3*G3) is transferred back to the main processing circuit for accumulation; the advantage is that the calculation amount inside the basic processing circuit is reduced, and the basis is improved. The computational efficiency of the processing circuit.
  • the part obtained by the inner product operation performed by each basic processing circuit and the register and/or the on-chip buffer stored in the basic processing circuit may be transferred to the main processing circuit after the accumulation is completed;
  • the data transmission between the basic processing circuit and the main processing circuit is reduced, the operation efficiency is improved, and the data transmission power consumption is reduced.
  • the main processing circuit performs accumulation, and is transferred back to the main processing circuit after the accumulation is completed; the advantage is that the data transmission amount between the basic processing circuit and the main processing circuit is reduced, the operation efficiency is improved, the data transmission power consumption is reduced, and the basic processing is reduced.
  • the amount of calculation inside the circuit improves the computational efficiency of the basic processing circuit.
  • the neural network computing device has K basic processing circuits:
  • Step S201b the control circuit of the main processing circuit distributes each row of data in the matrix S to one of the K basic processing circuits, and the basic processing circuit saves the received data in an on-chip buffer and/or a register;
  • the data of the matrix S is processed data.
  • the main processing circuit enables the first mapping circuit to process the matrix S, thereby obtaining the processed matrix S and a first mask matrix associated with the matrix S.
  • the first mapping circuit of the main processing circuit processes the matrix S according to the first mask matrix associated with the pre-stored matrix S to obtain the processed matrix S.
  • each row data in the processed matrix S and the row data corresponding to the corresponding associated identification data in the first mask matrix are sent to one or more of the K basic processing circuits by the control circuit.
  • the main processing circuit sends data to the basic processing circuit, the data in the processed matrix S whose absolute value is greater than the preset threshold or the non-zero data may be sent to the basic processing circuit to reduce the data transmission amount.
  • the control circuit of the main processing circuit respectively distributes one row of the S matrix to the M basic processing circuits; optionally, the corresponding row is also sent by the row.
  • the control circuitry of the main processing circuit distributes one or more rows of data in the S matrix to each of the underlying processing circuits.
  • the identifier data corresponding to the row in the first identifier matrix by the one or several rows is also sent;
  • the Mi line in S is distributed to the i-th base processing circuit, and the set of Mi lines is called Ai, and the calculation to be performed on the i-th basic processing circuit is shown in Fig. 2e.
  • each of the basic processing circuits such as the i-th basic processing circuit:
  • the received matrix Ai distributed by the main processing circuit stores the matrix Ai in the i-th basic processing circuit register and/or the on-chip buffer; the advantage is that the amount of data transmission afterwards is reduced, the calculation efficiency is improved, and the power consumption is reduced.
  • Step S202b the control circuit of the main processing circuit transmits each part of the matrix P to each basic processing circuit in a broadcast manner;
  • the data (parts) of the matrix P can be processed data.
  • the main processing circuit enables the first mapping circuit to process the matrix P, thereby obtaining the processed matrix P and a second matrix of the matrix associated with the matrix P.
  • the first mapping circuit of the main processing circuit processes the matrix P according to the second mask matrix associated with the pre-stored matrix P to obtain the processed matrix P.
  • the data in the processed matrix P (ie, each part) and the corresponding data corresponding to the data in the second mask matrix are sent to one or more of the K basic processing circuits by the control circuit. in.
  • the main processing circuit sends data to the basic processing circuit, specifically, the data in the processed matrix P whose absolute value is greater than a preset threshold or non-zero data may be sent to the basic processing circuit to reduce the data transmission amount.
  • each part of the matrix P can be broadcast only once to the registers of the respective basic processing circuits or the on-chip buffer, and the i-th basic processing circuit fully multiplexes the data of the matrix P obtained this time.
  • the inner product operation corresponding to each row in the matrix Ai is completed; the multiplexing in this embodiment may be repeatedly used in the calculation by the basic processing circuit, for example, the multiplexing of the data of the matrix P, and may be the data of the matrix P. use many times.
  • control circuit of the main processing circuit can broadcast the parts of the matrix P to the registers of the respective basic processing circuits or the on-chip buffer multiple times, and the i-th basic processing circuit pairs the matrix P obtained each time.
  • the data is not multiplexed, and the inner product operations corresponding to each row in the matrix Ai are completed in stages;
  • control circuit of the main processing circuit can broadcast the parts of the matrix P to the registers of the respective basic processing circuits or the on-chip buffer multiple times, and the i-th basic processing circuit pairs the matrix P obtained each time.
  • the data is partially multiplexed to complete an inner product operation corresponding to each row in the matrix Ai;
  • each of the basic processing circuits calculates an inner product of the data of the matrix Ai and the data of the matrix P;
  • Step S203b the accumulator circuit of each basic processing circuit accumulates the result of the inner product operation and transmits it back to the main processing circuit.
  • step S203b the inner product operator of the basic processing circuit needs to calculate the inner product of the data of the matrix S and the matrix P.
  • the inner product operator of the basic processing circuit needs to calculate the inner product of the data of the matrix S and the matrix P.
  • the basic processing circuit receives the data in the processed matrix S and the data corresponding to the identification data associated in the first mask matrix; and also receives the data in the processed matrix P. .
  • the basic processing circuit enables the second mapping circuit to process the data of the received matrix P according to the identification data in the received first mask matrix to obtain the data of the processed matrix P.
  • the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the received data in the processed matrix S and the processed matrix P data to obtain a result of the inner product operation.
  • the basic processing circuit receives the data in the processed matrix P and the data corresponding to the identification data associated in the second mask matrix; and also receives the data in the processed matrix S. .
  • the basic processing circuit enables the second mapping circuit to process the data of the received matrix S according to the identification data in the received second mask matrix to obtain the data of the processed matrix S.
  • the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the received data of the processed matrix P and the processed data in the matrix S to obtain a result of the inner product operation.
  • the basic processing circuit receives the data in the processed matrix S and the data corresponding to the identification data associated in the first mask matrix; and also receives the data in the processed matrix P. And the data corresponds to the identification data associated in the second mask matrix.
  • the basic processing circuit enables the second mapping circuit to obtain a relationship identification matrix (also referred to as a relational connection matrix) according to the identification data in the received first mask matrix and the identification data in the second mask matrix; and then use the relationship identification matrix
  • the identification data respectively processes the data in the received matrix S and the data in the matrix P to obtain the processed matrix S data and the processed matrix P data.
  • the inner product operator circuit is enabled to perform an inner product operation on the data in the processed matrix S and the processed matrix P data to obtain a result of the inner product operation.
  • the i-th basic processing circuit receives the matrix Ai, the identification matrix Bi associated with the Ai, the matrix P, and the second identification matrix associated with the matrix P; at this time, the second mapping circuit can be enabled to obtain the second identification matrix by using the Bi and the second identification matrix.
  • the relationship identification matrix is used to process the matrix Ai and the matrix P simultaneously or separately to obtain the processed matrix Ai and the processed matrix P.
  • the inner product operator circuit is enabled to perform an inner product operation on the processed matrix Ai and the processed matrix P.
  • the basic processing circuit may accumulate the portion obtained by performing the inner product operation each time and transmit back to the main processing circuit;
  • the portion obtained by the inner product operation performed by each basic processing circuit may be stored in a register and/or an on-chip buffer of the basic processing circuit, and then accumulated and returned to the main processing circuit;
  • the weight matrix of the fully connected layer is used as the matrix S, and the input vector is used as the vector P, according to the usage method of the device. Perform the operation of the matrix multiplication vector as shown in FIG. 2;
  • the weight matrix of the fully connected layer is used as the matrix S, the input vector is used as the matrix P, or the fully connected layer is used.
  • Step S301 The control circuit of the main processing circuit distributes the weight of each convolution kernel in the convolution layer weight to one of the K basic processing circuits, and stores the on-chip buffer and/or the register in the basic processing circuit. in;
  • the weight of the convolution kernel is processed weight data.
  • the main processing circuit enables the first mapping circuit to process the weight of the convolution kernel, thereby obtaining the processed convolution kernel and a first mask matrix associated with the convolution kernel.
  • the first mapping circuit of the main processing circuit processes the convolution kernel according to the first mask matrix associated with the pre-stored convolution kernel, and obtains the processed convolution kernel (ie, the weight of the processed convolution kernel).
  • the control circuit outputs the weight in the processed convolution kernel and the weight corresponding to the corresponding associated identification data in the first mask matrix to one or more of the K basic processing circuits.
  • the data in the processed convolution kernel whose absolute value is greater than a preset threshold or non-zero data may be specifically sent to the basic processing circuit to reduce the data transmission amount.
  • the set of Mi processed convolution kernels distributed to the i-th basic processing circuit is Ai; correspondingly, the identification matrix Bi corresponding to Ai is also distributed.
  • the control circuit of the main processing circuit separately distributes the weights of one convolution kernel to the M basic processing circuits; optionally, also sends
  • the convolution kernel corresponds to an associated identification matrix (ie, identification data in the identification matrix).
  • the control circuit of the main processing circuit separately distributes the weights of one or more convolution kernels to each of the basic processing circuits; optionally, Sending the one or more convolution kernels respectively corresponding to the associated identification matrix (ie, the identification data in the identification matrix).
  • a total of Mi convolution kernels are distributed to the i-th base processing circuit, and the set of these convolution kernel weights is called Ai.
  • each of the basic processing circuits such as the i-th basic processing circuit:
  • the received convolution kernel weight Ai distributed by the main processing circuit is stored in its register and/or on-chip buffer;
  • Step S302 the control circuit of the main processing circuit transmits each part of the input data P to each basic processing circuit in a broadcast manner;
  • the input data P is processed data.
  • the main processing circuit enables the first mapping circuit to process the input data P, thereby obtaining the processed input data P and a second mask matrix (ie, identification data) associated with the input data P.
  • the first mapping circuit of the main processing circuit processes the input data P according to the second mask matrix associated with the pre-stored input data P to obtain the processed input data P.
  • the data in the processed input data P (ie, each part) and the corresponding data corresponding to the data in the second mask matrix are sent to one or more of the K basic processing circuits by the control circuit. In the middle.
  • the main processing circuit sends data to the basic processing circuit, the data of the processed input data P whose absolute value is greater than a preset threshold or non-zero data may be specifically sent to the basic processing circuit to reduce the data transmission amount.
  • control circuit of the main processing circuit can broadcast each part of the input data P only once to the register or on-chip buffer of each basic processing circuit, and the i-th basic processing circuit inputs the input data for this time.
  • the data of P is fully multiplexed, and the inner product operation corresponding to each convolution kernel in Ai is completed;
  • control circuit of the main processing circuit can broadcast each part of the input data P to the register or the on-chip buffer of each basic processing circuit multiple times, and the input data obtained by the i-th basic processing circuit for each time.
  • the data of P is not multiplexed, and the inner product operation corresponding to each convolution kernel in Ai is completed in stages;
  • control circuit of the main processing circuit can broadcast each part of the input data P to the register or the on-chip buffer of each basic processing circuit multiple times, and the input data obtained by the i-th basic processing circuit for each time.
  • the data of P is partially multiplexed to complete an inner product operation corresponding to each convolution kernel in Ai;
  • each basic processing circuit calculates a data inner product of the convolution kernel and the input data P, for example, an i-th basic processing circuit, and calculates an inner product of each convolution kernel of the Ai and the data of the input data P;
  • the base processing circuit receives the data in the processed convolution kernel and the data corresponds to the identification data associated in the first mask matrix; and also receives the processed input data P.
  • the basic processing circuit enables the second mapping circuit to process the received input data P according to the identification data in the received first mask matrix to obtain the processed input data P.
  • the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the data in the received processed convolution kernel and the processed input data P to obtain a result of the inner product operation.
  • the i-th basic processing circuit receives the convolution kernel weight Ai, the identification matrix Bi associated with the Ai, and the input data P; at this time, the second mapping circuit can be enabled to process the input data P by using Bi.
  • the data P is input; the inner product operator circuit is further enabled to perform an inner product operation on the convolution kernel weight Ai and the processed input data P.
  • the basic processing circuit receives the data in the processed input data P and the data corresponding to the identification data associated in the second mask matrix; and also receives the processed convolution kernel The data.
  • the basic processing circuit enables the second mapping circuit to process the data of the received convolution kernel according to the identification data in the received second mask matrix to obtain the data of the processed convolution kernel.
  • the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the received processed input data P and the processed convolution kernel to obtain a result of the inner product operation.
  • the i-th basic processing circuit receives the convolution kernel weight Ai, the processed input data P, and the second identification matrix associated with the input data P; at this time, the second mapping circuit can be enabled to utilize the second identification matrix pair Ai performs processing to obtain the processed convolution kernel weight Ai; and then enables the inner product operator circuit to perform inner product operation on the processed convolution kernel weight Ai and the processed input data P.
  • the basic processing circuit receives the data in the processed convolution kernel and the data corresponding to the identification data associated in the first mask matrix; and also receives the processed input data P.
  • the data and the data correspond to the identification data associated in the second mask matrix.
  • the basic processing circuit enables the second mapping circuit to obtain a relationship identification matrix (also referred to as a relational connection matrix) according to the identification data in the received first mask matrix and the identification data in the second mask matrix; and then use the relationship identification matrix
  • the identification data in the process respectively processes the data in the received convolution kernel and the data in the input data P to obtain the processed convolution kernel data and the processed input data P.
  • the inner product calculator circuit is enabled to perform an inner product operation on the data in the processed convolution kernel and the processed input data P to obtain a result of the inner product operation.
  • the i-th basic processing circuit receives the convolution kernel weight Ai, the Ai-associated identification matrix Bi, the input data P, and the second identification matrix associated with the input data P; at this time, the second mapping circuit can be enabled to utilize Bi. And obtaining a relationship identifier matrix with the second identifier matrix, and then processing the convolution kernel weight Ai and the input data P by using the relationship identifier matrix, respectively, to obtain the processed convolution kernel weight Ai and the processed input data P .
  • the inner product operator circuit is enabled to perform an inner product operation on the processed convolution kernel weight Ai and the processed input data P.
  • Step S304 the accumulator circuit of each basic processing circuit accumulates the result of the inner product operation and transmits it back to the main processing circuit:
  • the basic processing circuit may accumulate the portion obtained by performing the inner product operation each time and transmit back to the main processing circuit;
  • the basic processing circuit may also save the portion obtained by the inner product operation performed each time and the register and/or the on-chip buffer stored in the basic processing circuit, and then transfer back to the main processing circuit after the accumulation is completed;
  • the basic processing circuit may also accumulate the portion obtained by each inner product operation and, in some cases, the register and/or the on-chip buffer of the basic processing circuit, and in some cases transmit to The main processing circuit performs accumulation, and is transferred back to the main processing circuit after the accumulation is completed;
  • the vector updater circuit of the main processing circuit is used to implement the weight update function in the neural network training process.
  • the weight update refers to a method of updating the weight using the gradient of the weight.
  • the vector operator circuit of the main processing circuit is used to add and subtract the two vectors of the weight and the weight gradient to obtain an operation result, and the operation result is an update weight.
  • the vector operator circuit of the main processing circuit multiplies or divides the weight and the weight gradient by a number to obtain an intermediate weight and an intermediate weight gradient value, and the vector operator circuit pairs the intermediate weight And the intermediate weight gradient value is added and subtracted to obtain the operation result, and the operation result is the update weight.
  • a set of momentum can be calculated by using the gradient of the weights, and then the updated weights are obtained by adding and subtracting the momentum and the weights.
  • GEMM calculation refers to the operation of matrix-matrix multiplication in the BLAS library.
  • auxiliary integers as parameters to describe the width and height of the S and P of the matrix;
  • the data type conversion operation circuit of the main processing circuit can perform data type conversion on the matrix S and the matrix P;
  • the conversion circuit of the main processing circuit performs respective op operations on the input matrix S and the matrix P;
  • op can be a transposition operation of the matrix; the matrix transposition operation can be implemented by using a matrix transposition circuit of the main processing circuit;
  • the data conversion operation circuit of the main processing circuit may also perform a data type conversion operation, that is, the data conversion operation circuit will op(S) and op
  • the data type of (P) is converted from floating point type data to fixed point type data, and then matrix multiplication operation as shown in Fig. 2b is performed.
  • the op of a certain matrix may be empty, and the op operation is not performed
  • the vector operator circuit of the main processing circuit is used to implement the steps of adding the corresponding positions between the matrix alpha*op(s)*op(P) and beta*C to obtain the result of the GEMM calculation.
  • this step is not performed
  • GEMV calculation refers to the operation of matrix-vector multiplication in the BLAS library.
  • the data type conversion operation circuit of the main processing circuit can perform data type conversion on the input matrix S and the matrix P;
  • the conversion circuit of the main processing circuit performs a corresponding op operation on the input matrix S;
  • op can be a transposition operation of the matrix; the matrix transposition operation is implemented by using a conversion circuit of the main processing circuit;
  • the op of a certain matrix may be empty, and the transposition operation is not performed
  • the result of GEMV is obtained by the step of adding the corresponding positions between the matrix alpha*op(S)*P and beta*C by using the vector operator circuit of the main processing circuit.
  • the step of adding is not performed
  • An activation circuit of the main processing circuit inputs a vector to calculate an activation vector of the vector
  • the main processing circuit activation circuit passes each value in the input vector through an activation function (the input of the activation function is a value and the output is also a value), and a correspondence of the output of the value to the output vector is calculated. position;
  • the activation function can be a piecewise linear function
  • the activation function can be any function that inputs a number and outputs a number.
  • the source of the input vector is (including but not limited to):
  • the input data is from the device for performing a matrix multiplication vector
  • the input data is from the device for performing a matrix multiplication matrix
  • the main processing circuit of the device calculates a result
  • the input data is derived from the calculations after the device main processing circuit implements the offset.
  • the above activation operation may be implemented by an arithmetic logic circuit and an accumulator circuit in the main processing circuit, or an activation circuit may be separately added to the main processing circuit to implement an activation operation.
  • the vector operator circuit of the main processing circuit can realize the function of adding two vectors or two matrices
  • the vector operator circuit of the main processing circuit can be used to add a vector to each row of a matrix, or to the function on each column.
  • the matrix may be derived from the result of the matrix multiplication matrix operation performed by the apparatus;
  • the matrix may be derived from the result of the device performing a matrix multiplication vector operation
  • the matrix may be derived from externally accepted data from the main processing circuitry of the device.
  • the vector may be from externally accepted data from the main processing circuitry of the device.
  • the main processing circuit is configured to receive a forward operation instruction, and parse the forward operation instruction to obtain an ith layer of the forward operation instruction in a forward operation of the neural network
  • the input data block is an output data block of the i-1th layer;
  • the main processing circuit is configured to divide the input data block into a broadcast data block according to the first operation instruction, and divide the convolution kernel data block into a data block; according to the first forward instruction
  • the operation control determines to start the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast data block;
  • the product instruction sends the processed first data block to at least one of the basic processing circuits connected to the main processing circuit;
  • the plurality of basic processing circuits are configured to determine, according to the operation control of the first operation instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block.
  • the operation obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit;
  • the second data block is the receiving the main processing determined by the basic processing circuit a data block sent by the circuit, the second data block being associated with the processed first data block;
  • the main processing circuit is configured to process the operation result to obtain an instruction result of the first operation instruction, and complete an operation of the first operation instruction included in the ith layer.
  • the main processing circuit is specifically configured to start the first mapping circuit, the distribution data block, and the Processing the broadcast data block to obtain the processed distribution data block and the identification data block associated with the distribution data block, the processed broadcast data block, and the identification data block associated with the broadcast data block; and the processed distribution data block And the identification data block associated with the distribution data block is subjected to split processing to obtain a plurality of basic data blocks and identification data blocks respectively associated with the basic data blocks, and the plurality of basic data blocks and the plurality of basic data blocks are respectively And the associated identification data block is distributed to the basic processing circuit connected thereto, and the processed broadcast data block and the identification data block associated with the broadcast data block are broadcasted to the basic processing circuit connected thereto;
  • the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the broadcast data block and the identification data associated with the basic data block, and according to the The connection identification data block processes the broadcast data block and the basic data block to obtain a processed broadcast data block and a basic data block; performing a forward operation on the processed broadcast data block and the basic data block to obtain an operation result And transmitting the operation result to the main processing circuit; wherein the forward operation includes but is not limited to a combination of any one or more of the following: a convolution operation (ie, an inner product operation), a product operation, One or any combination of paranoid operation, full connection operation, GEMM operation, GEMV operation, activation operation;
  • a convolution operation ie, an inner product operation
  • a product operation One or any combination of paranoid operation
  • full connection operation GEMM operation
  • GEMV operation activation operation
  • the main processing circuit is configured to process the operation result to obtain the instruction result.
  • the main processing circuit is specifically configured to start processing, by the first mapping circuit, the processing data block to be processed. Distributing the data block and the identification data block associated with the distribution data block, or initiating the first mapping circuit to process the distribution data block according to the pre-stored identification data block associated with the distribution data block to obtain the processed distribution data block And performing the split processing on the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and identification data blocks respectively associated with the basic data blocks, and the plurality of basic data And the identification data block associated with each of the plurality of basic data blocks is distributed to a basic processing circuit connected thereto, and the broadcast data block is broadcasted to a basic processing circuit connected thereto;
  • the basic processing circuit is specifically configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, to obtain a processed broadcast data block;
  • the broadcast data block and the processed basic data block perform a forward operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.
  • the main processing circuit is further configured to split the broadcast data block or the processed broadcast data block and the identification data block associated with the broadcast data block to obtain a plurality of partial broadcast data. a block and an identification data block associated with each of the plurality of partial broadcast data blocks; broadcasting the plurality of partial broadcast data blocks and the identification data blocks associated with each of the plurality of partial broadcast data blocks by the one or more broadcasts to the a base processing circuit; wherein the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.
  • the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the partial broadcast data block and the identification data block associated with the basic data block;
  • the connection identification data is processed to process the partial broadcast data block and the basic data block to obtain a processed partial broadcast data block and the processed basic data block; and the processed partial broadcast data block and the processed The basic data block performs a forward operation.
  • the main processing circuit is specifically configured to start the first mapping circuit to process the broadcast data block, and obtain the processed Broadcast data block and the identification data block associated with the broadcast data block, or the first mapping circuit is configured to process the broadcast data block according to the pre-stored identification data block associated with the broadcast data block to obtain the processed broadcast data. Blocking the distributed data block to obtain a plurality of basic data blocks; distributing the plurality of basic data blocks to a basic processing circuit connected thereto, and the processed broadcast data block and the broadcast data block The associated identification data block is broadcast to the basic processing circuit connected thereto;
  • the basic processing circuit is configured to start, by the second mapping circuit, the basic data block to be processed according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and the processed broadcast
  • the data block and the processed basic data block perform a forward operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.
  • the main processing circuit is further configured to split the processed broadcast data block and the identification data block associated with the broadcast data block to obtain a plurality of partial broadcast data blocks and the And an identifier data block associated with the plurality of partial broadcast data blocks; and the identification data blocks associated with the plurality of partial broadcast data blocks and the plurality of partial broadcast data blocks are broadcast to the basic processing circuit by one or more times; And the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.
  • the basic processing circuit is configured to process the basic data block according to the identifier data block associated with the partial broadcast data block to obtain a processed basic data block; and the processed basic data block and the The partial broadcast data block performs a forward operation.
  • the integrated circuit chip device is configured to perform a neural network forward operation
  • the neural network includes n layers
  • the main processing circuit includes a first mapping circuit
  • the plurality of At least one of the basic processing circuits includes a second mapping circuit
  • the first mapping circuit and the second mapping circuit are both configured to perform compression processing of respective data in the neural network operation
  • the main processing circuit is configured to receive a forward operation instruction, and parse the forward operation instruction to obtain a first operation instruction included in an ith layer of the forward operation instruction in the forward operation of the neural network An input data block and a weight data block required by the first operation instruction, wherein the range of i is an integer greater than or equal to 1, and less than or equal to n, and if the i is greater than or equal to 2, the input data block is Output data block of layer i-1;
  • the main processing circuit is configured to divide the input data block into a broadcast data block according to the first operation instruction, and divide the convolution kernel data block into a data block; according to the first forward instruction
  • the operation control determines to start the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast data block;
  • the product instruction sends the processed first data block to at least one of the basic processing circuits connected to the main processing circuit;
  • the plurality of basic processing circuits are configured to determine, according to the operation control of the first operation instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block.
  • the operation obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit;
  • the second data block is the receiving the main processing determined by the basic processing circuit a data block sent by the circuit, the second data block being associated with the processed first data block;
  • the main processing circuit is configured to process the operation result to obtain an instruction result of the first operation instruction, and complete an operation of the first operation instruction included in the ith layer.
  • the integrated circuit chip device may include a branch processing circuit connected between the main processing circuit and the basic processing circuit for converting data between the main processing circuit and the basic processing circuit.
  • Setting the branch processing circuit can increase the number of basic processing circuits connected to the main processing circuit, and also reduce the overhead of data transmission of the main processing circuit.
  • each layer uses its own input data and weights to calculate corresponding output data according to an operation rule specified by a layer type;
  • the forward operation process (also called inference) of the neural network is a process of processing the input data of each layer layer by layer, and obtaining the output data after a certain calculation, which has the following characteristics:
  • the input to a layer can be the input data of the neural network
  • the input of one layer can be the output of other layers;
  • the input of a layer can be the output of the layer at a moment (corresponding to the case of a cyclic neural network);
  • a layer can simultaneously acquire input from a plurality of the above input sources
  • the output of a layer can be used as the output of the neural network
  • the output of one layer can be the input of other layers
  • the output of a layer can be the input of this layer at the next moment (in the case of a cyclic neural network);
  • the output of a layer may output a result to the plurality of output directions described above;
  • the types of operations of the layers in the neural network include, but are not limited to, the following:
  • Normalized (regularized) layer includes LRN (Local Response Normalization) layer, BN (Batch Normalization) layer, and the like;
  • Activation layer including but not limited to the following types of Sigmoid layer, ReLU layer, PReLu layer, LeakyReLu layer, Tanh layer;
  • the inverse operation of the layer the inverse operation of each layer needs to perform a two-part operation: one part is to calculate the weight gradient using the output data gradient which may be sparse representation and the input data which may be sparse representation (for the weight
  • the value update step updates the weight of this layer, and the other part uses the output data gradient, which may be sparse representation, and the weight of the sparse representation, to calculate the input data gradient (used as the next layer in the inverse operation).
  • Output a data gradient for its inverse operation
  • the inverse operation reverses the gradient from the last layer in the reverse order of the forward operation.
  • the inverse of the output data gradient calculated by a layer can be derived from:
  • Input data gradient at a moment on this layer (corresponding to the case of a cyclic neural network);
  • a layer can simultaneously obtain an output data gradient from a plurality of the above sources
  • the gradient of the weights of the layers is calculated.
  • the first input buffer and the second input buffer of the device are respectively used to store the weights of the layer.
  • the gradient of the weights and then use the weight gradient to update the weights in the arithmetic unit;
  • the operations mentioned above are all operations of a layer in a neural network.
  • the implementation process is that, in the forward operation, when the previous artificial neural network is executed, the next layer of operations is performed.
  • the instruction will operate the output data calculated in the operation unit as the input data of the next layer (or perform some operations on the output data as the input data of the next layer), and at the same time, replace the weight with the next one.
  • the weight of one layer; in the reverse operation when the reverse operation of the upper artificial neural network is completed, the next layer of operation instructions will use the input data gradient calculated in the operation unit as the output data of the next layer.
  • the data involved in the present application (that is, the data in the data block) is the compressed data, and can be implemented in the first mapping circuit and the second mapping circuit.
  • the first mapping circuit and the second mapping circuit For details, refer to the related description in the foregoing embodiment.
  • the input data block ie, the data in the input data block
  • the weight data block
  • the convolution operation is described below.
  • One block in the following figure represents a data
  • the input data is represented by Figure 7a (N samples, each sample has C channels, and the feature map of each channel has a height H and a width W).
  • the weight, that is, the convolution kernel is represented by Figure 7b (there are M convolution kernels, each convolution kernel has C channels, and the height and width are KH and KW, respectively).
  • the rules for convolution operations are the same for N samples of input data.
  • each of the M convolution kernels must perform the same. Operation, each convolution kernel operation obtains a plane feature map, and M convolution kernels finally calculate M plane feature maps (for one sample, the convolution output is M feature maps), for a convolution kernel
  • M convolution kernels To perform an inner product operation at each plane position of a sample, and then slide in the H and W directions.
  • Figure 7c shows a convolution kernel performing inner product operations at the position of the lower right corner of a sample of the input data.
  • Fig. 7d shows that the position of the convolution slides one space to the left
  • Fig. 7e shows that the position of the convolution slides up one space.
  • the method of the convolution processing may be performed by using a chip structure as shown in FIG. 1a, and the first mapping circuit of the main processing circuit may process data in part or all of the convolution kernel of the weight to obtain a corresponding mask.
  • Data and processed weight data that is, data in some or all of the convolution kernels of the processed weights).
  • the control circuit of the main processing circuit sends the data in part or all of the convolution kernel of the weight (the data can be the original weight data or the processed weight data) to be directly connected to the main processing circuit through the horizontal data input interface.
  • the basic processing circuit also referred to as a base unit; at the same time, the control circuit sends the mask data associated with the data to the basic processing circuit connected to the main processing circuit;
  • control circuit of the main processing circuit sends a certain number or part of the data of a convolution kernel to a basic processing circuit each time (for example, for a basic processing circuit, The first time, the first number of the third line is transmitted, the second number of the third line of data is transmitted for the second time, the third number of the third line is transmitted for the third time, ..., or the third line is transmitted for the first time.
  • the control circuit takes a weight in one of the volumes
  • the mask data corresponding to the product core also uses the above-mentioned one or a part of data to be sent to the basic processing circuit each time;
  • control circuit of the main processing circuit sends the data of some convolution kernels of the weights to each of the basic processing circuits each time (for example, For a certain basic processing circuit, the first number of lines in the 3rd, 4th, and 5th lines is transmitted for the first time, and the second number of the 3rd, 4th, and 5th lines is transmitted for the second time, and the third time is transmitted.
  • control circuit will be associated with some of the convolution kernels in the weight
  • the mask data also sends a number or a portion of data to the basic processing circuit each time in the same manner as described above;
  • the control circuit of the main processing circuit divides the input data according to the position of the convolution, and the control circuit of the main processing circuit sends the data in part or all of the convolution position in the input data to the main processing circuit through the vertical data input interface.
  • the control circuit also divides the mask data associated with the input data according to the position of the convolution, and accordingly the control circuit also also partially or completely the input data
  • the mask data corresponding to the data in the convolution position is also sent together to the basic processing circuit electrically connected to the main processing circuit;
  • control circuit of the main processing circuit sends a certain number or part of the data of a certain convolution position in the input data and the mask data associated with the data to a certain basic processing circuit; For example, for a certain basic processing circuit, the first number of the third column is transmitted for the first time, the second number of the third column of data is transmitted for the second time, and the third number of the third column is transmitted for the third time... , or send the first two numbers in the third column for the first time, the third and fourth numbers in the third column for the second time, and the fifth and sixth numbers in the third column for the third time...;
  • control circuit of the main processing circuit sends data of a certain convolution position in the input data and mask data associated with the data each time by a number or a part of the data.
  • a basic processing circuit for example, for a basic processing circuit, the first number of the third, fourth, and fifth columns is sent for the first time, and the second, third, fourth, and fifth columns are for the second 2 digits, the 3rd number of the 3rd, 4th, and 5th columns, the 3rd number of each column..., or the 1st transmission of the 3rd, 4th, and 5th columns, the first two digits, the second transmission of the third digit , 4, 5 columns, 3rd and 4th, and 3rd, 3rd, 4th, 5th, 5th and 6th, each column...;
  • the basic processing circuit receives the data of the weight (specifically, the data of the convolution kernel in the weight (referred to as weight data) or the mask data associated with the weight data), and then outputs the data through the horizontal data thereof.
  • the interface transmits to the next basic processing circuit connected thereto; after receiving the data of the input data (the data can be input data sent by the main processing circuit and the identification mask data associated with the input data), the basic processing circuit passes the data through the interface
  • the vertical data output interface is transmitted to the next basic processing circuit connected thereto;
  • control circuit of the main processing circuit may send the input data and the mask data associated with the input data to the basic processing circuit, and the basic processing circuit receives the input data and the mask data associated with the input data;
  • Each of the basic processing circuits operates on the received data; specifically, the basic processing circuit can enable the second mapping circuit to associate the mask data associated with the input data with the mask data associated with the weight data (ie, the convolution kernel associated with the weights)
  • the mask data is obtained by the connection identification data; and the connection identification data is used to select the input data and the data in which the absolute value of the weight data is greater than a preset threshold is multiplied;
  • each basic processing circuit specifically, the data block to be calculated, such as the data in the convolution kernel in the weight and the mask data, the input data, or the data associated with the data
  • the basic processing circuit will no longer receive new input data, such as data in some convolution kernels of the weights subsequently sent by the main processing circuit and The data corresponds to the associated mask data and the like until the base processing circuit has sufficient buffer/storage space, and then receives the newly transmitted data of the main processing circuit.
  • the base processing circuit calculates a multiplication of one or more sets of two data at a time, and then accumulates the result on a register and/or an on-chip buffer;
  • the base processing circuit calculates the inner product of one or more sets of two vectors at a time, and then accumulates the result on the register and/or the on-chip buffer;
  • the result can be transmitted from the data output interface
  • the result of the calculation may be the final result or an intermediate result of the inner product operation
  • the basic processing circuit has an output interface directly connected to the main processing circuit, the result is transmitted from the interface, and if not, the result is output in the direction of the basic processing circuit that can be directly output to the main processing circuit.
  • the basic processing circuit After receiving the calculation result from other basic processing circuits, the basic processing circuit transmits the data to other basic processing circuits or main processing circuits connected thereto;
  • the main processing circuit receives the result of the inner product operation of each basic processing circuit, and the output result is obtained.
  • the tensor multiplying tensor operation can be accomplished using the apparatus shown in Figure 1a, which is the same as the data block described above, which can be a matrix, a vector, a three-dimensional data block, a four-bit data block, and a high-dimensional data block. Combination of any one or more of the above; see Figure 2a and Figure 2b above for a specific implementation of matrix multiplication vector and matrix multiplication matrix operation, respectively.
  • the forward operation indicated by the first operation instruction is a matrix multiplication matrix operation
  • the input data is the first matrix of the matrix multiplication matrix operation
  • the weight is the second of the matrix multiplication matrix operation
  • the matrix refer to the flowchart of the operation method of the matrix multiplication matrix in the foregoing example of FIG. 2b.
  • the forward operation indicated by the first operation instruction is a matrix multiplication vector operation
  • the input data is a first matrix of the matrix multiplication vector operation
  • the weight is a vector of the matrix multiplication vector operation, specifically See the flow chart of the operation method of the matrix multiplication matrix in the foregoing example of Fig. 2a.
  • the present disclosure also provides an integrated circuit chip device for performing a forward operation of a neural network, the neural network comprising a plurality of layers, the device comprising: a processing circuit and an external interface;
  • the external interface is configured to receive a forward operation instruction
  • the processing circuit is configured to parse the forward operation instruction to obtain a first operation instruction included in the i-th layer of the forward operation instruction and the input required by the first operation instruction in the forward operation of the neural network a data block and a weight data block, wherein the value range of i is an integer greater than or equal to 1, and less than or equal to n, as the i is greater than or equal to 2, and the input data block is an output data block of the i-1th layer. ;
  • the processing circuit is further configured to perform the operation of the first operation instruction included in the ith layer of the forward operation by the input data and the weight data.
  • the present disclosure also discloses a neural network computing device including one or more chips as shown in FIG. 9e for acquiring data to be processed and control information from other processing devices, performing specified neural network operations, and executing results. Passed to the peripheral device through the I/O interface. Peripherals such as cameras, monitors, mice, keyboards, network cards, wifi interfaces, servers. When more than one chip as shown in FIG. 9e is included, the chips shown in FIG. 9e can be linked and transmitted through a specific structure, for example, by interconnecting and transmitting data through the PCIE bus to support larger-scale nerves. Network computing. At this point, you can share the same control system, or you can have separate control systems; you can share memory, or each accelerator has its own memory. In addition, the interconnection method can be any interconnection topology.
  • the neural network computing device has high compatibility and can be connected to various types of servers through a PCIE interface.
  • the integrated circuit chip device is configured to receive a training instruction, determine first layer input data and first layer weight group data according to the training instruction, input data to the first layer, and first The layer weight group data performs the n-th layer forward operation of the neural network to obtain the nth output result of the forward operation;
  • the main processing circuit is further configured to obtain an nth output result gradient according to the nth output result, and obtain an nth reverse operation nth inverse operation instruction and the nth inverse operation according to the training instruction
  • the plurality of basic processing circuits are configured to determine, according to the operation control of the nth reverse operation instruction, whether to start the second mapping circuit to process the second data block, and execute the nerve in parallel according to the processed second data block
  • An operation in the network obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit;
  • the second data block is determined by the basic processing circuit to receive the a data block sent by the main processing circuit, the second data block being associated with the processed first data block;
  • the main processing circuit is further configured to process the operation result to obtain an nth layer weight group gradient and an nth layer input data gradient, and apply the nth layer weight group gradient to the nth layer weight group data.
  • the integrated circuit chip device is further configured to perform an n-1 layer inverse operation on the nth layer input data gradient as an n-1th output gradient of the n-1th layer to obtain an n-1 layer weight group gradient, and apply The n-1 layer weight group gradient updates the weight group data of the corresponding layer, and the weight group data includes at least two weights.
  • the main processing circuit is specifically configured to start the first mapping circuit, the distribution data block, and the Processing the broadcast data block to obtain the processed distribution data block and the identification data block associated with the distribution data block, the processed broadcast data block, and the identification data block associated with the broadcast data block; and the processed distribution data block And the identification data block associated with the distribution data block is subjected to split processing to obtain a plurality of basic data blocks and identification data blocks respectively associated with the basic data blocks, and the plurality of basic data blocks and the plurality of basic data blocks are respectively And the associated identification data block is distributed to the basic processing circuit connected thereto, and the processed broadcast data block and the identification data block associated with the broadcast data block are broadcasted to the basic processing circuit connected thereto;
  • the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the broadcast data block and the identification data associated with the basic data block, and according to the The connection identification data block processes the broadcast data block and the basic data block to obtain a processed broadcast data block and a basic data block; performing inverse operation on the processed broadcast data block and the basic data block to obtain an operation result Transmitting the operation result to the main processing circuit; wherein.
  • the reverse operation includes, but is not limited to, a combination of any one or more of the following: a convolution operation (ie, an inner product operation), a product operation, a paranoid operation, a full connection operation, a GEMM operation, a GEMV operation, and an activation operation.
  • the main processing circuit is configured to process the operation result to obtain the instruction result.
  • the main processing circuit is specifically configured to start processing, by the first mapping circuit, the processing data block to be processed. Distributing the data block and the identification data block associated with the distribution data block, or initiating the first mapping circuit to process the distribution data block according to the pre-stored identification data block associated with the distribution data block to obtain the processed distribution data block And performing the split processing on the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and identification data blocks respectively associated with the basic data blocks, and the plurality of basic data And the identification data block associated with each of the plurality of basic data blocks is distributed to a basic processing circuit connected thereto, and the broadcast data block is broadcasted to a basic processing circuit connected thereto;
  • the basic processing circuit is specifically configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, to obtain a processed broadcast data block;
  • the broadcast data block and the processed basic data block perform a reverse operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.
  • the basic processing circuit is specifically configured to start, by the second mapping circuit, the connection identifier data block according to the identifier data block associated with the partial broadcast data block and the identifier data block associated with the basic data block. Processing the partial broadcast data block and the basic data block according to the connection identification data to obtain a processed partial broadcast data block and the processed basic data block; and the processed partial broadcast data block and the The processed basic data block performs a reverse operation.
  • the main processing circuit is specifically configured to start the first mapping circuit to process the broadcast data block, and obtain the processed Broadcast data block and the identification data block associated with the broadcast data block, or the first mapping circuit is configured to process the broadcast data block according to the pre-stored identification data block associated with the broadcast data block to obtain the processed broadcast data. Blocking the distributed data block to obtain a plurality of basic data blocks; distributing the plurality of basic data blocks to a basic processing circuit connected thereto, and the processed broadcast data block and the broadcast data block The associated identification data block is broadcast to the basic processing circuit connected thereto;
  • the basic processing circuit is configured to start, by the second mapping circuit, the basic data block to be processed according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and the processed broadcast
  • the data block and the processed basic data block perform a reverse operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.
  • the main processing circuit is further configured to split the processed broadcast data block and the identification data block associated with the broadcast data block to obtain a plurality of partial broadcast data blocks and the And an identifier data block associated with the plurality of partial broadcast data blocks; and the identification data blocks associated with the plurality of partial broadcast data blocks and the plurality of partial broadcast data blocks are broadcast to the basic processing circuit by one or more times; And the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.
  • the basic processing circuit is configured to process the basic data block according to the identifier data block associated with the partial broadcast data block to obtain a processed basic data block; and the processed basic data block and the The partial broadcast data block performs a reverse operation.
  • the nth output result gradient is: one or any combination of a vector, a matrix, a three-dimensional data block, a four-dimensional data block, and an n-dimensional data block;
  • the nth layer input data may be represented by a tensor, which may specifically be: one or any combination of a vector, a matrix, a three-dimensional data block, a four-dimensional data block, and an n-dimensional data block;
  • the n-layer weight group data may be represented by a tensor, which may specifically be: one or any combination of a vector, a matrix, a three-dimensional data block, a four-dimensional data block, and an n-dimensional data block.
  • the steps of neural network training include:
  • Each layer in a (multi-layer) neural network performs a forward operation in sequence
  • the entire training process requires repeated execution (ie multiple iterations) to process this process multiple times.
  • FIG. 1a is an integrated circuit chip device for performing training of a neural network, where the neural network includes n layers, and the n value ranges from an integer of 2 or more, characterized in that
  • the integrated circuit chip device includes: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, and at least one of the plurality of basic processing circuits includes a second mapping circuit, the first mapping The circuit and the second mapping circuit are both used to perform compression processing of each data in the neural network operation;
  • the integrated circuit chip device is configured to receive a training instruction, determine first layer input data and first layer weight group data according to the training instruction, and perform a neural network on the first layer input data and the first layer weight group data.
  • the n-th layer forward operation obtains the nth output result of the forward operation;
  • the main processing circuit is further configured to obtain an nth output result gradient according to the nth output result, and obtain an nth reverse operation nth inverse operation instruction and the nth inverse operation according to the training instruction
  • the plurality of basic processing circuits are configured to determine, according to the operation control of the nth reverse operation instruction, whether to start the second mapping circuit to process the second data block, and execute the nerve in parallel according to the processed second data block
  • An operation in the network obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit;
  • the second data block is determined by the basic processing circuit to receive the a data block sent by the main processing circuit, the second data block being associated with the processed first data block;
  • the main processing circuit is further configured to process the operation result to obtain an nth layer weight group gradient and an nth layer input data gradient, and apply the nth layer weight group gradient to the nth layer weight group data.
  • the integrated circuit chip device is further configured to perform an n-1 layer inverse operation on the nth layer input data gradient as an n-1th output gradient of the n-1th layer to obtain an n-1 layer weight group gradient, and apply The n-1 layer weight group gradient updates the weight group data of the corresponding layer, and the weight group data includes at least two weights.
  • All or part of the data involved in the neural network training process may be processed data.
  • the foregoing embodiment which is obtained by the first mapping circuit and/or the second mapping circuit, and is not described here.
  • a data block ie, multiple input data blocks, an output data block), or a sub-block of a different portion divided in the same data block, may refer to a processed data block.
  • Figure 6b shows the specific calculation of neural network training for single-layer operation.
  • Figure 6b shows the forward operation of single-layer neural network.
  • the reverse operation of the single layer neural network is shown by the dashed line in Fig. 6b.
  • the forward operation of the layer is performed according to the input data and the weight or the parameter, and the output data is obtained, and then the preset rule is calculated according to the output data (the preset rule can be set by the manufacturer according to its own needs, here)
  • the specific operation step of the preset rule operation is not limited to obtain the output data gradient of the layer.
  • the inverse operation of the layer neural network can be performed according to the input data, the weight or the parameter of the layer, and the output data gradient, and the gradient of the input data and the gradient of the weight or the parameter of the layer can be obtained, and the weight obtained by the calculation can be used.
  • the gradient of the parameter corresponds to updating the weight or parameter of the layer, that is, the neural network training of the layer is completed.
  • the data involved in the forward operation or the reverse operation may be the processed data.
  • the technical solution provided by the embodiment of the present application may be an inverse operation according to the layer.
  • the instruction determines whether to initiate a correlation mapping circuit (specifically, the first mapping circuit and/or the second mapping circuit) to process the input data and/or the weight, and then perform the layer operation using the processed input data and/or weights .
  • a correlation mapping circuit specifically, the first mapping circuit and/or the second mapping circuit
  • the layer operation using the processed input data and/or weights .
  • the following is a structural diagram of neural network training for matrix multiplication and convolution, taking FIG. 9a and FIG. 9b as examples.
  • the calculation mode of the layer shown in FIG. 9a is matrix multiplication
  • the operation mode of the layer shown in FIG. 9b is a convolution operation, assuming that the input data and the weight of the layer are all matrix, for convenience, the input data is matrix I.
  • the larger the dimension can be understood as the larger the number of columns of the matrix I and the matrix W and the sum of the number of rows, that is, the matrix I and the matrix W can be considered to occupy a larger space in the memory and/or the register and the calculation amount is larger.
  • the amount of data calculation is large; in order to improve the data processing efficiency, the matrix I and the matrix W need to be processed, and then the matrix multiplication operation is performed.
  • the matrix I is a sparse matrix of 1000*1000
  • the matrix W is also a sparse matrix of 1000*1000.
  • the sum of the number of columns and the number of rows is 2000, the number of which is large, and the corresponding calculation amount is larger, matrix multiplication
  • the multiplication operation of the inner product of the matrix is 109 times.
  • the data processing of the two sparse matrices can greatly reduce the dimension of the matrix I and the matrix W (ie, the amount of data), thereby greatly reducing the amount of data transmitted and Calculate the amount, which in turn reduces transmission overhead and computational overhead.
  • FIG. 9c A schematic diagram of the specific structure of the multilayer neural network training is shown in Figures 9c and 9d.
  • the direction of the dashed arrow shows a reverse operation.
  • the output of the inverse operation is the output data gradient; when the output data gradient is the last layer of the iterative calculation of the multilayer neural network, the output data gradient is specifically the last layer of the iterative calculation
  • the output data is subjected to a preset operation (the preset operation can be set by the manufacturer according to his own needs, and the specific operation steps of the preset operation are not limited herein); if the output data gradient is not an iterative for the multilayer neural network
  • the last layer of the calculation for example, the output data gradient is the nth layer calculated for this iteration, then the output data gradient of the nth layer can be the input data gradient calculated by the n+1th layer inverse operation.
  • FIG. 4h can be a schematic diagram of multi-layer convolutional neural network training (including forward operation and reverse operation), and other operations in the figure can be expressed as layers other than the convolution layer. Or the operation between the layers, not limited.
  • the present disclosure also provides an integrated circuit chip device for performing training of a neural network, the neural network comprising a plurality of layers, the integrated circuit chip device comprising: a processing circuit and an external interface;
  • the external interface is configured to receive a training instruction
  • the processing circuit is configured to determine first layer input data and first layer weight data according to the training instruction, and perform n-th layer forward operation of the neural network by using the first layer input data and the first layer weight data to obtain the nth Output result
  • the processing circuit is further configured to obtain an nth output result gradient according to the nth output result, and obtain an nth reverse operation instruction of the nth layer reverse operation and the nth reverse operation instruction according to the training instruction.
  • the nth layer input data and the nth layer weight group data performing n-layer reversal of the neural network according to the nth reverse operation instruction, the nth output result gradient, the nth layer input data, and the nth layer weight group data The operation obtains n weight gradients of the n-layer operation;
  • the processing circuit is further configured to update the n weights of the n-layer operation by applying the n weight gradients.
  • the present invention also provides a chip, the chip comprising a computing device, the computing device comprising:
  • the data involved in the main processing circuit may be compressed processed data.
  • the compressed processed data includes at least one input neuron or at least one weight.
  • Each of the at least one neuron is greater than a first threshold or each of the at least one weight is greater than a second threshold.
  • the first threshold and the second threshold are customized by the user side, and they may be the same or different.
  • the main processing circuit includes a first mapping circuit
  • the main processing circuit includes an arithmetic unit that performs data compression processing, such as a vector operation unit;
  • a data input interface including receiving input data
  • the received data source may be: external to the neural network operation circuit device or part or all of the basic processing circuit of the neural network operation circuit device;
  • the data input interface may have multiple; specifically, may include a data output interface for outputting data;
  • the outgoing data may be: external to the neural network computing device or part or all of the basic processing circuit of the neural network computing circuit device;
  • the data output interface may have multiple;
  • the main processing circuit includes an on-chip buffer and/or a register
  • the main processing circuit includes an operation unit, and can perform a data operation
  • the main processing circuit includes an arithmetic operation unit
  • the main processing circuit includes a vector operation unit, and the operation may be performed on a group of data at the same time; specifically, the arithmetic operation and/or the vector operation may be any type of operation, including but not Limited to: two numbers plus, minus, multiply and divide, one number plus constant plus, minus, multiply and divide, perform exponential operation, power operation, logarithm operation, and various nonlinear operations on one number, perform comparison operation on two numbers, logical operation Wait.
  • Two vectors are added, subtracted, multiplied, and divided. Each element in a vector is added, subtracted, multiplied, and divided by a constant.
  • Each element in the vector is subjected to exponential operations, power operations, logarithmic operations, and various nonlinear operations.
  • Each of the two corresponding elements in the vector performs a comparison operation, a logical operation, and the like.
  • the main processing circuit includes a data rearranging unit for transmitting data to the basic processing circuit in a certain order, or rearranging the data in place in a certain order;
  • the order of the data arrangement comprises: performing a dimensional order transformation on a multi-dimensional data block; the order of the data arrangement may further comprise: segmenting a data block to send to a different basis. Processing circuit.
  • the computing device also includes a plurality of basic processing circuits: each of the basic processing circuits is configured to calculate an inner product of the two vectors, the calculation method is, the two sets of numbers received by the basic processing circuit, and the elements in the two sets of numbers are corresponding Multiply, and accumulate the results of the multiplication; the result of the inner product is transmitted, where it is transmitted according to the position of the basic processing circuit, and may be transmitted to other basic processing circuits, or directly to the main processing circuit.
  • the data involved in the basic processing circuit may be compressed processed data.
  • the compressed processed data includes at least one input neuron or at least one weight, the at least one neural Each of the neurons is greater than a first threshold or each of the at least one weight is greater than a second threshold.
  • the first threshold and the second threshold are customized by the user side, and they may be the same or different.
  • the basic processing circuit includes a second mapping circuit
  • the basic processing circuit includes a vector operation unit that performs data compression processing
  • a memory unit including an on-chip buffer and/or a register is included;
  • a data input interface including one or more received data
  • two data input interfaces are included, and one or more data can be respectively obtained from two data input interfaces at a time;
  • the basic processing circuit may receive the input data from the data input interface and save it in a register and/or an on-chip buffer;
  • the source of the data input interface receiving data may be: other basic processing circuits and/or main processing circuits.
  • the neural network operation circuit device has a plurality of basic processing circuits
  • the data output interface includes one or more transmission output data
  • one or more data can be transmitted from the data output interface
  • the data transmitted through the data output interface may be: data received from the data input interface, data stored in the on-chip buffer and/or register, multiplier operation result, accumulator operation result, or inner product operator operation One or any combination of the results.
  • three data output interfaces are included, two of which correspond to two data input interfaces, each layer outputs a layer of data received from the data input interface, and a third data output interface Responsible for outputting the operation result;
  • the data output interface may transmit data in a direction where the data source and the data direction here determine the connection relationship of the basic processing circuit in the device.
  • the arithmetic operation circuit includes: one or more multiplier circuits, one or more accumulator circuits, one or more of one or more circuits that perform two sets of inner product operations. combination.
  • two numbers of multiplication operations can be performed, the results of which can be stored in on-chip buffers and/or registers, or directly added to registers and/or on-chip buffers;
  • an inner product operation of the two sets of data can be performed, the result of which can be stored in an on-chip buffer and/or register, or directly added to the register and/or on-chip buffer;
  • the data accumulation operation can be performed to accumulate the data into the on-chip buffer and or the register;
  • the accumulated data of the accumulator circuit may be: data received from the data input interface, data stored in the on-chip buffer and/or register, multiplier operation result, accumulator operation result, inner product operator operation One or any combination of the results.
  • data input interface and “data output interface” used in the above description of the basic processing circuit refer to the data input and output interface of each basic processing circuit, rather than the data input and output of the entire device. interface.
  • the present invention also provides a neural network processor board, including the integrated circuit chip device described in the foregoing embodiments, as shown in FIG. 1a.
  • the neural network chip package structure further includes: a heat sink.
  • the neural network chip package structure is any one of the following packages: a flip chip ball grid array package, a thin quad flat package, a quad flat package with a heat sink, and no lead Quad flat package, small pitch quad flat package.
  • the present disclosure also discloses a combined processing apparatus including the above-described neural network computing device, a universal interconnect interface, and other processing devices (i.e., general processing devices).
  • the neural network computing device interacts with other processing devices to perform user-specified operations.
  • Figure 10a is a schematic diagram of a combined processing device.
  • Other processing devices include processor types of one or more of general purpose/dedicated processors such as a central processing unit CPU, a graphics processing unit GPU, a neural network processor, and the like.
  • the number of processors included in other processing devices is not limited.
  • the other processing device serves as an interface between the neural network computing device and external data and control, including data handling, and completes basic control such as opening and stopping of the neural network computing device; other processing devices may also cooperate with the neural network computing device to complete the computing task.
  • a universal interconnect interface for transmitting data and control commands between the neural network computing device and other processing devices.
  • the neural network computing device acquires the required input data from other processing devices and writes the storage device on the slice of the neural network computing device; the control command can be obtained from the other processing device and written into the control cache on the slice of the neural network computing device;
  • the data in the storage module of the neural network computing device can be read and transmitted to other processing devices.
  • the structure further includes a storage device for storing data required by the operation unit/operation device or other operation unit, and is particularly suitable for the data required for calculation in the neural network operation device. Data that cannot be saved in the internal storage of other processing devices.
  • the combined processing device can be used as a SOC on-chip system for mobile phones, robots, drones, video monitoring devices, etc., effectively reducing the core area of the control part, increasing the processing speed, and reducing the overall power consumption.
  • the universal interconnect interface of the combined processing device is coupled to certain components of the device. Some components such as camera, monitor, mouse, keyboard, network card, wifi interface.
  • Embodiments of the present disclosure provide a neural network processor board that can be used in numerous general purpose or dedicated computing system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, smart homes, home appliances, multiprocessor systems, microprocessor-based systems, robots, programmable consumer electronics devices, personal computers (personal computers) , PC), small computer, mainframe computer, distributed computing environment including any of the above systems or devices, and so on.
  • FIG. 11a is a schematic structural diagram of a neural network processor card according to an embodiment of the present disclosure.
  • the neural network processor board 10 includes a neural network chip package structure 11, a first electrical and non-electrical connection device 12, and a first substrate 13.
  • the disclosure is not limited to the specific structure of the neural network chip package structure 11.
  • the neural network chip package structure 11 includes: a neural network chip 111, a second electrical and non-electrical connection device 112, and a Two substrates 113.
  • the specific form of the neural network chip 111 involved in the disclosure is not limited.
  • the above neural network chip 111 includes, but is not limited to, a neural network chip integrated with a neural network processor, and the above silicon wafer may be made of silicon material, germanium material, quantum material or molecule. Made of materials, etc.
  • the neural network wafer can be packaged according to actual conditions (for example, a more severe environment) and different application requirements, so that most of the neural network wafer is wrapped, and the pins on the neural network wafer are passed through the gold wire.
  • the conductors are connected to the outside of the package structure for electrical connection to the outer layer.
  • the specific structure of the neural network chip 111 is not limited in this disclosure. Alternatively, please refer to the device shown in FIG. 1a or 1b.
  • the present disclosure is not limited to the types of the first substrate 13 and the second substrate 113, and may be a printed circuit board (PCB) or a printed wiring board (PWB), and may be other circuit boards. There are no restrictions on the materials used to make the PCB.
  • PCB printed circuit board
  • PWB printed wiring board
  • the second substrate 113 of the present disclosure is used to carry the neural network chip 111, and the neural network chip package structure 11 is obtained by connecting the above-mentioned neural network chip 111 and the second substrate 113 through the second electrical and non-electrical connection device 112.
  • the neural network chip 111 is protected to further encapsulate the neural network chip package structure 11 and the first substrate 13.
  • FCBGAP flip chip Flip Chip Ball Grid Array Package
  • LQFP Low-profile Quad Flat Package
  • HQFP Quad Flat Package with Heat Sink
  • FCBGAP flip chip Flip Chip Ball Grid Array Package
  • LQFP Low-profile Quad Flat Package
  • HQFP Quad Flat Package with Heat Sink
  • FBGA Fine-Pitch Ball Grid Package
  • Flip Chip is suitable for the case where the area after packaging is required to be high or sensitive to the inductance of the wire and the transmission time of the signal.
  • wire bonding can be used to reduce the cost and increase the flexibility of the package structure.
  • Ball Grid Array which can provide more pins, and the average lead length of the pins is short, which has the function of transmitting signals at high speed.
  • the package can be packaged in Pin Grid Array (PGA). Zero Insertion Force (ZIF), Single Edge Contact Connection (SECC), Land Grid Array (LGA), etc.
  • ZIF Zero Insertion Force
  • SECC Single Edge Contact Connection
  • LGA Land Grid Array
  • the neural network chip 111 and the second substrate 113 are encapsulated by using a flip chip ball grid array (Flip Chip Ball Grid Array).
  • a flip chip ball grid array flip chip Ball Grid Array
  • FIG. 12a the neural network chip package structure includes a neural network chip 21, a pad 22, a solder ball 23, a second substrate 24, a connection point 25 on the second substrate 24, and a lead 26.
  • the pad 22 is connected to the neural network chip 21, and the solder ball 23 is soldered between the pad 22 and the connection point 25 on the second substrate 24 to connect the neural network chip 21 and the second substrate 24, thereby realizing The package of the neural network chip 21.
  • the pin 26 is used for connecting with an external circuit of the package structure (for example, the first substrate 13 on the neural network processor board 10), and can realize transmission of external data and internal data, facilitating the neural network chip 21 or the neural network chip 21.
  • the corresponding neural network processor processes the data.
  • the type and number of pins are not limited in this disclosure. Different pin types may be selected according to different packaging technologies, and are arranged according to certain rules.
  • the neural network chip package structure further includes an insulating filler disposed in the gap between the pad 22, the solder ball 23 and the connection point 25 for preventing interference between the solder ball and the solder ball.
  • the material of the insulating filler may be silicon nitride, silicon oxide or silicon oxynitride; the interference includes electromagnetic interference, inductance interference and the like.
  • the neural network chip package structure further includes a heat dissipation device for dissipating heat of the neural network chip 21 during operation.
  • the heat sink may be a piece of metal with good thermal conductivity, a heat sink or a heat sink, for example, a fan.
  • the neural network chip package structure 11 includes: a neural network chip 21, a pad 22, a solder ball 23, a second substrate 24, a connection point 25 on the second substrate 24, and a pin 26, Insulating filler 27, thermal grease 28 and metal housing fins 29.
  • the heat dissipation paste 28 and the metal case heat sink 29 are used to dissipate the heat of the neural network chip 21 during operation.
  • the neural network chip package structure 11 further includes a reinforcing structure, is connected to the pad 22, and is embedded in the solder ball 23 to enhance the connection strength between the solder ball 23 and the pad 22.
  • the reinforcing structure may be a metal wire structure or a columnar structure, which is not limited herein.
  • the present disclosure is not limited to the specific form of the first electrical and non-electrical device 12, and the description of the second electrical and non-electrical device 112 may be referred to, that is, the neural network chip package structure 11 may be packaged by soldering, or may be connected.
  • the manner of connecting the second substrate 113 and the first substrate 13 by wire connection or plugging and unplugging facilitates subsequent replacement of the first substrate 13 or the neural network chip package structure 11.
  • the first substrate 13 includes an interface of a memory unit for expanding a storage capacity, for example, a Synchronous Dynamic Random Access Memory (SDRAM), and a Double Rate Rate SDRAM (Double Rate Rate SDRAM). DDR), etc., improve the processing power of the neural network processor by expanding the memory.
  • SDRAM Synchronous Dynamic Random Access Memory
  • DDR Double Rate Rate SDRAM
  • the first substrate 13 may further include a Peripheral Component Interconnect-Express (PCI-E or PCIe) interface, a Small Form-factor Pluggable (SFP) interface, and an Ethernet interface. Controller Area Network (CAN) interface, etc., used for data transmission between the package structure and external circuits, which can improve the operation speed and convenience of operation.
  • PCI-E or PCIe Peripheral Component Interconnect-Express
  • SFP Small Form-factor Pluggable
  • Ethernet interface Ethernet interface.
  • Controller Area Network (CAN) interface etc., used for data transmission between the package structure and external circuits, which can improve the operation speed and convenience of operation.
  • CAN Controller Area Network
  • the neural network processor is packaged as a neural network chip 111, the neural network chip 111 is packaged as a neural network chip package structure 11, and the neural network chip package structure 11 is packaged as a neural network processor board 10, through an interface on the board (The slot or ferrule) performs data interaction with an external circuit (for example, a computer motherboard), that is, directly implements the function of the neural network processor by using the neural network processor board 10, and protects the neural network chip 111.
  • other modules can be added to the neural network processor board 10, which improves the application range and computational efficiency of the neural network processor.
  • the present invention discloses a neural network computing device that includes functional units for performing all or part of the embodiments provided in the method embodiments described above.
  • the present invention discloses a chip for performing all or part of the embodiments provided in the method embodiments described above.
  • the present invention discloses an electronic device comprising functional units for performing all or part of the embodiments of the method as described above.
  • Electronic devices include data processing devices, robots, computers, printers, scanners, tablets, smart terminals, mobile phones, driving recorders, navigators, sensors, cameras, servers, cameras, camcorders, projectors, watches, headphones, mobile storage , wearables, vehicles, household appliances, and/or medical equipment.
  • the vehicle includes an airplane, a ship, and/or a vehicle;
  • the household appliance includes a television, an air conditioner, a microwave oven, a refrigerator, a rice cooker, a humidifier, a washing machine, an electric lamp, a gas stove, a range hood;
  • the medical device includes a nuclear magnetic resonance instrument, B-ultrasound and / or electrocardiograph.

Landscapes

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

Abstract

Provided are an integrated circuit chip apparatus and a related product. The integrated circuit chip apparatus comprises: a main processing circuit and a plurality of basic processing circuits, wherein the main processing circuit comprises a first mapping circuit, and at least one of the plurality of basic processing circuits comprises a second mapping circuit, the first mapping circuit and the second mapping circuit both being used to perform compression processing on each piece of data in a neural network operation. The technical solution provided in the present disclosure has the advantages of a small calculation amount and low power consumption.

Description

集成电路芯片装置、板卡及相关产品Integrated circuit chip devices, boards and related products 技术领域Technical field

本披露涉及神经网络领域,尤其涉及一种集成电路芯片装置、板卡及相关产品。The present disclosure relates to the field of neural networks, and more particularly to an integrated circuit chip device, a board, and related products.

背景技术Background technique

人工神经网络(Artificial Neural Network,即ANN),是20世纪80年代以来人工智能领域兴起的研究热点。它从信息处理角度对人脑神经元网络进行抽象,建立某种简单模型,按不同的连接方式组成不同的网络。在工程与学术界也常直接简称为神经网络或类神经网络。神经网络是一种运算模型,由大量的节点(或称神经元)之间相互联接构成。现有的神经网络的运算基于CPU(Central Processing Unit,中央处理器)或GPU(英文:Graphics Processing Unit,图形处理器)来实现神经网络的运算,此种运算的计算量大,功耗高。Artificial Neural Network (ANN) is a research hotspot in the field of artificial intelligence since the 1980s. It abstracts the human brain neuron network from the perspective of information processing, establishes a simple model, and forms different networks according to different connection methods. In engineering and academia, it is often referred to directly as a neural network or a neural network. A neural network is an operational model consisting of a large number of nodes (or neurons) connected to each other. The calculation of the existing neural network is based on a CPU (Central Processing Unit) or a GPU (Graphics Processing Unit) to implement the operation of the neural network. Such calculations have a large amount of calculation and high power consumption.

发明内容Summary of the invention

本披露实施例提供了一种集成电路芯片装置、板卡及相关产品,可提升计算装置的处理速度,提高效率。Embodiments of the present disclosure provide an integrated circuit chip device, a board, and related products, which can improve the processing speed of the computing device and improve efficiency.

第一方面,提供一种集成电路芯片装置,所述集成电路芯片装置包括:主处理电路以及多个基础处理电路;所述主处理电路包括第一映射电路,所述多个基础处理电路中至少一个电路包括第二映射电路,所述第一映射电路以及所述第二映射电路均用于执行神经网络运算中的各个数据的压缩处理;In a first aspect, an integrated circuit chip device is provided, the integrated circuit chip device comprising: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, wherein at least one of the plurality of basic processing circuits A circuit includes a second mapping circuit, each of the first mapping circuit and the second mapping circuit for performing compression processing of each data in a neural network operation;

所述主处理电路,用于执行神经网络运算中的各个连续的运算以及与所述基础处理电路传输数据;The main processing circuit is configured to perform each successive operation in the neural network operation and transmit data with the basic processing circuit;

所述多个基础处理电路,用于依据所述主处理电路传输的数据以并行方式执行神经网络中的运算,并将运算结果传输给所述主处理电路。The plurality of basic processing circuits are configured to perform operations in the neural network in parallel according to data transmitted by the main processing circuit, and transmit the operation results to the main processing circuit.

在一些可能的实施中,所述集成电路芯片装置还包括:分支处理电路,所述分支处理电路设置在主处理电路与至少一个基础处理电路之间;所述分支处理电路,用于在主处理电路与至少一个基础处理电路之间转发数据;其中,所述分支处理电路包含多个分支处理电路,所述主处理电路与所述多个分支处理电路分别连接,每个分支处理电路与至少一个基础处理电路连接。In some possible implementations, the integrated circuit chip device further includes: a branch processing circuit disposed between the main processing circuit and the at least one basic processing circuit; the branch processing circuit for performing the main processing Forwarding data between the circuit and the at least one basic processing circuit; wherein the branch processing circuit includes a plurality of branch processing circuits, the main processing circuit and the plurality of branch processing circuits being respectively connected, each branch processing circuit and at least one The basic processing circuit is connected.

第二方面,提供一种集成电路芯片装置,所述集成电路芯片装置包括:主处理电路以及多个基础处理电路;所述主处理电路包括第一映射电路,所述多个基础处理电路中至少一个电路包括第二映射电路,所述第一映射电路以及所述第二映射电路均用于执行神经网络运算中的各个数据的压缩处理;In a second aspect, an integrated circuit chip device is provided. The integrated circuit chip device includes: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, and at least the plurality of basic processing circuits A circuit includes a second mapping circuit, each of the first mapping circuit and the second mapping circuit for performing compression processing of each data in a neural network operation;

所述主处理电路,用于获取输入数据块、卷积核数据块以及卷积指令,依据所述卷积指令将所述输入数据块划分成广播数据块,将所述卷积核数据块划分成分发数据块;依据所述卷积指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述卷积指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is configured to acquire an input data block, a convolution kernel data block, and a convolution instruction, and divide the input data block into a broadcast data block according to the convolution instruction, and divide the convolution kernel data block into Generating a data block; determining, according to the operation control of the convolution instruction, starting the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and And the broadcast data block; transmitting the processed first data block to at least one of the basic processing circuits connected to the main processing circuit according to the convolution instruction;

所述多个基础处理电路,用于依据所述卷积指令的运算控制确定是否启动第二映射电路对第二数据 块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the convolution instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block. Calculating an operation result, and transmitting the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is the receiving the main processing circuit determined by the basic processing circuit a transmitted data block, the second data block being associated with the processed first data block;

所述主处理电路,用于将所述运算结果处理得到所述卷积指令的指令结果。The main processing circuit is configured to process the operation result to obtain an instruction result of the convolution instruction.

第三方面,提供一种集成电路芯片装置,所述集成电路芯片装置包括:主处理电路以及多个基础处理电路;所述主处理电路包括第一映射电路,所述多个基础处理电路中至少一个电路包括第二映射电路,所述第一映射电路以及所述第二映射电路均用于执行神经网络运算中的各个数据的压缩处理;In a third aspect, an integrated circuit chip device is provided, the integrated circuit chip device comprising: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, wherein at least one of the plurality of basic processing circuits A circuit includes a second mapping circuit, each of the first mapping circuit and the second mapping circuit for performing compression processing of each data in a neural network operation;

所述主处理电路,用于获取输入数据块、权值数据块以及乘法指令,依据所述乘法指令将所述输入数据块划分成分发数据块,将所述权值数据块划分成广播数据块;依据所述乘法指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述乘法指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is configured to acquire an input data block, a weight data block, and a multiplication instruction, and divide the input data block into a data block according to the multiplication instruction, and divide the weight data block into a broadcast data block. And determining, according to the operation control of the multiplication instruction, starting the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast a data block; transmitting, according to the multiplication instruction, the processed first data block to at least one of the basic processing circuits connected to the main processing circuit;

所述多个基础处理电路,用于依据所述乘法指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the multiplication instruction, whether to start the second mapping circuit to process the second data block, and perform the operation in the neural network in parallel according to the processed second data block. Obtaining an operation result, and transmitting the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is sent by the main processing circuit determined by the basic processing circuit Data block, the second data block is associated with the processed first data block;

所述主处理电路,用于将所述运算结果处理得到所述乘法指令的指令结果。The main processing circuit is configured to process the operation result to obtain an instruction result of the multiplication instruction.

第四方面,提供一种集成电路芯片装置,所述集成电路芯片装置用于执行神经网络正向运算,所述神经网络包含n层;所述主处理电路包括第一映射电路,所述多个基础处理电路中至少一个电路包括第二映射电路,所述第一映射电路以及所述第二映射电路均用于执行神经网络运算中的各个数据的压缩处理:In a fourth aspect, an integrated circuit chip device is provided for performing a neural network forward operation, the neural network includes n layers, and the main processing circuit includes a first mapping circuit, the plurality of At least one of the basic processing circuits includes a second mapping circuit, each of the first mapping circuit and the second mapping circuit for performing compression processing of each data in the neural network operation:

所述主处理电路,用于接收正向运算指令,解析所述正向运算指令得到所述正向运算指令在所述神经网络正向运算中的第i层所包含的第一运算指令以及所述第一运算指令所需的输入数据块以及权值数据块,所述i的取值范围为大于等于1,且小于等于n的整数,如所述i大于等于2,所述输入数据块为第i-1层的输出数据块;The main processing circuit is configured to receive a forward operation instruction, and parse the forward operation instruction to obtain a first operation instruction included in an ith layer of the forward operation instruction in the forward operation of the neural network An input data block and a weight data block required by the first operation instruction, wherein the range of i is an integer greater than or equal to 1, and less than or equal to n, and if the i is greater than or equal to 2, the input data block is Output data block of layer i-1;

所述主处理电路,用于依据所述第一运算指令将所述输入数据块划分成广播数据块,将所述卷积核数据块划分成分发数据块;依据所述第一正向指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述卷积指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is configured to divide the input data block into a broadcast data block according to the first operation instruction, and divide the convolution kernel data block into a data block; according to the first forward instruction The operation control determines to start the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast data block; The product instruction sends the processed first data block to at least one of the basic processing circuits connected to the main processing circuit;

所述多个基础处理电路,用于依据所述第一运算指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the first operation instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block. The operation obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is the receiving the main processing determined by the basic processing circuit a data block sent by the circuit, the second data block being associated with the processed first data block;

所述主处理电路,用于将所述运算结果进行处理得到所述第一运算指令的指令结果,完成所述第i层包含的所述第一运算指令的运算。The main processing circuit is configured to process the operation result to obtain an instruction result of the first operation instruction, and complete an operation of the first operation instruction included in the ith layer.

第五方面,提供一种集成电路芯片装置,所述集成电路芯片装置用于执行的神经网络的训练,该神经网络包含n层,所述n取值范围为大于等于2的整数,其特征在于,所述集成电路芯片装置包括:主 处理电路以及多个基础处理电路;所述主处理电路包括第一映射电路,所述多个基础处理电路中至少一个电路包括第二映射电路,所述第一映射电路以及所述第二映射电路均用于执行神经网络运算中的各个数据的压缩处理;In a fifth aspect, an integrated circuit chip device is provided for performing training of a neural network, where the neural network includes n layers, and the n value ranges from an integer greater than or equal to 2, wherein The integrated circuit chip device includes: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, and at least one of the plurality of basic processing circuits includes a second mapping circuit, A mapping circuit and the second mapping circuit are both used to perform compression processing of respective data in a neural network operation;

所述集成电路芯片装置,用于接收训练指令,依据该训练指令确定第一层输入数据和第一层权值组数据,对第一层输入数据和第一层权值组数据执行神经网络的n层正向运算得到正向运算的第n输出结果:The integrated circuit chip device is configured to receive a training instruction, determine first layer input data and first layer weight group data according to the training instruction, and perform a neural network on the first layer input data and the first layer weight group data. The n-th layer forward operation obtains the nth output result of the forward operation:

所述主处理电路,还用于依据所述第n输出结果得到第n输出结果梯度,依据所述训练指令获取第n层反向运算的第n反向运算指令以及所述第n反向运算指令所需的第n层输入数据以及第n层权值组数据;依据所述第n反向运算指令将所述第n输出结果梯度、第n层输入数据以及第n层权值组数据划分为广播数据块和分发数据块;依据所述第n反向运算指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述第n反向运算指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is further configured to obtain an nth output result gradient according to the nth output result, and obtain an nth reverse operation nth inverse operation instruction and the nth inverse operation according to the training instruction The nth layer input data and the nth layer weight group data required by the instruction; dividing the nth output result gradient, the nth layer input data, and the nth layer weight group data according to the nth reverse operation instruction a broadcast data block and a distribution data block; determining, according to the operation control of the nth reverse operation instruction, starting the first mapping circuit to process the first data block, and obtaining the processed first data block; the first data block Include the distribution data block and/or the broadcast data block; transmitting the processed first data block to at least one of the basic processing circuits connected to the main processing circuit according to the nth reverse operation instruction Processing circuit

所述多个基础处理电路,用于依据所述第n反向运算指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the nth reverse operation instruction, whether to start the second mapping circuit to process the second data block, and execute the nerve in parallel according to the processed second data block An operation in the network obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is determined by the basic processing circuit to receive the a data block sent by the main processing circuit, the second data block being associated with the processed first data block;

所述主处理电路,还用于对该运算结果进行处理得到第n层权值组梯度和第n层输入数据梯度,应用所述第n层权值组梯度对第n层权值组数据进行更新;The main processing circuit is further configured to process the operation result to obtain an nth layer weight group gradient and an nth layer input data gradient, and apply the nth layer weight group gradient to the nth layer weight group data. Update

所述集成电路芯片装置,还用于将第n层输入数据梯度作为第n-1层的第n-1输出结果梯度执行n-1层反向运算得到n-1层权值组梯度,应用n-1层权值组梯度更新对应层的权值组数据,所述权值组数据包括至少二个权值。The integrated circuit chip device is further configured to perform an n-1 layer inverse operation on the nth layer input data gradient as an n-1th output gradient of the n-1th layer to obtain an n-1 layer weight group gradient, and apply The n-1 layer weight group gradient updates the weight group data of the corresponding layer, and the weight group data includes at least two weights.

第六方面,提供一种神经网络处理器板卡,所述神经网络处理器板卡包括:神经网络芯片封装结构、第一电气及非电气连接装置和第一基板;所述神经网络芯片封装结构包括:神经网络芯片、第二电气及非电气连接装置和第二基板,所述第二基板承载所述神经网络芯片,所述第二基板通过所述第二电气及非电气连接装置与所述神经网络芯片连接;According to a sixth aspect, a neural network processor board is provided, the neural network processor board includes: a neural network chip package structure, a first electrical and non-electrical connection device, and a first substrate; the neural network chip package structure The method includes: a neural network chip, a second electrical and non-electrical connection device, and a second substrate, the second substrate carries the neural network chip, and the second substrate passes the second electrical and non-electrical connection device Neural network chip connection;

所述神经网络芯片包括上述第一方面至五方面中的任一方面所提供的集成电路芯片装置。The neural network chip includes the integrated circuit chip device provided by any of the above aspects to the fifth aspect.

第七方面,提供一种神经网络运算装置,所述神经网络运算装置包括上述第一方面至五方面中的任一方面所提供的集成电路芯片装置。According to a seventh aspect, a neural network computing device is provided, the neural network computing device comprising the integrated circuit chip device provided by any one of the first to fifth aspects.

第八方面,提供一种组合处理装置,所述组合处理装置包括:第七方面提供的神经网络运算装置、通用互联接口和通用处理装置;According to an eighth aspect, a combined processing apparatus is provided, where the combined processing apparatus includes: a neural network computing apparatus provided by the seventh aspect, a universal interconnection interface, and a general processing apparatus;

所述神经网络运算装置通过所述通用互联接口与所述通用处理装置连接。The neural network computing device is coupled to the general purpose processing device via the universal interconnect interface.

第九方面,提供一种芯片,所述芯片集成上述第一方面至第八方面中的任一方面所提供的装置。In a ninth aspect, a chip is provided, the chip integrating the apparatus provided in any one of the first to eighth aspects above.

第十方面,提供一种电子设备,所述电子设备包括第九方面的芯片。In a tenth aspect, an electronic device is provided, the electronic device comprising the chip of the ninth aspect.

第十一方面,提供一种神经网络的运算方法,所述方法应用在集成电路芯片装置内,所述集成电路芯片装置包括:第一方面至第五方面中的任一方面所述的集成电路芯片装置,所述集成电路芯片装置用于执行神经网络的运算。In an eleventh aspect, a method for computing a neural network is provided, the method being applied to an integrated circuit chip device, the integrated circuit chip device comprising: the integrated circuit of any one of the first aspect to the fifth aspect A chip device for performing an operation of a neural network.

可以看出,通过本披露实施例,提供压缩映射电路将数据块压缩处理后再进行运算,节省了传输资源以及计算资源,所以其具有功耗低,计算量小的优点。It can be seen that, by using the embodiment of the present disclosure, the compression mapping circuit is provided to compress the data block and then perform operations, thereby saving transmission resources and computing resources, so that it has the advantages of low power consumption and small calculation amount.

附图说明DRAWINGS

图1a是一种集成电路芯片装置结构示意图。1a is a schematic structural view of an integrated circuit chip device.

图1b是另一种集成电路芯片装置结构示意图。FIG. 1b is a schematic structural view of another integrated circuit chip device.

图1c是一种基础处理电路的结构示意图。Figure 1c is a schematic structural view of a basic processing circuit.

图2为一种矩阵乘以向量流程示意图。Figure 2 is a schematic diagram of a matrix multiplied by a vector flow.

图2a是矩阵乘以向量的示意图。Figure 2a is a schematic diagram of a matrix multiplied by a vector.

图2b为一种矩阵乘以矩阵流程示意图。Figure 2b is a schematic diagram of a matrix multiplied by a matrix flow.

图2c是矩阵Ai乘以向量B的示意图。Figure 2c is a schematic diagram of matrix Ai multiplied by vector B.

图2d是矩阵A乘以矩阵B的示意图。Figure 2d is a schematic diagram of matrix A multiplied by matrix B.

图2e是矩阵Ai乘以矩阵B的示意图。Figure 2e is a schematic diagram of matrix Ai multiplied by matrix B.

图3a为神经网络训练示意图。Figure 3a is a schematic diagram of neural network training.

图3b为卷积运算示意图。Figure 3b is a schematic diagram of a convolution operation.

图4为本披露实施例流提供的一种神经网络芯片的结构示意图;4 is a schematic structural diagram of a neural network chip provided by the flow of the embodiment of the present disclosure;

图5a-图5b为本申请实施例提供的两种映射电路的结构示意图。5a-5b are schematic structural diagrams of two mapping circuits provided by an embodiment of the present application.

图6a是一种神经网络的正向运算示意图。Figure 6a is a schematic diagram of the forward operation of a neural network.

图6b是一种神经网络运算的示意图。Figure 6b is a schematic diagram of a neural network operation.

图7a为卷积输入数据示意图。Figure 7a is a schematic diagram of convolution input data.

图7b为卷积核示意图。Figure 7b is a schematic diagram of a convolution kernel.

图7c为输入数据的一个三维数据块的运算窗口示意图。Figure 7c is a schematic diagram of the operation window of a three-dimensional data block of input data.

图7d为输入数据的一个三维数据块的另一运算窗口示意图。Figure 7d is a schematic diagram of another operational window of a three-dimensional data block of input data.

图7e为输入数据的一个三维数据块的又一运算窗口示意图。Figure 7e is a schematic diagram of still another operational window of a three-dimensional data block of input data.

图8是一种神经网络的训练方法示意图。FIG. 8 is a schematic diagram of a training method of a neural network.

图9a为一种神经网络训练示意图。Figure 9a is a schematic diagram of neural network training.

图9b为另一种神经网络训练示意图。Figure 9b is a schematic diagram of another neural network training.

图9c为神经网络正向与反向运算示意图。Figure 9c is a schematic diagram of the forward and reverse operations of the neural network.

图9d为神经网络训练多层结构示意图。Figure 9d is a schematic diagram of a multi-layer structure of neural network training.

图9e为本披露实施例流提供的一种神经网络芯片的结构示意图。9e is a schematic structural diagram of a neural network chip provided by the flow of the embodiment of the present disclosure.

图10a为本披露还揭露了一个组合处理装置结构示意图。FIG. 10a is a schematic structural diagram of a combined processing apparatus according to the present disclosure.

图10b为本披露还揭露了一个组合处理装置另一种结构示意图。FIG. 10b is another schematic structural diagram of a combined processing apparatus according to the present disclosure.

图11a为本披露实施例提供的一种神经网络处理器板卡的结构示意图;FIG. 11 is a schematic structural diagram of a neural network processor card according to an embodiment of the present disclosure;

图11b为本披露实施例流提供的一种神经网络芯片封装结构的结构示意图;FIG. 11b is a schematic structural diagram of a neural network chip package structure according to an embodiment of the present disclosure;

图12a为本披露实施例流提供的一种神经网络芯片封装结构的示意图;12a is a schematic diagram of a neural network chip package structure provided by the flow of the embodiment of the present disclosure;

图12b为本披露实施例流提供的另一种神经网络芯片封装结构的示意图。FIG. 12b is a schematic diagram of another neural network chip package structure provided by the flow of the embodiment of the present disclosure.

具体实施方式Detailed ways

为了使本技术领域的人员更好地理解本披露方案,下面将结合本披露实施例中的附图,对本披露实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本披露一部分实施例,而不是全部的实施例。基于本披露中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本披露保护的范围。The technical solutions in the embodiments of the present disclosure will be clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present disclosure. It is a partial embodiment of the disclosure, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present disclosure without departing from the inventive scope are the scope of the disclosure.

在第一方面提供的装置中,所述集成电路芯片装置包括:主处理电路以及多个基础处理电路;所述主处理电路包括第一映射电路,所述多个基础处理电路中至少一个电路(即部分或全部基础处理电路)包括第二映射电路,所述第一映射电路以及所述第二映射电路均用于执行神经网络运算中的各个数据的压缩处理;In the apparatus provided by the first aspect, the integrated circuit chip device includes: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, and at least one of the plurality of basic processing circuits ( That is, part or all of the basic processing circuit) includes a second mapping circuit, each of which is used to perform compression processing of each data in the neural network operation;

所述主处理电路,用于执行神经网络运算中的各个连续的运算以及与所述基础处理电路传输数据;The main processing circuit is configured to perform each successive operation in the neural network operation and transmit data with the basic processing circuit;

所述多个基础处理电路,用于依据所述主处理电路传输的数据以并行方式执行神经网络中的运算,并将运算结果传输给所述主处理电路。The plurality of basic processing circuits are configured to perform operations in the neural network in parallel according to data transmitted by the main processing circuit, and transmit the operation results to the main processing circuit.

在第一方面提供的装置中,所述集成电路芯片装置还包括:分支处理电路,所述分支处理电路设置在主处理电路与至少一个基础处理电路之间;所述分支处理电路,用于在主处理电路与至少一个基础处理电路之间转发数据。In the apparatus provided by the first aspect, the integrated circuit chip device further includes: a branch processing circuit disposed between the main processing circuit and the at least one basic processing circuit; the branch processing circuit configured to Data is forwarded between the main processing circuit and the at least one underlying processing circuit.

在第一方面提供的装置中,所述主处理电路用于获取待计算的数据块以及运算指令,依据所述运算指令将所述待计算的数据块划分为分发数据块和广播数据块;将所述分发数据块和预存的所述分发数据块关联的标识数据块进行拆分处理得到多个基本数据块以及所述多个基本数据块各自关联的标识数据块;将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路;将所述广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路。In the apparatus provided by the first aspect, the main processing circuit is configured to acquire a data block to be calculated and an operation instruction, and divide the data block to be calculated into a distribution data block and a broadcast data block according to the operation instruction; The distribution data block and the pre-stored identification data block associated with the distribution data block are subjected to split processing to obtain a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; and the plurality of basic data are The block and the identification data block associated with each of the plurality of basic data blocks are distributed to a base processing circuit connected thereto; the broadcast data block and the identification data block associated with the broadcast data block are broadcasted to a base processing circuit connected thereto.

其中,所述标识数据块具体可用直接索引或者步长索引的方式来表示,可选的还可用列表的列表(List of Lists,LIL)、坐标列表(Coordinate list,COO)、压缩稀疏行(Compressed Sparse Row,CSR)、压缩稀疏列(Compressed Sparse Column,CSC)、(ELL Pack,ELL)以及混合(Hybird,HYB)等方式表示,本申请不做限定。The identifier data block may be specifically represented by a direct index or a step index, and an optional List of Lists (LIL), a Coordinate list (COO), and a compressed sparse line (Compressed). Sparse Row (CSR), Compressed Sparse Column (CSC), (ELL Pack, ELL), and Hybrid (HyB) are not limited in this application.

以所述标识数据块用直接索引的方式表示为例,所述标识数据块具体可为是由0和1构成的数据块,其中,0表示数据块中包含的数据(如权值或输入神经元)的绝对值小于或等于第一阈值,1表示数据块中包含的数据(如权值或输入神经元)的绝对值大于第一阈值,第一阈值为用户侧或装置侧自定义随机设置的,例如0.05、0等等。For example, the identification data block is represented by a direct index, and the identification data block may specifically be a data block composed of 0 and 1, wherein 0 represents data included in the data block (such as weight or input nerve). The absolute value of the element is less than or equal to the first threshold, and 1 indicates that the absolute value of the data (such as the weight or the input neuron) contained in the data block is greater than the first threshold, and the first threshold is a custom random setting on the user side or the device side. , such as 0.05, 0, and so on.

为节省数据传输量、提高数据传输效率,在所述主处理电路向所述基础处理电路发送数据的过程中,具体可将所述多个基本数据块中的目标数据以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路;可选,还可将所述处理后的广播数据块中的目标数据以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路。其中,所述目标数据是指数据块中绝对值大于第一阈值的数据,或者是指数据块(这里具体可为处理后的分发数据块或处理后的广播数据块)中的非0数据。In order to save the data transmission amount and improve the data transmission efficiency, in the process of the main processing circuit transmitting the data to the basic processing circuit, the target data in the plurality of basic data blocks and the plurality of basic data may be specifically The identification data blocks associated with the blocks are distributed to the basic processing circuit connected thereto; optionally, the target data in the processed broadcast data block and the identification data block associated with the broadcast data block may also be broadcasted to the base connected thereto. Processing circuit. The target data refers to data in which the absolute value of the data block is greater than the first threshold, or refers to non-zero data in the data block (here, specifically, the processed distribution data block or the processed broadcast data block).

相应地,所述基础处理电路用于启动所述第二映射电路根据所述广播数据块关联的标识数据块和所述基本数据块关联的标识数据获得连接标识数据块;根据所述连接标识数据块对所述广播数据块和所述基本数据块进行处理得到处理后的广播数据块和基本数据块;对所述处理后的广播数据块和基本数据块执行内积运算得到运算结果,将所述运算结果发送至所述主处理电路;Correspondingly, the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the broadcast data block and the identification data associated with the basic data block; Processing, by the block, the broadcast data block and the basic data block to obtain a processed broadcast data block and a basic data block; performing an inner product operation on the processed broadcast data block and the basic data block to obtain an operation result, and Transmitting the result of the operation to the main processing circuit;

所述主处理电路,用于对所述运算结果处理得到所述待计算的数据块以及运算指令的指令结果。The main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result of the operation instruction.

例如,分发数据块为M1行N1列的矩阵,基本数据块为M2行N2列的矩阵,其中M1>M2,N1>N2。相应地,该分发数据块关联的标识数据块同样也为M1行N1列的矩阵,该基本数据块关联的标识数据块同样为M2行N2列的矩阵。以基本数据块为2*2的矩阵为例,设为

Figure PCTCN2019075979-appb-000001
第一阈值为0.05,则该基本数据块关联的标识数据块为
Figure PCTCN2019075979-appb-000002
关于第一映射电路和第二映射电路对数据块的处理将在后文进行具体阐述。 For example, the distribution data block is a matrix of M1 rows and N1 columns, and the basic data block is a matrix of M2 rows and N2 columns, where M1>M2, N1>N2. Correspondingly, the identification data block associated with the distribution data block is also a matrix of M1 rows and N1 columns, and the identification data block associated with the basic data block is also a matrix of M2 rows and N2 columns. Take a matrix with a basic data block of 2*2 as an example.
Figure PCTCN2019075979-appb-000001
The first threshold is 0.05, and the identifier data block associated with the basic data block is
Figure PCTCN2019075979-appb-000002
The processing of the data block with respect to the first mapping circuit and the second mapping circuit will be specifically described later.

在第一方面提供的装置中,所述主处理电路,用于获取待计算的数据块以及运算指令,依据所述运算指令将所述待计算的数据块划分为分发数据块和广播数据块;启动所述第一映射电路对所述分发数据块和所述广播数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块,处理后的广播数据块以及该广播数据块关联的标识数据块;将所述处理后的分发数据块以及该分发数据块关联的标识数据块进行拆分处理得到多个基本数据块以及所述基本数据块各自关联的标识数据块,将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路,将所述广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, the main processing circuit is configured to acquire a data block to be calculated and an operation instruction, and divide the data block to be calculated into a distribution data block and a broadcast data block according to the operation instruction; And the first mapping circuit is configured to process the distribution data block and the broadcast data block to obtain a processed distribution data block and an identification data block associated with the distribution data block, the processed broadcast data block, and the broadcast data block. Associated identification data block; splitting the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and identification data blocks associated with the basic data blocks, respectively The plurality of basic data blocks and the identification data blocks respectively associated with the plurality of basic data blocks are distributed to the basic processing circuit connected thereto, and the broadcast data block and the identification data block associated with the broadcast data block are broadcasted to the connected Basic processing circuit;

所述基础处理电路,用于启动所述第二映射电路根据所述广播数据块关联的标识数据块和所述基本数据块关联的标识数据获得连接标识数据块;根据所述连接标识数据块对所述广播数据块和所述基本数据块进行处理得到处理后的广播数据块和基本数据块;对所述处理后的广播数据块和基本数据块执行内积运算得到运算结果,将所述运算结果发送至所述主处理电路;The basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the broadcast data block and the identification data associated with the basic data block; and according to the connection identification data block pair Processing the broadcast data block and the basic data block to obtain a processed broadcast data block and a basic data block; performing an inner product operation on the processed broadcast data block and the basic data block to obtain an operation result, and performing the operation The result is sent to the main processing circuit;

所述主处理电路,用于对所述运算结果处理得到所述待计算的数据块以及运算指令的指令结果。The main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result of the operation instruction.

在可选实施例中,所述主处理电路,还具体用于将所述广播数据块或处理后的广播数据块以及该广播数据块关联的标识数据块进行拆分处理得到多个部分广播数据块以及所述多个部分广播数据块各自关联的标识数据块;将所述多个部分广播数据块以及所述多个部分广播数据块各自关联的标识数据块通过一次或多次广播给所述基础处理电路;其中,所述多个部分广播数据块组合形成所述广播数据块或处理后的广播数据块。In an optional embodiment, the main processing circuit is further configured to split the broadcast data block or the processed broadcast data block and the identification data block associated with the broadcast data block to obtain a plurality of partial broadcast data. a block and an identification data block associated with each of the plurality of partial broadcast data blocks; broadcasting the plurality of partial broadcast data blocks and the identification data blocks associated with each of the plurality of partial broadcast data blocks by the one or more broadcasts to the a base processing circuit; wherein the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.

相应地,所述基础处理电路,具体用于启动所述第二映射电路根据所述部分广播数据块关联的标识数据块以及所述基本数据块关联的标识数据块得到连接标识数据块;根据所述连接标识数据对所述部分广播数据块以及所述基本数据块进行处理得到处理后的部分广播数据块以及处理后的基本数据块;对所述处理后的部分广播数据块以及所述处理后的基本数据块执行内积运算。Correspondingly, the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the partial broadcast data block and the identification data block associated with the basic data block; The connection identification data is processed to process the partial broadcast data block and the basic data block to obtain a processed partial broadcast data block and the processed basic data block; and the processed partial broadcast data block and the processed The basic data block performs an inner product operation.

其中,该连接标识数据块是通过对所述基本数据块关联的标识数据块和所述部分广播数据块关联的标识数据块进行逐元素与操作而获得的数据块。可选的,该连接标识数据块用于表示两个数据块(具体为基本数据块以及广播数据块)中数据均大于绝对值的数据。具体在后文进行详述。The connection identification data block is a data block obtained by performing an element-by-element operation on the identification data block associated with the basic data block and the identification data block associated with the partial broadcast data block. Optionally, the connection identifier data block is used to represent data in which two data blocks (specifically, a basic data block and a broadcast data block) are larger than an absolute value. The details will be described in detail later.

例如,分发数据块关联的标识数据块为2*3的矩阵

Figure PCTCN2019075979-appb-000003
部分广播数据块关联的标识数据块为2*2的矩阵
Figure PCTCN2019075979-appb-000004
则对应获得的连接标识数据块为
Figure PCTCN2019075979-appb-000005
For example, the identification data block associated with the distribution data block is a 2*3 matrix.
Figure PCTCN2019075979-appb-000003
The identification data block associated with a part of the broadcast data block is a matrix of 2*2
Figure PCTCN2019075979-appb-000004
Corresponding to the obtained connection identification data block is
Figure PCTCN2019075979-appb-000005

在第一方面提供的装置中,所述主处理电路,用于获取待计算的数据块以及运算指令,依据所述运算指令将所述待计算的数据块划分为分发数据块和广播数据块;启动所述第一映射电路对所述分发数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块,或者启动所述第一映射电路根据预存的所述分发数据块关联的标识数据块对所述分发数据块进行处理得到处理后的分发数据块;将所述处理后的分发数据块以及该分发数据块关联的标识数据块进行拆分处理得到多个基本数据块以及所述基本数据块各自关联的标识数据块,将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路,将所述广播数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, the main processing circuit is configured to acquire a data block to be calculated and an operation instruction, and divide the data block to be calculated into a distribution data block and a broadcast data block according to the operation instruction; Initiating the first mapping circuit to process the distribution data block to obtain a processed distribution data block and an identification data block associated with the distribution data block, or to initiate the first mapping circuit to associate according to the pre-stored distribution data block The identification data block processes the distribution data block to obtain the processed distribution data block; and the processed distribution data block and the identification data block associated with the distribution data block are split to obtain a plurality of basic data blocks and Identifying data blocks associated with each of the basic data blocks, distributing the plurality of basic data blocks and the identification data blocks associated with the plurality of basic data blocks to a basic processing circuit connected thereto, and broadcasting the broadcast data block To the basic processing circuit connected to it;

所述基础处理电路,用于启动所述第二映射电路根据所述基本数据块关联的标识数据块对所述广播数据块进行处理,得到处理后的广播数据块;对所述处理后的广播数据块和所述处理后的基本数据块执行内积运算得到运算结果,将所述运算结果发送至所述主处理电路;The basic processing circuit is configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, to obtain a processed broadcast data block; and the processed broadcast Performing an inner product operation on the data block and the processed basic data block to obtain an operation result, and transmitting the operation result to the main processing circuit;

所述主处理电路,用于对所述运算结果处理得到所述待计算的数据块以及运算指令的指令结果。The main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result of the operation instruction.

在可选实施例中,所述主处理电路,还具体用于将所述广播数据块进行拆分处理得到多个部分广播数据块;将所述多个部分广播数据块通过一次或多次广播给所述基础处理电路;其中,所述多个部分广播数据块组合形成所述广播数据块或处理后的广播数据块。In an optional embodiment, the main processing circuit is further configured to: split the broadcast data block to obtain a plurality of partial broadcast data blocks; and broadcast the plurality of partial broadcast data blocks by one or more broadcasts. Giving the basic processing circuit; wherein the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.

相应地,所述基础处理电路具体用于根据所述基本数据块关联的标识数据块对所述部分广播数据块进行处理得到处理后的部分广播数据块;对所述基本数据块以及所述处理后的部分广播数据块执行内积运算。Correspondingly, the basic processing circuit is configured to process the partial broadcast data block according to the identifier data block associated with the basic data block to obtain a processed partial broadcast data block; and to process the basic data block and the processing The latter part of the broadcast data block performs an inner product operation.

在第一方面提供的装置中,所述主处理电路,用于获取待计算的数据块以及运算指令,依据所述运算指令将所述待计算的数据块划分为分发数据块和广播数据块;启动所述第一映射电路对所述广播数据块进行处理,得到处理后的广播数据块以及该广播数据块关联的标识数据块,或者启动所述第一映射电路根据预存的所述广播数据块关联的标识数据块对所述广播数据块进行处理得到处理后的广播数据块;对所述分发数据块进行拆分处理得到多个基本数据块;将所述多个基本数据块分发至与其连接的基础处理电路,将所述处理后的广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, the main processing circuit is configured to acquire a data block to be calculated and an operation instruction, and divide the data block to be calculated into a distribution data block and a broadcast data block according to the operation instruction; And the first mapping circuit is configured to process the broadcast data block to obtain a processed broadcast data block and an identifier data block associated with the broadcast data block, or start the first mapping circuit according to the pre-stored broadcast data block. Processing, by the associated identification data block, the broadcast data block to obtain a processed broadcast data block; performing split processing on the distributed data block to obtain a plurality of basic data blocks; and distributing the plurality of basic data blocks to the connected a basic processing circuit, broadcasting the processed broadcast data block and the identification data block associated with the broadcast data block to a basic processing circuit connected thereto;

所述基础处理电路,用于启动所述第二映射电路根据所述广播数据块关联的标识数据块对所述基本数据块进行处理得到处理后的基本数据块;对所述处理后的广播数据块和所述处理后的基本数据块执行内积运算得到运算结果,将所述运算结果发送至所述主处理电路;The basic processing circuit is configured to start, by the second mapping circuit, processing the basic data block according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and processing the processed broadcast data. Performing an inner product operation on the block and the processed basic data block to obtain an operation result, and transmitting the operation result to the main processing circuit;

所述主处理电路,用于对所述运算结果处理得到所述待计算的数据块以及运算指令的指令结果。The main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result of the operation instruction.

在可选实施例中,所述主处理电路,还具体用于将所述处理后的广播数据块和该广播数据块关联的标识数据块进行拆分处理得到多个部分广播数据块以及所述多个部分广播数据块关联的标识数据块;将所述多个部分广播数据块以及所述多个部分广播数据块各自关联的标识数据块通过一次或多次广播给所述基础处理电路;其中,所述多个部分广播数据块组合形成所述广播数据块或处理后的广播数据块。In an optional embodiment, the main processing circuit is further configured to split the processed broadcast data block and the identification data block associated with the broadcast data block to obtain a plurality of partial broadcast data blocks and the And an identifier data block associated with the plurality of partial broadcast data blocks; and the identification data blocks associated with the plurality of partial broadcast data blocks and the plurality of partial broadcast data blocks are broadcast to the basic processing circuit by one or more times; And the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.

相应地,所述基础处理电路具体用于根据所述部分广播数据块关联的标识数据块对所述基本数据块进行处理得到处理后的基本数据块;对所述处理后的基本数据块以及所述部分广播数据块执行内积运算。Correspondingly, the basic processing circuit is configured to process the basic data block according to the identifier data block associated with the partial broadcast data block to obtain a processed basic data block; and the processed basic data block and the The partial broadcast data block performs an inner product operation.

在第一方面提供的装置中,所述主处理电路,具体用于将该广播数据块(具体可为所述广播数据块或者处理后的广播数据块)通过一次广播发送至与其连接的所述基础处理电路。In the apparatus provided by the first aspect, the main processing circuit is specifically configured to send the broadcast data block (specifically, the broadcast data block or the processed broadcast data block) by one broadcast to the connected Basic processing circuit.

在第一方面提供的装置中,所述基础处理电路,具体用于将该基本数据块(同理可为所述基本数据 块或处理后的基本数据块)与该广播数据块执行内积处理得到内积处理结果,将所述内积处理结果累加得到运算结果,将所述运算结果发送至所述主处理电路。In the apparatus provided by the first aspect, the basic processing circuit is specifically configured to perform inner product processing on the basic data block (which may be the basic data block or the processed basic data block) and the broadcast data block. The inner product processing result is obtained, the inner product processing result is accumulated to obtain an operation result, and the operation result is sent to the main processing circuit.

在第一方面提供的装置中,所述主处理电路,用于在如所述运算结果为内积处理的结果时,对所述运算结果累加后得到累加结果,将该累加结果排列得到所述待计算的数据块以及运算指令的指令结果。In the apparatus provided by the first aspect, the main processing circuit is configured to accumulate the operation result and obtain an accumulation result when the operation result is the result of the inner product processing, and arrange the accumulation result to obtain the The data block to be calculated and the instruction result of the operation instruction.

在第一方面提供的装置中,所述主处理电路,具体用于将所述广播数据块分成多个部分广播数据块,将所述多个部分广播数据块通过多次广播至所述基础处理电路;所述多个部分广播数据块组合形成所述广播数据块。In the apparatus provided by the first aspect, the main processing circuit is specifically configured to divide the broadcast data block into a plurality of partial broadcast data blocks, and broadcast the plurality of partial broadcast data blocks to the basic processing by multiple times. a circuit; the plurality of partial broadcast data blocks are combined to form the broadcast data block.

在第一方面提供的装置中,所述基础处理电路,具体用于将该部分广播数据块(具体可为部分广播数据块或者处理后的部分广播数据块)与该基本数据块执行一次内积处理后得到内积处理结果,将所述内积处理结果累加得到部分运算结果,将所述部分运算结果发送至所述主处理电路。上述内积处理具体可以为:如部分广播数据块的元素为矩阵B的前2个元素,即为b10和b11;该基本数据块为输入数据矩阵A的第一行的前2个元素,即a10和a11,则内积=a10*b10+a11*b11。In the apparatus provided by the first aspect, the basic processing circuit is specifically configured to perform an inner product of the partial broadcast data block (specifically, a partial broadcast data block or a processed partial broadcast data block) and the basic data block. After processing, an inner product processing result is obtained, and the inner product processing result is accumulated to obtain a partial operation result, and the partial operation result is sent to the main processing circuit. The inner product processing may be specifically as follows: the element of the partial broadcast data block is the first two elements of the matrix B, that is, b10 and b11; the basic data block is the first two elements of the first row of the input data matrix A, that is, For a10 and a11, the inner product = a10*b10+a11*b11.

又如这里基本数据块以核3*3为例,该部分广播数据块以3*3矩阵为例,将*3矩阵与核3*3执行对应位置的乘法,那么对应获得的内积结果即有3个内积处理结果,将该3个内积处理结果累加得到部分运算结果。3个内积处理结果Out0(3*3矩阵第0行与核3*3第0行的内积)、Out1(3*3矩阵第1行与核3*3第1行的内积)、Out2(3*3矩阵第2行与核3*3第2行的内积)具体可以为:For example, the basic data block here takes the kernel 3*3 as an example. The partial broadcast data block takes the 3*3 matrix as an example, and the *3 matrix and the core 3*3 perform the multiplication of the corresponding positions, then the corresponding inner product result is There are three inner product processing results, and the three inner product processing results are accumulated to obtain partial operation results. The results of the three inner product processing Out0 (the inner product of the 0th row of the 3*3 matrix and the 0th row of the core 3*3), the Out1 (the inner product of the 1st row of the 3*3 matrix and the 1st row of the core 3*3), Out2 (the inner product of the 2nd line of the 3*3 matrix and the 2nd line of the 3*3 core) can be specifically:

Out0=r00*k0[0]+r01*k0[1]+r02*k0[2]Out0=r00*k0[0]+r01*k0[1]+r02*k0[2]

Out1=r10*k1[0]+r11*k1[1]+r12*k1[2]Out1=r10*k1[0]+r11*k1[1]+r12*k1[2]

Out2=r20*k2[0]+r21*k2[1]+r22*k2[2]Out2=r20*k2[0]+r21*k2[1]+r22*k2[2]

其中,r00的r表示部分广播数据块,00表示第0行的第0列元素。Where r of r00 represents a partial broadcast data block, and 00 represents a 0th column element of the 0th row.

k0[0],的k表示基本数据块,0[0]表示第0行的第0列元素;K0[0], k represents the basic data block, and 0[0] represents the 0th column element of the 0th row;

部分运算结果=Out0+Out1+Out2。Partial operation result = Out0+Out1+Out2.

在第一方面提供的装置中,所述基础处理电路,具体用于复用n次该部分广播数据块执行该部分广播数据块与该n个基本数据块内积运算得到n个部分处理结果(也可成n个內积运算结果),该n个內积运算结果与n个基本数据块对应,将n个部分处理结果分别累加后得到n个部分运算结果,将所述n个部分运算结果发送至主处理电路,所述n为大于等于2的整数。In the apparatus provided by the first aspect, the basic processing circuit is specifically configured to multiplex the partial broadcast data block n times to perform the inner product of the partial broadcast data block and the n basic data blocks to obtain n partial processing results ( Alternatively, the result of the n inner product operations may be corresponding to the n basic data blocks, and the n partial processing results are respectively accumulated to obtain n partial operation results, and the n partial operation results are obtained. Sended to the main processing circuit, the n is an integer greater than or equal to 2.

这里基本数据块以n个核3*3为例,该部分广播数据块以3*3矩阵为例,复用n次3*3矩阵分别与核3*3执行n次对应位置乘法,每次运算即对应的内积结果即有3个内积结果,3个内积结果组成一组内积运算结果,将n组中每组的3个内积结果累加得到n个部分运算结果。Here, the basic data block takes n cores 3*3 as an example. The partial broadcast data block takes a 3*3 matrix as an example, and the n times 3*3 matrix is multiplexed with the core 3*3 to perform n times corresponding position multiplication, each time. The operation is the corresponding inner product result, that is, there are three inner product results, and the three inner product results form a set of inner product operation results, and the three inner product results of each group in the n group are accumulated to obtain n partial operation results.

上述举例仅仅是为了说明卷积的运算,上述核3*3也可以用其他的规则代替,当然上述部分输入数据也可以为其他规则的数据块。The above examples are only for explaining the convolution operation, and the core 3*3 may be replaced by other rules. Of course, the partial input data may also be other regular data blocks.

在第一方面提供的装置中,所述主处理电路包括:主寄存器或主片上缓存电路;In the apparatus provided by the first aspect, the main processing circuit includes: a main register or a main on-chip buffer circuit;

所述基础处理电路包括:基本寄存器或基本片上缓存电路。The basic processing circuit includes a basic register or a basic on-chip buffer circuit.

在第一方面提供的装置中,所述主处理电路包括:向量运算器电路、算数逻辑单元电路、累加器电路、矩阵转置电路、直接内存存取电路、第一映射电路或数据重排电路中的一种或任意组合。In the apparatus provided by the first aspect, the main processing circuit comprises: a vector operator circuit, an arithmetic logic unit circuit, an accumulator circuit, a matrix transposition circuit, a direct memory access circuit, a first mapping circuit or a data rearrangement circuit. One or any combination of the above.

在第一方面提供的装置中,所述分支处理电路包含多个分支处理电路,所述主处理电路与所述多个分支处理电路分别连接,每个分支处理电路与至少一个基础处理电路连接。In the apparatus provided by the first aspect, the branch processing circuit includes a plurality of branch processing circuits, the main processing circuit being respectively connected to the plurality of branch processing circuits, each branch processing circuit being connected to at least one basic processing circuit.

在第一方面提供的装置中,所述基础处理电路,还具体用于将该广播数据块和基本数据块转发给其 他基础处理电路以先进行数据处理再执行内积运算得到运算结果,将所述运算结果发送至所述主处理电路;In the apparatus provided by the first aspect, the basic processing circuit is further configured to forward the broadcast data block and the basic data block to other basic processing circuits to perform data processing and then perform an inner product operation to obtain an operation result. Transmitting the result of the operation to the main processing circuit;

所述主处理电路,用于对所述运算结果处理得到所述待计算的数据块以及运算指令的指令结果。The main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result of the operation instruction.

在第一方面提供的装置中,所述数据块可用张量表示,其具体可以是向量、矩阵、三维数据块、四维数据块以及n维数据块中一种或任意组合。该数据块具体可包括但不限于输入数据块、卷积核数据块等。In the apparatus provided by the first aspect, the data block may be represented by a tensor, which may specifically be one or any combination of a vector, a matrix, a three-dimensional data block, a four-dimensional data block, and an n-dimensional data block. The data block may specifically include, but is not limited to, an input data block, a convolution kernel data block, and the like.

在第一方面提供的装置中,如所述运算指令为乘法指令,所述主处理电路确定乘数数据块为广播数据块,被乘数数据块为分发数据块;In the apparatus provided by the first aspect, the operation instruction is a multiplication instruction, the main processing circuit determines that the multiplier data block is a broadcast data block, and the multiplicand data block is a distribution data block;

如所述运算指令为卷积指令,所述主处理电路确定输入数据块为广播数据块,卷积核为分发数据块。If the operation instruction is a convolution instruction, the main processing circuit determines that the input data block is a broadcast data block, and the convolution kernel is a distribution data block.

在第六方面提供的方法中,所述神经网络的运算包括:卷积运算、矩阵乘矩阵运算、矩阵乘向量运算、偏执运算、全连接运算、GEMM运算、GEMV运算、激活运算中的一种或任意组合。In the method provided by the sixth aspect, the operation of the neural network includes: a convolution operation, a matrix multiplication matrix operation, a matrix multiplication vector operation, a paranoid operation, a full connection operation, a GEMM operation, a GEMV operation, and an activation operation. Or any combination.

其中运算指令包括但不限于乘法指令、卷积指令、正向运算指令以及训练指令。下面以运算指令分别为乘法指令和卷积指令为例,阐述集成芯片装置涉及的具体实施例。运算指令为卷积指令时,在第一方面提供的装置中,所述主处理电路包括第一映射电路,所述多个基础处理电路中至少一个电路包括第二映射电路,所述第一映射电路以及所述第二映射电路均用于执行神经网络运算中的各个数据的压缩处理:The operation instructions include, but are not limited to, a multiplication instruction, a convolution instruction, a forward operation instruction, and a training instruction. The specific embodiments involved in the integrated chip device will be described below by taking the operation instructions as the multiplication instruction and the convolution instruction, respectively. When the operation instruction is a convolution instruction, in the apparatus provided by the first aspect, the main processing circuit includes a first mapping circuit, and at least one of the plurality of basic processing circuits includes a second mapping circuit, the first mapping The circuit and the second mapping circuit are both used to perform compression processing of each data in the neural network operation:

所述主处理电路,用于获取输入数据块、卷积核数据块以及卷积指令,依据所述卷积指令将所述输入数据块划分为竖向数据块,将所述卷积核数据块划分为横向数据块;依据所述卷积指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述卷积指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is configured to acquire an input data block, a convolution kernel data block, and a convolution instruction, and divide the input data block into vertical data blocks according to the convolution instruction, and the convolution kernel data block Dividing into a horizontal data block; determining, according to the operation control of the convolution instruction, starting the first mapping circuit to process the first data block, and obtaining the processed first data block; the first data block including the distribution data block And/or the broadcast data block; transmitting the processed first data block to at least one of the basic processing circuits connected to the main processing circuit according to the convolution instruction;

所述多个基础处理电路,用于依据所述卷积指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;所述主处理电路,用于将所述运算结果处理得到所述卷积指令的指令结果。The plurality of basic processing circuits are configured to determine, according to the operation control of the convolution instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block. Calculating an operation result, and transmitting the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is the receiving the main processing circuit determined by the basic processing circuit a transmitted data block, the second data block being associated with the processed first data block; the main processing circuit configured to process the operation result to obtain an instruction result of the convolution instruction.

在第一方面提供的装置中,当所述第一数据块包括分发数据块和广播数据块时,所述主处理电路,具体用于启动所述第一映射电路对所述分发数据块和所述广播数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块、处理后的广播数据块以及该广播数据块关联的标识数据块;将所述处理后分发数据块和该分发数据块关联的标识数据块进行拆分得到多个基本数据块以及所述多个基本数据块各自关联的标识数据块;将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路,将所述广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a distribution data block and a broadcast data block, the main processing circuit is specifically configured to start the first mapping circuit, the distribution data block, and the Processing the broadcast data block to obtain the processed distribution data block, the identification data block associated with the distribution data block, the processed broadcast data block, and the identification data block associated with the broadcast data block; and distributing the processed data block and The identification data block associated with the distribution data block is split to obtain a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; and the plurality of basic data blocks and the plurality of basic data blocks are respectively And the associated identification data block is distributed to the basic processing circuit connected thereto, and the broadcast data block and the identification data block associated with the broadcast data block are broadcasted to the basic processing circuit connected thereto;

所述基础处理电路,用于启动所述第二映射电路依据所述基本数据块关联的标识数据块以及所述广播数据块关联的标识数据块得到连接标识数据块;根据所述连接标识数据块对所述基本数据块以及所述广播数据块进行处理,对处理后的基本数据块以及处理后的广播数据块执行卷积(即内积)运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the basic data block and the identification data block associated with the broadcast data block; and identify the data block according to the connection Processing the basic data block and the broadcast data block, performing a convolution (ie inner product) operation on the processed basic data block and the processed broadcast data block to obtain an operation result, and transmitting the operation result to the The main processing circuit.

在第一方面提供的装置中,当所述第一数据块包括分发数据块时,所述主处理电路,具体用于启动 所述第一映射电路对所述分发数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块,或者启动所述第一映射电路根据预存所述分发数据块关联的标识数据块对所述分发数据块进行处理得到处理后的分发数据块;将所述处理后的分发数据块以及该分发数据块关联的标识数据块进行拆分得到多个基本数据块以及所述多个基本数据块各自关联的标识数据块;将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路;将所述广播数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a distribution data block, the main processing circuit is specifically configured to start processing, by the first mapping circuit, the processing data block to be processed. Distributing the data block and the identification data block associated with the distribution data block, or initiating the first mapping circuit to process the distribution data block according to the identifier data block associated with the pre-stored distribution data block to obtain the processed distribution data block; And dividing the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; and the plurality of basic data And the identification data block associated with each of the plurality of basic data blocks is distributed to a basic processing circuit connected thereto; the broadcast data block is broadcasted to a basic processing circuit connected thereto;

所述基础处理电路,用于启动所述第二映射电路依据所述基本数据块关联的标识数据块对所述广播数据块进行处理,对处理后的广播数据块以及所述基本数据块执行卷积运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, and execute the volume on the processed broadcast data block and the basic data block The product operation obtains the operation result, and the operation result is sent to the main processing circuit.

在第一方面提供的装置中,当所述第一数据块包括广播数据块时,所述主处理电路,具体用于启动所述第一映射电路对所述广播数据块进行处理得到处理后的广播数据块以及该广播数据块关联的标识数据块,或者启动所述第一映射电路依据预存的所述广播数据块关联的标识数据块对所述广播数据块进行处理得到处理后的广播数据块;将所述分发数据块进行拆分得到多个基本数据块;将所述多个基本数据分发至与其连接的基础处理电路;将所述处理后的广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a broadcast data block, the main processing circuit is specifically configured to start processing, by the first mapping circuit, the broadcast data block to be processed. And the broadcast data block and the identifier data block associated with the broadcast data block, or the first mapping circuit is configured to process the broadcast data block according to the pre-stored identifier data block associated with the broadcast data block to obtain the processed broadcast data block. Splitting the distribution data block to obtain a plurality of basic data blocks; distributing the plurality of basic data to a base processing circuit connected thereto; and identifying the processed broadcast data block and the broadcast data block The data block is broadcast to the base processing circuit connected thereto;

所述基础处理电路,用于启动所述第二映射电路依据所述广播数据块关联的标识数据块对所述基本数据块进行处理得到处理后的基本数据块;对所述处理后的基本数据块以及所述处理后的广播数据块执行卷积运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is configured to start, by the second mapping circuit, processing the basic data block according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and processing the processed basic data. The block and the processed broadcast data block perform a convolution operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.

在第一方面提供的装置中,所述基础处理电路,具体用于对该基本数据块与该广播数据块执行卷积运算得到卷积结果,将所述卷积结果累加得到运算结果,将所述运算结果发送至所述主处理电路;所述主处理电路,用于在对所述运算结果累加后得到累加结果,将该累加结果排列得到所述指令结果。In the apparatus provided by the first aspect, the basic processing circuit is configured to perform a convolution operation on the basic data block and the broadcast data block to obtain a convolution result, and accumulate the convolution result to obtain an operation result, where The operation result is sent to the main processing circuit; the main processing circuit is configured to obtain an accumulation result after accumulating the operation result, and arrange the accumulation result to obtain the instruction result.

运算指令为乘法指令时,在第一方面提供的装置中,所述主处理电路包括第一映射电路,所述多个基础处理电路中至少一个电路包括第二映射电路,所述第一映射电路以及所述第二映射电路均用于执行神经网络运算中的各个数据的压缩处理;When the operation instruction is a multiplication instruction, in the apparatus provided by the first aspect, the main processing circuit includes a first mapping circuit, and at least one of the plurality of basic processing circuits includes a second mapping circuit, the first mapping circuit And the second mapping circuit is configured to perform compression processing of each data in the neural network operation;

所述主处理电路,用于获取输入数据块、权值数据块以及乘法指令,依据所述乘法指令将所述输入数据块划分成分发数据块,将所述权值数据块划分成广播数据块;依据所述乘法指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述乘法指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is configured to acquire an input data block, a weight data block, and a multiplication instruction, and divide the input data block into a data block according to the multiplication instruction, and divide the weight data block into a broadcast data block. And determining, according to the operation control of the multiplication instruction, starting the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast a data block; transmitting, according to the multiplication instruction, the processed first data block to at least one of the basic processing circuits connected to the main processing circuit;

所述多个基础处理电路,用于依据所述乘法指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;所述主处理电路,用于将所述运算结果处理得到所述乘法指令的指令结果。The plurality of basic processing circuits are configured to determine, according to the operation control of the multiplication instruction, whether to start the second mapping circuit to process the second data block, and perform the operation in the neural network in parallel according to the processed second data block. Obtaining an operation result, and transmitting the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is sent by the main processing circuit determined by the basic processing circuit The data block, the second data block is associated with the processed first data block; and the main processing circuit is configured to process the operation result to obtain an instruction result of the multiplication instruction.

在第一方面提供的装置中,当所述第一数据块包括分发数据块和广播数据块时,所述主处理电路,具体用于启动所述第一映射电路对所述分发数据块和所述广播数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块、处理后的广播数据块以及该广播数据块关联的标识数据块;将 所述处理后分发数据块和该分发数据块关联的标识数据块进行拆分得到多个基本数据块以及所述多个基本数据块各自关联的标识数据块;将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路,将所述广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a distribution data block and a broadcast data block, the main processing circuit is specifically configured to start the first mapping circuit, the distribution data block, and the Processing the broadcast data block to obtain the processed distribution data block, the identification data block associated with the distribution data block, the processed broadcast data block, and the identification data block associated with the broadcast data block; and distributing the processed data block and The identification data block associated with the distribution data block is split to obtain a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; and the plurality of basic data blocks and the plurality of basic data blocks are respectively And the associated identification data block is distributed to the basic processing circuit connected thereto, and the broadcast data block and the identification data block associated with the broadcast data block are broadcasted to the basic processing circuit connected thereto;

所述基础处理电路,用于启动所述第二映射电路依据所述基本数据块关联的标识数据块以及所述广播数据块关联的标识数据块得到连接标识数据块;根据所述连接标识数据块对所述基本数据块以及所述广播数据块进行处理,对处理后的基本数据块以及处理后的广播数据块执行乘积运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the basic data block and the identification data block associated with the broadcast data block; and identify the data block according to the connection Processing the basic data block and the broadcast data block, performing a product operation on the processed basic data block and the processed broadcast data block to obtain an operation result, and transmitting the operation result to the main processing circuit.

在第一方面提供的装置中,当所述第一数据块包括分发数据块时,所述主处理电路,具体用于启动所述第一映射电路对所述分发数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块,或者启动所述第一映射电路根据预存所述分发数据块关联的标识数据块对所述分发数据块进行处理得到处理后的分发数据块;将所述处理后的分发数据块以及该分发数据块关联的标识数据块进行拆分得到多个基本数据块以及所述多个基本数据块各自关联的标识数据块;将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路;将所述广播数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a distribution data block, the main processing circuit is specifically configured to start processing, by the first mapping circuit, the processing data block to be processed. Distributing the data block and the identification data block associated with the distribution data block, or initiating the first mapping circuit to process the distribution data block according to the identifier data block associated with the pre-stored distribution data block to obtain the processed distribution data block; And dividing the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; and the plurality of basic data And the identification data block associated with each of the plurality of basic data blocks is distributed to a basic processing circuit connected thereto; the broadcast data block is broadcasted to a basic processing circuit connected thereto;

所述基础处理电路,用于启动所述第二映射电路依据所述基本数据块关联的标识数据块对所述广播数据块进行处理,对处理后的广播数据块以及所述基本数据块执行乘积运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, and perform a product on the processed broadcast data block and the basic data block. The operation obtains an operation result, and the operation result is transmitted to the main processing circuit.

在第一方面提供的装置中,当所述第一数据块包括广播数据块时,所述主处理电路,具体用于启动所述第一映射电路对所述广播数据块进行处理得到处理后的广播数据块以及该广播数据块关联的标识数据块,或者启动所述第一映射电路依据预存的所述广播数据块关联的标识数据块对所述广播数据块进行处理得到处理后的广播数据块;将所述分发数据块进行拆分得到多个基本数据块;将所述多个基本数据分发至与其连接的基础处理电路;将所述处理后的广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a broadcast data block, the main processing circuit is specifically configured to start processing, by the first mapping circuit, the broadcast data block to be processed. And the broadcast data block and the identifier data block associated with the broadcast data block, or the first mapping circuit is configured to process the broadcast data block according to the pre-stored identifier data block associated with the broadcast data block to obtain the processed broadcast data block. Splitting the distribution data block to obtain a plurality of basic data blocks; distributing the plurality of basic data to a base processing circuit connected thereto; and identifying the processed broadcast data block and the broadcast data block The data block is broadcast to the base processing circuit connected thereto;

所述基础处理电路,用于启动所述第二映射电路依据所述广播数据块关联的标识数据块对所述基本数据块进行处理得到处理后的基本数据块;对所述处理后的基本数据块以及所述处理后的广播数据块执行乘积运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is configured to start, by the second mapping circuit, processing the basic data block according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and processing the processed basic data. The block and the processed broadcast data block perform a product operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.

在第一方面提供的装置中,所述基础处理电路,具体用于对该基本数据块与该广播数据块执行乘积运算得到乘积结果,将所述乘积结果累加得到运算结果,将所述运算结果发送至所述主处理电路;所述主处理电路,用于在对所述运算结果累加后得到累加结果,将该累加结果排列得到所述指令结果。In the apparatus provided by the first aspect, the basic processing circuit is configured to perform a product operation on the basic data block and the broadcast data block to obtain a product result, and accumulate the product result to obtain an operation result, and the operation result is obtained. Sending to the main processing circuit; the main processing circuit is configured to obtain an accumulated result after accumulating the operation result, and arrange the accumulated result to obtain the instruction result.

参阅图1a,图1a为一种集成电路芯片装置的结构示意图,如图1a所示,该芯片装置包括:主处理电路、基本处理电路和分支处理电路(可选的)。其中,Referring to FIG. 1a, FIG. 1a is a schematic structural diagram of an integrated circuit chip device. As shown in FIG. 1a, the chip device includes: a main processing circuit, a basic processing circuit, and a branch processing circuit (optional). among them,

主处理电路可以包括寄存器和/或片上缓存电路,该主处理电路还可以包括:控制电路、向量运算器电路、ALU(arithmetic and logic unit,算数逻辑单元)电路、累加器电路、DMA(Direct Memory Access,直接内存存取)电路等电路,当然在实际应用中,上述主处理电路还可以添加,转换电路(例如矩阵转置电路)、数据重排电路或激活电路等等其他的电路;The main processing circuit may include a register and/or an on-chip buffer circuit, and the main processing circuit may further include: a control circuit, a vector operator circuit, an ALU (arithmetic and logic unit) circuit, an accumulator circuit, and a DMA (Direct Memory). Access, direct memory access) circuits and other circuits, of course, in practical applications, the above main processing circuit can also add, conversion circuits (such as matrix transposition circuits), data rearrangement circuits or activation circuits, and the like;

可选的,主处理电路可以包括:第一映射电路,第一映射电路可以用于对接收或发送的数据进行处 理,以得到处理后的数据以及该数据关联的标识mask数据,该标识mask数据用于指示该数据的绝对值是否大于预设阈值,可选的,该mask数据可为0或1,其中0表示数据的绝对值小于或等于预设阈值;反之,1表示数据的绝对值大于预设阈值。该预设阈值为用户侧或终端设备侧自定义设置的,例如0.1或0.05等等。在实际应用中,通过第一映射电路可将数据为0或者不大于预设阈值(如0.1)的数据进行剔除,或将这些数据置为0。其优点是,减少主处理电路向基础处理电路传输的数据量、减少基础处理电路中数据运算的计算量,提升数据处理效率。本发明并不限制上述第一映射电路的具体形式。关于所述第一映射电路的具体实现将在下文进行阐述。Optionally, the main processing circuit may include: a first mapping circuit, where the first mapping circuit may be configured to process the received or sent data to obtain the processed data and the identifier mask data associated with the data, the identifier mask data It is used to indicate whether the absolute value of the data is greater than a preset threshold. Optionally, the mask data may be 0 or 1, where 0 indicates that the absolute value of the data is less than or equal to a preset threshold; otherwise, 1 indicates that the absolute value of the data is greater than Preset threshold. The preset threshold is customized on the user side or the terminal device side, for example, 0.1 or 0.05, and the like. In practical applications, data having a data of 0 or not greater than a preset threshold (eg, 0.1) may be culled by the first mapping circuit, or the data may be set to zero. The utility model has the advantages of reducing the amount of data transmitted by the main processing circuit to the basic processing circuit, reducing the calculation amount of the data operation in the basic processing circuit, and improving the data processing efficiency. The invention does not limit the specific form of the first mapping circuit described above. A specific implementation of the first mapping circuit will be set forth below.

例如,主处理电路的输入数据为矩阵数据块

Figure PCTCN2019075979-appb-000006
经过第一映射电路处理后可获得处理后的矩阵数据块为
Figure PCTCN2019075979-appb-000007
该矩阵数据块关联的标识数据块为
Figure PCTCN2019075979-appb-000008
关于第一映射电路的具体处理将在后文进行详述。 For example, the input data of the main processing circuit is a matrix data block.
Figure PCTCN2019075979-appb-000006
After processing by the first mapping circuit, the processed matrix data block can be obtained as
Figure PCTCN2019075979-appb-000007
The identification data block associated with the matrix data block is
Figure PCTCN2019075979-appb-000008
The specific processing regarding the first mapping circuit will be described later in detail.

相应地,在主处理电路向基础处理电路分发数据时,可仅发送1和0.5这两个数据,并非发送处理后的矩阵数据块,8个数据;同时还需将该矩阵数据块关联的标识数据块一起发送给基础处理电路,以便基础处理电路根据接收的标识数据块和接收的两个数据(1和0.5),对应获知这两个数据位于原矩阵数据块的位置。即是,所述基础处理电路可根据接收的标识数据块以及接收的数据,对应还原出主处理电路中处理后的矩阵数据块。Correspondingly, when the main processing circuit distributes data to the basic processing circuit, only two data of 1 and 0.5 may be transmitted, not the processed matrix data block and 8 data; and the identifier of the matrix data block is also required to be associated. The data blocks are sent together to the basic processing circuit, so that the basic processing circuit correspondingly knows that the two data are located at the position of the original matrix data block according to the received identification data block and the received two data (1 and 0.5). That is, the basic processing circuit can correspondingly restore the processed matrix data block in the main processing circuit according to the received identification data block and the received data.

主处理电路还包括数据发送电路、数据接收电路或接口,该数据发送电路可以集成数据分发电路以及数据广播电路,当然在实际应用中,数据分发电路以及数据广播电路也可以分别设置;在实际应用中上述数据发送电路以及数据接收电路也可以集成在一起形成数据收发电路。对于广播数据,即需要发送给每个基础处理电路的数据。对于分发数据,即需要有选择的发送给部分基础处理电路的数据,具体的选择方式可以由主处理电路依据负载以及计算方式进行具体的确定。对于广播发送方式,即将广播数据以广播形式发送至每个基础处理电路。(在实际应用中,通过一次广播的方式将广播数据发送至每个基础处理电路,也可以通过多次广播的方式将广播数据发送至每个基础处理电路,本申请具体实施方式并不限制上述广播的次数),对于分发发送方式,即将分发数据有选择的发送给部分基础处理电路。The main processing circuit further includes a data transmitting circuit, a data receiving circuit or an interface, and the data transmitting circuit can integrate the data distributing circuit and the data broadcasting circuit. Of course, in practical applications, the data distributing circuit and the data broadcasting circuit can also be separately set; in practical applications The above data transmitting circuit and data receiving circuit may also be integrated to form a data transmitting and receiving circuit. For broadcast data, data that needs to be sent to each of the underlying processing circuits. For distributing data, it is necessary to selectively send data to a part of the basic processing circuit, and the specific selection manner may be specifically determined by the main processing circuit according to the load and the calculation manner. For the broadcast transmission mode, the broadcast data is transmitted to each of the basic processing circuits in a broadcast form. (In practical applications, the broadcast data is sent to each of the basic processing circuits by means of one broadcast, and the broadcast data may be sent to each of the basic processing circuits by means of multiple broadcasts. The specific embodiment of the present application does not limit the above. The number of times of broadcasting), for the distribution transmission method, the distribution data is selectively transmitted to the partial basic processing circuit.

在实现分发数据时,主处理电路的控制电路向部分或者全部基础处理电路传输数据(该数据可以相同,也可以不同,具体的,如果采用分发的方式发送数据,各个接收数据的基础处理电路收到的数据可以不同,当然也可以有部分基础处理电路收到的数据相同;When the distribution data is implemented, the control circuit of the main processing circuit transmits data to some or all of the basic processing circuits (the data may be the same or different, and specifically, if the data is transmitted by means of distribution, the basic processing circuit of each received data is received. The data can be different, of course, the data received by some basic processing circuits can be the same;

具体地,广播数据时,主处理电路的控制电路向部分或者全部基础处理电路传输数据,各个接收数据的基础处理电路可以收到相同的数据。Specifically, when the data is broadcast, the control circuit of the main processing circuit transmits data to some or all of the basic processing circuits, and the basic processing circuit of each received data can receive the same data.

可选的,上述主处理电路的向量运算器电路可以执行向量运算,包括但不限于:两个向量加减乘除,向量与常数加、减、乘、除运算,或者对向量中的每个元素执行任意运算。其中,连续的运算具体可以为,向量与常数加、减、乘、除运算、激活运算、累加运算等等。Optionally, the vector operator circuit of the main processing circuit may perform vector operations, including but not limited to: two vector addition, subtraction, multiplication and division, vector and constant addition, subtraction, multiplication, division, or each element in the vector. Perform arbitrary operations. The continuous operation may specifically be: vector and constant addition, subtraction, multiplication, division, activation, accumulation, and the like.

每个基础处理电路可以包括基础寄存器和/或基础片上缓存电路;每个基础处理电路还可以包括:内积运算器电路、向量运算器电路、累加器电路等中一个或任意组合。上述内积运算器电路、向量运算器电路、累加器电路都可以是集成电路,上述内积运算器电路、向量运算器电路、累加器电路也可以为单独设置的电路。Each of the basic processing circuits may include a base register and/or a base on-chip buffer circuit; each of the base processing circuits may further include one or any combination of an inner product operator circuit, a vector operator circuit, an accumulator circuit, and the like. The inner product operator circuit, the vector operator circuit, and the accumulator circuit may be integrated circuits, and the inner product operator circuit, the vector operator circuit, and the accumulator circuit may be separately provided circuits.

该芯片装置可选的还可以包括一个或多个分支处理电路,如具有分支处理电路时,其中主处理电路与分支处理电路连接,该分支处理电路与基本处理电路连接,该基本处理电路的内积运算器电路用于执行数据块之间的内积运算,该主处理电路的控制电路控制数据接收电路或数据发送电路收发外部数据,以及通过控制电路控制数据发送电路将外部数据分发至分支处理电路,该分支处理电路用于收发主处理电路或基本处理电路的数据。如图1a所示的结构适合复杂数据的计算,因为对于主处理电路来说,其连接的单元的数量有限,所以需要在主处理电路与基本处理电路之间添加分支处理电路以实现更多的基本处理电路的接入,从而实现对复杂数据块的计算。分支处理电路和基础处理电路的连接结构可以是任意的,不局限在图1a的H型结构。可选的,主处理电路到基础处理电路是广播或分发的结构,基础处理电路到主处理电路是收集(gather)的结构。广播,分发和收集的定义如下,对于分发或广播结构,此时的基础处理电路的数量大于主处理电路,即1个主处理电路对应多个基础处理电路,即从主处理电路到多个基础处理电路为广播或分发的结构,反之,从多个基础处理电路到主处理电路可以为收集结构。Optionally, the chip device may further include one or more branch processing circuits, such as a branch processing circuit, wherein the main processing circuit is connected to the branch processing circuit, and the branch processing circuit is connected to the basic processing circuit, and the basic processing circuit is The product operator circuit is configured to perform an inner product operation between the data blocks, the control circuit of the main processing circuit controls the data receiving circuit or the data transmitting circuit to transmit and receive external data, and the control circuit controls the data transmitting circuit to distribute the external data to the branch processing a circuit for transmitting and receiving data of a main processing circuit or a basic processing circuit. The structure shown in Figure 1a is suitable for the calculation of complex data, because for the main processing circuit, the number of connected cells is limited, so it is necessary to add a branch processing circuit between the main processing circuit and the basic processing circuit to achieve more The basic processing circuit is accessed to enable calculation of complex data blocks. The connection structure of the branch processing circuit and the basic processing circuit may be arbitrary, and is not limited to the H-type structure of FIG. 1a. Alternatively, the main processing circuit to the basic processing circuit is a broadcast or distributed structure, and the basic processing circuit to the main processing circuit is a gather structure. Broadcast, distribution and collection are defined as follows. For a distribution or broadcast structure, the number of basic processing circuits at this time is greater than that of the main processing circuit, that is, one main processing circuit corresponds to a plurality of basic processing circuits, that is, from the main processing circuit to a plurality of foundations. The processing circuit is a broadcast or distributed structure, and conversely, the plurality of basic processing circuits to the main processing circuit may be a collection structure.

基础处理电路,接收主处理电路分发或者广播的数据保存到基础处理电路的片上缓存中,可以进行运算产生结果,可以向主处理电路发送数据。可选的,基础处理电路还可先对接收的数据进行处理,将处理后的数据保存至片上缓存中,还可利用处理后的数据进行运算产生结果,可选的还可将处理后的数据发送给其他基础处理电路或主处理电路等,本申请不做限定。The basic processing circuit receives the data distributed or broadcast by the main processing circuit and stores it in the on-chip buffer of the basic processing circuit, and can perform the operation to generate the result, and can transmit the data to the main processing circuit. Optionally, the basic processing circuit may first process the received data, save the processed data to the on-chip buffer, and perform processing using the processed data to generate a result, and optionally the processed data. It is sent to other basic processing circuits or main processing circuits, etc., and is not limited in this application.

可选的,每个基础处理电路均可以包括第二映射电路,也可以在部分基础处理电路中配置第二映射电路;第二映射电路可以用于对接收或发送的数据进行处理(即压缩处理)。本发明并不限制上述第二映射电路的具体形式。关于第二映射电路的具体实施将在下文进行详述。Optionally, each of the basic processing circuits may include a second mapping circuit, or a second mapping circuit may be configured in the partial basic processing circuit; the second mapping circuit may be configured to process the received or transmitted data (ie, compress processing) ). The present invention does not limit the specific form of the second mapping circuit described above. The specific implementation of the second mapping circuit will be described in detail below.

可选的,该基础处理电路的向量运算器电路可以对两个向量(两个向量中的任一个或两个均可为处理后的向量)执行的向量运算,当然在实际应用中,基础处理电路的内积运算器电路可以对两个向量执行内积运算,累加器电路也可以对内积运算的结果进行累加。Optionally, the vector operator circuit of the basic processing circuit can perform vector operations on two vectors (either one or both of the two vectors can be processed vectors), of course, in practical applications, basic processing The inner product operator circuit of the circuit can perform inner product operations on the two vectors, and the accumulator circuit can also accumulate the results of the inner product operations.

在一种可选方案中,两个向量可以存放在片上缓存和/或寄存器中,基础处理电路可以根据实际计算的需要提取两个向量执行运算。该运算包括但不限于:内积运算、乘法运算、加法运算或其他的运算。In an alternative, the two vectors can be stored in on-chip buffers and/or registers, and the underlying processing circuitry can extract two vectors to perform the operations as needed for the actual computation. The operations include, but are not limited to, inner product operations, multiplication operations, addition operations, or other operations.

在一种可选方案中,内积运算的结果可以累加到片上缓存和/或寄存器上;其可选方案的优点是,减少了基础处理电路和主处理电路之间的数据传输量,提高了运算效率,降低了数据传输功耗。In an alternative, the result of the inner product operation can be added to the on-chip buffer and/or the register; the advantage of the alternative is that the amount of data transfer between the basic processing circuit and the main processing circuit is reduced, and the number of data is increased. The efficiency of the operation reduces the power consumption of data transmission.

在一种可选方案中,内积运算的结果不进行累加,直接作为结果传输;此技术方案的优点是,减少了基础处理电路内部的运算量,提高基础处理电路的运算效率。In an alternative, the result of the inner product operation is not accumulated and directly transmitted as a result; the advantage of this technical solution is that the calculation amount inside the basic processing circuit is reduced, and the operation efficiency of the basic processing circuit is improved.

在一种可选方案中,每个基础处理电路可以执行多组两个向量的内积运算,也可以对多组内积运算的结果分别进行累加;In an alternative, each of the basic processing circuits may perform inner product operations of multiple sets of two vectors, or may accumulate results of multiple sets of inner product operations separately;

在一种可选方案中,多组的两个向量数据可以存放在片上缓存和/或寄存器中;In an alternative, multiple sets of two vector data can be stored in an on-chip buffer and/or register;

在一种可选方案中,多组内积运算的结果可以分别累加到片上缓存和/或寄存器中;In an alternative, the results of the multiple sets of inner product operations may be separately added to the on-chip buffer and/or registers;

在一种可选方案中,各组内积运算的结果可以不进行累加,直接作为结果传输;In an alternative, the results of the inner product operations of each group may be directly accumulated as a result without accumulating;

在一种可选方案中,每个基础处理电路可以执行同一个向量与多个向量分别进行内积运算的操作(“一对多”内积,即多组内积里每组的两个向量中有一个向量是共享的),并将每个向量对应的内积结果分别进行累加。此技术方案可以实现同一套权值对不同的输入数据进行多次计算,增加了数据复用,减少基础处理电路内部数据的数据传输量,提高计算效率,降低功耗。In an alternative, each of the basic processing circuits may perform an inner product operation operation of the same vector and the plurality of vectors ("one-to-many" inner product, that is, two vectors of each group in the plurality of inner products. There is a vector in the shared), and the inner product results corresponding to each vector are separately accumulated. The technical solution can realize the same set of weights to perform multiple calculations on different input data, increase data multiplexing, reduce data transmission amount of internal processing circuit internal data, improve calculation efficiency, and reduce power consumption.

具体地,计算内积使用的数据中,各组共享的向量和每组的另一个向量(即每组之间不同的那个向量)的数据来源可以不同:Specifically, in the data used to calculate the inner product, the data source shared by each group and the other vector of each group (ie, the vector different between each group) may be different:

在一种可选方案中,在计算内积时,各组共享的向量来自主处理电路或者分支处理电路的广播或者分发;In an alternative, when computing the inner product, the vectors shared by the groups are from the broadcast or distribution of the main processing circuit or the branch processing circuit;

在一种可选方案中,在计算内积时,各组共享的向量来自片上缓存;In an alternative, when computing the inner product, the vectors shared by each group are from an on-chip cache;

在一种可选方案中,在计算内积时,各组共享的向量来自寄存器;In an alternative, when computing the inner product, the vectors shared by the groups are from registers;

在一种可选方案中,在计算内积时,每组的另一个非共享向量来自主处理电路或者分支处理电路的广播或者分发;In an alternative, when computing the inner product, another non-shared vector of each group is from the broadcast or distribution of the main processing circuit or the branch processing circuit;

在一种可选方案中,在计算内积时,每组的另一个非共享向量来自从片上缓存;In an alternative, when computing the inner product, another non-shared vector of each group comes from the on-chip cache;

在一种可选方案中,在计算内积时,每组的另一个非共享向量来自寄存器;In an alternative, when computing the inner product, another non-shared vector of each group is from a register;

在一种可选方案中,在进行多组的内积运算时,每组共享的向量在基础处理电路的片上缓存和/寄存器中保留任意份数;In an alternative, each set of shared vectors retains any number of copies in the on-chip buffer and/or registers of the underlying processing circuitry when performing multiple sets of inner product operations;

在一种可选方案中,共享向量可以对应每组内积各保留一份;In an alternative, the shared vector may be reserved for each inner product of each group;

在一种可选方案中,共享向量可以只保留一份;In an alternative, the shared vector can be kept only one copy;

具体地,多组内积运算的结果可以分别累加到片上缓存和/或寄存器中;Specifically, the results of the multiple sets of inner product operations may be separately added to the on-chip buffer and/or the register;

具体地,各组内积运算的结果可以不进行累加,直接作为结果传输;Specifically, the result of the inner product operation of each group may be directly transmitted as a result without being accumulated;

在一种可选方案中,基础处理电路中涉及的向量或矩阵可为经过第二映射电路处理后的向量或矩阵,具体将在后文阐述。In an alternative, the vector or matrix involved in the basic processing circuit may be a vector or matrix processed by the second mapping circuit, as will be described later.

参阅图1a所示的结构,其包含一主处理电路(可以执行向量操作),多基础处理电路(可以执行内积操作)。这样组合的好处是:装置不仅能使用基础处理电路执行矩阵和向量乘法运算,也能使用主处理电路执行其他任意的向量运算,使装置在有限的硬件电路的配置下,能够更快的完成更多的运算,减少了与装置外部进行数据传输的次数,提高了计算效率,降低了功耗。另外,本芯片在主处理电路中可设置第一映射电路,以执行神经网络中数据的处理,如将小于或等于预设阈值的第一输入数据剔除,同时还可得到该第一输入数据对应关联的标识mask数据,该mask数据用于表示第一输入数据的绝对值是否大于预设阈值。具体可参见前述实施例所述,这里不再赘述。这样设计的优点,可减少向基础处理电路传输的数据量,减少基础处理电路数据的计算量,提高数据处理速率、降低功耗。Referring to the structure shown in Figure 1a, it includes a main processing circuit (which can perform vector operations) and a multi-base processing circuit (which can perform inner product operations). The advantage of this combination is that the device can not only perform matrix and vector multiplication operations using the basic processing circuit, but also perform other arbitrary vector operations using the main processing circuit, so that the device can be completed more quickly under the configuration of limited hardware circuits. More calculations reduce the number of data transmissions outside the device, improve computational efficiency, and reduce power consumption. In addition, the chip may be configured with a first mapping circuit in the main processing circuit to perform processing of data in the neural network, such as culling the first input data that is less than or equal to the preset threshold, and simultaneously obtaining the corresponding first input data. The associated mask data is used to indicate whether the absolute value of the first input data is greater than a preset threshold. For details, refer to the foregoing embodiment, and details are not described herein again. The advantages of this design can reduce the amount of data transmitted to the basic processing circuit, reduce the amount of calculation of the basic processing circuit data, increase the data processing rate, and reduce power consumption.

在基础处理电路中可设置第二映射电路,以执行神经网络中数据的处理,例如根据第一输入数据关联的mask数据对第二输入数据进行处理或者根据第一输入数据关联的mask数据和第二输入数据关联的mask数据选取绝对值大于预设阈值的第一输入数据和第二输入数据执行相应的运算操作的等等。关于第一映射电路和第二映射电路对数据的具体处理可参见后文详述。A second mapping circuit may be disposed in the basic processing circuit to perform processing of data in the neural network, for example, processing the second input data according to mask data associated with the first input data or mask data associated with the first input data and The mask data associated with the two input data selects the first input data whose absolute value is greater than the preset threshold and the second input data performs the corresponding arithmetic operation, and the like. The specific processing of the data by the first mapping circuit and the second mapping circuit can be referred to later in detail.

可选的,所述第一映射电路和所述第二映射电路均用于对数据进行处理,其具体可设计到以下电路中的任一项或多项中:主处理电路、分支处理电路以及基础处理电路等。这样在进行神经网络计算时能够减少计算的数据量,并且本芯片可以依据各个电路(主要是主处理电路和基础处理电路)的运算量(即负载量)动态的分配由哪个电路来进行数据压缩处理,这样能够减少数据计算的复杂程序,降低功耗,并且动态的分配数据处理能够实现不影响芯片的计算效率。该分配的方式包括但不限于:负载均衡、负载最小值分配等等方式。Optionally, the first mapping circuit and the second mapping circuit are both used to process data, which may be specifically designed into any one or more of the following circuits: a main processing circuit, a branch processing circuit, and Basic processing circuit, etc. In this way, the amount of data calculated can be reduced when performing neural network calculation, and the chip can dynamically allocate which circuit to perform data compression according to the calculation amount (ie, the load amount) of each circuit (mainly the main processing circuit and the basic processing circuit). Processing, which can reduce the complexity of data calculation, reduce power consumption, and dynamic allocation of data processing can achieve the calculation efficiency without affecting the chip. The manner of allocation includes, but is not limited to, load balancing, load minimum allocation, and the like.

参阅图1b所示的装置,图1b所示的装置为无分支处理电路的计算装置,如图1b所示的装置,其包括:主处理电路以及N个基础处理电路,其中,主处理电路(具体的结构如图1c所示)与N个基础处理电路可以直接或间接连接,如为间接连接的方式时,一种可选的方案如图1a所示可以包括N/4个分支处理电路,每个分支处理电路分别连接4个基础处理电路,对于主处理电路以及N个基础处理电路 分别包含的电路可以参见上述如图1a所示的描述,这里不再赘述,这里需要说明的是,上述基础处理电路还可以设置在分支处理电路内,另外,每个分支处理电路连接基础处理电路的数量也可以不局限于4个,厂家可以根据实际需要进行配置。该上述主处理电路和N个基础处理电路中可分别设计有第一映射电路和第二映射电路,具体的,可以是主处理电路包括第一映射电路,所述N个基础处理电路或其中的一部分包括第二映射电路;也可以是主处理电路包括第一映射电路和第二映射电路,还可以是指所述N个基础处理电路或其中的一部分包括第一映射电路和第二映射电路。上述主处理电路可以根据神经网络计算指令动态的分配数据压缩处理步骤的操作实体,具体的,主处理电路可以根据自身的负载确定是否对接收到的数据执行压缩处理步骤,具体的,可以将负载的值设置多个区间,每个区间对应分配数据压缩处理步骤的执行主体,例如,以3个区间为例,区间1的负载值较低,可以由N个基础处理电路执行数据压缩处理步骤。主处理电路单独执行数据压缩处理步骤,区间2负载值位于区间1以及区间3之间,可以由主处理电路单独执行数据压缩处理步骤,区间3负载值较高,可以由主处理电路或N个基础处理电路共同执行数据压缩处理步骤。对此,可以以明示的方式来执行,例如主处理电路可以配置一个特殊指示或指令,当基础处理电路接收到该特殊指示或指令时,确定执行数据压缩处理步骤,如基础处理电路未接收到特殊指示或指令时,确定不执行数据压缩处理步骤。又如,可以以暗示的方式来执行,例如,基础处理电路接收到稀疏数据(即含0,或包括小于预设阈值的数据大于预设数量)且确定需要执行内积运算时,将该稀疏数据进行压缩处理。Referring to the device shown in FIG. 1b, the device shown in FIG. 1b is a computing device without a branch processing circuit, as shown in FIG. 1b, comprising: a main processing circuit and N basic processing circuits, wherein the main processing circuit ( The specific structure is as shown in FIG. 1c) and can be directly or indirectly connected to the N basic processing circuits. For the indirect connection mode, an optional solution may include N/4 branch processing circuits as shown in FIG. 1a. Each of the branch processing circuits is respectively connected to four basic processing circuits. For the circuits respectively included in the main processing circuit and the N basic processing circuits, reference may be made to the description shown in FIG. 1a, and details are not described herein. The basic processing circuit can also be disposed in the branch processing circuit. In addition, the number of basic processing circuits connected to each branch processing circuit is not limited to four, and the manufacturer can configure according to actual needs. The first processing circuit and the second basic processing circuit may be respectively configured with a first mapping circuit and a second mapping circuit. Specifically, the main processing circuit may include a first mapping circuit, the N basic processing circuits or A portion includes a second mapping circuit; the main processing circuit may include a first mapping circuit and a second mapping circuit, and may also mean that the N basic processing circuits or a part thereof includes a first mapping circuit and a second mapping circuit. The main processing circuit may dynamically allocate an operation entity of the data compression processing step according to the neural network calculation instruction. Specifically, the main processing circuit may determine whether to perform a compression processing step on the received data according to its own load. Specifically, the load may be performed. The value is set to a plurality of sections, and each section corresponds to an execution subject of the allocation data compression processing step. For example, taking three sections as an example, the load value of the section 1 is low, and the data compression processing steps can be performed by the N basic processing circuits. The main processing circuit separately performs the data compression processing step, and the interval 2 load value is located between the interval 1 and the interval 3. The main processing circuit can separately perform the data compression processing step, and the interval 3 has a high load value, which can be performed by the main processing circuit or N The base processing circuit collectively performs the data compression processing steps. In this regard, it may be performed in an explicit manner. For example, the main processing circuit may be configured with a special indication or instruction. When the basic processing circuit receives the special indication or instruction, it determines to perform a data compression processing step, such as the basic processing circuit does not receive When a special instruction or instruction is made, it is determined that the data compression processing step is not performed. As another example, it may be performed in an implied manner, for example, when the basic processing circuit receives the sparse data (ie, includes 0, or includes data smaller than a preset threshold greater than a preset number) and determines that an inner product operation needs to be performed, the sparse The data is compressed.

本申请涉及的数据压缩处理具体在前文所述的第一映射电路和第二映射电路中执行。应理解的,由于神经网络是一个高计算量和高访存的算法,权值越多,计算量和访存量都会增大。特别是,针对权值较小(如为0,或小于设定数值的权值)的情况下,为提高计算速率、减小开销需对这些权值较小的数据进行压缩处理。在实际应用中,数据压缩处理在稀疏神经网络中应用,效果最为明显,如减小数据计算的工作量、减小数据额外开销,提高数据计算速率等。The data compression processing involved in the present application is specifically performed in the first mapping circuit and the second mapping circuit described above. It should be understood that since the neural network is an algorithm with high computational complexity and high memory access, the more weights, the larger the calculation amount and the memory access amount. In particular, in the case where the weight is small (for example, 0, or less than the weight of the set value), in order to increase the calculation rate and reduce the overhead, it is necessary to compress the data with smaller weights. In practical applications, data compression processing is applied in sparse neural networks, and the effect is most obvious, such as reducing the workload of data calculation, reducing data overhead, and increasing data calculation rate.

以输入数据为例,阐述数据压缩处理涉及的具体实施例。所述输入数据包括但不限于至少一个输入神经元和/或至少一个权值。Taking the input data as an example, a specific embodiment involved in the data compression processing will be explained. The input data includes, but is not limited to, at least one input neuron and/or at least one weight.

第一实施例中:In the first embodiment:

第一映射电路接收到第一输入数据(具体可为主处理电路发送的待计算的数据块,如分发数据块或者广播数据块等)后,所述第一映射电路可对所述第一输入数据进行处理,以获得处理后的第一输入数据以及该第一输入数据关联的标识mask数据,该mask数据用于指示该第一输入数据的绝对值是否大于第一阈值,如0.5、0等等。After the first mapping circuit receives the first input data (specifically, the data block to be calculated sent by the main processing circuit, such as a distribution data block or a broadcast data block, etc.), the first mapping circuit may be the first input The data is processed to obtain the processed first input data and the identifier mask data associated with the first input data, the mask data is used to indicate whether the absolute value of the first input data is greater than a first threshold, such as 0.5, 0, etc. Wait.

具体的,当所述第一输入数据的绝对值大于第一阈值,则保留该输入数据;否则删除该第一输入数据或将该第一输入数据置为0。例如,输入的矩阵数据块为

Figure PCTCN2019075979-appb-000009
第一阈值为0.05,则经过第一映射电路处理后可获得处理后的矩阵数据块
Figure PCTCN2019075979-appb-000010
与该矩阵数据块关联的标识数据块(也可称为mask矩阵)为
Figure PCTCN2019075979-appb-000011
Specifically, when the absolute value of the first input data is greater than the first threshold, the input data is retained; otherwise, the first input data is deleted or the first input data is set to 0. For example, the input matrix data block is
Figure PCTCN2019075979-appb-000009
The first threshold is 0.05, and the processed matrix data block can be obtained after being processed by the first mapping circuit.
Figure PCTCN2019075979-appb-000010
The identification data block (also referred to as the mask matrix) associated with the matrix data block is
Figure PCTCN2019075979-appb-000011

进一步地,为减少数据传输量,所述主处理电路再向与其连接的基础处理电路中分发数据时,可发送所述处理后的矩阵数据块中的目标数据(本例中即为1,0.06和0.5)以及该矩阵数据块关联的标识数 据块。具体实施时,所述主处理电路可按照设定规则将所述处理后的矩阵数据块中的目标数据分发至基础处理电路中,例如按照行顺序依次发送或者按照列顺序依次等等,本申请不做限定。相应地,基础处理电路在接收到所述目标数据以及该目标数据对应关联的标识数据块后,按照设定规则(例如行顺序)将其还原为处理后的矩阵数据块。例如本例中,基础处理电路根据接收的数据(1,0.06和0.5)以及标识数据块

Figure PCTCN2019075979-appb-000012
可获知该数据对应的矩阵数据块(即主处理电路中第一映射电路处理后的矩阵数据块)为
Figure PCTCN2019075979-appb-000013
Further, in order to reduce the amount of data transmission, when the main processing circuit distributes data to the basic processing circuit connected thereto, the target data in the processed matrix data block may be transmitted (in this example, 1, 0.06) And 0.5) and the identification data block associated with the matrix data block. In a specific implementation, the main processing circuit may distribute the target data in the processed matrix data block to the basic processing circuit according to a setting rule, for example, sequentially transmitting in a row order or sequentially in a column order, etc., the present application Not limited. Correspondingly, after receiving the target data and the associated data block corresponding to the target data, the basic processing circuit restores the target data block to the processed matrix data block according to a setting rule (for example, a row order). For example, in this example, the underlying processing circuit is based on the received data (1, 0.06, and 0.5) and the identified data block.
Figure PCTCN2019075979-appb-000012
It can be known that the matrix data block corresponding to the data (that is, the matrix data block processed by the first mapping circuit in the main processing circuit) is
Figure PCTCN2019075979-appb-000013

在本发明实施例中,该第一输入数据可为分发数据块和/或广播数据块。In the embodiment of the present invention, the first input data may be a distribution data block and/or a broadcast data block.

相应地,第二映射电路可利用第一输入数据关联的标识数据对第二输入数据进行处理,从而获得处理后的第二输入数据;其中第一输入数据与所述第二输入数据不同。例如当所述第一输入数据为至少一个权值时,则所述第二输入数据可为至少一个输入神经元;或者,当所述第一输入数据为至少一个输入神经元时,则所述第二输入数据可为至少一个权值。Correspondingly, the second mapping circuit can process the second input data by using the identification data associated with the first input data, thereby obtaining the processed second input data; wherein the first input data is different from the second input data. For example, when the first input data is at least one weight, the second input data may be at least one input neuron; or, when the first input data is at least one input neuron, then The second input data can be at least one weight.

在本发明实施例中,该第二输入数据与所述第一输入数据不同,所述第二输入数据可为以下中的任一个:分发数据块、基本数据块、广播数据块以及部分广播数据块。In the embodiment of the present invention, the second input data is different from the first input data, and the second input data may be any one of: a distribution data block, a basic data block, a broadcast data block, and a partial broadcast data. Piece.

例如,当所述第一输入数据为分发数据块时,则第二输入数据为部分广播数据块。假设第二输入数据为矩阵数据块

Figure PCTCN2019075979-appb-000014
相应地利用上例中mask矩阵
Figure PCTCN2019075979-appb-000015
处理后,获得处理后的部分广播数据块为
Figure PCTCN2019075979-appb-000016
由于在实际应用中,输入数据涉及的矩阵数据块维数较大,本申请这里仅为示意,本不构成限定。 For example, when the first input data is a distribution data block, the second input data is a partial broadcast data block. Assume that the second input data is a matrix data block
Figure PCTCN2019075979-appb-000014
Correspondingly use the mask matrix in the above example
Figure PCTCN2019075979-appb-000015
After processing, the processed partial broadcast data block is obtained as
Figure PCTCN2019075979-appb-000016
Since the dimension of the matrix data block involved in the input data is large in practical applications, the present application is merely illustrative and is not intended to be limiting.

第二实施例中:In the second embodiment:

所述第一映射电路可用于对第一输入数据和第二输入数据进行处理,以得到处理后的第一输入数据以及所述第一输入数据关联的第一标识mask数据、处理后的第二输入数据以及所述第二输入数据关联的第二标识mask数据。其中,所述第一mask数据或者第二mask数据用于指示第一或第二输入数据的绝对值是否大于第二阈值,该第二阈值为用户侧或装置侧自定义设置的,例如0.05、0等等。The first mapping circuit is configured to process the first input data and the second input data to obtain the processed first input data and the first identifier mask data associated with the first input data, and the processed second Input data and second identification mask data associated with the second input data. The first mask data or the second mask data is used to indicate whether the absolute value of the first or second input data is greater than a second threshold, and the second threshold is customized by the user side or the device side, for example, 0.05. 0 and so on.

所述处理后的第一输入数据或第二输入数据可为处理后的输入数据,也可为未处理前的输入数据。例如,第一输入数据为分发数据块,如上述例子中的矩阵数据块

Figure PCTCN2019075979-appb-000017
经过第一映射电路处理后可获得处理后的分发数据块,这里处理后的分发数据块可为原矩阵数据块
Figure PCTCN2019075979-appb-000018
也可为压缩处理后的矩阵数据块
Figure PCTCN2019075979-appb-000019
应理解的,本申请为减少数据量的传输以及基础处理电路中数据处理效率,优选地所述处理后的输入数据(如处理后的基本数据块或部分广播数据块等)应为压缩处理后的数据。优选地,主处理电路向基础处理电路中发送的数据,具体可为所述处理后的输入数据中的目标数据,该目标数据具体可为绝对值大于预设阈值的数据,也可为非0数据等等。 The processed first input data or second input data may be processed input data or may be input data before processing. For example, the first input data is a distribution data block, such as the matrix data block in the above example.
Figure PCTCN2019075979-appb-000017
After processing by the first mapping circuit, the processed distribution data block can be obtained, and the processed distribution data block can be the original matrix data block.
Figure PCTCN2019075979-appb-000018
Can also be a compressed matrix data block
Figure PCTCN2019075979-appb-000019
It should be understood that, in order to reduce the transmission of data amount and the data processing efficiency in the basic processing circuit, preferably, the processed input data (such as processed basic data block or partial broadcast data block, etc.) should be after compression processing. The data. Preferably, the data sent by the main processing circuit to the basic processing circuit may be the target data in the processed input data, and the target data may be data with an absolute value greater than a preset threshold, or may be non-zero. Data and more.

相应地在基础处理电路中,第二映射电路可根据所述第一输入数据关联的第一标识数据以及所述第二输入数据关联的第二标识数据得到连接标识数据;该连接标识数据用于指示所述第一输入数据和所述第二输入数据中绝对值均大于第三阈值的数据,其中第三阈值为用户侧或装置侧自定义设置的,如0.05、0等。进一步地,所述第二映射电路可根据所述连接标识数据分别对接收的第一输入数据和第二输入数据进行处理,从而获得处理后的第一输入数据和处理后的第二输入数据。Correspondingly, in the basic processing circuit, the second mapping circuit may obtain connection identification data according to the first identification data associated with the first input data and the second identification data associated with the second input data; the connection identification data is used for And indicating that the absolute value of the first input data and the second input data are greater than a third threshold, wherein the third threshold is customized by the user side or the device side, such as 0.05, 0, and the like. Further, the second mapping circuit may process the received first input data and the second input data according to the connection identification data, thereby obtaining the processed first input data and the processed second input data.

例如,第一输入数据为矩阵数据块

Figure PCTCN2019075979-appb-000020
第二输入数据块同样也为矩阵数据块
Figure PCTCN2019075979-appb-000021
经过第一映射电路处理后可获得该第一输入数据关联的第一标识数据块
Figure PCTCN2019075979-appb-000022
以及处理后的第一输入数据块
Figure PCTCN2019075979-appb-000023
相应地获得该第二输入数据关联的第二标识数据块
Figure PCTCN2019075979-appb-000024
处理后的第二输入数据块为
Figure PCTCN2019075979-appb-000025
相应地,为提高数据传输速率,主处理电路中仅可将处理后的第一输入数据块中的目标数据1,0.06和0.5、以及该第一输入数据块关联的第一标识数据块发送给基础处理电路;同时,将处理后的第二输入数据块中的目标数据1,1.1,0.6,0.3和0.5,以及该第二输入数据块关联的第二标识数据块发送给基础处理电路。 For example, the first input data is a matrix data block
Figure PCTCN2019075979-appb-000020
The second input data block is also a matrix data block
Figure PCTCN2019075979-appb-000021
Obtaining, by the first mapping circuit, the first identification data block associated with the first input data
Figure PCTCN2019075979-appb-000022
And the processed first input data block
Figure PCTCN2019075979-appb-000023
Correspondingly obtaining the second identification data block associated with the second input data
Figure PCTCN2019075979-appb-000024
The processed second input data block is
Figure PCTCN2019075979-appb-000025
Correspondingly, in order to increase the data transmission rate, only the target data 1, 0.06 and 0.5 in the processed first input data block and the first identification data block associated with the first input data block may be sent to the main processing circuit. The basic processing circuit; at the same time, the target data 1, 1.1, 0.6, 0.3 and 0.5 in the processed second input data block and the second identification data block associated with the second input data block are sent to the basic processing circuit.

相应地,基础处理电路在接收到上述数据后,可通过第二映射电路对上述第一标识数据块和第二标识数据块进行逐元素与操作,得到连接标识数据块

Figure PCTCN2019075979-appb-000026
相应地,第二映射电路利用该连接标识数据块分别对所述处理后的第一输入数据块和处理后的第二输入数据块进行处理,从而获得处理后的第一输入数据块为
Figure PCTCN2019075979-appb-000027
处理后的第二输入数据块为
Figure PCTCN2019075979-appb-000028
其中,在基础处理电路中可根据第一标识数据块以及接收的第一数据块中的目标数据,确定出该目标数据对应所在的第一数据块(即经过第一映射电路处理后的第一数据块);相应地,根据第二标识数据块以及接收的第二数据块中的目标数据,确定出该目标数据对应所在的第二数据块(即经过第一映射电路处理后的第二数据块);然后,在第二映射电路获知连接标识数据块后,利用该连接标识数据块分别与确定的第一数据块和确定的第二数据块进行逐元素与操作,以获得经由第二映射电路处理后的第一数据块和处理后的第二数据块。 Correspondingly, after receiving the foregoing data, the basic processing circuit may perform the element-by-element operation on the first identification data block and the second identification data block by using the second mapping circuit to obtain the connection identification data block.
Figure PCTCN2019075979-appb-000026
Correspondingly, the second mapping circuit processes the processed first input data block and the processed second input data block respectively by using the connection identification data block, so as to obtain the processed first input data block as
Figure PCTCN2019075979-appb-000027
The processed second input data block is
Figure PCTCN2019075979-appb-000028
The first processing block is configured to determine, according to the first identification data block and the target data in the received first data block, the first data block corresponding to the target data (ie, the first processed by the first mapping circuit) Correspondingly, determining, according to the second identification data block and the target data in the received second data block, the second data block corresponding to the target data (ie, the second data processed by the first mapping circuit) Blocking; then, after the second mapping circuit learns the connection identification data block, performing the element-by-element AND operation with the determined first data block and the determined second data block by using the connection identification data block, respectively, to obtain the second mapping The first data block after the circuit processing and the second data block after processing.

第三实施例中:In the third embodiment:

所述主处理电路中并不会设置第一映射电路,但所述主处理电路可将第三输入数据以及预存的所述第三输入数据关联的第三标识数据发送至与其连接的基础处理电路中。该基础处理电路中设置有第二映射电路。下面阐述第二映射电路涉及的数据压缩处理的具体实施例。The first mapping circuit is not disposed in the main processing circuit, but the main processing circuit may send the third input data and the pre-stored third identification data associated with the third input data to the basic processing circuit connected thereto in. A second mapping circuit is provided in the basic processing circuit. A specific embodiment of the data compression process involved in the second mapping circuit is explained below.

应理解的,所述第三输入数据包括但不限于基础数据块、部分广播数据块、广播数据块等。同样地,在神经网络处理器中,该第三输入数据也可为至少一个权值,和/或至少一个输入神经,本申请不做限定。It should be understood that the third input data includes, but is not limited to, an elementary data block, a partial broadcast data block, a broadcast data block, and the like. Similarly, in the neural network processor, the third input data may also be at least one weight, and/or at least one input nerve, which is not limited herein.

在第二映射电路中,所述第二映射电路可根据接收的第三输入数据关联的第三标识数据对所述第三输入数据进行处理,从而获得处理后的第三输入数据,以便后续对处理后的第三输入数据执行相关运算 操作,如内积运算等。In the second mapping circuit, the second mapping circuit may process the third input data according to the third identification data associated with the received third input data, thereby obtaining the processed third input data, so as to be subsequently The processed third input data performs related arithmetic operations, such as inner product operations.

例如,第二映射电路接收的第三输入数据为矩阵数据块

Figure PCTCN2019075979-appb-000029
相应地预存的该第三输入数据关联的第三标识数据块(也成mask矩阵数据块)为
Figure PCTCN2019075979-appb-000030
进一步地,第二映射电路根据第三标识数据块对第三输入数据块进行处理得到处理后的第三输入数据块具体为
Figure PCTCN2019075979-appb-000031
For example, the third input data received by the second mapping circuit is a matrix data block.
Figure PCTCN2019075979-appb-000029
Correspondingly storing the third identification data block associated with the third input data (also into a mask matrix data block) is
Figure PCTCN2019075979-appb-000030
Further, the third mapping circuit processes the third input data block according to the third identification data block, and the processed third input data block is specifically
Figure PCTCN2019075979-appb-000031

此外,本发明实施例中提到的输入神经元和输出神经元并非是指整个神经网络的输入层中的神经元和输出层中的神经元,而是对于神经网络中任意相邻的两层神经元,处于网络前馈运算下层中的神经元即为输入神经元,处于网络前馈运算上层中的神经元即为输出神经元。以卷积神经网络为例,假设一个卷积神经网络有L层,K=1,2,3…L-1,对于第K层和第K+1层来说,第K层被称为输入层,该层中的神经元为上述输入神经元,第K+1层被称为输出层,该层中的神经元为上述输出神经元,即除了顶层之外,每一层都可以作为输入层,其下一层为对应的输出层。Furthermore, the input neurons and output neurons mentioned in the embodiments of the present invention do not refer to neurons in the input layer of the entire neural network and neurons in the output layer, but to any adjacent two layers in the neural network. Neurons, the neurons in the lower layer of the network feedforward operation are the input neurons, and the neurons in the upper layer of the network feedforward operation are the output neurons. Taking a convolutional neural network as an example, suppose a convolutional neural network has an L layer, K=1, 2, 3...L-1. For the Kth and K+1th layers, the Kth layer is called an input. The layer, the neurons in the layer are the above input neurons, the K+1 layer is called the output layer, and the neurons in the layer are the above-mentioned output neurons, that is, each layer can be used as an input except the top layer. Layer, the next layer is the corresponding output layer.

第四实施中:In the fourth implementation:

所述主处理电路中并不设置映射电路,在所述基础处理电路中设置有第一映射电路和第二映射电路。关于所述第一映射电路和第二映射电路的数据处理具体可参见前述第一实施例至第三实施例所述,这里不再赘述。A mapping circuit is not provided in the main processing circuit, and a first mapping circuit and a second mapping circuit are disposed in the basic processing circuit. For details about the data processing of the first mapping circuit and the second mapping circuit, refer to the foregoing first to third embodiments, and details are not described herein again.

可选的,还存在第五实施例。第五实施例中,所述基础处理电路中并不设置映射电路,将所述第一映射电路和第二映射电路均设置在主处理电路中,关于所述第一映射电路和第二映射电路的数据处理具体可参见前述第一实施例至第三实施例所述,这里不再赘述。即是,主处理电路中完成数据的压缩处理,将处理后的输入数据发送给基础处理电路,以便基础处理电路利用处理后的输入数据(具体可为处理后的神经元和处理后权值)执行相应地的运算操作。Alternatively, there is also a fifth embodiment. In the fifth embodiment, the mapping circuit is not disposed in the basic processing circuit, and the first mapping circuit and the second mapping circuit are both disposed in the main processing circuit, and the first mapping circuit and the second mapping circuit are For details of the data processing, refer to the foregoing first to third embodiments, and details are not described herein again. That is, the main processing circuit completes the compression processing of the data, and sends the processed input data to the basic processing circuit, so that the basic processing circuit utilizes the processed input data (specifically, the processed neurons and the processed weights) Perform the corresponding arithmetic operations.

下面阐述本申请涉及映射电路的具体结构示意图。如图5a和5b示出两种可能的映射电路。其中,如图5a所示的映射电路包括比较器和选择器。关于所述比较器和选择器的数量本申请不做限定。如图5a示出一个比较器和两个选择器,其中,所述比较器用于判定输入数据是否满足预设条件。该预设条件可为用户侧或设备侧自定义设置的,例如本申请上述的所述输入数据的绝对值大于或等于预设阈值。如果满足预设条件,则比较器可确定允许输出该输入数据,该输入数据对应关联的标识数据为1;否则可确定不输出该输入数据,或者默认该输入数据为0。相应地,此时该输入数据对应关联的标识数据为0。也即是,经过该比较器后,可获知输入数据关联的标识数据。The following is a detailed structural diagram of the mapping circuit involved in the present application. Two possible mapping circuits are shown in Figures 5a and 5b. Among them, the mapping circuit shown in FIG. 5a includes a comparator and a selector. Regarding the number of the comparators and selectors, the application is not limited. A comparator and two selectors are shown in Fig. 5a, wherein the comparator is used to determine whether the input data satisfies a preset condition. The preset condition may be customized for the user side or the device side. For example, the absolute value of the input data described above in the application is greater than or equal to a preset threshold. If the preset condition is met, the comparator may determine to allow output of the input data, the input data corresponding to the associated identification data being 1; otherwise, it may be determined that the input data is not output, or the input data is 0 by default. Correspondingly, the identification data corresponding to the input data at this time is 0. That is, after the comparator is passed, the identification data associated with the input data can be known.

进一步地,所述比较器对输入数据进行预设条件的判定后,可将获得的标识数据输入至选择器中,以便选择器利用该标识数据来决定是否输出相应地输入数据,即获得处理后的输入数据。Further, after the comparator determines the preset condition of the input data, the obtained identification data may be input to the selector, so that the selector uses the identification data to determine whether to output the corresponding input data, that is, after the processing is obtained. Input data.

如图5a,以所述输入数据为矩阵数据块为例,经过比较器可对该矩阵数据块中的每个数据进行预设条件的判定,从而可获得该矩阵数据块关联的标识数据块(mask矩阵)。进一步地,在第一选择器中可利用该标识数据块对所述矩阵数据块进行筛选,将所述矩阵数据块中绝对值大于或等于预设阈值(即满足预设条件)的数据进行保留,其余数据进行删除,以输出处理后的矩阵数据块。可选的,在第二选择 器中还可利用该标识数据块对其他输入数据(例如第二矩阵数据块)进行处理,例如进行逐元素与操作,以将该第二矩阵数据块中绝对值大于或等于预设阈值的数据进行保留,以输出处理后的第二矩阵数据块。As shown in FIG. 5a, taking the input data as a matrix data block as an example, a comparator can determine a predetermined condition for each data in the matrix data block, so that an identifier data block associated with the matrix data block can be obtained ( Mask matrix). Further, the matrix data block may be filtered by using the identifier data block in the first selector, and the data in the matrix data block whose absolute value is greater than or equal to a preset threshold (ie, a preset condition is satisfied) is reserved. The remaining data is deleted to output the processed matrix data block. Optionally, the identifier data block may also be used in the second selector to process other input data (for example, the second matrix data block), for example, performing an element-by-element AND operation to obtain an absolute value in the second matrix data block. Data greater than or equal to the preset threshold is reserved to output the processed second matrix data block.

应理解的,对应于上述第一和第二实施例中,所述第一映射电路的具体结构可包括至少一个比较器和至少一个选择器,例如上例中图5a中的比较器和第一选择器;所述第二映射电路的具体结果可包括一个或多个选择器,例如上例中图5a的第二选择器。It should be understood that, corresponding to the above first and second embodiments, the specific structure of the first mapping circuit may include at least one comparator and at least one selector, such as the comparator and the first in FIG. 5a in the above example. a selector; the specific result of the second mapping circuit may include one or more selectors, such as the second selector of Figure 5a in the above example.

如图5b,示出另一种映射电路的结构示意图。如图5b,所述映射电路包括选择器,所述选择器的数量不做限定,可为一个,也可为多个。具体的,所述选择器用于根据输入数据所关联的标识数据来对所述输入数据进行选择,以将所述输入数据中绝对值大于或等于预设阈值的数据进行输出,其余数据进行删除/不输出,从而获得处理后的输入数据。As shown in FIG. 5b, a schematic structural diagram of another mapping circuit is shown. As shown in FIG. 5b, the mapping circuit includes a selector, and the number of the selectors is not limited, and may be one or multiple. Specifically, the selector is configured to select the input data according to the identification data associated with the input data, so as to output data in which the absolute value of the input data is greater than or equal to a preset threshold, and the remaining data is deleted/ Does not output, thus obtaining processed input data.

以所述输入数据为矩阵数据块为例,向所述映射电路输入该矩阵数据块以及该矩阵数据块关联的标识数据块,选择器可根据该标识数据块对所述矩阵数据块进行选择,将其绝对值大于或等于0的数据进行输出,其余数据不予输出,从而输出处理后的矩阵数据块。Taking the input data as a matrix data block as an example, the matrix data block and the identification data block associated with the matrix data block are input to the mapping circuit, and the selector may select the matrix data block according to the identification data block. The data whose absolute value is greater than or equal to 0 is output, and the remaining data is not output, thereby outputting the processed matrix data block.

应理解的,如图5b所示的结构可应用于上述第三实施例中的第二映射电路,即是上述第三实施例中的第二映射电路的具体结果可包括至少一个选择器。同理,对于主处理电路和基础处理电路中设计的第一映射电路和第二映射电路可按照如图5a和图5b所示的功能部件进行交叉组合或部件拆分,本申请不做限定。It should be understood that the structure shown in FIG. 5b can be applied to the second mapping circuit in the third embodiment described above, that is, the specific result of the second mapping circuit in the third embodiment described above may include at least one selector. For the same reason, the first mapping circuit and the second mapping circuit designed in the main processing circuit and the basic processing circuit may be cross-combined or split according to the functional components shown in FIG. 5a and FIG. 5b, which is not limited in this application.

下面提供一种采用如图1a所示神经网络的正向运算,神经网的装置实现计算的方法,该计算的方法具体可以为神经网络的计算方式,例如神经网络的训练,在实际应用中,正向运算依据不同的输入数据可以执行矩阵乘矩阵、卷积运算、激活运算、变换运算等等运算,上述运算均可以采用如图1a所示的装置实现。The following provides a method for implementing calculation using a neural network forward operation as shown in FIG. 1a, which may be a neural network calculation method, such as a neural network training, in practical applications, The forward operation can perform matrix multiplication matrix, convolution operation, activation operation, transformation operation, and the like according to different input data, and the above operations can be implemented by using the apparatus shown in FIG. 1a.

主处理电路的第一映射电路先对数据进行压缩处理然后由控制电路传输给基础处理电路运算,例如,主处理电路的第一映射电路可以对数据进行压缩处理后再传输给基础处理电路,其优点是可以减少传输数据的数据量,减少传输的总比特数量,基础处理电路执行数据运算的效率也更高,功耗更低。The first mapping circuit of the main processing circuit first compresses the data and then transmits the data to the basic processing circuit for calculation. For example, the first mapping circuit of the main processing circuit can compress the data and then transmit the data to the basic processing circuit. The advantage is that the amount of data transmitted data can be reduced, the total number of bits transmitted is reduced, and the basic processing circuit performs data operations more efficiently and consumes less power.

主处理电路将待计算的数据传输到全部或者一部分基础处理电路上;以矩阵乘以向量计算为例,主处理电路的控制电路可以将矩阵数据拆分每列作为一个基础数据,例如m*n矩阵,可以拆分成n个m行的向量,主处理电路的控制电路将拆分后的n个m行的向量分发给多个基础处理电路。对于向量,主处理电路的控制电路可以将向量整体广播给每个基础处理电路。如果m的值比较大,那么控制电路可以先将m*n矩阵拆分成x*n个向量,以x=2为例,具体的可以拆分成,2n个向量,每个向量包含m/2行,即将n个m行的向量中每个向量均分成2个向量,以第一行为例,如n个m行的向量的第一个向量为1000行,那么均分成2个向量可以为,将前500行组成第一向量,将后500行组成第二向量,控制电路通过2个广播将2个向量广播给多个基础处理电路。The main processing circuit transmits the data to be calculated to all or a part of the basic processing circuit; taking the matrix multiplication by the vector calculation as an example, the control circuit of the main processing circuit can split the matrix data into each column as a basic data, for example, m*n The matrix can be split into n m rows of vectors, and the control circuit of the main processing circuit distributes the split n m rows of vectors to a plurality of basic processing circuits. For vectors, the control circuitry of the main processing circuit can broadcast the vector as a whole to each of the underlying processing circuits. If the value of m is relatively large, the control circuit may first split the m*n matrix into x*n vectors, taking x=2 as an example, and the specific one may be split into 2n vectors, each vector containing m/ 2 rows, that is, each vector of n m rows of vectors is divided into 2 vectors. In the first behavior example, if the first vector of n m rows of vectors is 1000 rows, then the two vectors can be divided into 2 vectors. The first 500 lines are composed of the first vector, and the last 500 lines are composed of the second vector. The control circuit broadcasts 2 vectors to the plurality of basic processing circuits through 2 broadcasts.

所述数据传输的方式可以是广播或者分发,或者其他任何可能的传输方式;The manner of data transmission may be broadcast or distribution, or any other possible transmission method;

基础处理电路接收到数据后,先通过第二映射电路对数据进行处理,再执行运算,得到运算结果;After receiving the data, the basic processing circuit first processes the data through the second mapping circuit, and then performs an operation to obtain an operation result;

基础处理电路将运算结果传输回主处理电路;The basic processing circuit transmits the operation result back to the main processing circuit;

所述运算结果可以是中间运算结果,也可以是最终运算结果。The operation result may be an intermediate operation result or a final operation result.

使用如图1a所示装置可完成张量乘张量的运算,所述张量和前文所述的数据块相同,其可为矩阵、 向量、三维数据块、四位数据块以及高维数据块中的任一项或多项的组合;下面如图2和2b分别示出矩阵乘向量和矩阵乘矩阵运算的具体实现方法。The tensor multiplication tensor operation can be accomplished using the apparatus shown in Figure 1a, which is the same as the data block described above, which can be a matrix, a vector, a three-dimensional data block, a four-bit data block, and a high-dimensional data block. A combination of any one or more of the following; a specific implementation of the matrix multiplication vector and the matrix multiplication matrix operation is shown in Figures 2 and 2b, respectively.

使用如图1a所示装置完成矩阵乘向量的运算;(矩阵乘向量可以是矩阵中的每一行分别与向量进行内积运算,并将这些结果按对应行的顺序摆放成一个向量。)The operation of the matrix multiplication vector is performed using the apparatus as shown in Fig. 1a; (the matrix multiplication vector can be an inner product of each row in the matrix with the vector, and the results are placed into a vector in the order of the corresponding rows.)

下面描述计算尺寸是M行L列的矩阵S和长度是L的向量P的乘法的运算,如下图2a所示,(矩阵S中的每一行与向量P长度相同,他们中的数据按位置一一对应)所述神经网络计算装置拥有K个基础处理电路:The following describes the operation of calculating the multiplication of the matrix S of the M rows and L columns and the vector P of the length L, as shown in Fig. 2a, (each row in the matrix S has the same length as the vector P, and the data in them is in position one Correspondingly, the neural network computing device has K basic processing circuits:

参阅图2,图2提供了了一种矩阵乘向量的实现方法,具体可以包括:Referring to FIG. 2, FIG. 2 provides a method for implementing a matrix multiplication vector, which may specifically include:

步骤S201、主处理电路的控制电路将矩阵S中的每一行数据分发到K个基础处理电路中的某一个上,基础处理电路将接收到的分发数据保存在基础处理电路的片上缓存和/或寄存器中;Step S201, the control circuit of the main processing circuit distributes each row of data in the matrix S to one of the K basic processing circuits, and the basic processing circuit saves the received distribution data in an on-chip buffer of the basic processing circuit and/or In the register;

在一种可选的方案中,所述矩阵S的数据为处理后的数据。具体的,主处理电路启用第一映射电路对矩阵S进行处理,从而获得处理后的矩阵S以及该矩阵S关联的第一标识(mask)矩阵。或者,主处理电路的第一映射电路根据预存的矩阵S关联的第一mask矩阵对矩阵S进行处理,得到处理后的矩阵S。进一步地,通过控制电路将处理后的矩阵S中的每一行数据以及该行数据对应在第一mask矩阵中关联的标识数据一起发送给K个基础处理电路中的某一个或多个中。在主处理电路向基础处理电路发送数据时,具体可将处理后的矩阵S中绝对值大于预设阈值的数据,或者非0数据发送给基础处理电路,以减少数据传输量。例如,分发到第i个基础处理电路中处理后的矩阵S中的行的集合为Ai,共有Mi行;相应地,同时也分发有与Ai对应的标识矩阵Bi,Bi为第一mask矩阵的一部分,共有大于或等于Mi行。In an optional solution, the data of the matrix S is processed data. Specifically, the main processing circuit enables the first mapping circuit to process the matrix S, thereby obtaining the processed matrix S and a first mask matrix associated with the matrix S. Alternatively, the first mapping circuit of the main processing circuit processes the matrix S according to the first mask matrix associated with the pre-stored matrix S to obtain the processed matrix S. Further, each row data in the processed matrix S and the row data corresponding to the identification data associated in the first mask matrix are sent to one or more of the K basic processing circuits by the control circuit. When the main processing circuit sends data to the basic processing circuit, the data in the processed matrix S whose absolute value is greater than the preset threshold or the non-zero data may be sent to the basic processing circuit to reduce the data transmission amount. For example, the set of rows in the matrix S processed in the i-th basic processing circuit is Ai, and the Mi rows are shared; correspondingly, the identification matrix Bi corresponding to Ai is also distributed, and Bi is the first mask matrix. Part of a total of greater than or equal to the Mi line.

在一种可选方案中,如果矩阵S的行数M<=K则,主处理电路的控制电路给K个基础处理电路分别分发S矩阵的一行;可选的,同时还发送由该行对应在第一标识矩阵中的行的标识数据;In an alternative, if the number of rows of the matrix S is M<=K, the control circuit of the main processing circuit separately distributes one row of the S matrix to the K basic processing circuits; optionally, the corresponding row is also sent by the row. Identification data of rows in the first identification matrix;

在一种可选方案中,如果矩阵S的行数M>K,则主处理电路的控制电路给每个基础处理电路分别分发S矩阵中一行或多行的数据。可选的,同时还发送由该一行或几行对应在第一标识矩阵中的行的标识数据;In an alternative, if the number of rows of the matrix S is M > K, the control circuitry of the main processing circuit distributes one or more rows of data in the S matrix to each of the underlying processing circuits. Optionally, the identifier data corresponding to the row in the first identifier matrix by the one or several rows is also sent;

分发到第i个基础处理电路的S中的行的集合为Ai,共有Mi个行,如图2c表示第i个基础处理电路上将要执行的计算。The set of rows in S distributed to the i-th base processing circuit is Ai, sharing a total of Mi rows, as shown in Figure 2c, which is to be performed on the i-th base processing circuit.

在一种可选方案中,在每个基础处理电路中,例如第i个基础处理电路中,可以将接收到的分发数据例如矩阵Ai保存在第i个基础处理电路的寄存器和/或片上缓存中;优点是减少了之后的分发数据的数据传输量,提高了计算效率,降低了功耗。In an alternative, in each of the basic processing circuits, such as the i-th basic processing circuit, the received distribution data, such as the matrix Ai, may be stored in a register and/or an on-chip buffer of the i-th base processing circuit. The advantage is to reduce the amount of data transmission of the distributed data afterwards, improve the calculation efficiency, and reduce the power consumption.

步骤S202、主处理电路的控制电路将向量P中的各部分以广播的方式传输给K个基础处理电路;Step S202, the control circuit of the main processing circuit transmits the parts in the vector P to the K basic processing circuits in a broadcast manner;

在一种可选方案中,所述向量P的数据(各部分)可为处理后的数据。具体的,主处理电路启用第一映射电路对向量P进行处理,从而获得处理后的向量P以及该向量P关联的第二标识(mask)矩阵。或者,主处理电路的第一映射电路根据预存的向量P关联的第二mask矩阵对向量P进行处理,得到处理后的向量P。进一步地,通过控制电路将处理后的向量P中的数据(即各部分)以及该数据对应在第二mask矩阵中对应关联的标识数据一起发送给K个基础处理电路中的某一个或多个中。在主处理电路向基础处理电路发送数据时,具体可将处理后的向量P中绝对值大于预设阈值的数据,或者非0数据发送给基础处理电路,以减少数据传输量。In an alternative, the data (parts) of the vector P may be processed data. Specifically, the main processing circuit enables the first mapping circuit to process the vector P, thereby obtaining the processed vector P and a second mask matrix associated with the vector P. Alternatively, the first mapping circuit of the main processing circuit processes the vector P according to the second mask matrix associated with the pre-stored vector P to obtain the processed vector P. Further, the data in the processed vector P (ie, each part) and the corresponding data corresponding to the data in the second mask matrix are sent to one or more of the K basic processing circuits by the control circuit. in. When the main processing circuit sends data to the basic processing circuit, the data of the processed vector P having an absolute value greater than a preset threshold or non-zero data may be specifically sent to the basic processing circuit to reduce the data transmission amount.

在一种可选方案中,主处理电路的控制电路可以将向量P中各部分只广播一次到各个基础处理电路 的寄存器或者片上缓存中,第i个基础处理电路对这一次得到的向量P的数据进行充分地复用,完成对应与矩阵Ai中每一行的内积运算。优点是,减少从主处理电路到基础处理电路的向量P的重复传输的数据传输量,提高执行效率,降低传输功耗。In an alternative, the control circuit of the main processing circuit can broadcast each part of the vector P only once to the register or the on-chip buffer of each basic processing circuit, and the i-th basic processing circuit obtains the vector P of this time. The data is fully multiplexed to complete the inner product operation corresponding to each row in the matrix Ai. The advantage is that the data transmission amount of the repeated transmission of the vector P from the main processing circuit to the basic processing circuit is reduced, the execution efficiency is improved, and the transmission power consumption is reduced.

在一种可选方案中,主处理电路的控制电路可以将向量P中各部分多次广播到各个基础处理电路的寄存器或者片上缓存中,第i个基础处理电路对每次得到的向量P的数据不进行复用,分次完成对应于矩阵Ai中的每一行的内积运算;优点是,减少基础处理电路内部的单次传输的向量P的数据传输量,并可以降低基础处理电路缓存和/或寄存器的容量,提高执行效率,降低传输功耗,降低成本。In an alternative, the control circuit of the main processing circuit can broadcast each part of the vector P to the register or the on-chip buffer of each basic processing circuit multiple times, and the i-th basic processing circuit obtains the vector P for each time. The data is not multiplexed, and the inner product operation corresponding to each row in the matrix Ai is completed in stages; the advantage is that the data transmission amount of the vector P of the single transmission inside the basic processing circuit is reduced, and the basic processing circuit buffer and the lower limit can be reduced. / or the capacity of the register to improve execution efficiency, reduce transmission power consumption, and reduce costs.

在一种可选方案中,主处理电路的控制电路可以将向量P中各部分多次广播到各个基础处理电路的寄存器或者片上缓存中,第i个基础处理电路对每次得到的向量P的数据进行部分复用,完成对应于矩阵Ai中的每一行的内积运算;优点是,减少从主处理电路到基础处理电路的数据传输量,也减少基础处理电路内部的数据传输量,提高执行效率,降低传输功耗。In an alternative, the control circuit of the main processing circuit can broadcast each part of the vector P to the register or the on-chip buffer of each basic processing circuit multiple times, and the i-th basic processing circuit obtains the vector P for each time. The data is partially multiplexed to complete the inner product operation corresponding to each row in the matrix Ai; the advantage is that the data transmission amount from the main processing circuit to the basic processing circuit is reduced, and the data transmission amount inside the basic processing circuit is also reduced, and the execution is improved. Efficiency, reducing transmission power consumption.

步骤S203、K个基础处理电路的内积运算器电路计算矩阵S和向量P的数据的内积,例如第i个基础处理电路,计算矩阵Ai的数据和向量P的数据的内积;Step S203, the inner product operator circuit of the K basic processing circuits calculates an inner product of the data of the matrix S and the vector P, for example, the i-th basic processing circuit, and calculates an inner product of the data of the matrix Ai and the data of the vector P;

在一种具体实施方案中,所述基础处理电路接收到处理后的矩阵S中的数据以及该数据对应在第一mask矩阵中关联的标识数据;同时还接收到处理后的向量P中的数据。相应地,基础处理电路启用第二映射电路根据接收的第一mask矩阵中的标识数据对接收的向量P的数据进行处理,得到处理后的向量P的数据。进一步地,该基础处理电路启用内积运算器电路对接收的处理后的矩阵S中的数据和处理后的向量P的数据执行内积运算,得到内积运算的结果。例如,第i个基础处理电路,接收到矩阵Ai、该Ai关联的标识矩阵Bi以及向量P;此时可启用第二映射电路利用Bi对向量P进行处理得到处理后的向量P;再启用内积运算器电路对矩阵Ai和处理后的向量P进行内积运算。In a specific implementation, the basic processing circuit receives the data in the processed matrix S and the data corresponding to the identification data associated in the first mask matrix; and also receives the data in the processed vector P. . Correspondingly, the basic processing circuit enables the second mapping circuit to process the data of the received vector P according to the identification data in the received first mask matrix to obtain the data of the processed vector P. Further, the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the received data in the processed matrix S and the processed vector P data to obtain a result of the inner product operation. For example, the i-th basic processing circuit receives the matrix Ai, the identification matrix Bi associated with the Ai, and the vector P; at this time, the second mapping circuit can be enabled to process the vector P by using the Bi to obtain the processed vector P; The product operator circuit performs an inner product operation on the matrix Ai and the processed vector P.

在一种具体实施方案中,所述基础处理电路接收到处理后的向量P中的数据以及该数据对应在第二mask矩阵中关联的标识数据;同时还接收到处理后的矩阵S中的数据。相应地,基础处理电路启用第二映射电路根据接收的第二mask矩阵中的标识数据对接收的矩阵S的数据进行处理,得到处理后的矩阵S的数据。进一步地,该基础处理电路启用内积运算器电路对接收的处理后的向量P的数据和处理后的矩阵S中的数据执行内积运算,得到内积运算的结果。例如,第i个基础处理电路,接收到矩阵Ai、处理后的向量P以及该向量P关联的第二标识矩阵;此时可启用第二映射电路利用第二标识矩阵对Ai进行处理得到处理后的矩阵Ai;再启用内积运算器电路对处理后的矩阵Ai和处理后的向量P进行内积运算。In a specific implementation, the basic processing circuit receives the data in the processed vector P and the data corresponding to the identification data associated in the second mask matrix; and also receives the data in the processed matrix S. . Correspondingly, the basic processing circuit enables the second mapping circuit to process the data of the received matrix S according to the identification data in the received second mask matrix to obtain the data of the processed matrix S. Further, the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the received data of the processed vector P and the processed data in the matrix S to obtain a result of the inner product operation. For example, the i-th basic processing circuit receives the matrix Ai, the processed vector P, and the second identification matrix associated with the vector P; at this time, the second mapping circuit can be enabled to process the Ai by using the second identification matrix. The matrix Ai; the inner product operator circuit is further enabled to perform an inner product operation on the processed matrix Ai and the processed vector P.

在一种具体实施方案中,所述基础处理电路接收到处理后的矩阵S中的数据以及该数据对应在第一mask矩阵中关联的标识数据;同时还接收到处理后的向量P中的数据以及该数据对应在第二mask矩阵中关联的标识数据。相应地,基础处理电路启用第二映射电路根据接收的第一mask矩阵中的标识数据和第二mask矩阵中的标识数据得到关系标识矩阵(也可称为关系连接矩阵);然后利用关系标识矩阵中的标识数据分别对接收的矩阵S中的数据和向量P中的数据进行处理,得到处理后的矩阵S的数据和处理后的向量P的数据。进一步地,启用内积运算器电路对处理后的矩阵S中的数据和处理后的向量P的数据执行内积运算,得到内积运算的结果。例如,第i个基础处理电路,接收到矩阵Ai、该Ai关联的标识矩阵Bi、向量P以及向量P关联的第二标识矩阵;此时可启用第二映射电路利用Bi和第二标识矩阵获得关系标识矩阵,再利用该关系标识矩阵同时或分别对矩阵Ai和向量P进行处理,得到处理后的矩阵Ai和处理后的向量P。接着,启用内积运算器电路对处理后的矩阵Ai和处理后的向量P进行内积 运算。In a specific implementation, the basic processing circuit receives the data in the processed matrix S and the data corresponding to the identification data associated in the first mask matrix; and also receives the data in the processed vector P. And the data corresponds to the identification data associated in the second mask matrix. Correspondingly, the basic processing circuit enables the second mapping circuit to obtain a relationship identification matrix (also referred to as a relational connection matrix) according to the identification data in the received first mask matrix and the identification data in the second mask matrix; and then use the relationship identification matrix The identification data in the data is processed on the data in the received matrix S and the data in the vector P, respectively, to obtain the data of the processed matrix S and the data of the processed vector P. Further, the inner product operator circuit is enabled to perform an inner product operation on the data in the processed matrix S and the processed vector P data to obtain a result of the inner product operation. For example, the i-th basic processing circuit receives the matrix Ai, the identification matrix Bi associated with the Ai, the vector P, and the second identification matrix associated with the vector P; at this time, the second mapping circuit can be enabled to obtain the second identification matrix by using the Bi and the second identification matrix. The relationship identification matrix is used to process the matrix Ai and the vector P simultaneously or separately to obtain the processed matrix Ai and the processed vector P. Next, the inner product operator circuit is enabled to perform an inner product operation on the processed matrix Ai and the processed vector P.

步骤S204、K个基础处理电路的累加器电路将内积运算的结果进行累加得到累加结果,将累加结果以定点类型形式传输回主处理电路。Step S204: The accumulator circuit of the K basic processing circuits accumulates the result of the inner product operation to obtain an accumulated result, and transmits the accumulated result to the main processing circuit in a fixed point type.

在一种可选方案中,可以将每次基础处理电路执行内积运算得到的部分和(部分和即累加结果的一部分,例如累加结果为:F1*G1+F2*G2+F3*G3+F4*G4+F5*G5,那么部分和可以为:F1*G1+F2*G2+F3*G3的值)传输回主处理电路进行累加;优点是,减少了基础处理电路内部的运算量,提高基础处理电路的运算效率。In an alternative, each part of the basic processing circuit may perform an inner product operation to obtain a part and (partial and part of the accumulated result, for example, the accumulated result is: F1*G1+F2*G2+F3*G3+F4 *G4+F5*G5, then the part and can be: the value of F1*G1+F2*G2+F3*G3) is transferred back to the main processing circuit for accumulation; the advantage is that the calculation amount inside the basic processing circuit is reduced, and the basis is improved. The computational efficiency of the processing circuit.

在一种可选方案中,也可以将每次基础处理电路执行的内积运算得到的部分和保存在基础处理电路的寄存器和/或片上缓存中,累加结束之后传输回主处理电路;优点是,减少了基础处理电路和主处理电路之间的数据传输量,提高了运算效率,降低了数据传输功耗。In an alternative, the part obtained by the inner product operation performed by each basic processing circuit and the register and/or the on-chip buffer stored in the basic processing circuit may be transferred to the main processing circuit after the accumulation is completed; The data transmission between the basic processing circuit and the main processing circuit is reduced, the operation efficiency is improved, and the data transmission power consumption is reduced.

在一种可选方案中,也可以将每次基础处理电路执行的内积运算得到的部分和在部分情况下保存在基础处理电路的寄存器和/或片上缓存中进行累加,部分情况下传输到主处理电路进行累加,累加结束之后传输回主处理电路;优点是,减少了基础处理电路和主处理电路之间的数据传输量,提高了运算效率,降低了数据传输功耗,减少了基础处理电路内部的运算量,提高基础处理电路的运算效率。In an alternative, it is also possible to accumulate the portion obtained by the inner product operation performed by each basic processing circuit and, in some cases, the register and/or the on-chip buffer of the basic processing circuit, and in some cases transmit to The main processing circuit performs accumulation, and is transferred back to the main processing circuit after the accumulation is completed; the advantage is that the data transmission amount between the basic processing circuit and the main processing circuit is reduced, the operation efficiency is improved, the data transmission power consumption is reduced, and the basic processing is reduced. The amount of calculation inside the circuit improves the computational efficiency of the basic processing circuit.

参阅图2b,使用如图1a所示的装置完成矩阵乘矩阵的运算;Referring to Figure 2b, the operation of the matrix multiplication matrix is performed using the apparatus as shown in Figure 1a;

下面描述计算尺寸是M行L列的矩阵S和尺寸是L行N列的矩阵P的乘法的运算,(矩阵S中的每一行与矩阵P的每一列长度相同,如图2d所示)所述神经网络计算装置拥有K个基础处理电路:The operation of calculating the multiplication of the matrix S of the M rows and L columns and the matrix P of the size of the L rows and N columns is described below (each row in the matrix S is the same length as each column of the matrix P, as shown in Fig. 2d). The neural network computing device has K basic processing circuits:

步骤S201b、主处理电路的控制电路将矩阵S中的每一行数据分发到K个基础处理电路中的某一个上,基础处理电路将接收到的数据保存在片上缓存和/或寄存器中;Step S201b, the control circuit of the main processing circuit distributes each row of data in the matrix S to one of the K basic processing circuits, and the basic processing circuit saves the received data in an on-chip buffer and/or a register;

在一种可选的方案中,所述矩阵S的数据为处理后的数据。具体的,主处理电路启用第一映射电路对矩阵S进行处理,从而获得处理后的矩阵S以及该矩阵S关联的第一标识(mask)矩阵。或者,主处理电路的第一映射电路根据预存的矩阵S关联的第一mask矩阵对矩阵S进行处理,得到处理后的矩阵S。进一步地,通过控制电路将处理后的矩阵S中的每一行数据以及该行数据对应在第一mask矩阵中对应关联的标识数据一起发送给K个基础处理电路中的某一个或多个中。在主处理电路向基础处理电路发送数据时,具体可将处理后的矩阵S中绝对值大于预设阈值的数据,或者非0数据发送给基础处理电路,以减少数据传输量。In an optional solution, the data of the matrix S is processed data. Specifically, the main processing circuit enables the first mapping circuit to process the matrix S, thereby obtaining the processed matrix S and a first mask matrix associated with the matrix S. Alternatively, the first mapping circuit of the main processing circuit processes the matrix S according to the first mask matrix associated with the pre-stored matrix S to obtain the processed matrix S. Further, each row data in the processed matrix S and the row data corresponding to the corresponding associated identification data in the first mask matrix are sent to one or more of the K basic processing circuits by the control circuit. When the main processing circuit sends data to the basic processing circuit, the data in the processed matrix S whose absolute value is greater than the preset threshold or the non-zero data may be sent to the basic processing circuit to reduce the data transmission amount.

在一种可选方案中,如果S的行数M<=K则,主处理电路的控制电路给M个基础处理电路分别分发S矩阵的一行;可选的,同时还发送由该行对应在第一标识矩阵中的行的标识数据;In an alternative, if the number of rows of S is M<=K, the control circuit of the main processing circuit respectively distributes one row of the S matrix to the M basic processing circuits; optionally, the corresponding row is also sent by the row. Identification data of a row in the first identification matrix;

在一种可选方案中,如果S的行数M>K,主处理电路的控制电路给每个基础处理电路分别分发S矩阵中一行或多行的数据。可选的,同时还发送由该一行或几行对应在第一标识矩阵中的行的标识数据;In an alternative, if the number of rows of S is M > K, the control circuitry of the main processing circuit distributes one or more rows of data in the S matrix to each of the underlying processing circuits. Optionally, the identifier data corresponding to the row in the first identifier matrix by the one or several rows is also sent;

S中有Mi行分发到第i个基础处理电路,这Mi行的集合称为Ai,如图2e表示第i个基础处理电路上将要执行的计算。The Mi line in S is distributed to the i-th base processing circuit, and the set of Mi lines is called Ai, and the calculation to be performed on the i-th basic processing circuit is shown in Fig. 2e.

在一种可选方案中,在每个基础处理电路中,例如第i个基础处理电路中:In an alternative, in each of the basic processing circuits, such as the i-th basic processing circuit:

接收的由主处理电路分发的矩阵Ai,将矩阵Ai保存在第i个基础处理电路寄存器和/或片上缓存中;优点是减少了之后的数据传输量,提高了计算效率,降低了功耗。The received matrix Ai distributed by the main processing circuit stores the matrix Ai in the i-th basic processing circuit register and/or the on-chip buffer; the advantage is that the amount of data transmission afterwards is reduced, the calculation efficiency is improved, and the power consumption is reduced.

步骤S202b、主处理电路的控制电路将矩阵P中各部分以广播的方式传输给各个基础处理电路;Step S202b, the control circuit of the main processing circuit transmits each part of the matrix P to each basic processing circuit in a broadcast manner;

在一种可选方案中,所述矩阵P的数据(各部分)可为处理后的数据。具体的,主处理电路启用第一映射电路对矩阵P进行处理,从而获得处理后的矩阵P以及该矩阵P关联的第二标识(mask)矩阵。 或者,主处理电路的第一映射电路根据预存的矩阵P关联的第二mask矩阵对矩阵P进行处理,得到处理后的矩阵P。进一步地,通过控制电路将处理后的矩阵P中的数据(即各部分)以及该数据对应在第二mask矩阵中对应关联的标识数据一起发送给K个基础处理电路中的某一个或多个中。在主处理电路向基础处理电路发送数据时,具体可将处理后的矩阵P中绝对值大于预设阈值的数据,或者非0数据发送给基础处理电路,以减少数据传输量。In an alternative, the data (parts) of the matrix P can be processed data. Specifically, the main processing circuit enables the first mapping circuit to process the matrix P, thereby obtaining the processed matrix P and a second matrix of the matrix associated with the matrix P. Alternatively, the first mapping circuit of the main processing circuit processes the matrix P according to the second mask matrix associated with the pre-stored matrix P to obtain the processed matrix P. Further, the data in the processed matrix P (ie, each part) and the corresponding data corresponding to the data in the second mask matrix are sent to one or more of the K basic processing circuits by the control circuit. in. When the main processing circuit sends data to the basic processing circuit, specifically, the data in the processed matrix P whose absolute value is greater than a preset threshold or non-zero data may be sent to the basic processing circuit to reduce the data transmission amount.

在一种可选方案中,可以将矩阵P中各部分只广播一次到各个基础处理电路的寄存器或者片上缓存中,第i个基础处理电路对这一次得到的矩阵P的数据进行充分地复用,完成对应与矩阵Ai中每一行的内积运算;本实施例中的复用具体可以为基础处理电路在计算中重复使用,例如矩阵P的数据的复用,可以是对矩阵P的数据再多次使用。In an alternative, each part of the matrix P can be broadcast only once to the registers of the respective basic processing circuits or the on-chip buffer, and the i-th basic processing circuit fully multiplexes the data of the matrix P obtained this time. The inner product operation corresponding to each row in the matrix Ai is completed; the multiplexing in this embodiment may be repeatedly used in the calculation by the basic processing circuit, for example, the multiplexing of the data of the matrix P, and may be the data of the matrix P. use many times.

在一种可选方案中,主处理电路的控制电路可以将矩阵P中各部分多次广播到各个基础处理电路的寄存器或者片上缓存中,第i个基础处理电路对每次得到的矩阵P的数据不进行复用,分次完成对应于矩阵Ai中的每一行的内积运算;In an alternative, the control circuit of the main processing circuit can broadcast the parts of the matrix P to the registers of the respective basic processing circuits or the on-chip buffer multiple times, and the i-th basic processing circuit pairs the matrix P obtained each time. The data is not multiplexed, and the inner product operations corresponding to each row in the matrix Ai are completed in stages;

在一种可选方案中,主处理电路的控制电路可以将矩阵P中各部分多次广播到各个基础处理电路的寄存器或者片上缓存中,第i个基础处理电路对每次得到的矩阵P的数据进行部分复用,完成对应于矩阵Ai中的每一行的内积运算;In an alternative, the control circuit of the main processing circuit can broadcast the parts of the matrix P to the registers of the respective basic processing circuits or the on-chip buffer multiple times, and the i-th basic processing circuit pairs the matrix P obtained each time. The data is partially multiplexed to complete an inner product operation corresponding to each row in the matrix Ai;

在一种可选方案中,每个基础处理电路,例如第i个基础处理电路,计算矩阵Ai的数据和矩阵P的数据的内积;In an alternative, each of the basic processing circuits, such as the i-th basic processing circuit, calculates an inner product of the data of the matrix Ai and the data of the matrix P;

步骤S203b、每个基础处理电路的累加器电路将内积运算的结果进行累加并传输回主处理电路。Step S203b, the accumulator circuit of each basic processing circuit accumulates the result of the inner product operation and transmits it back to the main processing circuit.

可选的,步骤S203b之前,基础处理电路的内积运算器需计算矩阵S和矩阵P的数据的内积,具体存在以下几种实施方案。Optionally, before step S203b, the inner product operator of the basic processing circuit needs to calculate the inner product of the data of the matrix S and the matrix P. Specifically, the following implementation manners exist.

在一种具体实施方案中,所述基础处理电路接收到处理后的矩阵S中的数据以及该数据对应在第一mask矩阵中关联的标识数据;同时还接收到处理后的矩阵P中的数据。相应地,基础处理电路启用第二映射电路根据接收的第一mask矩阵中的标识数据对接收的矩阵P的数据进行处理,得到处理后的矩阵P的数据。进一步地,该基础处理电路启用内积运算器电路对接收的处理后的矩阵S中的数据和处理后的矩阵P的数据执行内积运算,得到内积运算的结果。In a specific implementation, the basic processing circuit receives the data in the processed matrix S and the data corresponding to the identification data associated in the first mask matrix; and also receives the data in the processed matrix P. . Correspondingly, the basic processing circuit enables the second mapping circuit to process the data of the received matrix P according to the identification data in the received first mask matrix to obtain the data of the processed matrix P. Further, the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the received data in the processed matrix S and the processed matrix P data to obtain a result of the inner product operation.

在一种具体实施方案中,所述基础处理电路接收到处理后的矩阵P中的数据以及该数据对应在第二mask矩阵中关联的标识数据;同时还接收到处理后的矩阵S中的数据。相应地,基础处理电路启用第二映射电路根据接收的第二mask矩阵中的标识数据对接收的矩阵S的数据进行处理,得到处理后的矩阵S的数据。进一步地,该基础处理电路启用内积运算器电路对接收的处理后的矩阵P的数据和处理后的矩阵S中的数据执行内积运算,得到内积运算的结果。In a specific implementation, the basic processing circuit receives the data in the processed matrix P and the data corresponding to the identification data associated in the second mask matrix; and also receives the data in the processed matrix S. . Correspondingly, the basic processing circuit enables the second mapping circuit to process the data of the received matrix S according to the identification data in the received second mask matrix to obtain the data of the processed matrix S. Further, the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the received data of the processed matrix P and the processed data in the matrix S to obtain a result of the inner product operation.

在一种具体实施方案中,所述基础处理电路接收到处理后的矩阵S中的数据以及该数据对应在第一mask矩阵中关联的标识数据;同时还接收到处理后的矩阵P中的数据以及该数据对应在第二mask矩阵中关联的标识数据。相应地,基础处理电路启用第二映射电路根据接收的第一mask矩阵中的标识数据和第二mask矩阵中的标识数据得到关系标识矩阵(也可称关系连接矩阵);然后利用关系标识矩阵中的标识数据分别对接收的矩阵S中的数据和矩阵P中的数据进行处理,得到处理后的矩阵S的数据和处理后的矩阵P的数据。进一步地,启用内积运算器电路对处理后的矩阵S中的数据和处理后的矩阵P的数据执行内积运算,得到内积运算的结果。例如,第i个基础处理电路,接收到矩阵Ai、该Ai关联的标识矩阵Bi、矩阵P以及矩阵P关联的第二标识矩阵;此时可启用第二映射电路利用Bi和第二标识矩阵 获得关系标识矩阵,再利用该关系标识矩阵同时或分别对矩阵Ai和矩阵P进行处理,得到处理后的矩阵Ai和处理后的矩阵P。接着,启用内积运算器电路对处理后的矩阵Ai和处理后的矩阵P进行内积运算。In a specific implementation, the basic processing circuit receives the data in the processed matrix S and the data corresponding to the identification data associated in the first mask matrix; and also receives the data in the processed matrix P. And the data corresponds to the identification data associated in the second mask matrix. Correspondingly, the basic processing circuit enables the second mapping circuit to obtain a relationship identification matrix (also referred to as a relational connection matrix) according to the identification data in the received first mask matrix and the identification data in the second mask matrix; and then use the relationship identification matrix The identification data respectively processes the data in the received matrix S and the data in the matrix P to obtain the processed matrix S data and the processed matrix P data. Further, the inner product operator circuit is enabled to perform an inner product operation on the data in the processed matrix S and the processed matrix P data to obtain a result of the inner product operation. For example, the i-th basic processing circuit receives the matrix Ai, the identification matrix Bi associated with the Ai, the matrix P, and the second identification matrix associated with the matrix P; at this time, the second mapping circuit can be enabled to obtain the second identification matrix by using the Bi and the second identification matrix. The relationship identification matrix is used to process the matrix Ai and the matrix P simultaneously or separately to obtain the processed matrix Ai and the processed matrix P. Next, the inner product operator circuit is enabled to perform an inner product operation on the processed matrix Ai and the processed matrix P.

在一种可选方案中,基础处理电路可以将每次执行内积运算得到的部分和传输回主处理电路进行累加;In an alternative, the basic processing circuit may accumulate the portion obtained by performing the inner product operation each time and transmit back to the main processing circuit;

在一种可选方案中,也可以将每次基础处理电路执行的内积运算得到的部分和保存在基础处理电路的寄存器和/或片上缓存中,累加结束之后传输回主处理电路;In an optional solution, the portion obtained by the inner product operation performed by each basic processing circuit may be stored in a register and/or an on-chip buffer of the basic processing circuit, and then accumulated and returned to the main processing circuit;

在一种可选方案中,也可以将每次基础处理电路执行的内积运算得到的部分和在部分情况下保存在基础处理电路的寄存器和/或片上缓存中进行累加,部分情况下传输到主处理电路进行累加,累加结束之后传输回主处理电路。In an alternative, it is also possible to accumulate the portion obtained by the inner product operation performed by each basic processing circuit and, in some cases, the register and/or the on-chip buffer of the basic processing circuit, and in some cases transmit to The main processing circuit performs accumulation, and after the accumulation is completed, it is transmitted back to the main processing circuit.

参阅图3a,使用如图1a所示的装置完成全连接运算:Referring to Figure 3a, the full join operation is done using the apparatus shown in Figure 1a:

如果全连接层的输入数据是一个向量(即神经网络的输入是单个样本的情况),则以全连接层的权值矩阵作为矩阵S,输入向量作为向量P,按照所述装置的使用方法一执行如图2所示的矩阵乘向量的运算;If the input data of the fully connected layer is a vector (that is, the input of the neural network is a single sample), the weight matrix of the fully connected layer is used as the matrix S, and the input vector is used as the vector P, according to the usage method of the device. Perform the operation of the matrix multiplication vector as shown in FIG. 2;

如果全连接层的输入数据是一个矩阵(即神经网络的输入是多个样本作为batch的情况),则以全连接层的权值矩阵作为矩阵S,输入向量作为矩阵P,或者以全连接层的权值矩阵作为矩阵P,输入向量作为矩阵S,使用所述装置完成如图2c所示的矩阵乘矩阵的运算;If the input data of the fully connected layer is a matrix (that is, the case where the input of the neural network is a plurality of samples as a batch), the weight matrix of the fully connected layer is used as the matrix S, the input vector is used as the matrix P, or the fully connected layer is used. The weight matrix as the matrix P, the input vector as the matrix S, using the device to complete the operation of the matrix multiplication matrix as shown in Figure 2c;

参阅图3b,使用如图1a所示的装置完成卷积运算:Referring to Figure 3b, the convolution operation is performed using the apparatus as shown in Figure 1a:

对于一个卷积层,记其卷积核的数量为M;For a convolutional layer, remember that the number of convolution kernels is M;

步骤S301、主处理电路的控制电路将卷积层权值中的每一个卷积核的权值分发到K个基础处理电路中的某一个上,保存在基础处理电路的片上缓存和/或寄存器中;Step S301: The control circuit of the main processing circuit distributes the weight of each convolution kernel in the convolution layer weight to one of the K basic processing circuits, and stores the on-chip buffer and/or the register in the basic processing circuit. in;

在一种可选方案中,所述卷积核的权值为处理后的权值数据。具体的,主处理电路启用第一映射电路对卷积核的权值进行处理,从而获得处理后的卷积核以及该卷积核关联的第一标识(mask)矩阵。或者,主处理电路的第一映射电路根据预存的卷积核关联的第一mask矩阵对该卷积核进行处理,得到处理后的卷积核(即处理后的卷积核的权值)。进一步地,通过控制电路将处理后的卷积核中的权值以及该权值对应在第一mask矩阵中对应关联的标识数据一起发送给K个基础处理电路中的某一个或多个中。在主处理电路向基础处理电路发送数据时,具体可将处理后的卷积核中绝对值大于预设阈值的数据,或者非0数据发送给基础处理电路,以减少数据传输量。例如,分发到第i个基础处理电路中Mi个处理后的卷积核的集合为Ai;相应地,同时也分发有与Ai对应的标识矩阵Bi。In an alternative, the weight of the convolution kernel is processed weight data. Specifically, the main processing circuit enables the first mapping circuit to process the weight of the convolution kernel, thereby obtaining the processed convolution kernel and a first mask matrix associated with the convolution kernel. Alternatively, the first mapping circuit of the main processing circuit processes the convolution kernel according to the first mask matrix associated with the pre-stored convolution kernel, and obtains the processed convolution kernel (ie, the weight of the processed convolution kernel). Further, the control circuit outputs the weight in the processed convolution kernel and the weight corresponding to the corresponding associated identification data in the first mask matrix to one or more of the K basic processing circuits. When the main processing circuit sends data to the basic processing circuit, the data in the processed convolution kernel whose absolute value is greater than a preset threshold or non-zero data may be specifically sent to the basic processing circuit to reduce the data transmission amount. For example, the set of Mi processed convolution kernels distributed to the i-th basic processing circuit is Ai; correspondingly, the identification matrix Bi corresponding to Ai is also distributed.

在一种可选方案中,如果卷积核的个数M<=K则,主处理电路的控制电路给M个基础处理电路分别分发一个卷积核的权值;可选的,同时还发送该卷积核对应关联的标识矩阵(即标识矩阵中的标识数据)。In an alternative, if the number of convolution kernels is M<=K, the control circuit of the main processing circuit separately distributes the weights of one convolution kernel to the M basic processing circuits; optionally, also sends The convolution kernel corresponds to an associated identification matrix (ie, identification data in the identification matrix).

在一种可选方案中,如果卷积核的个数M>K,主处理电路的控制电路给每个基础处理电路分别分发一个或多个卷积核的权值;可选的,同时还发送该一个或多个卷积核各自对应关联的标识矩阵(即标识矩阵中的标识数据)。In an alternative, if the number of convolution kernels is M>K, the control circuit of the main processing circuit separately distributes the weights of one or more convolution kernels to each of the basic processing circuits; optionally, Sending the one or more convolution kernels respectively corresponding to the associated identification matrix (ie, the identification data in the identification matrix).

共有Mi个卷积核分发到第i个基础处理电路,这些卷积核权值的集合称为Ai。A total of Mi convolution kernels are distributed to the i-th base processing circuit, and the set of these convolution kernel weights is called Ai.

在一种可选方案中,在每个基础处理电路中,例如第i个基础处理电路中:In an alternative, in each of the basic processing circuits, such as the i-th basic processing circuit:

将收到的由主处理电路分发的卷积核权值Ai保存在其寄存器和/或片上缓存中;The received convolution kernel weight Ai distributed by the main processing circuit is stored in its register and/or on-chip buffer;

步骤S302、主处理电路的控制电路将输入数据P中各部分以广播的方式传输给各个基础处理电路;Step S302, the control circuit of the main processing circuit transmits each part of the input data P to each basic processing circuit in a broadcast manner;

在一种可选方案中,所述输入数据P为处理后的数据。具体的,主处理电路启用第一映射电路对输入数据P进行处理,从而获得处理后的输入数据P以及该输入数据P关联的第二标识(mask)矩阵(即标识数据)。或者,主处理电路的第一映射电路根据预存的输入数据P关联的第二mask矩阵对输入数据P进行处理,得到处理后的输入数据P。进一步地,通过控制电路将处理后的输入数据P中的数据(即各部分)以及该数据对应在第二mask矩阵中对应关联的标识数据一起发送给K个基础处理电路中的某一个或多个中。在主处理电路向基础处理电路发送数据时,具体可将处理后的输入数据P中绝对值大于预设阈值的数据,或者非0数据发送给基础处理电路,以减少数据传输量。In an alternative, the input data P is processed data. Specifically, the main processing circuit enables the first mapping circuit to process the input data P, thereby obtaining the processed input data P and a second mask matrix (ie, identification data) associated with the input data P. Alternatively, the first mapping circuit of the main processing circuit processes the input data P according to the second mask matrix associated with the pre-stored input data P to obtain the processed input data P. Further, the data in the processed input data P (ie, each part) and the corresponding data corresponding to the data in the second mask matrix are sent to one or more of the K basic processing circuits by the control circuit. In the middle. When the main processing circuit sends data to the basic processing circuit, the data of the processed input data P whose absolute value is greater than a preset threshold or non-zero data may be specifically sent to the basic processing circuit to reduce the data transmission amount.

在一种可选方案中,主处理电路的控制电路可以将输入数据P中各部分只广播一次到各个基础处理电路的寄存器或者片上缓存中,第i个基础处理电路对这一次得到的输入数据P的数据进行充分地复用,完成对应与Ai中每一个卷积核的内积运算;In an alternative, the control circuit of the main processing circuit can broadcast each part of the input data P only once to the register or on-chip buffer of each basic processing circuit, and the i-th basic processing circuit inputs the input data for this time. The data of P is fully multiplexed, and the inner product operation corresponding to each convolution kernel in Ai is completed;

在一种可选方案中,主处理电路的控制电路可以将输入数据P中各部分多次广播到各个基础处理电路的寄存器或者片上缓存中,第i个基础处理电路对每次得到的输入数据P的数据不进行复用,分次完成对应于Ai中的每一个卷积核的内积运算;In an alternative, the control circuit of the main processing circuit can broadcast each part of the input data P to the register or the on-chip buffer of each basic processing circuit multiple times, and the input data obtained by the i-th basic processing circuit for each time. The data of P is not multiplexed, and the inner product operation corresponding to each convolution kernel in Ai is completed in stages;

在一种可选方案中,主处理电路的控制电路可以将输入数据P中各部分多次广播到各个基础处理电路的寄存器或者片上缓存中,第i个基础处理电路对每次得到的输入数据P的数据进行部分复用,完成对应于Ai中的每一个卷积核的内积运算;In an alternative, the control circuit of the main processing circuit can broadcast each part of the input data P to the register or the on-chip buffer of each basic processing circuit multiple times, and the input data obtained by the i-th basic processing circuit for each time. The data of P is partially multiplexed to complete an inner product operation corresponding to each convolution kernel in Ai;

步骤S303、每个基础处理电路计算卷积核和输入数据P的数据内积,例如第i个基础处理电路,计算Ai的每一个卷积核和输入数据P的数据的内积;Step S303, each basic processing circuit calculates a data inner product of the convolution kernel and the input data P, for example, an i-th basic processing circuit, and calculates an inner product of each convolution kernel of the Ai and the data of the input data P;

在一种具体实施方案中,所述基础处理电路接收到处理后的卷积核中的数据以及该数据对应在第一mask矩阵中关联的标识数据;同时还接收到处理后的输入数据P。相应地,基础处理电路启用第二映射电路根据接收的第一mask矩阵中的标识数据对接收的输入数据P进行处理,得到处理后的输入数据P。进一步地,该基础处理电路启用内积运算器电路对接收的处理后的卷积核中的数据和处理后的输入数据P执行内积运算,得到内积运算的结果。例如,第i个基础处理电路,接收到卷积核权值Ai、该Ai关联的标识矩阵Bi以及输入数据P;此时可启用第二映射电路利用Bi对输入数据P进行处理得到处理后的输入数据P;再启用内积运算器电路对卷积核权值Ai和处理后的输入数据P进行内积运算。In a specific embodiment, the base processing circuit receives the data in the processed convolution kernel and the data corresponds to the identification data associated in the first mask matrix; and also receives the processed input data P. Correspondingly, the basic processing circuit enables the second mapping circuit to process the received input data P according to the identification data in the received first mask matrix to obtain the processed input data P. Further, the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the data in the received processed convolution kernel and the processed input data P to obtain a result of the inner product operation. For example, the i-th basic processing circuit receives the convolution kernel weight Ai, the identification matrix Bi associated with the Ai, and the input data P; at this time, the second mapping circuit can be enabled to process the input data P by using Bi. The data P is input; the inner product operator circuit is further enabled to perform an inner product operation on the convolution kernel weight Ai and the processed input data P.

在一种具体实施方案中,所述基础处理电路接收到处理后的输入数据P中的数据以及该数据对应在第二mask矩阵中关联的标识数据;同时还接收到处理后的卷积核中的数据。相应地,基础处理电路启用第二映射电路根据接收的第二mask矩阵中的标识数据对接收的卷积核的数据进行处理,得到处理后的卷积核的数据。进一步地,该基础处理电路启用内积运算器电路对接收的处理后的输入数据P和处理后的卷积核中的数据执行内积运算,得到内积运算的结果。例如,第i个基础处理电路,接收到卷积核权值Ai、处理后的输入数据P以及该输入数据P关联的第二标识矩阵;此时可启用第二映射电路利用第二标识矩阵对Ai进行处理得到处理后的卷积核权值Ai;再启用内积运算器电路对处理后的卷积核权值Ai和处理后的输入数据P进行内积运算。In a specific implementation, the basic processing circuit receives the data in the processed input data P and the data corresponding to the identification data associated in the second mask matrix; and also receives the processed convolution kernel The data. Correspondingly, the basic processing circuit enables the second mapping circuit to process the data of the received convolution kernel according to the identification data in the received second mask matrix to obtain the data of the processed convolution kernel. Further, the basic processing circuit enables the inner product operator circuit to perform an inner product operation on the received processed input data P and the processed convolution kernel to obtain a result of the inner product operation. For example, the i-th basic processing circuit receives the convolution kernel weight Ai, the processed input data P, and the second identification matrix associated with the input data P; at this time, the second mapping circuit can be enabled to utilize the second identification matrix pair Ai performs processing to obtain the processed convolution kernel weight Ai; and then enables the inner product operator circuit to perform inner product operation on the processed convolution kernel weight Ai and the processed input data P.

在一种具体实施方案中,所述基础处理电路接收到处理后的卷积核中的数据以及该数据对应在第一mask矩阵中关联的标识数据;同时还接收到处理后的输入数据P中的数据以及该数据对应在第二mask矩阵中关联的标识数据。相应地,基础处理电路启用第二映射电路根据接收的第一mask矩阵中的标识数据和第二mask矩阵中的标识数据得到关系标识矩阵(也可称为关系连接矩阵);然后利用关系标识矩 阵中的标识数据分别对接收的卷积核中的数据和输入数据P中的数据进行处理,得到处理后的卷积核的数据和处理后的输入数据P。进一步地,启用内积运算器电路对处理后的卷积核中的数据和处理后的输入数据P执行内积运算,得到内积运算的结果。例如,第i个基础处理电路,接收到卷积核权值Ai、该Ai关联的标识矩阵Bi、输入数据P以及输入数据P关联的第二标识矩阵;此时可启用第二映射电路利用Bi和第二标识矩阵获得关系标识矩阵,再利用该关系标识矩阵同时或分别对卷积核权值Ai和输入数据P进行处理,得到处理后的卷积核权值Ai和处理后的输入数据P。接着,启用内积运算器电路对处理后的卷积核权值Ai和处理后的输入数据P进行内积运算。In a specific implementation, the basic processing circuit receives the data in the processed convolution kernel and the data corresponding to the identification data associated in the first mask matrix; and also receives the processed input data P. The data and the data correspond to the identification data associated in the second mask matrix. Correspondingly, the basic processing circuit enables the second mapping circuit to obtain a relationship identification matrix (also referred to as a relational connection matrix) according to the identification data in the received first mask matrix and the identification data in the second mask matrix; and then use the relationship identification matrix The identification data in the process respectively processes the data in the received convolution kernel and the data in the input data P to obtain the processed convolution kernel data and the processed input data P. Further, the inner product calculator circuit is enabled to perform an inner product operation on the data in the processed convolution kernel and the processed input data P to obtain a result of the inner product operation. For example, the i-th basic processing circuit receives the convolution kernel weight Ai, the Ai-associated identification matrix Bi, the input data P, and the second identification matrix associated with the input data P; at this time, the second mapping circuit can be enabled to utilize Bi. And obtaining a relationship identifier matrix with the second identifier matrix, and then processing the convolution kernel weight Ai and the input data P by using the relationship identifier matrix, respectively, to obtain the processed convolution kernel weight Ai and the processed input data P . Next, the inner product operator circuit is enabled to perform an inner product operation on the processed convolution kernel weight Ai and the processed input data P.

步骤S304、每个基础处理电路的累加器电路将内积运算的结果进行累加并传输回主处理电路:Step S304, the accumulator circuit of each basic processing circuit accumulates the result of the inner product operation and transmits it back to the main processing circuit:

在一种可选方案中,基础处理电路可以将每次执行内积运算得到的部分和传输回主处理电路进行累加;In an alternative, the basic processing circuit may accumulate the portion obtained by performing the inner product operation each time and transmit back to the main processing circuit;

在一种可选方案中,基础处理电路也可以将每次执行的内积运算得到的部分和保存在基础处理电路的寄存器和/或片上缓存中,累加结束之后传输回主处理电路;In an alternative, the basic processing circuit may also save the portion obtained by the inner product operation performed each time and the register and/or the on-chip buffer stored in the basic processing circuit, and then transfer back to the main processing circuit after the accumulation is completed;

在一种可选方案中,基础处理电路也可以将每次执行的内积运算得到的部分和在部分情况下保存在基础处理电路的寄存器和/或片上缓存中进行累加,部分情况下传输到主处理电路进行累加,累加结束之后传输回主处理电路;In an alternative, the basic processing circuit may also accumulate the portion obtained by each inner product operation and, in some cases, the register and/or the on-chip buffer of the basic processing circuit, and in some cases transmit to The main processing circuit performs accumulation, and is transferred back to the main processing circuit after the accumulation is completed;

使用如图1a所示的装置更新权值的方法:Use the device shown in Figure 1a to update the weights:

利用主处理电路的向量运算器电路实现神经网络训练过程中的权值更新功能,具体地,权值更新是指使用权值的梯度来更新权值的方法。The vector updater circuit of the main processing circuit is used to implement the weight update function in the neural network training process. Specifically, the weight update refers to a method of updating the weight using the gradient of the weight.

在一种可选方案中,使用主处理电路的向量运算器电路对权值和权值梯度这两个向量进行加减运算得到运算结果,该运算结果即为更新权值。In an alternative, the vector operator circuit of the main processing circuit is used to add and subtract the two vectors of the weight and the weight gradient to obtain an operation result, and the operation result is an update weight.

在一种可选方案中,使用主处理电路的向量运算器电路对权值以及权值梯度乘以或除以一个数得到中间权值和中间权值梯度值,向量运算器电路对中间权值和中间权值梯度值进行加减运算得到运算结果,该运算结果即为更新权值。In an alternative, the vector operator circuit of the main processing circuit multiplies or divides the weight and the weight gradient by a number to obtain an intermediate weight and an intermediate weight gradient value, and the vector operator circuit pairs the intermediate weight And the intermediate weight gradient value is added and subtracted to obtain the operation result, and the operation result is the update weight.

在一种可选方案中,可以先使用权值的梯度计算出一组动量,然后再使用动量与权值进行加减计算得到更新后的权值。In an alternative, a set of momentum can be calculated by using the gradient of the weights, and then the updated weights are obtained by adding and subtracting the momentum and the weights.

使用如图1a所示的装置实现BLAS(Basic Linear Algebra Subprograms)函数的方法Method for implementing BLAS (Basic Linear Algebra Subprograms) function using the apparatus as shown in FIG. 1a

GEMM计算是指:BLAS库中的矩阵-矩阵乘法的运算。该运算的通常表示形式为:C=alpha*op(S)*op(P)+beta*C,其中,S和P为输入的两个矩阵,C为输出矩阵,alpha和beta为标量,op代表对矩阵S或P的某种操作,此外,还会有一些辅助的整数作为参数来说明矩阵的S和P的宽高;GEMM calculation refers to the operation of matrix-matrix multiplication in the BLAS library. The usual representation of this operation is: C = alpha * op (S) * op (P) + beta * C, where S and P are the two matrices of the input, C is the output matrix, alpha and beta are scalar, op Represents some operation on the matrix S or P. In addition, there are some auxiliary integers as parameters to describe the width and height of the S and P of the matrix;

使用如图1a的装置实现GEMM计算的步骤包括:The steps to implement GEMM calculations using the apparatus of Figure 1a include:

主处理电路的数据类型转换运算电路可以对矩阵S以及矩阵P进行数据类型转换;The data type conversion operation circuit of the main processing circuit can perform data type conversion on the matrix S and the matrix P;

主处理电路的转换电路对输入矩阵S和矩阵P进行各自相应的op操作;The conversion circuit of the main processing circuit performs respective op operations on the input matrix S and the matrix P;

在一种可选方案中,op可以为矩阵的转置操作;可以利用主处理电路的矩阵转置电路实现该矩阵转置操作;In an alternative, op can be a transposition operation of the matrix; the matrix transposition operation can be implemented by using a matrix transposition circuit of the main processing circuit;

在一种可选方案中,在执行完矩阵S和矩阵P的OP操作以后,还可以由主处理电路的数据转换运算电路执行数据类型转换操作,即数据转换运算电路将op(S)以及op(P)的数据类型由浮点类型数据转换成定点类型数据,然后执行如图2b所示的矩阵乘法运算。In an alternative, after performing the OP operation of the matrix S and the matrix P, the data conversion operation circuit of the main processing circuit may also perform a data type conversion operation, that is, the data conversion operation circuit will op(S) and op The data type of (P) is converted from floating point type data to fixed point type data, and then matrix multiplication operation as shown in Fig. 2b is performed.

在一种可选方案中,某个矩阵的op可以为空,op操作不进行;In an alternative, the op of a certain matrix may be empty, and the op operation is not performed;

用如图1a所示的装置的使用如图2b中所述矩阵乘矩阵的计算方法完成op(S)与op(P)之间的矩阵乘法计算;Completing the matrix multiplication calculation between op(S) and op(P) using the calculation method of the matrix multiplication matrix as shown in Fig. 2b using the apparatus as shown in Fig. 1a;

利用主处理电路的算术逻辑单元对op(S)*op(P)的结果中的每一个值进行乘以alpha的操作;Multiplying each value in the result of op(S)*op(P) by an arithmetic logic unit of the main processing circuit by an alpha;

在一种可选方案中,alpha为1的情况下乘以alpha的操作不进行;In an alternative, the operation of multiplying alpha by alpha is not performed;

利用主处理电路的算术逻辑单元实现beta*C的运算;Implementing the operation of beta*C using the arithmetic logic unit of the main processing circuit;

在一种可选方案中,beta为1的情况下,不进行乘以beta的操作;In an alternative, where beta is 1, no multiplication by beta is performed;

利用主处理电路的向量运算器电路实现矩阵alpha*op(s)*op(P)和beta*C之间对应位置相加的步骤得到GEMM计算的结果。The vector operator circuit of the main processing circuit is used to implement the steps of adding the corresponding positions between the matrix alpha*op(s)*op(P) and beta*C to obtain the result of the GEMM calculation.

在一种可选方案中,beta为0的情况下,不进行这步操作;In an alternative, if the beta is 0, this step is not performed;

GEMV计算是指:BLAS库中的矩阵-向量乘法的运算。该运算的通常表示形式为:C=alpha*op(S)*P+beta*C,其中,S为输入矩阵,P为输入的向量,C为输出向量,alpha和beta为标量,op代表对矩阵S的某种操作;GEMV calculation refers to the operation of matrix-vector multiplication in the BLAS library. The usual representation of this operation is: C = alpha * op (S) * P + beta * C, where S is the input matrix, P is the input vector, C is the output vector, alpha and beta are scalars, and op is the pair Some operation of the matrix S;

使用如图1a的装置实现GEMV计算的步骤为:The steps to implement GEMV calculations using the apparatus of Figure 1a are:

主处理电路的数据类型转换运算电路可以对输入矩阵S以及矩阵P进行数据类型转换;The data type conversion operation circuit of the main processing circuit can perform data type conversion on the input matrix S and the matrix P;

主处理电路的转换电路对输入矩阵S进行相应的op操作;The conversion circuit of the main processing circuit performs a corresponding op operation on the input matrix S;

在一种可选方案中,op可以为矩阵的转置操作;利用主处理电路的转换电路实现矩阵转置操作;In an alternative, op can be a transposition operation of the matrix; the matrix transposition operation is implemented by using a conversion circuit of the main processing circuit;

在一种可选方案中,某个矩阵的op可以为空,转置操作不进行;In an alternative, the op of a certain matrix may be empty, and the transposition operation is not performed;

用如图1a所示装置使用如图2a中所述矩阵乘向量的计算方法完成矩阵op(S)与向量P之间的矩阵-向量乘法计算;Completing the matrix-vector multiplication calculation between the matrix op(S) and the vector P using the calculation method of the matrix multiplication vector as described in Fig. 2a as shown in Fig. 1a;

利用主处理电路的算术逻辑单元对op(S)*P的结果中的每一个值进行乘以alpha的操作;Multiplying each value of the result of op(S)*P by an arithmetic operation unit of the main processing circuit by an alpha;

在一种可选方案中,alpha为1的情况下乘以alpha的操作不进行;In an alternative, the operation of multiplying alpha by alpha is not performed;

利用主处理电路的算术逻辑单元实现beta*C的运算;Implementing the operation of beta*C using the arithmetic logic unit of the main processing circuit;

在一种可选方案中,beta为1的情况下,不进行乘以beta的操作;In an alternative, where beta is 1, no multiplication by beta is performed;

利用主处理电路的向量运算器电路实现矩阵alpha*op(S)*P和beta*C之间对应位置相加的步骤得到GEMV的结果。The result of GEMV is obtained by the step of adding the corresponding positions between the matrix alpha*op(S)*P and beta*C by using the vector operator circuit of the main processing circuit.

在一种可选方案中,beta为0的情况下,不进行相加的步骤操作;In an alternative, if the beta is 0, the step of adding is not performed;

使用如图1a的装置实现激活函数的方法Method of implementing an activation function using the apparatus of Figure 1a

利用主处理电路的激活电路输入一向量,计算出该向量的激活向量;An activation circuit of the main processing circuit inputs a vector to calculate an activation vector of the vector;

在一种可选方案中,主处理电路激活电路将输入向量中的每一个值通过一个激活函数(激活函数的输入是一个数值,输出也是一个数值),计算出一个数值输出到输出向量的对应位置;In an alternative, the main processing circuit activation circuit passes each value in the input vector through an activation function (the input of the activation function is a value and the output is also a value), and a correspondence of the output of the value to the output vector is calculated. position;

在一种可选方案中,激活函数可以是:y=max(m,x),其中x是输入数值,y是输出数值,m是一个常数;In an alternative, the activation function can be: y = max(m, x), where x is the input value, y is the output value, and m is a constant;

在一种可选方案中,激活函数可以是:y=tanh(x),其中x是输入数值,y是输出数值;In an alternative, the activation function can be: y = tanh(x), where x is the input value and y is the output value;

在一种可选方案中,激活函数可以是:y=sigmoid(x),其中x是输入数值,y是输出数值;In an alternative, the activation function can be: y = sigmoid (x), where x is the input value and y is the output value;

在一种可选方案中,激活函数可以是一个分段线性函数;In an alternative, the activation function can be a piecewise linear function;

在一种可选方案中,激活函数可以是任意输入一个数,输出一个数的函数。In an alternative, the activation function can be any function that inputs a number and outputs a number.

在一种可选方案中,输入向量的来源有(包括但不限于):In an alternative, the source of the input vector is (including but not limited to):

所述装置的外部数据来源;External data source of the device;

在一种可选方案中,输入数据来自所述装置进行矩阵乘向量的运算结果;In an alternative, the input data is from the device for performing a matrix multiplication vector;

在一种可选方案中,输入数据来自所述装置进行矩阵乘矩阵的运算结果;In an alternative, the input data is from the device for performing a matrix multiplication matrix;

所述装置的主处理电路计算结果;The main processing circuit of the device calculates a result;

在一种可选方案中,输入数据来自所述装置主处理电路实现加偏置之后的计算结果。In an alternative, the input data is derived from the calculations after the device main processing circuit implements the offset.

需要说明的是,上述激活操作可以由主处理电路内的算数逻辑电路和累加器电路来实现,也可以在主处理电路单独增加一个激活电路来实现激活操作。It should be noted that the above activation operation may be implemented by an arithmetic logic circuit and an accumulator circuit in the main processing circuit, or an activation circuit may be separately added to the main processing circuit to implement an activation operation.

使用如图1a的装置实现加偏置操作:The biasing operation is implemented using the device of Figure 1a:

利用主处理电路的向量运算器电路可以实现两个向量或者两个矩阵相加的功能;The vector operator circuit of the main processing circuit can realize the function of adding two vectors or two matrices;

利用主处理电路的向量运算器电路可以实现把一个向量加到一个矩阵的每一行上,或者每一个列上的功能。The vector operator circuit of the main processing circuit can be used to add a vector to each row of a matrix, or to the function on each column.

在一种可选方案中,所述矩阵可以来自所述装置执行矩阵乘矩阵运算的结果;In an alternative, the matrix may be derived from the result of the matrix multiplication matrix operation performed by the apparatus;

在一种可选方案中,所述矩阵可以来自所述装置执行矩阵乘向量运算的结果;In an alternative, the matrix may be derived from the result of the device performing a matrix multiplication vector operation;

在一种可选方案中,所述矩阵可以来自所述装置的主处理电路从外部接受的数据。In an alternative, the matrix may be derived from externally accepted data from the main processing circuitry of the device.

在一种可选方案中,所述向量可以来自所述装置的主处理电路从外部接受的数据。In an alternative, the vector may be from externally accepted data from the main processing circuitry of the device.

包括但不限于以上这些数据来源。This includes, but is not limited to, the above data sources.

参考前述实施例,下面阐述运算指令为正向运算指令所涉及的具体实施例。在第一方面提供的装置中,所述主处理电路用于接收正向运算指令,解析所述正向运算指令得到所述正向运算指令在所述神经网络正向运算中的第i层所包含的第一运算指令以及所述第一运算指令所需的输入数据块以及权值数据块,所述i的取值范围为大于等于1,且小于等于n的整数,如所述i大于等于2,所述输入数据块为第i-1层的输出数据块;With reference to the foregoing embodiments, the specific embodiments involved in the operation instructions being forward operation instructions are set forth below. In the apparatus provided by the first aspect, the main processing circuit is configured to receive a forward operation instruction, and parse the forward operation instruction to obtain an ith layer of the forward operation instruction in a forward operation of the neural network The first operation instruction included, and the input data block and the weight data block required by the first operation instruction, wherein the range of i is an integer greater than or equal to 1, and less than or equal to n, as the i is greater than or equal to 2. The input data block is an output data block of the i-1th layer;

所述主处理电路,用于依据所述第一运算指令将所述输入数据块划分成广播数据块,将所述卷积核数据块划分成分发数据块;依据所述第一正向指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述卷积指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is configured to divide the input data block into a broadcast data block according to the first operation instruction, and divide the convolution kernel data block into a data block; according to the first forward instruction The operation control determines to start the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast data block; The product instruction sends the processed first data block to at least one of the basic processing circuits connected to the main processing circuit;

所述多个基础处理电路,用于依据所述第一运算指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the first operation instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block. The operation obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is the receiving the main processing determined by the basic processing circuit a data block sent by the circuit, the second data block being associated with the processed first data block;

所述主处理电路,用于将所述运算结果进行处理得到所述第一运算指令的指令结果,完成所述第i层包含的所述第一运算指令的运算。The main processing circuit is configured to process the operation result to obtain an instruction result of the first operation instruction, and complete an operation of the first operation instruction included in the ith layer.

在第一方面提供的装置中,当所述第一数据块包括分发数据块和广播数据块时,所述主处理电路,具体用于启动所述第一映射电路对所述分发数据块和所述广播数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块,处理后的广播数据块以及该广播数据块关联的标识数据块;将所述处理后的分发数据块以及该分发数据块关联的标识数据块进行拆分处理得到多个基本数据块以及所述基本数据块各自关联的标识数据块,将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路,将所述处理后的广播数据块以及该广播数据块关联的标识数 据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a distribution data block and a broadcast data block, the main processing circuit is specifically configured to start the first mapping circuit, the distribution data block, and the Processing the broadcast data block to obtain the processed distribution data block and the identification data block associated with the distribution data block, the processed broadcast data block, and the identification data block associated with the broadcast data block; and the processed distribution data block And the identification data block associated with the distribution data block is subjected to split processing to obtain a plurality of basic data blocks and identification data blocks respectively associated with the basic data blocks, and the plurality of basic data blocks and the plurality of basic data blocks are respectively And the associated identification data block is distributed to the basic processing circuit connected thereto, and the processed broadcast data block and the identification data block associated with the broadcast data block are broadcasted to the basic processing circuit connected thereto;

相应地,所述基础处理电路,具体用于启动所述第二映射电路根据所述广播数据块关联的标识数据块和所述基本数据块关联的标识数据获得连接标识数据块,并根据所述连接标识数据块对所述广播数据块和所述基本数据块进行处理得到处理后的广播数据块和基本数据块;对所述处理后的广播数据块和基本数据块执行正向运算得到运算结果,将所述运算结果发送至所述主处理电路;其中,所述正向运算包括但不限于以下中的任一项或多项的组合:卷积运算(即内积运算)、乘积运算、偏执运算、全连接运算、GEMM运算、GEMV运算、激活运算中的一种或任意组合;Correspondingly, the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the broadcast data block and the identification data associated with the basic data block, and according to the The connection identification data block processes the broadcast data block and the basic data block to obtain a processed broadcast data block and a basic data block; performing a forward operation on the processed broadcast data block and the basic data block to obtain an operation result And transmitting the operation result to the main processing circuit; wherein the forward operation includes but is not limited to a combination of any one or more of the following: a convolution operation (ie, an inner product operation), a product operation, One or any combination of paranoid operation, full connection operation, GEMM operation, GEMV operation, activation operation;

所述主处理电路,用于对所述运算结果处理得到所述指令结果。The main processing circuit is configured to process the operation result to obtain the instruction result.

在第一方面提供的装置中,当所述第一数据块包括分发数据块时,所述主处理电路,具体用于启动所述第一映射电路对所述分发数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块,或者启动所述第一映射电路根据预存的所述分发数据块关联的标识数据块对所述分发数据块进行处理得到处理后的分发数据块;将所述处理后的分发数据块以及该分发数据块关联的标识数据块进行拆分处理得到多个基本数据块以及所述基本数据块各自关联的标识数据块,将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路,将所述广播数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a distribution data block, the main processing circuit is specifically configured to start processing, by the first mapping circuit, the processing data block to be processed. Distributing the data block and the identification data block associated with the distribution data block, or initiating the first mapping circuit to process the distribution data block according to the pre-stored identification data block associated with the distribution data block to obtain the processed distribution data block And performing the split processing on the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and identification data blocks respectively associated with the basic data blocks, and the plurality of basic data And the identification data block associated with each of the plurality of basic data blocks is distributed to a basic processing circuit connected thereto, and the broadcast data block is broadcasted to a basic processing circuit connected thereto;

所述基础处理电路,具体用于启动所述第二映射电路根据所述基本数据块关联的标识数据块对所述广播数据块进行处理,得到处理后的广播数据块;对所述处理后的广播数据块和所述处理后的基本数据块执行正向运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is specifically configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, to obtain a processed broadcast data block; The broadcast data block and the processed basic data block perform a forward operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.

在可选实施例中,所述主处理电路,还具体用于将所述广播数据块或处理后的广播数据块以及该广播数据块关联的标识数据块进行拆分处理得到多个部分广播数据块以及所述多个部分广播数据块各自关联的标识数据块;将所述多个部分广播数据块以及所述多个部分广播数据块各自关联的标识数据块通过一次或多次广播给所述基础处理电路;其中,所述多个部分广播数据块组合形成所述广播数据块或处理后的广播数据块。In an optional embodiment, the main processing circuit is further configured to split the broadcast data block or the processed broadcast data block and the identification data block associated with the broadcast data block to obtain a plurality of partial broadcast data. a block and an identification data block associated with each of the plurality of partial broadcast data blocks; broadcasting the plurality of partial broadcast data blocks and the identification data blocks associated with each of the plurality of partial broadcast data blocks by the one or more broadcasts to the a base processing circuit; wherein the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.

相应地,所述基础处理电路,具体用于启动所述第二映射电路根据所述部分广播数据块关联的标识数据块以及所述基本数据块关联的标识数据块得到连接标识数据块;根据所述连接标识数据对所述部分广播数据块以及所述基本数据块进行处理得到处理后的部分广播数据块以及处理后的基本数据块;对所述处理后的部分广播数据块以及所述处理后的基本数据块执行正向运算。Correspondingly, the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the partial broadcast data block and the identification data block associated with the basic data block; The connection identification data is processed to process the partial broadcast data block and the basic data block to obtain a processed partial broadcast data block and the processed basic data block; and the processed partial broadcast data block and the processed The basic data block performs a forward operation.

在第一方面提供的装置中,当所述第一数据块包括广播数据块时,所述主处理电路,具体用于启动所述第一映射电路对所述广播数据块进行处理,得到处理后的广播数据块以及该广播数据块关联的标识数据块,或者启动所述第一映射电路根据预存的所述广播数据块关联的标识数据块对所述广播数据块进行处理得到处理后的广播数据块;对所述分发数据块进行拆分处理得到多个基本数据块;将所述多个基本数据块分发至与其连接的基础处理电路,将所述处理后的广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a broadcast data block, the main processing circuit is specifically configured to start the first mapping circuit to process the broadcast data block, and obtain the processed Broadcast data block and the identification data block associated with the broadcast data block, or the first mapping circuit is configured to process the broadcast data block according to the pre-stored identification data block associated with the broadcast data block to obtain the processed broadcast data. Blocking the distributed data block to obtain a plurality of basic data blocks; distributing the plurality of basic data blocks to a basic processing circuit connected thereto, and the processed broadcast data block and the broadcast data block The associated identification data block is broadcast to the basic processing circuit connected thereto;

所述基础处理电路,具体用于启动所述第二映射电路根据所述广播数据块关联的标识数据块对所述基本数据块进行处理得到处理后的基本数据块;对所述处理后的广播数据块和所述处理后的基本数据块执行正向运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is configured to start, by the second mapping circuit, the basic data block to be processed according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and the processed broadcast The data block and the processed basic data block perform a forward operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.

在可选实施例中,所述主处理电路,还具体用于将所述处理后的广播数据块和该广播数据块关联的标识数据块进行拆分处理得到多个部分广播数据块以及所述多个部分广播数据块关联的标识数据块;将 所述多个部分广播数据块以及所述多个部分广播数据块各自关联的标识数据块通过一次或多次广播给所述基础处理电路;其中,所述多个部分广播数据块组合形成所述广播数据块或处理后的广播数据块。In an optional embodiment, the main processing circuit is further configured to split the processed broadcast data block and the identification data block associated with the broadcast data block to obtain a plurality of partial broadcast data blocks and the And an identifier data block associated with the plurality of partial broadcast data blocks; and the identification data blocks associated with the plurality of partial broadcast data blocks and the plurality of partial broadcast data blocks are broadcast to the basic processing circuit by one or more times; And the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.

相应地,所述基础处理电路具体用于根据所述部分广播数据块关联的标识数据块对所述基本数据块进行处理得到处理后的基本数据块;对所述处理后的基本数据块以及所述部分广播数据块执行正向运算。Correspondingly, the basic processing circuit is configured to process the basic data block according to the identifier data block associated with the partial broadcast data block to obtain a processed basic data block; and the processed basic data block and the The partial broadcast data block performs a forward operation.

本申请涉及的装置具体可参见前述图1a所示,集成电路芯片装置用于执行神经网络正向运算,所述神经网络包含n层;所述主处理电路包括第一映射电路,所述多个基础处理电路中至少一个电路包括第二映射电路,所述第一映射电路以及所述第二映射电路均用于执行神经网络运算中的各个数据的压缩处理;The device involved in the present application can be specifically referred to the foregoing FIG. 1a, the integrated circuit chip device is configured to perform a neural network forward operation, the neural network includes n layers, and the main processing circuit includes a first mapping circuit, the plurality of At least one of the basic processing circuits includes a second mapping circuit, and the first mapping circuit and the second mapping circuit are both configured to perform compression processing of respective data in the neural network operation;

所述主处理电路,用于接收正向运算指令,解析所述正向运算指令得到所述正向运算指令在所述神经网络正向运算中的第i层所包含的第一运算指令以及所述第一运算指令所需的输入数据块以及权值数据块,所述i的取值范围为大于等于1,且小于等于n的整数,如所述i大于等于2,所述输入数据块为第i-1层的输出数据块;The main processing circuit is configured to receive a forward operation instruction, and parse the forward operation instruction to obtain a first operation instruction included in an ith layer of the forward operation instruction in the forward operation of the neural network An input data block and a weight data block required by the first operation instruction, wherein the range of i is an integer greater than or equal to 1, and less than or equal to n, and if the i is greater than or equal to 2, the input data block is Output data block of layer i-1;

所述主处理电路,用于依据所述第一运算指令将所述输入数据块划分成广播数据块,将所述卷积核数据块划分成分发数据块;依据所述第一正向指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述卷积指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is configured to divide the input data block into a broadcast data block according to the first operation instruction, and divide the convolution kernel data block into a data block; according to the first forward instruction The operation control determines to start the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast data block; The product instruction sends the processed first data block to at least one of the basic processing circuits connected to the main processing circuit;

所述多个基础处理电路,用于依据所述第一运算指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the first operation instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block. The operation obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is the receiving the main processing determined by the basic processing circuit a data block sent by the circuit, the second data block being associated with the processed first data block;

所述主处理电路,用于将所述运算结果进行处理得到所述第一运算指令的指令结果,完成所述第i层包含的所述第一运算指令的运算。The main processing circuit is configured to process the operation result to obtain an instruction result of the first operation instruction, and complete an operation of the first operation instruction included in the ith layer.

可选的,上述集成电路芯片装置可以包括分支处理电路,该分支处理电路连接在主处理电路与基础处理电路之间,用于主处理电路与基础处理电路之间转换数据。设置分支处理电路可以提高主处理电路连接基础处理电路的数量,另外也减少了主处理电路的数据发送的开销。Optionally, the integrated circuit chip device may include a branch processing circuit connected between the main processing circuit and the basic processing circuit for converting data between the main processing circuit and the basic processing circuit. Setting the branch processing circuit can increase the number of basic processing circuits connected to the main processing circuit, and also reduce the overhead of data transmission of the main processing circuit.

如图6a所示,为本披露实施例提供的一种神经网络的正向运算,每一层使用自己的输入数据和权值按照层的类型所指定的运算规则计算得到相应的输出数据;As shown in FIG. 6a, a forward operation of a neural network according to an embodiment of the present disclosure, each layer uses its own input data and weights to calculate corresponding output data according to an operation rule specified by a layer type;

神经网络的正向运算过程(也叫推理,inference)是逐层处理各层的输入数据,经过一定的计算,得到输出数据的过程,具有如下特征:The forward operation process (also called inference) of the neural network is a process of processing the input data of each layer layer by layer, and obtaining the output data after a certain calculation, which has the following characteristics:

某一层的输入:Input to a layer:

某一层的输入可以是神经网络的输入数据;The input to a layer can be the input data of the neural network;

某一层的输入可以是其他层的输出;The input of one layer can be the output of other layers;

某一层的输入可以是本层上一时刻的输出(对应于循环神经网络的情况);The input of a layer can be the output of the layer at a moment (corresponding to the case of a cyclic neural network);

某一层可以同时从多个上述输入源获取输入;A layer can simultaneously acquire input from a plurality of the above input sources;

某一层的输出:The output of a layer:

某一层的输出可以作为神经网络的输出结果;The output of a layer can be used as the output of the neural network;

某一层的输出可以是其它层的输入;The output of one layer can be the input of other layers;

某一层的输出可以是下一时刻本层的输入(循环神经网络的情况);The output of a layer can be the input of this layer at the next moment (in the case of a cyclic neural network);

某一层的输出可以向上述多个输出方向输出结果;The output of a layer may output a result to the plurality of output directions described above;

具体地,所述神经网络中的层的运算的类型包括但不限于以下几种:Specifically, the types of operations of the layers in the neural network include, but are not limited to, the following:

卷积层(即执行卷积运算);Convolution layer (ie performing convolution operations);

全连接层(即执行全连接运算);Fully connected layer (ie performing a full join operation);

归一化(规则化)层:包括LRN(Local Response Normalization)层,BN(Batch Normalization)层等类型;Normalized (regularized) layer: includes LRN (Local Response Normalization) layer, BN (Batch Normalization) layer, and the like;

池化层;Pooling layer

激活层:包括但不限于以下类型Sigmoid层,ReLU层,PReLu层,LeakyReLu层,Tanh层;Activation layer: including but not limited to the following types of Sigmoid layer, ReLU layer, PReLu layer, LeakyReLu layer, Tanh layer;

层的反向运算,每一层的反向运算需要执行两部分运算:一部分是使用可能是稀疏表示的输出数据梯度和可能是稀疏表示的输入数据计算出权值的梯度(用于在“权值更新”步骤更新本层的权值),另一部分是使用可能是稀疏表示的输出数据梯度和可能是稀疏表示的权值,计算出输入数据梯度(用于作为反向运算中下一层的输出数据梯度以供其进行反向运算);The inverse operation of the layer, the inverse operation of each layer needs to perform a two-part operation: one part is to calculate the weight gradient using the output data gradient which may be sparse representation and the input data which may be sparse representation (for the weight The value update step updates the weight of this layer, and the other part uses the output data gradient, which may be sparse representation, and the weight of the sparse representation, to calculate the input data gradient (used as the next layer in the inverse operation). Output a data gradient for its inverse operation);

反向运算按照与正向运算相反的顺序,从最后一层开始反向传递梯度。The inverse operation reverses the gradient from the last layer in the reverse order of the forward operation.

在一种可选方案中,某一层反向计算得到的输出数据梯度可以来自:In an alternative, the inverse of the output data gradient calculated by a layer can be derived from:

神经网络最后的损失函数(lost function或者cost function)回传的梯度;The gradient of the return function of the last loss function or cost function of the neural network;

其它层的输入数据梯度;Input data gradient for other layers;

本层上一时刻的输入数据梯度(对应于循环神经网络的情况);Input data gradient at a moment on this layer (corresponding to the case of a cyclic neural network);

某一层可以同时从多个上述源获取输出数据梯度;A layer can simultaneously obtain an output data gradient from a plurality of the above sources;

在执行完神经网络的反向运算之后,就计算出了各层的权值的梯度,在这个步骤中,所述装置的第一输入缓存和第二输入缓存分别用于存储本层的权值和权值的梯度,然后在运算单元中使用权值梯度对权值进行更新;After performing the inverse operation of the neural network, the gradient of the weights of the layers is calculated. In this step, the first input buffer and the second input buffer of the device are respectively used to store the weights of the layer. And the gradient of the weights, and then use the weight gradient to update the weights in the arithmetic unit;

上文中提到的运算都是神经网络中的一层的运算,对于多层神经网络,其实现过程是,在正向运算中,当上一层人工神经网络执行完成之后,下一层的运算指令会将运算单元中计算出的输出数据作为下一层的输入数据进行运算(或者是对该输出数据进行某些操作再作为下一层的输入数据),同时,将权值也替换为下一层的权值;在反向运算中,当上一层人工神经网络的反向运算执行完成后,下一层运算指令会将运算单元中计算出的输入数据梯度作为下一层的输出数据梯度进行运算(或者是对该输入数据梯度进行某些操作再作为下一层的输出数据梯度),同时将权值替换为下一层的权值;具体如图6b所示,图中虚线的箭头表示反向运算,实线的箭头表示正向运算,各图下面的标注表示图的含义。The operations mentioned above are all operations of a layer in a neural network. For a multi-layer neural network, the implementation process is that, in the forward operation, when the previous artificial neural network is executed, the next layer of operations is performed. The instruction will operate the output data calculated in the operation unit as the input data of the next layer (or perform some operations on the output data as the input data of the next layer), and at the same time, replace the weight with the next one. The weight of one layer; in the reverse operation, when the reverse operation of the upper artificial neural network is completed, the next layer of operation instructions will use the input data gradient calculated in the operation unit as the output data of the next layer. Gradient operation (or some operation on the input data gradient and then as the output data gradient of the next layer), and replace the weight with the weight of the next layer; as shown in Figure 6b, the dotted line in the figure The arrows indicate the reverse operation, the solid arrows indicate the forward operation, and the labels below the respective figures indicate the meaning of the figure.

本申请涉及的数据(即数据块中的数据)为压缩处理后的数据,可在第一映射电路和第二映射电路中实现,具体可参见前述实施例中的相关阐述。The data involved in the present application (that is, the data in the data block) is the compressed data, and can be implemented in the first mapping circuit and the second mapping circuit. For details, refer to the related description in the foregoing embodiment.

下面示例性地给出几种神经网络正向运算的具体实现方法。当第一运算指令为卷积指令时,所述输入数据块(即输入数据块中的数据)为卷积输入数据,所述权值数据(块)为卷积核。下面描述卷积运算,下面的图中一个方块表示一个数据,输入数据用图7a表示(N个样本,每个样本有C个通道,每个通道的特征图的高为H,宽为W),权值也即卷积核用图7b表示(有M个卷积核,每个卷积核有C个通道,高和宽分别为KH和KW)。对于输入数据的N个样本,卷积运算的规则都是一样的,下面解释在一个样本上进行卷积运算的过程,在一个样本上,M个卷积核中的每一个都要进行同样的运算,每 个卷积核运算得到一张平面特征图,M个卷积核最终计算得到M个平面特征图,(对一个样本,卷积的输出是M个特征图),对于一个卷积核,要在一个样本的每一个平面位置进行内积运算,然后沿着H和W方向进行滑动,例如,图7c表示一个卷积核在输入数据的一个样本中右下角的位置进行内积运算的对应图;图7d表示卷积的位置向左滑动一格和图7e表示卷积的位置向上滑动一格。The specific implementation of several neural network forward operations is exemplarily given below. When the first operation instruction is a convolution instruction, the input data block (ie, the data in the input data block) is convolution input data, and the weight data (block) is a convolution kernel. The convolution operation is described below. One block in the following figure represents a data, and the input data is represented by Figure 7a (N samples, each sample has C channels, and the feature map of each channel has a height H and a width W). The weight, that is, the convolution kernel, is represented by Figure 7b (there are M convolution kernels, each convolution kernel has C channels, and the height and width are KH and KW, respectively). The rules for convolution operations are the same for N samples of input data. The following is a process of convolution on a sample. On one sample, each of the M convolution kernels must perform the same. Operation, each convolution kernel operation obtains a plane feature map, and M convolution kernels finally calculate M plane feature maps (for one sample, the convolution output is M feature maps), for a convolution kernel To perform an inner product operation at each plane position of a sample, and then slide in the H and W directions. For example, Figure 7c shows a convolution kernel performing inner product operations at the position of the lower right corner of a sample of the input data. Corresponding to the figure; Fig. 7d shows that the position of the convolution slides one space to the left and Fig. 7e shows that the position of the convolution slides up one space.

具体的,该卷积处理的方式可以采用如图1a所示的芯片结构处理,主处理电路的第一映射电路可将权值的部分或全部卷积核中的数据进行处理,得到对应的mask数据以及处理后的权值数据(即是处理后权值的部分或全部卷积核中的数据)。Specifically, the method of the convolution processing may be performed by using a chip structure as shown in FIG. 1a, and the first mapping circuit of the main processing circuit may process data in part or all of the convolution kernel of the weight to obtain a corresponding mask. Data and processed weight data (that is, data in some or all of the convolution kernels of the processed weights).

主处理电路的控制电路将权值的部分或全部卷积核中的数据(该数据可为原来的权值数据或者处理后的权值数据)发送到通过横向数据输入接口直接与主处理电路相连的那些基础处理电路(也可称为基础单元);同时,控制电路将与该数据对应关联的mask数据也一起发送给与主处理电路连接的基础处理电路中;The control circuit of the main processing circuit sends the data in part or all of the convolution kernel of the weight (the data can be the original weight data or the processed weight data) to be directly connected to the main processing circuit through the horizontal data input interface. The basic processing circuit (also referred to as a base unit); at the same time, the control circuit sends the mask data associated with the data to the basic processing circuit connected to the main processing circuit;

在一种可选方案中,主处理电路的控制电路将权值中某个卷积核的数据每次发送一个数或者一部分数给某个基础处理电路;(例如,对于某一个基础处理电路,第1次发送第3行第1个数,第2次发送第3行数据中的第2个数,第3次发送第3行的第3个数……,或者第1次发送第3行前两个数,第二次发送第3行第3和第4个数,第三次发送第3行第5和第6个数……;)同时,控制电路将该权值中某个卷积核对应的mask数据也采用上述每次发送一个数或一部分数据给那个基础处理电路;In an alternative, the control circuit of the main processing circuit sends a certain number or part of the data of a convolution kernel to a basic processing circuit each time (for example, for a basic processing circuit, The first time, the first number of the third line is transmitted, the second number of the third line of data is transmitted for the second time, the third number of the third line is transmitted for the third time, ..., or the third line is transmitted for the first time. The first two numbers, the second time sends the third and third numbers of the third line, the third time sends the fifth and fifth numbers of the third line...;) At the same time, the control circuit takes a weight in one of the volumes The mask data corresponding to the product core also uses the above-mentioned one or a part of data to be sent to the basic processing circuit each time;

在一种可选方案中另一种情况是,主处理电路的控制电路将权值中某几个卷积核的数据每次各发送一个数或者一部分数给某个基础处理电路;(例如,对于某一个基础处理电路,第1次发送第3,4,5行每行的第1个数,第2次发送第3,4,5行每行的第2个数,第3次发送第3,4,5行每行的第3个数……,或者第1次发送第3,4,5行每行前两个数,第二次发送第3,4,5行每行第3和第4个数,第三次发送第3,4,5行每行第5和第6个数……;)相应地,控制电路将与该权值中某几个卷积核所对应关联的mask数据也采用上述相同的方法每次发送一个数或一部分数据给所述基础处理电路;In another alternative, the control circuit of the main processing circuit sends the data of some convolution kernels of the weights to each of the basic processing circuits each time (for example, For a certain basic processing circuit, the first number of lines in the 3rd, 4th, and 5th lines is transmitted for the first time, and the second number of the 3rd, 4th, and 5th lines is transmitted for the second time, and the third time is transmitted. 3, 4, 5 lines, the 3rd number of each line..., or the first 2, 4, 5 lines, the first two lines, the second time, the 3rd, 4th, 5th line, the third line And the fourth number, the third time, the third, fourth, fifth line, the fifth and sixth numbers of each line...;) correspondingly, the control circuit will be associated with some of the convolution kernels in the weight The mask data also sends a number or a portion of data to the basic processing circuit each time in the same manner as described above;

主处理电路的控制电路把输入数据按照卷积的位置进行划分,主处理电路的控制电路将输入数据中的部分或全部卷积位置中的数据发送到通过竖向数据输入接口直接与主处理电路相连的至少一个基础处理电路;相应地,控制电路同样也会按照卷积的位置对于所述输入数据关联的mask数据进行划分,相应地控制电路同时也会将所述输入数据中的部分或全部卷积位置中的数据所对应的mask数据也一起发送给与主处理电路电性连接的基础处理电路中;The control circuit of the main processing circuit divides the input data according to the position of the convolution, and the control circuit of the main processing circuit sends the data in part or all of the convolution position in the input data to the main processing circuit through the vertical data input interface. Corresponding at least one basic processing circuit; correspondingly, the control circuit also divides the mask data associated with the input data according to the position of the convolution, and accordingly the control circuit also also partially or completely the input data The mask data corresponding to the data in the convolution position is also sent together to the basic processing circuit electrically connected to the main processing circuit;

在一种可选方案中,主处理电路的控制电路将输入数据中某个卷积位置的数据以及与该数据对应关联的mask数据每次发送一个数或者一部分数给某个基础处理电路;(例如,对于某一个基础处理电路,第1次发送第3列第1个数,第2次发送第3列数据中的第2个数,第3次发送第3列的第3个数……,或者第1次发送第3列前两个数,第二次发送第3列第3和第4个数,第三次发送第3列第5和第6个数……;)In an alternative, the control circuit of the main processing circuit sends a certain number or part of the data of a certain convolution position in the input data and the mask data associated with the data to a certain basic processing circuit; For example, for a certain basic processing circuit, the first number of the third column is transmitted for the first time, the second number of the third column of data is transmitted for the second time, and the third number of the third column is transmitted for the third time... , or send the first two numbers in the third column for the first time, the third and fourth numbers in the third column for the second time, and the fifth and sixth numbers in the third column for the third time...;)

在一种可选方案中另一种情况是,主处理电路的控制电路将输入数据中某几个卷积位置的数据以及与该数据对应关联的mask数据每次各发送一个数或者一部分数给某个基础处理电路;(例如,对于某一个基础处理电路,第1次发送第3,4,5列每列的第1个数,第2次发送第3,4,5列每列的第2个数,第3次发送第3,4,5列每列的第3个数……,或者第1次发送第3,4,5列每列前两个数,第二次发送第3,4,5列每列第3和第4个数,第三次发送第3,4,5列每列第5和第6个数……;)In another alternative, the control circuit of the main processing circuit sends data of a certain convolution position in the input data and mask data associated with the data each time by a number or a part of the data. a basic processing circuit; (for example, for a basic processing circuit, the first number of the third, fourth, and fifth columns is sent for the first time, and the second, third, fourth, and fifth columns are for the second 2 digits, the 3rd number of the 3rd, 4th, and 5th columns, the 3rd number of each column..., or the 1st transmission of the 3rd, 4th, and 5th columns, the first two digits, the second transmission of the third digit , 4, 5 columns, 3rd and 4th, and 3rd, 3rd, 4th, 5th, 5th and 6th, each column...;)

基础处理电路接收到权值的数据(具体可为权值中卷积核的数据(简称权值数据)或者与该权值数 据对应关联的mask数据)之后,将该数据通过其横向的数据输出接口传输给其相连接下一个基础处理电路;基础处理电路接收到输入数据的数据(该数据可为主处理电路发送的输入数据以及该输入数据关联的标识mask数据)后,将该数据通过其竖向的数据输出接口传输给与其相连接的下一个基础处理电路;The basic processing circuit receives the data of the weight (specifically, the data of the convolution kernel in the weight (referred to as weight data) or the mask data associated with the weight data), and then outputs the data through the horizontal data thereof. The interface transmits to the next basic processing circuit connected thereto; after receiving the data of the input data (the data can be input data sent by the main processing circuit and the identification mask data associated with the input data), the basic processing circuit passes the data through the interface The vertical data output interface is transmitted to the next basic processing circuit connected thereto;

具体的,主处理电路的控制电路可将输入数据以及该输入数据关联的mask数据一起发送给基础处理电路,基础处理电路接收该输入数据以及该输入数据关联的mask数据;Specifically, the control circuit of the main processing circuit may send the input data and the mask data associated with the input data to the basic processing circuit, and the basic processing circuit receives the input data and the mask data associated with the input data;

每一个基础处理电路对接收到的数据进行运算;具体的,基础处理电路可启用第二映射电路根据输入数据关联的mask数据以及权值数据关联的mask数据(即权值中卷积核所关联的mask数据)得到连接标识数据;再利用连接标识数据选择输入数据以及权值数据中绝对值大于预设阈值的数据进行乘法运算;Each of the basic processing circuits operates on the received data; specifically, the basic processing circuit can enable the second mapping circuit to associate the mask data associated with the input data with the mask data associated with the weight data (ie, the convolution kernel associated with the weights) The mask data is obtained by the connection identification data; and the connection identification data is used to select the input data and the data in which the absolute value of the weight data is greater than a preset threshold is multiplied;

在一种可选方案中,每个基础处理电路中若接收的数据(具体可为待计算的数据块,如权值中卷积核中的数据以及该数据关联的mask数据、输入数据或者该输入数据关联的mask数据)的数据量超过预设阈值时,该基础处理电路将不再接收新的输入数据,如主处理电路将后续发送的权值中某几个卷积核中的数据以及该数据对应关联的mask数据等等,直至基础处理电路中拥有足够的缓存/存储空间,再接收主处理电路新发送的数据。In an optional solution, if the data is received in each basic processing circuit (specifically, the data block to be calculated, such as the data in the convolution kernel in the weight and the mask data, the input data, or the data associated with the data When the amount of data of the mask data of the input data exceeds a preset threshold, the basic processing circuit will no longer receive new input data, such as data in some convolution kernels of the weights subsequently sent by the main processing circuit and The data corresponds to the associated mask data and the like until the base processing circuit has sufficient buffer/storage space, and then receives the newly transmitted data of the main processing circuit.

在一种可选方案中,基础处理电路每次计算一组或多组两个数据的乘法,然后将结果累加到寄存器和/或片上缓存上;In an alternative, the base processing circuit calculates a multiplication of one or more sets of two data at a time, and then accumulates the result on a register and/or an on-chip buffer;

在一种可选方案中,基础处理电路每次计算一组或多组两个向量的内积,然后将结果累加到寄存器和/或片上缓存上;In an alternative, the base processing circuit calculates the inner product of one or more sets of two vectors at a time, and then accumulates the result on the register and/or the on-chip buffer;

基础处理电路计算出结果后,可以将结果从数据输出接口传输出去;After the basic processing circuit calculates the result, the result can be transmitted from the data output interface;

在一种可选方案中,该计算结果可以是内积运算的最终结果或中间结果;In an alternative, the result of the calculation may be the final result or an intermediate result of the inner product operation;

具体地,如果该基础处理电路有直接与主处理电路相连接的输出接口则从该接口传输结果,如果没有,则向着能够直接向主处理电路输出的基础处理电路的方向输出结果。Specifically, if the basic processing circuit has an output interface directly connected to the main processing circuit, the result is transmitted from the interface, and if not, the result is output in the direction of the basic processing circuit that can be directly output to the main processing circuit.

基础处理电路接收到来自其他基础处理电路的计算结果之后,将该数据传输给与其相连接的其他基础处理电路或者主处理电路;After receiving the calculation result from other basic processing circuits, the basic processing circuit transmits the data to other basic processing circuits or main processing circuits connected thereto;

向着能够直接向主处理电路输出的方向输出结果(例如,最下面一行基础处理电路将其输出结果直接输出给主处理电路,其他基础处理电路从竖向的输出接口向下传输运算结果);Output results in a direction that can be directly output to the main processing circuit (for example, the bottom row of the basic processing circuit outputs its output directly to the main processing circuit, and the other basic processing circuits transfer the operation result from the vertical output interface);

主处理电路接收到各个基础处理电路内积运算的结果,即可得到输出结果。The main processing circuit receives the result of the inner product operation of each basic processing circuit, and the output result is obtained.

使用如图1a所示装置可完成张量乘张量的运算,所述张量和前文所述的数据块相同,其可为矩阵、向量、三维数据块、四位数据块以及高维数据块中的任一项或多项的组合;参见前述图2a和图2b分别示出矩阵乘向量和矩阵乘矩阵运算的具体实现方法。具体的,当第一运算指令所指示的正向运算为矩阵乘矩阵运算,所述输入数据为所述矩阵乘矩阵运算的第一矩阵,所述权值为所述矩阵乘矩阵运算的第二矩阵,具体可参见前述图2b实例中矩阵乘矩阵的运算方法的流程图。当所述第一运算指令所指示的正向运算为矩阵乘向量运算,所述输入数据为所述矩阵乘向量运算的第一矩阵,所述权值为所述矩阵乘向量运算的向量,具体可参见前述图2a实例中矩阵乘矩阵的运算方法的流程图。The tensor multiplying tensor operation can be accomplished using the apparatus shown in Figure 1a, which is the same as the data block described above, which can be a matrix, a vector, a three-dimensional data block, a four-bit data block, and a high-dimensional data block. Combination of any one or more of the above; see Figure 2a and Figure 2b above for a specific implementation of matrix multiplication vector and matrix multiplication matrix operation, respectively. Specifically, when the forward operation indicated by the first operation instruction is a matrix multiplication matrix operation, the input data is the first matrix of the matrix multiplication matrix operation, and the weight is the second of the matrix multiplication matrix operation For the matrix, refer to the flowchart of the operation method of the matrix multiplication matrix in the foregoing example of FIG. 2b. When the forward operation indicated by the first operation instruction is a matrix multiplication vector operation, the input data is a first matrix of the matrix multiplication vector operation, and the weight is a vector of the matrix multiplication vector operation, specifically See the flow chart of the operation method of the matrix multiplication matrix in the foregoing example of Fig. 2a.

本披露还提供一种集成电路芯片装置,所述集成电路芯片装置用于执行神经网络的正向运算,所述神经网络包含多层,所述装置包括:处理电路以及外部接口;The present disclosure also provides an integrated circuit chip device for performing a forward operation of a neural network, the neural network comprising a plurality of layers, the device comprising: a processing circuit and an external interface;

所述外部接口,用于接收正向运算指令;The external interface is configured to receive a forward operation instruction;

所述处理电路,用于解析所述正向运算指令得到所述正向运算指令在所述神经网络正向运算中第i层包含的第一运算指令以及所述第一运算指令所需的输入数据块和权值数据块,所述i的取值范围为大于等于1,且小于等于n的整数,如所述i大于等于2,所述输入数据块为第i-1层的输出数据块;The processing circuit is configured to parse the forward operation instruction to obtain a first operation instruction included in the i-th layer of the forward operation instruction and the input required by the first operation instruction in the forward operation of the neural network a data block and a weight data block, wherein the value range of i is an integer greater than or equal to 1, and less than or equal to n, as the i is greater than or equal to 2, and the input data block is an output data block of the i-1th layer. ;

所述处理电路,还用于将输入数据以及权值数据执行所述正向运算的第i层包含的第一运算指令的运算。The processing circuit is further configured to perform the operation of the first operation instruction included in the ith layer of the forward operation by the input data and the weight data.

本披露还揭露了一个神经网络运算装置,其包括一个或多个在如图9e所示的芯片,用于从其他处理装置中获取待运算数据和控制信息,执行指定的神经网络运算,执行结果通过I/O接口传递给外围设备。外围设备譬如摄像头,显示器,鼠标,键盘,网卡,wifi接口,服务器。当包含一个以上如图9e所示的芯片时,如图9e所示的芯片间可以通过特定的结构进行链接并传输数据,譬如,通过PCIE总线进行互联并传输数据,以支持更大规模的神经网络的运算。此时,可以共享同一控制系统,也可以有各自独立的控制系统;可以共享内存,也可以每个加速器有各自的内存。此外,其互联方式可以是任意互联拓扑。该神经网络运算装置具有较高的兼容性,可通过PCIE接口与各种类型的服务器相连接。The present disclosure also discloses a neural network computing device including one or more chips as shown in FIG. 9e for acquiring data to be processed and control information from other processing devices, performing specified neural network operations, and executing results. Passed to the peripheral device through the I/O interface. Peripherals such as cameras, monitors, mice, keyboards, network cards, wifi interfaces, servers. When more than one chip as shown in FIG. 9e is included, the chips shown in FIG. 9e can be linked and transmitted through a specific structure, for example, by interconnecting and transmitting data through the PCIE bus to support larger-scale nerves. Network computing. At this point, you can share the same control system, or you can have separate control systems; you can share memory, or each accelerator has its own memory. In addition, the interconnection method can be any interconnection topology. The neural network computing device has high compatibility and can be connected to various types of servers through a PCIE interface.

下面阐述运算指令为训练指令所涉及的具体实施例。在第一方面提供的装置中,所述集成电路芯片装置,用于接收训练指令,依据该训练指令确定第一层输入数据和第一层权值组数据,对第一层输入数据和第一层权值组数据执行神经网络的n层正向运算得到正向运算的第n输出结果;The specific embodiments involved in the operation instructions as training instructions are set forth below. In the apparatus provided by the first aspect, the integrated circuit chip device is configured to receive a training instruction, determine first layer input data and first layer weight group data according to the training instruction, input data to the first layer, and first The layer weight group data performs the n-th layer forward operation of the neural network to obtain the nth output result of the forward operation;

所述主处理电路,还用于依据所述第n输出结果得到第n输出结果梯度,依据所述训练指令获取第n层反向运算的第n反向运算指令以及所述第n反向运算指令所需的第n层输入数据以及第n层权值组数据;依据所述第n反向运算指令将所述第n输出结果梯度、第n层输入数据以及第n层权值组数据划分为广播数据块和分发数据块;依据所述第n反向运算指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述第n反向运算指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is further configured to obtain an nth output result gradient according to the nth output result, and obtain an nth reverse operation nth inverse operation instruction and the nth inverse operation according to the training instruction The nth layer input data and the nth layer weight group data required by the instruction; dividing the nth output result gradient, the nth layer input data, and the nth layer weight group data according to the nth reverse operation instruction a broadcast data block and a distribution data block; determining, according to the operation control of the nth reverse operation instruction, starting the first mapping circuit to process the first data block, and obtaining the processed first data block; the first data block Include the distribution data block and/or the broadcast data block; transmitting the processed first data block to at least one of the basic processing circuits connected to the main processing circuit according to the nth reverse operation instruction Processing circuit

所述多个基础处理电路,用于依据所述第n反向运算指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the nth reverse operation instruction, whether to start the second mapping circuit to process the second data block, and execute the nerve in parallel according to the processed second data block An operation in the network obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is determined by the basic processing circuit to receive the a data block sent by the main processing circuit, the second data block being associated with the processed first data block;

所述主处理电路,还用于对该运算结果进行处理得到第n层权值组梯度和第n层输入数据梯度,应用所述第n层权值组梯度对第n层权值组数据进行更新;The main processing circuit is further configured to process the operation result to obtain an nth layer weight group gradient and an nth layer input data gradient, and apply the nth layer weight group gradient to the nth layer weight group data. Update

所述集成电路芯片装置,还用于将第n层输入数据梯度作为第n-1层的第n-1输出结果梯度执行n-1层反向运算得到n-1层权值组梯度,应用n-1层权值组梯度更新对应层的权值组数据,所述权值组数据包括至少二个权值。The integrated circuit chip device is further configured to perform an n-1 layer inverse operation on the nth layer input data gradient as an n-1th output gradient of the n-1th layer to obtain an n-1 layer weight group gradient, and apply The n-1 layer weight group gradient updates the weight group data of the corresponding layer, and the weight group data includes at least two weights.

在第一方面提供的装置中,当所述第一数据块包括分发数据块和广播数据块时,所述主处理电路,具体用于启动所述第一映射电路对所述分发数据块和所述广播数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块,处理后的广播数据块以及该广播数据块关联的标识数据块;将所述处理后的分发数据块以及该分发数据块关联的标识数据块进行拆分处理得到多个基本数据块以及所述基本数据块各自关联的标识数据块,将所述多个基本数据块以及所述多个基本数据块各自关联的标 识数据块分发至与其连接的基础处理电路,将所述处理后的广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a distribution data block and a broadcast data block, the main processing circuit is specifically configured to start the first mapping circuit, the distribution data block, and the Processing the broadcast data block to obtain the processed distribution data block and the identification data block associated with the distribution data block, the processed broadcast data block, and the identification data block associated with the broadcast data block; and the processed distribution data block And the identification data block associated with the distribution data block is subjected to split processing to obtain a plurality of basic data blocks and identification data blocks respectively associated with the basic data blocks, and the plurality of basic data blocks and the plurality of basic data blocks are respectively And the associated identification data block is distributed to the basic processing circuit connected thereto, and the processed broadcast data block and the identification data block associated with the broadcast data block are broadcasted to the basic processing circuit connected thereto;

相应地,所述基础处理电路,具体用于启动所述第二映射电路根据所述广播数据块关联的标识数据块和所述基本数据块关联的标识数据获得连接标识数据块,并根据所述连接标识数据块对所述广播数据块和所述基本数据块进行处理得到处理后的广播数据块和基本数据块;对所述处理后的广播数据块和基本数据块执行反向运算得到运算结果,将所述运算结果发送至所述主处理电路;其中。所述反向运算包括但不限于以下中的任一项或多项的组合:卷积运算(即内积运算)、乘积运算、偏执运算、全连接运算、GEMM运算、GEMV运算、激活运算中的一种或任意组合;Correspondingly, the basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the broadcast data block and the identification data associated with the basic data block, and according to the The connection identification data block processes the broadcast data block and the basic data block to obtain a processed broadcast data block and a basic data block; performing inverse operation on the processed broadcast data block and the basic data block to obtain an operation result Transmitting the operation result to the main processing circuit; wherein. The reverse operation includes, but is not limited to, a combination of any one or more of the following: a convolution operation (ie, an inner product operation), a product operation, a paranoid operation, a full connection operation, a GEMM operation, a GEMV operation, and an activation operation. One or any combination of

所述主处理电路,用于对所述运算结果处理得到所述指令结果。The main processing circuit is configured to process the operation result to obtain the instruction result.

在第一方面提供的装置中,当所述第一数据块包括分发数据块时,所述主处理电路,具体用于启动所述第一映射电路对所述分发数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块,或者启动所述第一映射电路根据预存的所述分发数据块关联的标识数据块对所述分发数据块进行处理得到处理后的分发数据块;将所述处理后的分发数据块以及该分发数据块关联的标识数据块进行拆分处理得到多个基本数据块以及所述基本数据块各自关联的标识数据块,将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路,将所述广播数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a distribution data block, the main processing circuit is specifically configured to start processing, by the first mapping circuit, the processing data block to be processed. Distributing the data block and the identification data block associated with the distribution data block, or initiating the first mapping circuit to process the distribution data block according to the pre-stored identification data block associated with the distribution data block to obtain the processed distribution data block And performing the split processing on the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and identification data blocks respectively associated with the basic data blocks, and the plurality of basic data And the identification data block associated with each of the plurality of basic data blocks is distributed to a basic processing circuit connected thereto, and the broadcast data block is broadcasted to a basic processing circuit connected thereto;

所述基础处理电路,具体用于启动所述第二映射电路根据所述基本数据块关联的标识数据块对所述广播数据块进行处理,得到处理后的广播数据块;对所述处理后的广播数据块和所述处理后的基本数据块执行反向运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is specifically configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, to obtain a processed broadcast data block; The broadcast data block and the processed basic data block perform a reverse operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.

在可选实施例中,所述基础处理电路具体可用于启动所述第二映射电路根据所述部分广播数据块关联的标识数据块以及所述基本数据块关联的标识数据块得到连接标识数据块;根据所述连接标识数据对所述部分广播数据块以及所述基本数据块进行处理得到处理后的部分广播数据块以及处理后的基本数据块;对所述处理后的部分广播数据块以及所述处理后的基本数据块执行反向运算。In an optional embodiment, the basic processing circuit is specifically configured to start, by the second mapping circuit, the connection identifier data block according to the identifier data block associated with the partial broadcast data block and the identifier data block associated with the basic data block. Processing the partial broadcast data block and the basic data block according to the connection identification data to obtain a processed partial broadcast data block and the processed basic data block; and the processed partial broadcast data block and the The processed basic data block performs a reverse operation.

在第一方面提供的装置中,当所述第一数据块包括广播数据块时,所述主处理电路,具体用于启动所述第一映射电路对所述广播数据块进行处理,得到处理后的广播数据块以及该广播数据块关联的标识数据块,或者启动所述第一映射电路根据预存的所述广播数据块关联的标识数据块对所述广播数据块进行处理得到处理后的广播数据块;对所述分发数据块进行拆分处理得到多个基本数据块;将所述多个基本数据块分发至与其连接的基础处理电路,将所述处理后的广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;In the apparatus provided by the first aspect, when the first data block includes a broadcast data block, the main processing circuit is specifically configured to start the first mapping circuit to process the broadcast data block, and obtain the processed Broadcast data block and the identification data block associated with the broadcast data block, or the first mapping circuit is configured to process the broadcast data block according to the pre-stored identification data block associated with the broadcast data block to obtain the processed broadcast data. Blocking the distributed data block to obtain a plurality of basic data blocks; distributing the plurality of basic data blocks to a basic processing circuit connected thereto, and the processed broadcast data block and the broadcast data block The associated identification data block is broadcast to the basic processing circuit connected thereto;

所述基础处理电路,具体用于启动所述第二映射电路根据所述广播数据块关联的标识数据块对所述基本数据块进行处理得到处理后的基本数据块;对所述处理后的广播数据块和所述处理后的基本数据块执行反向运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is configured to start, by the second mapping circuit, the basic data block to be processed according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and the processed broadcast The data block and the processed basic data block perform a reverse operation to obtain an operation result, and the operation result is transmitted to the main processing circuit.

在可选实施例中,所述主处理电路,还具体用于将所述处理后的广播数据块和该广播数据块关联的标识数据块进行拆分处理得到多个部分广播数据块以及所述多个部分广播数据块关联的标识数据块;将所述多个部分广播数据块以及所述多个部分广播数据块各自关联的标识数据块通过一次或多次广播给所述基础处理电路;其中,所述多个部分广播数据块组合形成所述广播数据块或处理后的广播数据块。In an optional embodiment, the main processing circuit is further configured to split the processed broadcast data block and the identification data block associated with the broadcast data block to obtain a plurality of partial broadcast data blocks and the And an identifier data block associated with the plurality of partial broadcast data blocks; and the identification data blocks associated with the plurality of partial broadcast data blocks and the plurality of partial broadcast data blocks are broadcast to the basic processing circuit by one or more times; And the plurality of partial broadcast data blocks are combined to form the broadcast data block or the processed broadcast data block.

相应地,所述基础处理电路具体用于根据所述部分广播数据块关联的标识数据块对所述基本数据块进行处理得到处理后的基本数据块;对所述处理后的基本数据块以及所述部分广播数据块执行反向运 算。Correspondingly, the basic processing circuit is configured to process the basic data block according to the identifier data block associated with the partial broadcast data block to obtain a processed basic data block; and the processed basic data block and the The partial broadcast data block performs a reverse operation.

在第一方面提供的装置中,所述第n输出结果梯度为:向量、矩阵、三维数据块、四维数据块以及n维数据块中一种或任意组合;In the apparatus provided by the first aspect, the nth output result gradient is: one or any combination of a vector, a matrix, a three-dimensional data block, a four-dimensional data block, and an n-dimensional data block;

所述第n层输入数据可用张量表示,其具体可为:向量、矩阵、三维数据块、四维数据块以及n维数据块中一种或任意组合;The nth layer input data may be represented by a tensor, which may specifically be: one or any combination of a vector, a matrix, a three-dimensional data block, a four-dimensional data block, and an n-dimensional data block;

所述n层权值组数据可用张量表示,其具体可为:向量、矩阵、三维数据块、四维数据块以及n维数据块中一种或任意组合。The n-layer weight group data may be represented by a tensor, which may specifically be: one or any combination of a vector, a matrix, a three-dimensional data block, a four-dimensional data block, and an n-dimensional data block.

如图8所示,神经网络训练的步骤包括:As shown in Figure 8, the steps of neural network training include:

一个(多层)神经网络中的各层依次执行正向运算;Each layer in a (multi-layer) neural network performs a forward operation in sequence;

按照相反的层的顺序依次执行反向运算得到权值梯度;Performing a reverse operation in the order of the opposite layers to obtain a weight gradient;

用计算得到的权值的梯度去更新正向运算的权值;Using the calculated gradient of weights to update the weight of the forward operation;

这就是神经网络的训练的依次迭代,整个训练过程需要重复执行(即多次迭代计算)这个过程多次。This is the sequential iteration of the training of the neural network. The entire training process requires repeated execution (ie multiple iterations) to process this process multiple times.

参阅图1a,图1a为一种集成电路芯片装置,所述装置用于执行神经网络的训练,该神经网络包含n层,所述n取值范围为大于等于2的整数,其特征在于,所述集成电路芯片装置包括:主处理电路以及多个基础处理电路;所述主处理电路包括第一映射电路,所述多个基础处理电路中至少一个电路包括第二映射电路,所述第一映射电路以及所述第二映射电路均用于执行神经网络运算中的各个数据的压缩处理;Referring to FIG. 1a, FIG. 1a is an integrated circuit chip device for performing training of a neural network, where the neural network includes n layers, and the n value ranges from an integer of 2 or more, characterized in that The integrated circuit chip device includes: a main processing circuit and a plurality of basic processing circuits; the main processing circuit includes a first mapping circuit, and at least one of the plurality of basic processing circuits includes a second mapping circuit, the first mapping The circuit and the second mapping circuit are both used to perform compression processing of each data in the neural network operation;

所述集成电路芯片装置,用于接收训练指令,依据该训练指令确定第一层输入数据和第一层权值组数据,对第一层输入数据和第一层权值组数据执行神经网络的n层正向运算得到正向运算的第n输出结果;The integrated circuit chip device is configured to receive a training instruction, determine first layer input data and first layer weight group data according to the training instruction, and perform a neural network on the first layer input data and the first layer weight group data. The n-th layer forward operation obtains the nth output result of the forward operation;

所述主处理电路,还用于依据所述第n输出结果得到第n输出结果梯度,依据所述训练指令获取第n层反向运算的第n反向运算指令以及所述第n反向运算指令所需的第n层输入数据以及第n层权值组数据;依据所述第n反向运算指令将所述第n输出结果梯度、第n层输入数据以及第n层权值组数据划分为广播数据块和分发数据块;依据所述第n反向运算指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述第n反向运算指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is further configured to obtain an nth output result gradient according to the nth output result, and obtain an nth reverse operation nth inverse operation instruction and the nth inverse operation according to the training instruction The nth layer input data and the nth layer weight group data required by the instruction; dividing the nth output result gradient, the nth layer input data, and the nth layer weight group data according to the nth reverse operation instruction a broadcast data block and a distribution data block; determining, according to the operation control of the nth reverse operation instruction, starting the first mapping circuit to process the first data block, and obtaining the processed first data block; the first data block Include the distribution data block and/or the broadcast data block; transmitting the processed first data block to at least one of the basic processing circuits connected to the main processing circuit according to the nth reverse operation instruction Processing circuit

所述多个基础处理电路,用于依据所述第n反向运算指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the nth reverse operation instruction, whether to start the second mapping circuit to process the second data block, and execute the nerve in parallel according to the processed second data block An operation in the network obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is determined by the basic processing circuit to receive the a data block sent by the main processing circuit, the second data block being associated with the processed first data block;

所述主处理电路,还用于对该运算结果进行处理得到第n层权值组梯度和第n层输入数据梯度,应用所述第n层权值组梯度对第n层权值组数据进行更新;The main processing circuit is further configured to process the operation result to obtain an nth layer weight group gradient and an nth layer input data gradient, and apply the nth layer weight group gradient to the nth layer weight group data. Update

所述集成电路芯片装置,还用于将第n层输入数据梯度作为第n-1层的第n-1输出结果梯度执行n-1层反向运算得到n-1层权值组梯度,应用n-1层权值组梯度更新对应层的权值组数据,所述权值组数据包括至少二个权值。The integrated circuit chip device is further configured to perform an n-1 layer inverse operation on the nth layer input data gradient as an n-1th output gradient of the n-1th layer to obtain an n-1 layer weight group gradient, and apply The n-1 layer weight group gradient updates the weight group data of the corresponding layer, and the weight group data includes at least two weights.

神经网络训练方法Neural network training method

在神经网络训练过程中所涉及到所有或部分数据可以是处理后的数据,具体可参见前述实施例由第一映射电路和/或第二映射电路处理获得,这里不在赘述。All or part of the data involved in the neural network training process may be processed data. For details, refer to the foregoing embodiment, which is obtained by the first mapping circuit and/or the second mapping circuit, and is not described here.

需要说明的是,训练过程的不同时刻(具体来说就是不同的迭代次数或者初始化的时刻)、训练过程中的不同阶段(即正向或者反向运算)、不同的层、同一层中的不同数据块(即多个输入数据块,输出数据块),或者同一个数据块中划分的不同部分的子数据块,都可以是指处理后的数据块。It should be noted that different times of the training process (specifically, different iterations or initialization time), different stages of the training process (ie, forward or reverse operations), different layers, and different layers A data block (ie, multiple input data blocks, an output data block), or a sub-block of a different portion divided in the same data block, may refer to a processed data block.

下面以一个实际的例子来说明神经网络训练的具体实现方法,如图6b所示为单层运算的神经网络训练的具体的计算示意图,如图6b实线示出单层神经网络的正向运算,如图6b虚线示出单层神经网络的反向运算。具体的,先根据输入数据与权值或参数执行本层的正向运算,得到输出数据,再根据输出数据进行预设规则的运算(该预设规则可以由厂家根据自身需要自行设定,这里并不限定该预设规则运算的具体运算步骤)得到本层的输出数据梯度。接着,可根据本层的输入数据、权值或参数、输出数据梯度执行本层神经网络的反向运算,得到本层的输入数据梯度和权值或参数的梯度,可利用计算获得的权值或参数的梯度对应更新本层的权值或参数,即完成了本层神经网络训练。The following is a practical example to illustrate the specific implementation of neural network training. Figure 6b shows the specific calculation of neural network training for single-layer operation. Figure 6b shows the forward operation of single-layer neural network. The reverse operation of the single layer neural network is shown by the dashed line in Fig. 6b. Specifically, the forward operation of the layer is performed according to the input data and the weight or the parameter, and the output data is obtained, and then the preset rule is calculated according to the output data (the preset rule can be set by the manufacturer according to its own needs, here) The specific operation step of the preset rule operation is not limited to obtain the output data gradient of the layer. Then, the inverse operation of the layer neural network can be performed according to the input data, the weight or the parameter of the layer, and the output data gradient, and the gradient of the input data and the gradient of the weight or the parameter of the layer can be obtained, and the weight obtained by the calculation can be used. Or the gradient of the parameter corresponds to updating the weight or parameter of the layer, that is, the neural network training of the layer is completed.

在具体实现过程中,在正向运算或反向运算过程中涉及的数据可为处理后的数据,以正向运算为例,本申请实施例提供的技术方案可为依据本层的反向运算指令确定是否启动相关映射电路(具体可为第一映射电路和/或第二映射电路)对输入数据和/或权值进行处理,然后利用处理后的输入数据和/或权值执行本层运算。对于上述数据处理的原理可参见前述实施例中的相关阐述,这里不再赘述。应理解的,利用上述处理后的数据来执行神经网络运算,可以极大的减少计算器之间的传输开销,另外,对于计算器来说,较少比特位的数据存储的空间也较小,即存储开销会较小,计算量也会减少,即计算开销会减少,所以能够减少计算开销以及存储的开销。In the specific implementation process, the data involved in the forward operation or the reverse operation may be the processed data. Taking the forward operation as an example, the technical solution provided by the embodiment of the present application may be an inverse operation according to the layer. The instruction determines whether to initiate a correlation mapping circuit (specifically, the first mapping circuit and/or the second mapping circuit) to process the input data and/or the weight, and then perform the layer operation using the processed input data and/or weights . For the principle of the above data processing, refer to the related description in the foregoing embodiment, and details are not described herein again. It should be understood that using the above processed data to perform neural network operations can greatly reduce the transmission overhead between the calculators. In addition, for the calculator, the data storage space of fewer bits is also small. That is, the storage overhead will be smaller, the amount of calculation will be reduced, that is, the calculation overhead will be reduced, so the calculation overhead and the storage overhead can be reduced.

下面以图9a和图9b为例,具体给出矩阵乘法和卷积的神经网络训练的结构示意图。其中,图9a展示的本层运算方式为矩阵乘法,图9b展示的本层运算方式为卷积运算,假设本层的输入数据以及权值均为矩阵,为了方便说明这里的输入数据以矩阵I为例,权值以矩阵W为例,其中输出数据=矩阵I*矩阵W;如果矩阵I和矩阵W均为维数较大的稀疏矩阵,这里的稀疏矩阵是指矩阵中包括有绝对值小于等于预设阈值,或者为0的数据较多。维数较大可以理解为矩阵I以及矩阵W的列数量以及行数量之和较大,即可以认为上述矩阵I以及矩阵W在存储器和/或寄存器所占空间较大以及计算量也较大,此时如果按照常规矩阵乘法处理,数据计算量较大;为提高数据处理效率,需将矩阵I以及矩阵W进行处理,然后再执行矩阵乘法的运算。The following is a structural diagram of neural network training for matrix multiplication and convolution, taking FIG. 9a and FIG. 9b as examples. The calculation mode of the layer shown in FIG. 9a is matrix multiplication, and the operation mode of the layer shown in FIG. 9b is a convolution operation, assuming that the input data and the weight of the layer are all matrix, for convenience, the input data is matrix I. For example, the weight is based on the matrix W, where the output data = matrix I * matrix W; if the matrix I and the matrix W are sparse matrices with larger dimensions, the sparse matrix here means that the matrix includes absolute values less than Equal to the preset threshold, or more data with 0. The larger the dimension can be understood as the larger the number of columns of the matrix I and the matrix W and the sum of the number of rows, that is, the matrix I and the matrix W can be considered to occupy a larger space in the memory and/or the register and the calculation amount is larger. At this time, according to the conventional matrix multiplication processing, the amount of data calculation is large; in order to improve the data processing efficiency, the matrix I and the matrix W need to be processed, and then the matrix multiplication operation is performed.

例如,矩阵I为1000*1000的稀疏矩阵,矩阵W也为1000*1000的稀疏矩阵,那么对于列数量以及行数量之和为2000,其数量很大,对应的计算量就更大,矩阵乘以矩阵的内积运算的乘法运算即109次,对于此技术方案,由于矩阵I以及矩阵W的数量很大,不可能一次将所有的数据全部传输和计算,这样同一数据可能会多次传输和计算,如果此时采用数据处理方法,对两个稀疏矩阵进行数据处理,能够很大程度上的降低矩阵I以及矩阵W的维度(即数据量),就可以极大的减少传输的数据量和计算量,进而减少传输开销和计算开销。For example, the matrix I is a sparse matrix of 1000*1000, and the matrix W is also a sparse matrix of 1000*1000. Then, the sum of the number of columns and the number of rows is 2000, the number of which is large, and the corresponding calculation amount is larger, matrix multiplication The multiplication operation of the inner product of the matrix is 109 times. For this technical solution, since the number of the matrix I and the matrix W is large, it is impossible to transmit and calculate all the data at a time, so that the same data may be transmitted multiple times. Calculation, if the data processing method is used at this time, the data processing of the two sparse matrices can greatly reduce the dimension of the matrix I and the matrix W (ie, the amount of data), thereby greatly reducing the amount of data transmitted and Calculate the amount, which in turn reduces transmission overhead and computational overhead.

如图9c和9d示出多层神经网络训练的具体结构示意图。如图9c所示,虚线箭头方向示出一种反向运算。对于反向运算,其反向运算的输出为输出数据梯度;当所述输出数据梯度为多层神经网络迭代计算的最后一层,则该输出数据梯度具体为本次迭代计算的最后一层的输出数据经过预设运算(该预设运算可以由厂家根据自身需要自行设定,这里并不限定该预设运算的具体运算步骤)所得到;如过该输出数据梯度并非为多层神经网络迭代计算的最后一层,例如该输出数据梯度为本次迭代计算的第n层, 那么该第n层的输出数据梯度可为第n+1层反向运算计算得到的输入数据梯度。同理可理解图4d,图4h具体可为多层卷积神经网络训练的示意图(包括正向运算和反向运算),图示中的其他操作可表示为除了卷积层之外的其他层或者层之间的操作,不做限定。A schematic diagram of the specific structure of the multilayer neural network training is shown in Figures 9c and 9d. As shown in Figure 9c, the direction of the dashed arrow shows a reverse operation. For the inverse operation, the output of the inverse operation is the output data gradient; when the output data gradient is the last layer of the iterative calculation of the multilayer neural network, the output data gradient is specifically the last layer of the iterative calculation The output data is subjected to a preset operation (the preset operation can be set by the manufacturer according to his own needs, and the specific operation steps of the preset operation are not limited herein); if the output data gradient is not an iterative for the multilayer neural network The last layer of the calculation, for example, the output data gradient is the nth layer calculated for this iteration, then the output data gradient of the nth layer can be the input data gradient calculated by the n+1th layer inverse operation. Similarly, FIG. 4d can be understood. FIG. 4h can be a schematic diagram of multi-layer convolutional neural network training (including forward operation and reverse operation), and other operations in the figure can be expressed as layers other than the convolution layer. Or the operation between the layers, not limited.

本披露还提供一种集成电路芯片装置,所述集成电路芯片装置用于执行神经网络的训练,所述神经网络包含多层,所述集成电路芯片装置包括:处理电路以及外部接口;The present disclosure also provides an integrated circuit chip device for performing training of a neural network, the neural network comprising a plurality of layers, the integrated circuit chip device comprising: a processing circuit and an external interface;

所述外部接口,用于接收训练指令;The external interface is configured to receive a training instruction;

所述处理电路,用于依据该训练指令确定第一层输入数据和第一层权值数据,通过第一层输入数据和第一层权值数据执行神经网络的n层正向运算得到第n输出结果;The processing circuit is configured to determine first layer input data and first layer weight data according to the training instruction, and perform n-th layer forward operation of the neural network by using the first layer input data and the first layer weight data to obtain the nth Output result

所述处理电路,还用于依据第n输出结果得到第n输出结果梯度,依据所述训练指令获取第n层反向运算的第n反向运算指令以及所述第n反向运算指令所需的第n层输入数据以及第n层权值组数据;依据第n反向运算指令、第n输出结果梯度、第n层输入数据以及第n层权值组数据执行神经网络的n层反向运算得到n层运算的n个权值梯度;The processing circuit is further configured to obtain an nth output result gradient according to the nth output result, and obtain an nth reverse operation instruction of the nth layer reverse operation and the nth reverse operation instruction according to the training instruction. The nth layer input data and the nth layer weight group data; performing n-layer reversal of the neural network according to the nth reverse operation instruction, the nth output result gradient, the nth layer input data, and the nth layer weight group data The operation obtains n weight gradients of the n-layer operation;

所述处理电路,还用于将应用所述n个权值梯度对n层运算的n个权值进行更新。The processing circuit is further configured to update the n weights of the n-layer operation by applying the n weight gradients.

本发明还提供一种芯片,该芯片包含计算装置,该计算装置包括:The present invention also provides a chip, the chip comprising a computing device, the computing device comprising:

包括一个主处理电路,主处理电路中所涉及到的数据可以是压缩处理后的数据,在一种可选实施例中,所述压缩处理后的数据包括至少一个输入神经元或至少一个权值,所述至少一个神经元中的每个神经元大于第一阈值或者,所述至少一个权值中的每个权值大于第二阈值。所述第一阈值和所述第二阈值为用户侧自定义设置的,它们可以相同,也可不同。Including a main processing circuit, the data involved in the main processing circuit may be compressed processed data. In an optional embodiment, the compressed processed data includes at least one input neuron or at least one weight. Each of the at least one neuron is greater than a first threshold or each of the at least one weight is greater than a second threshold. The first threshold and the second threshold are customized by the user side, and they may be the same or different.

在一种可选方案中,主处理电路包括第一映射电路;In an alternative, the main processing circuit includes a first mapping circuit;

在一种可选方案中,主处理电路包括执行数据压缩处理的运算单元,如向量运算单元等;In an alternative, the main processing circuit includes an arithmetic unit that performs data compression processing, such as a vector operation unit;

具体地,包含接收输入数据的数据输入接口;Specifically, a data input interface including receiving input data;

在一种可选方案中,所述接收的数据来源可以是:所述神经网络运算电路装置的外部或所述神经网络运算电路装置的部分或全部基础处理电路;In an alternative, the received data source may be: external to the neural network operation circuit device or part or all of the basic processing circuit of the neural network operation circuit device;

在一种可选方案中,所述数据输入接口可以有多个;具体地,可以包含输出数据的数据输出接口;In an alternative, the data input interface may have multiple; specifically, may include a data output interface for outputting data;

在一种可选方案中,所述输出的数据的去向可以是:所述神经网络运算装置的外部或所述神经网络运算电路装置的部分或全部基础处理电路;In an alternative, the outgoing data may be: external to the neural network computing device or part or all of the basic processing circuit of the neural network computing circuit device;

在一种可选方案中,所述数据输出接口可以有多个;In an alternative, the data output interface may have multiple;

在一种可选方案中,所述主处理电路包括片上缓存和/或寄存器;In an alternative, the main processing circuit includes an on-chip buffer and/or a register;

在一种可选方案中,所述主处理电路中包含运算单元,可以执行数据运算;In an optional implementation, the main processing circuit includes an operation unit, and can perform a data operation;

在一种可选方案中,所述主处理电路中包含算术运算单元;In an optional aspect, the main processing circuit includes an arithmetic operation unit;

在一种可选方案中,所述主处理电路中包含向量运算单元,可以同时对一组数据执行运算;具体地,所述算术运算和/或向量运算可以是任意类型的运算,包括但不限于:两个数相加减乘除,一个数与常数加减乘除,对一个数执行指数运算,幂次运算,对数运算,以及各种非线性运算,对两个数执行比较运算,逻辑运算等。两个向量相加减乘除,一个向量中的每一个元素与常数加减乘除,对向量中的每一个元素执行指数运算,幂次运算,对数运算,以及各种非线性运算等,对一个向量中的每两个对应的元素执行比较运算,逻辑运算等。In an optional implementation, the main processing circuit includes a vector operation unit, and the operation may be performed on a group of data at the same time; specifically, the arithmetic operation and/or the vector operation may be any type of operation, including but not Limited to: two numbers plus, minus, multiply and divide, one number plus constant plus, minus, multiply and divide, perform exponential operation, power operation, logarithm operation, and various nonlinear operations on one number, perform comparison operation on two numbers, logical operation Wait. Two vectors are added, subtracted, multiplied, and divided. Each element in a vector is added, subtracted, multiplied, and divided by a constant. Each element in the vector is subjected to exponential operations, power operations, logarithmic operations, and various nonlinear operations. Each of the two corresponding elements in the vector performs a comparison operation, a logical operation, and the like.

在一种可选方案中,所述主处理电路包括数据重排列单元,用于按照一定的顺序向基础处理电路传输数据,或者按照一定的顺序原地重新排列数据;In an alternative, the main processing circuit includes a data rearranging unit for transmitting data to the basic processing circuit in a certain order, or rearranging the data in place in a certain order;

在一种可选方案中,所述数据排列的顺序包括:对一个多维数据块进行维度顺序的变换;所述数据排列的顺序还可以包括:对一个数据块进行分块以发送到不同的基础处理电路。In an alternative, the order of the data arrangement comprises: performing a dimensional order transformation on a multi-dimensional data block; the order of the data arrangement may further comprise: segmenting a data block to send to a different basis. Processing circuit.

该计算装置还包括多个基础处理电路:每一个基础处理电路用于计算两个向量的内积,计算的方法是,基础处理电路收到的两组数,将这两组数中的元素对应相乘,并且将相乘的结果累加起来;内积的结果传输出去,这里传输出去根据基础处理电路的位置,有可能传输给其他基础处理电路,也可以直接传输给主处理电路。The computing device also includes a plurality of basic processing circuits: each of the basic processing circuits is configured to calculate an inner product of the two vectors, the calculation method is, the two sets of numbers received by the basic processing circuit, and the elements in the two sets of numbers are corresponding Multiply, and accumulate the results of the multiplication; the result of the inner product is transmitted, where it is transmitted according to the position of the basic processing circuit, and may be transmitted to other basic processing circuits, or directly to the main processing circuit.

基础处理电路中所涉及到的数据可以是压缩处理后的数据,在一种可选实施例中,所述压缩处理后的数据包括至少一个输入神经元或至少一个权值,所述至少一个神经元中的每个神经元大于第一阈值或者,所述至少一个权值中的每个权值大于第二阈值。所述第一阈值和所述第二阈值为用户侧自定义设置的,它们可以相同,也可不同。The data involved in the basic processing circuit may be compressed processed data. In an optional embodiment, the compressed processed data includes at least one input neuron or at least one weight, the at least one neural Each of the neurons is greater than a first threshold or each of the at least one weight is greater than a second threshold. The first threshold and the second threshold are customized by the user side, and they may be the same or different.

在一种可选方案中,基础处理电路包括第二映射电路;In an alternative, the basic processing circuit includes a second mapping circuit;

在一种可选方案中,基础处理电路包括执行数据压缩处理的向量运算单元;In an alternative, the basic processing circuit includes a vector operation unit that performs data compression processing;

具体地,包括由片上缓存和/或寄存器构成的存储单元;Specifically, a memory unit including an on-chip buffer and/or a register is included;

具体地,包括一个或多个接收数据的数据输入接口;Specifically, a data input interface including one or more received data;

在一种可选方案中,包括两个数据输入接口,每次从两个数据输入接口处可以分别获得一个或多个数据;In an alternative, two data input interfaces are included, and one or more data can be respectively obtained from two data input interfaces at a time;

在一种可选方案中,基础处理电路可以将从数据输入接口接收到输入数据后保存在寄存器和/或片上缓存中;In an alternative, the basic processing circuit may receive the input data from the data input interface and save it in a register and/or an on-chip buffer;

上述数据输入接口接收数据的来源可以是:其他基础处理电路和/或主处理电路。The source of the data input interface receiving data may be: other basic processing circuits and/or main processing circuits.

所述神经网络运算电路装置的主处理电路;a main processing circuit of the neural network operation circuit device;

所述神经网络运算电路装置的其他基础处理电路(所述神经网络运算电路装置拥有多个基础处理电路);Other basic processing circuits of the neural network operation circuit device (the neural network operation circuit device has a plurality of basic processing circuits);

具体地,包括一个或多个传输输出数据的数据输出接口;Specifically, the data output interface includes one or more transmission output data;

在一种可选方案中,可以将一个或多个数据从数据输出接口传输出去;In an alternative, one or more data can be transmitted from the data output interface;

具体地,通过数据输出接口传输出去的数据可以是:从数据输入接口接收到的数据、保存在片上缓存和/或寄存器中的数据、乘法器运算结果、累加器运算结果或内积运算器运算结果中的一种或任意组合。Specifically, the data transmitted through the data output interface may be: data received from the data input interface, data stored in the on-chip buffer and/or register, multiplier operation result, accumulator operation result, or inner product operator operation One or any combination of the results.

在一种可选方案中,包含三个数据输出接口,其中的两个分别对应于两个数据输入接口,每一层输出上一层从数据输入接口接收到的数据,第三个数据输出接口负责输出运算结果;In an alternative, three data output interfaces are included, two of which correspond to two data input interfaces, each layer outputs a layer of data received from the data input interface, and a third data output interface Responsible for outputting the operation result;

具体地,所述数据输出接口传输数据的去向可以是:上文数据来源和此处的数据去向决定了基础处理电路在装置中的连接关系。Specifically, the data output interface may transmit data in a direction where the data source and the data direction here determine the connection relationship of the basic processing circuit in the device.

所述神经网络运算电路装置的主处理电路;a main processing circuit of the neural network operation circuit device;

所述神经网络运算电路装置的其他基础处理电路,所述神经网络运算电路装置拥有多个基础处理电路;Other basic processing circuits of the neural network operation circuit device, the neural network operation circuit device having a plurality of basic processing circuits;

具体地,包括算术运算电路:该算术运算电路具体可以为:一个或多个乘法器电路、一个或多个累加器电路、一个或多个执行两组数内积运算的电路中的一个或任意组合。Specifically, the arithmetic operation circuit includes: one or more multiplier circuits, one or more accumulator circuits, one or more of one or more circuits that perform two sets of inner product operations. combination.

在一种可选方案中,可以执行两个数的乘法运算,其结果可以保存在片上缓存和/或寄存器上,也可以直接累加到寄存器和/或片上缓存中;In an alternative, two numbers of multiplication operations can be performed, the results of which can be stored in on-chip buffers and/or registers, or directly added to registers and/or on-chip buffers;

在一种可选方案中,可以执行两组数据的内积运算,其结果可以保存在片上缓存和/或寄存器中,也 可以直接累加到寄存器和/或片上缓存中;In an alternative, an inner product operation of the two sets of data can be performed, the result of which can be stored in an on-chip buffer and/or register, or directly added to the register and/or on-chip buffer;

在一种可选方案中,可以执行数据的累加运算,将数据累加到片上缓存和或寄存器中;In an alternative, the data accumulation operation can be performed to accumulate the data into the on-chip buffer and or the register;

具体地,累加器电路被累加的数据,可以是:从数据输入接口接收到的数据、保存在片上缓存和/或寄存器中的数据、乘法器运算结果、累加器运算结果、内积运算器运算结果中的一个或任意组合。Specifically, the accumulated data of the accumulator circuit may be: data received from the data input interface, data stored in the on-chip buffer and/or register, multiplier operation result, accumulator operation result, inner product operator operation One or any combination of the results.

需要说明的是,上述对基础处理电路的描述中所用到的“数据输入接口”和“数据输出接口”是指每一个基础处理电路的数据输入与输出接口,而不是整个装置的数据输入与输出接口。It should be noted that the "data input interface" and "data output interface" used in the above description of the basic processing circuit refer to the data input and output interface of each basic processing circuit, rather than the data input and output of the entire device. interface.

本发明还提供一种神经网络处理器板卡,包括前述实施例所述的集成电路芯片装置,如图1a所示。The present invention also provides a neural network processor board, including the integrated circuit chip device described in the foregoing embodiments, as shown in FIG. 1a.

在本发明提供的板卡中,所述神经网络芯片封装结构还包括:散热装置。In the card provided by the present invention, the neural network chip package structure further includes: a heat sink.

在本发明提供的板卡中,所述神经网络芯片封装结构为下述封装的任意一种:倒装芯片球栅阵列封装、薄型四方扁平式封装、带散热器的四方扁平封装、无引脚四方扁平封装、小间距四方扁平式封装。In the card provided by the present invention, the neural network chip package structure is any one of the following packages: a flip chip ball grid array package, a thin quad flat package, a quad flat package with a heat sink, and no lead Quad flat package, small pitch quad flat package.

本披露还揭露了一个组合处理装置,其包括上述的神经网络运算装置,通用互联接口,和其他处理装置(即通用处理装置)。神经网络运算装置与其他处理装置进行交互,共同完成用户指定的操作。如10a下图为组合处理装置的示意图。The present disclosure also discloses a combined processing apparatus including the above-described neural network computing device, a universal interconnect interface, and other processing devices (i.e., general processing devices). The neural network computing device interacts with other processing devices to perform user-specified operations. As shown in Figure 10a below is a schematic diagram of a combined processing device.

其他处理装置,包括中央处理器CPU、图形处理器GPU、神经网络处理器等通用/专用处理器中的一种或以上的处理器类型。其他处理装置所包括的处理器数量不做限制。其他处理装置作为神经网络运算装置与外部数据和控制的接口,包括数据搬运,完成对本神经网络运算装置的开启、停止等基本控制;其他处理装置也可以和神经网络运算装置协作共同完成运算任务。Other processing devices include processor types of one or more of general purpose/dedicated processors such as a central processing unit CPU, a graphics processing unit GPU, a neural network processor, and the like. The number of processors included in other processing devices is not limited. The other processing device serves as an interface between the neural network computing device and external data and control, including data handling, and completes basic control such as opening and stopping of the neural network computing device; other processing devices may also cooperate with the neural network computing device to complete the computing task.

通用互联接口,用于在所述神经网络运算装置与其他处理装置间传输数据和控制指令。该神经网络运算装置从其他处理装置中获取所需的输入数据,写入神经网络运算装置片上的存储装置;可以从其他处理装置中获取控制指令,写入神经网络运算装置片上的控制缓存;也可以读取神经网络运算装置的存储模块中的数据并传输给其他处理装置。A universal interconnect interface for transmitting data and control commands between the neural network computing device and other processing devices. The neural network computing device acquires the required input data from other processing devices and writes the storage device on the slice of the neural network computing device; the control command can be obtained from the other processing device and written into the control cache on the slice of the neural network computing device; The data in the storage module of the neural network computing device can be read and transmitted to other processing devices.

如图10b所示,可选的,该结构还包括存储装置,用于保存在本运算单元/运算装置或其他运算单元所需要的数据,尤其适用于所需要运算的数据在本神经网络运算装置或其他处理装置的内部存储中无法全部保存的数据。As shown in FIG. 10b, optionally, the structure further includes a storage device for storing data required by the operation unit/operation device or other operation unit, and is particularly suitable for the data required for calculation in the neural network operation device. Data that cannot be saved in the internal storage of other processing devices.

该组合处理装置可以作为手机、机器人、无人机、视频监控设备等设备的SOC片上系统,有效降低控制部分的核心面积,提高处理速度,降低整体功耗。此情况时,该组合处理装置的通用互联接口与设备的某些部件相连接。某些部件譬如摄像头,显示器,鼠标,键盘,网卡,wifi接口。The combined processing device can be used as a SOC on-chip system for mobile phones, robots, drones, video monitoring devices, etc., effectively reducing the core area of the control part, increasing the processing speed, and reducing the overall power consumption. In this case, the universal interconnect interface of the combined processing device is coupled to certain components of the device. Some components such as camera, monitor, mouse, keyboard, network card, wifi interface.

本披露实施例提供了一种神经网络处理器板卡,可用于众多通用或专用的计算系统环境或配置中。例如:个人计算机、服务器计算机、手持设备或便携式设备、平板型设备、智能家居、家电、多处理器系统、基于微处理器的系统、机器人、可编程的消费电子设备、网络个人计算机(personal computer,PC)、小型计算机、大型计算机、包括以上任何系统或设备的分布式计算环境等等。Embodiments of the present disclosure provide a neural network processor board that can be used in numerous general purpose or dedicated computing system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, smart homes, home appliances, multiprocessor systems, microprocessor-based systems, robots, programmable consumer electronics devices, personal computers (personal computers) , PC), small computer, mainframe computer, distributed computing environment including any of the above systems or devices, and so on.

请参照图11a,图11a为本披露实施例提供的一种神经网络处理器板卡的结构示意图。如图11a所示,上述神经网络处理器板卡10包括神经网络芯片封装结构11、第一电气及非电气连接装置12和第一基板(substrate)13。Please refer to FIG. 11a. FIG. 11a is a schematic structural diagram of a neural network processor card according to an embodiment of the present disclosure. As shown in FIG. 11a, the neural network processor board 10 includes a neural network chip package structure 11, a first electrical and non-electrical connection device 12, and a first substrate 13.

本披露对于神经网络芯片封装结构11的具体结构不作限定,可选的,如图11b所示,上述神经网络芯片封装结构11包括:神经网络芯片111、第二电气及非电气连接装置112、第二基板113。The disclosure is not limited to the specific structure of the neural network chip package structure 11. Alternatively, as shown in FIG. 11b, the neural network chip package structure 11 includes: a neural network chip 111, a second electrical and non-electrical connection device 112, and a Two substrates 113.

本披露所涉及的神经网络芯片111的具体形式不作限定,上述的神经网络芯片111包含但不限于将神经网络处理器集成的神经网络晶片,上述晶片可以由硅材料、锗材料、量子材料或分子材料等制成。 根据实际情况(例如:较严苛的环境)和不同的应用需求可将上述神经网络晶片进行封装,以使神经网络晶片的大部分被包裹住,而将神经网络晶片上的引脚通过金线等导体连到封装结构的外边,用于和更外层进行电路连接。The specific form of the neural network chip 111 involved in the disclosure is not limited. The above neural network chip 111 includes, but is not limited to, a neural network chip integrated with a neural network processor, and the above silicon wafer may be made of silicon material, germanium material, quantum material or molecule. Made of materials, etc. The neural network wafer can be packaged according to actual conditions (for example, a more severe environment) and different application requirements, so that most of the neural network wafer is wrapped, and the pins on the neural network wafer are passed through the gold wire. The conductors are connected to the outside of the package structure for electrical connection to the outer layer.

本披露对于神经网络芯片111的具体结构不作限定,可选的,请参照图1a或图1b所示的装置。The specific structure of the neural network chip 111 is not limited in this disclosure. Alternatively, please refer to the device shown in FIG. 1a or 1b.

本披露对于第一基板13和第二基板113的类型不做限定,可以是印制电路板(printed circuit board,PCB)或(printed wiring board,PWB),还可能为其它电路板。对PCB的制作材料也不做限定。The present disclosure is not limited to the types of the first substrate 13 and the second substrate 113, and may be a printed circuit board (PCB) or a printed wiring board (PWB), and may be other circuit boards. There are no restrictions on the materials used to make the PCB.

本披露所涉及的第二基板113用于承载上述神经网络芯片111,通过第二电气及非电气连接装置112将上述的神经网络芯片111和第二基板113进行连接得到的神经网络芯片封装结构11,用于保护神经网络芯片111,便于将神经网络芯片封装结构11与第一基板13进行进一步封装。The second substrate 113 of the present disclosure is used to carry the neural network chip 111, and the neural network chip package structure 11 is obtained by connecting the above-mentioned neural network chip 111 and the second substrate 113 through the second electrical and non-electrical connection device 112. The neural network chip 111 is protected to further encapsulate the neural network chip package structure 11 and the first substrate 13.

对于上述具体的第二电气及非电气连接装置112的封装方式和封装方式对应的结构不作限定,可根据实际情况和不同的应用需求选择合适的封装方式并进行简单地改进,例如:倒装芯片球栅阵列封装(Flip Chip Ball Grid Array Package,FCBGAP),薄型四方扁平式封装(Low-profile Quad Flat Package,LQFP)、带散热器的四方扁平封装(Quad Flat Package with Heat sink,HQFP)、无引脚四方扁平封装(Quad Flat Non-lead Package,QFN)或小间距四方扁平式封装(Fine-pitch Ball Grid Package,FBGA)等封装方式。The structure of the specific second electrical and non-electrical connection device 112 and the corresponding configuration of the packaging method are not limited, and a suitable packaging method can be selected according to actual conditions and different application requirements and simply improved, for example, flip chip Flip Chip Ball Grid Array Package (FCBGAP), Low-profile Quad Flat Package (LQFP), Quad Flat Package with Heat Sink (HQFP), None Packaged in a Quad Flat Non-lead Package (QFN) or a Fine-Pitch Ball Grid Package (FBGA).

倒装芯片(Flip Chip),适用于对封装后的面积要求高或对导线的电感、信号的传输时间敏感的情况下。除此之外可以用引线键合(Wire Bonding)的封装方式,减少成本,提高封装结构的灵活性。Flip Chip is suitable for the case where the area after packaging is required to be high or sensitive to the inductance of the wire and the transmission time of the signal. In addition, wire bonding can be used to reduce the cost and increase the flexibility of the package structure.

球栅阵列(Ball Grid Array),能够提供更多引脚,且引脚的平均导线长度短,具备高速传递信号的作用,其中,封装可以用引脚网格阵列封装(Pin Grid Array,PGA)、零插拔力(Zero Insertion Force,ZIF)、单边接触连接(Single Edge Contact Connection,SECC)、触点阵列(Land Grid Array,LGA)等来代替。Ball Grid Array, which can provide more pins, and the average lead length of the pins is short, which has the function of transmitting signals at high speed. The package can be packaged in Pin Grid Array (PGA). Zero Insertion Force (ZIF), Single Edge Contact Connection (SECC), Land Grid Array (LGA), etc.

可选的,采用倒装芯片球栅阵列(Flip Chip Ball Grid Array)的封装方式对神经网络芯片111和第二基板113进行封装,具体的神经网络芯片封装结构的示意图可参照图12a。如图12a所示,上述神经网络芯片封装结构包括:神经网络芯片21、焊盘22、焊球23、第二基板24、第二基板24上的连接点25、引脚26。Optionally, the neural network chip 111 and the second substrate 113 are encapsulated by using a flip chip ball grid array (Flip Chip Ball Grid Array). For a schematic diagram of a specific neural network chip package structure, reference may be made to FIG. 12a. As shown in FIG. 12a, the neural network chip package structure includes a neural network chip 21, a pad 22, a solder ball 23, a second substrate 24, a connection point 25 on the second substrate 24, and a lead 26.

其中,焊盘22与神经网络芯片21相连,通过在焊盘22和第二基板24上的连接点25之间焊接形成焊球23,将神经网络芯片21和第二基板24连接,即实现了神经网络芯片21的封装。Wherein, the pad 22 is connected to the neural network chip 21, and the solder ball 23 is soldered between the pad 22 and the connection point 25 on the second substrate 24 to connect the neural network chip 21 and the second substrate 24, thereby realizing The package of the neural network chip 21.

引脚26用于与封装结构的外部电路(例如,神经网络处理器板卡10上的第一基板13)相连,可实现外部数据和内部数据的传输,便于神经网络芯片21或神经网络芯片21对应的神经网络处理器对数据进行处理。对于引脚的类型和数量本披露也不作限定,根据不同的封装技术可选用不同的引脚形式,并遵从一定规则进行排列。The pin 26 is used for connecting with an external circuit of the package structure (for example, the first substrate 13 on the neural network processor board 10), and can realize transmission of external data and internal data, facilitating the neural network chip 21 or the neural network chip 21. The corresponding neural network processor processes the data. The type and number of pins are not limited in this disclosure. Different pin types may be selected according to different packaging technologies, and are arranged according to certain rules.

可选的,上述神经网络芯片封装结构还包括绝缘填充物,置于焊盘22、焊球23和连接点25之间的空隙中,用于防止焊球与焊球之间产生干扰。Optionally, the neural network chip package structure further includes an insulating filler disposed in the gap between the pad 22, the solder ball 23 and the connection point 25 for preventing interference between the solder ball and the solder ball.

其中,绝缘填充物的材料可以是氮化硅、氧化硅或氧氮化硅;干扰包含电磁干扰、电感干扰等。The material of the insulating filler may be silicon nitride, silicon oxide or silicon oxynitride; the interference includes electromagnetic interference, inductance interference and the like.

可选的,上述神经网络芯片封装结构还包括散热装置,用于散发神经网络芯片21运行时的热量。其中,散热装置可以是一块导热性良好的金属片、散热片或散热器,例如,风扇。Optionally, the neural network chip package structure further includes a heat dissipation device for dissipating heat of the neural network chip 21 during operation. The heat sink may be a piece of metal with good thermal conductivity, a heat sink or a heat sink, for example, a fan.

举例来说,如图12b所示,神经网络芯片封装结构11包括:神经网络芯片21、焊盘22、焊球23、第二基板24、第二基板24上的连接点25、引脚26、绝缘填充物27、散热膏28和金属外壳散热片29。 其中,散热膏28和金属外壳散热片29用于散发神经网络芯片21运行时的热量。For example, as shown in FIG. 12b, the neural network chip package structure 11 includes: a neural network chip 21, a pad 22, a solder ball 23, a second substrate 24, a connection point 25 on the second substrate 24, and a pin 26, Insulating filler 27, thermal grease 28 and metal housing fins 29. Among them, the heat dissipation paste 28 and the metal case heat sink 29 are used to dissipate the heat of the neural network chip 21 during operation.

可选的,上述神经网络芯片封装结构11还包括补强结构,与焊盘22连接,且内埋于焊球23中,以增强焊球23与焊盘22之间的连接强度。Optionally, the neural network chip package structure 11 further includes a reinforcing structure, is connected to the pad 22, and is embedded in the solder ball 23 to enhance the connection strength between the solder ball 23 and the pad 22.

其中,补强结构可以是金属线结构或柱状结构,在此不做限定。The reinforcing structure may be a metal wire structure or a columnar structure, which is not limited herein.

本披露对于第一电气及非电气装置12的具体形式也不作限定,可参照第二电气及非电气装置112的描述,即通过焊接的方式将神经网络芯片封装结构11进行封装,也可以采用连接线连接或插拔方式连接第二基板113和第一基板13的方式,便于后续更换第一基板13或神经网络芯片封装结构11。The present disclosure is not limited to the specific form of the first electrical and non-electrical device 12, and the description of the second electrical and non-electrical device 112 may be referred to, that is, the neural network chip package structure 11 may be packaged by soldering, or may be connected. The manner of connecting the second substrate 113 and the first substrate 13 by wire connection or plugging and unplugging facilitates subsequent replacement of the first substrate 13 or the neural network chip package structure 11.

可选的,第一基板13包括用于扩展存储容量的内存单元的接口等,例如:同步动态随机存储器(Synchronous Dynamic Random Access Memory,SDRAM)、双倍速率同步动态随机存储器(Double Date Rate SDRAM,DDR)等,通过扩展内存提高了神经网络处理器的处理能力。Optionally, the first substrate 13 includes an interface of a memory unit for expanding a storage capacity, for example, a Synchronous Dynamic Random Access Memory (SDRAM), and a Double Rate Rate SDRAM (Double Rate Rate SDRAM). DDR), etc., improve the processing power of the neural network processor by expanding the memory.

第一基板13上还可包括快速外部设备互连总线(Peripheral Component Interconnect-Express,PCI-E或PCIe)接口、小封装可热插拔(Small Form-factor Pluggable,SFP)接口、以太网接口、控制器局域网总线(Controller Area Network,CAN)接口等等,用于封装结构和外部电路之间的数据传输,可提高运算速度和操作的便利性。The first substrate 13 may further include a Peripheral Component Interconnect-Express (PCI-E or PCIe) interface, a Small Form-factor Pluggable (SFP) interface, and an Ethernet interface. Controller Area Network (CAN) interface, etc., used for data transmission between the package structure and external circuits, which can improve the operation speed and convenience of operation.

将神经网络处理器封装为神经网络芯片111,将神经网络芯片111封装为神经网络芯片封装结构11,将神经网络芯片封装结构11封装为神经网络处理器板卡10,通过板卡上的接口(插槽或插芯)与外部电路(例如:计算机主板)进行数据交互,即直接通过使用神经网络处理器板卡10实现神经网络处理器的功能,并保护神经网络芯片111。且神经网络处理器板卡10上还可添加其他模块,提高了神经网络处理器的应用范围和运算效率。The neural network processor is packaged as a neural network chip 111, the neural network chip 111 is packaged as a neural network chip package structure 11, and the neural network chip package structure 11 is packaged as a neural network processor board 10, through an interface on the board ( The slot or ferrule) performs data interaction with an external circuit (for example, a computer motherboard), that is, directly implements the function of the neural network processor by using the neural network processor board 10, and protects the neural network chip 111. Moreover, other modules can be added to the neural network processor board 10, which improves the application range and computational efficiency of the neural network processor.

在一个实施例中,本发明公开了一种神经网络运算装置,其包括用于执行如上所述方法实施例中提供的所有或部分实施方式所对应的功能单元。In one embodiment, the present invention discloses a neural network computing device that includes functional units for performing all or part of the embodiments provided in the method embodiments described above.

在一个实施例里,本发明公开了一种芯片,用于执行如上所述方法实施例中提供的所有或部分实施方式。In one embodiment, the present invention discloses a chip for performing all or part of the embodiments provided in the method embodiments described above.

在一个实施例里,本发明公开了一种电子装置,其包括用于执行如上所述方法实施例中的所有或部分实施方式的功能单元。In one embodiment, the present invention discloses an electronic device comprising functional units for performing all or part of the embodiments of the method as described above.

电子装置包括数据处理装置、机器人、电脑、打印机、扫描仪、平板电脑、智能终端、手机、行车记录仪、导航仪、传感器、摄像头、服务器、相机、摄像机、投影仪、手表、耳机、移动存储、可穿戴设备、交通工具、家用电器、和/或医疗设备。Electronic devices include data processing devices, robots, computers, printers, scanners, tablets, smart terminals, mobile phones, driving recorders, navigators, sensors, cameras, servers, cameras, camcorders, projectors, watches, headphones, mobile storage , wearables, vehicles, household appliances, and/or medical equipment.

所述交通工具包括飞机、轮船和/或车辆;所述家用电器包括电视、空调、微波炉、冰箱、电饭煲、加湿器、洗衣机、电灯、燃气灶、油烟机;所述医疗设备包括核磁共振仪、B超仪和/或心电图仪。The vehicle includes an airplane, a ship, and/or a vehicle; the household appliance includes a television, an air conditioner, a microwave oven, a refrigerator, a rice cooker, a humidifier, a washing machine, an electric lamp, a gas stove, a range hood; the medical device includes a nuclear magnetic resonance instrument, B-ultrasound and / or electrocardiograph.

以上所述的具体实施例,对本披露的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本披露的具体实施例而已,并不用于限制本披露,凡在本披露的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本披露的保护范围之内。The specific embodiments of the present invention have been described in detail with reference to the specific embodiments of the present disclosure. It is understood that the above description is only the specific embodiment of the disclosure, and is not intended to limit the disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this disclosure are intended to be included within the scope of the disclosure.

Claims (22)

一种集成电路芯片装置,其特征在于,所述集成电路芯片装置包括:主处理电路以及多个基础处理电路;所述主处理电路包括第一映射电路,所述多个基础处理电路中至少一个电路包括第二映射电路,所述第一映射电路以及所述第二映射电路均用于执行神经网络运算中的各个数据的压缩处理;An integrated circuit chip device, comprising: a main processing circuit and a plurality of basic processing circuits; the main processing circuit comprising a first mapping circuit, at least one of the plurality of basic processing circuits The circuit includes a second mapping circuit, each of the first mapping circuit and the second mapping circuit for performing compression processing of each data in the neural network operation; 所述主处理电路,用于执行神经网络运算中的各个连续的运算以及与所述基础处理电路传输数据;The main processing circuit is configured to perform each successive operation in the neural network operation and transmit data with the basic processing circuit; 所述多个基础处理电路,用于依据所述主处理电路传输的数据以并行方式执行神经网络中的运算,并将运算结果传输给所述主处理电路。The plurality of basic processing circuits are configured to perform operations in the neural network in parallel according to data transmitted by the main processing circuit, and transmit the operation results to the main processing circuit. 根据权利要求1所述的集成电路芯片装置,其特征在于,所述集成电路芯片装置还包括:分支处理电路,所述分支处理电路设置在主处理电路与至少一个基础处理电路之间;The integrated circuit chip device according to claim 1, wherein the integrated circuit chip device further comprises: a branch processing circuit, the branch processing circuit being disposed between the main processing circuit and the at least one basic processing circuit; 所述分支处理电路,用于在主处理电路与至少一个基础处理电路之间转发数据;The branch processing circuit is configured to forward data between the main processing circuit and the at least one basic processing circuit; 其中,所述分支处理电路包含多个分支处理电路,所述主处理电路与所述多个分支处理电路分别连接,每个分支处理电路与至少一个基础处理电路连接。The branch processing circuit includes a plurality of branch processing circuits, the main processing circuit and the plurality of branch processing circuits are respectively connected, and each branch processing circuit is connected to at least one basic processing circuit. 根据权利要求1所述的集成电路芯片装置,其特征在于,The integrated circuit chip device according to claim 1, wherein 所述主处理电路,用于获取待计算的数据块以及运算指令,依据所述运算指令将所述待计算的数据块划分为分发数据块和广播数据块;启动所述第一映射电路对所述分发数据块和所述广播数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块、处理后的广播数据块以及该广播数据块关联的标识数据块;将所述处理后分发数据块和该分发数据块关联的标识数据块进行拆分得到多个基本数据块以及所述多个基本数据块各自关联的标识数据块;将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路,将所述广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;The main processing circuit is configured to acquire a data block to be calculated and an operation instruction, and divide the data block to be calculated into a distribution data block and a broadcast data block according to the operation instruction; and start the first mapping circuit Processing the data block and the broadcast data block to process the processed distribution data block, the identification data block associated with the distribution data block, the processed broadcast data block, and the identification data block associated with the broadcast data block; The processed distribution data block and the identification data block associated with the distribution data block are split to obtain a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; the plurality of basic data blocks and the An identification data block associated with each of the plurality of basic data blocks is distributed to a basic processing circuit connected thereto, and the broadcast data block and the identification data block associated with the broadcast data block are broadcasted to a basic processing circuit connected thereto; 所述基础处理电路,用于启动所述第二映射电路依据所述基本数据块关联的标识数据块以及所述广播数据块关联的标识数据块得到连接标识数据块;根据所述连接标识数据块对所述基本数据块以及所述广播数据块进行处理,对处理后的基本数据块以及处理后的广播数据块执行内积运算得到运算结果,将所述运算结果发送至所述主处理电路;The basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the basic data block and the identification data block associated with the broadcast data block; and identify the data block according to the connection Processing the basic data block and the broadcast data block, performing an inner product operation on the processed basic data block and the processed broadcast data block to obtain an operation result, and transmitting the operation result to the main processing circuit; 所述主处理电路,用于对所述运算结果处理得到所述待计算的数据块以及运算指令所对应的指令结果。The main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result corresponding to the operation instruction. 根据权利要求1所述的集成电路芯片装置,其特征在于,The integrated circuit chip device according to claim 1, wherein 所述主处理电路,用于获取待计算的数据块以及运算指令,依据所述运算指令将所述待计算的数据块划分为分发数据块和广播数据块;启动所述第一映射电路对所述分发数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块,或者启动所述第一映射电路根据预存所述分发数据块关联的标识数据块对所述分发数据块进行处理得到处理后的分发数据块;将所述处理后的分发数据块以及该分发数据块关联的标识数据块进行拆分得到多个基本数据块以及所述多个基本数据块各自关联的标识数据块;将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路;将所述广播数据块广播至与其连接的基础处理电路;The main processing circuit is configured to acquire a data block to be calculated and an operation instruction, and divide the data block to be calculated into a distribution data block and a broadcast data block according to the operation instruction; and start the first mapping circuit The distribution data block is processed to obtain the processed distribution data block and the identification data block associated with the distribution data block, or the first mapping circuit is activated to store the distribution data block according to the identifier data block associated with the pre-stored distribution data block. Processing the processed distribution data block; and separating the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and identifiers associated with each of the plurality of basic data blocks a data block; distributing the plurality of basic data blocks and the identification data blocks respectively associated with the plurality of basic data blocks to a base processing circuit connected thereto; broadcasting the broadcast data block to a base processing circuit connected thereto; 所述基础处理电路,用于启动所述第二映射电路依据所述基本数据块关联的标识数据块对所述广播数据块进行处理,对处理后的广播数据块以及所述基本数据块执行内积运算得到运算结果,将所述运算结果发送至所述主处理电路;The basic processing circuit is configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, and execute the processed broadcast data block and the basic data block The product operation obtains an operation result, and the operation result is sent to the main processing circuit; 所述主处理电路,用于对所述运算结果处理得到所述待计算的数据块以及运算指令的指令结果。The main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result of the operation instruction. 根据权利要求1所述的集成电路芯片装置,其特征在于,The integrated circuit chip device according to claim 1, wherein 所述主处理电路,用于获取待计算的数据块以及运算指令,依据所述运算指令将所述待计算的数据块划分为分发数据块和广播数据块;启动所述第一映射电路对所述广播数据块进行处理得到处理后的广播数据块以及该广播数据块关联的标识数据块,或者启动所述第一映射电路依据预存的所述广播数据块关联的标识数据块对所述广播数据块进行处理得到处理后的广播数据块;将所述分发数据块进行拆分得到多个基本数据块;将所述多个基本数据分发至与其连接的基础处理电路;将所述处理后的广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;The main processing circuit is configured to acquire a data block to be calculated and an operation instruction, and divide the data block to be calculated into a distribution data block and a broadcast data block according to the operation instruction; and start the first mapping circuit Processing the broadcast data block to obtain the processed broadcast data block and the identification data block associated with the broadcast data block, or initiating the first mapping circuit to perform the broadcast data according to the pre-stored identification data block associated with the broadcast data block. Processing the block to obtain a processed broadcast data block; splitting the distributed data block to obtain a plurality of basic data blocks; distributing the plurality of basic data to a base processing circuit connected thereto; and transmitting the processed broadcast The data block and the identification data block associated with the broadcast data block are broadcast to a basic processing circuit connected thereto; 所述基础处理电路,用于启动所述第二映射电路依据所述广播数据块关联的标识数据块对所述基本数据块进行处理得到处理后的基本数据块;对所述处理后的基本数据块以及所述处理后的广播数据块执行内积运算得到运算结果,将所述运算结果发送至所述主处理电路;The basic processing circuit is configured to start, by the second mapping circuit, processing the basic data block according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and processing the processed basic data. Performing an inner product operation on the block and the processed broadcast data block to obtain an operation result, and transmitting the operation result to the main processing circuit; 所述主处理电路,用于对所述运算结果处理得到所述待计算的数据块以及运算指令所对应的指令结果。The main processing circuit is configured to process the operation result to obtain the data block to be calculated and the instruction result corresponding to the operation instruction. 根据权利要求3-5中任一项所述的集成电路芯片装置,其特征在于,所述待计算的数据块包括至少一个权值,和/或至少一个输入神经元。The integrated circuit chip arrangement according to any of claims 3-5, wherein the data block to be calculated comprises at least one weight, and/or at least one input neuron. 根据权利要求6所述的集成电路芯片装置,其特征在于,当所述标识数据块用直接索引表示时,所述标识数据块是由0和1组成的矩阵数据块,其中,0表示所述权值或者所述输入神经元的绝对值小于或等于第一阈值,1表示所述权值或者所述输入神经元的绝对值大于第一阈值。The integrated circuit chip device according to claim 6, wherein when said identification data block is represented by a direct index, said identification data block is a matrix data block composed of 0 and 1, wherein 0 represents said The weight or the absolute value of the input neuron is less than or equal to the first threshold, and 1 represents the weight or the absolute value of the input neuron is greater than the first threshold. 根据权利要求3-5中任一项所述的集成电路芯片装置,其特征在于,The integrated circuit chip device according to any one of claims 3 to 5, wherein 所述基础处理电路,具体用于对该基本数据块与该广播数据块执行内积处理得到内积结果,将所述内积处理结果累加得到运算结果,将所述运算结果发送至所述主处理电路;The basic processing circuit is configured to perform inner product processing on the basic data block and the broadcast data block to obtain an inner product result, accumulate the inner product processing result to obtain an operation result, and send the operation result to the main Processing circuit 所述主处理电路,用于在如所述运算结果为内积处理的结果时,对所述运算结果累加后得到累加结果,将该累加结果排列得到所述待计算的数据块以及运算指令所对应的指令结果。The main processing circuit is configured to, when the result of the operation is the result of the inner product processing, accumulate the operation result to obtain an accumulation result, and arrange the accumulation result to obtain the data block to be calculated and the operation instruction unit. Corresponding instruction result. 根据权利要求3-5中任一项所述的集成电路芯片装置,其特征在于,The integrated circuit chip device according to any one of claims 3 to 5, wherein 所述主处理电路,具体用于将所述处理后的广播数据块以及该广播数据块关联的标识数据块进行拆分得到多个部分广播数据块以及所述多个部分广播数据块各自关联的标识数据块;将所述多个部分广播数据块以及所述多个部分广播数据块各自关联的标识数据块通过一次或多次广播至所述基础处理电路;所述多个部分广播数据块组合形成所述处理后的广播数据块;The main processing circuit is configured to split the processed broadcast data block and the identification data block associated with the broadcast data block to obtain a plurality of partial broadcast data blocks and the plurality of partial broadcast data blocks respectively associated with each other. Identifying a data block; broadcasting the plurality of partial broadcast data blocks and the identification data blocks respectively associated with the plurality of partial broadcast data blocks to the basic processing circuit by one or more times; the plurality of partial broadcast data block combinations Forming the processed broadcast data block; 所述基础处理电路,具体用于启动所述第二映射电路依据所述部分广播数据块关联的标识数据块以及所述基本数据块关联的标识数据块得到连接标识数据块;根据所述连接标识数据块对所述部分广播数 据块以及所述基本数据块进行处理得到处理后的广播数据块以及处理后的基本数据块;对所述处理后的广播数据块以及处理后的基本数据块执行内积运算;The basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the partial broadcast data block and the identification data block associated with the basic data block; according to the connection identifier Processing, by the data block, the partial broadcast data block and the basic data block to obtain the processed broadcast data block and the processed basic data block; and executing the processed broadcast data block and the processed basic data block Product operation 或者,所述基础处理电路,具体用于启动所述第二映射电路依据所述部分广播数据块关联的标识数据块对所述基本数据块进行处理得到处理后的基本数据块,对所述处理后的基本数据以及所述部分广播数据块执行内积运算。Or the basic processing circuit is configured to start, by the second mapping circuit, the basic data block to be processed according to the identifier data block associated with the partial broadcast data block, and the processed basic data block is processed. The subsequent basic data and the partial broadcast data block perform an inner product operation. 根据权利要求3-5中任一项所述的集成电路芯片装置,其特征在于,The integrated circuit chip device according to any one of claims 3 to 5, wherein 所述基础处理电路,具体用于将该部分广播数据块与该基本数据块执行一次内积处理后得到内积处理结果,将所述内积处理结果累加得到部分运算结果,将所述部分运算结果发送至所述主处理电路;或者,The basic processing circuit is specifically configured to perform inner product processing on the partial broadcast data block and the basic data block to obtain an inner product processing result, and accumulate the inner product processing result to obtain a partial operation result, and the partial operation result The result is sent to the main processing circuit; or 所述基础处理电路,具体用于复用n次该部分广播数据块执行该部分广播数据块与n个该基本数据块的内积运算得到n个部分处理结果,将n个部分处理结果分别累加后得到n个部分运算结果,将所述n个部分运算结果发送至主处理电路,所述n为大于等于2的整数。The basic processing circuit is specifically configured to multiplex the partial broadcast data block n times to perform an inner product operation of the partial broadcast data block and the n basic data blocks to obtain n partial processing results, and accumulate the n partial processing results respectively. Then, n partial operation results are obtained, and the n partial operation results are sent to the main processing circuit, and the n is an integer greater than or equal to 2. 根据权利要求3所述的集成电路芯片装置,其特征在于,所述运算指令为卷积指令,The integrated circuit chip device according to claim 3, wherein said operation instruction is a convolution instruction. 所述主处理电路,用于获取输入数据块、卷积核数据块以及卷积指令,依据所述卷积指令将所述输入数据块划分成广播数据块,将所述卷积核数据块划分成分发数据块;依据所述卷积指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述卷积指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is configured to acquire an input data block, a convolution kernel data block, and a convolution instruction, and divide the input data block into a broadcast data block according to the convolution instruction, and divide the convolution kernel data block into Generating a data block; determining, according to the operation control of the convolution instruction, starting the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and And the broadcast data block; transmitting the processed first data block to at least one of the basic processing circuits connected to the main processing circuit according to the convolution instruction; 所述多个基础处理电路,用于依据所述卷积指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the convolution instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block. Calculating an operation result, and transmitting the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is the receiving the main processing circuit determined by the basic processing circuit a transmitted data block, the second data block being associated with the processed first data block; 所述主处理电路,用于将所述运算结果处理得到所述卷积指令的指令结果。The main processing circuit is configured to process the operation result to obtain an instruction result of the convolution instruction. 根据权利要求3所述的集成电路芯片装置,其特征在于,所述运算指令为乘法指令,The integrated circuit chip device according to claim 3, wherein said operation instruction is a multiplication instruction. 所述主处理电路,用于获取输入数据块、权值数据块以及乘法指令,依据所述乘法指令将所述输入数据块划分成分发数据块,将所述权值数据块划分成广播数据块;依据所述乘法指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述乘法指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is configured to acquire an input data block, a weight data block, and a multiplication instruction, and divide the input data block into a data block according to the multiplication instruction, and divide the weight data block into a broadcast data block. And determining, according to the operation control of the multiplication instruction, starting the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast a data block; transmitting, according to the multiplication instruction, the processed first data block to at least one of the basic processing circuits connected to the main processing circuit; 所述多个基础处理电路,用于依据所述乘法指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the multiplication instruction, whether to start the second mapping circuit to process the second data block, and perform the operation in the neural network in parallel according to the processed second data block. Obtaining an operation result, and transmitting the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is sent by the main processing circuit determined by the basic processing circuit Data block, the second data block is associated with the processed first data block; 所述主处理电路,用于将所述运算结果处理得到所述乘法指令的指令结果。The main processing circuit is configured to process the operation result to obtain an instruction result of the multiplication instruction. 根据权利要求3所述的集成电路芯片装置,其特征在于,所述运算指令为正向运算指令,The integrated circuit chip device according to claim 3, wherein said operation instruction is a forward operation instruction. 所述主处理电路,用于接收正向运算指令,解析所述正向运算指令得到所述正向运算指令在所述神经网络正向运算中的第i层所包含的第一运算指令以及所述第一运算指令所需的输入数据块以及权值数据块,所述i的取值范围为大于等于1,且小于等于n的整数,如所述i大于等于2,所述输入数据块为第i-1层的输出数据块;The main processing circuit is configured to receive a forward operation instruction, and parse the forward operation instruction to obtain a first operation instruction included in an ith layer of the forward operation instruction in the forward operation of the neural network An input data block and a weight data block required by the first operation instruction, wherein the range of i is an integer greater than or equal to 1, and less than or equal to n, and if the i is greater than or equal to 2, the input data block is Output data block of layer i-1; 所述主处理电路,用于依据所述第一运算指令将所述输入数据块划分成广播数据块,将所述卷积核数据块划分成分发数据块;依据所述第一正向指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述卷积指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is configured to divide the input data block into a broadcast data block according to the first operation instruction, and divide the convolution kernel data block into a data block; according to the first forward instruction The operation control determines to start the first mapping circuit to process the first data block to obtain the processed first data block; the first data block includes the distribution data block and/or the broadcast data block; The product instruction sends the processed first data block to at least one of the basic processing circuits connected to the main processing circuit; 所述多个基础处理电路,用于依据所述第一运算指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the first operation instruction, whether to start the second mapping circuit to process the second data block, and execute the neural network in a parallel manner according to the processed second data block. The operation obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is the receiving the main processing determined by the basic processing circuit a data block sent by the circuit, the second data block being associated with the processed first data block; 所述主处理电路,用于将所述运算结果进行处理得到所述第一运算指令的指令结果,完成所述第i层包含的所述第一运算指令的运算。The main processing circuit is configured to process the operation result to obtain an instruction result of the first operation instruction, and complete an operation of the first operation instruction included in the ith layer. 根据权利要求3所述的集成电路芯片装置,其特征在于,所述装置用于执行的神经网络的训练,该神经网络包含n层,所述n取值范围为大于等于2的整数,所述运算指令为训练指令,The integrated circuit chip device according to claim 3, wherein said device is configured to perform training of a neural network, said neural network comprising n layers, said n value range being an integer greater than or equal to 2, said The operation instruction is a training instruction, 所述集成电路芯片装置,用于接收训练指令,依据该训练指令确定第一层输入数据和第一层权值组数据,对第一层输入数据和第一层权值组数据执行神经网络的n层正向运算得到正向运算的第n输出结果;The integrated circuit chip device is configured to receive a training instruction, determine first layer input data and first layer weight group data according to the training instruction, and perform a neural network on the first layer input data and the first layer weight group data. The n-th layer forward operation obtains the nth output result of the forward operation; 所述主处理电路,还用于依据所述第n输出结果得到第n输出结果梯度,依据所述训练指令获取第n层反向运算的第n反向运算指令以及所述第n反向运算指令所需的第n层输入数据以及第n层权值组数据;依据所述第n反向运算指令将所述第n输出结果梯度、第n层输入数据以及第n层权值组数据划分为广播数据块和分发数据块;依据所述第n反向运算指令的运算控制确定启动第一映射电路对第一数据块进行处理,得到处理后的第一数据块;所述第一数据块包括所述分发数据块和/或所述广播数据块;依据所述第n反向运算指令将处理后的第一数据块发送至与所述主处理电路相连的基础处理电路中的至少一个基础处理电路;The main processing circuit is further configured to obtain an nth output result gradient according to the nth output result, and obtain an nth reverse operation nth inverse operation instruction and the nth inverse operation according to the training instruction The nth layer input data and the nth layer weight group data required by the instruction; dividing the nth output result gradient, the nth layer input data, and the nth layer weight group data according to the nth reverse operation instruction a broadcast data block and a distribution data block; determining, according to the operation control of the nth reverse operation instruction, starting the first mapping circuit to process the first data block, and obtaining the processed first data block; the first data block Include the distribution data block and/or the broadcast data block; transmitting the processed first data block to at least one of the basic processing circuits connected to the main processing circuit according to the nth reverse operation instruction Processing circuit 所述多个基础处理电路,用于依据所述第n反向运算指令的运算控制确定是否启动第二映射电路对第二数据块进行处理,依据处理后的第二数据块以并行方式执行神经网络中的运算得到运算结果,并将该运算结果通过与所述主处理电路连接的基础处理电路传输给所述主处理电路;所述第二数据块为所述基础处理电路确定的接收所述主处理电路发送的数据块,所述第二数据块与所述处理后的第一数据块关联;The plurality of basic processing circuits are configured to determine, according to the operation control of the nth reverse operation instruction, whether to start the second mapping circuit to process the second data block, and execute the nerve in parallel according to the processed second data block An operation in the network obtains an operation result, and transmits the operation result to the main processing circuit through a basic processing circuit connected to the main processing circuit; the second data block is determined by the basic processing circuit to receive the a data block sent by the main processing circuit, the second data block being associated with the processed first data block; 所述主处理电路,还用于对该运算结果进行处理得到第n层权值组梯度和第n层输入数据梯度,应用所述第n层权值组梯度对第n层权值组数据进行更新;The main processing circuit is further configured to process the operation result to obtain an nth layer weight group gradient and an nth layer input data gradient, and apply the nth layer weight group gradient to the nth layer weight group data. Update 所述集成电路芯片装置,还用于将第n层输入数据梯度作为第n-1层的第n-1输出结果梯度执行n-1 层反向运算得到n-1层权值组梯度,应用n-1层权值组梯度更新对应层的权值组数据,所述权值组数据包括至少二个权值。The integrated circuit chip device is further configured to perform n-1 layer inverse operation on the nth layer input data gradient as the n-1th output gradient of the n-1th layer to obtain an n-1 layer weight group gradient, and apply The n-1 layer weight group gradient updates the weight group data of the corresponding layer, and the weight group data includes at least two weights. 根据权利要求11-14中任一项所述的集成电路芯片装置,其特征在于,当所述第一数据块包括分发数据块和广播数据块时,The integrated circuit chip device according to any one of claims 11 to 14, wherein when the first data block includes a distribution data block and a broadcast data block, 所述主处理电路,具体用于启动所述第一映射电路对所述分发数据块和所述广播数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块、处理后的广播数据块以及该广播数据块关联的标识数据块;将所述处理后分发数据块和该分发数据块关联的标识数据块进行拆分得到多个基本数据块以及所述多个基本数据块各自关联的标识数据块;将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路,将所述广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;The main processing circuit is specifically configured to start, by the first mapping circuit, the distributed data block processed by the distribution data block and the broadcast data block, and the identification data block associated with the distribution data block, and after processing a broadcast data block and an identification data block associated with the broadcast data block; splitting the processed distribution data block and the identification data block associated with the distribution data block to obtain a plurality of basic data blocks and the plurality of basic data blocks Corresponding identification data blocks; distributing the plurality of basic data blocks and the identification data blocks respectively associated with the plurality of basic data blocks to a base processing circuit connected thereto, associating the broadcast data block and the broadcast data block The identification data block is broadcast to the basic processing circuit connected thereto; 所述基础处理电路,用于启动所述第二映射电路依据所述基本数据块关联的标识数据块以及所述广播数据块关联的标识数据块得到连接标识数据块;根据所述连接标识数据块对所述基本数据块以及所述广播数据块进行处理,对处理后的基本数据块以及处理后的广播数据块执行所述运算指令所指示的运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is configured to start the second mapping circuit to obtain a connection identification data block according to the identification data block associated with the basic data block and the identification data block associated with the broadcast data block; and identify the data block according to the connection Processing the basic data block and the broadcast data block, performing an operation indicated by the operation instruction on the processed basic data block and the processed broadcast data block to obtain an operation result, and transmitting the operation result to the The main processing circuit. 根据权利要求11-14中任一项所述的集成电路芯片装置,其特征在于,当所述第一数据块包括分发数据块时,The integrated circuit chip device according to any one of claims 11 to 14, wherein when the first data block includes a distribution data block, 所述主处理电路,具体用于启动所述第一映射电路对所述分发数据块进行处理得到处理后的分发数据块以及该分发数据块关联的标识数据块,或者启动所述第一映射电路根据预存所述分发数据块关联的标识数据块对所述分发数据块进行处理得到处理后的分发数据块;将所述处理后的分发数据块以及该分发数据块关联的标识数据块进行拆分得到多个基本数据块以及所述多个基本数据块各自关联的标识数据块;将所述多个基本数据块以及所述多个基本数据块各自关联的标识数据块分发至与其连接的基础处理电路;将所述广播数据块广播至与其连接的基础处理电路;The main processing circuit is specifically configured to start, by the first mapping circuit, processing the distributed data block to obtain a processed distribution data block and an identification data block associated with the distribution data block, or start the first mapping circuit. And processing the distributed data block according to the pre-stored identifier data block associated with the distribution data block to obtain the processed distribution data block; and splitting the processed distribution data block and the identification data block associated with the distribution data block Obtaining a plurality of basic data blocks and identification data blocks respectively associated with the plurality of basic data blocks; distributing the plurality of basic data blocks and the identification data blocks associated with each of the plurality of basic data blocks to a basic processing connected thereto a circuit; broadcasting the broadcast data block to a base processing circuit connected thereto; 所述基础处理电路,用于启动所述第二映射电路依据所述基本数据块关联的标识数据块对所述广播数据块进行处理,对处理后的广播数据块以及所述基本数据块执行所述运算指令所指示的运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is configured to start the second mapping circuit to process the broadcast data block according to the identifier data block associated with the basic data block, and execute the processed broadcast data block and the basic data block The operation indicated by the operation command obtains the operation result, and the operation result is transmitted to the main processing circuit. 根据权利要求11-14中任一项所述的集成电路芯片装置,其特征在于,当所述第一数据块包括广播数据块时,The integrated circuit chip device according to any one of claims 11 to 14, wherein when the first data block includes a broadcast data block, 所述主处理电路,具体用于启动所述第一映射电路对所述广播数据块进行处理得到处理后的广播数据块以及该广播数据块关联的标识数据块,或者启动所述第一映射电路依据预存的所述广播数据块关联的标识数据块对所述广播数据块进行处理得到处理后的广播数据块;将所述分发数据块进行拆分得到多个基本数据块;将所述多个基本数据分发至与其连接的基础处理电路;将所述处理后的广播数据块以及该广播数据块关联的标识数据块广播至与其连接的基础处理电路;The main processing circuit is configured to: start, by the first mapping circuit, processing the broadcast data block to obtain a processed broadcast data block and an identifier data block associated with the broadcast data block, or start the first mapping circuit Processing the broadcast data block according to the pre-stored identifier data block associated with the broadcast data block to obtain a processed broadcast data block; splitting the distribution data block to obtain a plurality of basic data blocks; The basic data is distributed to the basic processing circuit connected thereto; the processed broadcast data block and the identification data block associated with the broadcast data block are broadcasted to the basic processing circuit connected thereto; 所述基础处理电路,用于启动所述第二映射电路依据所述广播数据块关联的标识数据块对所述基本数据块进行处理得到处理后的基本数据块;对所述处理后的基本数据块以及所述处理后的广播数据块执行所述运算指令所指示的运算得到运算结果,将所述运算结果发送至所述主处理电路。The basic processing circuit is configured to start, by the second mapping circuit, processing the basic data block according to the identification data block associated with the broadcast data block to obtain a processed basic data block; and processing the processed basic data. The block and the processed broadcast data block perform an operation indicated by the operation instruction to obtain an operation result, and the operation result is transmitted to the main processing circuit. 一种神经网络处理器板卡,其特征在于,所述神经网络处理器板卡包括:神经网络芯片封装结构、第一电气及非电气连接装置和第一基板;所述神经网络芯片封装结构包括:神经网络芯片、第二电气及非电气连接装置和第二基板,所述第二基板承载所述神经网络芯片,所述第二基板通过所述第二电气及非电气连接装置与所述神经网络芯片连接;A neural network processor board, characterized in that: the neural network processor board comprises: a neural network chip package structure, a first electrical and non-electrical connection device and a first substrate; the neural network chip package structure comprises a neural network chip, a second electrical and non-electrical connection device and a second substrate, the second substrate carrying the neural network chip, the second substrate passing through the second electrical and non-electrical connection device and the nerve Network chip connection; 所述神经网络芯片包括:如上权利要求1-17中任一项所述的集成电路芯片装置。The neural network chip comprises the integrated circuit chip device of any of claims 1-17. 根据权利要求18所述的神经网络处理器板卡,其特征在于,所述神经网络芯片封装结构还包括:散热装置。The neural network processor board according to claim 18, wherein the neural network chip package structure further comprises: a heat sink. 根据权利要求18所述的神经网络处理器板卡,其特征在于,所述神经网络芯片封装结构的封装结构为下述封装的任意一种:The neural network processor card according to claim 18, wherein the package structure of the neural network chip package structure is any one of the following packages: 倒装芯片球栅阵列封装、薄型四方扁平式封装、带散热器的四方扁平封装、无引脚四方扁平封装、小间距四方扁平式封装。Flip-chip ball grid array package, thin quad flat package, quad flat package with heat sink, leadless quad flat package, small pitch quad flat package. 一种芯片,其特征在于,所述芯片集成如权利要求1-17任意一项所述的装置。A chip, characterized in that the chip integrates the device according to any one of claims 1-17. 一种智能设备,其特征在于,所述智能设备包括如权利要求22所述的芯片。A smart device, characterized in that the smart device comprises the chip of claim 22.
PCT/CN2019/075979 2018-02-27 2019-02-23 Integrated circuit chip apparatus, board card and related product Ceased WO2019165940A1 (en)

Applications Claiming Priority (12)

Application Number Priority Date Filing Date Title
CN201810164841.4 2018-02-27
CN201810164317.7A CN110197268B (en) 2018-02-27 2018-02-27 Integrated circuit chip device and related product
CN201810164317.7 2018-02-27
CN201810164295.4A CN110197267B (en) 2018-02-27 2018-02-27 Neural network processor boards and related products
CN201810164738.X 2018-02-27
CN201810164295.4 2018-02-27
CN201810164841.4A CN110197273B (en) 2018-02-27 2018-02-27 Integrated circuit chip device and related product
CN201810164737.5A CN110197271B (en) 2018-02-27 2018-02-27 Integrated circuit chip devices and related products
CN201810164332.1A CN110197270B (en) 2018-02-27 2018-02-27 Integrated circuit chip device and related product
CN201810164737.5 2018-02-27
CN201810164332.1 2018-02-27
CN201810164738.XA CN110197272B (en) 2018-02-27 2018-02-27 Integrated circuit chip device and related product

Publications (1)

Publication Number Publication Date
WO2019165940A1 true WO2019165940A1 (en) 2019-09-06

Family

ID=67805619

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/075979 Ceased WO2019165940A1 (en) 2018-02-27 2019-02-23 Integrated circuit chip apparatus, board card and related product

Country Status (1)

Country Link
WO (1) WO2019165940A1 (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106447034A (en) * 2016-10-27 2017-02-22 中国科学院计算技术研究所 Neutral network processor based on data compression, design method and chip
CN107329936A (en) * 2016-04-29 2017-11-07 北京中科寒武纪科技有限公司 A kind of apparatus and method for performing neural network computing and matrix/vector computing
CN107688853A (en) * 2016-08-05 2018-02-13 北京中科寒武纪科技有限公司 A device and method for performing neural network operations

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107329936A (en) * 2016-04-29 2017-11-07 北京中科寒武纪科技有限公司 A kind of apparatus and method for performing neural network computing and matrix/vector computing
CN107688853A (en) * 2016-08-05 2018-02-13 北京中科寒武纪科技有限公司 A device and method for performing neural network operations
CN106447034A (en) * 2016-10-27 2017-02-22 中国科学院计算技术研究所 Neutral network processor based on data compression, design method and chip

Similar Documents

Publication Publication Date Title
US11983621B2 (en) Integrated circuit chip device
US12217162B2 (en) Integrated circuit chip apparatus
CN109961134B (en) Integrated circuit chip device and related product
TWI793224B (en) Integrated circuit chip apparatus and related product
CN110197264B (en) Neural network processor boards and related products
CN110197267B (en) Neural network processor boards and related products
WO2019165946A1 (en) Integrated circuit chip device, board card and related product
WO2019165940A1 (en) Integrated circuit chip apparatus, board card and related product
CN109977071A (en) Neural network processor board and Related product
CN109961137B (en) Integrated circuit chip device and related product
CN109978130A (en) Integrated circuit chip device and Related product

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19760628

Country of ref document: EP

Kind code of ref document: A1