Adaptive hardware-friendly hybrid quantization method based on deep neural networks
By using an adaptive hardware-friendly hybrid quantization method, the quantization sensitivity of the network layer is analyzed and quantization strategies are dynamically allocated. This solves the problem of the imbalance between model accuracy and hardware execution efficiency in existing technologies, and improves the inference efficiency and resource utilization of edge computing devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU DIANZI UNIV
- Filing Date
- 2026-01-23
- Publication Date
- 2026-06-09
AI Technical Summary
Existing quantization methods ignore the structural characteristics and hardware computational characteristics of different network layers, resulting in a decrease in the accuracy of network layers that are sensitive to quantization errors, and they cannot be efficiently mapped to hardware execution units, making it difficult to achieve a stable balance between model accuracy and hardware execution efficiency.
By analyzing the quantization sensitivity of network layers, the optimal quantization strategy is adaptively selected for each layer. Combining the signal-to-noise ratio evaluation index and preset thresholds, fixed-point quantization, logarithmic quantization, and median-width fixed-point quantization methods are dynamically allocated to optimize model storage and computing resource consumption, making it particularly suitable for edge computing devices.
It significantly reduces storage and computing resource consumption while ensuring model accuracy, improves inference efficiency and hardware execution efficiency of edge devices, and is suitable for edge computing and embedded platforms.
Smart Images

Figure CN122174895A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of neural network model compression and hardware acceleration technology, specifically involving an adaptive hardware-friendly hybrid quantization method based on deep neural networks, which is suitable for efficient deployment and inference computation of deep neural network models on edge computing devices, embedded processors, and dedicated artificial intelligence acceleration hardware. Background Technology
[0002] With the widespread application of deep neural networks in fields such as computer vision, speech recognition, and intelligent sensing, the scale and computational complexity of network models are constantly increasing. High-precision deep neural networks typically rely on large amounts of parameter storage and high-intensity floating-point operations. While they can be deployed in cloud server environments, their direct application on edge devices or embedded platforms with limited computing power, storage, and power consumption presents significant challenges.
[0003] To reduce the storage requirements and computational overhead of models, model quantization techniques have been widely researched and applied. By converting high-precision floating-point parameters in the network into low-bit-width representations, the size of model parameters can be effectively reduced, and computational efficiency during the inference phase can be improved. Existing quantization methods mainly include fixed-point quantization and logarithmic quantization. Among them, fixed-point quantization has the advantages of simple implementation and good precision preservation, while logarithmic quantization can convert multiplication operations into shift operations, resulting in higher execution efficiency in hardware implementation.
[0004] However, most existing quantization methods employ a uniform quantization strategy, applying the same quantization method and bit width to all layers of the entire network. This approach ignores the differences in structural characteristics, parameter distribution, and functional roles among different network layers, easily leading to a significant decrease in the accuracy of some network layers sensitive to quantization errors, thus affecting the overall model performance. To alleviate this problem, some studies have proposed hybrid quantization schemes, using different bit widths or different quantization methods for different network layers. However, existing hybrid quantization methods mostly rely on empirical rules or manual settings, lacking a systematic analysis of the quantization sensitivity of each network layer, making it difficult to achieve a stable and generalizable balance between model accuracy and hardware execution efficiency.
[0005] Furthermore, when deployed on actual hardware platforms, some quantization methods, while theoretically reducing bit width, fail to fully consider the characteristics of underlying hardware instructions. This results in quantized computations still not being efficiently mapped to hardware execution units, thus limiting the actual acceleration effect. Therefore, how to adaptively allocate appropriate quantization methods to different network layers while ensuring model inference accuracy, taking into account both network layer characteristics and hardware computational characteristics, remains a pressing technical problem to be solved in this field. Summary of the Invention
[0006] To overcome the shortcomings of existing technologies, the present invention aims to provide an adaptive hardware-friendly hybrid quantization method based on deep neural networks. By analyzing the sensitivity of different network layers to quantization errors, the method adaptively selects the optimal quantization strategy for each layer, thereby significantly reducing the storage and computing resource consumption of the model while maintaining the model accuracy to the maximum extent. This method is particularly suitable for edge computing devices.
[0007] To achieve the above objectives, the present invention may adopt the following specific technical solutions: The aforementioned adaptive hardware-friendly hybrid quantization method based on deep neural networks includes the following steps: Step 1: Obtain the full-precision deep neural network model to be quantized, extract the weight parameters of each network layer, and activate the parameters; Step 2: Perform statistical analysis on the weight parameters and activation parameters of each network layer to construct an evaluation index for measuring quantization error; Step 3: Based on the evaluation metrics, perform quantitative sensitivity analysis on different network layers; Step 4: Based on the quantization sensitivity analysis results, adaptively determine the quantization method corresponding to each network layer; Step 5: According to the quantization method, perform hybrid quantization processing on the weight parameters and activation parameters to obtain a hybrid precision quantization model; Step 6: Based on the quantized weight parameters and activation parameters, complete the inference calculation of the deep neural network.
[0008] Furthermore, step 1 specifically includes: Step 1.1 Obtain the pre-trained full-precision deep neural network model and extract the weight parameter set of each layer by traversing the network layers. ; Step 1.2 Obtain the activation parameters of each layer by performing forward inference calculations on the full-precision deep neural network model. The calculation relationship is as follows: ,in, These are the activation parameters for the previous layer. For bias parameters, For activation functions; In the process of obtaining activation parameters, multiple forward inference calculations are performed on the full-precision deep neural network model to form a sample set of activation parameters describing the numerical distribution of activation parameters in each network layer, which is represented as: ,in, Indicates the first The number of activation parameters obtained by each network layer during multiple forward inference computations; This represents the first activation value sample in layer l. This represents the Mth activation value sample in the l-th layer.
[0009] Furthermore, in step 2, the weight parameters obtained in step 1 are... and activation parameter sample set A signal-to-noise ratio (SNR) is constructed as an evaluation index to measure quantization error, characterizing the error relationship between parameters before and after quantization; the SNR evaluation index is calculated according to the following formula: , in, Indicates the parameters before quantization. Indicates and The corresponding quantized parameters.
[0010] Furthermore, in step 3, the signal-to-noise ratio (SQNR) evaluation index corresponding to the same network layer under the first quantization method, the second quantization method, and the third quantization method are calculated respectively; the first quantization method is fixed-point quantization, the second quantization method is logarithmic quantization, and the third quantization method is median-width fixed-point quantization; by comparing the changes in SQNR values under different quantization methods, the sensitivity of the network layer to the quantization method is determined.
[0011] Furthermore, in step 4, let the total number of network layers be... For the first layer( ), in the candidate quantization method set The signal-to-noise ratio value is ,in, Represents fixed-point quantification. This represents quantification; two preset threshold conditions are defined: First precondition: , Second pre-defined condition: , in, and The signal-to-noise ratio threshold is set according to the task requirements. This is a sensitivity tolerance, used to determine whether two quantization methods behave similarly at this layer; and These are two preset signal-to-noise ratio (SNR) thresholds used to classify and make decisions for the network layers based on the SQNR values calculated above. It is a relatively high signal-to-noise ratio threshold. It is a relatively low signal-to-noise ratio threshold. This represents the signal-to-noise ratio calculated after applying fixed-point quantization (e.g., 8-bit) to the parameters (weights and activation values) of the l-th layer. The signal-to-noise ratio (SNR) value is calculated after the parameters of the l-th layer are quantized in a logarithmic manner (e.g., 4 bits).
[0012] Furthermore, adaptive decision function Defined as: , In the formula, This indicates that high-precision fixed-point quantization is assigned to this layer; This represents the quantification of the allocation pairs for this layer; This indicates that a medium-precision fixed-point quantization is assigned as a trade-off between accuracy and efficiency; after the decision-making process traverses all layers, a quantization configuration vector is output. This allows for an adaptive mapping from global sensitivity analysis to a layer-by-layer quantization strategy.
[0013] Furthermore, based on the quantization sensitivity analysis results obtained in step 3, when the signal-to-noise ratio (SQNR) evaluation index corresponding to the network layer meets the first preset condition, the network layer is assigned a first quantization method; when the SQNR evaluation index meets the second preset condition, the network layer is assigned a second quantization method; when the SQNR evaluation index does not meet either the first or the second preset condition, the network layer is assigned a third quantization method.
[0014] Furthermore, in step 5, when When using fixed-point quantization, the quantization process is implemented as follows: , Wherein, scaling factor Round is the rounding function, Clip is the truncation function, ensuring that the result falls within the range of the target fixed-point representation, IL represents the integer bit width, and FL represents the decimal bit width; This represents the quantization result obtained after performing fixed-point quantization on the input value x. This means dividing the original value x by the quantization step size Δ to obtain a multiple relative to the step size; This means rounding the scaled value x / Δ to the nearest integer; x represents the original input value.
[0015] Furthermore, in step 6, when When using a quantitative approach, the quantification process is implemented as follows: , The Round and Clip functions ensure that the exponent is constrained within the range [a, b] determined by the quantization bit width, thereby controlling the dynamic range of the quantized value.
[0016] Furthermore, in step 6, based on the quantized weight parameters... and activation parameters The multiplication and addition operations are performed to complete the reasoning calculations, and the calculation relationships are as follows: When the activation parameter is quantized, the multiplication operation in the multiplication-addition operation is converted into a shift operation, which is expressed as: , in, Indicates performing operations on operands Logical left or right shift of bits.
[0017] Compared with the prior art, the present invention has the following advantages: The adaptive hardware-friendly hybrid quantization method proposed in this invention has several significant advantages. First, this method possesses high adaptability. By performing quantization sensitivity analysis on each network layer using the objective metric of signal-to-noise ratio (SQNR), it can automatically identify and distinguish the tolerance of different layers to quantization errors, thereby assigning appropriate quantization strategies to each layer. This effectively overcomes the performance degradation problem caused by the neglect of inter-layer differences in traditional unified quantization methods. Second, this method achieves an intelligent balance between accuracy and efficiency. By pre-setting thresholds and decision rules, it flexibly selects high-precision fixed-point, medium-precision fixed-point, or logarithmic quantization methods, significantly reducing storage overhead and computational complexity while maximizing the overall inference accuracy of the model. Third, this invention fully considers hardware execution characteristics. In particular, the introduction of logarithmic quantization converts multiplication operations into shift operations, fully leveraging the instruction-level parallelism and energy efficiency advantages of platforms such as ARM, FPGA, and dedicated AI accelerators, thereby significantly improving inference speed and reducing power consumption. Furthermore, this method exhibits good generalization and engineering practicality. Its process is independent of specific network structures; by obtaining statistical distributions from calibration data, it can be applied to various models. The generated hybrid quantization model can be directly deployed on existing edge devices and embedded platforms without additional hardware modifications, significantly reducing the barriers and costs for practical application. In summary, this invention demonstrates significant value in improving model compression, maintaining inference accuracy, optimizing hardware execution efficiency, and enhancing deployment convenience, making it particularly suitable for resource-constrained edge computing and embedded artificial intelligence applications.
[0018] This invention effectively reduces model storage and computational overhead while ensuring model inference accuracy, and improves model inference efficiency on edge devices and dedicated hardware platforms, thus having good engineering practical value. Attached Figure Description
[0019] Figure 1 This is one of the flowcharts of the method of the present invention; Figure 2This is the second flowchart of the method of the present invention; Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0021] like Figure 1 and Figure 2 As shown, the present invention provides an adaptive hardware-friendly hybrid quantization method based on deep neural networks, comprising the following steps: (a) Step 1: Obtain the full-precision deep neural network model to be quantized, extract the weight parameters of each network layer and activate the parameters.
[0022] Load a pre-trained, full-precision deep neural network model, iterate through each layer of the model, and extract its weight parameter tensors. : .
[0023] By performing forward inference computation on a full-precision deep neural network model, the activation parameters corresponding to each layer are obtained. The calculation relationship is as follows: ,in, These are the activation parameters for the previous layer. For bias parameters, This is the activation function.
[0024] In acquiring activation parameters, multiple forward inference calculations are performed on the full-precision deep neural network model to form a sample set of activation parameters describing the numerical distribution of activation parameters for each network layer. To obtain a statistically representative distribution of activation values, a set of representative calibration data is input into the model, and multiple forward inferences are performed. All activation outputs generated by each layer during this process are collected to form the sample set of activation parameters for that layer. : ,in, Indicates the first The number of activation parameters obtained by each network layer during multiple forward inference computations; This represents the first activation value sample in layer l. This represents the Mth activation value sample in the l-th layer.
[0025] (ii) Step 2: Perform statistical analysis on the weight parameters and activation parameters of each network layer to construct an evaluation index for measuring quantization error.
[0026] Signal-to-noise ratio (SNR) is constructed as the core evaluation metric. This metric considers both weights and activation values. For a given set of parameters of a network layer (including weights and collected activation samples), its original full precision is set to _____. The quantized value is The signal-to-noise ratio calculation formula for this layer parameter under a certain quantization method is: , in, Indicates the parameters before quantization. Indicates and The corresponding quantized parameters.
[0027] (III) Step 3: Based on the evaluation index, perform quantitative sensitivity analysis on different network layers.
[0028] This step aims to evaluate the tolerance of each network layer to different quantization schemes. For each network layer to be analyzed, two or more candidate quantization schemes are pre-defined (e.g., 8-bit fixed-point quantization, 4-bit logarithmic quantization, etc.). Using the formula in step 2, the SQNR value of the layer parameters under each candidate quantization scheme is calculated. By comparing the absolute magnitude of these SQNR values and their differences (variation magnitude), the sensitivity of the layer is determined: if the SQNR value difference caused by different quantization schemes is huge, it indicates that the layer is sensitive to the quantization scheme, and high-precision quantization should be carefully selected; if the difference is small, it indicates that the layer is robust to the quantization scheme, and aggressive quantization with lower bits can be tried to obtain a higher compression ratio.
[0029] For the same network layer, the signal-to-noise ratio (SQNR) evaluation index is calculated under the first, second, and third quantization methods respectively; the first quantization method is fixed-point quantization, the second quantization method is logarithmic quantization, and the third quantization method is median-width fixed-point quantization; by comparing the changes in SQNR values under different quantization methods, the sensitivity of the network layer to the quantization method is determined.
[0030] (iv) Step 4: Based on the results of the quantization sensitivity analysis, adaptively determine the quantization method corresponding to each network layer.
[0031] Based on the quantization sensitivity analysis results obtained in step 3 (i.e., the SQNR values of each network layer under different quantization methods), a suitable quantization method is adaptively assigned to each network layer according to preset decision rules. This process can be formally described as follows: Let the total number of network layers be . For the first layer( ), which is in the set of candidate quantization methods The signal-to-noise ratio value is ,in, Represents fixed-point quantification. This represents quantification.
[0032] Define two preset threshold conditions: First preset condition (high precision requirement): , Second pre-set condition (high efficiency requirement): , in, and The signal-to-noise ratio threshold is set according to the task requirements. This is a sensitivity tolerance used to determine whether two quantization methods behave similarly at this layer. and These are two preset signal-to-noise ratio (SNR) thresholds used to classify and make decisions for the network layers based on the SQNR values calculated above. It is a relatively high signal-to-noise ratio threshold. It is a relatively low signal-to-noise ratio threshold. This represents the signal-to-noise ratio calculated after applying fixed-point quantization to the parameters of the l-th layer. This represents the signal-to-noise ratio value calculated after applying logarithmic quantization to the parameters of the l-th layer.
[0033] Based on the obtained quantization sensitivity analysis results, when the signal-to-noise ratio (SQNR) evaluation index corresponding to the network layer meets the first preset condition, the network layer is assigned a first quantization method; when the SQNR evaluation index meets the second preset condition, the network layer is assigned a second quantization method; when the SQNR evaluation index does not meet either the first or the second preset condition, the network layer is assigned a third quantization method.
[0034] Adaptive decision function Defined as: , In the formula, This indicates that a high-precision fixed-point quantization (e.g., 8 bits) is assigned to this layer. This indicates that the allocation of pairs for this layer is quantized (e.g., 4 bits) to prioritize improving computational efficiency. This indicates the allocation of a medium-precision fixed-point quantization (e.g., 6 bits) as a trade-off between precision and efficiency.
[0035] After traversing all layers, the decision-making process outputs a quantized configuration vector. This allows for an adaptive mapping from global sensitivity analysis to a layer-by-layer quantization strategy.
[0036] (v) Step 5: According to the quantization method, perform mixed quantization processing on the weight parameters and activation parameters to obtain a mixed precision quantization model.
[0037] Based on the adaptive quantization configuration vector obtained in step 4 This step performs specific quantization operations on all layers of the neural network, thereby converting the full-precision model into a mixed-precision quantization model.
[0038] when When the interval (corresponding to the high-precision requirement range) is reached, high-bit-width fixed-point quantization is performed, using higher-precision fixed-point quantization (e.g., 8 bits) to maintain numerical accuracy to the maximum extent. The quantization process follows: , Wherein, scaling factor Round is the rounding function, and Clip is the truncation function, ensuring that the result falls within the range of the target fixed-point representation; This represents the quantization result obtained after performing fixed-point quantization on the input value x. This means dividing the original value x by the quantization step size Δ to obtain a multiple relative to the step size; This means rounding the scaled value x / Δ to the nearest integer; x represents the original input value.
[0039] when During the high-efficiency interval, logarithmic quantization is performed, using logarithmic quantization (e.g., 4 bits) to map the parameters to powers of 2, thus converting multiplication operations into shift operations. The quantization process follows: , The Round and Clip functions ensure that the exponent is constrained within the range [a, b] determined by the quantization bit width, thereby controlling the dynamic range of the quantized value.
[0040] when During the middle interval, medium-width fixed-point quantization is performed, using medium-precision fixed-point quantization (e.g., 6 bits) to achieve a balance between accuracy and efficiency. Its quantization formula is the same as high-width fixed-point quantization, only the bit width parameter differs. and The corresponding reduction.
[0041] By applying the corresponding quantization operations layer by layer, all weights and activation values of the model are converted into the specified low-precision format, ultimately generating a lightweight network model that combines high-precision fixed-point, medium-precision fixed-point, and logarithmic quantization methods, laying the foundation for efficient inference in the future.
[0042] (vi) Step 6: Based on the quantized weight parameters and activation parameters, complete the inference calculation of the deep neural network.
[0043] After quantization of each layer is completed, the final hybrid quantization model is obtained. This step performs forward propagation (inference) of the network based on the quantized weights and activation values, and leverages the hardware-friendly characteristics brought by quantization to accelerate computation.
[0044] For any computational layer in the network, given its quantized weight parameters With activation parameters The core computation of this layer—multiplication and addition—is performed in the following manner: This calculation is performed iteratively layer by layer throughout the network, eventually producing the model output.
[0045] For the network layers assigned in step 4 using logarithmic quantization, their activation values have This is a special form. This characteristic makes every multiplication operation in this layer: , This can be equivalently converted into a shift operation with extremely high hardware execution efficiency: , in, Indicates performing operations on operands Logical left shift of bits ( ) or move right ( On processors that support this instruction (such as ARM, FPGA, and dedicated AI accelerators), the execution time and resource overhead of a single shift operation are much lower than those of a multiplication operation.
[0046] Test case Step 1: Select a ResNet-18 full-precision model pre-trained on the ImageNet dataset as the base model. This model contains 17 convolutional layers and 1 fully connected layer, for a total of 18 quantizable layers. Iterate through all convolutional and fully connected layers, and convert their weight tensors... Export and store layer by layer. For example, the first layer's convolutional weights have a shape of [64, 3, 7, 7] (64 output channels, 3 input channels, 7×7 kernels). 500 representative images are randomly selected from the ImageNet validation set as a calibration dataset. This dataset is fed into the network and a full forward inference is performed. During this process, the output activation tensor of each layer is captured via a forward hook when processing each image. For the ... The layer, whose output shape is [batch size, number of channels, height, width], flattens and merges all the output values from 500 inferences to form the set of activation samples for that layer. For example, if the output shape of a certain layer is [1, 256, 14, 14], then... A sample size is sufficient to accurately reflect the statistical distribution of activation values in that layer (including minimum, maximum, mean, variance, and histogram shape).
[0047] Step 2: For each layer weight it With activation sample Merging them to form the complete set of parameters for this layer. Subsequently, quantitative simulation and index calculation were performed, and two representative quantization methods were selected as candidates: ① 8-bit uniform fixed-point quantization ( ); ② 4-bit logarithmic quantization ( ).
[0048] For the complete series The quantized values were obtained by applying two different quantization methods. Calculate the signal-to-noise ratio using the following formula: .
[0049] Steps 3-4: Based on the calculations obtained in Step 2, each layer and Set a decision threshold: high threshold Low threshold Sensitivity tolerance .
[0050] For each layer Applying decision function : , in, This indicates the allocation of 8-bit fixed-point quantization. This indicates the allocation of 4 bits for quantization. This indicates the allocation of 6-bit fixed-point quantization.
[0051] Analysis of the layers of ResNet-18 reveals a typical pattern: shallow convolutional layers (such as conv1 and layer1) are sensitive to quantization. Typically higher than 35 dB, therefore 8-bit fixed-point quantization is allocated; deep convolutional layers (such as partial convolutions in layer 4) and fully connected layers are robust to quantization. Below 25 dB and with Since the difference is less than 3 dB, 4 bits are allocated for logarithmic quantization; the remaining intermediate layers are allocated 6 bits for fixed-point quantization.
[0052] Step 5: Based on the allocation results, perform quantification layer by layer: For allocation as The layer: performs 8-bit fixed-point quantization. First, the scaling factor is determined based on the range of values for the layer's weights and activations. For example, if the parameter range for a certain layer is [-1.5, 1.8], then an integer bit width should be selected. (Range -2 to 1.75), decimal places ,make The quantization range covers [-2, 1.96875]. The quantization operation is as follows: , For allocation as Layer: Performs 4-bit logarithmic quantization. The exponent range is set to [a, b] = [-7, 6], meaning the set of non-zero values after quantization is... The quantification process is as follows: , For allocation as Layer: Performs 6-bit fixed-point quantization. For example, setting IL=2, FL=3 ( ), quantization range [-2, 1.875].
[0053] Step 6: Deploy the hybrid quantization model to an ARM Cortex-A72 processor platform that supports shift operations and perform inference: Fixed-point quantization layer computation: computation is performed using 8-bit or 6-bit fixed-point multiply-accumulate instructions (such as SMLAL, SMLAL2) provided by the processor.
[0054] For quantization layer computation: speed is achieved using shift operations. For example, the activation values of a pair of quantization layers. Then the weight The multiplication calculation with the activation value is converted to: , in" " indicates a left shift of 3 bits. In ARM assembly, this can be efficiently accomplished using the LSL instruction.
[0055] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An adaptive, hardware-friendly hybrid quantization method based on deep neural networks, characterized in that, Includes the following steps: Step 1: Obtain the full-precision deep neural network model to be quantized, extract the weight parameters of each network layer, and activate the parameters; Step 2: Perform statistical analysis on the weight parameters and activation parameters of each network layer to construct an evaluation index for measuring quantization error; Step 3: Based on the evaluation metrics, perform quantitative sensitivity analysis on different network layers; Step 4: Based on the quantization sensitivity analysis results, adaptively determine the quantization method corresponding to each network layer; Step 5: According to the quantization method, perform hybrid quantization processing on the weight parameters and activation parameters to obtain a hybrid precision quantization model; Step 6: Based on the quantized weight parameters and activation parameters, complete the inference calculation of the deep neural network.
2. The adaptive hardware-friendly hybrid quantization method based on deep neural networks as described in claim 1, characterized in that, The specific content of step 1 includes: Step 1.1 Obtain the pre-trained full-precision deep neural network model and extract the weight parameter set of each layer by traversing the network layers. ; Step 1.2 Obtain the activation parameters of each layer by performing forward inference calculations on the full-precision deep neural network model. The calculation relationship is as follows: ,in, These are the activation parameters for the previous layer. For bias parameters, For activation functions; In the process of obtaining activation parameters, multiple forward inference calculations are performed on the full-precision deep neural network model to form a sample set of activation parameters describing the numerical distribution of activation parameters in each network layer, which is represented as: ,in, Indicates the first The number of activation parameters obtained by each network layer during multiple forward inference computations; This represents the first activation value sample in layer l. This represents the Mth activation value sample in the l-th layer.
3. The adaptive hardware-friendly hybrid quantization method based on deep neural networks as described in claim 1, characterized in that, In step 2, the weight parameters obtained in step 1 are used... and activation parameter sample set A signal-to-noise ratio (SNR) is constructed as an evaluation index to measure quantization error, characterizing the error relationship between parameters before and after quantization; the SNR evaluation index is calculated according to the following formula: , in, Indicates the parameters before quantization. Indicates and The corresponding quantized parameters.
4. The adaptive hardware-friendly hybrid quantization method based on deep neural networks as described in claim 1, characterized in that, In step 3, the signal-to-noise ratio (SQNR) evaluation index corresponding to the same network layer under the first quantization method, the second quantization method, and the third quantization method are calculated respectively; the first quantization method is fixed-point quantization, the second quantization method is logarithmic quantization, and the third quantization method is median-width fixed-point quantization; by comparing the changes in SQNR values under different quantization methods, the sensitivity of the network layer to the quantization method is determined.
5. The adaptive hardware-friendly hybrid quantization method based on deep neural networks as described in claim 4, characterized in that, In step 4, let the total number of network layers be... For the first layer( ), in the candidate quantization method set The signal-to-noise ratio value is below ,in, Represents fixed-point quantification. This represents quantification; two preset threshold conditions are defined: First precondition: , Second pre-defined condition: , in, and The signal-to-noise ratio threshold is set according to the task requirements. This is a sensitivity tolerance, used to determine whether two quantization methods behave similarly at this layer; and These are two preset signal-to-noise ratio (SNR) thresholds used to classify and make decisions for the network layers based on the SQNR values calculated above. It is a relatively high signal-to-noise ratio threshold. It is a relatively low signal-to-noise ratio threshold. This represents the signal-to-noise ratio calculated after applying fixed-point quantization to the parameters of the l-th layer. This represents the signal-to-noise ratio value calculated after applying logarithmic quantization to the parameters of the l-th layer.
6. The adaptive hardware-friendly hybrid quantization method based on deep neural networks as described in claim 5, characterized in that, Adaptive decision function Defined as: , In the formula, This indicates that high-precision fixed-point quantization is assigned to this layer; This represents the quantification of the allocation pairs for this layer; This indicates that a medium-precision fixed-point quantization is assigned as a trade-off between accuracy and efficiency; after the decision-making process traverses all layers, a quantization configuration vector is output. This allows for an adaptive mapping from global sensitivity analysis to a layer-by-layer quantization strategy.
7. The adaptive hardware-friendly hybrid quantization method based on deep neural networks as described in claim 6, characterized in that, Based on the quantization sensitivity analysis results obtained in step 3, when the signal-to-noise ratio (SQNR) evaluation index corresponding to the network layer meets the first preset condition, the network layer is assigned a first quantization method; when the SQNR evaluation index meets the second preset condition, the network layer is assigned a second quantization method; when the SQNR evaluation index does not meet either the first or the second preset condition, the network layer is assigned a third quantization method.
8. The adaptive hardware-friendly hybrid quantization method based on deep neural networks as described in claim 6, characterized in that, In step 5, when When using fixed-point quantization, the quantization process is implemented as follows: , Wherein, scaling factor Round is the rounding function, Clip is the truncation function, ensuring that the result falls within the range of the target fixed-point representation, IL represents the integer bit width, and FL represents the decimal bit width; This represents the quantization result obtained after performing fixed-point quantization on the input value x. This means dividing the original value x by the quantization step size Δ to obtain a multiple relative to the step size; This means rounding the scaled value x / Δ to the nearest integer; x represents the original input value.
9. The adaptive hardware-friendly hybrid quantization method based on deep neural networks as described in claim 6, characterized in that, In step 6, when When using a quantitative approach, the quantification process is implemented as follows: , The Round and Clip functions ensure that the exponent is constrained within the range [a, b] determined by the quantization bit width, thereby controlling the dynamic range of the quantized value.
10. The adaptive hardware-friendly hybrid quantization method based on deep neural networks as described in claim 8, characterized in that, In step 6, based on the quantized weight parameters and activation parameters The multiplication and addition operations are performed to complete the reasoning calculations, and the calculation relationships are as follows: When the activation parameter is quantized, the multiplication operation in the multiplication-addition operation is converted into a shift operation, which is expressed as: , in, Indicates performing operations on operands Logical left or right shift of bits.