Visual model quantification method and device based on non-uniform and spatial perception characteristics
By employing a hybrid quantization strategy that dynamically and adaptively divides sensitive regions using quantizers and local variance, the problem of insufficient quantization level allocation in existing technologies is solved, achieving efficient model compression and accuracy preservation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INST OF SEMICONDUCTORS - CHINESE ACAD OF SCI
- Filing Date
- 2026-03-31
- Publication Date
- 2026-05-01
AI Technical Summary
Existing post-training quantization methods lack flexibility in quantization energy level allocation when quantizing activated data with non-uniform distribution characteristics, leading to a loss of accuracy after model compression.
A dynamic adaptive logarithmic quantizer is used to analyze the logarithmic frequency characteristics of the activated data. The sensitive regions are divided by local variance, and a hybrid adaptive quantization strategy is constructed to dynamically adjust the quantization energy level allocation. The dynamic adaptive logarithmic quantizer is used to improve accuracy in the high-sensitivity region, while the uniform quantizer reduces complexity in the low-sensitivity region.
While ensuring model accuracy, it achieves efficient model compression, improves the flexibility and efficiency of quantization level allocation, and maintains the model's excellent performance on edge devices.
Smart Images

Figure CN121962298A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of model quantization technology, and in particular to a visual model quantization method and apparatus based on non-uniformity and spatial perception characteristics. Background Technology
[0002] As a crucial compression step before model deployment, quantization technology significantly reduces the model's storage requirements and computational complexity by performing low-bit-width transformations on model weights and activation values. However, commonly used post-training quantization methods rely on fixed step sizes or uniform quantization level allocation when quantizing activated data with non-uniform distribution characteristics. This results in insufficient flexibility in quantization level allocation, leading to a significant loss of accuracy in the compressed model. Therefore, an effective solution is urgently needed to address these issues. Summary of the Invention
[0003] To address the aforementioned technical problems, this invention provides a visual model quantization method and apparatus based on non-uniformity and spatial perception characteristics.
[0004] The present invention provides a visual model quantization method based on non-uniformity and spatial perception characteristics, comprising: acquiring first activation data and second activation data corresponding to an initial visual model to be quantized, wherein the first activation data has non-uniform distribution characteristics and the second activation data has non-uniform distribution characteristics and spatial perception characteristics. A dynamic adaptive logarithmic quantizer is used to analyze the logarithmic domain frequency characteristics of the first activation data to quantize the first activation data, thereby obtaining the first quantized activation data. Based on the first activation data, the dynamic adaptive logarithmic quantizer is updated. Based on the local variance of the second activation data, the second activation data is divided into first sensitive region activation data and second sensitive region activation data. Based on the updated dynamic adaptive logarithmizer, the activation data of the first sensitive region is quantized, and the activation data of the second sensitive region is quantized using a standard uniform quantization strategy to obtain the second quantized activation data. Based on the first quantized activation data and the second quantized activation data, the quantized target visual model corresponding to the initial visual model is determined.
[0005] According to the present invention, a visual model quantization method based on non-uniformity and spatial perception characteristics is provided, wherein a dynamic adaptive logarithmic quantizer is used to analyze the logarithmic domain frequency characteristics of the first activation data to quantize the first activation data, thereby obtaining the first quantized activation data, comprising: Based on the scaling factor, the adaptive quantization base of the dynamic adaptive quantizer, and the integer step size, the first activation data is quantized to obtain the discrete index corresponding to the first activation data. Based on the scaling factor and the adaptive quantization basis, the discrete index corresponding to the first activation data is dequantized to obtain the first quantized activation data.
[0006] According to the present invention, a visual model quantization method based on non-uniformity and spatial perception characteristics is provided, wherein the first activation data is quantized based on a scaling factor, the adaptive quantization basis of the dynamically adaptive pair quantizer, and an integer step size to obtain a discrete index corresponding to the first activation data, comprising: Based on the scaling factor, the first activated data is scaled and truncated to obtain intermediate activated data. Based on the adaptive quantization basis and the integer step size, the logarithmic features of the intermediate activation data are discretely indexed to obtain the discrete index corresponding to the first activation data.
[0007] According to the present invention, a visual model quantization method based on non-uniformity and spatial perception characteristics is provided, wherein the discrete index corresponding to the first activation data is dequantized based on the scaling factor and the adaptive quantization basis to obtain the first quantized activation data, including: Based on the adaptive quantization basis, a lookup table is determined; Based on the lookup table and the scaling factor, the discrete index corresponding to the first activation data is dequantized using a lookup table method to obtain the first quantized activation data.
[0008] According to the present invention, a visual model quantization method based on non-uniformity and spatial perception characteristics is provided, wherein updating the dynamic adaptive logarithmic quantizer based on the first activation data includes: Based on the first activated data and the scaling factor, a logarithmic feature space mapping is performed to obtain the logarithmic feature representation of the first activated data; Based on the adaptive quantization basis, quantization basis search range, and logarithmic feature representation of the dynamically adaptive logarithmic quantizer, the adaptive quantization basis of the dynamically adaptive logarithmic quantizer is updated to obtain the updated dynamically adaptive logarithmic quantizer.
[0009] According to the present invention, a visual model quantization method based on non-uniformity and spatial perception characteristics is provided, wherein dividing the second activation data into first sensitive region activation data and second sensitive region activation data by using the local variance of the second activation data includes: Calculate the local variance of the second activated data based on a sliding window; A binary importance mask is constructed based on the adjusted threshold coefficient and the local variance of the second activation data; Based on the binary importance mask, a hybrid quantization mechanism is used to divide the second activation data into the first sensitive region activation data and the second sensitive region activation data.
[0010] According to the present invention, a visual model quantization method based on non-uniformity and spatial perception characteristics is provided, wherein the first sensitive region activation data is quantized based on the updated dynamic adaptive logarithmic quantizer, and the second sensitive region activation data is quantized using a standard uniform quantization strategy to obtain second quantized activation data, including: Based on the updated dynamic adaptive log quantizer, the activation data of the first sensitive region after the positive and negative branch separation processing is quantized to obtain the quantized activation data of the first sensitive region. Based on the bit width of uniform quantization, the scaling factor of uniform quantization, and the zero-point parameter of uniform quantization, the activation data of the second sensitive region is quantized using the standard uniform quantization strategy to obtain the quantized activation data of the second sensitive region. The quantized first sensitive region activation data and the quantized second sensitive region activation data are fused together to obtain the second quantized activation data.
[0011] According to the present invention, a visual model quantization method based on non-uniformity and spatial perception characteristics is provided. The step of quantizing the activation data of the first sensitive region after positive and negative branch separation processing based on the updated dynamic adaptive logarithmic quantizer to obtain the quantized activation data of the first sensitive region includes: A negative interval reparameterization strategy is adopted to perform positive and negative branch separation processing on the activation data of the first sensitive region, so as to obtain the non-negative part and the negative part of the activation data of the first sensitive region. Based on the updated dynamic adaptive logarithmic quantizer, the non-negative part and the negative part are quantized respectively to obtain the quantized non-negative part and the quantized negative part; Based on the reparameterization strategy, the non-negative value part and the negative value part after quantization are reconstructed to obtain the activation data of the first sensitive region after quantization.
[0012] According to the present invention, a visual model quantization method based on non-uniformity and spatial perception characteristics is provided. The method quantizes the activation data of the second sensitive region using a standard uniform quantization strategy, based on the bit width, scaling factor, and zero-point parameter of uniform quantization, to obtain the quantized activation data of the second sensitive region. The method includes: Based on the bit width of the uniform quantization, the scaling factor of the uniform quantization, and the zero-point parameter of the uniform quantization, the activation data of the second sensitive region is subjected to discrete index mapping to obtain the discrete index corresponding to the activation data of the second sensitive region. Based on the scaling factor and the zero-point parameter of the uniform quantization, the discrete index corresponding to the activation data of the second sensitive region is dequantized to obtain the quantized activation data of the second sensitive region.
[0013] The present invention also provides a visual model quantization device based on non-uniformity and spatial perception characteristics, comprising: The acquisition module is configured to acquire the first activation data and the second activation data corresponding to the initial visual model to be quantized. The first activation data has a non-uniform distribution characteristic, and the second activation data has a non-uniform distribution characteristic and a spatial perception characteristic. The first quantization module is configured to analyze the logarithmic domain frequency characteristics of the first activation data using a dynamic adaptive logarithmic quantizer to quantize the first activation data, obtain the first quantized activation data, and update the dynamic adaptive logarithmic quantizer based on the first activation data and the first quantized activation data. The partitioning module is configured to partition the second activation data into a first sensitive region activation data and a second sensitive region activation data based on the local variance of the second activation data. The second quantization module is configured to quantize the activation data of the first sensitive region based on the updated dynamic adaptive logarithmic quantizer, and to quantize the activation data of the second sensitive region using a standard uniform quantization strategy to obtain the second quantized activation data. The determination module is configured to determine the quantized target visual model corresponding to the initial visual model based on the first quantized activation data and the second quantized activation data.
[0014] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the visual model quantization method based on non-uniformity and spatial perception characteristics as described above.
[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the visual model quantization method based on non-uniformity and spatial perception characteristics as described above.
[0016] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the visual model quantization method based on non-uniformity and spatial perception characteristics as described above.
[0017] This invention provides a visual model quantization method and apparatus based on non-uniformity and spatial perception characteristics. The method involves acquiring first and second activation data corresponding to an initial visual model to be quantized. The first activation data exhibits non-uniform distribution characteristics, while the second activation data exhibits both non-uniform distribution and spatial perception characteristics. A dynamic adaptive logarithmic quantizer is used to analyze the logarithmic domain frequency characteristics of the first activation data to quantize it, resulting in first quantized activation data. Based on the first activation data, the dynamic adaptive logarithmic quantizer is updated. The second activation data is then divided into first sensitive region activation data and second sensitive region activation data based on the local variance. The first sensitive region activation data is quantized using the updated dynamic adaptive logarithmic quantizer, and the second sensitive region activation data is quantized using a standard uniform quantization strategy to obtain second quantized activation data. Finally, based on the first and second quantized activation data, the quantized target visual model corresponding to the initial visual model is determined. This invention utilizes a dynamic adaptive logarithmic quantizer to analyze the frequency characteristics in the logarithmic domain to adapt to the power-law-like distribution of activations, thereby enhancing the flexibility of quantization level allocation. Furthermore, it constructs a hybrid adaptive quantization strategy, employing a local optimal characteristic selection mechanism to analyze and divide regional sensitivity. In high-sensitivity regions, a dynamic adaptive logarithmic quantizer is used to improve accuracy, while in low-sensitivity regions, a computationally efficient uniform quantizer is used to reduce complexity. This achieves adaptive quantization of activation values with different distribution characteristics, ensuring model accuracy while achieving efficient model compression. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0019] Figure 1 This is a flowchart illustrating the visual model quantization method based on non-uniformity and spatial perception characteristics provided by the present invention.
[0020] Figure 2 This is a schematic diagram of the structure of the visual model quantization device based on non-uniformity and spatial perception characteristics provided by the present invention.
[0021] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0022] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0023] First, a brief description of the relevant content involved in this invention will be given.
[0024] Existing post-training quantization methods typically rely on fixed step sizes or uniform quantization level allocation. When quantizing activated data with non-uniform distribution characteristics, this results in insufficient flexibility in quantization level allocation, which significantly affects the accuracy preservation of the quantized model and thus restricts the deployment effect of the model on edge devices.
[0025] To address this technical problem, the present invention provides a visual model quantization method and apparatus based on non-uniformity and spatial perception characteristics. This method introduces a quantization strategy based on non-uniformity and spatial (important) perception characteristics. It not only improves the quantization accuracy for non-uniform distribution characteristics by dynamically and adaptively adapting the quantizer to the power-law-like distribution of activation, but also constructs a hybrid adaptive quantization mechanism that intelligently selects the quantization scheme based on regional sensitivity. This significantly improves quantization efficiency while ensuring model accuracy, enabling the model to maintain excellent performance even after compression.
[0026] The following is combined Figures 1 to 3 The present invention describes a visual model quantization method and apparatus based on non-uniformity and spatial perception characteristics.
[0027] Figure 1 This is a flowchart illustrating the visual model quantization method based on non-uniformity and spatial perception characteristics provided by the present invention, as shown below. Figure 1 As shown, the method includes: Step 101: Obtain the first activation data and the second activation data corresponding to the initial visual model to be quantized. The first activation data has a non-uniform distribution characteristic, and the second activation data has a non-uniform distribution characteristic and spatial perception characteristic. Step 102: Analyze the logarithmic domain frequency characteristics of the first activation data using a dynamic adaptive logarithmizer to quantize the first activation data, obtain the first quantized activation data, and update the dynamic adaptive logarithmizer based on the first activation data. Step 103: Based on the local variance of the second activation data, divide the second activation data into first sensitive region activation data and second sensitive region activation data; Step 104: Based on the updated dynamic adaptive log quantizer, quantize the activation data of the first sensitive region, and quantize the activation data of the second sensitive region using a standard uniform quantization strategy to obtain the second quantized activation data; Step 105: Based on the first quantized activation data and the second quantized activation data, determine the quantized target visual model corresponding to the initial visual model.
[0028] Specifically, the initial visual model is the visual model before quantization, and the target visual model is the visual model after quantization. The visual model can be a standard visual converter.
[0029] The basic building blocks of a standard visual transducer mainly consist of a multi-head self-attention module and a feedforward neural network module. The standard visual transducer includes four key linear projection layers and two core matrix operations. The four key linear projection layers include a query (Q) key (K) value (V) attention mechanism, a projection (Proj) module, a first fully connected (FC) layer FC1, and a second fully connected layer FC2. The two core matrix operations are denoted as the first matrix multiplication (MatMul1) and the second matrix multiplication (MatMul2).
[0030] Specifically, the first activation data is the activation data for the power-law distribution of the presentation, namely the post-softmax activation data; in the standard visual transformer, Post-Softmax is located between MatMul1 and MatMul2, and the Post-Softmax activation data corresponds to MatMul2.
[0031] The second activation data is the activated data that exhibits positive and negative asymmetry and spatial (local) heterogeneity, namely the Post Gaussian Error Linear Unit (Post-GELU) activation data; in the standard visual transducer, Post-GELU is located between FC1 and FC2, and the Post-GELU activation data corresponds to FC2.
[0032] The Dynamic Adaptive Logarithmic (DALog) quantizer can dynamically adapt to differences in activation distribution at different levels by adaptively searching for the optimal logarithmic basis.
[0033] Local variance is the variance calculated within a local window / neighborhood, used to measure the dispersion / drastic change of data within that local area.
[0034] The activation data for the first sensitive region is the activation data for the highly sensitive region in the second activation data, i.e., the activation data for the highly sensitive region; the activation data for the second sensitive region is the activation data for the low-sensitive region in the second activation data, i.e., the activation data for the low-sensitive region.
[0035] Existing methods have established relatively mature quantization paradigms for the weights and input activations of linear layers (such as QKV and FC1 layers). However, the feature distribution after activation exhibits significant non-uniformity, making efficient adaptive matching impossible. Quadratic matrix multiplication and the second fully connected layer also suffer from similar problems. Therefore, this invention provides a visual model quantization method based on non-uniformity and spatial perception characteristics, addressing the non-uniform distribution and spatial structural heterogeneity of two key activation types in visual models.
[0036] Specifically, an initial visual model to be quantized can be obtained first, and then first activation data (Post-Softmax activation data) with non-uniform distribution characteristics and second activation data (Post-GELU activation data) with non-uniform distribution characteristics and spatial perception characteristics can be obtained based on the initial visual model.
[0037] Because the first activated data exhibits a power-law-like long-tailed distribution in the [0,1] interval, the traditional logarithmic quantizer with base 2 (Log2) uses a fixed logarithmic base to non-uniformly divide the truncation interval, resulting in insufficient cross-layer distribution adaptability and difficulty in adaptively matching the non-uniform distribution characteristics of the activated data. To overcome the limitations of the fixed logarithmic base logarithmic quantizer, this invention employs a dynamic adaptive logarithmic quantizer for activated data exhibiting a power-law-like distribution. By analyzing its logarithmic domain frequency characteristics, the quantization basis is dynamically adjusted to achieve adaptive quantization level allocation for non-uniform distributions at different layers.
[0038] The dynamic adaptive logarithmic quantizer performs index quantization in the logarithmic domain using an adaptive quantization basis r and an integer step size q. By mining the statistical characteristics of the activation distribution within the layer, the quantization basis r is dynamically adjusted, thereby optimizing the distribution of quantization energy levels in the numerical space and making the quantization granularity adapt to the non-uniform spatial structural heterogeneity.
[0039] Specifically, a dynamic adaptive logarithmic quantizer can be used to analyze the logarithmic domain frequency characteristics of the first activation data to adapt to the power-law-like distribution of the activation, thereby quantizing the first activation data and enhancing the flexibility of quantization energy level allocation, and obtaining the first quantized activation data corresponding to the first activation data.
[0040] Furthermore, the adaptive quantization basis r of the dynamic adaptive logarithmic quantizer can be updated based on the first activation data to form the updated dynamic adaptive logarithmic quantizer.
[0041] Since the second activation data exhibits positive-negative asymmetry and spatial structural heterogeneity, a hybrid adaptive quantization strategy can be constructed. This strategy divides the high / low sensitivity regions by calculating local variance and uses dynamic adaptation to differentiate the quantizer and uniform quantizer. At the same time, the sign asymmetry problem is explicitly solved by negative reparameterization.
[0042] Specifically, the local variance of the second activation data is first calculated, and based on the local variance, the second activation data is divided into first sensitive region activation data and second sensitive region activation data. For the first sensitive region activation data, the updated dynamic adaptive quantizer is used for quantization, and for the second sensitive region activation data, a standard uniform quantization strategy is used for quantization, thereby obtaining the second quantized activation data corresponding to the second activation data.
[0043] Furthermore, based on the first quantized activation data and the second quantized activation data, the quantized target visual model corresponding to the initial visual model can be obtained.
[0044] The visual model quantization method provided by this invention, based on non-uniformity and spatial awareness characteristics, analyzes the frequency characteristics in the logarithmic domain through a dynamic adaptive logarithmic quantizer to adapt to the power-law-like distribution of activation, thereby enhancing the flexibility of quantization energy level allocation. Furthermore, it constructs a hybrid adaptive quantization strategy, utilizing spatial awareness characteristics to analyze and divide regional sensitivity. In high-sensitivity regions, a dynamic adaptive logarithmic quantizer is used to improve accuracy, while in low-sensitivity regions, a computationally efficient uniform quantizer is used to reduce complexity. This achieves adaptive quantization of activation values with different distribution characteristics, ensuring model accuracy while achieving efficient model compression.
[0045] Optionally, the step of using a dynamic adaptive logarithmic quantizer to analyze the logarithmic domain frequency characteristics of the first activation data to quantize the first activation data and obtain the first quantized activation data includes: Based on the scaling factor, the adaptive quantization base of the dynamic adaptive quantizer, and the integer step size, the first activation data is quantized to obtain the discrete index corresponding to the first activation data. Based on the scaling factor and the adaptive quantization basis, the discrete index corresponding to the first activation data is dequantized to obtain the first quantized activation data.
[0046] In practical applications, the quantization of the first activation data includes both the quantization process and the dequantization process.
[0047] During the quantization process, a learnable scaling factor can be introduced, combined with the adaptive quantization basis and integer step size of the quantizer, and the clamp (fixed) function is used to quantize the first activation data to obtain the discrete index corresponding to the first activation data, that is, the discrete index based on the continuous logarithmic feature map.
[0048] During the dequantization process, scaling factors and adaptive quantization bases can be used to dequantize the discrete index corresponding to the first activated data through reversible exponential mapping or by using a lookup table, thereby obtaining the first quantized activated data.
[0049] In this embodiment of the invention, by introducing a scaling factor and combining the adaptive quantization base and integer step size of the dynamic adaptive quantizer, the first activation data is quantized and dequantized, which can improve quantization efficiency and accuracy and achieve adaptive quantization energy level allocation for non-uniform distributions of different layers.
[0050] Optionally, the step of quantizing the first activation data based on the scaling factor, the adaptive quantization basis of the dynamically adaptive quantizer, and the integer step size to obtain the discrete index corresponding to the first activation data includes: Based on the scaling factor, the first activated data is scaled and truncated to obtain intermediate activated data. Based on the adaptive quantization basis and the integer step size, the logarithmic features of the intermediate activation data are discretely indexed to obtain the discrete index corresponding to the first activation data.
[0051] Specifically, the quantization process first introduces a learnable scaling factor, performing scale normalization and threshold truncation on the floating-point tensor to be quantized (the first activation number), as shown in the following formula:
[0052] in, The intermediate activation data is normalized and truncated, and it is normalized by a hierarchical scaling factor to eliminate the difference in numerical magnitude; X represents the original floating-point activation tensor to be quantized, i.e. the first activation data; S is a learnable scaling factor used to adjust the dynamic range of the input data, and s∈R+, where R+ is the set of positive real numbers. To prevent underflow parameters, and to prevent numerical underflow, and =1e-15; clamp(·) is the clamp (fixed) function, used to constrain normalized values to [ Within the closed interval [1.0], ensure that the value lies strictly within the effective domain of the logarithmic function.
[0053] Unlike logarithmic quantization with a fixed logarithmic base, the dynamic adaptive logarithmizer introduces a dynamic quantization basis *r* to adjust the discretization granularity of the logarithmic domain. During scale normalization and threshold truncation, the quantization process maps continuous logarithmic features to discrete indices, as shown in the following formula:
[0054] in, This represents the integer codeword index corresponding to the first activated data generated, i.e., the discrete index, which satisfies 0 ≤ k ≤ , b is the bit width, and b∈N, where N is a natural number; q is the integer step size (constraint), and , is used to ensure alignment in the hardware implementation, where r is the adaptive quantization basis. round(·) is the rounding function, which represents the rounding operation and is used to discretize the results of continuous domain calculations into integer codewords.
[0055] In this embodiment of the invention, by using scale normalization, threshold truncation, and logarithmic feature mapping, the first activation data with non-uniform distribution characteristics can be accurately and quickly converted into a discrete index.
[0056] Optionally, the step of dequantizing the discrete index corresponding to the first activation data based on the scaling factor and the adaptive quantization basis to obtain the first quantized activation data includes: Based on the scaling factor and the adaptive quantization base, the discrete index corresponding to the first activation data is dequantized through reversible exponential mapping to obtain the first quantized activation data.
[0057] Specifically, the dequantization process is achieved through a reversible exponential mapping, the formula of which is as follows:
[0058] in, This represents the inverse quantization output value corresponding to the first activation data, i.e., the first quantized activation data, which is used to approximately recover the first activation data Χ.
[0059] Optionally, the step of dequantizing the discrete index corresponding to the first activation data based on the scaling factor and the adaptive quantization basis to obtain the first quantized activation data includes: Based on the adaptive quantization basis, a lookup table is determined; Based on the lookup table and the scaling factor, the discrete index corresponding to the first activation data is dequantized using a lookup table method to obtain the first quantized activation data.
[0060] In practical applications, to reduce the computational overhead of exponentiation operations during the inference stage, a lookup table method can be used to amortize the computational cost. Equivalent to:
[0061] in, and All are lookup tables, which are updated dynamically with the adaptive quantization basis r.
[0062] In this embodiment of the invention, the dequantization operation is performed by looking up a table, which simplifies the dequantization operation to integer index lookup and scalar multiplication, avoiding expensive logarithmic and exponentiation operations in the inference stage, thereby achieving efficient numerical mapping.
[0063] Optionally, updating the dynamic adaptive logarithmizer based on the first activation data includes: Based on the first activated data and the scaling factor, a logarithmic feature space mapping is performed to obtain the logarithmic feature representation of the first activated data; Based on the adaptive quantization basis, quantization basis search range, and logarithmic feature representation of the dynamically adaptive logarithmic quantizer, the adaptive quantization basis of the dynamically adaptive logarithmic quantizer is updated to obtain the updated dynamically adaptive logarithmic quantizer.
[0064] In practical applications, finding the optimal adaptive quantization basis r is crucial. The degree of dispersion of the activated data in the logarithmic domain directly reflects its long-tailed nature. Therefore, non-zero activations can be mapped to the logarithmic feature space, as shown in the following formula:
[0065] Where z is the feature representation of the input data (first activated data) in the logarithmic field, i.e., the logarithmic feature representation.
[0066] The optimization of the adaptive quantization basis is driven by the statistical dispersion in the logarithmic field. Based on this, the dynamic update formula for the adaptive quantization basis r is as follows:
[0067] in, For the updated adaptive quantization basis, and These are the lower and upper bounds for the search of the adaptive quantization basis r, respectively. and This constitutes the search range for the quantization basis. This is a sensitivity hyperparameter used to control the adjustment range; Let z be the standard deviation of z, which serves as a measure of the sparsity of the distribution.
[0068] when When the value of r is large, it indicates that the data spans a significant range in the logarithmic domain, meaning that the original small value region is extremely dense and the tail is sparse. In this case, increasing r can effectively improve the sampling density of the quantizer in the small value interval, and vice versa. When the value of r is small, reducing r can avoid redundant allocation of quantization levels. This dynamic adjustment mechanism based on statistical feedback ensures that the dynamic adaptive quantizer can approximate the spatially optimal distribution match at different network layers.
[0069] Optionally, dividing the second activation data into first sensitive region activation data and second sensitive region activation data based on the local variance of the second activation data includes: Calculate the local variance of the second activated data based on a sliding window; A binary importance mask is constructed based on the adjusted threshold coefficient and the local variance of the second activation data; Based on the binary importance mask, a hybrid quantization mechanism is used to divide the second activation data into the first sensitive region activation data and the second sensitive region activation data.
[0070] In practical applications, the second activation data exhibits significant distribution asymmetry, with negative values concentrated in a narrow range (approximately [-0.17, 0]) and positive values showing a long-tailed distribution, and significant heterogeneity across layers.
[0071] To address the quantization challenges posed by distribution asymmetry, this invention provides a dynamic update method for quantization strategies based on spatial (importance) awareness characteristics. It employs local variance as a metric for quantization sensitivity and generates a binary importance mask to divide activation values into high-sensitivity and low-sensitivity regions, thereby achieving adaptive alignment of differentiated quantization granularity with the feature space distribution.
[0072] For the second activation data Y, the local variance (matrix or tensor) is calculated using a sliding window. :
[0073] in, This represents the local variance value at position (i,j). This represents the expectation operation. This indicates a local mean calculation within a sliding window w. The size of the sliding window can be adjusted, such as 5×5.
[0074] The local variance V is then flattened, and its global mean is calculated. with standard deviation And by introducing an adjustment threshold coefficient Construct a binary importance mask The specific definition is as follows:
[0075] in, This is an indicator function; it takes the value 1 when the condition is met, and 0 otherwise. Preferably, the threshold coefficient is adjusted. =0.5, at which point the model quantization accuracy reaches its optimal value.
[0076] Based on the binary importance mask M, the hybrid quantization mechanism dynamically splits the second activation data Y into high-sensitivity and low-sensitivity regions, as specifically defined below:
[0077]
[0078] in, Activate the data for the first sensitive region that requires high-precision quantization; Activate the data for the second sensitive region that requires high-precision quantization; This represents the Hadamard product, used to perform element-wise masking operations to achieve spatial filtering and region isolation of feature maps.
[0079] In this embodiment of the invention, local variance is used as a measure of quantization sensitivity, and a binary importance mask is generated to divide the activation values into high-sensitivity and low-sensitivity regions, thereby achieving adaptive alignment of differentiated quantization granularity with feature space distribution.
[0080] Optionally, the step of quantizing the activation data of the first sensitive region based on the updated dynamic adaptive logarithmic quantizer, and quantizing the activation data of the second sensitive region using a standard uniform quantization strategy to obtain the second quantized activation data includes: Based on the updated dynamic adaptive log quantizer, the activation data of the first sensitive region after the positive and negative branch separation processing is quantized to obtain the quantized activation data of the first sensitive region. Based on the bit width of uniform quantization, the scaling factor of uniform quantization, and the zero-point parameter of uniform quantization, the activation data of the second sensitive region is quantized using the standard uniform quantization strategy to obtain the quantized activation data of the second sensitive region. The quantized first sensitive region activation data and the quantized second sensitive region activation data are fused together to obtain the second quantized activation data.
[0081] In practical applications, the quantizer can be dynamically and adaptively quantized for the activated data in the first sensitive region.
[0082] Since quantization is only applicable to the non-negative domain, the activation data of the first sensitive region can be separated into positive and negative branches based on the negative interval reparameterization strategy, and then the quantizer can be quantized based on the updated dynamic adaptive quantization to obtain the quantized activation data of the first sensitive region. .
[0083] For the activation data of the second sensitive region, a standard uniform quantization scheme is adopted, combined with the bit width, scaling factor, and zero-point parameter based on uniform quantization, to obtain the quantized activation data of the second sensitive region. .
[0084] Activate data in the first sensitive region after quantization. and quantized second sensitive region activation data Based on this, they are fused together to obtain the second quantized activation data. ,Right now .
[0085] Furthermore, the inference process of both the dynamic adaptive quantizer and the uniform quantizer can be equivalently converted into a pre-computed lookup table mapping, which supports efficient feature representation with extremely low bit width, thereby significantly reducing the runtime memory usage of the model.
[0086] In this embodiment of the invention, by using different methods to quantize high-sensitivity and low-sensitivity regions, the accuracy and reliability of quantization are further improved on the basis of achieving adaptive alignment of differentiated quantization granularity with feature space distribution.
[0087] Optionally, the step of quantizing the activation data of the first sensitive region after positive and negative branch separation processing based on the updated dynamic adaptive logarithmizer to obtain the quantized activation data of the first sensitive region includes: A negative interval reparameterization strategy is adopted to perform positive and negative branch separation processing on the activation data of the first sensitive region, so as to obtain the non-negative part and the negative part of the activation data of the first sensitive region. Based on the updated dynamic adaptive logarithmic quantizer, the non-negative part and the negative part are quantized respectively to obtain the quantized non-negative part and the quantized negative part; Based on the reparameterization strategy, the non-negative value part and the negative value part after quantization are reconstructed to obtain the activation data of the first sensitive region after quantization.
[0088] In practical applications, based on the negative interval reparameterization strategy, positive and negative branch separation processing is performed on the activation data of the first sensitive region. The specific formula is as follows:
[0089]
[0090] in, The non-negative values in the data are activated for the first sensitive region. Activate the negative values in the data for the first sensitive region; Used to separate positive and negative values.
[0091] Independent dynamic adaptive quantization operations are performed on the two branches respectively, and feature reconstruction is completed based on the reparameterization logic. The specific formula is as follows:
[0092] in, The activation values of the reconstructed high-sensitivity region are the activation data of the first sensitive region. and These represent the independent scaling factors for the positive and negative branches, respectively. For the dynamic adaptive quantization process of the quantizer; This is the dequantization process of the quantizer for dynamic adaptive quantization.
[0093] Specifically, It can be expressed by the following formula:
[0094]
[0095] Where U represents the non-negative or negative portion of the activation data in the first sensitive region; The non-negative or negative value portion after normalization and truncation; This represents the discrete index corresponding to the generated non-negative or negative value portion.
[0096] Inverse Quantization It can be expressed by the following formula:
[0097] in, This is the dequantized output value corresponding to the non-negative or negative part.
[0098] In this embodiment of the invention, a "region-sensitive" hybrid strategy achieves an intelligent balance between accuracy and computational cost: computationally complex non-uniform quantization is not used throughout the entire model. Sensitive regions are defined by local variance, and a high-precision dynamic adaptive logarithmic quantizer is used only in critical regions, while efficient uniform quantization is used in non-critical regions. This strategy effectively controls overall computational complexity while achieving high accuracy, avoiding the slowdown in inference speed caused by the widespread use of non-uniform quantization.
[0099] Optionally, the step of quantizing the second sensitive region activation data using a standard uniform quantization strategy based on the uniform quantization bit width, uniform quantization scaling factor, and uniform quantization zero-point parameter to obtain the quantized second sensitive region activation data includes: Based on the bit width of the uniform quantization, the scaling factor of the uniform quantization, and the zero-point parameter of the uniform quantization, the activation data of the second sensitive region is subjected to discrete index mapping to obtain the discrete index corresponding to the activation data of the second sensitive region. Based on the scaling factor and the zero-point parameter of the uniform quantization, the discrete index corresponding to the activation data of the second sensitive region is dequantized to obtain the quantized activation data of the second sensitive region.
[0100] In practical applications, for low-sensitivity regions, a standard uniform quantization scheme is used, where the quantization process maps floating-point activation values to discrete integer indices. :
[0101] Where b represents the bit width of uniform quantization, and b∈N; The scaling factor for uniform quantization; For uniformly quantized zero-point parameters, and ∈Z, where Z is the set of integers.
[0102] The dequantization process restores integer indices to approximate floating-point values. The specific formula is as follows:
[0103] in, The activation values for the reconstructed low-sensitivity region are the activation data for the second sensitive region.
[0104] By integrating a dynamic adaptive logarithmic quantizer and a hybrid adaptive quantization strategy into a unified post-training quantization framework, accurate quantization of two types of key activation values is achieved, significantly reducing computational and storage overhead while maintaining model accuracy. Validation was performed on the large visualization database ImageNet, and the results are shown in Table 1. Table 1: Comparison of classification accuracy (Top-1, %) on the ImageNet dataset
[0105] Here, transformer stands for transformer; PTQ4 (Post-Training Quantization for VisionTransformers) is a post-training quantization framework for vision transformer models; RepQ (Generalizing Quantization-Aware Training for Re-Parametrized Architectures) is a method that generalizes quantization-aware training to re-parameterized network architectures; FIMA-Q (Post-Training Quantization for VisionTransformers by Fisher Information Matrix Approximation) is a method for post-training quantization of vision transformers by approximating the Fisher information matrix; SOTA (State Of The Art) guarantees the current state-of-the-art technology or highest level on the ImageNet dataset; Transformer-S (Transformer Small) is a smaller version of Transformer; and DeiT-T (DeiT-Tiny) is a data-efficient image transformer - tiny version.
[0106] The data in Table 1 show that, especially under the extremely challenging 3-bit quantization setting, the method of this application has a significant improvement over the existing state-of-the-art (SOTA) methods. For example, the accuracy is improved by 5.04% on the visual transformer-S model, which fully demonstrates the excellent effectiveness of the technical solution of this application in achieving high-precision and low-overhead quantization of the visual transformer-S model.
[0107] The visual model quantization method provided by this invention, based on non-uniformity and spatial awareness characteristics, significantly improves accuracy preservation at extremely low bit depths through dynamic quantization with "spatial awareness": achieving state-of-the-art accuracy under challenging settings such as 3-bit and 4-bit. For example, it achieves a 5.04% improvement in Top-1 accuracy on the visual transformer-S model. This means that with the same hardware resources, this solution can deploy smaller models while maintaining higher performance; or, with the same performance requirements, it can achieve more extreme compression.
[0108] The visual model quantization method provided by this invention, based on non-uniformity and spatial awareness characteristics, achieves an intelligent balance between accuracy and computational cost through a "region-sensitive" hybrid strategy: it avoids using computationally complex non-uniform quantization throughout the entire model. Sensitive regions are defined by local variance, and a high-precision dynamic adaptive logarithmic quantizer is used only in critical regions, while efficient uniform quantization is used in non-critical regions. This effectively controls the overall computational complexity while achieving high accuracy, avoiding the decrease in inference speed caused by the full application of non-uniform quantization.
[0109] The visual model quantization method based on non-uniformity and spatial awareness characteristics provided in this invention is not a piecemeal fix for a single problem, but rather a systemic framework. Simultaneously, it precisely solves two core challenges in visual converters—the "power-law-like non-uniform distribution" of activated data and the "positive-negative asymmetry and spatial structural heterogeneity non-uniform distribution" of activated data. This comprehensive problem coverage enables this invention to exhibit stable high performance and strong versatility across various tasks such as image classification, object detection, and instance segmentation.
[0110] The visual model quantization device based on non-uniformity and spatial perception characteristics provided by the present invention will be described below. The visual model quantization device based on non-uniformity and spatial perception characteristics described below can be referred to in correspondence with the visual model quantization method based on non-uniformity and spatial perception characteristics described above.
[0111] Figure 2 This is a schematic diagram of the structure of the visual model quantization device based on non-uniformity and spatial perception characteristics provided by the present invention, as shown below. Figure 1 As shown, the device includes: The acquisition module 201 is configured to acquire first activation data and second activation data corresponding to the initial visual model to be quantized. The first activation data has non-uniform distribution characteristics, and the second activation data has non-uniform distribution characteristics and spatial perception characteristics. The first quantization module 202 is configured to use a dynamic adaptive logarithmic quantizer to analyze the logarithmic domain frequency characteristics of the first activation data to quantize the first activation data, obtain the first quantized activation data, and update the dynamic adaptive logarithmic quantizer based on the first activation data and the first quantized activation data. The partitioning module 203 is configured to partition the second activation data into a first sensitive region activation data and a second sensitive region activation data based on the local variance of the second activation data. The second quantization module 204 is configured to quantize the first sensitive region activation data based on the updated dynamic adaptive logarithmic quantizer, and to quantize the second sensitive region activation data using a standard uniform quantization strategy to obtain the second quantized activation data. The determination module 205 is configured to determine the quantized target visual model corresponding to the initial visual model based on the first quantized activation data and the second quantized activation data.
[0112] The visual model quantization device based on non-uniformity and spatial awareness characteristics provided by this invention analyzes the frequency characteristics of the logarithmic domain to adapt to the power-law-like distribution of activation through a dynamic adaptive logarithmic quantizer, thereby enhancing the flexibility of quantization energy level allocation. Furthermore, it constructs a hybrid adaptive quantization strategy, which uses spatial awareness characteristics to analyze and divide the region sensitivity. In high-sensitivity regions, a dynamic adaptive logarithmic quantizer is used to improve accuracy, while in low-sensitivity regions, a computationally efficient uniform quantizer is used to reduce complexity. This achieves adaptive quantization of activation values with different distribution characteristics, ensuring model accuracy while achieving efficient model compression.
[0113] Optionally, the first quantization module 202 is specifically configured as follows: Based on the scaling factor, the adaptive quantization base of the dynamic adaptive quantizer, and the integer step size, the first activation data is quantized to obtain the discrete index corresponding to the first activation data. Based on the scaling factor and the adaptive quantization basis, the discrete index corresponding to the first activation data is dequantized to obtain the first quantized activation data.
[0114] Optionally, the first quantization module 202 is specifically configured as follows: Based on the scaling factor, the first activated data is scaled and truncated to obtain intermediate activated data. Based on the adaptive quantization basis and the integer step size, the logarithmic features of the intermediate activation data are discretely indexed to obtain the discrete index corresponding to the first activation data.
[0115] Optionally, the first quantization module 202 is specifically configured as follows: Based on the adaptive quantization basis, a lookup table is determined; Based on the lookup table and the scaling factor, the discrete index corresponding to the first activation data is dequantized using a lookup table method to obtain the first quantized activation data.
[0116] Optionally, the first quantization module 202 is specifically configured as follows: Based on the first activated data and the scaling factor, a logarithmic feature space mapping is performed to obtain the logarithmic feature representation of the first activated data; Based on the adaptive quantization basis, quantization basis search range, and logarithmic feature representation of the dynamically adaptive logarithmic quantizer, the adaptive quantization basis of the dynamically adaptive logarithmic quantizer is updated to obtain the updated dynamically adaptive logarithmic quantizer.
[0117] Optionally, the partitioning module 203 is specifically configured as follows: Calculate the local variance of the second activated data based on a sliding window; A binary importance mask is constructed based on the adjusted threshold coefficient and the local variance of the second activation data; Based on the binary importance mask, a hybrid quantization mechanism is used to divide the second activation data into the first sensitive region activation data and the second sensitive region activation data.
[0118] Optionally, the second quantization module 204 is specifically configured as follows: Based on the updated dynamic adaptive log quantizer, the activation data of the first sensitive region after the positive and negative branch separation processing is quantized to obtain the quantized activation data of the first sensitive region. Based on the bit width of uniform quantization, the scaling factor of uniform quantization, and the zero-point parameter of uniform quantization, the activation data of the second sensitive region is quantized using the standard uniform quantization strategy to obtain the quantized activation data of the second sensitive region. The quantized first sensitive region activation data and the quantized second sensitive region activation data are fused together to obtain the second quantized activation data.
[0119] Optionally, the second quantization module 204 is specifically configured as follows: A negative interval reparameterization strategy is adopted to perform positive and negative branch separation processing on the activation data of the first sensitive region, so as to obtain the non-negative part and the negative part of the activation data of the first sensitive region. Based on the updated dynamic adaptive logarithmic quantizer, the non-negative part and the negative part are quantized respectively to obtain the quantized non-negative part and the quantized negative part; Based on the reparameterization strategy, the non-negative value part and the negative value part after quantization are reconstructed to obtain the activation data of the first sensitive region after quantization.
[0120] Optionally, the second quantization module 204 is specifically configured as follows: Based on the bit width of the uniform quantization, the scaling factor of the uniform quantization, and the zero-point parameter of the uniform quantization, the activation data of the second sensitive region is subjected to discrete index mapping to obtain the discrete index corresponding to the activation data of the second sensitive region. Based on the scaling factor and the zero-point parameter of the uniform quantization, the discrete index corresponding to the activation data of the second sensitive region is dequantized to obtain the quantized activation data of the second sensitive region.
[0121] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 3 As shown, the electronic device may include: a processor 310, a communications interface 320, a memory 330, and a communications bus 340, wherein the processor 310, the communications interface 320, and the memory 330 communicate with each other through the communications bus 340. The processor 310 can call logic instructions in the memory 330 to execute a visual model quantization method based on non-uniformity and spatial awareness characteristics. The method includes: acquiring first activation data and second activation data corresponding to an initial visual model to be quantized, wherein the first activation data has non-uniform distribution characteristics, and the second activation data has both non-uniform distribution characteristics and spatial awareness characteristics; analyzing the logarithmic domain frequency characteristics of the first activation data using a dynamic adaptive logarithmic quantizer to quantize the first activation data, obtaining first quantized activation data, and updating the dynamic adaptive logarithmic quantizer based on the first activation data; dividing the second activation data into first sensitive region activation data and second sensitive region activation data using the local variance of the second activation data; quantizing the first sensitive region activation data based on the updated dynamic adaptive logarithmic quantizer, and quantizing the second sensitive region activation data using a standard uniform quantization strategy, obtaining second quantized activation data; and determining the quantized target visual model corresponding to the initial visual model based on the first quantized activation data and the second quantized activation data.
[0122] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0123] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the visual model quantization method based on non-uniformity and spatial perception characteristics provided by the above methods. The method includes: acquiring first activation data and second activation data corresponding to an initial visual model to be quantized, wherein the first activation data has non-uniform distribution characteristics, and the second activation data has non-uniform distribution characteristics and spatial perception characteristics; analyzing the logarithmic domain frequency characteristics of the first activation data using a dynamic adaptive logarithmic quantizer to quantize the first activation data, obtaining first quantized activation data, and updating the dynamic adaptive logarithmic quantizer based on the first activation data; dividing the second activation data into first sensitive region activation data and second sensitive region activation data through the local variance of the second activation data; quantizing the first sensitive region activation data based on the updated dynamic adaptive logarithmic quantizer, and quantizing the second sensitive region activation data using a standard uniform quantization strategy, obtaining second quantized activation data; and determining the quantized target visual model corresponding to the initial visual model based on the first quantized activation data and the second quantized activation data.
[0124] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements a visual model quantization method based on non-uniformity and spatial perception characteristics provided by the above methods. The method includes: acquiring first activation data and second activation data corresponding to an initial visual model to be quantized, wherein the first activation data has non-uniform distribution characteristics, and the second activation data has both non-uniform distribution characteristics and spatial perception characteristics; analyzing the logarithmic domain frequency characteristics of the first activation data using a dynamic adaptive logarithmic quantizer to quantize the first activation data, obtaining first quantized activation data, and updating the dynamic adaptive logarithmic quantizer based on the first activation data; dividing the second activation data into first sensitive region activation data and second sensitive region activation data using the local variance of the second activation data; quantizing the first sensitive region activation data based on the updated dynamic adaptive logarithmic quantizer, and quantizing the second sensitive region activation data using a standard uniform quantization strategy, obtaining second quantized activation data; and determining the quantized target visual model corresponding to the initial visual model based on the first quantized activation data and the second quantized activation data.
[0125] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0126] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0127] 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 of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A visual model quantization method based on non-uniformity and spatial perception characteristics, characterized in that, include: Obtain the first activation data and the second activation data corresponding to the initial visual model to be quantized. The first activation data has a non-uniform distribution characteristic, and the second activation data has a non-uniform distribution characteristic and a spatial perception characteristic. A dynamic adaptive logarithmic quantizer is used to analyze the logarithmic domain frequency characteristics of the first activation data to quantize the first activation data, thereby obtaining the first quantized activation data. Based on the first activation data, the dynamic adaptive logarithmic quantizer is updated. Based on the local variance of the second activation data, the second activation data is divided into first sensitive region activation data and second sensitive region activation data. Based on the updated dynamic adaptive logarithmizer, the activation data of the first sensitive region is quantized, and the activation data of the second sensitive region is quantized using a standard uniform quantization strategy to obtain the second quantized activation data. Based on the first quantized activation data and the second quantized activation data, the quantized target visual model corresponding to the initial visual model is determined.
2. The visual model quantization method based on non-uniformity and spatial perception characteristics according to claim 1, characterized in that, The step of using a dynamic adaptive logarithmic quantizer to analyze the logarithmic domain frequency characteristics of the first activation data to quantize the first activation data and obtain the first quantized activation data includes: Based on the scaling factor, the adaptive quantization base of the dynamic adaptive quantizer, and the integer step size, the first activation data is quantized to obtain the discrete index corresponding to the first activation data. Based on the scaling factor and the adaptive quantization basis, the discrete index corresponding to the first activation data is dequantized to obtain the first quantized activation data.
3. The visual model quantization method based on non-uniformity and spatial perception characteristics according to claim 2, characterized in that, The first activation data is quantized based on the scaling factor, the adaptive quantization base of the dynamically adaptive quantizer, and the integer step size to obtain the discrete index corresponding to the first activation data, including: Based on the scaling factor, the first activated data is scaled and truncated to obtain intermediate activated data. Based on the adaptive quantization basis and the integer step size, the logarithmic features of the intermediate activation data are discretely indexed to obtain the discrete index corresponding to the first activation data.
4. The visual model quantization method based on non-uniformity and spatial perception characteristics according to claim 2, characterized in that, The step of performing dequantization processing on the discrete index corresponding to the first activation data based on the scaling factor and the adaptive quantization basis to obtain the first quantized activation data includes: Based on the adaptive quantization basis, a lookup table is determined; Based on the lookup table and the scaling factor, the discrete index corresponding to the first activation data is dequantized using a lookup table method to obtain the first quantized activation data.
5. The visual model quantization method based on non-uniformity and spatial perception characteristics according to claim 1, characterized in that, The step of updating the dynamic adaptive logarithmizer based on the first activation data includes: Based on the first activated data and the scaling factor, a logarithmic feature space mapping is performed to obtain the logarithmic feature representation of the first activated data; Based on the adaptive quantization basis, quantization basis search range, and logarithmic feature representation of the dynamically adaptive logarithmic quantizer, the adaptive quantization basis of the dynamically adaptive logarithmic quantizer is updated to obtain the updated dynamically adaptive logarithmic quantizer.
6. The visual model quantization method based on non-uniformity and spatial perception characteristics according to any one of claims 1-5, characterized in that, The step of dividing the second activation data into first sensitive region activation data and second sensitive region activation data based on the local variance of the second activation data includes: Calculate the local variance of the second activated data based on a sliding window; A binary importance mask is constructed based on the adjusted threshold coefficient and the local variance of the second activation data; Based on the binary importance mask, a hybrid quantization mechanism is used to divide the second activation data into the first sensitive region activation data and the second sensitive region activation data.
7. The visual model quantization method based on non-uniformity and spatial perception characteristics according to any one of claims 1-5, characterized in that, The process involves quantizing the activation data of the first sensitive region based on the updated dynamic adaptive logarithmic quantizer, and then quantizing the activation data of the second sensitive region using a standard uniform quantization strategy to obtain the second quantized activation data, including: Based on the updated dynamic adaptive log quantizer, the activation data of the first sensitive region after the positive and negative branch separation processing is quantized to obtain the quantized activation data of the first sensitive region. Based on the bit width of uniform quantization, the scaling factor of uniform quantization, and the zero-point parameter of uniform quantization, the activation data of the second sensitive region is quantized using the standard uniform quantization strategy to obtain the quantized activation data of the second sensitive region. The quantized first sensitive region activation data and the quantized second sensitive region activation data are fused together to obtain the second quantized activation data.
8. The visual model quantization method based on non-uniformity and spatial perception characteristics according to claim 7, characterized in that, The step of quantizing the activation data of the first sensitive region after positive and negative branch separation processing based on the updated dynamic adaptive logarithmizer to obtain the quantized activation data of the first sensitive region includes: A negative interval reparameterization strategy is adopted to perform positive and negative branch separation processing on the activation data of the first sensitive region, so as to obtain the non-negative part and the negative part of the activation data of the first sensitive region. Based on the updated dynamic adaptive logarithmic quantizer, the non-negative part and the negative part are quantized respectively to obtain the quantized non-negative part and the quantized negative part; Based on the reparameterization strategy, the non-negative value part and the negative value part after quantization are reconstructed to obtain the activation data of the first sensitive region after quantization.
9. The visual model quantization method based on non-uniformity and spatial perception characteristics according to claim 7, characterized in that, The second sensitive region activation data is quantized using a standard uniform quantization strategy based on the bit width, scaling factor, and zero-point parameter of uniform quantization, resulting in quantized second sensitive region activation data, including: Based on the bit width of the uniform quantization, the scaling factor of the uniform quantization, and the zero-point parameter of the uniform quantization, the activation data of the second sensitive region is subjected to discrete index mapping to obtain the discrete index corresponding to the activation data of the second sensitive region. Based on the scaling factor and the zero-point parameter of the uniform quantization, the discrete index corresponding to the activation data of the second sensitive region is dequantized to obtain the quantized activation data of the second sensitive region.
10. A visual model quantization device based on non-uniformity and spatial perception characteristics, characterized in that, include: The acquisition module is configured to acquire the first activation data and the second activation data corresponding to the initial visual model to be quantized. The first activation data has a non-uniform distribution characteristic, and the second activation data has a non-uniform distribution characteristic and a spatial perception characteristic. The first quantization module is configured to analyze the logarithmic domain frequency characteristics of the first activation data using a dynamic adaptive logarithmic quantizer to quantize the first activation data, obtain the first quantized activation data, and update the dynamic adaptive logarithmic quantizer based on the first activation data and the first quantized activation data. The partitioning module is configured to partition the second activation data into a first sensitive region activation data and a second sensitive region activation data based on the local variance of the second activation data. The second quantization module is configured to quantize the activation data of the first sensitive region based on the updated dynamic adaptive logarithmic quantizer, and to quantize the activation data of the second sensitive region using a standard uniform quantization strategy to obtain the second quantized activation data. The determination module is configured to determine the quantized target visual model corresponding to the initial visual model based on the first quantized activation data and the second quantized activation data.