Batch Processing in Neural Network Processors

Special purpose hardware circuitry in neural networks reuses weight inputs across multiple inputs to form batches, addressing inefficiencies in existing systems and enhancing throughput by minimizing memory access latency.

JP7561916B2Active Publication Date: 2024-10-04GOOGLE LLC
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
JP2023085256
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2015-09-03
Filing Date
2023-05-24
Publication Date
2024-10-04
Estimated Expiration
2036-05-03

AI Technical Summary

Technical Problem

Existing neural network systems inefficiently process multiple inputs due to continuous calculation and memory access latency, leading to circuit stalls and reduced throughput.

Method used

Implementing special purpose hardware circuitry that reuses weight inputs across multiple independent inputs, forming batches based on layer-specific batch sizes, and utilizing a matrix computation unit to maximize throughput by minimizing memory access time.

Benefits of technology

The hardware circuit efficiently performs neural network computations by reusing weight inputs multiple times, reducing memory access latency and maximizing throughput, thereby avoiding circuit stalls and enhancing processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007561916000001
    Figure 0007561916000001
  • Figure 0007561916000002
    Figure 0007561916000002
  • Figure 0007561916000003
    Figure 0007561916000003
Patent Text Reader

Abstract

To provide a method, a system, and an apparatus, including a computer program for generating a respective neural network output for each of a plurality of inputs.SOLUTION: A method comprises receiving a plurality of inputs to be processed at a neural network layer for each of the neural network layers and forming one or more batches of inputs from the plurality of inputs. Each batch has a number of inputs up to the respective batch size for the neural network layer. The method also includes selecting a number of one or more batches of inputs to process for each of the neural network layers. A count of the inputs in the number of one or more batches is greater than or equal to the respective associated batch size of a subsequent layer in sequence. The method further processes the number of one or more batches of inputs to generate the respective neural network layer output for each of the neural network layers.SELECTED DRAWING: Figure 1
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] background This specification relates to computing neural network guesses in hardware. [Background technology]

[0002] A neural network is a machine learning model that utilizes one or more layers of neurons to generate an output, e.g., a classification, for a received input. Some neural networks include one or more hidden layers in addition to an output layer. The output of each hidden layer is used as the input to the next layer in the network, i.e., the next hidden or output layer of the network. Each layer of the network generates an output from the received input according to the current values ​​of a respective set of parameters.

[0003] Traditionally, some neural network systems compute guesses serially, i.e., when computing guesses for multiple inputs, the neural network system may process each input through each layer of the neural network to generate an output for that input before processing the next input. Summary of the Invention [Problem to be solved by the invention]

[0004] overview Generally, this specification describes special purpose hardware circuitry for computing neural network guesses. [Means for solving the problem]

[0005] In general, one innovative aspect of the subject matter described herein may be embodied in a method that includes operations of generating a respective neural network output for each of a plurality of inputs, the generating comprising processing each input through each of a plurality of neural network layers to generate the respective neural network output for the input, the neural network layers being arranged in an order, each neural network layer having a respective batch size, the method comprising, for each of the neural network layers, receiving a plurality of inputs to be processed at the neural network layer and forming one or more batches of inputs from the plurality of inputs, each batch having a number of inputs up to the respective batch size of the neural network layer, the method further comprising, for each of the neural network layers, selecting some of the one or more batches of inputs for processing, a number of the inputs in some of the one or more batches being greater than or equal to an associated batch size of each of subsequent layers in the order, and the method further comprising, for each of the neural network layers, processing some of the one or more batches of inputs to generate the respective neural network layer output.

[0006] Implementations may include one or more of the following features: each batch size is based at least on a weight reuse value, the weight reuse value representing the number of times a weight input needs to be reused during a computation time of an output value using the weight input in a matrix computation unit that is greater than a load time of the weight input from memory; the weight reuse value is based at least on a clock rate of the memory storing the weight input; each batch size is based on at least a weight reuse value representing the number of times a weight input needs to be reused during a computation time of an output value using the weight input in a matrix computation unit that is greater than a load time of the weight input from memory; The method further comprises: forming a batch from the one or more layer outputs for processing in the subsequent layer; generating a corresponding guess value for each output; and generating a corresponding estimate for each output. The neural network layers are processed in a matrix processing unit, and processing some of the one or more batches of inputs comprises computing an accumulation value for each input using the matrix computation unit. The weight reuse value is based on a number of computation units in the matrix computation unit. Each input corresponds to a separate image resource. The method further comprises forming a batch from the one or more layer outputs for processing in the subsequent layer; generating a corresponding guess value for each output.

[0007] Certain embodiments of the subject matter described herein can be implemented to achieve one or more of the following advantages: A special purpose hardware circuit can efficiently perform computations for neural networks having multiple layers by reusing weight inputs for a given layer on multiple independent inputs. In particular, a weight input is reused a number of times such that the computation time to reuse a weight input multiple times is greater than the fetch time to access a new weight input from memory, thereby maximizing throughput in the circuit and avoiding stalls in the circuit. The circuit can efficiently perform computations even if the weight inputs are reused a different number of times in each layer.

[0008] The details of one or more embodiments of the subject matter herein are set forth in the accompanying drawings and the description below. Other features, aspects, and advantages of the subject matter will become apparent from the description, drawings, and claims. [Brief description of the drawings]

[0009] [Figure 1] FIG. 2 is a flow diagram of an exemplary method for performing computations for a given layer of a neural network. [Diagram 2] 1 illustrates an exemplary neural network processing system. [Diagram 3] 1 illustrates an exemplary architecture including a matrix computation unit. [Figure 4] 1 illustrates an exemplary architecture of a cell in a systolic array. [Diagram 5] FIG. 1 is a flow diagram of an exemplary method for performing neural network computations for multiple layers. [Figure 6] 1 illustrates an example neural network with multiple layers and a batch size for each layer. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0010] Like reference numbers and designations in the various drawings indicate like elements. Detailed Description A neural network with multiple layers can be used to compute a guess. For example, given an input, the neural network can compute a guess for the input. The neural network computes this guess by processing the input through each layer of the neural network. In particular, the layers of the neural network can be arranged in a certain order, with each layer having a respective set of weights. Each layer receives an input and processes the input according to the layer's set of weights to generate an output. The output can be used as an input in the next neural network layer.

[0011] Thus, to compute a guess from a received input, the neural network receives the input and processes it through each of the neural network layers in the sequence to generate a guess, with the output from one neural network layer being provided as an input to the next neural network layer. A data input to a neural network layer, e.g., an input to the neural network or an output to a neural network layer of a layer below the layer in the sequence, may be referred to as an activation input to the layer.

[0012] In some implementations, the layers of a neural network are arranged in a directed graph structure, i.e., any particular layer can receive multiple inputs, multiple outputs, or both. The layers of a neural network can also be arranged such that the output of a layer can be sent back as input to a previous layer.

[0013] 1 is a flow diagram of an exemplary process 100 for performing computations for a given layer of a neural network using special purpose hardware circuitry. For convenience, method 100 is described in the context of a system having one or more circuits that perform method 100. Method 100 may be performed for each layer of a neural network to compute guesses from received inputs.

[0014] The system receives a plurality of sets of weight inputs for a given layer (step 102) and a plurality of sets of activation inputs for a given layer (step 104). The plurality of sets of weight inputs and the plurality of sets of activation inputs may be received from a dynamic memory and a unification buffer, respectively, of a special purpose hardware circuit. In some implementations, both the plurality of sets of weight inputs and the plurality of sets of activation inputs may be received from a unification buffer.

[0015] The system generates accumulation values ​​from the weight inputs and activation inputs using a matrix multiplication unit of a special purpose hardware circuit (step 106). In some implementations, the accumulation values ​​are dot products of multiple sets of weight inputs with multiple sets of activation inputs. That is, for one set of weights, the system may multiply each weight input with each activation input and sum the products to form an accumulation value. The system may then calculate dot products of other sets of weights with other sets of activation inputs.

[0016] The system may generate layer outputs from the accumulated values ​​using a vector computation unit of the special purpose hardware circuit (step 108). In some implementations, the vector computation unit applies an activation function to the accumulated values. The layer outputs may be stored in a synthesis buffer for use as inputs to subsequent layers in the neural network, or may be used to generate guesses. The system finishes processing the neural network once it has processed the received inputs through each layer of the neural network to generate guesses for the received inputs.

[0017] 2 illustrates an exemplary special purpose integrated circuit 200 for performing neural network computations. The system 200 includes a host interface 202. The host interface 202 can receive instructions including configuration information for the neural network computations. The configuration information can include at least one or more of: how many layers to process, a corresponding set of weight inputs for each layer of the layers, an initial set of startup inputs, i.e., inputs to the neural network for computing guesses, corresponding input and output sizes of each layer, a stride value for the neural network computation, and the type of layer to process, e.g., a convolutional layer or a fully connected layer.

[0018] The host interface 202 can send instructions to the sequencer 206, which converts the instructions into low-level control signals that control the circuit to perform neural network computations. In some implementations, the control signals regulate the data flow within the circuit, such as how the sets of weight inputs and the sets of activation inputs flow through the circuit. The sequencer 206 can send the control signals to the unification buffer 208, the matrix computation unit 212, and the vector computation unit 214. In some implementations, the sequencer 206 can send the control signals to the direct memory access engine 204 and and dynamic memory 210. In some implementations, sequencer 206 is a processor that generates a clock signal. Sequencer 206 can use the timing of the clock signal to send the control signals to each component of circuit 200 at the appropriate times. In some other implementations, host interface 202 passes the clock signal from an external processor.

[0019] The host interface 202 can send the multiple sets of weight inputs and the initial set of activation inputs to a direct memory access engine 204. The direct memory access engine 204 can store the multiple sets of activation inputs in a unified buffer 208. In some implementations, the direct memory access stores the multiple sets of weights in a dynamic memory 210, which may be a memory unit. In some implementations, the dynamic memory is located away from the circuit.

[0020] The unified buffer 208 is a memory buffer. The unified buffer 208 can be used to store a set of activation inputs from the direct memory access engine 204 and the output of the vector computation unit 214. The direct memory access engine 204 can also read the output of the vector computation unit 214 from the unified buffer 208.

[0021] The dynamic memory 210 and the integration buffer 208 can send multiple sets of weight inputs and multiple sets of activation inputs, respectively, to the matrix computation unit 212. In some implementations, the matrix computation unit 212 is a two-dimensional systolic array. The matrix computation unit 212 may be a one-dimensional systolic array or other circuitry capable of performing mathematical operations, such as multiplication and addition. In some implementations, the matrix computation unit 212 is a general-purpose matrix processor.

[0022] The matrix computation unit 212 can process the weight inputs and the activation inputs to provide a vector of outputs to the vector computation unit 214. In some implementations, the matrix computation unit sends the vector of outputs to the integration buffer 208, which sends the vector of outputs to the vector computation unit 214. The vector computation unit can process the vector of outputs and store the processed vector of outputs in the integration buffer 208. For example, the vector computation unit 214 can apply a nonlinear function to the output of the matrix computation unit, e.g., a vector of accumulated values, to generate activation values. In some implementations, the vector computation unit 214 generates normalized values, pooled values, or both. The processed vector of outputs can be used as activation inputs to the matrix computation unit 212, e.g., for use in a subsequent layer in the neural network. The matrix computation unit 212 is described in more detail below with reference to FIG. 3 and FIG. 4.

[0023] 3 illustrates an example architecture 300 including a matrix computation unit. The matrix computation unit is a two-dimensional systolic array 306. The array 306 includes a plurality of cells 304. In some implementations, a first dimension 320 of the systolic array 306 corresponds to a column of cells and a second dimension 322 of the systolic array 306 corresponds to a row of cells. The systolic array may have more rows than columns, more columns than rows, or an equal number of columns and rows.

[0024] In the illustrated example, value loader 302 sends activation inputs to the rows of array 306 and weight fetcher interface 308 sends weight inputs to the columns of array 306. However, in some other implementations, activation inputs are sent to the columns of array 306 and weight inputs are sent to the rows of array 306.

[0025] The value loader 302 may receive activation inputs from a consolidation buffer, such as consolidation buffer 208 of FIG. 2. Each value loader may send a corresponding activation input to a respective left-most cell of the array 306. The left-most cell may be a cell along the left-most column of the array 306. For example, value loader 312 may send an activation input to cell 314. A value loader may also send an activation input to an adjacent value loader, such that the activation input can be used by another left-most cell of the array 306. This allows the activation input to be shifted for use by another particular cell of the array 306.

[0026] The weight fetcher interface 308 may receive weight inputs from a memory unit, such as the dynamic memory 210 of FIG. 2. The weight fetcher interface 308 may send corresponding weight inputs to individual top cells of the array 306. The top cells may be cells along the top row of the array 306. For example, the weight fetcher interface 308 may send weight inputs to cells 314 and 316.

[0027] 2 shifts activation inputs along one dimension across array 306, e.g., to the right, and shifts weight inputs along another dimension across array 306, e.g., to the bottom. For example, in one clock cycle, an activation input in cell 314 can be shifted into an activation register in cell 316 to the right of cell 314. Similarly, a weight input in cell 316 can be shifted into a weight register in cell 318 below cell 314.

[0028] At each clock cycle, each cell can process a given weight input and a given activation input to generate an accumulated output. The accumulated output can also be passed to adjacent cells along the same dimension as the given weight input. Individual cells are further described below with reference to FIG. 4.

[0029] The accumulated outputs can be passed along the same columns as the weight inputs, for example towards the bottom of the columns in the array 306. In some implementations, the array 306 may include an accumulator unit 310 at the bottom of each column that stores and accumulates each accumulated output from each column when performing calculations on layers with more weight inputs than columns or layers with more activation inputs than rows. In some implementations, each accumulator unit stores multiple parallel accumulation values, which are further described below with reference to FIG. 6. The accumulator unit 310 can accumulate each accumulated output to generate a final accumulated value. The final accumulated value can be sent to the vector computation unit. In some other implementations, the accumulator unit 310 passes the accumulated value to the vector computation unit without performing any accumulations when processing layers with fewer weight inputs than columns or layers with fewer activation inputs than rows.

[0030] FIG. 4 illustrates an example architecture 400 of a cell in a systolic array, such as systolic array 306 of FIG.

[0031] The cell may include a start register 406 that stores the start input. The start register may receive the start input from a left neighbor, i.e., the neighbor located to the left of a given cell, or from the integration buffer, depending on the location of the cell in the systolic array. The cell may include a weight register 402 that stores a weight input. The weight input may be sent from an upper neighbor or from a weight fetcher interface, depending on the location of the cell in the systolic array. The cell may also include a sum register 404. The sum register 404 may store the accumulated value from the upper neighbor. Multiplication Path 408 may be used to multiply a weight input from weight register 402 with an activation input from activation register 406. Multiplication circuit 408 may output the product to summation circuit 410.

[0032] A summation circuit can sum the product with an accumulated value from sum register 404 to generate a new accumulated value. Summation circuit 410 can then send the new accumulated value to another summation register located in a lower adjacent cell. The new accumulated value can be used as an operand for the summation in the lower adjacent cell.

[0033] A cell can also shift its weight and activation inputs to adjacent cells for processing. For example, weight register 402 can send its weight input to another weight register in an adjacent cell below. Activation register 406 can send its activation input to another activation register in an adjacent cell to the right. Thus, both the weight and activation inputs can be reused by other cells in the array in subsequent clock cycles.

[0034] In some implementations, the cell also includes a control register. The control register can store a control signal that determines whether the cell should shift the weight input or the activation input to an adjacent cell. In some implementations, shifting the weight input or the activation input takes one or more clock cycles. The control signal can also determine whether to send the activation input or the weight input to the multiplication circuit 408, or whether the multiplication circuit 408 operates on the activation input and the weight input. The control signal can also be passed to one or more adjacent cells, for example using wires.

[0035] In some implementations, the weights are pre-shifted into the weight path register 412. The weight path register 412 can receive weight inputs, for example, from an upper adjacent cell, and send the weight inputs to the weight register 402 based on the control signal. The weight register 402 can statically store the weight inputs such that the weight inputs remain within the cell and are not sent to adjacent cells when the activation inputs are sent to the cell for multiple clock cycles, for example, via the activation register 406. Thus, the weight inputs can be applied to multiple activation inputs, for example using the multiplication circuit 408, and the respective accumulated values ​​can be sent to adjacent cells.

[0036] In some implementations, a single neural network input is processed through each layer of the neural network to generate a neural network output for that neural network input, but in some implementations, the circuit rapidly processes multiple neural network inputs through the layers of the neural network to generate a neural network output for that input, thereby increasing utilization of the circuit.

[0037] The inputs to a particular layer of a neural network can be referred to as a set of activation inputs. Thus, a neural network input can be a set of activation inputs to a first layer. The first layer can generate outputs that are processed by a second layer, and the outputs can be referred to as a set of activation inputs to the second layer.

[0038] In some implementations, instead of processing one set of activation inputs to generate guesses by sending activation inputs from a first layer to a last layer of a neural network, the circuit may process multiple sets of activation inputs in the first layer and generate an accumulation value for each set of activation inputs, e.g., as described above in FIG. 3, then process multiple sets of activation inputs in the second layer, etc. The multiple sets of activation inputs in a given layer may constitute one or more batches of inputs. In some implementations, a batch in a given layer is processed before the circuit processes a batch in a subsequent layer. For each input, the circuit may In one embodiment, a batch can be processed by generating an accumulated value using a set of inputs, which can be an independent set of inputs within the batch.

[0039] In some implementations, to maximize throughput while performing computations for a given neural network layer, the circuitry can be adapted to process multiple independent activation inputs while the weight inputs for the given neural network layer are loaded into the systolic array. That is, the weight inputs can be reused with multiple activation inputs. In particular, the circuitry reuses the weight inputs by computing an accumulation value using the weight inputs and the various activation inputs, for example using the matrix computation unit 212 of FIG. 2. By way of example, the activation inputs may be from multiple different image resources or multiple audio samples. This is further described below with reference to FIG. 6.

[0040] A circuit has a processing speed and a speed at which the circuit can access memory. Generally, the processing speed is faster than the memory access speed. By reusing weights, and thereby taking advantage of the processing speed of the circuit, the circuit can utilize the cells of the systolic array in parallel while accessing weight inputs from memory for use in subsequent calculations.

[0041] For each layer of the neural network, the circuit can determine how many times to reuse a weight from the circuit's weight reuse value. This may be determined by software on the circuit compiling for the hardware, or it may be determined by the hardware. In some implementations, the weight reuse value is the number of times the circuit can reuse a weight input before the computation time to reuse a weight input multiple times with different launch inputs becomes equal to or exceeds the fetch time to access a new weight input from memory. Thus, the weight reuse value can indicate how many times the circuit should reuse a weight input to maximize utilization and minimize memory access latency.

[0042] The weight reuse value may be based on one or more of the clock rate of the memory storing the weight inputs, e.g., the dynamic memory 210 of FIG. 2, the number of computation units in the circuit, e.g., the matrix computation unit 212 of FIG. 2, and the number of channels in the memory, e.g., the integration buffer 208 and the dynamic memory 210 of FIG. 2. The weight reuse value may be used to determine the respective batch size of each layer of the neural network. The batch size may be referred to as the effective batch size, i.e., the batch size that allows the layer to operate in a manner that produces the most efficient amount of weight reuse. The batch size is the number of inputs that are processed in the layer such that the systolic array in the circuit is maximized. In some implementations, the batch size of a given layer is an upper bound on the weight reuse value divided by the number of times that the weight inputs are reused in that layer. The number of times that the weight inputs are reused may directly correspond to the number of activation inputs stored in the cells of the systolic array of the circuit when performing the accumulation calculation. This is because the weight inputs may remain in the cells, i.e., be "paused", while multiple sets of new activation inputs are loaded. Once new sets of activation inputs are loaded with the weight inputs frozen in place, the circuit can again reuse the weight inputs to compute convolutions with the new sets of activation inputs, an example of which is further described below with reference to FIG.

[0043] 5 is a flow diagram 500 of an exemplary method for performing neural network computations for multiple layers. The method may be performed by special purpose hardware circuitry, such as using host 202 of FIG. 2, or by one or more processors, firmware, off-chip processes, or some other software process configured to control the circuitry.

[0044] During processing at each neural network layer, the circuitry may receive a set of layer inputs for processing by the layer (step 502). The set of layer inputs may be from a memory, such as the integration buffer 208 of FIG. 2, or may be from a previous layer, i.e., the set of inputs are outputs generated from a previous layer in the network, and the use of such outputs as the set of inputs may be managed by the host 202 described above with reference to FIG. 2. Each input may be a set of activation inputs and may be generated from an independent neural network input.

[0045] The system may form one or more batches of inputs from the set of inputs for a given neural network layer (step 504). As described above, each neural network layer has an associated batch size. Each formed batch at the layer includes a number of inputs that does not exceed the batch size of the layer. The batch size of each neural network layer may be determined as a configuration of the neural network. In some implementations, the batch size of each neural network layer is calculated when compiling the neural network model for execution on the circuit. The batch size of a given layer may be calculated before processing begins at the layer, so that a number of inputs in a batch may be formed based on the batch size of the given layer.

[0046] As an example, if a neural network needs to process 24 images and the first layer of the neural network has a batch size of 8, the circuit can form 3 batches of 8 images each, i.e., divide the 24 images into 3 batches of 8 inputs each. For each batch, the circuit can process the 8 individual images in the batch by reusing a particular set of weight inputs for that layer. The circuit can then either (1) process one or more batches in a subsequent layer, or (2) process another batch of 8 individual image resources in that layer using a particular set of weight inputs. The circuit determines whether to proceed to (1) or (2) based on the batch sizes of other layers in the neural network, which will be further described below in step 506 and with reference to FIG. 6.

[0047] The circuit may select some of the one or more batches of inputs for processing for a given neural network layer (step 506). In some implementations, the number is selected such that the number of inputs in some of the one or more batches is equal to or greater than the corresponding batch size of the subsequent layer. For example, if the current layer must process three batches, each having five inputs, and the subsequent layer has a batch size of 10, the circuit may select two of the three batches for processing. The two selected batches have a total of 10 inputs, i.e., 2×5, equal to the corresponding batch size of the subsequent layer, i.e., 10. In some implementations, the remaining third batch will be processed in a subsequent pass through a systolic array in the circuit. Yet another example is further described below with reference to FIG. 6.

[0048] The circuitry can process a batch of selected inputs, for example using a systolic array, to generate a respective layer output for each input in the selected batch (step 508). The circuitry can process each batch of selected inputs by reusing the weight inputs when calculating the accumulated values ​​for each input. As noted above, the weight inputs are applied to multiple independent inputs because the weight inputs may remain in the cell, or be "paused," while multiple sets of new activation inputs are loaded.

[0049] As an example, a batch may have two inputs: a set of activation inputs A1 and a set of activation inputs A2. The circuit may then fetch the set of weight inputs W2 from memory before Set W1 can be reused by applying set W1 of weight inputs to both sets A1 and A2, with set W2 being the set of weights for a subsequent layer, or the next subset of weights for the layer if the layer has more weights to be processed by the systolic array of the circuit. In another example, if there are eight batches of five inputs each to process, for a total of 40 inputs, and the circuit selects four batches for processing, the circuit can process the inputs in the four batches, for a total of 20 inputs, to generate respective layer outputs, for a total of 20 layer outputs. This is further described below with reference to FIG. 6.

[0050] After processing a selected number of batches, the circuitry can either process a second number of batches at that layer, or proceed to process one or more batches of inputs at a subsequent layer, as will be further described below with reference to FIG.

[0051] Although the method has been described as being implemented in a circuit for processing a neural network, the method may also be implemented in a processor, such as a Central Processing Unit (CP). The weights may be implemented in a multi-threaded processor (CPU) or a graphics processing unit (GPU). For example, the processor may reuse the weight values ​​several times, retrieving the weights from a memory, e.g., a dynamic random access memory (DRAM).

[0052] FIG. 6 illustrates an example neural network 600 with multiple layers and a batch size for each layer. As mentioned above, the batch size for a given layer is an upper bound on the weight reuse value divided by the number of times a weight input is reused in that layer. A ceiling function can process a number and return the smallest integer greater than or equal to the number. The number of times a weight input is reused may directly correspond to the number of activation inputs stored in a cell of the circuit's systolic array. For example, the weight reuse value for the circuit may be 1500. Layer 1 602 processes 170×170 inputs. Each of the 170×170 activation inputs can be stored in a cell of the systolic array. Thus, the batch size for layer 1 602 is CEIL(1500 / (170*170))=1. The batch size for layer 2 604 is CEIL(1500 / (28*28))=2. Using the same calculation, layers 3-5 606-610 have a batch size of 8, and layer 6 612 has a batch size of 32. In some implementations, the batch size is rounded up to the nearest power of two.

[0053] Illustratively, layer 1 has a batch size of 1 input and layer 2 has a batch size of 2 inputs. The circuit can receive, for example, 10 inputs, for example a total of 10 distinct images, for processing at layer 1.

[0054] The circuit may determine that it should process two batches of 10 in layer 1, i.e., two total inputs. In some implementations, the circuit determines this number by dividing the batch size in layer 2 by the batch size of layer 1, i.e., 2 / 1=2. By processing two batches of a single input, the circuit processes two inputs equal to the batch size of layer 2, i.e., two. The circuit may process the two batches to generate two layer outputs from the two inputs, e.g., by computing two vectors of accumulated values, one from each image. Each layer output may be an input for inputting to a subsequent layer. The circuit may form a batch of two inputs, e.g., two vectors of accumulated values, for processing in layer 2. The batches may be stored in a consolidation buffer.

[0055] The circuit can determine that it should process 4 batches in layer 2. By processing 4 batches of size 2, the circuit can determine that it should process 4 batches in layer 3, i.e. 8 The circuit processes 8 inputs equal to 10 ...

[0056] The circuit may continue until inputs have been processed in all layers of the neural network. For example, because layers 3-5 have a batch size of 8, the circuit may determine that it should process one batch of 8 inputs in each of layers 3-5. Similarly, the circuit may determine that it should process four batches of 8 inputs each in layer 5, thereby forming a batch of 32 inputs, which can be processed in layer 6. For each input, layer 6 may generate one or more layer outputs that can be used for guessing.

[0057] In some implementations, the circuit calculates, e.g., using arithmetic circuitry, the least common multiple of the batch sizes across all layers in the neural network. The circuit can then process the smallest number of inputs at each layer that is greater than or equal to the least common multiple before processing the subsequent layer. In other words, the circuit can determine whether to (1) process a batch at a subsequent layer or (2) process another batch at the current layer based on the least common multiple. For example, the least common multiple of the batch sizes for layers 1-6 602-612 is 32. After processing one batch at layer 1, the circuit can determine that layer 1 only generated one output that is less than the least common multiple of 32. Thus, the circuit can determine to process another batch at layer 1, at which point a total of two outputs have been generated. The circuit can continue to generate outputs until 32, i.e., the least common multiple, outputs have been generated at layer 1. The circuit can then proceed to process the batch at the subsequent layer. In some implementations, each layer output is stored in a consolidation buffer, e.g., consolidation buffer 208 of FIG. 2.

[0058] By way of example, the circuitry may select 32 batches for processing at layer 1 totaling 32 inputs. The circuitry may then select 16 batches for processing at layer 2 totaling 32 inputs, then select 4 batches for processing at layer 3 totaling 32 inputs, then select 4 batches for processing at layer 4 totaling 32 inputs, then select 4 batches for processing at layer 5 totaling 32 inputs, and then finally select 1 batch for processing at layer 6 totaling 32 inputs.

[0059] In some implementations, at a particular layer, the circuit processes a number of inputs that are greater than the least common multiple based on system parameters, e.g., parameters provided by a user. In some implementations, the circuit processes a number of inputs that are divisible by the batch size of the subsequent layer. In some other implementations, the circuit receives instructions to process a number of inputs, and the circuit processes a batch of inputs to maximize the number of outputs generated at a particular layer before proceeding to generate outputs in a subsequent number. The circuit can limit the number of outputs generated at a particular layer such that the number of outputs generated is divisible by the batch size of the subsequent layer.

[0060] Embodiments of the subject matter and functional operations described herein may be implemented in digital electronic circuitry, in tangibly embodied computer software or firmware, in computer hardware containing the structures disclosed herein and their structural equivalents, or in a combination of one or more of them. Embodiments of the subject matter described herein may be implemented as one or more computer programs, i.e., code encoded on a tangible, non-transitory program carrier for execution by or control of the operation of a data processing apparatus. The computer program may be implemented as one or more modules of computer program instructions. Alternatively or additionally, the program instructions may be encoded into an artificially generated propagated signal, such as a machine-generated electrical, optical or electromagnetic signal, which is generated to encode information and transmit it to a suitable receiver device for execution by a data processing device. The computer storage medium may be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or a combination of one or more thereof.

[0061] The term "data processing apparatus" encompasses all kinds of apparatus, devices and machines for processing data, including, by way of example, a programmable processor, a computer, or multiple processors or computers. The apparatus may include special purpose logic circuitry, such as an FPGA (field programmable gate array) or an ASIC (application specific integrated circuit). In addition to hardware, the apparatus may also include code that creates an execution environment for a subject computer program, such as code that constitutes a processor firmware, a protocol stack, a database management system, an operating system, or a combination of one or more of these.

[0062] A computer program (which may be referred to or described as a program, software, software application, module, software module, script, or code) may be written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages, and may be deployed in any form including a stand-alone program or a module, component, subroutine, or other unit suitable for use in a computing environment. A computer program may correspond to a file in a file system, but this is not required. A program may be stored as part of a file that holds other programs or data, e.g. one or more scripts stored in a markup language document, in a single file dedicated to the program in question, or in multiple cooperating files, e.g. files that store one or more modules, subprograms, or code portions. A computer program may be deployed to run on one computer or on multiple computers that are located at one site or distributed across multiple sites and interconnected by a communication network.

[0063] The processes and logic flows described herein may be performed by one or more programmable computers executing one or more computer programs to perform functions by operating on input data and generating output, or the processes and logic flows may be performed by, and an apparatus may be implemented as, special purpose logic circuitry, such as an FPGA (field programmable gate array) or an ASIC (application specific integrated circuit).

[0064] A computer suitable for running a computer program may be based, by way of example, on a general purpose or special purpose microprocessor, or both, or on other types of central processing units. Typically, the central processing unit receives instructions and data from a read-only memory or a random access memory, or both. The essential elements of a computer are a central processing unit for performing or executing instructions, and one or more memory devices for storing instructions and data. Typically, a computer will also include one or more mass storage devices, such as magnetic disks, magneto-optical disks, or optical disks, for storing data, or the computer will receive data from, transmit data to, or read data from the one or more mass storage devices. The computer is operatively coupled to receive data from and transmit data to a mass storage device, although the computer need not have such a device. Additionally, the computer may be coupled to another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a gaming console, a Global Positioning System (GPS), to name a few. The address may be implemented in a GPS (Global Positioning System) receiver or in a portable storage device, such as a universal serial bus (USB) flash drive.

[0065] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media and memory devices, including, by way of example, semiconductor memory devices, such as EPROM, EEPROM and flash memory devices; magnetic disks, such as internal hard disks or removable disks; magneto-optical disks; and CD ROM and DVD-ROM disks. The processor and the memory may be supplemented by, or incorporated in, special purpose logic circuitry.

[0066] To solicit user interaction, embodiments of the subject matter described herein may be implemented in a computer having a display device, such as a CRT (cathode ray tube) or LCD (liquid crystal display) monitor, for displaying information to the user, and a keyboard and pointing device, such as a mouse or trackball, by which the user can send input to the computer. Other types of devices may also be used to solicit user interaction. For example, feedback provided to the user may be any form of sensory feedback, such as visual feedback, auditory feedback, or tactile feedback, and input from the user may be received in any form, including acoustic input, speech input, or tactile input. The computer may also interact with the user by sending documents to and receiving documents from a device used by the user, for example by sending a web page to a web browser on the user's client device in response to a request received from the web browser.

[0067] An embodiment of the subject matter described herein may be implemented in a computing system including a back-end component, e.g., a data server, or a middleware component, e.g., an application server, or a front-end component, e.g., a client computer having a graphical user interface or web browser through which a user can interact with an implementation of the subject matter described herein, or a computing system including any combination of one or more such back-end, middleware, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication, e.g., a communications network. Examples of communications networks include local area networks (LANs) and wide area networks (WANs), e.g., the Internet.

[0068] A computing system may include clients and servers. Clients and servers are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.

[0069] Although the specification contains many specific implementation details, these should not be construed as limiting the scope of the invention or what may be claimed, but rather as being directed to specific implementations. The following description should be construed as describing features that may be specific to a particular embodiment of the invention. Certain features described herein in the context of separate embodiments may also be combined and implemented in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented in multiple embodiments separately or in any suitable subcombination. Furthermore, although features may be described above as operating in a particular combination and may even be initially claimed as such, one or more features from a claimed combination may in some cases be deleted from the combination, and the claimed combination may be directed to a subcombination or a variation of the subcombination.

[0070] Similarly, although operations are shown in the figures in a particular order, this should not be understood as requiring such operations to be performed in the particular order shown or in a sequential order to achieve desirable results, or as requiring all of the shown operations to be performed. In certain circumstances, multitasking and parallel processing may be advantageous. Furthermore, the separation of various system modules and components in the above embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the program components and systems described may generally be implemented in a single software product or packaged in multiple software products.

[0071] Specific embodiments of the subject matter have been described. Other embodiments are within the scope of the following claims. For example, the actions recited in the claims may be performed in a different order and still achieve desirable results. As an example, the processes depicted in the accompanying figures do not necessarily require the particular order depicted, or sequential order, to achieve desirable results. In certain implementations, multitasking and parallel processing may be advantageous.

Claims

1. 1. A method for performing neural network computations for a neural network having a plurality of neural network layers, comprising: obtaining a number of layer inputs to be processed; identifying a weight reuse value representing the number of times a hardware matrix computation unit of the neural network hardware circuit reuses weight inputs for neural network computation; processing, by the hardware matrix computation unit, a number of batches including layer inputs of the plurality of layer inputs for a first neural network layer, a batch size of each of the number of batches corresponding to the weight reuse value; The method, wherein the batch size represents a number of layer inputs that are processed in parallel by the hardware matrix computation unit.

2. The method of claim 1 , wherein the weight reuse value is based at least on a clock rate of a memory that stores weight inputs.

3. The method of claim 1 , wherein the weight reuse value is based at least on a number of hardware computation units in the hardware matrix computation unit.

4. 4. The method of claim 1, further comprising determining the batch size of each of the several batches based on a batch size of a layer following the first neural network layer in the plurality of neural network layers.

5. 5. The method of claim 1, further comprising determining the batch size for each of the several batches based on at least a weight reuse value divided by a number of the plurality of layer inputs.

6. The method according to any one of claims 1 to 5, wherein the step of processing the number of batches comprises the step of computing an accumulation value for each layer input using the hardware matrix computation unit of the neural network hardware circuit.

7. The method of claim 6 , further comprising determining one or more guess values ​​based on one or more layer outputs.

8. The method of claim 7, further comprising: determining, for the plurality of neural network layers, a least common multiple of batch sizes across the plurality of neural network layers; and determining the batch size that contains a minimum number of layer inputs that is greater than or equal to the least common multiple.

9. The method according to any of claims 1 to 8, wherein each layer input corresponds to a feature of a separate image resource.

10. The method according to any of claims 1 to 9, wherein the multiple neural network layers are arranged in a directed graph structure.

11. 1. A system for performing neural network computations for a neural network having a plurality of neural network layers, comprising: one or more processors; and a computer-readable medium coupled to the one or more processors and storing instructions that, when executed by the one or more processors, cause the one or more processors to perform operations, including: obtaining a number of layer inputs to be processed; identifying a weight reuse value representing the number of times a hardware matrix computation unit of the neural network hardware circuit reuses weight inputs for neural network computation; processing, by the hardware matrix computation unit, a number of batches including layer inputs of the plurality of layer inputs for a first neural network layer, a batch size of each of the number of batches corresponding to the weight reuse value; The batch size represents the number of layer inputs that are processed in parallel by the hardware matrix computation unit.

12. The system of claim 11 , wherein the weight reuse value is based at least on a clock rate of a memory that stores the weight inputs.

13. The system of claim 11 , wherein the weight reuse value is based at least on a number of hardware computation units in the hardware matrix computation unit.

14. The operation comprises:

14. The system of claim 11, further comprising determining a batch size of each of the several batches based on a batch size of a layer subsequent to the first neural network layer in the plurality of neural network layers.

15. A system described in any of claims 11 to 14, wherein a batch size for each of the several batches is determined based at least on a value obtained by dividing the weight reuse value by the number of the plurality of layer inputs.

16. The system of any of claims 11 to 15, wherein the step of processing the number of batches comprises the step of computing an accumulation value for each layer input using the hardware matrix computation unit of the neural network hardware circuit.

17. The system of claim 16 , further comprising determining one or more guess values ​​based on one or more layer outputs.

18. The operation includes: For the plurality of neural network layers, determining a least common multiple of batch sizes across the plurality of neural network layers; and determining the batch size that includes a minimum number of layer inputs that is greater than or equal to the least common multiple.

19. A program causing a processor to execute the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • High speed partitioned neural network and building-up method thereof

    JP1994203005A

  • Hierarchy processing device

    JP2004157756A

  • Deep neural networks training for speech and pattern recognition

    US20140142929A1