A deep learning model reasoning method, system, device and computer medium

By determining the quantitative parameters of channels and branches in the deep learning model, the problem of low inference accuracy of the deep learning model in the existing technology is solved, and efficient and accurate inference results are achieved.

CN114444658BActive Publication Date: 2024-09-20INSPUR SUZHOU INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202111675314.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2024-09-20
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

The reasoning accuracy of existing deep learning models is poor, mainly because the existing quantization method is hierarchical quantization, which makes it difficult to balance calculation efficiency and accuracy.

Method used

By determining the channel quantization parameters of each channel in the target deep learning model, and determining the branch quantization parameters based on the relationship between the channel and the model branch, fine-grained quantization parameter determination is achieved, thereby improving the inference accuracy. Specific methods include determining the absolute maximum value of the channel as a quantization parameter, quantizing in combination with preset values, and considering the summation and comparison of different types of parameters during branch quantization to ensure calculation accuracy.

Benefits of technology

It improves the inference accuracy of the deep learning model, realizes the inference of the deep learning model based on fine-grained channel quantization parameters, and significantly improves the calculation efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114444658B
    Figure CN114444658B
Patent Text Reader

Abstract

The present application discloses a deep learning model reasoning method, system, device and computer medium, which determine the channel quantization parameters of each channel in the target deep learning model; determine the branch quantization parameters of the model branch based on the channel quantization parameters according to the relationship between the channel and the model branch in the target deep learning model; quantize the target deep learning model based on the branch quantization parameters to obtain a quantized deep learning model; and perform reasoning based on the quantized deep learning model to obtain a reasoning result. In the present application, the channel quantization parameters of each channel in the target deep learning module are determined, and fine-grained quantization parameter determination is achieved. The branch quantization parameters of the model branch are determined based on the channel quantization parameters, and reasoning is performed based on the quantized deep learning model to obtain a reasoning result, which realizes deep learning model reasoning based on fine-grained channel quantization parameters and improves the reasoning accuracy of the deep learning model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of deep learning technology, and more specifically, to a deep learning model reasoning method, system, device and computer medium. Background Art

[0002] Deep learning (i.e. deep neural network) is a branch of machine learning. It is an algorithm that uses artificial neural network as the architecture to achieve pattern recognition (i.e. reasoning) by learning (i.e. training) information features. The characteristic of deep learning is to use unsupervised or semi-supervised feature learning and hierarchical feature extraction to replace manual feature extraction. The engineering implementation of deep learning training and reasoning process generally relies on deep learning framework. Deep learning framework focuses on rich deep learning model structure and operator expression, but there is no perfect solution for how to efficiently implement reasoning tasks on different hardware backends. As a common component and bridge between framework and hardware, the deep learning compiler hopes to achieve the goal of automatically generating the optimal reasoning code for any device from the model generated by the deep learning framework. For example, operators developed for CPU can be used almost intact for GPU and ASIC chips, thereby significantly reducing costs.

[0003] Before performing inference calculations, the deep learning compiler can quantize the model. By using quantization parameters, the weights in the model and the feature maps in the inference calculation process can be quantized to low-precision data to achieve low-precision inference with high computational efficiency. There are currently two mainstream quantization methods: offline quantization and training quantization. However, the existing quantization methods are all hierarchical quantization, which makes the inference accuracy of deep learning models poor.

[0004] In summary, how to improve the reasoning accuracy of deep learning models is an urgent problem to be solved by technical personnel in this field. Summary of the invention

[0005] The purpose of this application is to provide a deep learning model reasoning method, which can solve the technical problem of how to improve the reasoning accuracy of the deep learning model to a certain extent. This application also provides a deep learning model reasoning system, device and computer-readable storage medium.

[0006] In order to achieve the above objectives, this application provides the following technical solutions:

[0007] A deep learning model reasoning method, comprising:

[0008] Determine the channel quantization parameters of each channel in the target deep learning model;

[0009] According to the relationship between the channel and the model branch in the target deep learning model, determining the branch quantization parameter of the model branch based on the channel quantization parameter;

[0010] Quantize the target deep learning model based on the branch quantization parameter to obtain a quantized deep learning model;

[0011] Reasoning is performed based on the quantized deep learning model to obtain reasoning results.

[0012] Preferably, determining the channel quantization parameter of each channel in the target deep learning model includes:

[0013] Determining an absolute maximum value of the channel of the target deep learning model;

[0014] The channel quantization parameter corresponding to the channel is determined based on the absolute maximum value of the channel.

[0015] Preferably, determining the channel quantization parameter corresponding to the channel based on the absolute maximum value of the channel includes:

[0016] The sum of the absolute maximum value of the channel and a preset value is used as the channel quantization parameter corresponding to the channel.

[0017] Preferably, the determining the branch quantization parameter of the model branch based on the channel quantization parameter includes:

[0018] If both of the two channel quantization parameters are scalars, the channel quantization parameter with a smaller value is used as the branch quantization parameter of the model branch.

[0019] Preferably, the determining the branch quantization parameter of the model branch based on the channel quantization parameter includes:

[0020] If both of the two channel quantization parameters are vectors, the two channel quantization parameters are compared channel by channel, and the smaller channel quantization parameter of the two channels is used as the branch quantization parameter of the model branch.

[0021] Preferably, the determining the branch quantization parameter of the model branch based on the channel quantization parameter includes:

[0022] If the two channel quantization parameters are a scalar and a vector respectively, the sum of the elements of the channel quantization parameter of the vector and the channel quantization parameter of the scalar is used as the corresponding element of the branch quantization parameter of the model branch to obtain the branch quantization parameter.

[0023] Preferably, the determining the branch quantization parameter of the model branch based on the channel quantization parameter includes:

[0024] If the quantization parameters of the two channels are neither vectors nor scalars, the channel quantization parameter of the channel with the convolution operation is used as the branch quantization parameter of the model branch.

[0025] A deep learning model inference system, comprising:

[0026] A first determination module, used to determine a channel quantization parameter of each channel in a target deep learning model;

[0027] A second determination module is used to determine a branch quantization parameter of the model branch based on the channel quantization parameter according to the relationship between the channel and the model branch in the target deep learning model;

[0028] A first quantization module, configured to quantize the target deep learning model based on the branch quantization parameter to obtain a quantized deep learning model;

[0029] The first reasoning module is used to perform reasoning based on the quantized deep learning model to obtain a reasoning result.

[0030] A deep learning model inference device, comprising:

[0031] Memory for storing computer programs;

[0032] A processor is used to implement the steps of any of the deep learning model inference methods described above when executing the computer program.

[0033] A computer-readable storage medium having a computer program stored therein, wherein the computer program, when executed by a processor, implements the steps of any of the deep learning model inference methods described above.

[0034] The present application provides a deep learning model inference method, which determines the channel quantization parameters of each channel in the target deep learning model; determines the branch quantization parameters of the model branches based on the channel quantization parameters according to the relationship between the channels and the model branches in the target deep learning model; quantizes the target deep learning model based on the branch quantization parameters to obtain a quantized deep learning model; and performs inference based on the quantized deep learning model to obtain an inference result. In the present application, the channel quantization parameters of each channel in the target deep learning module are determined, and fine-grained quantization parameter determination is achieved. The branch quantization parameters of the model branches are determined based on the channel quantization parameters, the target deep learning model is quantized based on the branch quantization parameters to obtain a quantized deep learning model, and inference is performed based on the quantized deep learning model to obtain an inference result, which realizes deep learning model inference based on fine-grained channel quantization parameters and improves the inference accuracy of the deep learning model. The present application provides a deep learning model inference system, device and computer-readable storage medium that also solves corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0036] Figure 1 A flowchart of a deep learning model reasoning method provided in an embodiment of the present application;

[0037] Figure 2 A schematic diagram of the structure of a deep learning model reasoning system provided in an embodiment of the present application;

[0038] Figure 3 A schematic diagram of the structure of a deep learning model inference device provided in an embodiment of the present application;

[0039] Figure 4 Another structural schematic diagram of a deep learning model inference device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0040] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0041] See also Figure 1 , Figure 1 A flowchart of a deep learning model reasoning method provided in an embodiment of the present application.

[0042] A deep learning model reasoning method provided in an embodiment of the present application may include the following steps:

[0043] Step S101: Determine the channel quantization parameter of each channel in the target deep learning model.

[0044] In practical applications, the channel quantization parameters of each channel in the target deep learning model can be determined first. The type of the target deep learning model and the corresponding channel information can be determined according to actual needs, and this application does not make specific limitations here.

[0045] In specific application scenarios, in the process of determining the channel quantization parameters of each channel in the target deep learning model, the absolute maximum value of the channel of the target deep learning model can be determined; the channel quantization parameter corresponding to the channel is determined based on the absolute maximum value of the channel, such as taking the sum of the absolute maximum value of the channel and the preset value as the channel quantization parameter corresponding to the channel, etc. The specific value of the preset value can be determined according to actual needs, such as the preset value can be 0.001, etc.

[0046] It should be noted that in specific application scenarios, pseudo-quantization is required in the inference process of the target deep learning model, that is, pseudo-quantization nodes are embedded in certain identifiable operations to statistically analyze the distribution of data flowing through the node during training and obtain quantization parameters. Floating-point data mapped by the integer data range can be used for pseudo-quantization inference to verify the theoretical calculation accuracy of the quantization algorithm. When mounting the pseudo-quantization operator, corresponding operations need to be performed according to the dimension of the channel. The weight data dimension of Depthwise convolution is different from that of ordinary convolution, so the channels can be marked as the channels corresponding to Depthwise convolution and the channels corresponding to other convolutions. Specifically, axis=-1 can be used to represent the channels corresponding to other convolutions, and axis=2 can be used to represent the channels corresponding to Depthwise convolution, etc. Correspondingly, for the channels with axis=-1, the modulus operation of the tensor dimension by axis can be converted into the last dimension of the tensor, etc. Among them, when identifying the channel corresponding to the Depthwise convolution, if the groups of the convolution operator of the channel are equal to the channels and the groups is not equal to 1, then the channel is the channel corresponding to the Depthwise convolution.

[0047] Step S102: According to the relationship between channels and model branches in the target deep learning model, determine the branch quantization parameters of the model branches based on the channel quantization parameters.

[0048] In practical applications, each channel of a deep learning model will constitute a model branch. Therefore, after determining the channel quantization parameters of each channel in the target deep learning model, it is also necessary to determine the branch quantization parameters of the model branch based on the channel quantization parameters according to the relationship between the channel and the model branch in the target deep learning model.

[0049] In specific application scenarios, in the process of determining the branch quantization parameters of the model branch based on the channel quantization parameters according to the relationship between the channels and the model branches in the target deep learning model, no matter how many channels the model branch is composed of, it can be split into the sum of the quantization parameters between two channels. That is, in the process of determining the branch quantization parameters of the model branch based on the channel quantization parameters, if both channel quantization parameters are scalars, the channel quantization parameter with the smaller value will be used as the branch quantization parameter of the model branch. That is, when both the left and right input channels are of int8 type, priority is given to avoiding data range compression rather than data truncation. When the left and right input channels are of int8 type at one end and int32 type at the other end, since the quantization parameter of int32 type is smaller, the sum operator will use the quantization parameter of int32 type to ensure the calculation accuracy to the greatest extent.

[0050] Correspondingly, if both channel quantization parameters are vectors, the two channel quantization parameters are compared channel by channel, and the smaller channel quantization parameter in both channels is used as the branch quantization parameter of the model branch.

[0051] Correspondingly, if the two channel quantization parameters are a scalar and a vector respectively, the sum of the elements of the channel quantization parameter of the vector and the channel quantization parameter of the scalar is used as the corresponding element of the branch quantization parameter of the model branch to obtain the branch quantization parameter to avoid data truncation.

[0052] Correspondingly, if the quantization parameters of the two channels are neither vectors nor scalars, the channel quantization parameters of the channels with convolution operations are used as the branch quantization parameters of the model branches.

[0053] Step S103: quantize the target deep learning model based on the branch quantization parameter to obtain a quantized deep learning model.

[0054] In practical applications, after determining the branch quantization parameters of the model branches based on the channel quantization parameters according to the relationship between the channels and the model branches in the target deep learning model, the target deep learning model can be quantized based on the branch quantization parameters to obtain a quantized deep learning model. Specifically, the channel-by-channel quantization inference calculation method used for tflite pre-quantization model inference can be reused to quantize the target deep learning model based on the branch quantization parameters to obtain a quantized deep learning model.

[0055] Step S104: Perform inference based on the quantized deep learning model to obtain an inference result.

[0056] In practical applications, after quantizing the target deep learning model based on the branch quantization parameters to obtain the quantized deep learning model, reasoning can be performed based on the quantized deep learning model to obtain the reasoning result.

[0057] The present application provides a deep learning model inference method, which determines the channel quantization parameters of each channel in the target deep learning model; determines the branch quantization parameters of the model branches based on the channel quantization parameters according to the relationship between the channels and the model branches in the target deep learning model; quantizes the target deep learning model based on the branch quantization parameters to obtain a quantized deep learning model; and performs inference based on the quantized deep learning model to obtain an inference result. In the present application, the channel quantization parameters of each channel in the target deep learning module are determined, and fine-grained quantization parameter determination is achieved. The branch quantization parameters of the model branches are determined based on the channel quantization parameters, the target deep learning model is quantized based on the branch quantization parameters to obtain a quantized deep learning model, and inference is performed based on the quantized deep learning model to obtain an inference result, which achieves deep learning model inference based on fine-grained channel quantization parameters and improves the inference accuracy of the deep learning model.

[0058] In order to facilitate the understanding of the deep learning model reasoning method provided by the present application, the method provided by the present application is now described in combination with TVM (Tensor Virtual Machine). It should be noted that TVM is an open source deep learning compiler designed for CPU, GPU and dedicated accelerator (ASIC). Its function is to effectively connect the deep learning framework focusing on richness with the hardware backend focusing on performance or efficiency. The quantization process in TVM can be as follows:

[0059] 1. Define the data structure: that is, set the quantization parameter type of the operator to a vector, and use the axis attribute to mark the dimension of the corresponding channel in the channel quantization;

[0060] 2. In the Annotation stage, optimize the implementation and mounting of pseudo-quantization operators:

[0061] (1) Depthwise convolution identification: Depthwise convolution is identified in the rewriting phase of the conv2d operator. Since the weight data dimensions of depthwise convolution and ordinary convolution are different, the depthwise convolution flag is used to distinguish the channel dimensions of depthwise convolution and ordinary convolution when mounting the pseudo-quantization operator in the subsequent phase. The judgment condition for depthwise convolution is that the groups and channels of the convolution operator are equal and groups is not equal to 1.

[0062] (2) Mounting of pseudo-quantization operator: The mounting entry of pseudo-quantization operator needs to pass in the axis parameter, which is used to determine the dimension of the channel for channel-wise quantization. The default axis is -1. For Depthwise convolution, axis is 2. For the default case of axis = -1, the axis modulus operation on the tensor dimension will be used to convert it into the last dimension of the tensor in subsequent calculations.

[0063] 3. In the Calibration phase, the quantization parameter calculation phase of the deep learning compiler, different modules control different weight and feature map quantization parameter calculation methods. However, the current mainstream weight quantization parameter calculation methods only have two modes: max and power2. The channel_max mode is added. According to the axis attribute, the corresponding channels are quantized by channel, that is, the absolute maximum value of each channel is taken as the quantization parameter. In order to avoid the absolute maximum value being too small and causing subsequent calculation accuracy errors, it is necessary to add an epsilon small amount to the absolute maximum value. The value of this small amount can be 0.0001.

[0064] 4. In the Realization phase, perform the following steps:

[0065] (1) Quantization process implementation: In the Realization stage, the key method called in the implementation stage of the pseudo-quantization operator reuses the channel-wise quantization inference calculation method used for tflite pre-quantization model inference. In the current layer calculation output stage of Realization, the dequantization process is changed from the scalar quantization parameter calculation mode to the vector parameter calculation mode.

[0066] (2) Quantization parameter fusion: When processing the sum operator in the existing deep learning compiler quantization module, the smaller quantization parameter of the two inputs is selected as the new quantization parameter. When performing layered quantization, the quantization parameter is a scalar, and this processing method is feasible; but when performing channel-by-channel quantization, the quantization parameter may be a vector or a scalar. When the quantization parameter is a vector, it is not possible to simply select the "smaller" one of the two vector quantization parameters. It needs to be processed as follows: For the case where one of the two inputs is a pseudo-quantization operator and the other is a non-pseudo-quantization operator, the quantization parameter of the pseudo-quantization operator is used as the quantization parameter of the sum operator (mainly processing the sum in the BiasAdd operator. Since the subsequent graph optimization process of the deep learning compiler contains a constant folding graph optimization method, this processing method of BiasAdd can avoid adding additional operators in the weight quantization calculation process, and no secondary quantization is required in the feature map quantization process).

[0067] For other two-input cases, if both channel quantization parameters are scalars, the channel quantization parameter with the smaller value is used as the branch quantization parameter of the model branch; if both channel quantization parameters are vectors, the two channel quantization parameters are compared channel by channel, and the channel quantization parameter with the smaller value in both channels is used as the branch quantization parameter of the model branch; if the two channel quantization parameters are a scalar and a vector respectively, the sum of the elements of the channel quantization parameter of the vector and the channel quantization parameter of the scalar is used as the corresponding element of the branch quantization parameter of the model branch to obtain the branch quantization parameter; if the quantization parameters of the two channels are neither vectors nor scalars, the channel quantization parameter of the channel with convolution operation is used as the branch quantization parameter of the model branch.

[0068] See also Figure 2 , Figure 2 A schematic diagram of the structure of a deep learning model reasoning system provided in an embodiment of the present application.

[0069] A deep learning model reasoning system provided in an embodiment of the present application may include:

[0070] A first determination module 101 is used to determine a channel quantization parameter of each channel in a target deep learning model;

[0071] A second determination module 102 is used to determine a branch quantization parameter of a model branch based on a channel quantization parameter according to a relationship between a channel and a model branch in a target deep learning model;

[0072] A first quantization module 103, configured to quantize a target deep learning model based on a branch quantization parameter to obtain a quantized deep learning model;

[0073] The first reasoning module 104 is used to perform reasoning based on the quantized deep learning model to obtain a reasoning result.

[0074] In a deep learning model inference system provided in an embodiment of the present application, the first determination module may include:

[0075] A first determining unit, configured to determine an absolute maximum value of a channel of a target deep learning model;

[0076] The second determining unit is used to determine a channel quantization parameter corresponding to the channel based on the absolute maximum value of the channel.

[0077] In a deep learning model inference system provided by an embodiment of the present application, the second determination unit can be specifically used to: use the sum of the absolute maximum value of the channel and the preset value as the channel quantization parameter corresponding to the channel.

[0078] In a deep learning model inference system provided in an embodiment of the present application, the second determination module may include:

[0079] The third determining unit is configured to use the channel quantization parameter with a smaller value as the branch quantization parameter of the model branch if both channel quantization parameters are scalars.

[0080] In a deep learning model inference system provided in an embodiment of the present application, the second determination module may include:

[0081] The fourth determining unit is used for comparing the two channel quantization parameters channel by channel if both channel quantization parameters are vectors, and taking the smaller channel quantization parameter in the two channels as the branch quantization parameter of the model branch.

[0082] In a deep learning model inference system provided in an embodiment of the present application, the second determination module may include:

[0083] The fifth determining unit is configured to, if the two channel quantization parameters are a scalar and a vector respectively, use the sum of the elements of the channel quantization parameter of the vector and the channel quantization parameter of the scalar as the corresponding elements of the branch quantization parameters of the model branch to obtain the branch quantization parameters.

[0084] In a deep learning model inference system provided in an embodiment of the present application, the second determination module may include:

[0085] The sixth determining unit is configured to use the channel quantization parameter of the channel having the convolution operation as the branch quantization parameter of the model branch if the quantization parameters of the two channels are neither vectors nor scalars.

[0086] The present application also provides a deep learning model inference device and a computer-readable storage medium, both of which have the corresponding effects of a deep learning model inference method provided in an embodiment of the present application. Figure 3 , Figure 3 A schematic diagram of the structure of a deep learning model inference device provided in an embodiment of the present application.

[0087] A deep learning model inference device provided in an embodiment of the present application includes a memory 201 and a processor 202. The memory 201 stores a computer program. When the processor 202 executes the computer program, the following steps are implemented:

[0088] Determine the channel quantization parameters of each channel in the target deep learning model;

[0089] According to the relationship between channels and model branches in the target deep learning model, the branch quantization parameters of the model branches are determined based on the channel quantization parameters;

[0090] Quantize the target deep learning model based on the branch quantization parameters to obtain a quantized deep learning model;

[0091] Reasoning is performed based on the quantized deep learning model to obtain the reasoning results.

[0092] A deep learning model inference device provided in an embodiment of the present application includes a memory 201 and a processor 202. The memory 201 stores a computer program. When the processor 202 executes the computer program, the following steps are implemented: determining the absolute maximum value of the channel of the target deep learning model; determining the channel quantization parameter corresponding to the channel based on the absolute maximum value of the channel.

[0093] A deep learning model inference device provided in an embodiment of the present application includes a memory 201 and a processor 202. A computer program is stored in the memory 201. When the processor 202 executes the computer program, the following steps are implemented: the sum of the absolute maximum value of the channel and the preset value is used as the channel quantization parameter corresponding to the channel.

[0094] A deep learning model inference device provided in an embodiment of the present application includes a memory 201 and a processor 202. A computer program is stored in the memory 201. When the processor 202 executes the computer program, the following steps are implemented: if both channel quantization parameters are scalars, the channel quantization parameter with a smaller value is used as the branch quantization parameter of the model branch.

[0095] A deep learning model inference device provided in an embodiment of the present application includes a memory 201 and a processor 202. A computer program is stored in the memory 201. When the processor 202 executes the computer program, the following steps are implemented: if both channel quantization parameters are vectors, the two channel quantization parameters are compared channel by channel, and the smaller channel quantization parameter in both channels is used as the branch quantization parameter of the model branch.

[0096] A deep learning model inference device provided in an embodiment of the present application includes a memory 201 and a processor 202. A computer program is stored in the memory 201. When the processor 202 executes the computer program, the following steps are implemented: if the two channel quantization parameters are a scalar and a vector, respectively, then the sum of the elements of the channel quantization parameter of the vector and the channel quantization parameter of the scalar is used as the corresponding element of the branch quantization parameter of the model branch to obtain the branch quantization parameter.

[0097] A deep learning model inference device provided in an embodiment of the present application includes a memory 201 and a processor 202. A computer program is stored in the memory 201. When the processor 202 executes the computer program, the following steps are implemented: if the quantization parameters of the two channels are neither vectors nor scalars, the channel quantization parameters of the channel with convolution operation are used as branch quantization parameters of the model branch.

[0098] See also Figure 4, another deep learning model inference device provided in the embodiment of the present application may also include: an input port 203 connected to the processor 202, used to transmit commands input from the outside to the processor 202; a display unit 204 connected to the processor 202, used to display the processing results of the processor 202 to the outside; a communication module 205 connected to the processor 202, used to realize the communication between the deep learning model inference device and the outside. The display unit 204 can be a display panel, a laser scanning display, etc.; the communication mode adopted by the communication module 205 includes but is not limited to mobile high-definition link technology (HML), universal serial bus (USB), high-definition multimedia interface (HDMI), wireless connection: wireless fidelity technology (WiFi), Bluetooth communication technology, low-power Bluetooth communication technology, and communication technology based on IEEE802.11s.

[0099] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0100] Determine the channel quantization parameters of each channel in the target deep learning model;

[0101] According to the relationship between channels and model branches in the target deep learning model, the branch quantization parameters of the model branches are determined based on the channel quantization parameters;

[0102] Quantize the target deep learning model based on the branch quantization parameters to obtain a quantized deep learning model;

[0103] Reasoning is performed based on the quantized deep learning model to obtain the reasoning results.

[0104] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: determining the absolute maximum value of the channel of the target deep learning model; and determining the channel quantization parameter corresponding to the channel based on the absolute maximum value of the channel.

[0105] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: the sum of the absolute maximum value of the channel and the preset value is used as the channel quantization parameter corresponding to the channel.

[0106] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: if both channel quantization parameters are scalars, the channel quantization parameter with a smaller value is used as the branch quantization parameter of the model branch.

[0107] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: if both channel quantization parameters are vectors, the two channel quantization parameters are compared channel by channel, and the smaller channel quantization parameter in both channels is used as the branch quantization parameter of the model branch.

[0108] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: if two channel quantization parameters are a scalar and a vector, respectively, then the sum of the elements of the channel quantization parameter of the vector and the channel quantization parameter of the scalar is used as the corresponding element of the branch quantization parameter of the model branch to obtain the branch quantization parameter.

[0109] An embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: if the quantization parameters of the two channels are neither vectors nor scalars, the channel quantization parameters of the channel with convolution operation are used as branch quantization parameters of the model branch.

[0110] The computer-readable storage medium involved in the present application includes random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or any other form of storage medium known in the technical field.

[0111] For the description of the relevant parts of the deep learning model inference system, device and computer-readable storage medium provided in the embodiments of the present application, please refer to the detailed description of the corresponding parts in the deep learning model inference method provided in the embodiments of the present application, which will not be repeated here. In addition, the parts of the above-mentioned technical solutions provided in the embodiments of the present application that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive elaboration.

[0112] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0113] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A deep learning model reasoning method, characterized in that: include: Determine the channel quantization parameters of each channel in the target deep learning model; According to the relationship between the channel and the model branch in the target deep learning model, determining the branch quantization parameter of the model branch based on the channel quantization parameter; Quantize the target deep learning model based on the branch quantization parameter to obtain a quantized deep learning model; Perform reasoning based on the quantized deep learning model to obtain a reasoning result; The target deep learning model includes an open source deep learning compiler designed for CPU, GPU and dedicated accelerator, which is used to connect the deep learning framework focusing on richness and the hardware backend focusing on performance or efficiency; Wherein, determining the channel quantization parameter of each channel in the target deep learning model includes: Determining an absolute maximum value of the channel of the target deep learning model; Determine the channel quantization parameter corresponding to the channel based on the absolute maximum value of the channel; Wherein, determining the branch quantization parameter of the model branch based on the channel quantization parameter includes: If both of the two channel quantization parameters are scalars, the channel quantization parameter with a smaller value is used as the branch quantization parameter of the model branch; If both of the two channel quantization parameters are vectors, comparing the two channel quantization parameters channel by channel, and taking the smaller channel quantization parameter of the two channels as the branch quantization parameter of the model branch; If the two channel quantization parameters are a scalar and a vector respectively, taking the sum of the elements of the channel quantization parameter of the vector and the channel quantization parameter of the scalar as the corresponding elements of the branch quantization parameter of the model branch to obtain the branch quantization parameter; If the quantization parameters of the two channels are neither vectors nor scalars, the channel quantization parameter of the channel with the convolution operation is used as the branch quantization parameter of the model branch.

2. The method according to claim 1, characterized in that The determining the channel quantization parameter corresponding to the channel based on the absolute maximum value of the channel includes: The sum of the absolute maximum value of the channel and a preset value is used as the channel quantization parameter corresponding to the channel.

3. A deep learning model reasoning system, characterized in that: include: A first determination module, used to determine a channel quantization parameter of each channel in a target deep learning model; A second determination module is used to determine a branch quantization parameter of the model branch based on the channel quantization parameter according to the relationship between the channel and the model branch in the target deep learning model; A first quantization module, configured to quantize the target deep learning model based on the branch quantization parameter to obtain a quantized deep learning model; A first reasoning module, used to perform reasoning based on the quantized deep learning model to obtain a reasoning result; The target deep learning model includes an open source deep learning compiler designed for CPU, GPU and dedicated accelerator, which is used to connect the deep learning framework focusing on richness and the hardware backend focusing on performance or efficiency; Wherein, the first determining module includes: A first determining unit, configured to determine an absolute maximum value of the channel of the target deep learning model; A second determining unit, configured to determine the channel quantization parameter corresponding to the channel based on the absolute maximum value of the channel; Wherein, the second determining module includes: A third determining unit, configured to use the channel quantization parameter with a smaller value as the branch quantization parameter of the model branch if both of the two channel quantization parameters are scalars; a fourth determining unit, configured to compare the two channel quantization parameters channel by channel if both of the two channel quantization parameters are vectors, and use the smaller channel quantization parameter of the two channels as the branch quantization parameter of the model branch; a fifth determining unit, configured to, if the two channel quantization parameters are a scalar and a vector respectively, use a sum of an element of the channel quantization parameter of the vector and the channel quantization parameter of the scalar as a corresponding element of a branch quantization parameter of the model branch to obtain the branch quantization parameter; The sixth determining unit is configured to use the channel quantization parameter of the channel with the convolution operation as the branch quantization parameter of the model branch if the quantization parameters of the two channels are neither vectors nor scalars.

4. A deep learning model inference device, characterized in that: include: Memory for storing computer programs; A processor, used to implement the steps of the deep learning model inference method as described in any one of claims 1 to 2 when executing the computer program.

5. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the deep learning model inference method as described in any one of claims 1 to 2.

Citation Information

Patent Citations

  • Vectorization method of convolution neural network operation for vector processor

    CN108985450A

  • Deep-learning model reasoning period acceleration method, device and system

    CN109034371A

  • Text classification method for character-numeral unique translatable depth modeland storage medium

    CN109284388A

  • Optimization method and device of deep learning model and terminal equipment

    CN111310890A

  • Deep learning model reasoning acceleration method, system and device and medium

    CN112200313A

Cited By

  • Deep learning algorithm model reasoning scheduling engine architecture and method

    CN116204282A

  • A deep learning algorithm model inference scheduling engine system and method

    CN116204282B