Patent Description:
One or more embodiments may relate to improved operation of neural networks such as convolutional neural networks.

A neural network (NN) is a computational architecture that attempts to identify underlying relationships in a set of data by using a process that mimics the way the human brain operates. Neural networks have the ability of adapting to changing inputs so that a network may produce a best possible result without redesigning the output criteria.

Neural networks are widely used e.g. to extract patterns and detect trends that are too complex to be noticed by either humans or other computer techniques.

Some advantages of using neural networks (NNs) include, for instance:.

More specifically, the invention relates to a method according to the preamble of claim <NUM>, which is known, for instance, from the documents by H. Nakahara et al. mentioned on page <NUM>.

Other documents of interest for the invention include the document by Miyashita et. mentioned in the following as well as <NPL>.

Despite the intensive activity in that area, a demand exists for further improved NN arrangements.

An object of one or more embodiments is to contribute in meeting such a demand.

According to one or more embodiments, that object may be achieved by means of a method having the features set forth in claim <NUM> that follows.

One or more embodiments may also relate to a corresponding apparatus and to a corresponding computer program product loadable into the memory of at least one processing device and including software code portions for executing the steps of the method when the product is run on at least one computer. As used herein, reference to such a computer program product is understood as being equivalent to reference to a computer-readable means containing instructions for controlling the processing system in order to coordinate implementation of the method according to one or more embodiments. Reference to "at least one processor device" is intended to highlight the possibility for one or more embodiments to be implemented in modular and/or distributed form.

The claims are an integral part of the technical disclosure of embodiments as provided herein.

One or more embodiments may be based on the recognition that noise tolerance of NNs can motivate simplifications in hardware complexity.

One or more embodiments may provide a procedure for approximating operations by using low-precision arithmetic in accelerating a forward propagation step of CNNs.

In one or more embodiments, an inference stage in a generic CNN may involve approximated computations performed using a data representation based on a low-precision Residue Number System (RNS) with rescaling stages introduced for weights and activations.

One or more embodiments may involve a procedure for "tuning up" system parameters which may handle a reduced resolution while minimizing rounding and overflow errors.

One or more embodiments may decrease hardware complexity of e.g. dot product operators and enable a parallelized implementation operating on values represented with few bits, with minimal loss in the overall accuracy of the network.

One or more embodiments may facilitate e.g. recent advances in deep learning that use large, deep neural networks (DNNs) with tens of millions of units suitable for a number of applications requiring real time processing. DNNs, and in particular convolutional neural networks (CNNs), may play a significant role in performing intelligent tasks in many different domains, e.g. acoustic scene classification, sensor-based activity recognition, classification of heartbeats and facial emotion recognition. A wide range of embedded systems may involve e.g. low-power CNN accelerators for applications such as Internet of Things (IoT) or smart sensors, etc..

In these arrangements, the resolution of adders and multipliers may be related to the resolution of residues, which in general is smaller than the resolution of the original values. Potentially, this may represent an advantage in terms of both power consumption and storage efficiency, with respect to standard <NUM>/<NUM>-bit Multiply and ACcumulate units or blocks (MACs) or other low-precision MAC units.

In one or more embodiments, with certain sets of moduli, some operations are further simplified, which may provide an advantage in terms of efficiency.

In one or more embodiments, for instance when considering hardware-oriented implementations, the fragmentation of e.g. a dot product operator as allowed by a RNS solution is adapted to be described as N-parallel sub operators with a (much) smaller bit width. This may lead to a quadratic complexity reduction (e.g. number of gates) for multipliers while at the same time improving the latency of the units (e.g. twice as fast for an <NUM> bit implementation vs. a <NUM> bit implementation).

In one or more embodiments, complexity reduction and timing improvements may occur (also) for adders with a linear scale with respect to the number of bits.

One or more embodiments may involve area and latency reductions which, may lead to a significant decrease in power consumption in comparison with a conventional representation, static for area and dynamic for latency.

The references used herein are provided merely for convenience and hence do not define the extent of protection or the scope of the embodiments.

One or more embodiments may contribute to accelerating forward propagation in neural networks.

Convolutional neural networks (CNNs), which can be generally ascribed to the "family" of so-called deep neural networks (DNNs), are exemplary of neural networks to which one or more embodiments may apply.

DNNs are neural networks structured in successive layers of computing units and may have different architectures.

From a formal viewpoint, a neural network architecture may be described as a "tuple" (I, U, O, E) consisting of a set I of input sites, a set U of computing units, a set O of output sites and a set E of weighted directed edges.

A directed edge is a tuple (i, o, w) where
i ∈ I ∪ U, o ∈ U ∪ O and <MAT>.

Even if - strictly speaking - they are not computing units and represent only entry points for the information into the network, the input sites are called input units.

For instance, input data to the input units may be images, but also other kinds of digital signals: acoustic signals, bio-medical signals, inertial signals from gyroscopes and accelerometers may be exemplary of these.

The output sites are called output units, and they are computing units whose results constitute the output of the network.

Finally, the computing sites in U are called hidden units.

The units are grouped in successive levels, called layers, such that there are connections only from the units of a layer to the units of the successive layer.

In one or more embodiments, the direction of propagation of the information may be unilateral e.g. of a feed-forward type, starting from the input layer and proceeding through the hidden layers up to the output layer.

Assuming that the network has L layers, one may adopt the convention of denoting the layers with k = <NUM>, <NUM>,. , L, starting from the input layer, going on through the hidden layers up to the output layer.

By considering the layer Lk , in a possible notation:
uk: denotes the number of units of the layer k, <MAT>: denotes a unit of layer k or equivalently its value,.

W(k) : denotes the matrix of the weights from the units of layer k to the units of layer (k + <NUM>); it is not defined for the output layer.

The values <MAT> are the results of the computation performed by the units, except for the input units, for which the values <MAT> are the input values of the network. These values represent the activation values, o briefly, the "activations" of the units.

The element (i, j) of matrix W(k) is the value of the weight from the unit <MAT> to the unit <MAT>.

Such weights may be learned via a back-propagation algorithm.

Moreover, for each layer k = <NUM>,. , (L - <NUM>), an additional unit <MAT>, denoted as the bias unit can be considered (e.g. with a value fixed to <NUM>) which allows shifting the activation function to the left or right.

A computing unit <MAT> may perform a computation which can be described as a combination of two functions:.

In one or more embodiments, operation (execution) of a neural network as exemplified herein may involve a computation of the activations of the computing units following the direction of the network, e.g. with propagation of information from the input layer to the output layer. This procedure is called forward propagation.

<FIG> is exemplary of a network arrangement as discussed in the foregoing, including L + <NUM> layers, including an input layer IL (layer <NUM>), hidden layers HL (e.g. layer <NUM>, layer <NUM>,. ) and an output layer OL (layer L).

CNNs correspond to the basic layout of deep neural networks discussed previously and include neurons with "learnable" weight and bias values. Each neuron may receive some inputs and perform a specific computation, which may optionally include an activation function.

A basic idea underlying CNNs may combine three architectural ideas to facilitate achieving some degree of shift and distortion invariance: local receptive fields, shared weights, and, sometimes, spatial or temporal subsampling.

A CNN may include three types of layers:.

These layers can be combined in many ways producing a (wide) variety of different structures.

For instance, a CNN architecture may include some pairs of a convolutional layers followed by a subsampling layer, and then final fully-connected layers.

An exemplary structure of a CNN is shown in <FIG> where C, P and FC denote convolution, pooling and full connection layers, respectively.

For instance, the input to a CNN may include e.g. a <NUM>-dimensional or a <NUM>-dimensional matrix, and the convolutional and subsampling layers may receive a multi-dimensional matrix as an input and provide a multi-dimensional matrix as an output. These matrices are denoted as the input or output features, and each value in these matrices is denoted as a pixel.

In a fully-connected layer all the units may be connected through weighted edges to all the units of the previous layer, since this type of layer is the same of the standard feed-forward network.

Finally, the pooling layers perform some form of nonlinear subsampling, which may reduce the sensitivity of the output to shifts and distortions. The more frequent pooling operations are the mean (average) or the maximum of the values of the portion of pixels,.

AlexNet and GoogLeNet are exemplary of well-known trained CNNs. These are (very) large and deep convolutional neural networks, developed in order to classify the images from the ImageNet LSVRC contest into <NUM> different classes.

GoogLeNet was proposed in <NUM> in <NPL>.

These networks differ from each other for certain aspects in their general architecture.

For instance, GoogLeNet includes so-called Inception subnetworks, which perform different sizes of convolutions and concatenate the filters for the next layer. In AlexNet, on the other hand, layer input is provided by one previous layer instead of a filter concatenation.

Exemplary architectures for AlexNet and GoogLeNet are illustrated in <FIG>, where the abbreviations in the various boxes therein have the following meanings:.

As schematically shown in <FIG>, AlexNet includes eight weight layers: the first five (layer <NUM> to layer <NUM>) are convolutional layers C, while the three last layers (layer <NUM> to layer <NUM>) are fully-connected layers FC. The last layer is fed to a <NUM>-units softmax layer, which produces a distribution over the <NUM> class labels.

As schematically shown in <FIG> (where the "depth" values indicate the number of layers), GoogLeNet includes twenty-two levels of weighted layers, including again convolutional and fully connected layers C and FC, with certain layers grouped in inception subnetworks I. The overall number of layers (independent building blocks) used for the construction of the network is about <NUM>: the exact number depends on how layers are counted by the machine learning infrastructure.

An inception I may be a network consisting of convolutional modules stacked upon each other with occasional max-pooling modules. The network has a depth of two levels and the module results are concatenated producing the output of the Inception network.

A possible architecture of an inception is depicted in the <FIG>, where the definitions provided in the foregoing apply to the labeling in the various blocks, and "max pool" and "concat" denote maximum pooling and concatenation, respectively.

Complexity of CNNs may be related primarily to convolutions (e.g. in convolutional layers) and matrix multiplications (e.g. in fully connected layers).

In both instances, a key operation may be represented by a dot (or "inner") product.

Let w = [w<NUM>,. , wu]T and a = [a<NUM>,. , au]T be two vectors, then the dot product thereof, z = wTa, can be computed according to the formula <MAT> where each component aj (e.g. activations) and wj (e.g. weights) can be represented using any numerical representation, e.g. floating-point, fixed-point or others.

Using conventional digital hardware, the dot product operation can be performed using Multiply-and-ACcumulate (MAC) operations.

For example, for an image 224x224, a single category labeling classification with <NUM> classes may require, by using AlexNet, close to <NUM> giga MAC operations.

Simplifying/accelerating such operations may thus play a significant role in permitting large networks to be run in real-time applications over mobile or embedded platforms (e.g. low-power wearable or IoT devices).

Addressing this problem with HW acceleration and offloading may led to improvements in terms of performance and power efficiency; however, the resulting HW may turn out to be expensive to implement (e.g. in terms of silicon area); additionally, energy budget requirements may not be met for constrained applications.

Various approaches have been proposed in order to accelerate computation in CNNs in recent years, e.g. by exploring the use of non-conventional data representation for accelerating the forward propagation step.

For instance, the document Miyashita et. <NPL> describes a non-conventional data representation based on a base-<NUM> logarithmic system. Weights and activations are represented at low precision in the log-domain thus obviating the need for digital multipliers (multiplications become additions in the log-domain) and obtaining higher accuracy than fixed-point at the same resolution. While taking advantage of recasting dot products in the log-domain, this solution still requires accumulators at full precision (e.g. <NUM> bits). Also, while log-domain representation shows a good complexity reduction potential, a fully analysis in terms of the costs associated to the HW implementation of a complete chain of processing in a convolutional stage is not documented.

In <NPL> a non-conventional data representation is presented based on a Nested Residue Number. Specifically a so-called NRNS system (a variation of the Residue Number System - RNS) is proposed in accordance with the preamble of claim <NUM>.

A <NUM>-bit fixed-point representation is used for weights and activations, and dot products of convolutional layers are computed in parallel using an NRNS at high precision in order to cover a maximum dynamic range of <NUM>. By applying NRNS, standard MAC units may be decomposed into parallel <NUM>-bit MACs.

One or more embodiments are based on the recognition that a RNS representation may exploit the CNN error propagation resiliency by adopting a low-precision Residue Number System - RNS and adequately tuned rescaling stages in order to manage the reduced resolution of data and accumulators and increasing the resulting accuracy.

One or more embodiments may be based on the recognition that the algorithmic-level noise tolerance of neural networks such as CNNs may facilitate and motivate simplifications in hardware complexity, such as e.g. resorting to a low-precision approach in certain calculations.

One or more embodiments involve approximating operations by using low-precision arithmetic for accelerating the forward propagation step of e.g. CNNs, for instance by computing dot products in the Residue Number System (RNS), thus facilitating more efficient network operation e.g. in digital hardware.

One or more embodiments involve redefining the general architecture of a neural network such as a CNN.

Such a redefinition involves, for each layer:.

Recalling some basic mathematical concepts underlying the Residue Number System or RNS may be helpful by way of introduction to the detailed description of exemplary embodiments.

A residue number system or RNS is characterized by a set of integers (mN,. ,m<NUM>), called base, where every integer mi is called modulus.

RNS is an integer number system where the number of different representations is given by the least common multiple of the moduli, and it is denoted by M.

A number <MAT> is represented in the RNS by the set of residues (xN,. , x<NUM>) where xi: = |x|mi = x mod mi for i = <NUM>,.

Conversely, the corresponding value of a RNS number is provided by the Chinese Remainder Theorem modulo M, under the assumption that the moduli are pairwise relatively prime: see e.g. <NPL>.

In order to have a univocal corresponding value for each RNS number, the RNS can be accompanied with a range of represented values, denoted by IRNS = [r,r + M - <NUM>].

In that way, a given RNS number (xN,. ,x<NUM>) is converted to x = v if x ∈ IRNS, or x = v - M otherwise, where <MAT> is obtained by applying the Chinese Remainder Theorem, where <MAT> and <MAT> stands for the multiplicative inverse of a number c modulo mj.

The selection of RNS blocks in a CNN simply consists in recognizing which network operations involve e.g. dot products or, more generally, are homogeneous with respect to activations and weights.

For a convolutional layer, the RNS block consists of convolutions, while for a fully connected layer it consists of a matrix product.

In one or more embodiments (in the exemplary case of AlexNet: see <FIG> as discussed previously), each convolutional layer C and fully-connected layer FC may thus include (e.g. begin with) a RNS block.

This situation is exemplified, in <FIG>, where the same basic layout of <FIG> is reproduced with the RNS blocks highlighted in shading.

In the case of GoogLeNet, RNS blocks may be used for convolutions practically for all blocks but one (all in the inception networks), while for the last layer, which is a fully connected layer, RNS may be used for a matrix product.

The selection of RNS blocks in such a network is highlighted in shading in <FIG> and <FIG>.

Once all RNS blocks are selected in a certain network to be implemented, dedicated FW (forward) and BW (backward) converters are concatenated before and after each RNS block, respectively.

In one more embodiments two different schemes may be adopted for that purpose.

In a first, general scheme, both weights wj activations aj may be converted on-line for a fixed moduli set.

In a second, alternative scheme either of weights or activations e.g. weights wj are converted off-line and stored in RNS representation using a Look-Up Table or LUT.

The two schemes are illustrated in <FIG> and <FIG>, respectively.

In these <FIG> denotes a RNS block (including e.g. a number N of RNS operation units <NUM><NUM>, <NUM><NUM>,. , <NUM>N) preceded by a FW converter <NUM> and followed by a BW converter <NUM>.

In <FIG>, reference <NUM> denotes a storage unit (e.g. a LUT) for storing parameters (e.g. weights wj) converted off-line.

In one or more embodiments, irrespective of the scheme adopted (on-line or off-line) processing as discussed involves conversion proper into RNS (e.g. at <NUM>) and from RNS (e.g. at <NUM>): this permits operation (e.g. computation) of the RNS block <NUM> to take place in RNS representation.

In one or more embodiments, scaling plus rounding of the input parameters (e.g. at <NUM>) and complementary scaling of the results (e.g. at <NUM>) facilitates maintaining more information from the original values of data.

For instance, in the general scheme of <FIG>, in blocks <NUM> in the forward converter <NUM>, activations from the previous layer and weights are multiplied by respective scale factors <MAT> and <MAT>, then rounded to integer and converted to RNS representation in blocks <NUM>.

Similarly, in the alternative scheme of <FIG>, weights multiplied by the corresponding scale factor, rounded and converted offline may be stored in RNS representation in the memory <NUM>, while in a block <NUM> in the forward converter <NUM>, activations from the previous layer may be multiplied by a scale factor <MAT>, then rounded to integer and converted to RNS representation in a block <NUM>.

In one or more embodiments, the backward converter <NUM> may first perform the conversion of the output of the RNS block <NUM> back to integer in a block <NUM> and then divide the result by ( <MAT>) in block <NUM> in case scaling and rounding has been applied at <NUM>.

In one or more embodiments, the scale factors <MAT> and <MAT> may define both the quantity of information from the original weights and activations which is maintained after the rounding and the magnitude of the range of the RNS values inside each RNS block.

In one or more embodiments, scale factors may be selected in order to limit the rounding errors and determine a range of values that reduces the risk of overflow. This may be relevant e.g. for weights wj having values in the interval (-<NUM>, <NUM>), which may be highly concentrated around <NUM>.

In one or more embodiments, large scale factors may be considered in order to retain much information after rounding. On the other hand, large scale factors may increase the range of the output values, which may result in an increased risk of overflow. One or more embodiments may not contemplate overflow detection, with errors possibly deriving from rounding of weights and activations and/or from overflow.

In one or more embodiments network accuracy may be increased by resorting to procedure for "customizing" scale factors for each layer.

As schematically represented in the flow chart of <FIG>, a first step <NUM> in such a procedure may involve setting a sufficiently large resolution M for weights and activations (for example <NUM> bits), so that one may consider the same RNS base for each "residual" block, while the ranges are different.

In a step <NUM>, an output distributions of the residual blocks performing the forward propagation on the original CNN over a random subsample of the inputs may be estimated. To that effect, values at the output of the residual block k may be collected in v(k).

By denoting by I(k) the input range of values, processing as discussed above may result in an estimated output distribution of the block k which may be expressed as: <MAT>.

In a step <NUM>, in order to customize the scale factors, values for the following tables may collected as exemplified below:.

In a step <NUM>, for each layer, the rightmost entry in Table <NUM> that is greater than the corresponding product ( <MAT>) is selected.

Assuming that the ratio between the scale factors is given by the ratio of the minimum values, i.e. <MAT>, the scale factors may be computed under the condition that their product is equal to the selected entry of Table <NUM>.

Such procedure is further exemplified in the two portions a) and b) of <FIG>, where OD and ID denote the original distribution and the scaled distribution, respectively.

<FIG> is exemplary of the selection of an entry of Table <NUM>.

Portion a) portrays an exemplary possible histogram of an "original" distribution OD in v(k), with the range I(k) highlighted.

The distribution in v(k) may be used in order to select a value for ( <MAT>) which satisfies a specific condition.

By way of example one may assume f = <NUM>, meaning that the output distribution scaled with a proper factor has a range whose width is equal to <NUM> times the width of the RNS range, i.e. M. With this additional constrain, a value for the product ( <MAT>) can be computed.

Portion b) shows an exemplary histogram of a scaled distribution SD for which e.g. f = <NUM>, and in this case corresponds to <MAT>, with the range <MAT> shown.

It was observed that a procedure as discussed above involves a multiplication for each activation (and for each weight, in the general scheme).

Also, in the process for the search of <MAT> and <MAT>, a further constrain can be added by considering numbers in the form <NUM>s as scale factors, so that multiplications and divisions (in binary form) involve a simple shift.

From the viewpoint of hardware implementation, this may be advantageous. Even if applied (only) to the weights, such an approach may permit to choose the general scheme (where the weights are converted "each time" and not stored e.g. in a LUT) in embodiments where amount of available memory may represent a point to consider.

In one or more embodiments, one may thus consider each layer k and select an adequate power of <NUM> for the scale factors <MAT> and <MAT>.

An exemplary procedure for properly setting the scale factors for the residual block k to power of <NUM> is described below.

One may select a lower bound (e.g. minimum) for the powers of <NUM> which are greater than <MAT> and <MAT>. Such values may be denoted as <MAT> and <MAT>, respectively.

If the product ( <MAT>) is lower than one or more entries in the corresponding row in Table <NUM>, one may set the scale factors to these powers, i.e. <MAT>.

The exemplary procedure for the selection of scale factors just described assumes that the resolution is sufficiently large. This means that, in general, the minimum distribution obtained by multiplying the values of v(k) by ( <MAT>) has a range which is sufficiently lower than M. This facilitates selecting values that do not affect the network accuracy by rounding and overflow errors.

In that respect, various options may be considered.

For instance, resolution may be increased or some testing may be performed on a "grid" of candidate scale factors in order to select a value leading to a judicious trade-off between the two error sources.

For instance, in one or more embodiments, if for a layer k every entry in the corresponding row of Table <NUM> is lower than the product ( <MAT>), a grid of increasing values from the lowest value for both <MAT> and <MAT> may be set.

Then, a test may be performed over a random subset of inputs with the aim of selecting the values that provide an increased accuracy (e.g. by maximizing it).

In that case, if the selected values for the scale factors produce a range Ĩ(k) whose width is greater than M, the RNS range can be selected in a different manner with respect to other cases, as discussed in the following.

For instance, in one or more embodiments, a RNS range may be selected in order to increase (e.g. maximize) the percentage of values of ṽ(k) that belongs to it.

For instance, after setting the scale factors for each residual block k, a RNS range, denoted by <MAT> may be selected, with the parameters r(k) customized in order to include the estimated output range Ĩ(k) while at the same time reducing the probability of overflows.

<FIG> is a flow chart for an exemplary procedure for each residual block k.

In a step <NUM> an estimated output distribution, denoted by ṽ(k), is computed where each component is obtained by the corresponding one in v(k) multiplied by ( <MAT>).

In a step <NUM> the mean (average) of the values in ṽ(k), denoted by mean(k) is computed.

In a step <NUM> distance of the lowest (minimum) value of Ĩ(k) from the mean is computed , i.e. <MAT>.

In a step <NUM> a cardinality factor card(k) = M - |Ĩ(k)| may be defined and the left-hand end of the RNS range calculated as <MAT>.

Such a procedure is exemplified in <FIG>.

In one or more embodiments the estimated output distribution in ṽ(k) may be exploited in order to select the RNS range.

This range may cover the estimated output range Ĩ(k), with margins A and B both to the left and the right of this interval. The available number of values for these margins, card(k) may be distributed to the margins accordingly to the distance of the left and right extreme of Ĩ(k) to the mean (average).

<FIG> is exemplary of selection of an RNS range for an estimated output distribution v(k) with f = <NUM>:<NUM>. The range of values is given by the interval [-<NUM>; <NUM>] and the mean is <NUM>. One may assume M=<NUM>, thus card(k) = <NUM>. By using the procedure exemplified herein, r(k) = -<NUM>.

In one or more embodiments as exemplified herein, in order to be able to process data in the RNS domain in the RNS operation units (e.g. <NUM> in <FIG> and <FIG>), rounded activations aj and, possibly, weights wj are converted to RNS representation (e.g. at <NUM> in <FIG> and <FIG>).

Similarly, the results of such processing in such RNS operation units (e.g. <NUM> in <FIG> and <FIG>) are converted back into the conventional representation (e.g. at <NUM> in <FIG> and <FIG>).

From a mathematical viewpoint, the conversion from integer to RNS may be performed e.g. applying modular reductions, while the Chinese Remainder Theorem may be exploited in reverse (backward) conversion form RNS.

Several approaches and hardware designs for efficient conversion are proposed e.g. in<NPL> and Chapter <NUM> pp. <NUM>-<NUM>).

In one or more embodiments, operations within RNS blocks (e.g. <NUM> in <FIG> and <FIG>) are defined in the Residue Number System.

Various arithmetic operations such as e.g. additions, subtractions and multiplications may take a simplified form in the RNS, with the results of these operations adapted to be computed by considering separately for each modulus the corresponding residues of the operands.

In one or more embodiments, the operation performed in the "residual" (that is RNS) domain may include a dot product followed by addition of bias.

This kind of operation may involve the following.

Let w = [w<NUM>,. , wu]T and a = [a<NUM>,. , au]T be two vectors with integral components.

In one or more embodiments, the RNS representation of z = wTa may be computed as: <MAT>.

Also, in one or more embodiments, computation in a RNS block (e.g. <NUM> in <FIG> and <FIG>) may include the addition of bias values.

In that case, bias values for the layer k may be multiplied by the product ( <MAT>) and then rounded, and the (main) operation performed by a RNS block according to formula (<NUM>) above may be slightly modified.

Let b an integer, the RNS representation of z = wTa + b can be computed as: <MAT>.

As a consequence, one or more embodiments may involve a parallelized implementation for performing computations separately for each modulus.

It may be otherwise observed that computational cost of formulas such as (<NUM>) and (<NUM>) above derives primarily form the cost for the largest modulus, which in general is much lower than M and thus of the original values.

Algorithms and hardware designs for efficient implementation of arithmetic in the RNS domain are the subject matter of extensive literature: see e.g. example P. Mohan (already cited).

For instance, in one or more embodiments a RNS unit for power-of-<NUM> moduli may include a standard adder (e.g. carry save) or multiplier (e.g. Wallace tree/booth) with a bit width equal to the corresponding base.

The complexity of the resulting circuit may thus be proportional (with a law linear for adders and quadratic for multipliers) to the number of bits, and the resulting HW implementation will be much less complex and faster for RNS units in comparison with conventional units.

It was otherwise observed that for moduli in the form <NUM>s - <NUM> the implementation is more complex, requiring wider multipliers and end-carry adders for the modulo arithmetic.

The following Table reports a set of experimental results for area, power and timing for standard MAC units with <NUM>-bits of precision and three different RNS representations with basis <NUM> and <NUM>. These results were obtained with a Synopsys dc compiler with front-end synthesis in FD-SOI28 nm at <NUM>. 1V and 125C (DesignWare was used for the multipliers and adder blocks) with a pure combinatorial design. Each column is split into <NUM> subcolumns that contain the actual values and the increase factors respectively.

While these results do not account for integer-to-RNS and back conversion, those costs may be "averaged down" by creating parallel HW units to process multiple MACs from kernel convolutions and accumulating them before converting back the results.

It was observed that the choice of the set of moduli may play a significant role. In fact, the moduli are responsible of the range width. Moreover, a judicious choice of the base may lead to advantages in terms of computation or storage efficiency and simplification of some operations.

In general, in one or more embodiments, possible aims directing the choice of the moduli may include:.

A possible way of increasing the range may include using moduli that are (pairwise) mutually prime. This result may be facilitated e.g. by strategies for choosing the moduli including, e.g.:.

The former strategy facilitates reducing the execution time of additions and multiplications, which given primarily by the execution time of additions and multiplications of residues corresponding to the largest modulus. On the other side, this strategy may increase the time for conversion from residue number system to the associated mixed-radix system (see e.g. <NPL>) and does not maximize the storage efficiency.

The latter strategy facilitates efficient storage and simplifies the execution of some arithmetic operations such as additions and subtractions. In fact the smallest number of bits needed to represent the residue digits for the modulus mi is <MAT>.

Thus, representation storage efficiency may be increased by select a modulus mi that is equal to <NUM>s for some s or very close to it, such as (<NUM>s - <NUM>). This strategy may be also useful for operation simplifications. For example, for moduli of the form <NUM>s, addition may be performed with an ordinary binary adder, and the additive inverse of a number is simply the complement-to-<NUM> thereof. For a modulus (<NUM>s - <NUM>), modular reduction may be further simplified, and addition may become an adder with end-around carry, with the additive inverse of a number being the complement-to-<NUM> thereof. In that way, no modular reductions may be involved for additions and subtractions.

Performance of embodiments was evaluated e.g. in the contest of a CNN such as AlexNet (discussed previously).

For experimental purposes a MATLAB replica of forward propagation of AlexNet was adopted using the version of the network provided by the Caffe Model Zoo (http://caffe. berkeleyvision. org/model zoo. html) for which trained weights are available.

An analysis of the distributions of values which would be treated in RNS representation was performed in particular with reference to the distribution of inputs and outputs to RNS blocks - performing the forward propagation on the original network with <NUM> random validation images -along with the distribution of weights. Based on the values obtained, the resolution of the network is set to n = <NUM> bits, by setting the RNS base to (<NUM><NUM>; <NUM><NUM> - <NUM>; <NUM><NUM> - <NUM>), which provides M = <NUM>.

Also, it was verified that setting <MAT> for k = <NUM>,. , L := <NUM> does not appreciably affect network accuracy.

Further testing involved the procedure for tuning of the remaining parameters, starting from the scale factors for the weights, <MAT> for k = <NUM>,. , <NUM> - for which the network is particularly sensitive -, and then selecting consequently the RNS range for each block. The final values are reported in the table below which for the first and second convolutional layers conveys the outcome of tests made for selecting a best value for the scale factor.

The impact of one or more embodiments on the performance of AlexNet over the entire validation set are reported in the further table below, which refer to the exemplary procedure discussed herein was experimented with the additional condition of considering the scale factors as powers of <NUM>. This choice further facilitates simplifying the division by the scale factors at the end of the residual blocks in view of an optimized hardware implementation. The same resolution and RNS base were maintained and with tuning of the scale factors <MAT> for k = <NUM>;. ; <NUM> partly modified.

The following table summarizes by way of direct comparison results obtainable with one or more embodiments, including the variation discussed above.

The block diagram of <FIG> is exemplary of apparatus which may include a neural network <NUM> according to one or more embodiments.

Such apparatus may include an input element or device IS, e.g. a sensor such as a microphone, a (video)camera, a biomedical sensor, and the like, providing input signals to be processed by a neural network <NUM> according to one or more embodiments. The neural network <NUM> may be configured as discussed previously to perform on the input signals from the device IS processing tasks such as e.g. acoustic scene classification, sensor-based activity recognition, classification of heartbeats and facial emotion recognition (these are just example of course) and provide corresponding results to an output device OD such as e.g. a display unit, a warning system, a "networked" device e.g. in an Internet-of-Things (IoT) scenario.

By way of comparison, certain conventional solutions may adopt a <NUM>-bit representation for weights and activations (this may represent a maximum value for a conventional implementation), with corresponding <NUM>-bit accumulators (for 11x11 convolutional filters). This may correspond to a RNS representation using a number of bits in excess of <NUM>. Absent steps allowing a reduction in accumulator resolution, a loss in network accuracy would be unavoidable.

By way of contrast, one or more embodiments may admit a reduced representation for accumulators.

For instance, tests as discussed in the foregoing may start from a <NUM>-bit representation for weights which, without loss of information as in conventional approaches, would require <NUM>-bit accumulators. One or more embodiments may adopt <NUM>-bit RNS accumulators by minimally affecting network accuracy. In one or more embodiments this may be made possible by using scale factors as discussed previously.

One or more embodiments may thus relate to a computer-implemented method of operating a convolutional neural network in accordance with claim <NUM>.

In one or more embodiments, the set of selected operating units may include operating units performing operations selected out of multiplication, including dot product and matrix multiplication, additions and subtractions.

In one or more embodiments, the set of selected operating units may include operating units performing operations (for instance dot products) homogeneous with respect to a first set and a second set of input data (e.g. activations a(k-<NUM>) and weights w(k)) and the method may include:.

In one or more embodiments, the RNS-converted input data includes data scaled (e.g. at <NUM>) by respective scale factors, wherein backward converting (e.g. <NUM>) from the Residue Number System includes complementary re-scaling (e.g. <NUM>) of the RNS output data resulting from the RNS operations by respective complementary scale factors.

In one or more embodiments, the RNS-converted input data may include integer-to-RNS converted data (e.g. <NUM>), wherein backward converting from the Residue Number System may includes RNS-to-integer conversion (e.g. <NUM>) of the RNS output data resulting from the RNS operations.

One or more embodiments may include one or more of:.

One or more embodiments may include performing (<NUM>) arithmetic operations in a Residue Number System RNS with power-of-two moduli.

One or more embodiments may concern a neural network including a plurality of layers (e.g. IL, HL, OL) including operating units performing arithmetic operations on input data to provide output data, the network including units configured (see e.g. <NUM>, <NUM>, <NUM> in <FIG> and <FIG>) for operating in a Residue Number System (briefly, RNS) by performing RNS operations on RNS-converted input data with the method of one or more embodiments.

One or more embodiments may concern apparatus in accordance with claim <NUM>.

One or more embodiments may concern a computer program product loadable into the memory of at least one processing device and including software code portions for executing the steps of the method of one or more embodiments when the product is run on at least one processing device.

Without prejudice to the underlying principles, the details and embodiments may vary, even significantly, with respect to what has been described in the foregoing by way of example only, without departing from the extent of protection.

Claim 1:
A computer-implemented method of operating a convolutional neural network, the convolutional neural network including a plurality of network layers (IL, HL, OL) including operating units performing arithmetic operations on input data (a(k-<NUM>), w(k)) to provide output data (a(k)), wherein the method includes:
- selecting a set of operating units (conv, fc, inception) in the network layers (IL, HL, OL), and
- performing arithmetic operations in operating units (<NUM>) in said selected set of operating units by performing operations in a Residue Number System, RNS, on RNS-converted (<NUM>; <NUM>) input data (a(k-<NUM>), w(k)) by obtaining RNS output data (a(k)) in the Residue Number System,
- backward converting (<NUM>) from the Residue Number System the RNS output data (a(k)) resulting from the RNS operations,
characterized in that:
- the RNS-converted input data (a(k-<NUM>), w(k)) include data scaled (<NUM>) by respective scale factors,
- backward converting (<NUM>) from the Residue Number System includes complementary re-scaling (<NUM>) of the RNS output data (a(k)) resulting from the RNS operations by respective complementary scale factors,
- the Residue Number System, RNS, is accompanied with a range of represented values and scale factors determine said range of values.