A selective hadamard optimization quantization method and system for a learning-oriented image compression model

CN122891718APending Publication Date: 2026-10-09NANJING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611377600.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-07
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

[0005]本发明旨在解决学习式图像压缩模型进行整数低比特量化时,权重和激活离群值导致量化误差放大,以及统一采用激活侧哈达玛变换可能在部分层引起激活动态范围扩张的问题,提供一种面向学习式图像压缩模型的选择性哈达玛优化量化方法及系统

Benefits of technology

[0039]本发明的核心创新点在于:针对学习式图像压缩模型整数低比特推理中权重和激活离群值导致量化误差放大、率失真性能退化的问题,引入哈达玛正交变换对神经网络算子层的数值分布进行重整,并通过校准样本逐层判断激活侧变换是否会放大全局极值;对于稳定层采用权重侧与激活侧双侧哈达玛量化策略,对于激活放大敏感层切换为仅权重哈达玛量化策略,从而实现面向硬件整数推理的稳定部署。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122891718A_ABST
    Figure CN122891718A_ABST
Patent Text Reader

Abstract

The application discloses a selective Hadamard optimization quantization method and system for a learning-oriented image compression model and belongs to the field of neural network low-bit deployment. The application aims at the problems of quantization error caused by weight and activation outliers and unified adoption of activation side Hadamard transform possibly amplifying the dynamic range of some layers. Fixed level strategy labels are generated according to extreme value amplification probability based on layer-by-layer comparison of original activation and analog transform activation of a calibration image. Stable layers adopt double-side Hadamard quantization with input side activation and weight offsetting each other, and sensitive layers adopt output channel weight transform and output side inverse transform. Through orthogonal expansion of convolution expansion dimension, dimension completion based on a constructable Hadamard order, rate distortion post-training quantization or quantization perception training with abnormal scale blocking, an integer low-bit deployment model without input related dynamic branches is generated, thereby reducing quantization error and improving deployment stability while keeping floating point equivalence.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image coding technology, and in particular to a selective Hadamard optimization quantization method and system for learning-based image compression models. Background Technology

[0002] Images have become a ubiquitous medium for recording and disseminating visual information. With the widespread deployment of cameras, smart devices, and networked sensors, the scale of image data continues to grow. Simultaneously, images are also a crucial data format in modern artificial intelligence processes, supporting tasks such as visual perception, visual understanding, and visual-language question answering. The increased scale and resolution of image data lead to higher resource costs for storage, transmission, and downstream visual intelligence computing.

[0003] In recent years, neural network-based image compression methods have achieved or surpassed the compression performance of traditional codec standards such as JPEG, BPG, and VVC / H.266 in some application scenarios. Current mainstream learning-based image compression methods typically improve image reconstruction fidelity and bit efficiency through deeper neural network structures and more complex contextual entropy models, with weights and activations often stored and computed in floating-point form. However, in practical deployment scenarios such as mobile terminals, embedded chips, and edge servers, floating-point models suffer from high memory consumption, high power consumption, and high inference latency, hindering the large-scale application of learning-based image compression technology.

[0004] INT8 quantization maps floating-point weights and activations to low-bit integers, thereby reducing storage overhead and improving fixed-point hardware inference efficiency. However, weights and activations in learned image compression models may contain significant outliers. A few extreme values ​​can widen the overall quantization range, causing most valid values ​​to fall into coarser quantization intervals, leading to increased reconstruction distortion and bitrate overhead. Especially in tensor activation quantization, extreme values ​​in a single channel can dominate the entire tensor quantization scale, causing more severe rate-distortion performance degradation. Therefore, a learned image compression quantization scheme is needed that can balance outlier smoothing, non-power-law channel dimension adaptation, hierarchical anomaly detection, rate-distortion optimization, and hardware-friendly deployment. Summary of the Invention

[0005] This invention aims to address the problems of amplified quantization errors caused by weights and activation outliers when performing integer low-bit quantization in learned image compression models, and the potential for activation dynamic range expansion in some layers when uniformly using activation-side Hadamard transform. It provides a selective Hadamard optimized quantization method and system for learned image compression models.

[0006] The method includes the following steps:

[0007] Step 1: Obtain the learning-based image compression model to be quantized, the calibration image set, and the quantization configuration; parse the learning-based image compression model; and determine the neural network operator layer to be quantized.

[0008] Step 2: Based on the number of input channels, the number of convolution kernel spatial positions, and the number of output channels of the neural network operator layer to be quantized, construct the input channel Hadamard matrix and the normalized output channel Hadamard matrix; for the convolutional layer, expand the input channel Hadamard matrix according to the spatial position of the convolution kernel into an equivalent orthogonal matrix that acts on the feature dimension of the convolution unfolding.

[0009] Step 3: For the same calibration image and the same neural network operator layer to be quantized, acquire the original input activation tensor and use an equivalent orthogonal matrix to simulate the Hadamard transform offline to obtain the simulated transformation activation tensor that corresponds one-to-one with the original input activation tensor.

[0010] Step 4, for the first Layer, First Calculate the extreme value increment using paired samples of the calibrated image. Extreme value amplification ratio and the probability of extreme value amplification And calculate the mean coherent component corresponding to the all-positive Hadamard vector to form a layer-by-layer quantization sensitivity assessment result;

[0011] Step 5: Determine the hierarchical strategy labels ;

[0012] Step 6, when When performing two-sided Hadamard quantization, an orthogonal transformation is inserted into the input channel and the activation and weights are quantized separately to achieve integer approximation of floating-point calculations;

[0013] Step 7, when When performing weighted Hadamard quantization, the input remains unchanged, and Hadamard transformation and quantization are performed on the weights and outputs to achieve integer approximation calculation only on the weight side.

[0014] Step 8: After the quantization operator topology of the corresponding layer is uniquely determined by the hierarchical policy label, perform full network rate-distortion post-training quantization or quantization-aware training with abnormal scale blocking, and transform the fixed policy label into an integer low-bit deployment graph without input-related dynamic branches.

[0015] In step 2, construct a structure that satisfies the orthogonal normalization condition. input channel Hadamard matrix and normalized output channel Hadamard matrix Where H represents the Hadamard matrix, express An identity matrix of order T, where the superscript T denotes transpose;

[0016] For any dimension to be transformed From satisfying the Hadamard matrix construction conditions and not less than Choose the completed order from the candidate orders. ;when The Hadamard matrix is ​​constructed using Sylvester, where It is a non-negative integer; when there exists a prime power. Paley I is used to construct the Hadamard matrix, and mod is the remainder function; when a prime power exists... The Hadamard matrix is ​​constructed using Paley II; when no smaller Paley order is available, it is regressed to a value not less than 1. The least second power order is determined and the Hadamard matrix is ​​constructed using Sylvester; the positive basis vectors are placed in fixed columns by normalizing the row and column signs; in the processing of the Hadamard matrix in steps 3 to 8 for the same layer to be quantized, the currently determined order after padding and the Hadamard matrix construction method are used, and the original dimension, order after padding, Hadamard matrix construction method and number of new dimensions of the layer to be quantized are recorded.

[0017] In step 4, for the first Layer and first Zhang calibration images, each defining the transformed global maximum absolute value. and the global maximum absolute value before transformation for The extreme value increment is The extreme value amplification ratio is The probability of extreme value amplification is ;in, Indicates the application to the first Transform operators activated by layer input, Indicates the first Zhang calibration image in the first The input activation generated by the layer, This represents a preset positive number used to prevent the denominator from being zero. Indicates the total number of calibration images. Indicates an indicator function.

[0018] In step 4, the all-positive column basis vectors corresponding to the right multiplication direction of the input matrix in the normalized Hadamard matrix are... Defined as For channel vectors When represented as a column vector The projection along the directions of all positive basis vectors is The absolute value of the projection As a mean coherent component, it is used to explain and assist in verifying the dynamic range expansion caused by the mean of non-zero channels; the hierarchical strategy label is still determined according to the comparison result of the extreme value amplification probability and the preset threshold; among which This indicates the dimension in which the Hadamard transformation is actually performed; when there is no dimension padding, The original dimension to be transformed; when dimension padding exists, Take the completed order from step 2 , Represents channel vector The Middle The element value corresponding to each channel Represents channel vector The channel mean.

[0019] In step 5, With preset threshold Compare and determine the hierarchical strategy labels The hierarchical strategy label Steps 6, 7, and 8, which involve quantization and inference deployment after step 5, remain unchanged; when hour, For weighted Hadamard quantization only; when hour, The two-sided Hadamard quantization is used; the mean coherent component is used to explain and assist in verifying the source of extreme value amplification, without changing the threshold determination result alone.

[0020] In step 6, the hierarchical strategy label-controlled operator graph generator inserts mutually canceling orthogonal transformations in the input channel dimension to ensure that floating-point calculations satisfy... And quantize the transformation activation and transformation weights respectively, where Indicates the first The input activation matrix of the layer to be quantized Indicates the first The weight matrix of the layer to be quantized Indicates the first The output matrix of the nth layer to be quantized; The number of spatial locations of the convolution kernel is denoted as The actual number of input channels and the number of output channels are denoted as follows: and The input feature dimension after convolution unwinding is The input activation matrix after the convolution sliding window is unwound. Weight matrix and output matrix Each satisfies , and , where M represents the total number of sample positions after the convolution sliding window is expanded, which is equal to the product of the batch size and the number of output spatial positions;

[0021] The input channel Hadamard matrix satisfies The equivalent input-side matrix acting on the feature dimension of the convolution is: ;in, express An identity matrix of order 1. Represents the Kronecker product;

[0022] The integer activation operands, integer weight operands, integer accumulation result, and approximate output of two-sided Hadamard quantization are as follows: , , as well as ;in, Indicates according to quantitative scale Execution of signed Bit-symmetric quantization Represents the space of real numbers. Indicates the first In the dual-sided Hadamard quantization mode, the integer activation operands are obtained by input-side Hadamard transform and quantization. Indicates the first In the dual-sided Hadamard quantization mode, the integer weight operands are obtained by inverse Hadamard transform and quantization on the input side. Indicates that the operand is activated by an integer. With integer weight operands The integer sum of the multiplication and addition results in the following: Represents the result of accumulating integers. The approximate output obtained after scaling based on the activation quantization scale and the weighted quantization scale. Indicates the first Layer activation quantization scale, Indicates the first The weight quantization scale after layer transformation.

[0023] In step 7, keep Without performing the input channel Hadamard transform, Offline transformation along the output channel dimension And execute on the output side of the operator layer of the neural network to be quantized. To make floating-point calculations satisfy ;

[0024] The output channel Hadamard matrix satisfies The integer operands, integer summation result, and approximate output of weighted Hadamard quantization are as follows: , , as well as When the operator layer contains biases represented by row vectors At that time, the bias offline transformation is performed. and satisfy The normalization factor is incorporated into the quantization scale, and the inverse transformation on the output side is achieved through fixed addition and subtraction operations and rescaling; among which, Indicates the first Integer activation operands of the layer in weighted Hadamard quantization mode only. Indicates the first The integer weight operands of the layer after output channel Hadamard transform in weight-only Hadamard quantization mode. Indicates that the operand is activated by an integer. With integer weight operands The integer sum of the multiplication and addition results in the following: Represents the result of accumulating integers. The approximate output is obtained after scaling recovery and inverse Hadamard transform on the output side.

[0025] In step 8, in the quantization perception training path, symmetric pseudo-quantization is used for forward computation, and the rounding operation in the pseudo-quantization process is backpropagated using a pass-through estimator. The model parameters are updated according to the rate-distortion loss of the learned image compression model.

[0026] For the The layer in the first The activation tensor generated by each training batch Calculate the quantization scale of candidate activations for the current batch: ,in This represents the quantization scale of candidate activations calculated based on the activation tensor of the current batch;

[0027] Update the following section format: Layer activation quantization scale: when hour, ;when hour, ;in, Indicates the first The layer activates the quantization scale during the run before the current batch update. Indicates the momentum coefficient. This represents the threshold for abnormal folds; after training, the running activation quantization scale of each layer is frozen, and the frozen value is then... The activation quantization scale used for corresponding layer pseudo-quantization and inference quantization ;when When the initial run activation quantization scale is set to the first candidate scale or the scale predetermined by the calibration image set, the initial run activation quantization scale is set to the first candidate scale.

[0028] The present invention also provides a selective Hadamard optimization quantization system for implementing the method in a learning-oriented image compression model, comprising a model and calibration data acquisition module, a Hadamard matrix construction module, a quantization sensitivity evaluation module, a layer-by-layer quantization strategy determination module, a quantization calculation graph generation module, a quantization parameter optimization module, and a deployment model generation module.

[0029] The model and calibration data acquisition module is used to acquire the learning image compression model to be quantized, the calibration image set and the quantization configuration, and to obtain the calibration activation data of each layer to be quantized through the learning image compression model.

[0030] The Hadamard matrix construction module is used to construct input-side and output-side normalized Hadamard matrices based on the number of input channels, the number of convolution kernel spatial locations, and the number of output channels of each layer to be quantized, and to ensure that each module corresponding to the same layer to be quantized uses the same normalized Hadamard matrix.

[0031] The quantization sensitivity assessment module is used to input the same calibration activation data into the original assessment path without Hadamard transformation and the simulated assessment path after input-side Hadamard transformation, respectively. It performs pairwise comparison of the activation data before and after transformation, calculates the extreme value increment, extreme value amplification ratio, extreme value amplification probability and mean coherence component, and summarizes the results layer by layer to obtain the quantization sensitivity assessment results.

[0032] The layer-by-layer quantization strategy determination module is used to compare the extreme value amplification probability of each layer to be quantized with a preset probability threshold, and determine the corresponding layer-level strategy label for each layer to be quantized based on the comparison result; the layer-level strategy label is determined based on the pairing comparison result of the same calibration activation data before and after the Hadamard transformation, and remains unchanged in each module involved in quantization and inference deployment.

[0033] The quantization computation graph generation module is used to select one of two mathematically equivalent computation structures in the floating-point computation domain as the computation graph of the corresponding quantization layer according to the hierarchical strategy label of each layer to be quantized; for the layer to be quantized where the extreme value amplification probability is not higher than a preset probability threshold, a two-sided Hadamard computation structure is generated that applies mutually canceling Hadamard transforms to the input activation and weights respectively in the input feature dimension; for the layer to be quantized where the extreme value amplification probability is higher than the preset probability threshold, a computation structure is generated that applies Hadamard transform to the weights and applies the corresponding inverse transform to the layer output in the output channel dimension.

[0034] The quantization parameter optimization module is used to perform full-network post-training quantization with rate-distortion loss as the optimization objective, or to perform quantization-aware training, while keeping the quantization computation graph unchanged. During quantization-aware training, when the candidate activation quantization scale of the current training batch exceeds the abnormal multiple threshold determined based on the historical activation quantization scale, the historical activation quantization scale is kept unchanged to reduce the impact of abnormal activation values ​​on quantization scale updates.

[0035] The deployment model generation module is used to perform offline Hadamard transformation and low-bit quantization on the weights before model deployment, convert the hierarchical policy labels of each layer to be quantized into corresponding fixed operator structures, and generate a low-bit integer deployment model that does not contain conditional branches that dynamically select quantization strategies based on input data.

[0036] The present invention also provides an electronic device, including a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor performs the steps of the method to achieve hardware adaptation of Hadamard quantization and quantization model.

[0037] The present invention also provides a computer-readable storage medium storing a computer program or instructions that, when the computer program or instructions are run on a computer, execute the steps of the method.

[0038] Compared with existing commercial solutions, the present invention has at least the following advantages:

[0039] The core innovation of this invention lies in addressing the problem of amplified quantization errors and rate-distortion performance degradation caused by weight and activation outliers in low-bit integer inference of learning-based image compression models. It introduces Hadamard orthogonal transformation to reshape the numerical distribution of the neural network operator layers and uses calibration samples to determine layer by layer whether the activation-side transformation amplifies global extrema. For stable layers, a dual-side Hadamard quantization strategy is adopted, using both weight and activation sides. For activation-sensitive layers, a weight-only Hadamard quantization strategy is switched, thereby achieving stable deployment for hardware-oriented integer inference.

[0040] The core advantage of this invention lies in constructing an integrated quantization pipeline encompassing "numerical distribution analysis, selective Hadamard transform, rate-distortion calibration, and integer inference deployment." This scheme can utilize Hadamard transform to smooth outliers and reduce quantization scale sensitivity, while avoiding the extremum amplification problem introduced by the unified transform strategy in some layers. Furthermore, by combining rate-distortion joint calibration and hardware-friendly offline weight folding, the quantization model becomes compatible with TensorRT, mobile NPUs, edge AI chips, and other general-purpose integer inference backends.

[0041] The beneficial effects of this invention include: reducing the bit rate and reconstruction distortion degradation introduced by low-bit integer quantization without changing the backbone structure of the learning-based image compression model; improving the stability of tensor activation quantization scenarios through selective Hadamard quantization; reducing additional computational redundancy through irregular channel dimension adaptation; and being compatible with both post-training quantization and quantization-aware training deployment paths, thereby improving the deployment efficiency and engineering feasibility of the learning-based image compression model on practical integer inference platforms. Attached Figure Description

[0042] Figure 1 This is a schematic diagram of the module composition and data flow of the selective Hadamard quantization system of the present invention.

[0043] Figure 2 A schematic diagram illustrating the floating-point equivalence relationship between a two-sided Hadamard quantization computation structure and a weighted Hadamard quantization computation structure.

[0044] Figure 3 This is a schematic diagram of the process for generating layer-by-layer quantization strategy labels based on calibration-paired samples.

[0045] Figure 4 This diagram illustrates the post-training quantization path, quantization-aware training path, and model deployment generation path under fixed-level policy label constraints. Detailed Implementation

[0046] The present invention will be further described below with reference to the accompanying drawings and embodiments. It should be understood that the embodiments are used to illustrate the technical solutions of the present invention, and not to limit the scope of protection. The learning-based image compression model in the embodiments may include at least one of the following: an analytical transform network, a synthetic transform network, a super-prior network, a context model, an entropy parameter estimation network, and an attention module.

[0047] This invention provides a selective Hadamard quantization method for learning-based image compression models.

[0048] like Figure 1 As shown, the method sequentially performs model and calibration data acquisition, Hadamard matrix construction, quantization sensitivity assessment, layer-by-layer quantization strategy determination, quantization computation graph generation, quantization parameter optimization, and deployment model generation. The layer-by-layer strategy labels are fixed after the quantization sensitivity assessment and serve as common control parameters for the subsequent quantization computation graph, quantization parameter optimization path, and deployment operator structure.

[0049] Step 1: Model and calibration data acquisition.

[0050] Step 1.1: Obtain the pre-trained floating-point learning-based image compression model, calibration image set, and quantization configuration. The calibration image set can be selected from the training set or an independent calibration set, and should cover the main image content and resolution range in the proposed deployment scene.

[0051] Step 1.2: Analyze the model computation graph to determine the neural network operator layer to be quantized. The operator layer may include convolutional layers, deconvolutional layers, subpixel convolutional layers, linear layers, attention projection layers, feature fusion layers, or entropy parameter generation layers. For operators that directly receive the original image and whose numerical range is determined by the input specification, they can be excluded from the Hadamard transform range based on the quantization configuration.

[0052] Step 1.3: Record the input feature dimension, output feature dimension, weight and bias shape, activation shape, quantization bit width, and quantization granularity by tensor or by channel for each layer to be quantized, and establish the correspondence between the layer identifier and the above parameters.

[0053] Step 2: Construct the Hadamard matrix.

[0054] Step 2.1, for any real dimension to be transformed Never less than Furthermore, the order n after completion is determined from the candidate orders that satisfy the construction conditions of the Hadamard matrix, and the normalized Hadamard matrix is ​​constructed. .when Dimension completion is not performed at times; when At that time, add to the end of the corresponding feature dimension Each dimension has a zero value, and the same fill position is maintained during subsequent transformation, quantization, and deployment phases.

[0055] When the order is complete, the following condition is met. When using the Sylvester construct, m is a non-negative integer representing the order after padding. The second power exponent. A Sylvester-type normalized Hadamard matrix satisfies:

[0056] ,

[0057] in, This represents the Kronecker product.

[0058] When there exists a satisfying A prime power of q, and whose order satisfies the condition after completion. When, the Paley I method is used to construct a normalized Hadamard matrix; when there exists a condition satisfying... A prime power of q, and whose order satisfies the condition after completion. When a normalized Hadamard matrix is ​​generated, Paley II is used; where q represents a prime power satisfying the corresponding congruence condition. When there is no available Paley construct order less than the least square order, n is determined to be a least square order not less than C, and Sylvester is used for construction.

[0059] Step 2.2: Perform row sign normalization and column sign normalization on the constructed normalized Hadamard matrix, and set all positive basis vectors in predetermined columns. The normalized Hadamard matrix satisfies:

[0060] ,

[0061] in, express The transpose of the matrix, This represents an n-order identity matrix.

[0062] Step 2.3: Record the original dimension C, the order n after padding, the Hadamard matrix construction method, and the number of new dimensions for each dimension to be transformed. The padding position and the column containing all positive basis vectors are specified. For the same layer to be quantized, the same order of padding, construction method, sign normalization method, and padding position are used in the sensitivity assessment, post-training quantization, quantization-aware training, and deployment stages.

[0063] Step 3: Quantitative sensitivity assessment.

[0064] Step 3.1, for the first Layer and k-th calibration image, save the original input activation tensor during the same data acquisition process. Without rewriting the original model parameters, the normalized Hadamard transform is simulated offline using the input-side orthogonal matrix constructed in step 2 to obtain the simulated transform activation tensor. .in, Indicates the application to the first The normalized Hadamard transform operator for layer input activation. The original input activation tensor and the analog transformation activation tensor share the same sample source and layer source, forming a pair of samples.

[0065] Step 3.2 calculates the maximum absolute value of each channel, the global maximum absolute value, the channel mean, the extreme value increment, and the extreme value amplification ratio for each paired sample group. It also calculates the excess kurtosis change before and after the transformation to help characterize the heavy-tailed distribution and the dominance of outliers. The excess kurtosis change and the mean coherence component serve as explanatory and auxiliary verification indicators, and the hierarchical strategy label is determined based on the comparison between the extreme value amplification probability and a preset threshold.

[0066] Step 3.3: Summarize the statistical results of the same layer to be quantized on all calibration images layer by layer to form a layer-by-layer quantization sensitivity evaluation result. The evaluation result includes at least the extreme value increment, extreme value amplification ratio, extreme value amplification event identifier, extreme value amplification probability of the layer, and mean coherence component for each sample.

[0067] Step 4: Determine the layer-by-layer quantization strategy.

[0068] Step 4.1, as follows Figure 3As shown, for the first Layer and first The extreme value increment is calculated from the calibrated image based on the original input activation tensor and its analog transformation activation tensor.

[0069] The extreme value increment is defined as:

[0070] ,

[0071] The extreme value amplification ratio is defined as:

[0072] ,

[0073] in, Indicates the application to the first Normalized Hadamard transform operator activated by layer input, Indicates the first Zhang calibration image in the first The input activation tensor generated by the layer, This represents a preset positive number used to prevent the denominator from being zero. This indicates taking the maximum absolute value of all elements in the tensor.

[0074] The probability of extreme value amplification is defined as:

[0075] ,

[0076] Where N represents the total number of calibration images, This indicates an indicator function; its value is 1 when the condition within the parentheses is true, and 0 otherwise. The extreme value amplification probability measures the recurrence of the event in the calibration samples where the Hadamard transform on the activation side leads to an increase in the global maximum absolute value. When... When, it means that the global maximum absolute value of the paired sample after the Hadamard transform is greater than the global maximum absolute value before the transform.

[0077] Step 4.2, define the all-positive column basis vectors in the normalized Hadamard matrix corresponding to the right multiplication direction of the input matrix as:

[0078] ,

[0079] Where C represents the dimension in which the Hadamard transform is actually performed; when dimension padding exists, C takes the order n after padding. For channel vectors represented as column vectors... Its projection onto the directions of all positive basis vectors is:

[0080] ,

[0081] in, This represents the element value corresponding to the j-th channel in the channel vector x. This represents the channel mean of the channel vector. The absolute value of the projection. It is also defined as the mean coherent component, used to explain and assist in verifying the dynamic range expansion caused by the coherent superposition of non-zero channel means in the direction of all positive basis vectors.

[0082] Step 4.3, according to the first Extreme value amplification probability of layer and preset strategy threshold Determine the hierarchical quantization strategy label for this layer:

[0083] ,

[0084] in, Indicates the first Layer-level quantization strategy labels This represents the preset extreme value amplification probability threshold. The label W indicates a weighted Hadamard quantization strategy, and the label D indicates a two-sided Hadamard quantization strategy.

[0085] Step 5: Generate the quantization calculation graph.

[0086] Step 5.1: After unfolding the convolution sliding window and the batch and spatial positions, represent the original convolution operator in matrix multiplication form. Let the number of spatial positions of the convolution kernel, the number of true input channels, and the number of output channels be respectively... , and The input feature dimension after convolution unwinding is The rows of the input activation matrix correspond to the expanded sample positions, and the columns correspond to the combination of the convolution kernel spatial position and the real input channel. The rows of the weight matrix correspond to the same expanded features, and the columns correspond to the output channels.

[0087] The first The layer input activation matrix, weight matrix, and output matrix are denoted as follows: , and Input channel Hadamard matrix The matrix acting on the true input channel dimension; for convolutional layers, the equivalent matrix acting on the expanded feature dimension is... Output channel Hadamard matrix The order is .

[0088] Step 5.2, as follows Figure 2 As shown, when the hierarchical policy label is two-sided Hadamard quantization, the orthogonality of the input channel Hadamard matrices is used to insert mutually canceling orthogonal transformations between the input activations and weights. The corresponding floating-point calculation is expressed as follows:

[0089] ,

[0090] Define a signed b-bit symmetric quantization function as:

[0091] ,

[0092] Where z represents the floating-point tensor to be quantized, b is the quantization bit width, and s is the quantization scale. This indicates that the integer result is restricted to a range of signed b-bit integers. ]Inside, This indicates rounding to the nearest integer. When using channel-wise quantization, s is a scale vector composed of the quantization scales of each channel, and division and scale recovery are performed element-wise for each corresponding channel.

[0093] The integer activation operands, integer weight operands, integer summation result, and approximate output of two-sided Hadamard quantization are as follows: , , in, Indicates the first The integer activation operands of the layer are obtained by input-side Hadamard transform and quantization in the dual-sided Hadamard quantization mode. Indicates the first The integer weight operands of the layer are obtained by inverse Hadamard transform and quantization on the input side in dual-sided Hadamard quantization mode. This represents the integer summation result obtained by multiplying and summing the integer activation operand and the integer weight operand; This represents the approximate output obtained by scaling the integer accumulation result according to the active quantization scale and the weighted quantization scale; the superscript D indicates the two-sided Hadamard quantization mode; Indicates the first The quantization scale of the input activation after layer transformation; Indicates the first The quantization scale of weights after layer transformation.

[0094] The integer accumulation result Calculations are performed using an INT32 integer accumulator or an integer accumulator with a width greater than the input operands. When the... When a layer contains biases, the biases can be quantized to the level of biases. After determining the accumulation scale, add the integer accumulation result, or add the bias in floating-point or high-precision fixed-point form after scale recovery.

[0095] Step 5.3: When the hierarchical strategy label is weighted Hadamard quantization only, the input-side Hadamard transformation is not performed on the input activation. Instead, the weights are transformed offline along the output channel dimension, and the corresponding inverse transformation is performed on the layer output side.

[0096] The floating-point equivalence relation for a weighted Hadamard structure is:

[0097] ,

[0098] The integer activation operands, integer weight operands, integer summation result, and approximate output for weighted Hadamard quantization are as follows:

[0099] ,

[0100] in, Indicates the first In the weighted Hadamard quantization mode, the number of integer activation operands is obtained by directly quantizing the original input activation. Indicates the first The integer weight operands obtained by Hadamard transforming and quantizing the output channel in the weight-only Hadamard quantization mode; This represents the integer summation result obtained by multiplying and summing the integer activation operand and the integer weight operand; This represents the approximate output obtained by scaling the integer accumulation result and performing an inverse Hadamard transform on the output side; superscript This indicates a weighted Hadamard quantization pattern. Indicates the first Quantization scale of the original input activation of the layer; Indicates the first The weight quantization scale after the layer undergoes Hadamard transformation in the output channel.

[0101] When the The layer contains biases represented by row vectors. At that time, the bias is transformed offline as follows:

[0102] ,

[0103] ,

[0104] in, This represents the transform bias in the Hadamard domain of the output channel. The transform bias can be added after quantization to the accumulation scale corresponding to the integer accumulation result, or it can be added in a high-precision form after scale restoration and before the inverse Hadamard transformation on the output side.

[0105] In weighted Hadamard quantization only, "weighted only" means that the input activation side does not perform the Hadamard transform, but it does not mean that the output-side inverse Hadamard transform required to maintain floating-point equivalence is omitted. The Hadamard transforms of weights and biases are performed offline before model derivation; the normalization factor in the output-side inverse transform is incorporated into the quantization scale or integer rescaling coefficients; Hadamard sign matrix multiplication is implemented through fixed addition and subtraction, and is merged with the weights of subsequent linear operators when the linear fusion condition is met.

[0106] Step 5.4, as follows Figure 4 As shown, under the constraint of fixed-level quantization strategy labels, the system generates post-training quantization paths and quantization-aware training paths respectively. The post-training quantization path optimizes the quantization parameters without updating the main parameters of the floating-point model; the quantization-aware training path simulates low-bit integer computation errors through pseudo-quantization nodes and updates the model parameters and quantization parameters. After the quantization parameters are optimized, the system performs offline weight transformation, offline bias transformation, fixed inverse transformation fusion, dimension completion processing, and integer deployment model export.

[0107] Step 6: Quantize the training after rate distortion across the entire network.

[0108] Step 6.1: After fixing the hierarchical strategy labels and quantization calculation graph, at least one of the following parameters for each layer to be quantized is used to form a set of full-network quantization parameters: weight quantization scale, activation quantization scale, truncation threshold, or rounding parameter. Then, joint optimization of the entire network is performed on the calibration image set.

[0109] The joint optimization objective for rate-distortion across the entire network can be expressed as:

[0110] ,

[0111] in, Let U represent the set of quantization parameters for the entire network to be optimized, U represent the calibration image set, R represent the bitrate estimated by the entropy model of the learned image compression model or obtained by actual encoding, and D represent the distortion between the input image and the image reconstructed by the quantization model. This indicates that the quantization model is based on the set of quantization parameters. The reconstructed image generated from the input image x is as follows. Represents the rate-distortion tradeoff parameter.

[0112] The bit rate can be represented by the total number of bits, the number of bits per pixel, or the negative log-likelihood calculated by a probability model. The distortion can be represented by mean squared error, loss based on multi-scale structural similarity, perceptual loss, or a combination of the above. By jointly optimizing the quantization parameters of the entire network, the quantization errors generated by different layers to be quantized are adjusted together in the complete encoding and decoding link according to a unified rate-distortion target.

[0113] Step 7: Quantitative perception training with anomalous scale blocking.

[0114] Step 7.1: Insert static symmetric pseudo-quantization nodes into the fixed-level strategy labels and corresponding quantization calculation graphs. Forward propagation uses pseudo-quantization results to simulate low-bit integer errors, while backpropagation uses a pass-through estimator for rounding operations and updates model parameters based on the rate-distortion loss of the learned image compression model.

[0115] Step 7.2, for the first Calculate the candidate activation quantization scale for the activation tensor generated by layer in the t-th training batch:

[0116] ,

[0117] in, Indicates the quantization scale of candidate activations. Indicates activation tensor The maximum absolute value of all elements in the quantization set, where b represents the activation quantization bit width. When using channel-based activation quantization, the corresponding candidate activation quantization scale is calculated separately for each channel.

[0118] Step 7.3, quantize the candidate activation scale Compared with the previous running activation quantization scale Compare and update according to the following segmentation rules:

[0119] ,

[0120] ,

[0121] in, Indicates the first The layer's activation quantization scale is updated after the t-th training batch. Indicates the momentum coefficient. This represents the anomaly fold threshold. When the candidate activation quantization scale does not exceed the running scale before the update... When the time factor increases, the operating scale is updated using the Exponential Moving Average (EMA) method; when the candidate activation quantization scale exceeds the operating scale before the update... When the scale is increased by a factor of 1, the current training batch is deemed to have an abnormal scale, and the scale update for that run is blocked to prevent occasional activation peaks from significantly increasing the static quantization interval shared by subsequent training batches and inference samples. In this case, the initial running activation quantization scale is set to the first candidate activation quantization scale, or to an initial scale pre-calculated using the calibration image set. For channel-based quantization, the comparison and update rules are applied to the running quantization scale corresponding to each channel.

[0122] Step 7.4: After training is complete, freeze the activation quantization scale for each layer and use the frozen scale for pseudo-quantization and inference quantization of the corresponding layer. Abnormal scale blocking only affects quantization scale updates and does not change the layer policy labels determined in Step 4.

[0123] In one embodiment, the quantization bit width b is 8, and the momentum coefficient... Set the threshold to 0.99 for abnormal multiples. Set the value to 15. The above values ​​can be set based on training stability, target bit width, and deployment data distribution.

[0124] Step 8: Generate deployment model.

[0125] Step 8.1: The deployment model generation module performs offline Hadamard transform on the weight side and the bias side according to a fixed hierarchical quantization strategy label, and performs INT8 or other integer low-bit quantization on the transformed weights. For input channel dimension padding, the newly added dimension remains consistent in the input activation and weight mapping; for output channel dimension padding, the newly added channel remains consistent in the weight, bias, and output mapping, and is pruned at a predetermined position after the output-side inverse Hadamard transform is completed.

[0126] Step 8.2: For the bilateral Hadamard quantization layer labeled D with a hierarchical quantization strategy, a fixed activation-side Hadamard transform is performed at runtime along the input feature dimension. Integer convolutions or integer matrix multiplications use offline weights after the corresponding inverse Hadamard transform. The activation-side Hadamard transform is implemented through a fixed-parameter 1×1 convolution, a linear operator, a fast Hadamard transform, or an equivalent operator consisting of addition, subtraction, and scale merging.

[0127] Step 8.3: For the weight-only Hadamard quantization layer with the hierarchical quantization strategy label W, the input activation is maintained during runtime, and the input-side Hadamard transformation is not performed. Integer convolution or integer matrix multiplication uses the weights after offline transformation along the output channel dimension, and the result is performed on the output side of the integer accumulation result. The corresponding fixed inverse Hadamard transform. When subsequent operators satisfy the linear fusion condition, the output-side inverse Hadamard transform is incorporated into the weights of the subsequent linear operators.

[0128] The normalized Hadamard matrix can be represented as the product of the sign matrix and the normalization factor. During deployment, the normalization factor is incorporated into the activation quantization scale, weighted quantization scale, or integer rescaling coefficients, and the sign matrix multiplication is implemented using fixed addition and subtraction, thereby avoiding the execution of general floating-point matrix multiplication at runtime.

[0129] Step 8.4: Based on the frozen quantization scale, integer weights, integer biases, padding information, and fixed transformation structure, the determined quantization computation graph is exported to TensorRT, mobile neural network processors, edge AI processors, or other backends that support integer inference. The hierarchical quantization strategy labels are converted into corresponding fixed operator structures during the model export stage, eliminating the need for re-collecting activation data, calculating sensitivity metrics, or performing hierarchical strategy judgments for input samples during the inference stage.

[0130] In one set of embodiments, Cheng2020 and ELIC were selected as the learning-based image compression models to be quantized. Weights were quantized per output channel, and activations were quantized per tensor. For hierarchical policy evaluation, 1000 images were randomly selected from the training data, and a preset probability threshold of 0.8 was set. Post-training quantized full-network rate-distortion joint calibration used independent calibration images. In the experiments, the transformation activation of most layers to be quantized showed a reduction in outliers, while extreme value amplification events in a few layers repeatedly occurred in a large number of calibration samples. These layers were therefore identified as activation amplification-sensitive layers and switched to weight-only Hadamard quantization.

[0131] Table 1. Changes in BD-rate of different learned image compression models and quantization paths relative to their corresponding FP32 models.

[0132]

[0133] In Table 1, a negative BD-rate indicates an average bitrate saving compared to the corresponding FP32 model under the same reconstruction quality, while a positive BD-rate indicates an increase in average bitrate. For example, for quantization-aware training of Cheng2020, when using bilateral Hadamard quantization uniformly across all layers, the BD-rate on the Kodak dataset increases by 9.30%; after adopting the layer-by-layer strategy selection of this invention, the BD-rate improves from +9.30% to −1.84%, indicating that the improvement in quantization performance comes from the combination of layer-by-layer sensitivity assessment and two types of fixed computation graphs.

[0134] Table 2. Memory, latency, and rate-distortion performance under TensorRT deployment conditions.

[0135]

[0136] In the deployment embodiment with a fixed input resolution of 768×512, the weight-side Hadamard transform is performed before model derivation, and the activation-side transform is implemented using a fixed linear operator. The results listed in Table 2 show that the INT8 deployment model of this invention improves reconstruction quality and reduces the bit rate compared to the baseline INT8 quantization model. Due to the implementation of the fixed activation-side transform, its inference latency is higher than the baseline INT8 model, but still lower than the original FP32 model, demonstrating a feasible trade-off between rate-distortion performance and deployment overhead.

[0137] In the calibration phase, this invention first constructs an input-side normalized Hadamard matrix based on the channel dimension and convolutional kernel spatial size of the layer to be quantized. Then, for the same calibration image and the same neural network operator layer to be quantized, it obtains the original input activation tensor and the activation tensor after offline simulation of applying the input-side Hadamard transform, and compares the two in pairs. The simulated transformation activation tensor is only used to evaluate the possible numerical impact of the input-side Hadamard transform and does not change the original model output of this calibration forward process.

[0138] This invention calculates the extreme value increment, extreme value amplification ratio, and extreme value amplification probability across calibration samples based on paired comparison results, and calculates the mean coherence component of the channel mean in the direction of the all-positive Hadamard vector, forming a layer-by-layer quantization sensitivity assessment result. The hierarchical strategy label is determined according to the comparison result of the extreme value amplification probability and the preset threshold, and the mean coherence component is used to explain and assist in verifying the source of extreme value amplification.

[0139] After determining the layer-by-layer quantization strategy, this invention selects one of two mathematically equivalent fixed computational structures in the floating-point computation domain: the stabilizing layer employs a two-sided Hadamard computation structure, applying mutually canceling orthogonal transformations to activations and weights in the input feature dimension; the activation amplification sensitive layer employs a weight-only Hadamard computation structure, transforming weights offline in the output channel dimension and performing the corresponding inverse transformation on the layer output side. Thus, strategy selection occurs during the offline evaluation phase, and the resulting layer-by-layer strategy labels remain unchanged throughout the steps involving quantization and inference deployment.

[0140] The present invention also provides a selective Hadamard optimization quantization system for implementing the method in a learning-oriented image compression model, including a model and calibration data acquisition module, a Hadamard matrix construction module, a quantization sensitivity evaluation module, a layer-by-layer quantization strategy determination module, a quantization calculation graph generation module, a quantization parameter optimization module, and a deployment model generation module.

[0141] The model and calibration data acquisition module is used to acquire the learning-based image compression model to be quantized, the calibration image set and the quantization configuration, parse the neural network operator layer to be quantized in the model, and record the input feature dimension, output feature dimension, weight tensor shape, activation tensor shape, quantization bit width and quantization granularity of each layer.

[0142] The quantization sensitivity evaluation module is used to send the same calibration activation data into the original calculation path without input-side Hadamard transformation and the evaluation path with offline simulated input-side Hadamard transformation, respectively, and to perform paired comparison of the activation data before and after the transformation.

[0143] The quantization sensitivity assessment module is also used to calculate the extreme value increment, extreme value amplification ratio, extreme value amplification probability, and mean coherence component corresponding to the all-positive Hadamard vector, and to summarize the results of layer-by-layer quantization sensitivity assessment according to the operator layer of the neural network to be quantized; it can also calculate the excess kurtosis change as an auxiliary statistic.

[0144] like Figure 3As shown, the layer-by-layer quantization strategy determination module is used to compare the extreme value amplification probability of each layer to be quantized with a preset probability threshold to determine the corresponding layer strategy label; the layer with the extreme value amplification probability higher than the preset probability threshold is determined as the activation amplification sensitive layer and uses weighted Hadamard quantization only, and the other layers are determined as stable layers and use two-sided Hadamard quantization.

[0145] like Figure 2 As shown, the quantization computation graph generation module generates corresponding quantization computation graphs based on fixed hierarchical strategy labels: for bilateral Hadamard quantization, mutually canceling orthogonal transformations are inserted into the input feature dimension; for weight-only Hadamard quantization, the weights are transformed in the output channel dimension, and corresponding inverse transformations are set on the layer output side. Both computation graphs are mathematically equivalent to the original operators in the floating-point computation domain.

[0146] like Figure 4 As shown, the quantization parameter optimization module is used to perform post-training quantization while keeping the quantization computation graph unchanged, and aims to optimize the weight quantization scale, truncation threshold or rounding parameters of each layer to be quantized with the goal of the full network rate-distortion (RD) loss of the learned image compression model.

[0147] The quantization parameter optimization module is also used to perform quantization-aware training. In forward propagation, static symmetric pseudo-quantization is used, and in backpropagation, a pass-through estimator is used for rounding operations. When the quantization scale of the candidate activations in the current training batch exceeds the upper limit determined by the historical operating scale and the abnormal multiple threshold, the historical operating scale is kept unchanged to reduce the impact of occasional abnormal activations on the static quantization scale.

[0148] The deployment model generation module is used to complete the weight-side Hadamard transform and low-bit quantization offline before model deployment, convert the hierarchical policy labels into a defined operator structure, and implement the activation-side transform or output-side inverse transform into a fixed linear operator, a fast Hadamard transform operator, or an equivalent structure fused with adjacent linear operators, to generate an integer low-bit deployment model that does not contain input-related dynamic branches.

[0149] This invention also provides a computer program product, whose computer program or instructions, when executed by a processor, complete the acquisition of model and calibration data, quantization sensitivity assessment, determination of layer-by-layer quantization strategy, generation of quantization calculation graph, optimization of quantization parameters and generation of deployment model, and output an integer low-bit learning image compression model.

[0150] The above embodiments are only used to illustrate the technical solutions of the present invention. Those skilled in the art can adjust or equivalently replace the learning image compression model type, the range of operators to be quantized, the Hadamard matrix construction method, the number of calibration images, the preset probability threshold, the quantization bit width, the quantization granularity, the rate-distortion loss form, the anomaly multiple threshold, and the deployment operator implementation method without departing from the technical concept of the present invention.

Claims

1. A selective Hadamard quantization method for learning-based image compression models, characterized in that, Includes the following steps: Step 1: Obtain the learning-based image compression model to be quantized, the calibration image set, and the quantization configuration; parse the learning-based image compression model; and determine the neural network operator layer to be quantized. Step 2: Based on the number of input channels, the number of convolution kernel spatial positions, and the number of output channels of the neural network operator layer to be quantized, construct the input channel Hadamard matrix and the normalized output channel Hadamard matrix; for the convolutional layer, expand the input channel Hadamard matrix according to the spatial position of the convolution kernel into an equivalent orthogonal matrix that acts on the feature dimension of the convolution unfolding. Step 3: For the same calibration image and the same neural network operator layer to be quantized, acquire the original input activation tensor and use an equivalent orthogonal matrix to simulate the Hadamard transform offline to obtain the simulated transformation activation tensor that corresponds one-to-one with the original input activation tensor. Step 4, for the first Layer, First Calculate the extreme value increment using paired samples of the calibrated image. Extreme value amplification ratio and the probability of extreme value amplification And calculate the mean coherent component corresponding to the all-positive Hadamard vector to form a layer-by-layer quantization sensitivity assessment result; Step 5: Determine the hierarchical strategy labels ; Step 6, when When performing two-sided Hadamard quantization, an orthogonal transformation is inserted into the input channel and the activation and weights are quantized separately to achieve integer approximation of floating-point calculations; Step 7, when When performing weighted Hadamard quantization, the input remains unchanged, and Hadamard transformation and quantization are performed on the weights and output to achieve integer approximation calculation only on the weight side. Step 8: After the quantization operator topology of the corresponding layer is uniquely determined by the hierarchical policy label, perform full network rate-distortion post-training quantization or quantization-aware training with abnormal scale blocking, and transform the fixed policy label into an integer low-bit deployment graph without input-related dynamic branches.

2. The method according to claim 1, characterized in that, In step 2, construct a structure that satisfies the orthogonal normalization condition. input channel Hadamard matrix and normalized output channel Hadamard matrix Where H represents the Hadamard matrix, express An identity matrix of order T, where the superscript T denotes transpose; For any dimension to be transformed From satisfying the Hadamard matrix construction conditions and not less than Choose the completed order from the candidate orders. ;when The Hadamard matrix is ​​constructed using Sylvester, where It is a non-negative integer; when there exists a prime power. Paley I is used to construct the Hadamard matrix, and mod is the remainder function; when a prime power exists... The Hadamard matrix is ​​constructed using Paley II; when no smaller Paley order is available, it is regressed to a value not less than 1. The least second power order is obtained and the Hadamard matrix is ​​constructed using Sylvester; the positive basis vectors are placed in fixed columns by normalizing the row and column signs.

3. The method according to claim 2, characterized in that, In step 4, for the first Layer and first Zhang calibration images, each defining the transformed global maximum absolute value. and the global maximum absolute value before transformation for The extreme value increment is The extreme value amplification ratio is The probability of extreme value amplification is ;in, Indicates the application to the first Transform operators activated by layer input, Indicates the first Zhang calibration image in the first The input activation generated by the layer, This represents a preset positive number used to prevent the denominator from being zero. Indicates the total number of calibration images. Indicates an indicator function.

4. The method according to claim 3, characterized in that, In step 4, the all-positive column basis vectors corresponding to the right multiplication direction of the input matrix in the normalized Hadamard matrix are... Defined as For channel vectors When represented as a column vector The projection along the directions of all positive basis vectors is The absolute value of the projection As a mean coherent component, it is used to explain and assist in verifying the dynamic range expansion caused by the mean of non-zero channels; the hierarchical strategy label is still determined according to the comparison result of the extreme value amplification probability and the preset threshold; where C represents the dimension of the actual Hadamard transformation performed. When there is no dimension padding, C is the original dimension to be transformed; when there is dimension padding, C is the order after padding in step 2. , Represents channel vector The Middle The element value corresponding to each channel Represents channel vector The channel mean.

5. The method according to claim 4, characterized in that, In step 5, With preset threshold Compare and determine the hierarchical strategy labels. ;when hour, For weighted Hadamard quantization only; when hour, For bilateral Hadamard quantification.

6. The method according to claim 5, characterized in that, In step 6, the hierarchical strategy label-controlled operator graph generator inserts mutually canceling orthogonal transformations in the input channel dimension to ensure that floating-point calculations satisfy... And quantize the transformation activation and transformation weights respectively, where Indicates the first The input activation matrix of the layer to be quantized Indicates the first The weight matrix of the layer to be quantized Indicates the first The output matrix of the nth layer to be quantized; the nth... The number of spatial locations of the convolution kernel is denoted as The actual number of input channels and the number of output channels are denoted as follows: and The input feature dimension after convolution unwinding is The input activation matrix after the convolution sliding window is unwound. Weight matrix and output matrix Each satisfies , and , where M represents the total number of sample positions after the convolution sliding window is expanded; The input channel Hadamard matrix satisfies The equivalent input-side matrix acting on the feature dimension of the convolution is: ;in, express An identity matrix of order 1. Represents the Kronecker product; The integer activation operands, integer weight operands, integer summation result, and approximate output of two-sided Hadamard quantization are as follows: , , as well as ;in, Indicated according to quantitative scale Execution of signed Bit-symmetric quantization Represents the space of real numbers. Indicates the first In the dual-sided Hadamard quantization mode, the integer activation operands are obtained by input-side Hadamard transform and quantization. Indicates the first In the dual-sided Hadamard quantization mode, the integer weight operands are obtained by inverse Hadamard transform and quantization on the input side. Indicates that the operand is activated by an integer. With integer weight operands The integer sum of the multiplication and addition results in the following: Represents the result of accumulating integers. The approximate output obtained after scaling based on the activation quantization scale and the weighted quantization scale. Indicates the first Layer activation quantization scale, Indicates the first The weight quantization scale after layer transformation.

7. The method according to claim 6, characterized in that, In step 7, keep Without performing the input channel Hadamard transform, Offline transformation along the output channel dimension And execute on the output side of the operator layer of the neural network to be quantized. To make floating-point calculations satisfy ; The output channel Hadamard matrix satisfies The integer operands, integer summation result, and approximate output of weighted Hadamard quantization are as follows: , , as well as ; When the operator layer contains biases represented by row vectors At that time, the bias offline transformation is performed. and satisfy ;in, Indicates the first Integer activation operands of the layer in weighted Hadamard quantization mode only. Indicates the first The integer weight operands of the layer after output channel Hadamard transform in weight-only Hadamard quantization mode. Indicates that the operand is activated by an integer. With integer weight operands The integer sum of the multiplication and addition results in the following: Represents the result of accumulating integers. The approximate output is obtained after scaling recovery and inverse Hadamard transform on the output side.

8. The method according to claim 7, characterized in that, In step 8, in the quantization perception training path, symmetric pseudo-quantization is used for forward computation, and the rounding operation in the pseudo-quantization process is backpropagated using a pass-through estimator. The model parameters are updated according to the rate-distortion loss of the learned image compression model. For the The layer in the first The activation tensor generated by each training batch Calculate the quantization scale of candidate activations for the current batch: ,in This represents the quantization scale of candidate activations calculated based on the activation tensor of the current batch; Update the following section format: Layer activation quantization scale: when hour, ;when hour, ;in, Indicates the first The layer activates the quantization scale during the run before the current batch update. Indicates the momentum coefficient. Indicates the threshold for abnormal multiples; After training, freeze the activation quantization scale of each layer, and then freeze the data. The activation quantization scale used for corresponding layer pseudo-quantization and inference quantization ;when When the initial run activation quantization scale is set to the first candidate scale or the scale predetermined by the calibration image set, the initial run activation quantization scale is set to the first candidate scale.

9. A selective Hadamard quantization system for implementing a learning-oriented image compression model as described in any one of claims 1 to 8, characterized in that, It includes a model and calibration data acquisition module, a Hadamard matrix construction module, a quantization sensitivity assessment module, a layer-by-layer quantization strategy determination module, a quantization calculation graph generation module, a quantization parameter optimization module, and a deployment model generation module; The model and calibration data acquisition module is used to acquire the learning image compression model to be quantized, the calibration image set and the quantization configuration, and to obtain the calibration activation data of each layer to be quantized through the learning image compression model. The Hadamard matrix construction module is used to construct input-side and output-side normalized Hadamard matrices based on the number of input channels, the number of convolutional kernel spatial locations, and the number of output channels of each layer to be quantized. The quantization sensitivity assessment module is used to input the same calibration activation data into the original assessment path without Hadamard transformation and the simulated assessment path after input-side Hadamard transformation, respectively. It performs pairwise comparison of the activation data before and after transformation, calculates the extreme value increment, extreme value amplification ratio, extreme value amplification probability and mean coherence component, and summarizes the results layer by layer to obtain the quantization sensitivity assessment results. The layer-by-layer quantization strategy determination module is used to compare the extreme value amplification probability of each layer to be quantized with a preset probability threshold, and determine the corresponding layer strategy label for each layer to be quantized based on the comparison result. The hierarchical strategy label is determined based on the pairing comparison results of the same calibration activation data before and after the Hadamard transformation; The quantization computation graph generation module is used to select one of two mathematically equivalent computation structures in the floating-point computation domain as the computation graph of the corresponding quantization layer according to the hierarchical strategy label of each layer to be quantized; for the layer to be quantized where the extreme value amplification probability is not higher than a preset probability threshold, a two-sided Hadamard computation structure is generated that applies mutually canceling Hadamard transforms to the input activation and weights respectively in the input feature dimension; for the layer to be quantized where the extreme value amplification probability is higher than the preset probability threshold, a computation structure is generated that applies Hadamard transform to the weights and applies the corresponding inverse transform to the layer output in the output channel dimension. The quantization parameter optimization module is used to perform full-network post-training quantization with rate-distortion loss as the optimization objective, or to perform quantization-aware training, under the condition that the quantization calculation graph remains unchanged; during the quantization-aware training process, when the candidate activation quantization scale of the current training batch exceeds the abnormal multiple threshold determined based on the historical activation quantization scale, the historical activation quantization scale is kept unchanged. The deployment model generation module is used to perform offline Hadamard transformation and low-bit quantization on the weights before model deployment, convert the hierarchical policy labels of each layer to be quantized into corresponding fixed operator structures, and generate a low-bit integer deployment model that does not contain conditional branches that dynamically select quantization strategies based on input data.

10. An electronic device, characterized in that, It includes a processor and a memory, the memory storing program code that, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1 to 8.