Data-free post-training quantization method and apparatus, device, and storage medium

By acquiring user data distribution and using random data for statistical analysis, quantization parameters are determined, solving the problem of high resource consumption in post-training quantization, realizing quantization without a standard dataset, protecting user privacy, and improving quantization efficiency.

WO2025055499A9PCT designated stage expired Publication Date: 2026-01-29HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/103661
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-09-13
Filing Date
2024-07-04
Publication Date
2026-01-29

AI Technical Summary

Technical Problem

In the post-training quantization process, standard datasets are required for computation. However, standard datasets involve user privacy and are difficult to obtain, resulting in high resource consumption and making quantization impossible.

Method used

By acquiring the data distribution of user input and performing statistical analysis using random data, the quantization parameters of the input activation values ​​and weight values ​​of the network layer are determined, allowing for direct quantization of the floating-point model without the need to train a data generation model.

Benefits of technology

It saves resources, protects user privacy, has a wider range of applications, high quantification efficiency, and is suitable for training scenarios without data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024103661_29012026_PF_FP_ABST
    Figure CN2024103661_29012026_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of neural networks, and provides a data-free post-training quantization method and apparatus, a device, and a storage medium. The method comprises: acquiring data distribution inputted by a user, wherein the data distribution is distribution to which an input activation value of each network layer of a floating-point model conforms; inputting random data into the floating-point model to obtain the input activation value of each network layer; performing statistical analysis on the input activation value of each network layer on the basis of the data distribution to obtain a data range of the input activation value of each network layer; determining a quantization parameter of the input activation value of each network layer on the basis of endpoint values of the data range; and in the process of using the floating-point model for reasoning, using the quantization parameter of the input activation value of each network layer to perform quantization processing on the input activation value generated in the reasoning process of each network layer. By means of the solution of the present application, input activation values can be quantized without data.
Need to check novelty before this filing date? Find Prior Art

Description

Methods, apparatus, equipment, and storage media for quantization without data training

[0001] This application claims priority to Chinese Patent Application No. 2023111850901, filed on September 13, 2023, entitled “Method, Apparatus, Device and Storage Medium for Quantization after Training Without Data”, the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of neural network technology, and in particular to a method, apparatus, device, and storage medium for quantization after training without data. Background Technology

[0003] Post-training quantization (PTQ) converts floating-point parameters in a model to fixed-point parameters after training, and is a commonly used method for compressing deep learning models. During inference, the quantized model reduces computational cost and effectively improves inference performance. However, PTQ requires calculating the quantization parameters of the input activation values ​​in the floating-point model using a standard dataset. Since standard datasets are often inaccessible due to privacy concerns, it may be impossible to use them for quantizing the input activation values ​​in the floating-point model.

[0004] In related technologies, a data-generated post-training quantization algorithm is provided. In this method, a data generation model is trained by mining information about the training dataset in the floating-point model, the data generation model is used to generate a dataset, and the quantization parameters of the input activation values ​​are calculated based on the dataset.

[0005] Because a data generation model needs to be trained before quantization, the training overhead is relatively large, resulting in high resource consumption.

[0006] Summary of the Invention

[0007] This application provides a method, apparatus, device, and storage medium for quantization without data training, which requires no standard dataset or training data to generate a model, thus saving resources when quantizing floating-point models.

[0008] In a first aspect, this application provides a method for quantization after training without data. The method includes: obtaining a data distribution of user input, which is the distribution of input activation values ​​of each network layer of a floating-point model; inputting random data into the floating-point model to obtain the input activation values ​​of each network layer; performing statistical analysis on the input activation values ​​of each network layer based on the data distribution to obtain the data range of the input activation values ​​of each network layer; determining quantization parameters of the input activation values ​​of each network layer based on the endpoint values ​​of the data range; and quantizing the input activation values ​​generated during the inference process using the floating-point model by using the quantization parameters of the input activation values ​​of each network layer.

[0009] In the scheme shown in this application, the user provides the data distribution of the input activation values, and by using random data as the input of the floating-point model, the quantization parameters of the input activation values ​​can be determined and the input activation values ​​of the floating-point model can be quantized. Therefore, there is no need to train the data to generate the model, which can save resources.

[0010] In one alternative approach, for each network layer of the floating-point model, the initial values ​​of the quantization parameters for the input activation values ​​of that network layer are first determined using the endpoints of the data range of the input activation values. Then, using these initial values, the input activation values ​​are quantized to obtain quantized input activation values. Based on these quantized input activation values ​​and the network layer's input activation values, the quantization error is determined. The initial values ​​of the quantization parameters are then updated until the quantization error is less than or equal to a target value, or minimized, thus obtaining the final value of the quantization parameters for that network layer. In this way, using the quantization error as a constraint allows for the determination of the quantization parameter values.

[0011] In one alternative approach, when the quantization parameters include a scaling factor and a quantization bias, the scaling factor and the quantization bias are updated alternately. The process is as follows: with the scaling factor as the initial value, the quantization bias is updated until the quantization error of the input activation value of the network layer is less than or equal to the target value, or minimized, to obtain the value of the quantization bias; after the quantization bias update is completed, the scaling factor is updated until the quantization error of the input activation value of the network layer is less than or equal to the target value, or minimized, to obtain the value of the scaling factor.

[0012] In an alternative approach, the method can further quantize the weight values ​​in the floating-point model. This involves: for each group of the floating-point model, determining the quantization parameter corresponding to that group; and based on the quantization parameter, quantizing the weight values ​​in that group to obtain the quantized values. This further reduces the storage resources occupied by the floating-point model and saves computational resources. Moreover, determining the quantization parameter by group allows for rapid determination of the quantization parameter.

[0013] In one alternative approach, when quantizing the weight values ​​in the floating-point model, the rounding direction of weight values ​​with large quantization errors is adjusted according to the grouping of weight values. This process involves: determining the perturbation tensor corresponding to the weight value to be adjusted during quantization rounding in the group; the weight value to be adjusted being the top K weight values ​​in the group, arranged from largest to smallest quantization error during quantization; this perturbation tensor is used to adjust the rounding direction of the weight value to be adjusted during quantization rounding; determining the ratio of the weight value to be adjusted to the corresponding scaling factor; rounding the sum of this ratio and the perturbation tensor to obtain the rounded result; in the case of asymmetric quantization, updating the sum of the rounded result and the quantization bias corresponding to the weight value to be adjusted to the quantized value of the weight value to be adjusted; in the case of symmetric quantization, updating the rounded result to the quantized value of the weight value to be adjusted. This further reduces quantization error.

[0014] In an alternative approach, the method further includes grouping the weight values ​​in the floating-point model according to the channel to which the weight values ​​belong, wherein weight values ​​in the same channel belong to the same group.

[0015] Secondly, this application provides an apparatus for data-free training-after-quantization, which has the functionality of the first aspect described above. The apparatus includes at least one module for implementing the data-free training-after-quantization method provided in the first aspect.

[0016] In some embodiments, modules in the device for quantization without data training are implemented in software; these modules are program modules. In other embodiments, the modules are implemented in hardware or firmware.

[0017] Thirdly, this application provides a computing device, which includes a processor and a memory, wherein the memory stores computer instructions, and the processor executes the computer instructions to implement the method of the first aspect and its optional implementation.

[0018] Fourthly, this application provides a computer-readable storage medium storing computer instructions that, when executed by a computing device, cause the computing device to perform the method of the first aspect and its optional implementation.

[0019] Fifthly, this application provides a computer program product containing instructions that, when run on a computing device, cause the computing device to execute the method described in the first aspect and its optional implementations. Attached Figure Description

[0020] Figure 1 is a schematic diagram of a system architecture provided in an exemplary embodiment of this application;

[0021] Figure 2 is a schematic diagram of the system architecture provided in an exemplary embodiment of this application;

[0022] Figure 3 is a schematic diagram of the structure of a computing device provided in an exemplary embodiment of this application;

[0023] Figure 4 is a schematic flowchart of a post-training quantization method provided in an exemplary embodiment of this application;

[0024] Figure 5 is a schematic diagram of the input activation value quantization process provided in an exemplary embodiment of this application;

[0025] Figure 6 is a flowchart illustrating the optimization of the weight value rounding method provided in an exemplary embodiment of this application;

[0026] Figure 7 is a schematic diagram of the structure of a data-free training post-quantization apparatus provided in an exemplary embodiment of this application. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0028] The following explains some terms and concepts involved in the embodiments of this application.

[0029] 1. Model quantization is the process of directly converting a floating-point model into a model that can be computed using fixed-point integers. For example, converting a floating-point model with single-precision floating-point (FP32) or half-precision floating-point (FP16) data types into an integer model with 8-bit integer (int8) data types. Quantization reduces the computational load, effectively improving inference speed, and also reduces memory usage, enabling the deployment of deep learning models on devices with limited memory.

[0030] 2. Post-training quantization is a commonly used deep learning model compression method. It refers to converting the floating-point parameters in the model into fixed-point parameters after the model is trained. During the conversion, the quantization parameters used need to be calibrated or optimized to ensure that the accuracy loss after model quantization meets the requirements.

[0031] 3. Data-free post-quantization (PTQ) refers to a method that allows for post-quantization of floating-point models without requiring users to provide a standard dataset.

[0032] The background of the embodiments of this application is described below.

[0033] Deep learning has wide applications and practical needs in many fields, such as speech recognition, image processing, and autonomous driving. In some scenarios, such as autonomous driving, there are stringent requirements for the latency and memory usage of deep learning model inference. Therefore, post-training quantization is necessary to obtain deep learning models with low latency and low memory consumption. During post-training quantization, the quantization parameters of the input activation values ​​in the deep learning model need to be calculated using a standard dataset. However, standard datasets are often unavailable due to user privacy concerns, making it possible to quantize the input activation values ​​using a standard dataset. Based on this, a data-free post-training quantization method has emerged. This method quantizes the model in scenarios where the user does not provide data, and its application scope is wider than that of ordinary model quantization methods.

[0034] This application provides a data-free training post-quantization method. In this method, no standard dataset or training data generation model is required to perform data-free training post-quantization on floating-point models, which can save resources.

[0035] The technical solutions provided in the embodiments of this application are described in detail below, according to the execution subject, system architecture, hardware structure of the devices in the system architecture, and method flow of the quantization method after training without data.

[0036] The following describes the main body of the quantization method after training without data.

[0037] The execution entity of the data-free training post-quantization method is the data-free training post-quantization device, or simply the quantization device. Optionally, the quantization device is a hardware device, such as a terminal device or a computing device like a server. Optionally, the quantization device is a software device, such as a software program running on the hardware device.

[0038] The system architecture provided in the embodiments of this application is described below.

[0039] In one alternative embodiment, this application provides a system architecture 100. As shown in FIG1, the system architecture 100 includes a terminal device 101 and a computing device 102. The terminal device 101 and the computing device 102 are connected via a wired or wireless network. The terminal device 101 is a device used by a user, such as a desktop computer, laptop computer, or tablet computer, and is used for user interaction with the computing device 102. For example, the user can input data distributions through the terminal device 101. The computing device 102 may be a server, and is used to quantize a pre-trained floating-point model using the data distribution, returning the quantized model to the terminal device 101.

[0040] In another alternative embodiment, this application provides another system architecture 200. As shown in FIG2, system architecture 200 includes a terminal device 101 and a public cloud 201. The terminal device 101 and the public cloud 201 are connected via a wired or wireless network. The terminal device 101 is a device used by the user to interact with the public cloud 201. The public cloud 201 is an entity that provides cloud services to users using basic resources in a cloud computing model; the public cloud 201 can also be considered a cloud environment. The public cloud 201 includes a cloud data center, which includes a large amount of basic resources owned by the cloud service provider. These basic resources include computing resources, storage resources, and network resources. The computing resources included in the cloud data center may be a cluster of computing devices, and the cluster of computing devices includes at least one computing device 102, which may be a server, etc. When users use cloud services, they can input data distributions to public cloud 201 via API or interactive interface (the interactive interface can be a graphical user interface, GUI). The computing devices in public cloud 201 receive the pre-trained floating-point model and data distributions input by the user, use the data distributions to quantize the pre-trained floating-point model, and return the quantized model to terminal device 101.

[0041] In system architecture 200, the method of quantization without data training can be abstracted into a cloud service by the cloud service provider in the public cloud 201 and provided to users. After obtaining the permission to use the cloud service, users can use the cloud service to perform quantization without data training.

[0042] In another alternative embodiment, this application also provides a system architecture. This system architecture includes a terminal device, which is a device used by a user. The terminal device executes the data-free training followed by quantization method described in this application.

[0043] The hardware structure of the device is described below.

[0044] As shown in Figure 3, device 300 may optionally be implemented using a general bus architecture. Device 300 includes at least one processor 301, a communication bus 302, a memory 303, and at least one network interface 304. This device 300 is the terminal device 101 and computing device 102 mentioned above.

[0045] Processor 301 may be, for example, a general-purpose central processing unit (CPU), a network processor (NP), a graphics processing unit (GPU), a neural-network processing unit (NPU), a data processing unit (DPU), a microprocessor, or one or more integrated circuits for implementing the embodiments of this application. For example, processor 301 may include an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. A PLD may be, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0046] The communication bus 302 is used to transmit information between the aforementioned components. The communication bus 302 can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used to represent it in Figure 3, but this does not mean that there is only one bus or one type of bus.

[0047] Memory 303 may be, for example, read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions; random access memory (RAM) or other types of dynamic storage devices capable of storing information and instructions; electrically erasable programmable read-only memory (EEPROM); compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile optical discs, Blu-ray discs, etc.); magnetic disk storage media or other magnetic storage devices; or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. Memory 303 may exist independently and be connected to processor 301 via communication bus 302. Memory 303 may also be integrated with processor 301.

[0048] Optionally, memory 303 is used to store pre-trained floating-point models. When device 300 needs to use the floating-point model, processor 301 accesses memory 303 to obtain the floating-point model stored in memory 303.

[0049] Network interface 304 uses any transceiver-like device for communicating with other devices or communication networks. Network interface 304 includes a wired network interface and may also include a wireless network interface. The wired network interface may be, for example, an Ethernet interface. The Ethernet interface may be an optical interface, an electrical interface, or a combination thereof. The wireless network interface may be a wireless local area network (WLAN) interface, a cellular network interface, or a combination thereof.

[0050] In a specific implementation, as an example, processor 301 may include one or more CPUs.

[0051] In a specific implementation, as an example, device 300 may include multiple processors. Each of these processors may be a single-core processor (single-CPU) or a multi-core processor (multi-CPU). Here, a processor may refer to one or more devices, circuits, and / or processing cores used to process data (such as computer program instructions).

[0052] In some embodiments, memory 303 is used to store program code 3031 for executing data-free training post-quantization in this application, and processor 301 executes program code 3031 stored in memory 303. That is, device 300 can implement the data-free training post-quantization method provided in the method embodiment through processor 301 and program code 3031 in memory 303.

[0053] The following describes the method and process of post-training quantization with reference to Figures 4 to 6.

[0054] In post-training quantization, the quantized weight values ​​can be represented as W. q = W + ΔW, where W represents the weight value before quantization, and ΔW represents the difference between the weight value before and after quantization. The quantized value of the input activation value is represented as A. q =A + ΔA, where A represents the input activation value before quantization, ΔA represents the difference between the input activation value before and after quantization, and the final calculated value after quantization is expressed as formula (1). W q A q =WA+AΔW+WΔA+ΔWΔA (1)

[0055] The goal of quantization is to minimize the quantization error, as expressed in formula (2), or the goal of quantization is to make the quantization error less than or equal to a certain value.

[0056] In this embodiment, quantization error is the optimization target. Combining formulas (1) and (2), it can be seen that quantization error mainly comes from input activation value quantization and weight value quantization. Therefore, in this embodiment, for the quantization requirements in the absence of data, input activation value quantization and weight value quantization are performed separately to minimize quantization error, or to make it less than or equal to a certain value.

[0057] As described above, post-training quantization includes two parts: input activation value quantization and weight value quantization. Referring to Figure 4, during input activation value quantization, the input for post-training quantization includes a pre-trained floating-point model and a data distribution. The pre-trained floating-point model is a pre-trained deep learning model where the data type of the parameters is floating-point. This deep learning model includes deep learning models for scenarios such as speech recognition, text recognition, image processing, or vehicle driving. This application embodiment does not limit the data type; the data type in the pre-trained floating-point model can be any floating-point type, such as FP32, FP16, or FP64. The floating-point model includes multiple network layers connected sequentially. For example, the network layers of a floating-point model may include convolutional layers, fully connected layers, and pooling layers. Different floating-point models may include different network layers. The multiple network layers included in the floating-point model correspond to the application scenario of the floating-point model. For example, in a deep learning model for text recognition, the multiple network layers include embedding layers, convolutional layers, and fully connected layers. The data distribution is the statistical distribution of the input activation values. For example, the data distribution may be normally distributed. During weight quantization, the input for post-training quantization includes the pre-trained floating-point model. There is no specific order for input activation value quantization and weight value quantization; the input activation values ​​can be quantized first, or the weight values ​​can be quantized first. This embodiment does not impose a limitation. Figure 4 shows the process of quantizing the input activation values ​​first, followed by the weight values. After input activation value quantization and weight value quantization, the quantized model is output.

[0058] The processes of input activation value quantization and weight value quantization are described below.

[0059] 1. Activation value quantization process. This quantization process includes the quantization of the input activation value and the optimization of the rounding method.

[0060] 1.1 The quantization process of input activation value is described in steps 501 to 505 of Figure 5. The process shown in Figure 5 is illustrated using the system architecture shown in Figure 2 above as an example. The computing device in Figure 5 is the computing device 102 mentioned above.

[0061] Step 501: Obtain the data distribution of user input.

[0062] In this embodiment, the user inputs a data distribution through a terminal device, and the computing device receives the data distribution sent by the terminal device. This data distribution is the distribution that the input activation values ​​of each network layer of the floating-point model conform to. In other words, the input activation values ​​of each network layer conform to this data distribution, such as a normal distribution or a Poisson distribution.

[0063] In one alternative approach, if the pre-trained floating-point model is trained by a computing device, the user does not need to provide the floating-point model. Essentially, the computing device trains the floating-point model and then provides an input interface for the user to upload the data distribution of input activation values, which the computing device then receives. If the pre-trained floating-point model is not trained by a computing device, the computing device provides an input interface for the user to upload both the pre-trained floating-point model and the data distribution of input activation values.

[0064] In an alternative approach, the user also inputs the number of quantization bits n via a terminal device, where the number of quantization bits represents the number of bits for each quantized input activation value, and the computing device obtains the number of quantization bits n.

[0065] Step 502: Input random data into the floating-point model to obtain the input activation values ​​of each network layer.

[0066] In this embodiment, the computing device stores random data, which is commonly used data that ensures the input activation values ​​of each network layer conform to the data distribution input by the user. Alternatively, the computing device stores random data with a corresponding data distribution, and the computing device retrieves random data from the stored random data that conforms to the data distribution input by the user. Or, the computing device generates random data that conforms to the data distribution based on the data distribution. The computing device inputs the random data into the floating-point model and performs forward inference to obtain the input activation values ​​of each network layer of the floating-point model. For the first network layer in a series of sequentially connected network layers in the floating-point model, the input activation value of this network layer can be a feature of the random data. For any network layer other than the first network layer, the input activation value of this network layer is the feature data output by the previous network layer preceding it.

[0067] Step 503: Based on the data distribution, perform statistical analysis on the input activation values ​​of each network layer to obtain the data range of the input activation values ​​of each network layer.

[0068] In this embodiment, the user-input data distribution is the data distribution that the input activation values ​​of each network layer conform to. For any network layer, the computing device uses this data distribution to determine the maximum and minimum values ​​of the input activation values ​​of that network layer, thereby obtaining the data range of the input activation values. For example, if the data distribution is a normal distribution, for the k-th network layer of the floating-point model, the parameters μ and σ of the normal distribution can be calculated using the input activation values ​​of the k-th network layer, where μ is the expected value and σ is the standard deviation. In a normal distribution, the probability that the data falls within (μ-3σ, μ+3σ) is 99.74%. Therefore, (μ-3σ, μ+3σ) can be used as the data range of the input activation values ​​of the k-th network layer, where μ-3σ is the minimum value of this data range and μ+3σ is the maximum value of this data range.

[0069] Given a quantization bit count n, the range of the quantized value of the input activation value is [-2]. n-1 ,2 n-1 -1].

[0070] Step 504: Based on the endpoint values ​​of the data range, determine the quantization parameters of the input activation values ​​of each network layer.

[0071] In this embodiment, for any network layer, the endpoints of the data range of that network layer are the maximum and minimum values ​​of the input activation values ​​of that network layer. The computing device uses the maximum and minimum values ​​to determine the quantization parameters of the input activation values ​​of that network layer. Specifically, in the case of asymmetric quantization, the quantization parameters include a scaling factor and a quantization bias; in the case of symmetric quantization, the quantization parameters include a scaling factor.

[0072] In one alternative approach, the process of determining the quantization parameters using the endpoint values ​​of the data range is as follows:

[0073] In the case of asymmetric quantization, the quantization parameters include scaling factor and quantization bias. For any network layer, the computing device uses formula (3) to calculate the initial value of the scaling factor corresponding to the network layer and uses formula (4) to calculate the initial value of the quantization bias corresponding to the network layer.

[0074] In Equations (3) and (4), scale1 represents the scaling factor, max_val represents the maximum value of the input activation value of the network layer, min_val represents the minimum value of the input activation value of the network layer, n represents the number of quantization bits, offset1 represents the quantization bias, and round represents the rounding operation, which can be a rounding operation, a rounding up operation, or a rounding down operation, etc.

[0075] Then, the initial value of the quantization parameter used by the calculation device is used to quantize the input activation value of the network layer using formula (5) to obtain the quantized value of the input activation value. The quantized value of the input activation value is then dequantized to obtain the dequantized value. The quantization error of the input activation value of the network layer is calculated using formula (6) or (7). It is determined whether the quantization error is less than or equal to the target value of the network layer. If the quantization error is less than or equal to the target value, the initial value of the scaling factor is determined as the value of the scaling factor, and the initial value of the quantization bias is determined as the value of the quantization bias. If the quantization error is greater than the target value, the initial value of the quantization parameter of the input activation value of the network layer is updated, and the above process is continued until the quantization error of the input activation value of the network layer is less than or equal to the target value, and the value of the quantization parameter of the input activation value of the network layer is obtained. Alternatively, the initial value of the quantization parameter of the input activation value of the network layer is updated until the quantization error of the input activation value of the network layer is minimized, and the value of the quantization parameter of the input activation value of the network layer is obtained. The target value can be set based on the actual situation. The larger the number of input activation values ​​of the network layer, the larger the target value should be, and the smaller the number of input activation values ​​of the network layer, the smaller the target value should be.

[0076] In formula (5), A2 represents the quantized value of the input activation value, A1 represents the value of the input activation value before quantization, scale1 represents the scaling factor, offset1 represents the quantization bias, and round represents the rounding operation.

[0077] In formula (6), L(A1,A2) represents the quantization error, and A 1i A represents the value of the i-th input activation value before quantization, where i is an integer less than or equal to m. 2i This represents the value obtained by dequantizing the quantized value of the i-th input activation value. The dequantized value is a floating-point number, and m represents the number of input activation values ​​of this network layer.

[0078] Optionally, in the case of asymmetric quantization, the computing device can use an alternating update method to determine the scaling factor and quantization bias. For example, for any network layer, with the scaling factor as the initial value, the initial values ​​of the scaling factor and quantization bias are used to quantize the input activation values ​​of the network layer to obtain the quantized values ​​of the input activation values ​​of the network layer, as shown in Equation (5).

[0079] The computing device then dequantizes the quantized values ​​and calculates the quantization error corresponding to the network layer using formula (6) or (7). The computing device increases the initial value of the quantization bias by a first adjustment magnitude, substitutes the initial value of the scaling factor and the adjusted quantization bias into formula (5), and quantizes the input activation values ​​of the network layer to obtain the quantized values ​​of the input activation values ​​of the network layer. The computing device then calculates the quantization error corresponding to the network layer using formula (6) or (7). The computing device determines whether the quantization error meets the minimum or is less than or equal to the target value. If not, it continues to adjust the quantization bias, and so on, until the value of the quantization bias when the quantization error is minimum is obtained, or until the value of the quantization bias when the quantization error is less than or equal to the target value is obtained.

[0080] Then, after obtaining the quantization bias, the quantization bias is fixed, and the scaling factor is updated to determine the value of the scaling factor when the quantization error is minimized, or the value of the scaling factor when the quantization error is less than or equal to the target value. The process of updating the scaling factor is similar to the process of updating the quantization bias, and will not be described in detail here.

[0081] In this way, after repeatedly updating the quantization bias and scaling factor, the final scaling factor and quantization bias are obtained.

[0082] In the case of symmetric quantization, the target quantization parameter includes a scaling factor. For any network layer, the computing device calculates the initial value of the scaling factor corresponding to that network layer using formula (3). For any network layer, only the scaling factor corresponding to that network layer is adjusted, which is equivalent to the quantization bias being set to 0. The process of determining the scaling factor is the same as that of asymmetric quantization, and will not be repeated here.

[0083] Step 505: During the inference process using the floating-point model, the input activation values ​​generated during the inference process of each network layer are quantized using the quantization parameters of the input activation values ​​of each network layer.

[0084] In this embodiment, the quantization parameters for all input activation values ​​of each network layer are the same. During subsequent inference using this floating-point model, after inputting the inference data into the floating-point model, the input activation values ​​of each network layer are obtained. These input activation values ​​are then quantized using the quantization parameters of the network layer before inference calculations are performed. This conversion of floating-point input activation values ​​to integer input activation values ​​reduces computational complexity.

[0085] The device performing step 505 can be the same device as the device performing steps 501 to 504, or it can be a different device. For example, the computing device determines the quantization parameters of the input activation value and performs the inference process. As another example, after obtaining the quantization parameters of the input activation value based on the process shown in Figure 5, the computing device returns the quantization parameters to the terminal device. The terminal device stores the quantization parameters, and subsequently uses these quantization parameters to quantize the input activation value during the inference process, which can reduce the computational load of the input activation value.

[0086] Using the process shown in Figure 5, user-provided data is not required during model quantization, thus protecting user privacy and broadening the application scope. Furthermore, it eliminates the need for additional training of a data generator, saving resources and improving quantization efficiency.

[0087] In post-quantization scenarios without data training, initializing the quantization parameters of the input activation values ​​based on the data distribution of the input activation values ​​yields higher accuracy compared to random estimation. Furthermore, post-quantization scenarios without data training have no requirements on the structure of the floating-point model, resulting in stronger generalization capabilities.

[0088] 1.2 Optimization process of rounding method during input activation value quantization.

[0089] After determining the quantization parameters, for any network layer's input activation value, without introducing a perturbation tensor, the input activation value of the network layer is quantized and rounded to obtain the quantized value of the input activation value (using formula (5) for quantization processing; in the case of symmetric quantization, the quantization bias is 0). Formula (6) or (7) is used to calculate the quantization error of the network layer's input activation value.

[0090] Then, determine the top K input activation values ​​in the network layer with the largest quantization errors, sorted from largest to smallest. Introduce perturbation tensors for these K input activation values ​​(see formula (8) for asymmetric quantization and formula (9) for symmetric quantization). Quantize and round the input activation values ​​of the network layer to obtain the quantized values. Continue to use formula (6) or (7) to calculate the quantization error of the input activation values ​​to be adjusted in the network layer (m represents the number of input activation values ​​to be adjusted), and update the perturbation tensor until the quantization error is minimized, obtaining the perturbation tensor with the smallest quantization error. Alternatively, calculate whether the quantization error of each input activation value to be adjusted is minimized. If it is minimized, obtain the perturbation tensor corresponding to the input activation value to be adjusted. If it is not minimized, update the perturbation tensor until the quantization error of each input activation value to be adjusted is minimized, obtaining the perturbation tensor with the smallest quantization error. The perturbation tensors corresponding to the K input activation values ​​of the network layer can be the same, partially the same, or completely different.

[0091] In formulas (8) and (9), Δ1 is the perturbation tensor.

[0092] Furthermore, the principle of introducing the perturbation tensor is as follows: assuming the rounding operation is rounding to the nearest integer, if the decimal part of the original ratio of the input activation value to the scaling factor is less than 5, by introducing the perturbation tensor, the decimal part is changed to be greater than or equal to 5, thereby changing the rounded value. Alternatively, if the decimal part of the original ratio of the input activation value to the scaling factor is greater than or equal to 5, by introducing the perturbation tensor, the decimal part is changed to be less than 5, thereby changing the rounded value.

[0093] It should be noted that after determining the quantization parameters, perturbation tensors are introduced for the input activation values ​​with relatively large quantization errors in each network layer, and the rounding direction is adjusted to further reduce the quantization error.

[0094] 2. The process of weight value quantization: The process of weight value quantization includes the process of determining the weight value and the process of optimizing the rounding method.

[0095] 2.1 The quantification process of the weight values ​​is as follows:

[0096] In the floating-point model, the weights are divided into multiple groups, each group containing one or more weights. For each weight in a group of the floating-point model, the quantization parameters corresponding to each weight in that group are the same.

[0097] In one alternative approach, in the case of asymmetric quantization, the quantization parameter corresponding to the weight value in the group is determined according to formula (10), and in the case of symmetric quantization, the quantization parameter corresponding to the weight value in the group is determined according to formula (11).

[0098] Where L(W1,W2) represents the quantization error of the weight values ​​in a group, and the expression is given in formula (12). In formula (10), The values ​​of scaling factor scale2 and quantization offset2, representing minimizing quantization error, are determined by formula (13). In formula (11), The value of scale2 is determined by formula (14) when minimizing the quantization error.

[0099] In formulas (12) and (15), W1 represents the weight value before quantization, W2 represents the weight value after quantization and the value after dequantization, and W... 1j W represents the value of the j-th weight before quantization, where j is an integer less than or equal to g.2j denoted as the inverse quantized value of the j-th weight value, and g represents the number of weight values ​​in this group. In formulas (13) and (14), scale2 represents the scaling factor of the weight value, offset2 represents the quantization bias of the weight value, round represents the rounding operation, which can be rounding to the nearest integer, rounding up, or rounding down, and Δ2 represents the perturbation tensor in the following text, which is set to 0 here.

[0100] In formula (10), two parameters need to be adjusted: scaling factor scale2 and quantization offset offset2. When adjusting these two parameters, their initial values ​​are preset values. With scale2 fixed, offset2 is adjusted to minimize the quantization error L(W1,W2) of the weight values ​​in the group. Then, offset2 is fixed to the offset2 when L(W1,W2) is minimized, and scale2 is adjusted to minimize L(W1,W2). This process is repeated until a preset number of times is reached. The scale2 and offset2 at the last execution of this process are then determined as the final quantization parameters. This preset number is set based on empirical values, such as 10.

[0101] In another alternative approach, when adjusting the quantization parameters of the weight values, it can also be considered that the quantization parameters are determined when L(W1,W2) is less than or equal to the target value.

[0102] For the weight values ​​in each group, after determining the quantization parameters, the quantization process is performed using the quantization parameters to obtain the quantized values ​​of the weight values.

[0103] 2.2 The process of optimizing the rounding method and quantizing based on the optimized rounding method.

[0104] After determining the quantization parameters of the weight values ​​in each group, the quantization error of some weight values ​​in each group may be relatively large. In order to further reduce the quantization error of these weight values, a quantization process based on the optimized rounding method is performed. See steps 601 to 603 in Figure 6. The process shown in Figure 6 is illustrated using the system architecture shown in Figure 2 in the previous text as an example. The computing device in Figure 6 is the computing device 102 mentioned in the previous text.

[0105] Step 601: For the weight values ​​in each group in the floating-point model, determine the perturbation tensor corresponding to the quantization and rounding of the weight values ​​to be adjusted in that group.

[0106] In this embodiment, for any weight value of a group, without introducing a perturbation tensor, in the case of asymmetric quantization, the quantized value of the weight value is calculated using formula (13) (Δ2 is 0), and in the case of symmetric quantization, the quantized value of the weight value is calculated using formula (14) (Δ2 is 0). The weight values ​​in the group are quantized and rounded to obtain the quantized value of the weight value, and the quantization error of the weight values ​​in the group is calculated using formula (12) or (15).

[0107] Then, the quantization errors of the weight values ​​in the group are sorted from largest to smallest, and the top K quantization errors are assigned to their respective weight values. These K weight values ​​are the weight values ​​to be adjusted. The value of K may vary for different groups; the more weight values ​​in a group, the larger the value of K, and vice versa.

[0108] Then, a perturbation tensor is introduced for the weight values ​​to be adjusted in the group. In the case of asymmetric quantization, the quantized value of the weight value to be adjusted is calculated using formula (13), and in the case of symmetric quantization, the quantized value of the weight value to be adjusted is calculated using formula (14). Continue to use formula (12) or (15) to calculate the quantization error of the weight value to be adjusted (g represents the number of weight values ​​to be adjusted) until a suitable perturbation tensor is selected to minimize the quantization error. This process is represented by formula (16). Alternatively, calculate whether the quantization error of each weight value to be adjusted is minimized. If it is minimized, obtain the perturbation tensor corresponding to the weight value to be adjusted. If it is not minimized, update the perturbation tensor until the quantization error of each weight value to be adjusted is minimized, and obtain the perturbation tensor with the minimum quantization error. For any group, the perturbation tensors corresponding to the weight values ​​to be adjusted in the group can be the same, partially the same, or completely different.

[0109] In formula (16), The value of Δ2 is given when minimizing the quantization error. The expression for L(W1,W2) can be found in formula (12) or (15).

[0110] It should be noted that the principle of introducing the perturbation tensor is as follows: assuming the rounding operation is rounding to the nearest integer, if the decimal part of the original ratio of the weight value to the scaling factor is less than 5, by introducing the perturbation tensor, the decimal part is changed to be greater than or equal to 5, thereby changing the rounded value. Alternatively, if the decimal part of the original ratio of the weight value to the scaling factor is greater than or equal to 5, by introducing the perturbation tensor, the decimal part is changed to be less than 5, thereby changing the rounded value.

[0111] Step 602: Determine the ratio of the weight value to be adjusted to the corresponding scaling factor.

[0112] Step 603: The sum of the ratio and the perturbation tensor is rounded to obtain the rounded result. In the case of asymmetric quantization, the sum of the rounded result and the quantization bias corresponding to the weight value to be adjusted is updated to the quantized value of the weight value to be adjusted. In the case of symmetric quantization, the rounded result is updated to the quantized value of the weight value to be adjusted.

[0113] In this embodiment, in the case of asymmetric quantization, the value of the weight to be adjusted after quantization is calculated using formula (13), and in the case of symmetric quantization, the value of the weight to be adjusted after quantization is calculated using formula (14).

[0114] In formulas (13) and (14), This represents the ratio of the weight value to be adjusted to the scaling factor.

[0115] The weight values ​​to be adjusted in any group can be quantified using the process shown in Figure 6.

[0116] In one alternative approach, there are several ways to group the weight values ​​in the floating-point model; two feasible methods are provided below.

[0117] Method 1: Group the weight values ​​in the floating-point model according to the channel to which the weight value belongs. Weight values ​​belonging to the same channel are grouped into the same group.

[0118] For example, the weights of the convolutional layer in a floating-point model are four-dimensional tensors, represented as s×e×h×r, where s represents the number of output channels of the convolutional layer, e represents the number of input channels of the convolutional layer, and h×r represents the h×r convolutional kernel. During quantization, the e×h×r weights are grouped together.

[0119] Method 2: Group the weights in the floating-point model according to the network layer to which the weights belong; weights belonging to the same network layer are grouped into the same group.

[0120] In this embodiment of the application, when quantizing the weight value, the minimum quantization error or the target value is used as a constraint condition. Quantizing the weight value can reduce the error caused by quantization and improve the inference accuracy of the quantized model.

[0121] In this application embodiment, the products that may be involved include model compression tools or inference model deployment tools, etc. When determining whether infringement has occurred, the following methods can be used to determine whether infringement has occurred:

[0122] 1. Determine whether input data is needed based on the quantized input after training, and whether the data distribution of activation values ​​is required.

[0123] 2. Analyze the model compression process and logs to determine whether the quantization process uses a dataset, whether additional data processing steps are performed, and whether it is necessary to initialize quantization parameters for different random data to calculate input activation values ​​for different data distributions.

[0124] 3. Examine the features released by the model compression tool to see if it integrates the above-mentioned quantization process after training without data.

[0125] Figure 7 is a structural diagram of the device for quantization after training without data provided in an embodiment of this application. This device can be implemented as part or all of the device through software, hardware, or a combination of both. The device provided in this embodiment of the application can implement the processes described in Figures 4 to 6 of this embodiment of the application. The device includes: an acquisition module 710 and a quantization module 720, wherein:

[0126] The acquisition module 710 is used to acquire the data distribution of user input. The data distribution is the distribution of the input activation values ​​of each network layer of the floating-point model. Specifically, it can be used to implement the acquisition function of step 501 and execute the implicit steps included in step 501.

[0127] Quantization module 720, used for:

[0128] Random data is input into the floating-point model to obtain the input activation values ​​of each network layer;

[0129] Based on the data distribution, statistical analysis is performed on the input activation values ​​of each network layer to obtain the data range of the input activation values ​​of each network layer.

[0130] Based on the endpoint values ​​of the data range, the quantization parameters of the input activation values ​​of each network layer are determined;

[0131] During the inference process using the floating-point model, the input activation values ​​generated during the inference process of each network layer are quantized using the quantization parameters of the input activation values ​​of each network layer. Specifically, this can be used to implement the input activation value quantization function in steps 502 to 505 and to execute the implicit steps contained in steps 502 to 505.

[0132] In an alternative embodiment, the quantization module 720 is configured to:

[0133] For each network layer of the floating-point model, the initial value of the quantization parameter of the input activation value of the network layer is determined using the endpoint values ​​of the data range of the input activation value of the network layer;

[0134] Using the initial value of the quantization parameter, the input activation value of the network layer is quantized to obtain the quantized input activation value.

[0135] Based on the quantized input activation value and the input activation value of the network layer, determine the quantization error of the input activation value of the network layer;

[0136] The initial value of the quantization parameter of the input activation value of the network layer is updated until the quantization error of the input activation value of the network layer is less than or equal to the target value, or minimized, so as to obtain the value of the quantization parameter of the input activation value of the network layer.

[0137] In one alternative approach, the quantization parameters include a scaling factor and a quantization bias;

[0138] The quantization module 720 is used for:

[0139] With the scaling factor as the initial value, the quantization bias is updated until the quantization error of the input activation value of the network layer is less than or equal to the target value, or minimized, so as to obtain the value of the quantization bias.

[0140] Once the quantization bias update is complete, the scaling factor is updated until the quantization error of the input activation value of the network layer is less than or equal to the target value, or minimized, to obtain the value of the scaling factor.

[0141] In an alternative embodiment, the quantization module 720 is further configured to:

[0142] For each group of the floating-point model, the quantization parameters corresponding to the group are determined. In the case of asymmetric quantization, the quantization parameters corresponding to the group include a scaling factor and a quantization bias. In the case of symmetric quantization, the quantization parameters corresponding to the group include a scaling factor.

[0143] Based on the quantization parameters corresponding to the group, the weight values ​​in the group are quantized to obtain the quantized values ​​of the weight values ​​in the group.

[0144] In an alternative embodiment, the quantization module 720 is further configured to:

[0145] Determine the perturbation tensor corresponding to the quantization and rounding of the weight values ​​to be adjusted in the group. The weight values ​​to be adjusted are the top K weight values ​​in the group whose quantization errors are arranged from largest to smallest. The perturbation tensor is used to adjust the rounding direction when the weight values ​​to be adjusted are quantized and rounded.

[0146] Determine the ratio of the weight value to be adjusted to the corresponding scaling factor;

[0147] The sum of the ratio and the perturbation tensor is rounded to obtain a rounded result. In the case of asymmetric quantization, the sum of the rounded result and the quantization bias corresponding to the weight value to be adjusted is updated to the quantized value of the weight value to be adjusted. In the case of symmetric quantization, the rounded result is updated to the quantized value of the weight value to be adjusted.

[0148] In an alternative embodiment, the acquisition module 710 is configured to:

[0149] The weight values ​​in the floating-point model are grouped according to the channel to which the weight value belongs, wherein weight values ​​in the same channel belong to the same group.

[0150] The detailed process of input activation value quantization by the data-free training post-quantization device shown in Figure 7 is described in the preceding embodiments and will not be repeated here. The data-free training post-quantization device shown in Figure 7 is the computing device 102 in Figures 1 and 2.

[0151] In one alternative approach, a computer program product is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computing device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computing device to perform the processes shown in Figures 4 through 6.

[0152] Those skilled in the art will recognize that the method steps and units described in the embodiments disclosed in this application can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the steps and components of each embodiment have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0153] In the embodiments provided in this application, it should be understood that the disclosed system architecture, apparatus, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or modules, or may be electrical, mechanical, or other forms of connection.

[0154] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the embodiments of this application, depending on actual needs.

[0155] Furthermore, the modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or in software.

[0156] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or 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 in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0157] In this application, the term "multiple" means two or more.

[0158] The above description is merely an exemplary embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and such modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method of data-free post-training quantization, characterized in that, The method comprises: obtaining a data distribution input by a user, the data distribution being a distribution to which input activation values of each network layer of a floating-point model conform; inputting random data into the floating-point model to obtain the input activation values of the each network layer; based on the data distribution, statistically analyzing the input activation values of the each network layer to obtain a data range of the input activation values of the each network layer; based on an endpoint value of the data range, determining a quantization parameter of the input activation values of the each network layer; in an inference process using the floating-point model, using the quantization parameter of the input activation values of the each network layer to quantize input activation values generated in an inference process of the each network layer.

2. The method of claim 1, wherein, The method further comprises: for each network layer of the floating-point model, using an endpoint value of a data range of the input activation values of the network layer to determine an initial value of a quantization parameter of the input activation values of the network layer; using the initial value of the quantization parameter to quantize the input activation values of the network layer to obtain quantized input activation values; based on the quantized input activation values and the input activation values of the network layer, determining a quantization error of the input activation values of the network layer; updating the initial value of the quantization parameter of the input activation values of the network layer until the quantization error of the input activation values of the network layer is less than or equal to a target value or is minimum, to obtain a value of the quantization parameter of the input activation values of the network layer.

3. The method of claim 2, wherein, The quantization parameter comprises a scaling factor and a quantization bias. The method further comprises: in a case where the scaling factor is an initial value, updating the quantization bias until the quantization error of the input activation values of the network layer is less than or equal to the target value or is minimum, to obtain a value of the quantization bias; in a case where the updating of the quantization bias is completed, updating the scaling factor until the quantization error of the input activation values of the network layer is less than or equal to the target value or is minimum, to obtain a value of the scaling factor.

4. The method according to any one of claims 1 to 3, characterized in that, The method further comprises: for each group of the floating-point model, determining a quantization parameter corresponding to the group, wherein in a case of asymmetric quantization, the quantization parameter corresponding to the group comprises a scaling factor and a quantization bias, and in a case of symmetric quantization, the quantization parameter corresponding to the group comprises a scaling factor; based on the quantization parameter corresponding to the group, quantizing weight values in the group to obtain quantized values of the weight values in the group.

5. The method of claim 4, wherein, The method further comprises: determining a perturbation tensor corresponding to quantization rounding of a to-be-adjusted weight value in the group, the to-be-adjusted weight value being a top K weight value in the group in descending order of quantization error in quantization, and the perturbation tensor being used to adjust a rounding direction of the quantization rounding of the to-be-adjusted weight value. determining a ratio of the weight value to be adjusted and a corresponding scaling factor; performing integer processing on a sum of the ratio and the perturbation tensor to obtain an integer result, and updating a sum of the integer result and a quantization bias corresponding to the weight value to be adjusted to be a quantized value of the weight value to be adjusted in a case of asymmetric quantization, or updating the integer result to be the quantized value of the weight value to be adjusted in a case of symmetric quantization.

6. The method according to claim 4 or 5, characterized in that, The method further includes: grouping weight values in the floating-point model according to channels to which the weight values belong, wherein weight values in a same channel belong to a same group.

7. An apparatus for data-free post-training quantization, the apparatus comprising: The apparatus includes: an obtaining module configured to obtain a data distribution input by a user, the data distribution being a distribution to which input activation values of each network layer of a floating-point model conform; a quantizing module configured to: input random data into the floating-point model to obtain the input activation values of the each network layer; perform statistical analysis on the input activation values of the each network layer based on the data distribution to obtain a data range of the input activation values of the each network layer; determine quantization parameters of the input activation values of the each network layer based on endpoint values of the data range; and quantize input activation values generated in a reasoning process of the each network layer using the quantization parameters of the input activation values of the each network layer in the reasoning process of the floating-point model.

8. The apparatus of claim 7, wherein, The quantizing module is configured to: for each network layer of the floating-point model, determine an initial value of the quantization parameters of the input activation values of the network layer using endpoint values of a data range of the input activation values of the network layer; quantize the input activation values of the network layer using the initial value of the quantization parameters to obtain quantized input activation values; determine a quantization error of the input activation values of the network layer based on the quantized input activation values and the input activation values of the network layer; update the initial value of the quantization parameters of the input activation values of the network layer until the quantization error of the input activation values of the network layer is less than or equal to a target value or is minimum to obtain a value of the quantization parameters of the input activation values of the network layer.

9. The apparatus of claim 8, wherein, The quantization parameters include a scaling factor and a quantization bias. The quantizing module is configured to: update the quantization bias until the quantization error of the input activation values of the network layer is less than or equal to the target value or is minimum to obtain a value of the quantization bias in a case where the scaling factor is an initial value; update the scaling factor until the quantization error of the input activation values of the network layer is less than or equal to the target value or is minimum to obtain a value of the scaling factor in a case where the update of the quantization bias is completed.

10. The apparatus of any one of claims 7 to 9, wherein, The quantizing module is further configured to: for each group of the floating-point model, determine quantization parameters corresponding to the group, wherein the quantization parameters corresponding to the group include a scaling factor and a quantization bias in a case of asymmetric quantization, and the quantization parameters corresponding to the group include a scaling factor in a case of symmetric quantization; and quantize weight values in the group based on the quantization parameters corresponding to the group to obtain quantized values of the weight values in the group.

11. The apparatus of claim 10, wherein, The quantization module is further configured to: determine a perturbation tensor corresponding to the quantization rounding of the to-be-adjusted weight values in the group, the to-be-adjusted weight values being the first K weight values arranged in descending order of quantization error in the group, the perturbation tensor being used to adjust the rounding direction of the quantization rounding of the to-be-adjusted weight values; determine a ratio of the to-be-adjusted weight values to the corresponding scaling factors; perform rounding processing on the sum of the ratio and the perturbation tensor to obtain a rounding result, and update the rounding result and the sum of the quantization bias corresponding to the to-be-adjusted weight values to obtain the quantized value of the to-be-adjusted weight values in the case of asymmetric quantization, or update the rounding result to the quantized value of the to-be-adjusted weight values in the case of symmetric quantization.

12. The apparatus of claim 10 or 11, wherein, The obtaining module is configured to: group the weight values in the floating-point model according to the channels to which the weight values belong, wherein the weight values in the same channel belong to one group.

13. A computing device, comprising: The computing device includes a processor and a memory, wherein: The memory stores computer instructions; The processor executes the computer instructions to enable the computing device to perform the method of any one of claims 1 to 6.

14. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions, and when the computer instructions in the computer readable storage medium are executed by a computing device, the computing device is enabled to perform the method of any one of claims 1 to 6.