Methods and systems for online selection of number formats for network parameters of a neural network
Collecting statistics before format conversion and using a stable format selection algorithm in neural networks addresses the sensitivity to outliers and instability in existing methods, achieving stable and efficient number format selection for neural networks.
Patent Information
- Application Number
- GB2022014407
- Authority / Receiving Office
- GB · GB
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2024-10-30
- Estimated Expiration
- 2042-09-30
AI Technical Summary
Existing format selection algorithms for neural networks, such as the minimum/maximum algorithm, are sensitive to outliers, leading to large quantization errors and instability when selecting a number format for representing network parameters, especially when statistics are collected after format conversion.
Implementing a format selection algorithm that collects statistics before format conversion and using a stable, convergent method like the minimum/maximum algorithm, with adjustments such as capping the minimum value before the log function, or employing a more complex algorithm to address metastability and slow convergence issues.
This approach results in more stable and faster convergence of number formats, reducing quantization errors and ensuring accurate representation of network parameters, with similar classification accuracy to offline format selection methods.
Smart Images

Figure 00000001_0000 
Figure 00000002_0000 
Figure 00000003_0000
Abstract
Description
[0092] A format selection algorithm is an algorithm that is used to select a number format for representing a set of values from a plurality of potential number formats. Where the plurality of 13 09 23 potential number formats are number formats of a specific block-configurable type of number format, selecting a number format from the plurality of potential number formats may comprise selecting one or more quantisation parameters for the type of number format. For example, determining a number format of a block-configurable type of number format defined by a b-bit 5 mantissa and an exponent exp may comprise identifying the bit width b of the mantissa and / or the value of the exponent exp. In the examples described herein it is assumed that the bit width for a block-configurable number format has been pre-determined and the methods herein are used to select any combination of the remaining quantisation parameters (e.g. exp).
[0093] One example format selection algorithm for selecting a number format for representing a 10 set of network parameters of an ANN, which may be used in combination with the statistics collection hardware units described herein, is referred to as the full range algorithm or the minimum / maximum algorithm. The minimum / maximum algorithm selects a number format that will cover the entire range of the set of network parameters. For example, for a given mantissa bit depth b, the method may be used to select the smallest exponent exp that covers the range for the 15 set of network parameters x. For example, for a given mantissa bit depth b, the exponent exp can be selected in accordance with equation (3) such that the number format covers the entire range of x where [. 1 is the ceiling function. It will be evident to a person of skill in the art that equation (3) is a simplified version of the minimum / maximum algorithm that ignores the fact that the upper bound, strictly speaking is - i (i.e., the final (-1) is ignored). The addition of 1 in equation (3) 2 o accounts for the fact that the mantissa incorporates a sign bit, for example for 2s complement arithmetic. exp = [log2(max(|x|))l - b + 1 (3)
[0094] However, such a method is sensitive to outliers. Specifically, where the set of network parameters x has outliers, precision is sacrificed to cover the outliers. This may result in large 25 quantisation errors (e.g., the error between the set of network parameters in a first number format (e.g., floating point number format) and the set of network parameters in the selected number format). As a consequence, the error in the output data of the layer and / or of the ANN caused by the quantisation, may be greater than if the number format covered a smaller range, but with more precision. 3 0
[0095] Another example format selection algorithm for selecting a number format for representing a set of network parameters of an ANN, which may be used in combination with the statistics collection hardware units described herein is referred to as the weighted outlier algorithm and is described in the Applicant’s GB Patent Application No. 1718293.2, which is herein incorporated by reference in its entirety. In the weighted outlier algorithm the number format for a set of network 35 parameters is selected from a plurality of potential number formats based on the weighted sum of the quantisation errors when a particular number format is used, wherein a constant weight is applied to the quantisation errors for network parameters that fall within the representable range of 13 09 23 the number format and a linearly increasing weight is applied to the quantisation errors for the values that fall outside the representable range.
[0096] It will be evident to a person of skill in the art that these are only example format selection algorithms and any format selection algorithm which selects a fixed point number format for a set of 5 values based on one or more statistics of the set of network parameters may be used with the statistics collection hardware units described herein.
[0097] In some cases, the format selection algorithm used to select a number format from statistics generated by a statistics collection hardware unit may be implemented or executed by the NNA. For example, the NNA may have dedicated hardware (e.g., a format selection hardware unit 10 (e.g., fixed function circuitry)) to receive the statistics generated by the statistics collection hardware unit, and select a number format therefrom in accordance with a format selection algorithm. In some cases, the dedicated hardware may form part of the associated statistics collection hardware unit. Having dedicated hardware in the NNA that is configured to implement a format selection hardware may increase the speed at which a number format can be selected, but 15 it may increase the complexity of the NNA.
[0098] In other cases, the format selection algorithm used to select a number format from statistics generated by a statistics collection hardware unit may be implemented or executed by a unit external to the NNA. For example, there may be a processor or dedicated hardware that is external, but connected, to the NNA that is configured to receive the statistics generated by the 2 0 statistics collection hardware unit, and select a number format therefrom in accordance with a format selection algorithm. In another example, the host (e.g., host CPU) that controls the operation of the NNA may be configured to receive the statistics generated by a statistics collection hardware unit, and select a number format therefrom in accordance with a format selection algorithm. Where an external processor or a CPU executes the format selection algorithm the 2 5 format selection algorithm may be implemented in software. One benefit of implementing the format selection algorithm in software rather than hardware is that it allows the format selection algorithm to be more easily changed if, for example, a better or more efficient format selection algorithm is developed or discovered. Relationship Between Statistics Collection Hardware Unit and Format Conversion Hardware 30 Unit
[0099] As described above, each statistics collection hardware unit generates statistics for a set of network parameters that are converted by the associated format conversion hardware unit, and the number format selected based on the statistics collected by a statistics collection hardware unit is used to control the conversion performed by that format conversion hardware unit for a current 35 pass of the neural network or a subsequent pass of the neural network. In some cases, as shown in FIG. 3 and at 502 of FIG. 5 a statistics collection hardware unit 504 may be configured to collect or generate statistics on the set of network parameters before the network parameters have been converted to a desired number format by the associated format conversion hardware unit 506. In other words, in some cases the statistics collection hardware unit may collect statistics on a set of 13 09 23 network parameters input to the associated format conversion hardware unit. However, in other cases, as shown at 508 of FIG. 5 a statistics collection hardware unit 510 may be configured to collect or generate statistics on the set of network parameters after they have been converted to a desired number format by the associated format conversion hardware unit 512. In other words, in some cases, the statistics collection hardware unit may collect statistics on a set of network parameters output from the associated format conversion hardware unit. If an NNA has more than one statistics collection hardware unit, then one or more of the statistics collection hardware units may collect statistics on a set of network parameters prior to format conversion by the respective associated format conversion hardware unit(s), and one or more of the statistics collection hardware units may collect one or more statistics on a set of network parameters after format conversion by the respective associated format conversion hardware unit(s).
[0100] Since it may take multiple passes in the same direction (e.g. multiple forward passes or multiple backward passes) to settle upon a suitable number format for a set of network parameters due to factors such as changes in number formats in earlier layers causing knock-on effects later in the network, it is preferable to use a format selection method that converges and is stable after convergence. A stable, convergent method will also be able to track changes in the input after convergence. As shown in FIG. 5 collecting statistics prior to format conversion results in a fully feed forward graph and collecting statistics post format conversion results in feedback. Testing shows that, particularly when a simple format selection algorithm, such as the minimum / maximum format selection algorithm is used, selecting a format from statistics collected from a set of network parameters prior to format conversion produces more stable results and converges faster than selecting a format from statistics collected from the set of network parameters after format conversion.
[0101] For example, FIG. 6 shows, on the left, plots of tensor stability points for the ResNet v2 network with 5 format selection images, with statistics collected before and after format conversion using the minimum / maximum method. The stability point indicates the number of iterations for the format to converge. For example, a stability point of 0 indicates that the format was stable after one iteration, and a stability point of 1 indicates it took 2 iterations to stabilize. It can be seen that, when the statistics were collected before format conversion, the formats of the neural network were in a steady state after 5 iterations, whereas when the statistics were collected after format conversion, the formats were not all stable even after 10 iterations. FIG. 6 also shows, in the middle, plots of the exponent selected each iteration in accordance with the minimum / maximum method with statistics collected before and after format conversion for the tensor output from a layer, early in the network, that implements a ReLU function. It can be seen that the format (e.g. exponent) for this layer converges whether the statistics are collected before or after format conversion. FIG. 6 also shows, on the right, plots of the exponent selected each iteration in accordance with the minimum / maximum method with statistics collected before and after conversion for the tensor output from a layer, later in the network, that implements a SoftMax function. It can be seen that the format (e.g. exponent) for this tensor does not correctly converge 13 09 23 when the statistics are collected after format conversion; rather, it oscillates between two values. This undesired property is called metastability.
[0102] FIG. 7 shows, on the left, plots of tensor stability points fora style transfer network, with statistics collected before and after format conversion using the minimum / maximum method. This network’s architecture is deeper and more complex than the first example. It can be seen that, when the statistics were collected before format conversion, the formats were in a steady state after 50 iterations, although there was quite a range of convergence points over the layers of the network. In contrast, it can be seen that, when the statistics were collected after format conversions, the formats of the network were not stable even after 100 iterations. FIG. 7 also shows, in the middle, plots of the exponent selected each iteration in accordance with the minimum / maximum method with statistics collected before and after format conversion for the tensor output from a layer that implements a multiply function. It can be seen that the format (e.g. exponent) for this layer converges whether the statistics are collected before or after format conversion, although it takes significantly longer for the format to converge when the statistics are collected after format conversion. FIG. 7 also shows, on the right, plots of the exponent selected each iteration in accordance with the minimum / maximum method with statistics collected before and after conversion for the tensor output from a layer that implements a reduce step function. It can be seen that the format (e.g. exponent) takes a long time to converge when the statistics are collected prior to format conversion, and does not converge (after 100 iterations) when the statistics are collected after format conversion. So, in the example, collecting statistics after format conversion results in slow convergence and instability.
[0103] In some cases, where the format selection method is the minimum / maximum method, some of the stability problems (e.g. non-convergence and metastability) that occur when selecting a format from statistics collected from the set of network parameters after format conversion may be addressed by capping the minimum value before the log at 2prevexp where prevexp is the current exponent such that the format selection algorithm that is implemented is expressed in equation (4). However, testing has shown that this may still converge more slowly than a selecting a format from statistics collected from a set of network parameters prior to format conversion and / or may be at risk of metastability. In other cases, some of the stability problems that occur when selecting a format from statistics collected from the set of network parameters after format conversion may be addressed by using a more complex format selection algorithm. exp = [log2(max (max(|x|), 2prevexp)] — b + 1 (4) Statistics Collection Hardware Unit
[0104] As described above, the statistics that are collected or generated by a statistics collection hardware unit may be chosen to correspond to the format selection algorithm that is used. For example, if the minimum / maximum algorithm is used to select a number format, then the statistics collection hardware unit may be configured to collect or generate the maximum absolute value of a set of network parameters. In another example, if the weighted outlier algorithm is used to select a number format, then the statistics collection hardware unit may be configured to generate a 13 09 23 histogram of the set of values (e.g. with roughly 1000 entries). The component implementing the format selection may then generate quantisation errors for each range in the histogram for each of a plurality of number formats, and select one of those formats in accordance with the weighted outlier method. It will be evident that these are example statistics that may be collected by a statistics collection hardware unit and that other statistics may be collected or generated by a statistics collection hardware unit.
[0105] Reference is now made to FIG. 8 which illustrates an example statistics collection hardware unit 800 for use with the minimum / maximum format selection algorithm. Specifically, the example statistics collection hardware unit 800 is configured to collect or generate the maximum absolute value from a set of network parameters. The example statistics collection hardware unit comprises an absolute value module 802, a maximum module 804, and a register 806. The absolute value module 802 is configured to receive a value (e.g., a network parameter) and output the absolute value thereof. The maximum module 804 is configured to select the maximum of the output of the absolute value module 802 and the value stored in the register 806. The register 806 is configured to store the output of the maximum module 804. It will be evident to a person of skill in the art that the network parameters are streamed overtime into the absolute value module 802 and for each network parameter the register will be clocked and updated. Accordingly, the example statistics collection hardware unit 800 is configured to determine and output the maximum absolute value of a set of network parameters streamed over time.
[0106] In the example shown in FIG. 8 the statistics collection hardware unit 800 is configured to receive one network parameter at a time, however, in other cases the statistics collection hardware unit may be configured to receive multiple (N) network parameters at a time (e.g., an N-element vector of network parameters). In such cases, the statistics collection hardware unit may comprise N absolute values modules, or a vectorised absolute value module that can output the absolute value of N inputs; and the maximum module may be configured to receive and compare N +1 inputs (that is, the N outputs of the vectorised absolute value module and the value stored in the register).
[0107] Preferably the absolute value module, maximum module and register operate in the same number format as the received network parameters (i.e., no format conversion). Where the bit width or bit length of the network parameters is variable then preferably the absolute value module, maximum module, and register are capable of supporting the maximum possible bit width orbit length. Where the set of networks may be in any of a plurality of types of number formats, preferably the statistics collection unit is able to process network parameters in any of the types of number format. For example, in some cases, the input buffer may be able to receive input data in either a floating point number format or a fixed point number format. In these cases, it would be preferable for a statistics collection unit that is configured to collect statistics on the input data to the input buffer to be able to accept and process network parameters in either type of number format. 13 09 23
[0108] As described above, in some cases, the format selection algorithm may be implemented by hardware in the NNA. In such cases, the NNA may comprise dedicated hardware that implements the format selection algorithm. The dedicated hardware that implements the format selection algorithm may be separate from or form part of the associated statistics collection hardware unit. For example, to implement the minimum / maximum format selection algorithm which selects the exponent for a fixed number of bits, the statistics collection hardware unit may comprise a log base 2 module 808 which is configured to receive a value (e.g. the maximum absolute value output by the maximum module 804) and output the log base 2 value thereof, a ceiling module 810 which is configured to receive a value (e.g. the output of the log base 2 module) and output the ceiling thereof, a subtraction module 812 which is configured to receive a value and subtract an integer (e.g. n+1) therefrom. It can be seen that together the log base 2 module 808, the ceiling module 810 and the subtraction module 812 implement the minimum / maximum format selection algorithm as set forth in equation (3) above. Even when the statistics collection part of the hardware unit can receive and process multiple network parameters at the same time, the format selection part of the hardware unit (log base 2 module and the ceiling module) still only has to process one input at time since there will only be one absolute value for all of the network parameters. Enabling and Disabling Statistics Collection and Format Selection
[0109] In some cases, it may be possible to dynamically enable and disable the statistics collection and / or format selection. For example, instead of running the statistics collection and format selection at a selected granularity for each pass of the neural network indefinitely, the statistics collection and / or format selection may be dynamically enabled and disabled when certain conditions are met. In some cases, the statistics collection and / or format selection may be periodically enabled at fixed intervals (e.g., every few hundred pass in a single direction (e.g. every few hundred forward passes)). In some cases, to initialise a neural network, a single input set may be fed through the neural network multiple times (e.g. a few times to 100 times or more depending on the depth of the neural network and the configuration of the format selection relative to the stats collection (e.g. whether the statistic collection is before or after format conversion)) until the number formats converge. Once the number formats have converged the statistics collection and / or format selection may be disabled (e.g. to prevent the corresponding hardware unit from consuming power). In some cases, statistics collection and / or format selection may be initially enabled for a predetermined number of passes of the neural network, after which the statistics collection and / or format selection may be disabled such that the number formats are frozen from this point onwards. In some cases, the information indicating whether the statistics collection and / or format selection is to be enabled or disabled in a hardware pass may be included in the information that the neural network accelerator receives for each hardware pass. Format Conversion Hardware Unit
[0110] As described above, each format conversion hardware unit is configured to receive information identifying a desired number format; receive network parameters in a number format; 13 09 23 and convert the received network parameters to the desired number format. The format conversion that is performed, and how it is performed, is based on the type of number format of the received network parameters and the type of the desired number format. For example, a format conversion hardware unit may receive network parameters in a floating point number format and 5 convert the received network parameters to a fixed point number format; a format conversion hardware unit may receive network parameters in a fixed point number format and convert the received network parameters to another fixed point number format; a format conversion module may receive network parameters in a fixed point number format and convert the received network parameters to a floating point number format. The conversion from one number format to another 10 may be performed in any suitable manner.
[0111] Where the format of the received network parameters is parametrised the format conversion hardware unit may also receive information indicating or identifying the number format of the received network parameters. For example, where the received network parameters are in a block-configurable type of number format, the format conversion hardware unit may receive 15 information identifying the values of one or more of the configurable quantisation parameters (e.g., where the received network parameters are in a type of number format identified by a bit width and an exponent, a format conversion hardware module may receive information identifying the exponent).
[0112] The manner in which a format conversion is implemented depends on the input and the 2 0 desired number format. Methods of converting from one number format to another are known to those of skill in the art. For example, where the received network parameters are in a number format that is defined by a mantissa bit width and an exponent (as described above) and the format conversion hardware unit is configured to convert the received network parameters to a different exponent, the format conversion unit may be configured to implement the format conversion via an 2 5 arithmetic bit shift of the mantissas of the received network parameters by the difference between the initial exponent and the desired exponent. Network Processing Hardware Units
[0113] Each of the network processing hardware units of FIG. 3 will now be described. As described above, the example NNA 300 of FIG. 3 comprises a convolution processing unit 302, an 3 0 activation processing unit 304, an element-wise operations processing unit 306, a normalisation processing unit 308, a configurable pooling processing unit 310, an interleave processing unit 312, and twotensel rescale processing units 314, 316. It will be evident to a person of skill in the art that this is just an example set of network processing hardware units and that other NNAs may have additional network processing hardware units, fewer network processing hardware units 35 and / or different network processing hardware units.
[0114] The convolution processing unit 302 is hardware configured to accelerate the processing of convolution operations. The convolution processing unit 302 is configured to receive input data and weights and perform convolution operations between the input data and weights and output the results of the convolution operations. As shown in FIG. 9, the convolution processing unit 302 13 09 23 may comprise one or more convolution engines 902 which are configured to receive a set of weights {k^, k2 ..., k8} that represent all or a portion of a filter, and a set of input data values x2, ..., x8} that represent all or a portion of a window of the input data, and perform multiplication and addition calculations on the received weights and input data values. 5
[0115] In some examples, as shown in FIG. 10, each convolution engine 902 may comprise a plurality of multipliers 1002, each of which is configured to multiple a weight ( / q) and a corresponding input data value (%J to produce a multiplication output value. The multipliers 1002 are followed by a plurality of adders 1004 which calculate the sum of the multiplication outputs. As shown in FIG. 10 the adders 1004 may form an adder tree. In the example of FIG. 10 the 10 convolution engine 902 comprises eight multipliers 1002, but in other examples there may be more or fewer multipliers. For example, in some cases there may be 128 multipliers. Generally, if there are Z multipliers an adder tree comprises Z-1 adders. The multipliers 1002 and / or adders 1004 may be implemented by fixed-function circuitry.
[0116] Since it may take more than one hardware pass of the convolution engine(s) 902 to 15 generate a complete output value / tensel (e.g., because a convolution engine may only receive and process a portion of the weights of a filter and / or a portion of the input data values of a window in a cycle), the convolution processing unit 302 may comprise an accumulator 904 for each convolution engine 902. A hardware pass of the convolution engine(s) 902 comprises receiving a set of weights and a set of input data values and performing a multiply-accumulate operation thereon. 2 0 Each accumulator 904 receives the output of one convolution engine 902 and adds the output to a previous convolution engine output that relates to the same filter. Since a convolution engine 902 may not generate or produce outputs that relate to the same filter in consecutive cycles, the partial results of one or more filters may be stored in an accumulation buffer 906 and then the appropriate partial results may be provided to the accumulator(s) 904 each cycle by the accumulation buffer 2 5 906.
[0117] As described above, the weights (and optionally biases) used by the convolution processing unit 302 may be stored in a coefficient buffer 338.
[0118] The activation processing unit 304 is hardware configured to receive input data and apply a non-linear function (which may also be referred to as an activation function) thereto. Example, 3 0 non-linear functions which may be implemented (or approximated) by the activation processing unit 304 include, but are not limited to, a Tanh function, a sigmoid function, a Rectified Linear Unit (ReLU) function or a leaky ReLU (LReLU) function. In a ReLU function, the output element yijk is calculated by identifying a maximum value as set out in equation (5) wherein for x values less than 0, y = 0. A LReLU function outputs the input if it is greater than zero, and outputs a fraction (e.g., 35 0.01) of the input when it is negative. An example implementation of a LReLU function is set out in equation (6). yy,fc = max(0,xij;fc) (5) 13 09 23 yt,j,k = max(0.01 * x^, x^^ (6)
[0119] In some cases, the activation function that is performed by the activation processing unit 304 may be configurable. For example, in some cases, the activation processing unit 304 may receive information that identifies one activation function of a plurality of activation functions that is to be applied to the input data.
[0120] In some cases, the activation processing unit 304 may be configurable such that it can evaluate and / or approximate a large class of activation functions. For example, it may configured to store, in entries of a lookup table, data representing the activation function to be implemented. In these cases, the activation processing unit 304 may be configured to use the input data to lookup one or more entries in the lookup table and generate the output of the activation function based on the one or more entries in the lookup table and / or the input data. For example, the activation processing unit 304 may be configured to calculate the output of the activation function by interpolating between two or more entries read from the lookup table. An example implementation of an activation processing unit 304 is described in the Applicant’s GB Patent No. 2552242, which is herein incorporated by reference in its entirety.
[0121] The element-wise operations processing unit 306 is hardware configured to receive input data (e.g., an input tensor) and perform an element-wise operation on the input data (e.g., input tensor), optionally with another set of data (e.g., another tensor) received via a secondary data receiver (Rx) 344 which may be obtained or retrieved from external memory. An element-wise operation is a same operation that is performed on each element of the input data / tensor (e.g., each input data value or each tensel). Element-wise operations which may be performed on the input data include, but are not limited to, add, multiply, maximum, and minimum.
[0122] The other data set / tensor may be the same size (e.g., have the same dimensions) as the input data / tensor such that corresponding elements of the two tensors are combined using an element-wise operation. Alternatively, the other data set / tensor and the input data / tensor may have different sizes or dimensions. If, for example, the mismatching dimension of one of the tensors is of size 1, an element-wise operation may be performed between the input data / tensor and the other data set / tensor using a broadcast technique wherein the smaller tensor is broadcast (or expanded) to the size of the other tensor. For example, a tensor of size [ / V, H, W, Cin] = [1, 10, 1,10] (where N is the number of batches) can be combined elementwise with a tensor of size [ / V, H, W, Cin] = [1, 10, 10, 10] by expanding the W dimension of the first tensor.
[0123] The normalisation processing unit 308 is hardware configured to receive input data and apply a normalisation function to the received input data to produce normalised data. Example normalisation functions which may be implemented by the normalisation processing unit 308 include, but are not limited to, a Local Response Normalisation (LRN) function and a Local Contrast Normalisation (LCN) function. In some cases, the normalisation function which is applied to the input data may be configurable. For example, the normalisation processing unit 308 may 13 09 23 receive information indicating which of a plurality of normalisation functions is to be applied to the input data. This allows different normalisation functions to be applied to different input data. An example implementation of a normalisation processing unit 308 is described in the Applicant’s GB Patent No. 2552242, which is herein incorporated by reference in its entirety.
[0124] The configurable pooling processing unit 310 is hardware which can be dynamically configured to perform a pooling operation or a depth-wise convolution operation. The configurable pooling processing unit 310 is configured to receive an input tensor and configuration information identifying the operation to be performed on the input tensor, and perform the identified operation on the input tensor to generate an output tensor. The identified operation is one of a plurality of selectable operations. The plurality of selectable operations comprises at least one pooling operation and a depth-wise convolution operation. A pooling operation is an operation that reduces the size of the data by summarizing blocks or subsets of data in the same channel. Example pooling operations include a maximum operation, a minimum operation, and an average operation. In a neural network, the purpose of a pooling operation is to reduce the spatial size of the representation to reduce the number of parameters and computations in the neural network, and hence also to control overfitting. Since both pooling operations and depth-wise convolution operations involve performing a mathematical operation on windows or blocks or subsets oftensels in a channel of the input tensor, hardware that is efficient at processing windows of channels of an input tensor can be used to implement both pooling operations and depth-wise convolution operations efficiently.
[0125] In some cases, a configurable pooling processing unit 310 may comprise a plurality of pool engines. Each pool engine is configured to receive a channel of the input tensor and configuration information indicating which of a plurality of different channel outputs are to be generated, and generate the identified channel output from the received channel of the input tensor.
[0126] The interleave processing unit 312 is hardware configured to receive input data and perform a rearrangement operation to produce data that is in a particular order. The rearrangement may comprise sorting and / or transposing the received input data.
[0127] As shown in FIG. 3, the configurable pooling processing unit 310 and the interleave processing unit 312 may each have access to a shared buffer 346 which can be used by these units to write data to and retrieve data from. For example, the shared buffer 346 may be used by these units to rearrange the order of received data or the generated data. For example, the configurable pooling processing unit 310 and / or the interleave processing unit 312 may be configured to write data to the shared buffer 346 and then read the same data out in a different order. In some cases, each of the configurable pooling processing unit 310 and the interleave processing unit 312 may be allotted a portion of the shared buffer 346 which only that unit can access. In these cases, the configurable pooling processing unit 310 and the interleave processing unit 312 may only be able to read data out of the shared buffer 346 that they have written to it. 13 09 23 Method
[0128] Reference is now made to FIG. 11 which is a flow chart of an example method 1100 of performing online number format selection for network parameters of a neural network, which may be implemented by a system with an NNA, such as, but not limited to, the NNA 300 of FIG. 3, with 5 one or more network processing hardware units, one or more statistics collection hardware units and one or more format conversion hardware units.
[0129] The method 1100 begins at block 1102 where one or more statistics on a first set of network parameters for a layer of the neural network are collected, using a statistics collection hardware unit of the NNA, while the NNA is performing a pass (e.g. forward pass or backward 10 pass) of the neural network. In other words, the statistics are collected on a set of network parameters as they flow through the NNA during a pass of the neural network.
[0130] As described above, the statistics collection may be performed at any suitable granularity. For example, the first set of network parameters for a layer of the neural network may comprise (i) all of the network parameters of a particular type (e.g. all of the input data values or all of the 15 weights) for the layer; (ii) all of the network parameters of a particular type in a hardware pass of the NNA that relate to the layer of the neural network; or (iii) all of the network parameters of a particular type in a subset of the network parameters in a hardware pass of the NNA that relate to the layer of the neural network. If the set of network parameters comprises all of the network parameters of a particular type for the layer and that layer belongs to a layer group that is divided 2 0 into a plurality of hardware passes, then the statistics collection unit may be configured to collect the statistics over the plurality of hardware passes. Once the one or more statistics have been collected the method 1100 proceeds to block 1104.
[0131] At block 1104, a number format is selected based on the one or more statistics collected in block 1102. The number format may be selected from the one or more statistics in accordance 2 5 with a format selection algorithm. Example format selection algorithms were described above. The one or more statistics that are collected in block 1102 may be chosen to correspond to the format selection algorithm that is used to select the number format. For example, where the format selection algorithm uses the maximum absolute value to select a number format, then the statistics collection unit may collect or generate the maximum absolute value of the set of network 3 0 parameters. As described above, the number format selection may be performed by the NNA (e.g., by a dedicated hardware unit (e.g., fixed function circuitry) within the NNA), or a unit external to the NNA (e.g., by a dedicated hardware unit (e.g., fixed function circuitry), an external processor or a CPU that controls the operation of the NNA). Once a number format has been selected based on the one or more statistics collected in block 1102, then the method proceeds to block 1106. 35
[0132] At block 1106, a second set of network parameters are converted, using a format conversion hardware unit of the NNA, to the number format selected in block 1104. The second set of network parameters is related to the first set of network parameters (i.e., the set of network parameters from which the one or more statistics are generated). In particular, as described above, the second set of network parameters is related to the same layer of the neural network, but 13 09 23 may relate to the same pass of the neural network or a different pass of the neural network. For example, the second set of the network parameters may: (i) be the first set of network parameters such that the selected format is applied to the set of network parameters from which the one or more statistics were generated; (ii) comprise another set of network parameters from the first set of network parameters but that relate to the same layer and the same pass of the neural network (e.g. if the first set of network parameters is a subset of network parameters in a hardware pass, the second set may comprise a subsequent subset in the same hardware pass, and / or the network parameters in one or more subsequent hardware passes that relate to the same layer; if the first set of network parameters comprises the network parameters in a hardware pass, the second set of network parameters may comprise the network parameter in one or more subsequent hardware passes); (iii) comprise both the first set of network parameters and a different set of network parameters related to the same layer and the same pass of the neural network; (iv) be a set of network parameters for a subsequent pass of the neural network that correspond to the first set of network parameters; (v) comprise another set of network parameters from the first set of network parameters but that relate to the same layer for a subsequent pass of the neural network; (vi) comprises both a set of network parameters for subsequent pass of the neural network that correspond to the first set of network parameters and comprise another set of network from the first set of network parameter but that relate to the same layer for a subsequent pass of the neural network. As described above, (i), (ii) and (iii) may only be suitable if the statistics are collected for a subset of a hardware pass or for a hardware pass. Once the format conversion has been performed the method proceeds to block 1108.
[0133] At block 1108, the converted second set of network parameters are processed using one or more network processing hardware units of the neural network accelerator in accordance with the neural network to perform the pass or to perform a subsequent pass of the neural network. For example, if the second set of network parameters are the input to the element-wise operations processing unit then the element-wise operations processing unit may perform an element-wise operation on the converted second set of network parameters in accordance with the layer of the neural network. Once the converted set of network parameters have been processed the method 1100 may end or the method 1100 may proceed to block 1110.
[0134] At block 1110, a determination may be made as to whether the statistics collection, format selection, and format application should be repeated. In some cases, it may be determined that the statistics collection, format selection and format application is not to be repeated if one or more conditions are met. The one or more conditions may comprise one or more of: a predetermined number of passes of the neural network in a single direction have been performed; and the number format has converged (e.g., the number format has not changed more than a predetermined amount over a predetermined number of iterations of the method). If it is determined that the statistics collection, format selection and format application should be repeated then the method proceeds back to block 1102. If, however, it is determined that the statistics collection, format selection and format application should not be repeated then the method 1100 may end 1112. 13 09 23
[0135] As described above with respect to FIG. 5, where the statistics collection hardware unit and the associated format conversion hardware unit operate on the same network parameters, in some cases the statistics collection hardware unit may be configured or situated so as to collect statistics on the set of network parameters prior to the format conversion hardware unit converting the set of network parameters to a desired number format, and other cases the statistics collection hardware unit may be configured or situated so as to collect statistics on the set of network parameters after the format conversion unit has converted the set of network parameters to the desired number format. However, where the statistics collection hardware unit collects statistics on the set of network parameters post format conversion, the number format selected based on the collected statistic will not be applied to the set of network parameters from which the statistics have been generated. Results
[0136] Testing has shown that a classification neural network which uses network parameter formats selected in the online manner described herein (i.e., by collecting one or more statistics on a set of network parameters using a statistics collection hardware unit of an NNA while the NNA is performing a pass of the neural network, selecting a number format based on the collected one or more statistics, and converting a second set of network parameters (related to the first set of network parameters) to the select number format) has a similar classification accuracy as when the network parameter number formats are selected offline (i.e., in advance). For example, FIGS. 12 and 13 illustrate the Top-1 and Top-5 classification accuracies for a number of different classification neural networks when the network parameters are represented using (a) a 32-bit floating point number format (identified as “FP32” in FIGS. 12 and 13); (b) number formats selected offline using training data in accordance with the minimum / maximum selection algorithm (identified as “Minmax” in FIGS. 12 and 13); and (c) number formats selected online in accordance with the methods and NNAs described herein (identified as “Online Minmax” in FIGS. 12 and 13). It can be seen in FIGS. 12 and 13 that the classification accuracy for (b) and (c) are quite similar. Accordingly, using the methods and NNAs described herein to perform online number format selection allows similar performance as selecting number formats offline, with the additional benefits of (i) not having to select the formats offline or in advance; and (ii) being able to adapt to changes in the input data. As is known to those of skill in the art, the Top-N classification accuracy is a measure of how often the correct classification is in the top N classifications output by a classification neural network.
[0137] FIG. 14 shows an example computer system in which the neural network accelerators described herein may be implemented. The computer system comprises a CPU 1402, a GPU 1404, a memory 1406, a neural network accelerator (NNA) 1408 (which may be any of the neural network accelerators described herein, such as, but not limited to the NNA 300 of FIG. 3) and other devices 1414, such as a display 1416, speakers 1418 and a camera 1422. A statistics collection hardware unit 1424 and a format conversion hardware unit 1426 as described herein are implemented on the NNA 1408. The components of the computer system can communicate with each other via a communications bus 1420. 13 09 23
[0138] The neural network accelerators, statistics collection hardware units, convolution processing units and convolution engines of FIGS. 3, 8, 9 and 10 are shown as comprising a number of functional blocks. This is schematic only and is not intended to define a strict division between different logic elements of such entities. Each functional block may be provided in any 5 suitable manner. It is to be understood that intermediate values described herein as being formed by a neural network accelerator, statistics collection hardware unit, convolution processing unit or convolution engine need not be physically generated by the neural network accelerator, statistics collection hardware unit, convolution processing unit or convolution engine at any point and may merely represent logical values which conveniently describe the processing performed by the 10 neural network accelerator, statistics collection hardware unit, convolution processing unit or convolution engine between its input and output.
[0139] The neural network accelerators, statistics collection hardware units, convolution processing units and convolution engines described herein may be embodied in hardware on an integrated circuit. The neural network accelerators described herein may be configured to perform 15 any of the methods described herein. Generally, any of the functions, methods, techniques or components described above can be implemented in software, firmware, hardware (e.g., fixed logic circuitry), or any combination thereof. The terms “module,” “functionality,” “component”, “element”, “unit”, “block” and “logic” may be used herein to generally represent software, firmware, hardware, or any combination thereof. In the case of a software implementation, the module, functionality, 2 0 component, element, unit, block or logic represents program code that performs the specified tasks when executed on a processor. The algorithms and methods described herein could be performed by one or more processors executing code that causes the processor(s) to perform the algorithms / methods. Examples of a computer-readable storage medium include a random-access memory (RAM), read-only memory (ROM), an optical disc, flash memory, hard disk memory, and 2 5 other memory devices that may use magnetic, optical, and other techniques to store instructions or other data and that can be accessed by a machine.
[0140] The terms computer program code and computer readable instructions as used herein refer to any kind of executable code for processors, including code expressed in a machine language, an interpreted language ora scripting language. Executable code includes binary code, 3 0 machine code, bytecode, code defining an integrated circuit (such as a hardware description language or netlist), and code expressed in a programming language code such as C, Java or OpenCL. Executable code may be, for example, any kind of software, firmware, script, module or library which, when suitably executed, processed, interpreted, compiled, executed at a virtual machine or other software environment, cause a processor of the computer system at which the 35 executable code is supported to perform the tasks specified by the code.
[0141] A processor, computer, or computer system may be any kind of device, machine or dedicated circuit, or collection or portion thereof, with processing capability such that it can execute instructions. A processor may be or comprise any kind of general purpose or dedicated processor, such as a CPU, GPU, NNA, System-on-chip, state machine, media processor, an application 13 09 23 specific integrated circuit (ASIC), a programmable logic array, a field-programmable gate array (FPGA), or the like. A computer or computer system may comprise one or more processors.
[0142] It is also intended to encompass software which defines a configuration of hardware as described herein, such as HDL (hardware description language) software, as is used for designing 5 integrated circuits, or for configuring programmable chips, to carry out desired functions. That is, there may be provided a computer readable storage medium having encoded thereon computer readable program code in the form of an integrated circuit definition dataset that when processed (i.e., run) in an integrated circuit manufacturing system configures the system to manufacture a neural network accelerator configured to perform any of the methods described herein, or to 10 manufacture a neural network accelerator comprising any apparatus described herein. An integrated circuit definition dataset may be, for example, an integrated circuit description.
[0143] Therefore, there may be provided a method of manufacturing, at an integrated circuit manufacturing system, a neural network accelerator as described herein. Furthermore, there may be provided an integrated circuit definition dataset that, when processed in an integrated circuit 15 manufacturing system, causes the method of manufacturing a neural network accelerator to be performed.
[0144] An integrated circuit definition dataset may be in the form of computer code, for example as a netlist, code for configuring a programmable chip, as a hardware description language defining hardware suitable for manufacture in an integrated circuit at any level, including as register 2 0 transfer level (RTL) code, as high-level circuit representations such as Verilog or VHDL, and as low-level circuit representations such as OASIS (RTM) and GDSII. Higher level representations which logically define hardware suitable for manufacture in an integrated circuit (such as RTL) may be processed at a computer system configured for generating a manufacturing definition of an integrated circuit in the context of a software environment comprising definitions of circuit elements 2 5 and rules for combining those elements in order to generate the manufacturing definition of an integrated circuit so defined by the representation. As is typically the case with software executing at a computer system so as to define a machine, one or more intermediate user steps (e.g., providing commands, variables etc.) may be required in order for a computer system configured for generating a manufacturing definition of an integrated circuit to execute code defining an integrated 3 0 circuit so as to generate the manufacturing definition of that integrated circuit.
[0145] An example of processing an integrated circuit definition dataset at an integrated circuit manufacturing system so as to configure the system to manufacture a neural network accelerator will now be described with respect to FIG. 15.
[0146] FIG. 15 shows an example of an integrated circuit (IC) manufacturing system 1502 which 35 is configured to manufacture a neural network accelerator as described in any of the examples herein. In particular, the IC manufacturing system 1502 comprises a layout processing system 1504 and an integrated circuit generation system 1506. The IC manufacturing system 1502 is configured to receive an IC definition dataset (e.g., defining a neural network accelerator as described in any of the examples herein), process the IC definition dataset, and generate an IC 13 09 23 according to the IC definition dataset (e.g., which embodies a neural network accelerator as described in any of the examples herein). The processing of the IC definition dataset configures the IC manufacturing system 1502 to manufacture an integrated circuit embodying a neural network accelerator as described in any of the examples herein. 5
[0147] The layout processing system 1504 is configured to receive and process the IC definition dataset to determine a circuit layout. Methods of determining a circuit layout from an IC definition dataset are known in the art, and for example may involve synthesising RTL code to determine a gate level representation of a circuit to be generated, e.g., in terms of logical components (e.g., NAND, NOR, AND, OR, MUX and FLIP-FLOP components). A circuit layout can be determined 10 from the gate level representation of the circuit by determining positional information for the logical components. This may be done automatically or with user involvement in order to optimise the circuit layout. When the layout processing system 1504 has determined the circuit layout it may output a circuit layout definition to the IC generation system 1506. A circuit layout definition may be, for example, a circuit layout description. 15
[0148] The IC generation system 1506 generates an IC according to the circuit layout definition, as is known in the art. For example, the IC generation system 1506 may implement a semiconductor device fabrication process to generate the IC, which may involve a multiple-step sequence of photo lithographic and chemical processing steps during which electronic circuits are gradually created on a wafer made of semiconducting material. The circuit layout definition may be 2 0 in the form of a mask which can be used in a lithographic process for generating an IC according to the circuit definition. Alternatively, the circuit layout definition provided to the IC generation system 1506 may be in the form of computer-readable code which the IC generation system 1506 can use to form a suitable mask for use in generating an IC.
[0149] The different processes performed by the IC manufacturing system 1502 may be 25 implemented all in one location, e.g., by one party. Alternatively, the IC manufacturing system 1502 may be a distributed system such that some of the processes may be performed at different locations, and may be performed by different parties. For example, some of the stages of: (i) synthesising RTL code representing the IC definition dataset to form a gate level representation of a circuit to be generated, (ii) generating a circuit layout based on the gate level representation, (iii) 3 0 forming a mask in accordance with the circuit layout, and (iv) fabricating an integrated circuit using the mask, may be performed in different locations and / or by different parties.
[0150] In other examples, processing of the integrated circuit definition dataset at an integrated circuit manufacturing system may configure the system to manufacture a neural network accelerator without the IC definition dataset being processed so as to determine a circuit layout. 35 For instance, an integrated circuit definition dataset may define the configuration of a reconfigurable processor, such as an FPGA, and the processing of that dataset may configure an IC manufacturing system to generate a reconfigurable processor having that defined configuration (e.g., by loading configuration data to the FPGA). 13 09 23
[0151] In some embodiments, an integrated circuit manufacturing definition dataset, when processed in an integrated circuit manufacturing system, may cause an integrated circuit manufacturing system to generate a device as described herein. For example, the configuration of an integrated circuit manufacturing system in the manner described above with respect to FIG. 15 5 by an integrated circuit manufacturing definition dataset may cause a device as described herein to be manufactured.
[0152] In some examples, an integrated circuit definition dataset could include software which runs on hardware defined at the dataset or in combination with hardware defined at the dataset. In the example shown in FIG. 15, the IC generation system may further be configured by an 10 integrated circuit definition dataset to, on manufacturing an integrated circuit, load firmware onto that integrated circuit in accordance with program code defined at the integrated circuit definition dataset or otherwise provide program code with the integrated circuit for use with the integrated circuit.
[0153] The implementation of concepts set forth in this application in devices, apparatus, 15 modules, and / or systems (as well as in methods implemented herein) may give rise to performance improvements when compared with known implementations. The performance improvements may include one or more of increased computational performance, reduced latency, increased throughput, and / or reduced power consumption. During manufacture of such devices, apparatus, modules, and systems (e.g., in integrated circuits) performance improvements can be traded-off 2 0 against the physical implementation, thereby improving the method of manufacture. For example, a performance improvement may be traded against layout area, thereby matching the performance of a known implementation but using less silicon. This may be done, for example, by reusing functional blocks in a serialised fashion or sharing functional blocks between elements of the devices, apparatus, modules and / or systems. Conversely, concepts set forth in this application 2 5 that give rise to improvements in the physical implementation of the devices, apparatus, modules, and systems (such as reduced silicon area) may be traded for improved performance. This may be done, for example, by manufacturing multiple instances of a module within a predefined area budget.
[0154] The applicant hereby discloses in isolation each individual feature described herein and 3 0 any combination of two or more such features, to the extent that such features or combinations are capable of being carried out based on the present specification as a whole in the light of the common general knowledge of a person skilled in the art, irrespective of whether such features or combinations of features solve any problems disclosed herein. In view of the foregoing description it will be evident to a person skilled in the art that various modifications may be made within the 35 scope of the invention.
Claims
1. A method of dynamically selecting a number format for a set of network parameters of a neural network, the method comprising:5 collecting, using a statistics collection hardware unit of a neural network accelerator, one ormore statistics on a first set of network parameters for a layer of the neural network while the neural network accelerator is performing a pass of the neural network;selecting a number format based on the collected one or more statistics;ioconverting, using a format conversion hardware unit of the neural network accelerator, a second set of network parameters to the selected number format, the second set of network parameters comprising (i) the first set of network parameters and / or another set of network parameters for the layer, or (ii) a set of network parameters for a subsequent pass15 of the neural network corresponding to the first set of network parameters; andprocessing, using one or more network processing hardware units of the neural network accelerator, the converted second set of network parameters in accordance with the neural network to perform the pass of the neural network or to perform the subsequent pass of the2 0 neural network.
2. A neural network accelerator comprising:at least one network processing hardware unit configured to receive network parameters2 5 for layers of a neural network and perform one or more neural network operations on thereceived network parameters in accordance with the neural network;a statistics collection hardware unit configured to collect one or more statistics on a first set of network parameters for a layer while the neural network accelerator is performing a pass3 0 of the neural network; anda format conversion hardware unit configured to convert a second set of network parameters to a number format selected based on the collected one or more statistics, the second set of network parameters comprising (i) the first set of network parameters and / or35 another set of network parameters for the layer, or (ii) a set of network parameters for asubsequent pass of the neural network corresponding to the first set of network parameters.neural network accelerator, the external unit configured to select the number format based on the collected one or more statistics in accordance with a format selection algorithm.13 09 234. The neural network accelerator of claim 3, wherein the external unit is a central processing 5 unit that controls the operation of the neural network accelerator.
5. The neural network accelerator of claim 3, wherein the external unit is distinct from a central processing unit that controls the operation of the neural network accelerator.10 6. The neural network accelerator of claim 2, further comprising a format selection hardwareunit that is configured to select the number format based on the collected one or more statistics in accordance with a format select algorithm.
7. The neural network accelerator of any of claims 2 to 6, wherein the neural network15 accelerator is configured to perform a pass of the neural network in a plurality of hardwarepasses of the neural network accelerator, wherein for each hardware pass the neural network accelerator receives a set of input data corresponding to all ora portion of the input data to a layer of the neural network and processes that set of input data in accordance with at least the layer of the neural network for the pass of the neural network.
208. The neural network accelerator of any of claims 2 to 7, wherein the first set of network parameters comprises all network parameters of a same type for the layer, and the second set of network parameters comprises a set of network parameters for a subsequent pass of the neural network that correspond to the first set of network parameters.
259. The neural network accelerator of claim 7, wherein the first set of network parameters comprises all of the network parameters of a particular type fora layer that are in a hardware pass of the neural network accelerator for the pass of the neural network.3 0 10. The neural network accelerator of claim 9, wherein the second set of network parameterscomprises all of the network parameters of the particular type for the layer that are in another hardware pass of the neural network accelerator for the pass of the neural network.35 11. The neural network accelerator of claim 7, wherein the first set of network parameterscomprises a subset of the network parameters of a particular type for the layer that are in a hardware pass of the neural network accelerator for the pass of the neural network.
12. The neural network accelerator of claim 11, wherein the second set of network parameters 4 0 comprises another subset of the network parameters of the particular type for the layer that13 09 23are in the hardware pass of the neural network accelerator for the pass of the neural network.
13. The neural network accelerator of claim 9 or claim 11, wherein the second set of network parameters comprises the network parameters in a hardware pass of the neural network accelerator for a subsequent pass of the neural network that correspond to the first set of network parameters.
14. The neural network accelerator of any of claims 9, 10, 11 and 12, wherein the second set of network parameters comprises the first set of network parameters.
15. The neural network accelerator of any of claims 2 to 14, wherein:the format conversion hardware unit is configured to convert the first set of network parameters to a configurable number format prior to the first set of network parameters being processed by one or more of the at least one network processing hardware unit; andthe statistics collection hardware unit is configured to collect the statistics on the first set of network parameters prior to the format conversion performed by the format conversion hardware unit.
16. The neural network accelerator of any of claims 2 to 13, wherein:the format conversion hardware unit is configured to convert the first set of network parameters to a configurable number format prior to the first set of network parameters being processed by one or more of the at least one network processing hardware unit;the statistics collection hardware unit is configured to collect the statistics on the first set of network parameters after the format conversion performed by the format conversion hardware unit; andthe second set of network parameters comprises (i) another set of network parameters for the layer for the pass of the neural network, or (ii) a set of network parameters for a subsequent pass of the neural network corresponding to the first set of network parameters.
17. The neural network accelerator of any of claims 2 to 16, further comprising:another statistics collection hardware unit configured to collect one or more statistics on a third set of network parameters for another layer of the neural network while the neural network accelerator is performing the pass of the neural network; and13 09 23another format conversion hardware unit configured to convert a fourth set of network parameters to a number format selected based on the one or more statistics collected by the other statistics collection hardware unit, the fourth set of network parameters comprising (i) the third set of network parameters and / or another set of network parameters for the other layer, or (ii) a set of network parameters for a subsequent pass of the neural network corresponding to the third set of network parameters.
18. The neural network accelerator of any of claims 2 to 17, wherein the pass of the neural network and the subsequent pass of the neural network are forward passes of the neural network.
19. The neural network accelerator of any of claims 2 to 17, wherein the pass of the neural network and the subsequent pass of the network are backward passes of the neural network.
20. A computer system comprising:the neural network accelerator of any of claims 3-5 and 7 to 19, when dependent on claim 3; andthe external unit.
21. A system comprising a neural network accelerator comprising one or more network processing hardware units, a statistics collection hardware unit, and a format conversion hardware unit, the system configured to perform the method of claim 1.
22. The neural network accelerator of any of claims 2 to 19, wherein the neural network accelerator is embodied in hardware on an integrated circuit.
23. A method of manufacturing, using an integrated circuit manufacturing system, the neural network accelerator of any of claims 2 to 19 or the system of claim 21.
24. A computer readable storage medium having stored thereon a computer readable description of the neural network accelerator of any of claims 2 to 19 that, when processed in an integrated circuit manufacturing system, causes the integrated circuit manufacturing system to manufacture an integrated circuit embodying the neural network accelerator.
25. A computer readable storage medium having stored thereon computer readable code configured to cause a processor and a neural network accelerator to perform the method of claim 1 when the code is run.
Citation Information
Patent Citations
Adaptive bit-width reduction for neural networks
US20190050710A1
Adjustable Precision for Multi-Stage Compute Processes
US20200042287A1
Adaptive quantization for execution of machine learning models
US20210279635A1
