Model optimization method, device, computer equipment and computer readable storage medium

By obtaining model configuration parameters and analyzing performance indicators, and combining multiple model training frameworks for model optimization, the problem of low model optimization performance in the existing technology is solved, and efficient quantification and performance improvement of the model are achieved.

CN118378725BActive Publication Date: 2024-10-01SHENZHEN SMARTMORE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410825543.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-10-01
Estimated Expiration
2044-06-25

Smart Images

  • Figure CN118378725B_ABST
    Figure CN118378725B_ABST
Patent Text Reader

Abstract

The present application relates to a model optimization method, device, computer equipment and computer-readable storage medium. The method includes: obtaining a model to be optimized and model configuration parameters; training the model to be optimized based on the model training framework corresponding to the model training framework identification information to obtain the model to be quantized; reasoning the model to be quantized based on the model quantization requirements to obtain the model quantization parameters; determining the target quantization model corresponding to the model to be quantized based on the model quantization parameters; obtaining input data information corresponding to at least two types of resource quantities in the input resource quantity range, reasoning the target quantization model based on the input data information corresponding to each type of resource quantity, and obtaining the model performance indicators corresponding to each type of resource quantity; determining the target input resource quantity based on the comparison results of the model performance indicators corresponding to each type of resource quantity; determining the target optimization model based on the target input resource quantity and the target quantization model. The present application can improve the performance of the optimization model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a model optimization method, device, computer equipment and computer-readable storage medium. Background Art

[0002] With the rapid development and widespread application of deep learning, a large number of technologies based on neural network models have begun to be deployed. Since the neural network model itself has the characteristics of many layers, many parameters, and large amount of calculation, in order to improve the reasoning performance of the model, technology for optimizing the model has emerged.

[0003] However, existing model optimization technologies are relatively limited and cannot optimize the model in a targeted manner according to actual application requirements. The optimized model cannot achieve higher reasoning performance while maintaining high accuracy, resulting in the problem of low model optimization performance. Summary of the invention

[0004] Based on this, it is necessary to provide a model optimization method, device, computer equipment, computer readable storage medium and computer program product to address the above technical problems, which can improve the performance of the optimization model.

[0005] In a first aspect, the present application provides a model optimization method, comprising:

[0006] Obtain the model to be optimized and model configuration parameters, including model training framework identification information, model quantization requirements, and input resource range;

[0007] Based on the model training framework corresponding to the model training framework identification information, the model to be optimized is trained to obtain the model to be quantized; based on the model quantization requirements, the model to be quantized is inferred to obtain the model quantization parameters; based on the model quantization parameters, the target quantization model corresponding to the model to be quantized is determined;

[0008] Obtain input data information corresponding to at least two types of resources in the input resource range, and infer the target quantification model based on the input data information corresponding to each type of resource to obtain model performance indicators corresponding to each type of resource;

[0009] Based on the comparison results of the model performance indicators corresponding to various types of resource quantities, the target input resource quantity is determined; based on the target input resource quantity and the target quantification model, the target optimization model is determined.

[0010] In a second aspect, the present application provides a model optimization device, comprising:

[0011] An acquisition module is used to obtain the model to be optimized and the model configuration parameters. The model configuration parameters include the model training framework identification information, the model quantization requirements and the input resource range;

[0012] A quantization module is used to train the model to be optimized based on the model training framework corresponding to the model training framework identification information to obtain the model to be quantized; based on the model quantization requirements, the model to be quantized is inferred to obtain the model quantization parameters; based on the model quantization parameters, a target quantization model corresponding to the model to be quantized is determined;

[0013] An analysis module is used to obtain input data information corresponding to at least two types of resource quantities in the input resource quantity range, and to infer the target quantitative model based on the input data information corresponding to each type of resource quantity to obtain model performance indicators corresponding to each type of resource quantity;

[0014] The determination module is used to determine the target input resource quantity based on the comparison results of the model performance indicators corresponding to various types of resource quantities; and determine the target optimization model based on the target input resource quantity and the target quantification model.

[0015] In a third aspect, the present application provides a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method when executing the computer program.

[0016] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above method when executed by a processor.

[0017] In a fifth aspect, the present application provides a computer program product, which includes a computer program, and the computer program implements the steps in the above method when executed by a processor.

[0018] The above-mentioned model optimization method, device, computer equipment, computer-readable storage medium and computer program product determine the model training framework based on the model training framework identification information in the acquired model configuration parameters, and train the model to be optimized based on the model training framework to obtain the model to be quantized. The model training framework identification information in the model configuration parameters can be set according to actual requirements, and there is no limit on the number of model training frameworks, which is conducive to setting multiple frameworks according to actual application needs, thereby realizing a single model training framework or a multi-model training framework to train the model to be optimized; then, the model to be quantized is inferred based on the model quantization requirements in the model configuration parameters to obtain model quantization parameters, and the target quantization model corresponding to the model to be quantized is determined according to the model quantization parameters, thereby realizing the quantization of the model, which is conducive to reducing the storage space of the model and improving the reasoning of the model. It can further obtain input data information corresponding to at least two types of resource quantities in the input resource quantity range in the model configuration parameters, and infer the target quantization model based on the input data information of each type of resource quantity to obtain the model performance indicators corresponding to each type of resource quantity, and determine the target input resource quantity based on the comparison results of the model performance indicators corresponding to each type of resource quantity, and determine the target optimization model according to the target input resource quantity and the target quantization model. The setting of the input resource quantity is conducive to realizing the dynamic conversion of the model input size during the model optimization process, and is conducive to further analyzing the impact of the input size on the performance of the quantitative model on the basis of quantifying the model to improve the model performance, and using the input resource quantity that can better further improve the model performance as the input size of the target optimization model, which is conducive to determining a model configuration that is more suitable for application requirements, thereby improving the performance of the optimization model adapted to application requirements. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 An application environment diagram of a model optimization method provided in an embodiment of the present application;

[0020] Figure 2 A schematic diagram of a flow chart of a model optimization method provided in an embodiment of the present application;

[0021] Figure 3 A schematic diagram of a process of model optimization and deployment provided in an embodiment of the present application;

[0022] Figure 4 A structural block diagram of a model optimization device provided in an embodiment of the present application;

[0023] Figure 5 An internal structure diagram of a computer device provided in an embodiment of the present application;

[0024] Figure 6 An internal structure diagram of another computer device provided in an embodiment of the present application;

[0025] Figure 7 An internal structure diagram of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0027] The model optimization method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through a communication network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.

[0028] like Figure 2 As shown, the embodiment of the present application provides a model optimization method, which is applied to Figure 1 The terminal 102 or the server 104 in the example is used for explanation. It is understandable that the computer device may include at least one of the terminal and the server. The method comprises the following steps:

[0029] S200, obtaining the model to be optimized and model configuration parameters, where the model configuration parameters include model training framework identification information, model quantization requirements, and input resource quantity range.

[0030] The model to be optimized can be any model that needs to be optimized; the optimization operation includes quantizing the model and dynamically converting the model input size. Model configuration parameters refer to parameters for model optimization configuration, including but not limited to model training framework identification information, model quantization requirements, input resource range, preset message digest check code of model file, application scenario type, etc. Model training framework identification information refers to information used to identify model training framework, including identification information of multiple model training frameworks; model training frameworks include but are not limited to PyTorch, PaddlePaddle and TensorFlow, etc. Model quantization requirements refer to the requirements for quantizing the model, such as quantizing model accuracy. Input resource range refers to the size range of model input data. The data type of model input is not limited and can be text, picture, audio, etc. Model file refers to the file used to define the model to be optimized. Preset message digest check code refers to the check code used for self-checking, which can be MD5 (MessageDigest Algorithm 5) code. Application scenario type refers to the application scenario type of the model, such as target detection, image classification and other application scenarios. Different application scenarios may correspond to different models.

[0031] Exemplarily, the terminal can respond to the model file to be optimized and the model configuration parameter file uploaded on the model optimization service interface. The model to be optimized is defined by the model file to be optimized, and the model configuration parameters are obtained from the model configuration parameter file. The model configuration parameters include model training framework identification information of multiple model training framework identification information, model quantization requirements and input resource quantity range, providing a data basis for subsequent model optimization.

[0032] S202. Train the model to be optimized based on the model training framework corresponding to the model training framework identification information to obtain the model to be quantized; infer the model to be quantized based on the model quantization requirements to obtain model quantization parameters; determine the target quantization model corresponding to the model to be quantized based on the model quantization parameters.

[0033] The model to be quantized refers to the model to be quantized; the model to be quantized is the model that has been trained according to the model training framework. Model quantization parameters refer to the quantization parameters obtained after quantizing the model to be quantized, including but not limited to the quantized model weight value and the quantized model activation value. The model activation value can be the result value of the model. For example, in y=kx, the y value calculated after inputting x is the activation value. The target quantization model refers to the model obtained after quantizing the model to be quantized.

[0034] Exemplarily, the corresponding model training framework can be determined according to the model training framework identification information. If the model training framework identification information includes multiple model training frameworks, the current model training framework can be determined according to the preset model training framework usage order; different model training frameworks have different corresponding formats. The format of the model file to be optimized that defines the model to be optimized can be first converted into an intermediate format to obtain the current model file to be converted, and then the current model file to be converted is converted into a format that matches the current model training framework to obtain the current model file to be trained. Based on the current model training framework, the model in the current model file to be trained is trained to obtain the current trained model file, and the current trained model file is converted into a file in the intermediate format as the current model file to be converted, and so on, until the execution of multiple model training frameworks is completed, and the model in the current trained model file corresponding to the last model training framework is used as the model to be quantized, realizing the conversion of the model from one model training framework to another or multiple model training frameworks, and improving the flexibility of the model training framework for efficient application of the model. In order to ensure that the GPU has sufficient computing power during the model quantization process, the server GPU computing power in the current quantization process can also be automatically queried, and the model currently required to be quantized is allocated to a server with sufficient GPU computing power for operation, which is conducive to ensuring the efficient operation of the model quantization.

[0035] Furthermore, in order to improve the accuracy of model quantization, the model configuration parameters may also include a preset message digest check code, and the message digest check code of the model to be quantized file that defines the model to be quantized is calculated. If the calculated message digest check code is consistent with the preset message digest check code, the target quantization method can be determined according to the model quantization requirements, and the model to be quantized is inferred based on the target quantization method to implement the quantization operation of the model to be quantized, and the corresponding target quantization model is obtained, wherein the operation of reasoning the model to be quantized can be implemented through the TensorRT reasoning engine.

[0036] In some embodiments, the process of quantizing the model to be optimized includes the implementation of layer fusion and tensor merging. Among them, layer fusion can perform convolution fusion according to the model network structure, merging the convolution layer with the bias, activation function and normalization layer (such as batch normalization) into a single operation; batch normalization fusion refers to merging the convolution layer with the batch normalization layer into a single operation. Tensor merging can connect layers and connect multiple tensors of the same height and width on the entire channel dimension of the model, thereby reducing the number of cores of the GPU graphics card occupied and improving the calculation speed.

[0037] S204, obtaining input data information corresponding to at least two types of resource quantities in the input resource quantity range, and inferring the target quantization model based on the input data information corresponding to each type of resource quantity to obtain model performance indicators corresponding to each type of resource quantity.

[0038] The input data information includes but is not limited to data of types such as text, images, and audio. For the same model optimization task process, the types of input data information corresponding to different types of resources are the same, for example, they all belong to images, and the type of input data information can be set according to actual needs. Model performance indicators include but are not limited to indicators such as model inference time, inference speed, and inference accuracy.

[0039] Exemplarily, the input resource quantity of the target quantification model can be set to an input resource quantity range, that is, the value of the input resource quantity of the target quantification model is no longer limited to a fixed value, but a dynamically convertible range, so that input data information corresponding to at least two types of resource quantities in the input resource quantity range can be obtained, and the number of input data information can also be equal to a preset number, so that model performance indicators corresponding to multiple resources of the same type can be obtained subsequently for analysis and comparison, thereby improving the accuracy of determining the target input resource quantity; the input data information corresponding to each type of resource quantity can be input into the target quantification model for processing to obtain model performance indicators corresponding to each type of resource quantity.

[0040] S206. Determine the target input resource quantity based on the comparison results of the model performance indicators corresponding to each type of resource quantity; determine the target optimization model based on the target input resource quantity and the target quantification model.

[0041] The target input resource volume refers to the model input size that is selected to make the model's performance better than other types of resource volumes. The target optimization model refers to the model with relatively good performance after optimization; in terms of model performance: target optimization model > model to be quantized > model to be optimized; the target optimization model can be defined by the target optimization model file, which can be the trt file of the TensorRT inference engine.

[0042] Exemplarily, model performance indicators may include model inference time, model inference speed, model inference accuracy and other types of indicators; indicators of the same type may be sorted, and different weights may be set according to the sorting order; for each type of resource quantity, the weights of indicators of different types may be accumulated to obtain the total weights corresponding to each type of resource quantity; the total weights of each type of resource quantity may be compared to determine the target input resource quantity; the larger the total weight, the better the model performance; the resource quantity corresponding to the maximum total weight may be used as the target input resource quantity; and then the target optimization model may be determined based on the target input resource quantity and the target quantification model; the target optimization model may also be defined by the target optimization model.

[0043] The above-mentioned model optimization method determines the model training framework based on the model training framework identification information in the obtained model configuration parameters, and trains the model to be optimized based on the model training framework to obtain the model to be quantized. The model training framework identification information in the model configuration parameters can be set according to actual requirements, and there is no restriction on the number of model training frameworks, which is conducive to setting multiple frameworks according to actual application requirements, thereby realizing a single model training framework or a multi-model training framework to train the model to be optimized; then, the model to be quantized is inferred based on the model quantization requirements in the model configuration parameters to obtain model quantization parameters, and the target quantization model corresponding to the model to be quantized is determined according to the model quantization parameters, thereby realizing the quantization of the model, which is conducive to reducing the storage space of the model and improving the reasoning performance of the model; further, obtaining the model configuration parameters The input data information corresponding to at least two types of resource quantities in the input resource quantity range in the number is obtained, and the target quantization model is inferred based on the input data information of each type of resource quantity to obtain the model performance indicators corresponding to each type of resource quantity, and the target input resource quantity is determined based on the comparison results of the model performance indicators corresponding to each type of resource quantity, and the target optimization model is determined according to the target input resource quantity and the target quantization model. The setting of the input resource quantity is conducive to realizing the dynamic conversion of the model input size during the model optimization process, and is conducive to further analyzing the impact of the input size on the performance of the quantitative model on the basis of quantifying the model to improve the model performance, and taking the input resource quantity that can better further improve the model performance as the input size of the target optimization model, which is conducive to determining the model configuration that is more suitable for the application needs, thereby improving the performance of the optimization model adapted to the application needs.

[0044] In some embodiments, the model training framework identification information includes identification information of at least two model training frameworks; the model to be optimized is defined by the model file to be optimized; in S202, the model to be optimized is trained based on the model training framework corresponding to the model training framework identification information to obtain the model to be quantized, including:

[0045] S300, converting the format of the model file to be optimized into an intermediate format to obtain the current model file to be converted.

[0046] S302. Determine the current model training framework from at least two model training frameworks, convert the format of the current model file to be converted into a format that matches the current model training framework, and obtain the current model file to be trained; train the model defined by the current model file to be trained based on the current model training framework to obtain the current trained model file; convert the current trained model file into a file in an intermediate format as the current model file to be converted.

[0047] S304. Return to the step of determining the current model training framework from at least two model training frameworks until the current trained model file corresponding to the last model training framework is obtained, and the model defined by the current trained model file corresponding to the last model training framework is used as the model to be quantized.

[0048] Among them, the intermediate format can be but is not limited to ONNX (Open Neural Network Exchange). ONNX is an open intermediate model representation format that can perform model conversion across different deep learning frameworks; the model configuration parameters include application scenario types, and the corresponding relationship between the application scenario type and the intermediate format can be set. For different application scenarios, the corresponding intermediate formats are different. The application scenario type, model reasoning performance requirements, hardware device environment and reasoning engine type can also be combined to set the corresponding intermediate format. The current model file to be converted refers to the model file that is currently to be converted to match the format of the current model training framework. The current model training framework refers to the model training framework currently used to train the model in the current model file to be converted; the determination of the current model training framework can be determined in an order based on actual application requirements.

[0049] Exemplarily, in order to achieve model optimization in multiple application scenarios and improve the performance of model optimization, the model to be optimized can be flexibly set to be converted and trained between multiple model training frameworks. The intermediate format adapted between multiple model training frameworks can be determined based on the application scenario type included in the model configuration parameters, as well as the model reasoning performance requirements, hardware device environment and reasoning engine type, and then the format of the model file to be optimized that defines the model to be optimized is first converted into the intermediate format to obtain the current model file to be converted; the current model training framework can also be determined based on the preset model training framework usage order, and the format of the current model file to be converted is converted into a format that matches the current model training framework to obtain the current model file to be trained, and then the model in the current model file to be trained is trained based on the current model training framework to obtain the current trained model file, and then the current trained model file is converted into a file in the intermediate format as the current file for the next round. The model file to be converted, and so on, until the current trained model file corresponding to the final model training framework is obtained, and the model in the current trained model file corresponding to the final model training framework is used as the model to be quantized; wherein, the method for determining the intermediate format adapted between multiple model training frameworks can be based on the adaptation relationship between the application scenario type and the intermediate format, to determine the set of intermediate formats to be screened, and then to use the intermediate format to be screened that meets at least one of the model reasoning performance requirements, hardware device environment, and reasoning engine type as the intermediate format to be processed. If there are multiple intermediate formats to be processed, the intermediate format to be processed that meets the model reasoning performance requirements, hardware device environment, and the largest number of conditions in the reasoning engine type is used as the intermediate format adapted between multiple model training frameworks; wherein, the preset model training framework usage order can be set based on the actual application scenario, without limiting the setting method.

[0050] It can be seen that in this embodiment, when there are multiple model training frameworks, the intermediate format between the multiple model training frameworks is determined, and the model file to be optimized that defines the model to be optimized is used as the current model file to be converted for format conversion, first converted to the intermediate format, then converted to a format matching the current model training framework, and then the converted format is converted into the intermediate format as the next round of current model file to be converted, and so on, until the multiple model training frameworks corresponding to the model training framework identification information in the model configuration parameters have processed the model to be optimized, thereby converting the model from one model training framework to another or multiple model training frameworks, thereby improving the flexibility of the model to efficiently apply the model training framework, improving the performance of model optimization to a certain extent, and making the optimized model more adaptable to the actual application scenario.

[0051] In some embodiments, the model configuration parameters further include a preset message digest check code; the model to be quantized is defined by a model file to be quantized; before the model to be quantized is inferred based on the model quantization requirements in S202 and the model quantization parameters are obtained, the model optimization method further includes:

[0052] S400: Calculate a message digest check code corresponding to the model file to be quantized.

[0053] S402: If the message digest check code is consistent with the preset message digest check code, then the step of inferring the model to be quantized based on the model quantization requirement to obtain the model quantization parameters is executed.

[0054] Alternatively, S404: if the message digest verification code is inconsistent with a preset message digest verification code, an alarm message is generated and sent to the terminal.

[0055] The message digest check code refers to a check code used to check the model to be quantized, which can be calculated based on the MD5 algorithm for the model file to be quantized. The warning information refers to a prompt information used to reflect that the version of the model file to be quantized used does not match the expected model file version to be optimized.

[0056] Exemplarily, in order to ensure the consistency and correctness of the model version update process during the model quantization process, and to ensure that the model file to be quantized is consistent with the expected original model file version, before the model to be quantized is inferred based on the model quantization requirements, the message digest check code of the model file to be quantized that defines the model to be quantized can be calculated, and the message digest check code can be compared with the preset message digest check code in the model configuration parameters. If the message digest check code is consistent with the preset message digest check code, the target quantization method is determined based on the model quantization requirements, and the model to be quantized is inferred based on the target quantization method to obtain the model quantization parameters after quantization inference, and the target quantization model is determined based on the model quantization parameters; if the message digest check code is inconsistent with the preset message digest check code, an alarm message is generated and sent to the terminal for display, so as to feedback the system error signal and improve maintenance efficiency.

[0057] It can be seen that in this embodiment, the message digest check code of the model file to be quantized is calculated before the quantization inference is performed on the model to be quantized, and the quantization inference operation of the model to be quantized is performed when the message digest check code is consistent with the preset message digest check code in the model configuration parameters. When the message digest check code is inconsistent with the preset message digest check code, an alarm message is generated to improve the system error reporting efficiency, thereby ensuring the accuracy of the quantization model.

[0058] In some embodiments, in S202, based on the model quantization requirement, the model to be quantized is inferred to obtain the model quantization parameters, including:

[0059] S500: Determine a target quantification method based on the model quantification requirements.

[0060] S502: If the target quantization method is the first quantization method, obtain the data set to be processed, run the model to be quantized based on the data set to be processed, and obtain activation data; construct an activation data histogram of the activation data, and divide the activation data histogram into multiple divided intervals.

[0061] S504: For each partition interval, the activation data in the partition interval is fused with the activation data in the backward interval set corresponding to the partition interval to obtain a fusion value corresponding to each partition interval, and the true distribution corresponding to the data set to be processed is determined based on each fusion value.

[0062] S506 , performing quantization mapping on the true distribution to obtain a quantized distribution corresponding to the data set to be processed; calculating the distribution distinction between the true distribution and the quantized distribution, and determining the model quantization parameters based on the distribution distinction.

[0063] Among them, the target quantization method refers to the quantization method that matches the model quantization requirement, which can be the KL (Kullback-Leibler) divergence quantization method; different quantization methods can be matched for different model quantization requirements. For example, if the model quantization requirement is "ensuring low precision loss under large computational complexity", the KL divergence quantization method can be matched accordingly. For example, if the model quantization requirement is "simple and computationally efficient", the uniform quantization method can be matched accordingly. The matching of specific model quantization conditions and quantization methods is not limited to the two mentioned above. The first quantization method focuses on quantizing the model accuracy. The data set to be processed refers to the data set used for model quantization. The activation data refers to the result value of the model, such as in y=kx, the y value calculated after inputting x is the activation data; the activation data can also include the weight value of the model. The activation data histogram refers to a histogram constructed based on the activation data, the vertical axis of the histogram corresponds to the activation data, and the horizontal axis corresponds to the independent variables related to the input data of the model. The partition interval refers to the interval divided by the activation data histogram. The backward interval set refers to the set of all partition intervals after the partition interval. The fusion value can be a fusion value obtained by accumulating the activation data in the backward interval set. The true distribution refers to the distribution obtained based on the fusion value analysis of each partitioned interval, which can reflect the true distribution of the activation data corresponding to the data set to be processed. Quantization mapping refers to the operation of quantizing floating-point precision data into integer precision data. Distribution distinctiveness refers to the KL divergence between the true distribution and the quantized distribution; the number of subset intervals with the smallest distribution distinctiveness is the interval size of the true distribution to be quantized, and the activation data in the partitioned interval to be quantized is quantized to an interval of a preset integer number of bits (such as an int8 interval), which can determine the quantized values ​​corresponding to the weight values ​​and activation data of the quantized model, and the quantized values ​​corresponding to the weight values ​​and activation data of the quantized model are the model quantization parameters.

[0064] Exemplarily, for different model quantization requirements, different quantization methods can be selected in a targeted manner. If the model quantization requirement focuses on large quantization calculation amount and low precision loss, the quantization model to be quantized can be inferred based on the first quantization method. Specifically, the data set to be processed can be first obtained, the data set to be processed is input into the model to be quantized for processing, the corresponding activation data is output, and the activation data histogram corresponding to the activation data is constructed, and the activation data histogram is divided to obtain multiple partition intervals, which can be divided into a preset number of partition intervals, and the preset number can be 2048; and multiple partition intervals within a preset range are used as partition intervals to be processed, and the fusion value corresponding to each partition interval to be processed is calculated, which can be the partition interval within the range of [128, 2048] as the partition interval to be processed, that is, the 128th partition interval to the 2048th partition interval is used as the partition interval to be processed; and then the backward interval set corresponding to each partition interval to be processed is determined, and the activation data in each partition interval to be processed is cumulatively fused with the activation data in each partition interval in the corresponding backward interval set to obtain the fusion value corresponding to each partition interval to be processed, and the corresponding true distribution is determined according to the fusion value corresponding to each partition interval to be processed.

[0065] Furthermore, the true distribution is quantized and mapped to obtain the quantized distribution, and the distribution distinction between the true distribution and the quantized distribution is calculated, and the number of subset intervals with the smallest distribution distinction is selected as the interval size of the true distribution to be quantized, and then the activation data in the partition interval to be quantized is quantized to an interval of preset integer bits to obtain the quantization value corresponding to each partition interval to be processed. The quantization value corresponding to each partition interval to be processed can determine the quantized model weight value and the quantization value corresponding to the activation data respectively, and the quantized model weight value and the quantization value corresponding to the activation data respectively are used as model quantization parameters.

[0066] It can be seen that in this embodiment, determining the model quantization parameter by the first quantization method is beneficial to reducing the loss of model accuracy after quantization when the model quantization calculation amount is large, thereby improving the model quantization accuracy and further improving the performance of the quantization model.

[0067] In some embodiments, the model optimization method further comprises:

[0068] S600. If the target quantization method is the second quantization method, obtain the data set to be processed, run the model to be quantized based on the data set to be processed, and obtain activation data; determine the maximum activation value and the minimum activation value from the activation data; and perform quantization mapping on the activation data based on the preset quantization level, the maximum activation value, and the minimum activation value to obtain the model quantization parameters.

[0069] Alternatively, S602, if the target quantization method is the third quantization method, obtain the data set to be processed, run the model to be quantized based on the data set to be processed, and obtain activation data; divide the activation data into a preset number of data intervals; for each data interval, quantize the activation data in the data interval into a preset representation form to obtain the quantization value corresponding to the data interval; determine the model quantization parameters based on the quantization values ​​corresponding to each data interval.

[0070] Among them, the second quantization method focuses on blurring the original model detail information for quantization, which can be a maximum and minimum value quantization method. The preset quantization level refers to a preset fixed quantization level, which can be expressed in a quantization interval range; for example, a floating point number is represented as an 8-bit integer (ie, int8) ranging from 0 to 255; for example, the value of the activation data belonging to the [1,10] interval is quantized and mapped to the value of the [4,8] interval in the preset quantization level. The third quantization method focuses on simple calculation and high efficiency, and can be a uniform quantization method. The preset representation refers to quantizing the value of each data interval into a value of a fixed representation, such as quantizing the floating point precision in the data interval into a fixed 8-bit integer.

[0071] Exemplarily, if the actual application scenario does not pay much attention to the model detail information, the second quantization method can be used to determine the model quantization parameter, specifically, the maximum activation value and the minimum activation value can be determined from the activation data, a first fusion value between each activation data and the minimum activation value, and a second fusion value between the maximum activation value and the minimum activation value are calculated, a third fusion value between the maximum quantization value and the minimum quantization value in a preset quantization level is calculated, the first fusion value, the second fusion value and the third fusion value are fused to obtain a fourth fusion value, and the activation data is fused with the corresponding fourth fusion value to obtain the value obtained As the quantization value of the activation data, the model quantization parameter is determined according to the quantization value of each activation data; for example, 1 can be used as the minimum activation value, 10 as the maximum activation value, 2 as the activation data currently being quantized, and [4,8] as the preset quantization level (that is, the preset quantization interval value). The corresponding maximum quantization value is 8 and the minimum quantization value is 4. Then, the first fusion value is 2-1=1, the second fusion value is 10-1=9, the third fusion value is 8-4=4, the fourth fusion value is (1 / 9)*4=4 / 9, and the quantization value of activation data 2 is 2 / (4 / 9)=4.5.

[0072] Furthermore, if the actual application scenario requires simple implementation of model quantization and high computational efficiency of the model quantization process, the third quantization method can be used to determine the model quantization parameters. Specifically, the activation data can be divided into a preset number of data intervals, and the activation data in the data intervals can be quantized into a preset representation to obtain the quantization values ​​corresponding to the data intervals. The quantization values ​​corresponding to each data interval can determine the model quantization parameters.

[0073] It can be seen that in this embodiment, model quantization is achieved by adopting the second quantization method or the third quantization method, and the second quantization method focuses on blurring the original model detail information for quantization, which is conducive to blurring the model detail information and reducing the risk of data being maliciously attacked or abused; the third quantization method focuses on quantization with simple calculation and high calculation efficiency, which is conducive to more efficient model quantization. Different quantization methods can be adapted to different application requirements, and different quantization methods can reduce the storage space of the model. Different quantization methods can also improve the performance of the quantized model to a certain extent, which is conducive to improving the flexibility of selecting a quantization method suitable for actual application needs, thereby improving the performance of model quantization.

[0074] In some embodiments, the model optimization method further comprises:

[0075] S700, obtaining a model quantization reasoning log, and generating a performance analysis report based on the model quantization reasoning log and model performance indicators corresponding to various resource quantities.

[0076] S702: Pack the performance analysis report and the target optimization model into a to-be-deployed model toolkit; send the to-be-deployed model toolkit to the target device, so that the target device installs the to-be-deployed model toolkit.

[0077] Among them, the model quantization inference log refers to the performance indicator data recorded in the model quantization process, including but not limited to inference time, inference speed, inference accuracy, etc. The performance analysis report refers to the report obtained by analyzing the performance indicator data related to model quantization and the model performance indicators corresponding to various resource quantities in the model quantization inference log. The model toolkit to be deployed refers to the SDK package that can be directly downloaded to the target device for operation. The target device refers to the device used to install and run the model toolkit to be deployed, which can be a local service device.

[0078] Exemplarily, in order to achieve efficient reasoning on the terminal side, a complete model optimization process is provided, and a model deployment process can also be provided. A performance analysis report for model optimization can be generated based on the data information in the acquired model quantification reasoning log and the model performance indicators corresponding to each type of resource quantity, and the performance analysis report and the target optimization model file of the target optimization model are packaged into a model toolkit to be deployed. If the target device is a local service device, the model toolkit to be deployed can be directly installed and deployed on the local service device, and the target optimization model can be run directly on the local service device; wherein, the target optimization model file includes a model configuration file.

[0079] It can be seen that in this embodiment, a performance analysis report is generated based on the obtained model quantization inference log and the model performance indicators corresponding to each type of resource amount, and the performance analysis report and the target optimization model are packaged into a model toolkit to be deployed, and the model toolkit to be deployed is installed and deployed on the target device for operation, thereby achieving efficient reasoning of the model on the terminal side, which is beneficial to improving the efficiency of the model optimization and deployment process.

[0080] In some embodiments, it can be combined with Figure 3 The flowchart shown describes the process of model optimization and deployment. A trained model file can be obtained by training the model in the original model file based on the model training framework. The model to be quantized is defined by the trained model file, and the model configuration parameters are obtained. The model configuration parameters include a preset message digest check code (i.e., a preset MD5 code). The message digest check code corresponding to the trained model file can be calculated first (i.e., the calculated MD5 code), and then the calculated message digest check code is verified with the preset message digest check code. If the message digest check code is inconsistent with the preset message digest check code (i.e., Figure 3 If the message digest check code is consistent with the preset message digest check code (i.e. Figure 3 'Pass' in the ... Figure 3 'Support dynamic form input' in the input resource), if necessary, set the input resource amount (i.e. input size) of the model to the input resource amount range, that is, set the model input size from a single fixed value to a dynamic input size that can be within the set interval size, and obtain input data information corresponding to at least two types of resource amounts within the input resource amount. The number of input data information corresponding to each type of resource amount can be a preset number (corresponding to Figure 3 The target quantization model is inferred based on the input data information corresponding to each type of resource amount, and the model performance indicators corresponding to each type of resource amount are obtained. The corresponding performance analysis report can be generated according to the model performance indicators corresponding to each type of resource amount and the model quantization inference log, and the performance analysis report and the target optimization model file containing the target optimization model and model configuration information are packaged into a model toolkit to be deployed (corresponding to Figure 3The inference software development kit in the terminal is downloaded and the model toolkit to be deployed is downloaded to the terminal device for running inference, thereby realizing the process solution of model optimization and deployment. It is beneficial to improve the model optimization performance while reducing the complexity of model deployment, so that the optimized model can be deployed more easily and efficiently on the local service device on the terminal side for installation and operation, thereby realizing efficient inference on the model terminal side.

[0081] It should be understood that, although the steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indications of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0082] Based on the same inventive concept, the embodiment of the present application also provides a model optimization device. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more model optimization device embodiments provided below can refer to the limitations on the model optimization method above, and will not be repeated here.

[0083] like Figure 4 As shown, the embodiment of the present application provides a model optimization device 400, including:

[0084] An acquisition module 402 is used to acquire a model to be optimized and model configuration parameters, where the model configuration parameters include model training framework identification information, model quantization requirements, and input resource quantity range;

[0085] The quantization module 404 is used to train the model to be optimized based on the model training framework corresponding to the model training framework identification information to obtain the model to be quantized; based on the model quantization requirements, infer the model to be quantized to obtain the model quantization parameters; based on the model quantization parameters, determine the target quantization model corresponding to the model to be quantized;

[0086] The analysis module 406 is used to obtain input data information corresponding to at least two types of resource quantities in the input resource quantity range, and to infer the target quantitative model based on the input data information corresponding to each type of resource quantity to obtain model performance indicators corresponding to each type of resource quantity;

[0087] The determination module 408 is used to determine the target input resource quantity based on the comparison results of the model performance indicators corresponding to each type of resource quantity; and determine the target optimization model based on the target input resource quantity and the target quantification model.

[0088] In some embodiments, the model training framework identification information includes identification information of at least two model training frameworks; the model to be optimized is defined by the model file to be optimized; in terms of training the model to be optimized based on the model training framework corresponding to the model training framework identification information to obtain the model to be quantized, the quantization module 404 is specifically used to:

[0089] Convert the format of the model file to be optimized into an intermediate format to obtain the current model file to be converted;

[0090] Determine the current model training framework from at least two model training frameworks, convert the format of the current model file to be converted into a format that matches the current model training framework, and obtain the current model file to be trained; train the model defined by the current model file to be trained based on the current model training framework to obtain the current trained model file; convert the current trained model file into a file in an intermediate format as the current model file to be converted;

[0091] Return to the step of determining the current model training framework from at least two model training frameworks until the current trained model file corresponding to the last model training framework is obtained, and the model defined by the current trained model file corresponding to the last model training framework is used as the model to be quantized.

[0092] In some embodiments, the model configuration parameters further include a preset message digest check code; the model to be quantized is defined by a model file to be quantized; before the model to be quantized is inferred based on the model quantization requirements to obtain the model quantization parameters, the quantization module 404 is further specifically used to:

[0093] Calculate the message digest check code corresponding to the model file to be quantized;

[0094] If the message digest check code is consistent with the preset message digest check code, then the step of inferring the model to be quantized based on the model quantization requirement to obtain the model quantization parameters is performed; or,

[0095] If the message digest verification code is inconsistent with the preset message digest verification code, an alarm message is generated and sent to the terminal.

[0096] In some embodiments, in terms of inferring the model to be quantized based on the model quantization requirement to obtain the model quantization parameters, the quantization module 404 is specifically used to:

[0097] Determine the target quantification method based on the model quantification requirements;

[0098] If the target quantization method is the first quantization method, a data set to be processed is obtained, and a model to be quantized is run based on the data set to be processed to obtain activation data; an activation data histogram of the activation data is constructed, and the activation data histogram is divided to obtain a plurality of divided intervals;

[0099] For each partition interval, the activation data in the partition interval is fused with the activation data in the backward interval set corresponding to the partition interval to obtain the fusion value corresponding to each partition interval, and the true distribution corresponding to the data set to be processed is determined based on each fusion value;

[0100] The real distribution is quantized and mapped to obtain the quantized distribution corresponding to the data set to be processed; the distribution distinction between the real distribution and the quantized distribution is calculated, and the model quantization parameters are determined based on the distribution distinction.

[0101] In some embodiments, in terms of inferring the model to be quantized based on the model quantization requirement to obtain the model quantization parameters, the quantization module 404 is specifically used to:

[0102] If the target quantization method is the second quantization method, obtaining a data set to be processed, running the model to be quantized based on the data set to be processed, and obtaining activation data; determining a maximum activation value and a minimum activation value from the activation data; performing quantization mapping on the activation data based on a preset quantization level, a maximum activation value, and a minimum activation value, and obtaining a model quantization parameter; or,

[0103] If the target quantization method is the third quantization method, obtain the data set to be processed, run the model to be quantized based on the data set to be processed, and obtain activation data; divide the activation data into a preset number of data intervals; for each data interval, quantize the activation data in the data interval into a preset representation form to obtain the quantization value corresponding to the data interval; determine the model quantization parameters based on the quantization values ​​corresponding to each data interval.

[0104] In some embodiments, the model optimization model 400 further includes a deployment module 410, which is used to:

[0105] Obtain the model quantization reasoning log, and generate a performance analysis report based on the model quantization reasoning log and the model performance indicators corresponding to various resource quantities;

[0106] The performance analysis report and the target optimization model are packaged into a model toolkit to be deployed; the model toolkit to be deployed is sent to the target device, so that the target device installs the model toolkit to be deployed.

[0107] Each module in the above-mentioned model optimization device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0108] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data related to model optimization. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in the above-mentioned model optimization method are implemented.

[0109] In some embodiments, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, the steps in the above-mentioned model optimization method are implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen; the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0110] Those skilled in the art will understand that Figure 5 or Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0111] In some embodiments, a computer device is provided. The computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the steps in the above method embodiments are implemented.

[0112] In some embodiments, Figure 7 The figure shows an internal structure diagram of a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0113] In some embodiments, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0114] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0115] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0116] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0117] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A model optimization method, characterized in that: include: Obtain the model to be optimized and model configuration parameters, wherein the model configuration parameters include model training framework identification information, model quantization requirements, and input resource range; the input resource range refers to the size range of model input data, and the model input data types include text, pictures, and audio; Based on the model training framework corresponding to the model training framework identification information, the model to be optimized is trained to obtain the model to be quantized; based on the model quantization requirements, the model to be quantized is inferred to obtain model quantization parameters; Based on the model quantization parameters, determining a target quantization model corresponding to the model to be quantized; Acquire input data information corresponding to at least two types of resource quantities in the input resource quantity range, and infer the target quantization model based on the input data information corresponding to each type of resource quantity to obtain model performance indicators corresponding to each type of resource quantity; Determining the target input resource volume based on the comparison results of the model performance indicators corresponding to the various types of resource volumes; Based on the target input resource quantity and the target quantification model, a target optimization model is determined.

2. The method according to claim 1, characterized in that The model training framework identification information includes identification information of at least two model training frameworks; the model to be optimized is defined by a model file to be optimized; and the model to be optimized is trained based on the model training framework corresponding to the model training framework identification information to obtain a model to be quantized, including: Converting the format of the model file to be optimized into an intermediate format to obtain the current model file to be converted; Determine the current model training framework from the at least two model training frameworks, convert the format of the current model file to be converted into a format matching the current model training framework, and obtain the current model file to be trained; train the model defined by the current model file to be trained based on the current model training framework, and obtain the current trained model file; convert the current trained model file into the file in the intermediate format as the current model file to be converted; Return to the step of determining the current model training framework from the at least two model training frameworks until the current trained model file corresponding to the last model training framework is obtained, and use the model defined by the current trained model file corresponding to the last model training framework as the model to be quantized.

3. The method according to claim 1, characterized in that The model configuration parameters also include a preset message digest check code; the model to be quantized is defined by a model file to be quantized; before the model to be quantized is inferred based on the model quantization requirements to obtain the model quantization parameters, the method also includes: Calculating a message digest check code corresponding to the model file to be quantized; If the message digest check code is consistent with the preset message digest check code, then executing the step of inferring the model to be quantized based on the model quantization requirement to obtain the model quantization parameter; or, If the message digest verification code is inconsistent with the preset message digest verification code, an alarm message is generated and sent to the terminal.

4. The method according to claim 1, characterized in that The step of reasoning the model to be quantized based on the model quantization requirement to obtain model quantization parameters includes: Based on the model quantification requirements, determine the target quantification method; If the target quantization method is the first quantization method, obtaining a data set to be processed, running the model to be quantized based on the data set to be processed to obtain activation data; constructing an activation data histogram of the activation data, and dividing the activation data histogram to obtain a plurality of divided intervals; For each partition interval, the activation data in the partition interval is fused with the activation data in the backward interval set corresponding to the partition interval to obtain a fusion value corresponding to each partition interval, and the true distribution corresponding to the data set to be processed is determined based on each fusion value; The true distribution is quantized and mapped to obtain a quantized distribution corresponding to the data set to be processed; a distribution distinction between the true distribution and the quantized distribution is calculated, and a model quantization parameter is determined based on the distribution distinction.

5. The method according to claim 4, characterized in that The method further comprises: If the target quantization mode is the second quantization mode, obtaining a data set to be processed, running the model to be quantized based on the data set to be processed to obtain activation data; determining a maximum activation value and a minimum activation value from the activation data; performing quantization mapping on the activation data based on a preset quantization level, the maximum activation value and the minimum activation value to obtain a model quantization parameter; or, If the target quantization method is the third quantization method, obtain the data set to be processed, run the model to be quantized based on the data set to be processed, and obtain activation data; divide the activation data into a preset number of data intervals; for each data interval, quantize the activation data in the data interval into a preset representation form to obtain the quantization value corresponding to the data interval; determine the model quantization parameters based on the quantization values ​​corresponding to each data interval.

6. The method according to claim 1, characterized in that The method further comprises: Obtaining a model quantization reasoning log, and generating a performance analysis report based on the model quantization reasoning log and the model performance indicators corresponding to the various resource quantities; The performance analysis report and the target optimization model are packaged into a model toolkit to be deployed; the model toolkit to be deployed is sent to a target device, so that the target device installs the model toolkit to be deployed.

7. A model optimization device, characterized in that: include: An acquisition module is used to acquire the model to be optimized and model configuration parameters, wherein the model configuration parameters include model training framework identification information, model quantization requirements, and input resource range; the input resource range refers to the size range of model input data, and the data types of model input include text, pictures, and audio; A quantization module, used to train the model to be optimized based on the model training framework corresponding to the model training framework identification information to obtain the model to be quantized; based on the model quantization requirements, infer the model to be quantized to obtain model quantization parameters; Based on the model quantization parameters, determining a target quantization model corresponding to the model to be quantized; An analysis module, used to obtain input data information corresponding to at least two types of resource quantities in the input resource quantity range, and to infer the target quantization model based on the input data information corresponding to each type of resource quantity to obtain model performance indicators corresponding to each type of resource quantity; A determination module, used to determine the target input resource quantity based on the comparison results of the model performance indicators corresponding to the various types of resource quantities; Based on the target input resource quantity and the target quantification model, a target optimization model is determined.

8. The device according to claim 7, characterized in that The model training framework identification information includes identification information of at least two model training frameworks; the model to be optimized is defined by a model file to be optimized; in the aspect of training the model to be optimized based on the model training framework corresponding to the model training framework identification information to obtain the model to be quantized, the quantization module is specifically used for: Convert the format of the model file to be optimized into an intermediate format to obtain the current model file to be converted; Determine the current model training framework from the at least two model training frameworks, convert the format of the current model file to be converted into a format matching the current model training framework, and obtain the current model file to be trained; train the model defined by the current model file to be trained based on the current model training framework, and obtain the current trained model file; Convert the currently trained model file into the file in the intermediate format as the current model file to be converted; Return to the step of determining the current model training framework from the at least two model training frameworks until the current trained model file corresponding to the last model training framework is obtained, and use the model defined by the current trained model file corresponding to the last model training framework as the model to be quantized.

9. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.