A multi-mode low-precision inner-product computation circuit for a massively parallel neural inference engine
The multimode low-precision dot product computation circuit addresses inefficiencies in neural inference engines by employing Booth recoding and carry-save adders to optimize neural activation calculations, achieving faster and more efficient neural network operations with reduced resource usage.
Patent Information
- Application Number
- JP2022520842
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2019-10-15
- Filing Date
- 2020-10-05
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2040-10-05
AI Technical Summary
Existing neural inference engines face inefficiencies in performing low-precision dot product calculations due to the complexity and resource-intensive nature of traditional circuit designs, particularly in massively parallel computations.
The implementation of a multimode low-precision dot product computation circuit using Booth recoding and carry-save adders to efficiently calculate neural activations, allowing for parallel processing and reduced resource usage by summing partial sums of the same scale before final addition.
This approach enhances the efficiency of neural inference operations by minimizing circuit complexity and resource requirements while supporting multiple precision modes, enabling faster and more compact neural network computations.
Smart Images

Figure 0007586604000003 
Figure 0007586604000004 
Figure 0007586604000005
Abstract
Description
[Technical field]
[0001] Embodiments of the present disclosure relate to neural network processing, and more particularly, to a multi-mode low precision dot product computation circuit for a massively parallel neural inference engine. Summary of the Invention
[0002] According to an embodiment of the present disclosure, a neural inference chip for computing neural activations is provided. In various embodiments, the neural inference chip is adapted to: receive an input activation tensor including a plurality of input activations; receive a weight tensor including a plurality of weights; Booth-recoding each of the plurality of weights into a plurality of Booth-coded weights, each Booth-coded value having an order; multiplying the input activation tensor by the Booth-coded weights such that a plurality of results are computed for each input activation, each of the plurality of results corresponding to an order of the Booth-coded weight; summing the results corresponding to each order of the Booth-coded weights such that a plurality of partial sums are computed, one for each order; and computing a neural activation from a sum of the plurality of partial sums.
[0003] In some embodiments, the input activation tensor is one-dimensional. In some embodiments, the weight tensor is two-dimensional.
[0004] In some embodiments, computing the neural activations includes shifting each of the plurality of partial sums according to its corresponding scale. In some embodiments, computing the neural activations includes shifting each of the plurality of partial sums according to a precision of the input activations. In some embodiments, computing the neural activations includes applying a non-linear activation function to a sum of the plurality of partial sums. In some embodiments, summing the corresponding results includes applying a plurality of carry-save adders.
[0005] According to an embodiment of the present disclosure, a neural inference chip for computing neural activations is provided. In various embodiments, the neural inference chip is adapted to: receive an input activation tensor including a plurality of input activations; receive a weight tensor including a plurality of weights; Booth-recoding each of the plurality of input activations into a plurality of Booth-coded input activations, each Booth-coded value having a scale; multiplying the weight tensor by the Booth-coded input activations such that a plurality of results are calculated for each weight, each of the plurality of results corresponding to a scale of the Booth-coded input activations; summing the results corresponding to each scale of the Booth-coded input activations such that a plurality of partial sums are calculated, one for each scale; and computing a neural activation from a sum of the plurality of partial sums.
[0006] In some embodiments, the input activation tensor is one-dimensional. In some embodiments, the weight tensor is two-dimensional.
[0007] In some embodiments, computing the neural activations includes shifting each of the plurality of partial sums according to its corresponding scale. In some embodiments, computing the neural activations includes shifting each of the plurality of partial sums according to a precision of the input activations. In some embodiments, computing the neural activations includes applying a non-linear activation function to a sum of the plurality of partial sums. In some embodiments, summing the corresponding results includes applying a plurality of carry-save adders.
[0008] According to an embodiment of the present disclosure, a method of computing neural activations and a computer program product for computing neural activations are provided. An input activation tensor is received, the input activation tensor includes a plurality of input activations. A weight tensor is received, the weight tensor includes a plurality of weights. Each of the plurality of weights is Booth-recoded into a plurality of Booth-coded weights, each Booth-coded value having a scale. The input activation tensor is multiplied by the Booth-coded weights such that a plurality of results are calculated for each input activation, each of the plurality of results corresponding to a scale of the Booth-coded weight. Corresponding results for each scale of the Booth-coded weights are summed such that a plurality of partial sums, one for each scale, are calculated. A neural activation is calculated from a sum of the plurality of partial sums.
[0009] In some embodiments, the input activation tensor is one-dimensional. In some embodiments, the weight tensor is two-dimensional.
[0010] In some embodiments, computing the neural activations includes shifting each of the plurality of partial sums according to its corresponding scale. In some embodiments, computing the neural activations includes shifting each of the plurality of partial sums according to a precision of the input activations. In some embodiments, computing the neural activations includes applying a non-linear activation function to a sum of the plurality of partial sums. In some embodiments, summing the corresponding results includes applying a plurality of carry-save adders.
[0011] According to an embodiment of the present disclosure, a method of computing neural activations and a computer program product for computing neural activations are provided. An input activation tensor is received, the input activation tensor including a plurality of input activations. A weight tensor is received, the weight tensor including a plurality of weights. Each of the plurality of input activations is Booth-recoded into a plurality of Booth-coded input activations, each Booth-coded value having a scale. The weight tensor is multiplied by the Booth-coded input activations such that a plurality of results are calculated for each weight, each of the plurality of results corresponding to a scale of the Booth-coded input activations. The corresponding results for each scale of the Booth-coded input activations are summed such that a plurality of partial sums, one for each scale, are calculated. A neural activation is computed from a sum of the plurality of partial sums.
[0012] In some embodiments, the input activation tensor is one-dimensional. In some embodiments, the weight tensor is two-dimensional.
[0013] In some embodiments, computing the neural activations includes shifting each of the plurality of partial sums according to its corresponding scale. In some embodiments, computing the neural activations includes shifting each of the plurality of partial sums according to a precision of the input activations. In some embodiments, computing the neural activations includes applying a non-linear activation function to a sum of the plurality of partial sums. In some embodiments, summing the corresponding results includes applying a plurality of carry-save adders. [Brief description of the drawings]
[0014] [Figure 1] FIG. 2 illustrates a neural core according to an embodiment of the present disclosure. [Diagram 2] FIG. 1 illustrates an exemplary inference processing unit (IPU) according to an embodiment of the present disclosure. [Diagram 3] FIG. 1 illustrates a multi-core inference processing unit (IPU) according to an embodiment of the present disclosure. [Figure 4] FIG. 1 illustrates an exemplary Booth recoding diagram according to an embodiment of the present disclosure. [Diagram 5] FIG. 2 illustrates an example Booth recoding multiplier according to an embodiment of the present disclosure. [Figure 6] FIG. 2 illustrates an example Booth recoding multiplier according to an embodiment of the present disclosure. [Figure 7] FIG. 1 illustrates an exemplary method for calculating a dot product according to an embodiment of the present disclosure. [Figure 8] FIG. 1 illustrates an exemplary method for calculating a dot product according to an embodiment of the present disclosure. [Figure 9] FIG. 1 illustrates a method for calculating a dot product according to an embodiment of the present disclosure. [Figure 10] FIG. 1 illustrates a multi-precision input data format according to an embodiment of the present disclosure. [Figure 11A] FIG. 1 illustrates partial sum generation at various precisions according to an embodiment of the present disclosure. [Figure 11B] FIG. 1 illustrates partial sum generation at various precisions according to an embodiment of the present disclosure. [Figure 11C] FIG. 1 illustrates partial sum generation at various precisions according to an embodiment of the present disclosure. [Figure 12] FIG. 1 illustrates a method for calculating a 4-bit dot product according to an embodiment of the present disclosure. [Figure 13] FIG. 1 illustrates a method for calculating a 4-bit dot product according to an embodiment of the present disclosure. [Figure 14] FIG. 1 illustrates a variable precision method for computing dot products according to an embodiment of the present disclosure. [Figure 15] FIG. 1 illustrates a method for computing neural activations according to an embodiment of the present disclosure. [Figure 16] FIG. 2 illustrates a computing node according to an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0015] An artificial neuron is a mathematical function whose output is a nonlinear function of a linear combination of its inputs. Two neurons are connected if the output of one is an input to the other. A weight is a scalar value that encodes the strength of the connection between the output of one neuron and the input of another neuron.
[0016] A neuron calculates its output, called activation, by applying a nonlinear activation function to a weighted sum of its inputs. A weighted sum is an intermediate result calculated by multiplying each input by its corresponding weight and accumulating the products. A partial sum is a weighted sum of a subset of the inputs. The weighted sum of all inputs can be calculated incrementally by accumulating one or more partial sums.
[0017] A neural network is a collection of one or more neurons. Neural networks are often divided into sets of neurons called layers. A layer is a collection of one or more neurons that all receive input from and all send output to the same layer, typically performing a similar function. An input layer is a layer that receives input from sources outside the neural network. An output layer is a layer that sends output to targets outside the neural network. All other layers are intermediate processing layers. A multilayer neural network is a neural network that has two or more layers. A deep neural network is a multilayer neural network that has many layers.
[0018] A tensor is a multidimensional array of numbers. A tensor block is a contiguous subarray of elements in a tensor.
[0019] Each neural network layer is associated with a parameter tensor V, a weight tensor W, an input data tensor X, an output data tensor Y, and an intermediate data tensor Z. The parameter tensor contains all the parameters that control the activation function σ of the neurons in the layer. The weight tensor contains all the weights that connect the inputs to the layer. The input data tensor contains all the data that the layer consumes as input. The output data tensor contains all the data that the layer computes as output. The intermediate data tensor contains any data that the layer produces as intermediate computations, such as partial sums.
[0020] The data tensors (input, output, and intermediate) for a layer may be three-dimensional, in which case the first two dimensions can be interpreted as encoding spatial locations and the third dimension as encoding a different feature. For example, if the data tensor represents a color image, the first two dimensions encode the vertical and horizontal coordinates in the image, and the third dimension encodes the color at each location. Every element of the input data tensor X can be connected to every neuron by a separate weight, in which case the weight tensor W generally has six dimensions, concatenating the three dimensions of the input data tensor (input row a, input column b, input feature c) with the three dimensions of the output data tensor (output row i, output column j, output feature k). The intermediate data tensor Z has the same shape as the output data tensor Y. The parameter tensor V concatenates the three dimensions of the output data tensor with an additional dimension o that indexes the parameters of the activation function σ. In some embodiments, the activation function σ does not require additional parameters, in which case no additional dimensions are required. However, in some embodiments, the activation function σ requires at least one additional parameter, which appears in the dimension o.
[0021] The elements of the output data tensor Y of a layer can be calculated as shown in Equation 1, where the neuron activation function σ is composed of a vector of activation function parameters V[i,j,k,:], and the weighted sum Z[i,j,k] can be calculated as shown in Equation 2. Y[i,j,k]=σ(V[i,j,k,:];Z[i,j,k]) formula 1
number
[0022] For simplicity of notation, the weighted sum in Equation 2 is sometimes referred to as the output, with the understanding that this is equivalent to using a linear activation function Y[i,j,k] = σ(Z[i,j,k]) = Z[i,j,k], and the same description applies without loss of generality when a different activation function is used.
[0023] In various embodiments, the computation of the output data tensors as described above is decomposed into smaller problems, each of which can then be solved in parallel on one or more neural cores, or on one or more cores of a conventional multi-core system.
[0024] It should be clear from the above that neural networks are parallel structures. Neurons in a given layer receive elements x from one or more layers or other inputs. i Each neuron receives an input X with an input and an element w i The neural network computes its state y∈Y based on weights W with the weights W having the weights b. In various embodiments, the weighted sum of the inputs is scaled by a bias b, and then the result is passed to a nonlinearity F(·). For example, the activation of a single neuron is given by y=F(b+Σx i w i )
[0025] Since all neurons in a given layer receive input from the same layer and calculate their output independently, neuron activations can be calculated in parallel. This aspect of the overall neural network accelerates the overall computation by performing the computations in parallel distributed cores. Furthermore, within each core, vector operations can be calculated in parallel. In the case of recurrent inputs, even when a layer projects back on itself, all neurons are still updated simultaneously. In effect, the recurrent connections are delayed to line up with the next input to the layer.
[0026] Referring now to FIG. 1, a neural core according to an embodiment of the present disclosure is depicted. The neural core 100 is a tileable computational unit that computes one block of output tensors. The neural core 100 has M inputs and N outputs. In various embodiments, M=N. To compute the output tensor block, the neural core multiplies the M×1 input tensor block 101 with the M×N weight tensor block 102 and accumulates the products to obtain a weighted sum that is stored in the 1×N intermediate tensor block 103. The O×N parameter tensor block contains O parameters that define each of the N neuron activation functions that are applied to the intermediate tensor block 103 to generate the 1×N output tensor block 105.
[0027] The multiple neural cores can be tiled in an array of neural cores, hi some embodiments, the array is two-dimensional.
[0028] A neural network model is a set of constants that collectively specify the set of computations performed by a neural network, including the graph of connections between neurons and the weight and activation function parameters for every neuron. Training is the process of modifying a neural network model to perform a desired function. Inference is the process of applying a neural network to inputs to produce outputs, without modifying the neural network model.
[0029] An inference processing unit is a category of processor that performs neural network inference. A neural inference chip is a concrete physical instance of an inference processing unit.
[0030] Referring to FIG. 2, an exemplary inference processing unit (IPU) according to an embodiment of the present disclosure is shown. The IPU 200 includes a memory 201 for a neural network model. As mentioned above, the neural network model may include synaptic weights for the neural network to be calculated. The IPU 200 includes an activation memory 202, which may be temporary. The activation memory 202 may be divided into an input domain and an output domain and stores neuron activations to be processed. The IPU 200 includes a neural computation unit 203, which is loaded with the neural network model from the model memory 201. Before each computation step, the input activations are provided from the activation memory 202. The output from the neural computation unit 203 is written back to the activation memory 202 for processing on the same or another neural computation unit.
[0031] In various embodiments, the IPU 200 includes a micro-engine 204. In such an embodiment, all operations in the IPU are directed by the micro-engine. As described below, in various embodiments, a central micro-engine and / or distributed micro-engines may be provided. The global micro-engine may be referred to as a chip micro-engine, while the local micro-engines may be referred to as a core micro-engine or local controller. In various embodiments, the micro-engine comprises one or more micro-engines, micro-controllers, state machines, CPUs, or other controllers.
[0032] Referring to FIG. 3, a multi-core inference processing unit (IPU) according to an embodiment of the present disclosure is shown. The IPU 300 includes memory 301 and instructions for a neural network model. In some embodiments, the memory 301 is divided into a weight portion 311 and an instruction portion 312. As discussed above, the neural network model may include synaptic weights for the neural network to be calculated. The IPU 300 includes an activation memory 302, which may be temporary. The activation memory 302 may be divided into an input domain and an output domain and stores neuron activations to be processed.
[0033] The IPU 300 includes an array 306 of neural cores 303. Each core 303 includes a computation unit 333 that is loaded with a neural network model from the model memory 301 and is operable to perform vector computations. Each core also includes a local activation memory 332. Before each computation step, input activations are provided from the local activation memory 332. Outputs from the computation units 333 are written back to the activation memory 332 for processing on the same or another computation unit.
[0034] The IPU 300 includes one or more networks-on-chip (NoCs) 305. In some embodiments, a partial sum NoC 351 interconnects the cores 303 and communicates partial sums between them. In some embodiments, a separate parameter distribution NoC 352 connects the cores 303 to memory 301 for distributing weights and instructions to the cores 303. It will be appreciated that various configurations of NoCs 351 and 352 are suitable for use in accordance with the present disclosure. For example, a broadcast network, a row broadcast network, a tree network, and a switching network may be used.
[0035] In various embodiments, the IPU 300 includes a global micro-engine 304. In various embodiments, each core 303 includes a local core controller 334. In such embodiments, operational instructions are shared between the global micro-engine (chip micro-engine) and the local core controller (core micro-engine). In particular, at 311, the global micro-engine 304 loads computation instructions from the model memory 301 into the neural computation units 333 on each core 303. At 312, the global micro-engine 304 loads parameters (e.g., neural network weights / synaptic weights) from the model memory 301 into the neural computation units 333 on each core 303. At 313, the local core controller 334 loads neural network activation data from the local activation memory 332 into the neural computation units 333 of each core 303. As noted above, activations are provided to neurons of a particular neural network defined by the model and may originate from the same or another neural computation unit, or from outside the system. At 314, the neural computation unit 333 performs a computation to generate an output neuronal activation, as directed by the local core controller 334. In particular, the computation involves applying input synaptic weights to the input activations. It will be appreciated that various methods are available for performing such computations, including in silico dendrite and vector multiplication units. At 315, the results of the computation are stored in the local activation memory 332, as directed by the local core controller 334. As noted above, these stages may be pipelined to achieve efficient use of the neural computation units of each core. It will also be appreciated that inputs and outputs may be transmitted from the local activation memory 332 to the global activation memory 302, as per the requirements of a given neural network.
[0036] In this manner, the present disclosure provides run-time control of operations in an inference processing unit (IPU). In some embodiments, the micro-engine is centralized (a single micro-engine). In some embodiments, the IPU computations are distributed (performed by an array of cores). In some embodiments, the run-time control of operations is hierarchical, involving both centralized and distributed micro-engines.
[0037] One micro-engine or multiple micro-engines direct the execution of all operations in the IPU. Each instruction in the micro-engine corresponds to several sub-operations (e.g., address generation, load, calculation, store, etc.). In the distributed case, the core microcode executes on the core micro-engines (e.g., 334). The core microcode contains instructions to execute one complete tensor operation, e.g., a convolution between a weight tensor and a data tensor. In the single-core context, the core microcode contains instructions to execute one tensor operation on a subset of the locally stored data tensors (and partial sums). The chip microcode executes on the chip micro-engines (e.g., 304). The microcode contains instructions to execute all tensor operations in the neural network.
[0038] In various embodiments, a vector-matrix multiplier is used to accelerate the computation of synaptic integration. As outlined above, the activation vector X is multiplied by the weight matrix W. This intermediate result is given as PS = XW. Each column of PS is a matrix of weights W, and the weights W are multiplied by the activation vector X. j =Σx i w ij In this formula, activation x i and weight w ij For example, x may be 2 bits, 4 bits, or 8 bits in low-precision fixed-point arithmetic. In an exemplary implementation, the multiplication x i w ij is performed and all the products are summed.
[0039] An exemplary multiplier suitable for this computation can be implemented as follows: Booth recoding is applied to the generated partial sums to generate n / 2 partial sums for an n-bit multiplier. The partial sums are then compressed by a carry-save adder, reducing the number of partial sums from n / 2 to 2. A full carry-propagate adder (or a variant thereof) is used to add the final two partial sums to the product. In these steps, the carry-propagate adder requires complex circuitry. For a vector-multiplicative multiplication of an n-element vector X and an n×m-element matrix W, n×m carry-propagate adders are required. To reduce circuit space, Σx i w ij It is desirable to use only one carry propagate adder for each computation of Σx i w ij This can be optimized by changing the scale of the calculations in
[0040] It is further desirable to modify the vector-matrix multiplier to support multiple precisions, e.g., 2-bit, 4-bit, 8-bit, or more. It is also desirable to reuse circuitry as much as possible between these multiple precision calculations. In a multiply-first-summation approach, each multiplier must support multiple precision multiplications. By changing the scale of the operations in the circuitry, the same data path can be reused for the multiple precision operations.
[0041] In various embodiments, a fixed-point dot product calculation Σx i w ij is done by generating Booth-recoded partial sums, reducing the Booth-recoded partial sums of the same scale, and then summing all the partial sums to get the final answer.
[0042] In this case, individual multiplier values are not generated. Instead, the computation of each multiplier is distributed across the dot product computations. When computing with different precisions, different amounts of shifts are performed on the partial sums in the summation step. Thus, the amount of multi-precision circuitry required is minimal.
[0043] Referring to FIG. 4, an exemplary Booth recoding is shown. Booth recoding may be used by multipliers to generate partial sums. Values are recoded by table lookup. In this example, a radix-2 Booth recoding table is shown in Table 1.
[0044] [Table 1]
[0045] To illustrate the Booth recoding procedure, consider multiplying A by B using radix-4 Booth recoding. First, check the Booth recoding table (e.g., Table 1) for three bits of the multiplier B, starting from every other bit and overlapping. Use bits B[1:-1], B[3:1], B[5:3], etc. B[-1] is an extra bit added to the right of the least significant bit of B, which is 0. A partial sum vector is generated from A according to the Booth recoding of the corresponding position of B. The partial sum vector is shifted by two bits for each Booth recoding. This results in {B1,B0,B -1 The partial sum of} starts at bit position 0, while the partial sum of {B3,B2,B1} starts at bit position 2. The number of partial sum vectors is compressed down to 2 using a carry-save adder. Finally, the two compressed partial sum vectors are added to the product using a carry-propagate adder (or a variant thereof).
[0046] Referring to FIG. 5, an 8-bit Booth recoding multiplier is shown. In this example, a multiplication is performed between a multiplicand A (501) and a multiplier B (502). Assume B is an 8-bit binary number B[7:0]. B[-1]=0 is added to the right of B[0]. To compute the partial sums 503...506, a Booth table lookup is performed: Booth(B[i+1:i-1]) for i=0,2,4,6. If Booth(B[i+1:i-1])=2, then A*Booth(B[i+1:i-1])=A<<1. If Booth(B[i+1:i-1])=1, then A*Booth(B[i+1:i-1])=A. If Booth(B[i+1:i-1])=0, then A*Booth(B[i+1:i-1])=0. If Booth(B[i+1:i-1]) = -1, then A*Booth(B[i+1:i-1]) = -A. If Booth(B[i+1:i-1]) = -2, then A*Booth(B[i+1:i-1]) = -A<<1. The partial sum A*Booth(B[i+1:i-1]) is shifted left by i bits before the addition.
[0047] For example, partial sum 503 for i=0 is aligned with the positions of A and B. Partial sums 504, 505, and 506 are shifted left 2, 4, and 6 bits, respectively, so that partial sums 503-506 are offset from one another and are said to be of different scales.
[0048] In either case, the partial sum A*Booth(B[i+1:i-1])=A can be computed from the value A by selecting either 0, A, or -A, and optionally shifting one bit to the left. Finally, the four partial sums 503...506 are added together to obtain the product A*B 507.
[0049] Referring to Figure 6, an example of a Booth recoding multiplier is shown. This example shows a binary calculation of 19*71. The Booth recoded value from bit 110 in [B1:B-1] is -1 according to Table 1, so the first partial sum 603 is 111111111101101, which is the sign extension to the two's complement of the multiplicand 00010011 (601). The second Booth recoding of 011 in [B3:B1] is 2, so the second partial sum 000100110 (604) is the multiplicand shifted one bit to the left. The third Booth recoding value of 000 in [B5:B3] is 0, so the third partial sum 605 is 000000000. The last partial sum 606 is 000010011, because the Booth recoding of 010 in [B7:B5] is 1. These partial sums are two bits apart, i.e. partial sum 604 is two bits to the left of partial sum 603, partial sum 605 is four bits to the left of partial sum 603, and partial sum 606 is six bits to the left of partial sum 603. Finally, adding all the partial sums together produces the correct product 607, 19*71=1349, in binary format.
[0050] Referring to FIG. 7, an exemplary method for computing the dot product is shown. In this example, the multiplier A i *B i Then, add them together and calculate ΣA i *B i In this way, the inner product is calculated for each A i *B i This is obtained by first computing the results of the multiplications of and then adding them together.
[0051] Referring to FIG. 8, an exemplary method for calculating the dot product is shown. In this example, each A i *B i Instead of computing the product of A, the sum of the partial sums of the same scale is computed and then added together. i *B iFor 801...804, partial sums 811...814, 821...824, 831...834, and 841...844 are calculated as described above. i [1:-1], B i [3:1], B i [5:3], B i Four partial sums are calculated, corresponding to [7:5]. The partial sums of the same scale are individually summed by adder 805 to produce sum 806...809. For example, partial sums 811, 821, 831, and 841 are of the same scale and are added together by adder 805 to produce sum 806. Separately, partial sums 812, 822, 832, and 842 are of the same scale and are added together to produce sum 807. Partial sums 813, 823, 833, and 843 are added together to produce sum 808. Partial sums 814, 824, 834, and 844 are added together to produce sum 809. Finally, sums 806...809 are shifted two bits apart and added together to produce the final result ΣA i *B i 810 is calculated.
[0052] Referring to FIG. 9, a method for computing the inner product is shown. In particular, as shown, the inner product ΣA0*B0 is computed using the sum of partial sums of the same scale. At 901, all multiplicands B i Booth recoded. In 902, A i and B i Partial sums are generated from the recoded values of , and . At 903, the sums of all partial sums with the same scale from different multipliers are calculated separately. At 904, the sums of the partial sums are appropriately shifted and added.
[0053] In this approach, all partial sums of the same scale are aligned, making the initial summation process more efficient. In low-precision neural vector-matrix multiplication of large vectors and matrices, the number of partial sums of different scales that each multiplication has is small. However, there are many partial sums of the same scale from different multiplications. Thus, reducing the number of partial sums leads to a more efficient implementation. For example, a 32x32 matrix with 8-bit precision has 4 partial sums per multiplication. However, each dot product calculation requires adding up all 32 partial sums of the same scale.
[0054] Another advantage of this approach is that it allows sharing of computation circuitry for multiple precision modes. Referring to FIG. 10, a multiple precision input data format is shown. In such an embodiment, the same vector or matrix is interpreted with different precisions. For example, 16 bits of data may be used as a 2 element 8 bit vector, a 4 element 4 bit vector, or an 8 element 2 bit vector. As shown in FIG. 10, 8 bits may be used to provide 8 bit mode activation (1001), 4 bit mode activation (1002), or 2 bit mode activation (1003). Similarly, 8 bits may be used to provide 8 bit mode weight (1004), 4 bit mode weight (1005), or 2 bit mode weight (1006). This shows how 8 bits of data may be interpreted as one 8 bit, two 4 bits, or four 2 bits.
[0055] The dot product circuit described above can be used to support multi-precision dot product generation. The Booth recoding and partial sum generation circuits need to modify the input data somewhat. No modification is needed for the circuit to add all partial sums of the same scale. The final summation circuit needs to shift the sums of partial sums of the same scale with different amounts and then add them together.
[0056] Referring to Figures 11A-11C, partial sum generation is compared for 8-bit (Figure 11A), 4-bit (Figure 11B), and 2-bit (Figure 11C) modes. This shows how the partial sums are generated. In comparison to the 8-bit mode, the multiplicand input to the partial sum generator is a 4-bit A' i or 2-bit A'' i The multiplicands input to the Booth encoder are almost identical bits (B0[7:5]=B'1[3:1] and B0[7:6]=B''3[1:0]). i [-1] and B'' i Only [-1] should be assumed to be 0.
[0057] 11A shows how an 8-bit multiplier computes an 8-bit product 1117. The partial sums 1113...1116 for the 8-bit multiplier are generated by first computing the Booth recoding of B0, and then choosing 0, A0, or -A0, possibly with a shift.
[0058] In FIG. 11B, a binary 4-bit multiplier generates A'0*B'0+A'1*B'1. First B'0 is Booth-recoded and used to generate partial sums 1123...1124. These partial sums need to be generated by selecting either 0, A'0, or -A'0, possibly with a shift of 1 bit to the left. Similarly, B'1 will be Booth-recoded and used to generate partial sums 1125...1126, possibly with a shift of 1 bit, by selecting either 0, A'1, or -A'1. Unlike the 8-bit multiplier, the partial sums 1123...1124 from A'0 and B'0 are aligned with the partial sums 1125...1126 generated from A'1 and B'1 because they are both generated from Booth-recoding in the 1 to -1 positions, which are B'0[1:-1] and B'1[1:-1]. Finally, all of the partial sums 1123 . . . 1126 are added together to generate a 4-bit dot product 1127 .
[0059] In FIG. 11C, a quaternary 2-bit multiplier computes the dot product A''0*B''0+A''1*B''1+A''2*B''2+A''3*B''3. Partial sum 1133 is generated from A''0 and B''0 by first Booth recoding B''0 and selecting either 0, A''0, or -A''0. Similarly, partial sum 1134 is generated from A''1 and B''1, partial sum 1135 is generated from A''2 and B''2, and partial sum 1136 is generated from A''3 and B''3. All partial sums 1133...1136 are aligned because they are generated from the same bit position Booth recording values. Partial sums 1133...1136 are added together to generate a 2-bit dot product 1137.
[0060] Compared to the 8-bit mode, the multiplicand input to the partial sum generator is a 4-bit A' i or 2-bit A'' i The multiplicands input to the Booth encoder are almost identical bits (B0[7:5]=B'1[3:1] and B0[7:6]=B''3[1:0]). i [-1] and B'' i Only [-1] must be assumed to be 0. The Booth recoding logic is shareable because the logic can select and shift the multiplicand.
[0061] Referring to FIG. 12, a method for computing a 4-bit dot product is shown. In this embodiment, the same approach is employed to add the partial sums first. In this case, the partial sum summing circuitry is the same as the 8-bit dot product computation as shown in FIG. 8. In particular, the first partial sums (e.g., 1201) from each multiplier are collected to compute sum 1205 using circuitry as described for 8-bit mode. Similarly, the second partial sums (e.g., 1202) are added to generate sum 1206, the third partial sums (e.g., 1203) are added to generate sum 1207, and the fourth partial sums (e.g., 1204) are added to generate sum 1208. To accommodate 4-bit mode computation, a different shift amount is applied to each of the sums 1205...1208 before the final summation to compute result 1209.
[0062] For each partial sum calculation, the first partial sum 1201 and the second partial sum 1202 are of different scale, and therefore partial sum 1202 is shifted two bits to the left compared to partial sum 1201. However, the third partial sum 1203 has the same scale as partial sum 1201, and these two partial sums are aligned before the final addition. Similarly, the fourth partial sum 1204 is aligned with the second partial sum 1202, but is shifted two bits to the left compared to partial sum 1203. Sum 1206 is shifted two bits to the left compared to the sum of partial sums 1205. However, the third sum 1207 has the same scale as sum 1205, and these two sums are aligned before the final addition. Similarly, the fourth sum 1208 is aligned with the second sum 1206, but is shifted two bits to the left compared to sum 1207. The shift control for 4-bit mode differs from 8-bit mode in that it only needs to be performed once before the final addition to compute the result 1209, rather than at each multiplier.
[0063] Referring to Figure 13, a method for computing a 2-bit dot product is shown. Similar to the 4-bit dot product calculation in Figure 12, the 2-bit calculation uses the same data path as the 8-bit mode (as in Figure 8) to add together the partial sums, except that the final sum is obtained by adding the sum of the partial sums without any shifting.
[0064] By employing a technique of first adding partial sums of the same scale, the data path for multiple precisions can be shared, for example providing 8-bit, 4-bit and 2-bit modes. The Booth recoder and partial sum generators adopt somewhat modified inputs between the various precision configurations. The summation circuitry for partial sums of the same scale is identical. The final summation requires different amounts of shifting depending on the precision. This leads to a more compact design than the others. Compared to the 8-bit configuration, the 4-bit mode requires twice the amount of computations per cycle for multiply-and-accumulate operations, and the 2-bit mode requires four times the number of multiply-and-accumulate operations.
[0065] Referring to FIG. 14, a method for computing a variable precision inner product using the sum of partial sums of the same scale is shown. At 1401, all multiplicands B i is Booth-recoded. In 1402, A i and B i Partial sums are generated from the recoded values of x, y, and y. At 1403, all partial sums with the same scale are summed. At 1404, the sums of the partial sums are shifted according to their precision. At 1405, the partial sums are added to arrive at a result.
[0066] Referring to FIG. 15, a method for computing neural activations is shown. At 1501, an input activation tensor is received that includes a plurality of input activations. At 1502, a weight tensor is received that includes a plurality of weights. At 1503, each of the plurality of weights is Booth-recoded into a plurality of Booth-coded weights, each Booth-coded value having a scale. At 1504, the input activation tensor is multiplied by the Booth-coded weights to compute a plurality of results for each input activation, each of the plurality of results corresponding to a scale of the Booth-coded weight. At 1505, the results corresponding to each scale of the Booth-coded weights are summed to compute a plurality of partial sums, one for each scale. At 1506, neural activations are computed from the sum of the plurality of partial sums.
[0067] As discussed above, various embodiments of the present disclosure include a chip for computing an inner product of two vectors by Booth recoding each element of the multiplication vector. Partial sums are generated using elements of the multiplicand vector and the recoded multiplication values. All partial sums of the same scale are added. The sums of partial sums of the same scale are added with shifts. In some embodiments, the partial sum addition is performed using a tree of carry-save adders. In various embodiments, multiple instances of a vector multiplier are combined to form a vector-matrix multiplier. In various embodiments, multiple instances are combined to form a matrix-matrix multiplier.
[0068] In various embodiments, multiple precisions are supported by first Booth-recoding the elements of the multiplication vector according to the precision. Partial sums can then be generated according to that precision. All partial sums of the same scale are added. The sums of the partial sums are shifted according to the precision and then they are added together.
[0069] 16, a schematic diagram of an example computational node is shown. Computational node 10 is merely one example of a suitable computational node, and is not intended to suggest any limitation as to the scope of use or functionality of the embodiments described herein. In any case, computational node 10 may be implemented and / or capable of performing any of the functionality described herein above.
[0070] Residing on the computing node 10 is a computer system / server 12 that is capable of operating with numerous other general purpose or special purpose computing system environments or configurations. Examples of well-known computing systems, environments, or configurations or combinations thereof that may be suitable for use with the computer system / server 12 include, but are not limited to, personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics devices, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments that include any of the above systems or devices.
[0071] The computer system / server 12 may be described in the general context of computer system executable instructions, such as program modules, executed by a computer system. Generally, program modules may include routines, programs, objects, components, logic, data structures, etc. that perform particular tasks or implement particular abstract data types. The computer system / server 12 may also be practiced in a distributed cloud computing environment where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules may be located in both local and remote computer system storage media, including memory storage devices.
[0072] 16, computer system / server 12 in compute node 10 is shown in the form of a general purpose computing device. Components of computer system / server 12 may include, but are not limited to, one or more processors or processing units 16, system memory 28, and a bus 18 coupling various system components including system memory 28 to processor 16.
[0073] Bus 18 may represent one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures, including, by way of example and without limitation, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA (EISA) bus, Video Electronics Standards Association (VESA) local bus, Peripheral Component Interconnects (PCI) bus, Peripheral Component Interconnect Express (PCIe), and Advanced Microcontroller Bus Architecture (AMBA).
[0074] In various embodiments, one or more inference processing units (not shown) are coupled to bus 18. In such embodiments, the IPU may receive data from or write data to memory 28 via bus 18. Similarly, the IPU may interact with other components via bus 18 as described herein.
[0075] Computer system / server 12 typically includes a variety of computer system readable media, which may be any available media accessible by computer system / server 12 and includes both volatile and nonvolatile media, removable and non-removable media.
[0076] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The computer system / server 12 may further include other removable / non-removable volatile / non-volatile computer system storage media. By way of example only, a storage system 34 may be provided for reading from and writing to a non-removable, non-volatile magnetic medium (not shown, but typically referred to as a "hard drive"). Although not shown, a magnetic disk drive may be provided for reading from and writing to a removable, non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive may be provided for reading from or writing to a removable, non-volatile optical disk, such as a CD-ROM, DVD-ROM, or other optical medium. In such an example, each may be connected to the bus 18 by one or more data media interfaces. As further depicted and described below, the memory 28 may include at least one program product having a set (e.g., at least one) program module configured to perform the functions of an embodiment of the present disclosure.
[0077] A program / utility 40 having a set (at least one) program module 42 may be stored in memory 28, by way of example and not limitation, but also in an operating system, one or more application programs, other program modules, and program data. Each of the operating system, one or more application programs, other program modules, and program data, or any combination thereof, may include an implementation of a networking environment. The program modules 42 generally perform the functions or methodologies, or combinations thereof, of the embodiments described herein.
[0078] The computer system / server 12 may also communicate with one or more external devices 14, such as a keyboard, pointing device, display 24, etc., one or more devices that enable a user to interact with the computer system / server 12, or any device (e.g., network card, modem, etc.) that enables the computer system / server 12 to communicate with one or more other computing devices, or a combination thereof. Such communication may occur via an input / output (I / O) interface 22. Furthermore, the computer system / server 12 may communicate with one or more networks, such as a local area network (LAN), a general wide area network (WAN), or a public network (e.g., the Internet), or a combination thereof, via a network adapter 20. As depicted, the network adapter 20 communicates with other components of the computer system / server 12 via a bus 18. Although not shown, it should be understood that other hardware and / or software components may be used in combination with the computer system / server 12. Examples include, but are not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archive storage systems.
[0079] The present disclosure may be embodied as a system, method, or computer program product, or a combination thereof. The computer program product may include a computer-readable storage medium having computer-readable program instructions for causing a processor to perform aspects of the present disclosure.
[0080] A computer readable storage medium may be a tangible device capable of holding and storing instructions for use by an instruction execution device. A computer readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the above. A non-exhaustive list of more specific examples of computer readable storage media includes the following: portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD), memory stick, floppy disk, mechanically encoded devices such as punch cards or ridge structures in a groove on which instructions are recorded, and any suitable combination of the above. As used herein, computer-readable storage media should not be construed as ephemeral signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission medium (e.g., light pulses passing through a fiber optic cable), or electrical signals transmitted over wires.
[0081] The computer readable program instructions described herein may be downloaded from a computer readable storage medium to each computing / processing device or to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, or a wireless network, or a combination thereof. The network may comprise copper transmission cables, optical transmission fiber, wireless transmission, routers, firewalls, switches, gateway computers, or edge servers, or a combination thereof. A network adapter card or network interface in each computing / processing device receives the computer readable program instructions from the network and forwards the computer readable program instructions to be stored in a computer readable storage medium in the respective computing / processing device.
[0082] The computer readable program instructions for carrying out the operations of the present disclosure may be either source code or object code written in any combination of one or more programming languages, including assembler instructions, instruction set architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state setting data, or object oriented programming languages such as Smalltalk®, C++, and traditional procedural programming languages such as the “C” programming language or similar programming languages. The computer readable program instructions may be executed exclusively on the user's computer, partially on the user's computer as a stand-alone software package, partially on the user's computer and partially on a remote computer, or exclusively on a remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), can execute computer readable program instructions to personalize the electronic circuitry by utilizing state information of the computer readable program instructions to perform aspects of the present disclosure.
[0083] Aspects of the present disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present disclosure. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer readable program instructions.
[0084] These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, executed by the processor of the computer or other programmable data processing apparatus, produce means for performing the functions / operations specified in one or more blocks of the flowcharts and / or block diagrams. These computer readable program instructions may also be stored on a computer readable storage medium and capable of directing a computer, programmable data processing apparatus, or other device, or combination thereof, to function in a particular manner, such that the computer readable storage medium on which the instructions are stored comprises an article of manufacture containing instructions for performing aspects of the functions / operations specified in one or more blocks of the flowcharts and / or block diagrams.
[0085] The computer readable program instructions may also be loaded into a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus, or other device to create a computer-implemented process such that the instructions, which execute on the computer, other programmable apparatus, or other device, perform the functions / operations specified in one or more blocks of the flowcharts and / or block diagrams.
[0086] The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowcharts or block diagrams may represent a module, segment, or portion of instructions, comprising one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions noted in the blocks may be executed in a different order than that noted in the figures. For example, two blocks shown in succession may in fact be executed substantially in parallel, or the blocks may sometimes be executed in reverse order depending on the functionality involved. It will also be noted that each block of the block diagrams and / or flowchart illustrations, and combinations of blocks in the block diagrams and / or flowchart illustrations, may be implemented by a dedicated hardware-based system that performs the specified functions or operations or executes a combination of dedicated hardware and computer instructions.
[0087] Although the description of various embodiments of the present disclosure has been presented for illustrative purposes, they are not intended to be exhaustive or limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used in this specification has been selected to best explain the principles of the embodiments, practical applications, or technical improvements to the technology found in the market, or to allow other skilled in the art to understand the embodiments disclosed herein.
Claims
1. 1. A method for fixed-point computation of neural activations, comprising: receiving an input activation tensor that includes a plurality of input activations; receiving a weight tensor including a plurality of weights; Booth-recoding each of the plurality of weights into a plurality of Booth-coded weights, each Booth-coded value having a scale; multiplying the input activation tensors by the Booth coded weights such that a plurality of results are calculated for each input activation, each of the plurality of results corresponding to the scale of the Booth coded weight; summing the corresponding results for each scale of the Booth-coded weights such that a plurality of partial sums are calculated, one for each scale; and computing neural activations from a sum of the plurality of partial sums, the sum including shifting each of the plurality of partial sums.
2. The method of claim 1 , wherein the input activation tensor is one-dimensional.
3. The method of claim 1 , wherein the weight tensor is two-dimensional.
4. The method of claim 1 , wherein computing the neural activations comprises shifting each of the plurality of partial sums according to its corresponding scale.
5. A method for calculating neural activation, comprising: receiving an input activation tensor that includes a plurality of input activations; receiving a weight tensor including a plurality of weights; Booth-recoding each of the plurality of weights into a plurality of Booth-coded weights, each Booth-coded value having a scale; multiplying the input activation tensors by the Booth coded weights such that a plurality of results are calculated for each input activation, each of the plurality of results corresponding to the scale of the Booth coded weight; summing the corresponding results for each scale of the Booth-coded weights such that a plurality of partial sums are calculated, one for each scale; and computing a neural activation from a sum of the plurality of partial sums; The method of claim 1, wherein computing the neural activations includes shifting each of the plurality of partial sums according to a precision of the input activations.
6. The method of claim 1 , wherein computing the neural activations comprises applying a non-linear activation function to the sum of the plurality of partial sums.
7. 2. The method of claim 1, wherein summing the corresponding results comprises applying a multiple carry-save adder.
8. 1. A method for fixed-point computation of neural activations, comprising: receiving an input activation tensor that includes a plurality of input activations; receiving a weight tensor including a plurality of weights; Booth-recoding each of the plurality of input activations into a plurality of Booth-coded input activations, each Booth-coded value having a scale; multiplying the weight tensor by the Booth-coded input activations to produce a plurality of results for each weight, each of the plurality of results corresponding to the scale of the Booth-coded input activations; summing the corresponding results for each scale of the Booth-coded input activations such that a plurality of partial sums are calculated, one for each scale; and computing neural activations from a sum of the plurality of partial sums, the sum including shifting each of the plurality of partial sums.
9. The method of claim 8 , wherein the input activation tensor is one-dimensional.
10. The method of claim 8 , wherein the weight tensor is two-dimensional.
11. 9. The method of claim 8, wherein computing the neural activations comprises shifting each of the plurality of partial sums according to its corresponding scale.
12. A method for calculating neural activation, comprising: receiving an input activation tensor that includes a plurality of input activations; receiving a weight tensor including a plurality of weights; Booth-recoding each of the plurality of input activations into a plurality of Booth-coded input activations, each Booth-coded value having a scale; multiplying the weight tensor by the Booth-coded input activations to produce a plurality of results for each weight, each of the plurality of results corresponding to the scale of the Booth-coded input activations; summing the corresponding results for each scale of the Booth-coded input activations such that a plurality of partial sums are calculated, one for each scale; and computing a neural activation from a sum of the plurality of partial sums; The method of claim 1, wherein computing the neural activations includes shifting each of the plurality of partial sums according to a precision of the input activations.
13. 9. The method of claim 8, wherein computing the neural activations comprises applying a non-linear activation function to the sum of the plurality of partial sums.
14. 9. The method of claim 8, wherein summing the corresponding results comprises applying a multiple carry-save adder.
15. A neural inference chip for fixed-point computation of neural activations, comprising: receiving an input activation tensor that includes a plurality of input activations; receiving a weight tensor including a plurality of weights; Booth-recoding each of the plurality of weights into a plurality of Booth-coded weights, each Booth-coded value having a scale; multiplying the input activation tensors by the Booth coded weights such that a plurality of results are calculated for each input activation, each of the plurality of results corresponding to the scale of the Booth coded weight; summing the corresponding results for each scale of the Booth-coded weights such that a plurality of partial sums are calculated, one for each scale; and calculating a neural activation from a sum of the plurality of partial sums, including shifting each of the plurality of partial sums.
16. 16. The neural inference chip of claim 15, wherein computing the neural activations includes shifting each of the plurality of partial sums according to its corresponding scale.
17. A neural inference chip for computing neural activations, comprising: receiving an input activation tensor that includes a plurality of input activations; receiving a weight tensor including a plurality of weights; Booth-recoding each of the plurality of weights into a plurality of Booth-coded weights, each Booth-coded value having a scale; multiplying the input activation tensors by the Booth coded weights such that a plurality of results are calculated for each input activation, each of the plurality of results corresponding to the scale of the Booth coded weight; summing the corresponding results for each scale of the Booth-coded weights such that a plurality of partial sums are calculated, one for each scale; and computing a neural activation from the sum of the plurality of partial sums; A neural inference chip, wherein computing the neural activations includes shifting each of the plurality of partial sums according to a precision of the input activations.
18. 16. The neural inference chip of claim 15, wherein computing the neural activations comprises applying a non-linear activation function to the sum of the plurality of partial sums.
19. 16. The neural inference chip of claim 15, wherein summing the corresponding results includes applying a multiple carry-save adder.
20. A neural inference chip for fixed-point computation of neural activations, comprising: receiving an input activation tensor that includes a plurality of input activations; receiving a weight tensor including a plurality of weights; Booth-recoding each of the plurality of input activations into a plurality of Booth-coded input activations, each Booth-coded value having a scale; multiplying the weight tensor by the Booth-coded input activations to produce a plurality of results for each weight, each of the plurality of results corresponding to the scale of the Booth-coded input activations; summing the corresponding results for each scale of the Booth-coded input activations such that a plurality of partial sums are calculated, one for each scale; and calculating a neural activation from a sum of the plurality of partial sums, including shifting each of the plurality of partial sums.
Citation Information
Patent Citations
System containing neural net layer
JP1992280387A
Multiplier and arithmetic unit for sum of product
JP1997179723A
Multiplier for performing 3D graphics interpolation
JP2000510268A
Accelerated mathematical engine
US20190026078A1
