Traitement en cours

Veuillez attendre...

Paramétrages

Paramétrages

Aller à Demande

1. WO2020160787 - PROCÉDÉ DE QUANTIFICATION DE RÉSEAU NEURONAL FAISANT INTERVENIR DE MULTIPLES NOYAUX QUANTIFIÉS AFFINÉS POUR UN DÉPLOIEMENT DE MATÉRIEL CONTRAINT

Note: Texte fondé sur des processus automatiques de reconnaissance optique de caractères. Seule la version PDF a une valeur juridique

[ EN ]

NEURAL NETWORK QUANTIZATION METHOD USING MULTIPLE REFINED QUANTIZED KERNELS FOR CONSTRAINED HARDWARE DEPLOYMENT

BACKGROUND

The present invention, in some embodiments thereof, relates to neural network quantization, but not exclusively, to a system for neural network quantization for constrained hardware.

Transforming pre-trained neural networks to computationally efficient and low power models is an important task in optimization of firmware resources, which has recently become ubiquitous, and requires transforming, with minimal loss of accuracy and data, an initial full precision model into a lower precision model that can be efficiently handled with dedicated firmware. An example where optimization of firmware resources are needed is a face detection/recognition scenario, where large amounts of data needs to be analyzed in real time with minimal power cost and on small devices (such as surveillance cameras).

Quantization is a method for transforming a neural network into a lower precision model, by reducing the precision of neural network parameters. For example, quantization may apply to neural network weights, activation functions, and/or neural network gradients. Quantization methods transforming a neural network parameters and activations from a 32-bit floating point (FP32) model to an 8-bit (INT8) model are well known to speed computations and reduce hardware energy consumption.

SUMMARY

It is an object of some embodiments of the present invention to provide a system and a method for neural network quantization.

The foregoing and other objects are achieved by the features of the independent claims. Further implementation forms are apparent from the dependent claims, the description and the figures.

According to a first aspect of the invention, a method of configuring a neural network, trained from a plurality of data samples, comprising: quantizing each layer of the neural network to produce a quantized neural network with a plurality of respective scaling factors; locating one or more layers of the quantized neural network; computing a modified quantization for the one or more located layers to produce a modified quantized neural network; and adjusting the plurality of scaling factors of the modified quantized neural network by computing a similarity between a plurality of neural network outputs and a plurality of modified quantized neural network outputs. Employing a three step configuration for which neural network layers which exhibit high error are reconfigured, and scaling factors readjusted, enables accurate quantization within constrained hardware, in particular FP32 to INT4 quantization.

According to a second aspect of the invention, a system for configuring a neural network, trained from a plurality of data samples, comprising: processing circuitry, configured to: quantizing each layer of the neural network to produce a quantized neural network with a plurality of respective scaling factors; locating one or more layers of the quantized neural network; computing a modified quantization for the one or more located layers to produce a modified quantized neural network; and adjusting the plurality of scaling factors of the modified quantized neural network by computing a similarity between a plurality of neural network outputs and a plurality of modified quantized neural network outputs. The system may be part of a system, such as a factory manufacturing system, in which neural networks are configured for installment as firmware within constrained hardware.

With reference to the first aspect, wherein a non-transitory computer-readable storage medium comprising a program code which, when executed by a computer, causes the computer to execute the method. The method may be coded as software, and stored within a computer memory.

With reference to the first aspect, wherein the neural network is a convolutional neural network. Convolutional neural networks are commonly used in a wide range of applications, such as computer vision, and image recognition methods, and usually are highly structured in within layers, which makes them particularly suited to the method described herein.

With reference to the first aspect, wherein the configuration is performed on a plurality of weights of the neural network, by: quantizing each layer of the neural network by quantizing each kernel of the plurality of kernels of each layer of the neural network to produce a quantized neural network with a plurality of respective scaling factors. Quantizing each kernel rather than each layer or weight maintains approximation accuracy with a relatively low computational complexity.

With reference to the first aspect, wherein applying the quantization of the plurality of kernels is performed uniformly for groups of kernels of the plurality of kernels. Applying the quantization to groups of kernels may reduce computational complexity further, while maintain acceptable approximation accuracy.

With reference to the first aspect, wherein locating one or more layers of the quantized neural network further comprises: comparing a reconstruction error computed between the quantized neural network and the neural network to a predefined error threshold. Locating and modifying quantization of neural network layers that have a high minimum squared error may improve performance of the quantization of the neural network.

With reference to the first aspect, wherein computing a modified quantization for the one or more located layers further comprises: alternating between each located layer of the one or more located layers, until a predefined convergence criteria is met: computing one or more additional quantization(s) for a respective located layer by using an additional quantization for the respective located layer, to produce an intermediately modified quantized neural network; computing a modified scaling factor for the respective located layer, by minimizing a distance metric between the quantized neural network and the intermediately modified quantized neural network; and assigning the modified quantization(s) and the modified scaling factor to the respective located layer of the intermediately modified quantized neural network. A nested optimization approach for modifying located layers may reduce computational costs in comparison to layer by layer optimization. This approach further enables multiple quantization for located layers, where dual quantization precision is a special case.

With reference to the first aspect, wherein adjusting the plurality of scaling factors of the modified quantized neural network further comprises: for each layer of the modified quantized neural network: computing a scaling factor by minimizing a distance metric between outputs of the neural network and the modified quantized neural network, using a plurality of calibration data sets; and assigning the scaling factor to the respective layer. Using calibration data sets for scaling factor adjustment may help overcome rigidity commonly displayed in quantized neural networks, for example in classifying and pattern recognition tasks.

With reference to the first aspect, wherein data labels of the plurality of calibration data sets are used in adjusting the plurality of scaling factors. Using data labels may facilitate scaling factor adjustment.

With reference to the first aspect, wherein the configuration is performed on a plurality of activations of the neural network by: computing a scaling factor for each layer of the neural network by minimizing a reconstruction error estimated between activations of the neural network on a respective layer and approximations of activations of the respective layer, wherein the activations are calculated on a plurality of calibration datasets assigning each layer of the neural network a respective computed scaling factor to produce a modified neural network; locating one or more layers of the modified neural network according to a predefined weight error threshold computed on each layer of the modified neural network; assigning a second scaling factor for each located layer by minimizing a reconstruction error estimated between activations of the modified neural network on a respective located layer and approximations of activations of the respective located layer, wherein the activations are calculated on a plurality of calibration datasets. Activation configuration may be useful as an implementation with weights configuration for constrained hardware, for example hardware capable of only INT4 representations.

With reference to the first aspect, wherein computing a modified quantization for a located layer is performed by using one additional quantization for the respective located layer, and the first and second scaling factors are computed by minimizing a reconstruction error consisting of a quadratic term. In these cases it is possible to configure a layer with higher approximation accuracy.

With reference to the first aspect, further comprising: configuring the neural network by configuring the plurality of weights of the neural network, and/or configuring the plurality of activations of the neural network; and processing data inputs by using the configured neural network. The method supports configuration of neural network weights and/or neural network activations, both which may be employed as tailored solutions for specific client requirements.

Other systems, methods, features, and advantages of the present disclosure will be or become apparent to one with skill in the art upon examination of the following drawings and detailed description. It is intended that all such additional systems, methods, features, and advantages be included within this description, be within the scope of the present disclosure, and be protected by the accompanying claims.

Unless otherwise defined, all technical and/or scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the invention pertains. Although methods and materials similar or equivalent to those described herein can be used in the practice or testing of embodiments of the invention, exemplary methods and/or materials are described below. In case of conflict, the patent specification, including definitions, will control. In addition, the materials, methods, and examples are illustrative only and are not intended to be necessarily limiting.

BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS

Some embodiments of the invention are herein described, by way of example only, with reference to the accompanying drawings. With specific reference now to the drawings in detail, it is stressed that the particulars shown are by way of example and for purposes of illustrative discussion of embodiments of the invention. In this regard, the description taken with the drawings makes apparent to those skilled in the art how embodiments of the invention may be practiced.

In the drawings:

FIG. 1 is an exemplary layout of the various components of a neural network quantization system, according to some embodiments of the present invention;

FIG. 2 is an exemplary dataflow of a process for configuring a neural network, according to some embodiments of the present invention;

FIG. 3 is an exemplary dataflow of a process of kernel wise quantization of a neural network, according to some embodiments of the present invention;

FIG. 4 is an exemplary dataflow of an iterative process of modifying quantization of neural network layers with a high reconstruction error, according to some embodiments of the present invention; and

FIG. 5 is an exemplary dataflow of an iterative process of adjusting scaling factors of a neural network, according to some embodiments of the present invention.

FIG. 6 is an exemplary dataflow of a process of configuring a neural network by neural network activations, according to some embodiments of the present invention;

FIG. 7 is a depiction of results of simulations of NN weight configuration, by using the first two configuration stages, according to some embodiments of the present invention.

FIG. 8 is a depiction of results of simulations of NN weight configuration, by using all three configuration stages, according to some embodiments of the present invention.

DETAILED DESCRIPTION

The present invention, in some embodiments thereof, relates to neural network quantization, but not exclusively, to a system for neural network quantization for constrained hardware deployment.

According to some embodiments of the present invention, there are provided systems and methods which quantize neural networks for a purpose of improving computational efficiency and reducing resource consumption. For example, a neural network quantization system may transform FP32 representations of neural network weights and/or activations to INT4 representations, while preserving some accuracy of the neural network functionality (functionality such as classification and/or identification of data).

Quantization of neural network parameters, such as weights and activations, may reduce memory loading, computation latency, and power consumption herein‘activations’ means both inputs and outputs of neural network layers, also known as‘feature maps’. Quantization of neural networks is especially relevant when processing datasets in real time using limited hardware, for example in scenarios where deep neural networks are used for image recognition, such as in security cameras placed at sensitive locations.

CURRENT STATE OF THE ART FOR NEURAL NETWORK QUANTIZATION.

Current solutions to neural network (NN) quantization focus on approximation of NN parameters such as weights and/or NN activations by reducing their precision, either by approximating pre-trained NN parameters and activations, or training NN’s directly with low precision parameters.

Commonly used NN quantization solutions by approximation of pre-trained NN parameters, include those provided by Google and NVIDIA, which are described respectively in the following references:“Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference” by B. Jacob, S. Kligys, B. Chen, M. Zhu, M. Tang, A. Howard, H. Adam, and D. Kalenichenko. Published at arXiv: 1712.05877 on December 15, 2017, and“8-bit Inference with TensorRT” by S. Migacz, presented at GPU technology conference on May 8, 2017.

The solution provided by Google is not feasible if prior statistics on NN activations are not given, and is more applicable for quantization during training of NN models. The solution provided by NVIDIA requires statistics of NN activations for more efficient quantization of feature maps.

The main disadvantage of both frameworks is inaccuracy for lower precision approximations, especially in quantizing to INT4 precision.

THE NN CONFIGURATION SOLUTION PROVIDED HEREIN.

The method described herein provides a NN configuration solution, applicable to both NN weights and activations, which reduce both memory footprint and hardware power consumption. The system may provide a relatively high accuracy for INT4 NN quantization as demonstrated in experimental results (FIG. 7, FIG. 8), which may improve implementation functionality within constrained hardware.

The method is particular useful in structured NN’s, such as convolutional NN’s (CNN’s), for which connectivity between neurons are organized in layers, wherein in each layer groups of neurons, commonly referred to as kernels, share a common connectivity to a previous layer. Each layer of a CNN is represented by a weight tensor, which may be high dimensional, for example, a CNN layer in a computer vision application may contain three channels, each representing a red, green, and blue color respectively. CNN’s are commonly used in object recognition methods, and are often used within constrained hardware. For brevity, ‘CNN’ may be referred to herein as ‘NN’, and is used herein interchangeably.

The method consists of a three stage process, where each stage varies whether configuration of a NN is performed on NN weights or NN activations. For both variations, it is assumed the NN is pre-trained.

The stages are described generically as follows:

First, a quantization of each layer of the NN is performed to produce a quantized neural network. The quantization is performed on the NN weights and/or activations by a computation which approximates the respective NN parameter, for example, by computing a minimal square error (MSE), and assigning a result to a lower precision representation of the respective NN parameter.

Next, a location process is executed in order to locate one or more layers of the NN which display a high reconstruction error following the quantization, for example, layers with a high MSE. For each located layer a modified quantization is computed, by assigning a multiple quantization representation, producing a modified quantized NN. Assigning a dual quantization representation, for example, a dual INT4 representation, means that constrained hardware may be supported, as some low power devices prohibit mixed precision inference (such as using both INT4 and INT8 representations).

Finally, an adjustment of the scaling factors of the modified quantized NN is computed by using calibration datasets to minimize a distance between NN outputs and modified quantized neural network outputs.

As stated, for NN weight configuration, some stages vary from the generic description. The first stage is performed on each kernel, or optionally, on each group of kernels, of each layer of the NN separately. The reason is because a high output variance is observed in cumulative sub-kernels, which produces a low performance when kernels are quantized together, for example from FP32 to INT4.

Note, that quantizing kernel wise preserves linearity of a Hilbert space defined by a dot product operating on the NN weights tensor representation. In addition, the number of scaling factors increases linearly with the number of kernels, however in most NN’s the number of kernels is low compared to an amount of NN parameters, and therefore computational overhead increases linearly.

The second stage for NN weight configuration is performed by a nested optimization performed on the located NN layers, which iteratively minimizes a distance metric between the NN weight tensor and an intermediately modified quantized neural network. The intermediately modified quantized neural network is updated each iteration by updating a respective computed scaling factor for each located layer.

For NN activations configuration, the configuration process searches for optimal scaling factors for approximation of full precision activations. The first stage quantization is computed for each layer, by minimizing a reconstruction error (MSE) between estimated between activations of the neural network on a respective layer and approximations of activations of the respective layer. Since using NN activations require NN inputs, the minimizing uses calibration datasets for the computations. The second stage for NN activations configuration, is performed by locating layers according to NN weights, as described for NN configuration by NN weights. The third stage for NN activations configuration is performed by computing an optimal scaling factor for each located layer using the calibration datasets, and assigning for each located layer a second scaling factor.

In addition, a more accurate configuration process is described for weights configuration when the NN located layers are approximated using one additional

quantization, and quantization is performed within a predefined precision range (such as INT4, which defines sixteen possible values). In this case the quantization may be computed by minimization of a quadratic term, which increases computational complexity but improves accuracy, in relation to the general case.

Before explaining at least one embodiment of the invention in detail, it is to be understood that the invention is not necessarily limited in its application to the details of construction and the arrangement of the components and/or methods set forth in the following description and/or illustrated in the drawings and/or the Examples. The invention is capable of other embodiments or of being practiced or carried out in various ways.

The present invention may be a system, a method, and/or a computer program product. The computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present invention.

The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing.

Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network.

The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.

Aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer readable program instructions.

The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts or carry out combinations of special purpose hardware and computer instructions.

Each of the described systems includes and each of the described methods is implemented using a processing circuitry configured to execute a code. The processing circuitry may comprise hardware and firmware and/or software. For example, the processing circuitry may comprise one or more processors and a non-transitory medium connected to the one or more processors and carrying the code. The code, when executed by the one or more processors, causes the system to carry out the operations described herein.

Reference is now made to FIG. 1 , which is a depiction of system components in a NN configuration system 100, and related components, according to some embodiments of the present invention. The system 100 is used for configuring NN’s according to NN weights and/or NN activations. For example, the system 100 may be installed in a computer for improving pre-trained NN’s prior to installation of the NN’s as firmware

within constrained hardware, for example, installation within security cameras for a purpose of facial/pattern recognition.

An I/O interface 104 receives NN parameters from a client(s) 108. NN parameters consist of information which suffices to simulate the NN within the system 100. The parameters consist of tensors of NN weights, and NN activation functions parameters (such as rectified linear unit (RelU) and/or sigmoid functions parameters). In addition the I/O interface receives an input which indicates a type of configuration requested by the client(s), which may consist of a NN weights configuration and/or a NN activations configuration request. The clients(s) may request NN configuration for installment within constrained hardware. For example, a client factory installing pattern recognition firmware within security cameras may use the system 100.

The inputs received via the I/O interface are then processed by a code stored in the memory storage 106, by execution of the code by the one or more processor(s) 108. The code contains instructions for a process for configuring a NN, either based on NN weights or based on NN activations. Outcomes of NN configuration are outputted via the I/O interface 104 by the one or more processor(s) executing the code instructions, whereas the outputs may be directed to back to the client(s).

Reference is now made to FIG. 2, which is an exemplary dataflow of a process for configuring a NN by NN weights, according to some embodiments of the present invention.

Following a specification by the client(s) 108, to perform a NN configuration on the inputted NN according to NN weights, NN parameters are received by the process, as shown in 200. NN parameters consist of tensors of weights for each layer of the NN, and parameters related to the NN activation functions.

Next, as shown in 202, in a first configuration stage, a kernel-wise quantization is executed on the NN weight tensor T. The kernel-wise quantization is performed by altering a precision of each weight in T, according to predefined specifications, for example by altering precisions of weights from 32FP representations to INT4 representations. The purpose of performing kernel-wise quantization rather than uniform quantization per layer is to improve performance of configured NN’s, since kernels may display large variance in values.

In addition, a scaling factor ak is computed for each kernel k of each layer in the NN. The scaling factor ak is computed by approximating wherein Tk is a

respective sub-tensor k, as further detailed in FIG. 3.

Next, as shown in 204, NN layers with an MSE higher than a predefined threshold are located, and quantization is modified for the located layers. Optionally, the modified quantization may be of identical precision to the kernel wise quantization performed in 202. This enables implementation of the method in constrained hardware which does not allow mixed precision representation. For each layer a modified scaling factor is computed, as further detailed in FIG. 4.

In a third configuration stage, as depicted in 206, scaling factors are adjusted using calibration datasets. This stage’s purpose is to address rigidity of the NN which may arise following low precision quantization (such as INT4 quantization). The adjustment of scaling factors is performed by minimizing a distance metric between outputs of the neural network and the modified quantized neural network, using the calibration data sets, as further detailed in FIG. 5.

Next, as shown in 208, the configured NN parameters are outputted via the I/O interface to the client(s) 108.

Reference is now made to FIG. 3, which is an exemplary dataflow of a process of kernel wise quantization of a NN, according to some embodiments of the present invention. FIG. 3 details the NN weights quantization stage depicted in 202.

As shown in 300, 302, for each kernel of the NN the process applies a quantization for all NN weights of the respective kernel, and a respective scaling factor is computed. The quantization is applied according to a predefined precision range, for example, to INT8 or INT4 precision ranges, optionally according to hardware constraints employed by the client(s) 108.

The scaling factor for the respective kernel is computed by minimizing a reconstruction error on the respective kernel. Optionally, given a sub-tensor Tj representation of a kernel kj of size nj·, a scaling factor is computed by a

minimization process which is applied to an MSE, wherein


Next, as shown in 304, 302 is repeated for all unprocessed kernels, and as shown in 306, upon completion of quantization and scaling factor computation for all kernels, the

quantized kernels and respective scaling factors are outputted to 204, which is the second stage of NN configuration by weights.

Reference is now made to FIG. 4, which is an exemplary dataflow of an iterative process of modifying quantization of NN layers with a high reconstruction error, according to some embodiments of the present invention. FIG. 4 details the NN layers modification stage depicted in 204.

As shown in 400, quantized NN parameters are received from the NN configuration process according to NN weights as detailed in FIG. 2. The received parameters include quantized NN weights tensors, a predefined error threshold, and optionally a precision vector V = [/1 ... IN] The predefined error threshold is used for determining whether each layer’s quantization(s) is modified by a using a higher precision or multiple quantization, and computing a respective modified scaling factor. The optional precision vector V defines for each NN layer Lj a precision range. For example if Ij = 16, then an INT4 precision may be applied to Lj.

Next, as shown in 402 and 404, for each NN layer, the error threshold, denoted by t, is compared to a reconstruction error between the quantized NN and an intermediately modified quantized NN. Optionally, the reconstruction error comprises an MSE, as detailed in 302, and if the MSE is larger than t, the modification starting at 406 is applied to the respective layer.

Next, as shown in 406 and 408, for each kernel of the respective layer a modified quantization and scaling factor is computed. The modified quantization(s) is computed by a higher precision weights representation, optionally, a special case being a dual weight representation, which may be useful for implementation within constrained hardware. For example, for implementation within hardware supporting only INT4 representation, weights of a modified layer may be transformed from a FP32 representation to a dual INT4 representation, wherein each INT4 representation represents part of a quantization of a NN weight.

The modified scaling factor is computed by minimizing a distance metric computed between the quantized neural network as computed in 202, and the current intermediately modified quantized neural network, which may be described mathematically as follows. Denote by d the distance metric (i.e. MSE), by [1 ... t] a renumbering of indices of NN the layers located for modification. Denote by respective modified scaling

factors and respective quantized sub-tensors for layers
of the NN. In addition denote
an allowed quantization range for layer li.

The iterative process of modifying NN layers quantization searches for:


Next, as shown in 410, the modified quantized NN and the calculated scaling factors are outputted to the third NN weights quantization stage depicted in 206. Else, modification of the quantized NN is applied to a next layer, until all layers of the quantized NN are either modified or deemed as not needing modification due to a low reconstruction error.

For cases where a NN contains a layer that is quantized using dual quantization, and the quantization range is discrete (for example, INT4 or INT8 quantization), optimal first and second scaling factors may be efficiently computable. The computation may be executed using a grid search approach. Assuming scaling factors a1, a2 are given following the grid search, tensor elements are computed by minimizing a reconstruction error consisting of a quadratic term, Denote by an element with index j of quantized

weight tensors
and denote by an allowed quantization range, then are

computable by the following term:


Reference is now made to FIG. 5, which is an exemplary dataflow of an iterative process of adjusting scaling factors of a NN, according to some embodiments of the present invention. The purpose of adjusting the scaling factors is to overcome any rigidity of the NN functionality which may arise following the first two stages of NN quantization, and layer quantization modification. FIG. 5 details the adjustment of scaling factors depicted in 206.

As shown in 500, modified quantized NN parameters are received following 204. In addition a small set of calibration datasets is received from the process depicted in FIG. 2. Next, as shown in 502 and 504, the calibration set is used to adjust the scaling factors layer-wise by minimizing the distance metric between outputs of the neural network and the modified quantized neural network, using the calibration data sets.

The minimization is performed as follows. Denote by k an optional desired precision (given by the client(s) 108) and by /:
a function representing the NN function mapping between the calibration datasets and NN parameters

W in to a given mapping in
wherein
denotes an output of layer l of the NN.

The scaling factors readjustment is performed by finding a value for a parameter yl for layer l defined by wherein cq is a scaling factor generated in the first

two configuration stages, and is a weight tensor with precision k computed from a

given mapping algorithm, which maps the outputs of the NN inputted to the system 100 to the outputs of the tensor
Next, yl is computed using a predefined metric d (for example, using L, or L2 norm), and an optional discount factor for layer l

( bi designates a client defined importance of layer Z), as follows:


Computing gi is computationally economical as few parameters are involved in the optimization.

Next, as shown in 504, the adjustment of scaling factors is repeated for all layers of the NN, until, as shown in 506, the adjusted scaling factors are outputted to 208 for processing.

Reference is now made to FIG. 6, which is an exemplary dataflow of a process of configuring a NN by NN activations, according to some embodiments of the present invention. The purpose of configuring a NN by NN activations is to allow implementations of NN’s within constrained hardware to be configured in real time, by pre-calculating configuration parameters. The process achieves this by using calibration datasets in advance in order to calculate configuration parameters for low precision representation of activations of the NN. Next, the calculated parameters may be programmed in firmware by a client(s), for example, by implementing a code within the firmware which performs a low cost arithmetic operation following any NN activation taking place during operations running on the hardware. For example, FP32 may be quantized to INT4 activations using scaling factors computed as described in FIG. 6. This may improve NN output accuracy, and may be implemented independently or before/after NN configuration by NN weights.

As shown in 600, NN parameters, comprising NN weight tensors, and NN activation function parameters are received from the client(s) 108 via the I/O interface. In addition, a set of calibration datasets is received, which are used for generating NN activations.

Next, as shown in 602, for each NN layer a first scaling factor is computed using the calibration datasets. Given a NN layer l, denote by M the size of the set of calibration datasets, by the activations of layer l on a dataset with index i. The first scaling factor

is computed by:


Note, that computing is equivalent to solving an MSE problem.


Next, as shown in 604, NN layers are located for modification as described for the NN configuration by weights as depicted in 204. Next, as shown in 606, for each located layer a dual quantization representation is generated and a second scaling factor for the dual quantization of layer 1 is computed by:


Finally, as shown in 608, the first and second scaling factors are outputted to the client(s) 108 via the I/O interface.

Reference is now made to FIG. 7, which is a depiction of results of simulations of NN weight configuration, by using the first two configuration stages, according to some embodiments of the present invention. Simulations were performed using ImageNet validation data. Table 700 depicts prediction rate success of the top prediction scores of various NN’s using full precision FP32 representations, and INT4, dual INT4 and INT8 quantization. As shown in 700, dual INT4 quantization using the method described herein produces results close to INT8 quantization, which demonstrates viability for implementation of the method for constrained hardware. Table 702 depicts prediction rate success of the top five prediction scores of various NN’s. As seen in 702, for this accuracy analysis, dual INT4 quantization also demonstrates performance similar to INT8

quantization and significantly better than INT4 quantization performance. Table 704 depicts compression rates of the different NN’s following quantization. As seen, dual INT4 quantization displays similar compression rates to INT8 for all the simulated NN’s.

Reference is now made to FIG. 8, which is a depiction of results of simulations of NN weight configuration, by using all three configuration stages (depicted in the ‘dual+optimization’ column), according to some embodiments of the present invention. Simulations were performed using ImageNet data. Tables 800 and 802 depict prediction rate success of the top prediction scores and top five prediction scores respectively. As show in 800, 802, adding the scaling factor readjustment stage improves performance of all simulated NN’s in both tables, to a level beyond that of INT8 quantization alone. Note, that NN activations in the simulations were used in full precision.

Both FIG. 7 and FIG. 8 demonstrate the usefulness of the method described, especially in applying dual INT4 quantization to various known NN’s frameworks.

Other systems, methods, features, and advantages of the present disclosure will be or become apparent to one with skill in the art upon examination of the following drawings and detailed description. It is intended that all such additional systems, methods, features, and advantages be included within this description, be within the scope of the present disclosure, and be protected by the accompanying claims.

The descriptions of the various embodiments of the present invention have been presented for purposes of illustration, but are not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terminology used herein was chosen to best explain the principles of the embodiments, the practical application or technical improvement over technologies found in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.

It is expected that during the life of a patent maturing from this application many relevant systems, methods and computer programs will be developed and the scope of the term neural network quantization is intended to include all such new technologies a priori.

As used herein the term“about” refers to ± 10 %.

The terms“comprises”,“comprising”,“includes”,“including”,“having” and their conjugates mean “including but not limited to”. This term encompasses the terms “consisting of’ and“consisting essentially of’.

The phrase“consisting essentially of’ means that the composition or method may include additional ingredients and/or steps, but only if the additional ingredients and/or steps do not materially alter the basic and novel characteristics of the claimed composition or method.

As used herein, the singular form“a”,“an” and“the” include plural references unless the context clearly dictates otherwise. For example, the term“a compound” or“at least one compound” may include a plurality of compounds, including mixtures thereof.

The word“exemplary” is used herein to mean“serving as an example, instance or illustration”. Any embodiment described as“exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments and/or to exclude the incorporation of features from other embodiments.

The word“optionally” is used herein to mean“is provided in some embodiments and not provided in other embodiments”. Any particular embodiment of the invention may include a plurality of“optional” features unless such features conflict.

Throughout this application, various embodiments of this invention may be presented in a range format. It should be understood that the description in range format is merely for convenience and brevity and should not be construed as an inflexible limitation on the scope of the invention. Accordingly, the description of a range should be considered to have specifically disclosed all the possible subranges as well as individual numerical values within that range. For example, description of a range such as from 1 to 6 should be considered to have specifically disclosed subranges such as from 1 to 3, from 1 to 4, from 1 to 5, from 2 to 4, from 2 to 6, from 3 to 6 etc., as well as individual numbers within that range, for example, 1, 2, 3, 4, 5, and 6. This applies regardless of the breadth of the range.

Whenever a numerical range is indicated herein, it is meant to include any cited numeral (fractional or integral) within the indicated range. The phrases“ranging/ranges between” a first indicate number and a second indicate number and“ranging/ranges from” a first indicate number“to” a second indicate number are used herein interchangeably and are meant to include the first and second indicated numbers and all the fractional and integral numerals therebetween.

It is appreciated that certain features of the invention, which are, for clarity, described in the context of separate embodiments, may also be provided in combination in a single embodiment. Conversely, various features of the invention, which are, for brevity, described in the context of a single embodiment, may also be provided separately or in any suitable subcombination or as suitable in any other described embodiment of the invention. Certain features described in the context of various embodiments are not to be considered essential features of those embodiments, unless the embodiment is inoperative without those elements.

All publications, patents and patent applications mentioned in this specification are herein incorporated in their entirety by reference into the specification, to the same extent as if each individual publication, patent or patent application was specifically and individually indicated to be incorporated herein by reference. In addition, citation or identification of any reference in this application shall not be construed as an admission that such reference is available as prior art to the present invention. To the extent that section headings are used, they should not be construed as necessarily limiting.