A data update method, device and electronic device
By reducing the OPSET version of the ONNX model, the problem of excessive OPSET version causing chip unsupportation is solved, and the success rate of the model deployment on the chip platform is improved.
Patent Information
- Application Number
- CN202510307982.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-14
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2045-03-14
AI Technical Summary
When the OPSET version of the ONNX model is too high, the chip is not supported, so the ONNX operator cannot be converted into a chip-supported operator, and the actual deployment of the ONNX model cannot be realized.
By determining the minimum historical OPSET version of each operator in the original model and using it as the target OPSET version, replacing the OPSET version of the original model to reduce the OPSET version and increase the conversion success rate of the ONNX model on the chip platform.
By reducing the OPSET version, the problem that the chip does not support the ONNX model is solved, and the success rate of the model deployment on the chip platform is improved.
Smart Images

Figure CN119848061B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and particularly to a data update method, apparatus, and electronic device. Background Art
[0002] The Open Neural Network Exchange (ONNX) format is an open file format designed for machine learning and is used to store trained models.
[0003] Based on ONNX, different deep learning training frameworks (such as TensorFlow, PyTorch, Keras, MXNet, Caffe, MindSpore, etc.) can store model data in the same format and interact, promoting interoperability between different deep learning frameworks.
[0004] After a user trains a target model using any deep learning training framework, they will consider deploying the target model in practice; when deploying the target model, the traditional method is to export the target model trained by the deep learning training framework as an ONNX format model. When exporting the target model as an ONNX format model, an operator set OPSET version needs to be specified. The OPSET version determines the set of operators that can be used in the model, and there may be compatibility issues between different OPSET versions. Therefore, it is necessary to ensure that the selected OPSET version is compatible with the OPSET version of the currently used ONNX model when exporting the model.
[0005] Currently, the ONNX model can be sent to a model conversion compiler, and the model conversion compiler converts the ONNX operators in the ONNX model into operators supported by the chip according to the OPSET information, operator attributes, number of inputs, etc. in the ONNX model, completing the actual deployment of the ONNX model.
[0006] However, when the OPSET version of the ONNX model to be deployed is too high, it will cause the model conversion compiler to be unable to convert the ONNX operators into operators supported by the chip, and thus the actual deployment of the ONNX model cannot be achieved. Summary of the Invention
[0007] This application provides a data update method, apparatus, and electronic device to solve the problem that the chip does not support and cannot be converted due to the too high OPSET version of the ONNX model, and improve the deployment success rate of the model on the chip platform. The specific technical solutions are as follows:
[0008] In a first aspect, this application provides a data update method, including:
[0009] Determine the set of historical operator set OPSET versions for each operator included in the original model;
[0010] From the set of historical OPSET versions for each operator, filter out the lowest historical OPSET version for each operator;
[0011] Select a target OPSET version from the lowest historical OPSET versions of each operator, and replace the original OPSET version of the original model with the target OPSET version.
[0012] Based on the above method, by calculating the lowest historical OPSET version of each operator in the original model and determining the lowest OPSET version (target OPSET version) of the original model according to the lowest historical OPSET version of each operator, that is, reducing the OPSET version of the original model, the conversion success rate of the ONNX model on the chip platform can be increased, and the deployment success rate of the model on the chip platform can be improved.
[0013] In a possible implementation, the filtering out of the lowest historical OPSET version for each operator from the set of historical OPSET versions for each operator includes:
[0014] Determine the first historical OPSET version with the smallest difference from the original OPSET version from the set of historical OPSET versions, and determine each historical OPSET version whose historical OPSET version is lower than or equal to the first historical OPSET version;
[0015] Compare each of the historical OPSET versions with the first historical OPSET version, and filter out each candidate historical OPSET version that meets the operator OPSET version selection condition;
[0016] Filter out the lowest historical OPSET version among each of the candidate historical OPSET versions.
[0017] Based on the above method, the lowest historical OPSET version for each operator can be filtered out from the set of historical OPSET versions for each operator, preparing data for subsequent downgrading of the OPSET version of the original model.
[0018] In a possible implementation, the filtering out of the lowest historical OPSET version for each operator from the set of historical OPSET versions for each operator includes:
[0019] From the set of historical OPSET versions, select a baseline OPSET version to obtain the remaining set of historical OPSET versions, where the baseline OPSET version represents the highest historical OPSET version of the available operators in the set of historical OPSET versions;
[0020] Compare each remaining historical OPSET version in the remaining set of historical OPSET versions with the baseline OPSET version, and filter out each remaining historical OPSET version that meets the operator OPSET version selection criteria;
[0021] And determine the lowest historical OPSET version from each of the remaining historical OPSET versions; where the operator OPSET version selection criteria are:
[0022] The operator function of the remaining historical OPSET version is compatible with the operator function of the baseline OPSET version;
[0023] The number of operator inputs and definitions of the remaining historical OPSET version are compatible with the number of operator inputs and definitions of the baseline OPSET version;
[0024] The operator attributes of the remaining historical OPSET version are compatible with the operator attributes of the baseline OPSET version;
[0025] The number of operator outputs and definitions of the remaining historical OPSET version are compatible with the number of operator outputs and definitions of the baseline OPSET version.
[0026] Based on the above method, it is possible to filter out the lowest historical OPSET version of each operator from the set of historical OPSET versions of each operator, preparing data for subsequent downgrading of the OPSET version of the original model.
[0027] In a possible implementation, the selecting a target OPSET version from the lowest historical OPSET version of each operator includes:
[0028] Determine the version number of the lowest historical OPSET version of each operator;
[0029] Sort the lowest historical OPSET version of each operator based on the version number, and select the lowest historical OPSET version with the largest version number as the target OPSET version.
[0030] Based on the above method, it is possible to select a target OPSET version from the lowest historical OPSET version of each operator to replace the original OPSET version of the original model, improving the deployment success rate of the model on the chip platform.
[0031] In a second aspect, the present application provides a data update device, including:
[0032] a data acquisition module, configured to determine the set of historical operator set (OPSET) versions of each operator included in the original model;
[0033] a data screening module, configured to screen out the lowest historical OPSET version of each operator from the set of historical OPSET versions of each operator;
[0034] a data update module, configured to select a target OPSET version from the lowest historical OPSET versions of each operator, and replace the original OPSET version of the original model with the target OPSET version.
[0035] In a possible implementation, the data screening module is specifically configured to:
[0036] determine a first historical OPSET version with the smallest difference from the original OPSET version from the set of historical OPSET versions, and determine each historical OPSET version whose historical OPSET version is lower than or equal to the first historical OPSET version;
[0037] compare each of the historical OPSET versions with the first historical OPSET version, and screen out each candidate historical OPSET version that meets the operator OPSET version selection condition;
[0038] screen out the lowest historical OPSET version among each of the candidate historical OPSET versions.
[0039] In a possible implementation, the data screening module is further configured to:
[0040] select a reference OPSET version from the set of historical OPSET versions to obtain a remaining set of historical OPSET versions, where the reference OPSET version represents the highest historical OPSET version of the available operators in the set of historical OPSET versions;
[0041] compare each remaining historical OPSET version in the remaining set of historical OPSET versions with the reference OPSET version, and screen out each remaining historical OPSET version that meets the operator OPSET version selection condition;
[0042] and determine the lowest historical OPSET version from each of the remaining historical OPSET versions; where the operator OPSET version selection condition is:
[0043] The operator functions of the remaining historical OPSET versions are compatible with those of the reference OPSET version;
[0044] The number of operator inputs and their definitions in the remaining historical OPSET versions are compatible with those of the reference OPSET version;
[0045] The operator attributes of the remaining historical OPSET versions are compatible with those of the reference OPSET version;
[0046] The number of operator outputs and their definitions in the remaining historical OPSET versions are compatible with those of the reference OPSET version.
[0047] In a possible implementation, the data update module is specifically configured to:
[0048] Determine the version number of the lowest historical OPSET version for each operator;
[0049] Sort the lowest historical OPSET versions of each operator based on the version number, and select the lowest historical OPSET version with the largest version number as the target OPSET version.
[0050] In a third aspect, the present application provides an electronic device, including:
[0051] A memory for storing a computer program;
[0052] A processor for implementing the steps of the above data update method when executing the computer program stored in the memory.
[0053] In a fourth aspect, the present application provides a computer-readable storage medium, in which a computer program is stored, and the steps of the above data update method are implemented when the computer program is executed by a processor.
[0054] For the various aspects in the second to fourth aspects above and the possible technical effects that each aspect may achieve, please refer to the technical effects that can be achieved by the above-mentioned first aspect or various possible solutions in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 Schematic diagram of the OPSET version of the original model provided by the embodiment of the present application;
[0056] Figure 2 Flowchart of a data update method provided by the embodiment of the present application;
[0057] Figure 3Schematic diagram of the original model provided by the embodiments of the present application;
[0058] Figure 4 One of the flowcharts of the method for screening the lowest historical OPSET version provided by the embodiments of the present application;
[0059] Figure 5 Another flowchart of the method for screening the lowest historical OPSET version provided by the embodiments of the present application;
[0060] Figure 6 Schematic diagram of the structure of a data update device provided by the embodiments of the present application;
[0061] Figure 7 Schematic diagram of the structure of an electronic device provided by the embodiments of the present application. Detailed implementation manners
[0062] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings. The specific operation methods in the method embodiments can also be applied to the device embodiments or system embodiments. It should be noted that in the description of the present application, "a plurality of" is understood as "at least two". "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The connection between A and B can represent: A is directly connected to B and A is connected to B through C. In addition, in the description of the present application, words such as "first" and "second" are only used for the purpose of distinguishing descriptions, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying order.
[0063] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0064] The Open Neural Network Exchange format is an open file format designed for machine learning and is used to store trained models.
[0065] Based on ONNX, different deep learning training frameworks can store model data in the same format and interact, promoting interoperability between different deep learning frameworks.
[0066] After a user trains a target model using any deep learning training framework, they will consider deploying the target model for actual use; when deploying the target model, the traditional method is to export the target model trained by the deep learning training framework into an ONNX format model. With the development of ONNX, it has introduced different versions of the Operator Set (OPSET), and each OPSET version contains different operators and functions.
[0067] When exporting the target model to an ONNX format model, an OPSET version needs to be specified. The OPSET version determines the set of operators available in the model. There may be compatibility issues between different OPSET versions. Therefore, when exporting the model, it is necessary to ensure that the selected OPSET version is compatible with the OPSET version of the currently used ONNX model.
[0068] Currently, the ONNX model can be sent to the model conversion compiler. The model conversion compiler can convert the ONNX operators in the ONNX model into operators supported by the chip according to the OPSET information, operator attributes, number of inputs, etc. in the ONNX model, and complete the actual deployment of the ONNX model.
[0069] However, when the OPSET version of the ONNX model to be deployed is too high, it will cause the model conversion compiler to be unable to convert the ONNX operators into operators supported by the chip, and thus the actual deployment of the ONNX model cannot be achieved.
[0070] In view of this, to solve the problem that the chip does not support and cannot be converted due to the too high OPSET version of the ONNX model, and to improve the success rate of model deployment on the chip platform, this application provides a data update method, which specifically includes: first determining the set of historical operator set OPSET versions of each operator included in the original model, then screening out the lowest historical OPSET version of each operator from the historical OPSET version sets of each operator, and finally selecting a target OPSET version from the lowest historical OPSET versions of each operator, and replacing the original OPSET version of the original model with the target OPSET version.
[0071] This application calculates the lowest historical OPSET version of each operator in the original model, and determines the lowest OPSET version (target OPSET version) of the original model according to the lowest historical OPSET version of each operator, that is, reduces the OPSET version of the original model, which can increase the conversion success rate of the ONNX model on the chip platform and improve the deployment success rate of the model on the chip platform.
[0072] To facilitate the understanding of this solution, the following explains the relevant technical terms involved in this solution:
[0073] Attribute: In ONNX, an attribute is a parameter unique to an operator, used to describe the behavior and characteristics of these operators. Attributes can be either necessary or optional parameters of the operator, depending on the definition of the operator; in addition, attributes are usually used to control the specific implementation method of the operator. For example, parameters such as stride and padding set in a convolution operation.
[0074] Layer Input: In ONNX, the input refers to the data passed to the layer. These inputs may come from the previous layer of the model, directly from the input data of the entire network, or may belong to weight data (e.g., the weights of the convolution kernel and bias in a convolutional neural network).
[0075] In the embodiments of the present application, an operator in the ONNX model consists of the following parts:
[0076] 1. Operator Type: Represents the function of the operator. For example, the convolution operator (CONV).
[0077] 2. Attributes: Part of the parameters that describe how the operator calculates, such as parameters like stride and padding.
[0078] 3. Input: The input can be specifically divided into dynamic input and static input. Dynamic input means that this input comes from the output of other operators (i.e., this input has a connection relationship with other operators), and the data is the result calculated during the operation of the previous connected layer, and this result is variable; static input means that this input has no connection relationship with other operators, but is a fixed value (weight), and this value is similar to the function of the attributes described above.
[0079] 4. Output: The result output after the operator finishes calculating during operation, and this output result is dynamically changing.
[0080] 5. OPSET: OPSET can be divided into the model OPSET version and the operator OPSET version. If a model OPSET version is specified in the ONNX model, the operator OPSET version corresponding to this model OPSET version takes the operator version corresponding to the maximum OPSET value that conforms to the operator version matching rule in its own supported version list. In addition, for different operator versions, for the same operator type, the number of inputs can change, the attribute definition can be modified, and attributes can also be added or deleted. Therefore, the actual effective function of an operator must be determined according to the operator attributes and inputs under the condition of determining the operator OPSET version to determine the final calculation method.
[0081] The matching rules for operator versions are as follows:
[0082] See Appendix Figure 1 As shown, assuming the OPSET version of the original model is ai.onnx v14, then if there are SOFTMAX operator 13, CONV operator 11, and MAXPOOL operator 12 in this model, then the operator version 13 that is less than or equal to version 14 and closest to this value will be matched as the operator OPSET version.
[0083] The inventive concept of the present application will be described below:
[0084] Taking the SOFTMAX operator as an example, assume that the operator has a total of 3 OPSET versions, version 1, 11, and 13.
[0085] The functions supported in version 1 include: a single dynamic input, a single dynamic output, and support for a positive attribute axis, which indicates that starting from axis, all subsequent dimensions are mixed, and then the overall SOFTMAX calculation is performed.
[0086] In version 11, support for negative axis is newly added (the original positive axis still takes effect). For example, -1 represents the last dimension, and the calculation method remains unchanged compared to version 1.
[0087] In version 13, the range of axis remains unchanged compared to version 1, but the operator definition (function) changes, indicating that the SOFTMAX calculation is only performed on the dimension of axis.
[0088] Based on the above description of the OPSET versions of the historical operators, it can be seen that the functions of version 11 and version 13 of the SOFTMAX operator are not compatible, and these two versions cannot be directly substituted. However, when filling in non - negative numbers, the operator of version 11 actually has the same effect as version 1. Therefore, there is a possibility to change the OPSET version of the operator to achieve the same functional effect.
[0089] Refer to Figure 2 As shown, it is a flowchart of a data update method provided by an embodiment of the present application. The method includes:
[0090] S1. Determine the set of historical operator set OPSET versions of each operator included in the original model.
[0091] In the embodiment of the present application, referring to the attached Figure 3 As shown, it is a schematic structural diagram of the original model. First, the original operator set OPSET version of the original model can be determined. Exemplarily, the original operator set OPSET version can be ai.onnxv15; then determine the set of historical operator set OPSET versions of each operator and each operator included in the original model. Exemplarily, the original model may include sigmoid operator, Relu operator, and Clip operator. And for the convenience of subsequent description of the present solution, assume that the set of historical OPSET versions of each operator is as follows:
[0092] Sigmoid operator:
[0093] Version 1: With the consumed_inputs attribute;
[0094] Version 6: Delete the consumed_inputs attribute;
[0095] Version 13: The attributes are the same as those in Version 6.
[0096] Relu operator:
[0097] Version 1: With the consumed_inputs attribute;
[0098] Version 6: Delete the consumed_inputs attribute;
[0099] Version 13: The attributes are the same as those in Version 6.
[0100] Clip operator:
[0101] Version 1: With 3 attributes, namely consumed_inputs, min, and max attributes;
[0102] Version 6: Delete the consumed_inputs attribute;
[0103] Version 11: Delete the attributes min and max, and change them to inputs. The number of inputs changes from 1 to 3, namely the original input, min input, and max input;
[0104] Version 13 and 12: The same as Version 11.
[0105] It should be noted that each operator included in the above original model and the set of historical operator OPSET versions of each operator are only for illustrative purposes and do not limit the solution of this application.
[0106] In the above manner, the original OPSET version of the original model (e.g., ai.onnx v15) can be determined, and each operator included in the original model and the set of historical OPSET versions of each operator can be determined.
[0107] S2. From the set of historical OPSET versions of each operator, filter out the lowest historical OPSET version of each operator.
[0108] In the embodiments of this application, see the appendix Figure 4 As shown, filtering out the lowest historical OPSET version of each operator in the original model may include the following steps:
[0109] S401. Determine the first historical OPSET version with the smallest difference from the original OPSET version from the set of historical OPSET versions, and determine each historical OPSET version whose operator version is lower than or equal to the first historical OPSET version;
[0110] S402. Compare each historical OPSET version with the first historical OPSET version, and screen out each candidate historical OPSET version that meets the operator OPSET version selection criteria.
[0111] S403. Screen out the lowest historical OPSET version among each candidate historical OPSET version.
[0112] In step S401, the original OPSET version of the original model is ai.onnx v15 (hereinafter referred to as the original OPSET version 15). For the sigmoid operator in each operator included in the original model, the historical OPSET versions included in the sigmoid operator are: historical OPSET version 1, historical OPSET version 6, and historical OPSET version 13. When determining the first historical OPSET version with the smallest difference from the original OPSET version from the set of historical OPSET versions, specifically, historical OPSET version 13 can be selected as the first historical OPSET version, and the first historical OPSET version is used as the subsequent determination benchmark.
[0113] In this application, while determining the first historical OPSET version, the historical OPSET versions with a historical OPSET version lower than or equal to the first historical OPSET version can also be determined. For example, historical OPSET version 1 and historical OPSET version 6.
[0114] In step S402, each historical OPSET version can be compared with the first historical OPSET version, and each candidate historical OPSET version that meets the operator OPSET version selection criteria is screened out. Specifically, one historical OPSET version can be selected from each historical OPSET version and compared with the first historical OPSET version in reverse order or order of the version number size, and each candidate historical OPSET version that meets the operator OPSET version selection criteria is screened out. This application does not specifically limit the selection method of the historical OPSET version.
[0115] In the embodiment of this application, when screening out each candidate historical OPSET version that meets the operator OPSET version selection criteria, the operator OPSET version selection criteria are as follows:
[0116] For any candidate historical OPSET version among each historical OPSET version, for example, historical OPSET version 1.
[0117] First, it can be determined whether the operator functions of the candidate historical OPSET versions are compatible with those of the first historical OPSET version (historical OPSET version 13). If they are compatible, it means that the first condition for selecting the operator OPSET version is met. If not, then jump to the next candidate historical OPSET version among each historical OPSET version (e.g., historical OPSET version 6); then determine whether the number of operator inputs and the definitions of the candidate historical OPSET version are compatible with those of the first historical OPSET version. If they are compatible, it means that the second condition for selecting the operator OPSET version is met. If not, then jump to the next candidate historical OPSET version among each historical OPSET version; then determine whether the operator attributes of the candidate historical OPSET version are compatible with those of the first historical OPSET version. If they are compatible, it means that the third condition for selecting the operator OPSET version is met. If not, then jump to the next candidate historical OPSET version among each historical OPSET version; finally, determine whether the number of operator outputs and the definitions of the candidate historical OPSET version are compatible with those of the first historical OPSET version. If they are compatible, it means that the fourth condition for selecting the operator OPSET version is met. If not, then jump to the next candidate historical OPSET version among each historical OPSET version.
[0118] When the candidate historical OPSET version meets the first, second, third, and fourth conditions for selecting the operator OPSET version, it can be determined that the candidate historical OPSET version meets the conditions for selecting the operator OPSET version. This application does not make specific restrictions on the number of conditions for selecting the operator OPSET version and the comparison order between the candidate historical OPSET version and the first historical OPSET version.
[0119] In step S403, refer to the appendix Figure 5 Combined with the above example, historical OPSET versions 1 and 13 have the same functions, meeting the requirements for operator function compatibility; the number of operator inputs of historical OPSET versions 1 and 13 is the same, and the definitions have not changed, meeting the compatibility requirements; the operator attributes of historical OPSET versions 1 and 13 are not compatible. Historical OPSET version 1 includes the consumed_inputs attribute. Therefore, historical OPSET version 1 does not meet the conditions for selecting the operator OPSET version.
[0120] Further, the historical OPSET version 6 is compared with the first historical OPSET version as the candidate historical OPSET version. The operator functions of the historical OPSET versions 6 and 13 are the same, meeting the compatibility requirements; the number of operator inputs of the historical OPSET versions 6 and 13 is the same, and the definitions have not changed, meeting the compatibility requirements; the operator attributes of the historical OPSET versions 6 and 13 are exactly the same, meeting the compatibility requirements; the number of operator outputs of the historical OPSET versions 6 and 13 is the same, and the definitions have not changed, meeting the compatibility requirements. Therefore, the historical OPSET version 6 meets the operator OPSET version selection conditions and can be used as the lowest historical OPSET version of the sigmoid operator.
[0121] Based on the above method, the lowest historical OPSET version of the sigmoid operator in the original model can be determined.
[0122] In the embodiment of the present application, after determining the lowest historical OPSET version of the sigmoid operator, based on the above operator OPSET version selection conditions same as those of the sigmoid operator, the remaining Relu operators and Clip operators in the original model can be traversed.
[0123] The process of determining the lowest historical OPSET version of the Relu operator is as follows:
[0124] The Relu operator has 3 OPSET versions: historical OPSET versions 1, 6, and 13; the operator version 13 closest to the original OPSET version 15 is used as the (first historical OPSET version) determination benchmark:
[0125] Starting from the historical OPSET version 1 for determination (the historical OPSET version 1 is used as the candidate historical OPSET version), it is determined that the operator functions of the historical OPSET versions 1 and 13 are the same, meeting the compatibility requirements; next, the number of operator inputs is determined, the number of operator inputs is the same, and the definition has not changed, meeting the compatibility requirements; next, the operator attributes are determined, the operator attributes of the historical OPSET versions 1 and 13 are not compatible, and the historical OPSET version 1 includes the consumed_inputs attribute. Therefore, the historical OPSET version 1 does not meet the operator OPSET version selection conditions.
[0126] Start to determine version 6 (historical OPSET version 6 is used as the candidate historical OPSET version). The operator functions of version 6 and 13 are the same, meeting the compatibility requirements; next, determine the number of operator inputs. The number of operators is the same, and the definition has not changed, meeting the compatibility requirements; next, determine the operator attributes. The operator attributes are required to be exactly the same, meeting the compatibility requirements; next, determine the number of operator outputs. The numbers are the same, and the definition has not changed, meeting the compatibility requirements. Therefore, historical OPSET version 6 meets the operator OPSET version selection conditions, and historical OPSET version 6 can be used as the lowest historical OPSET version of the Relu operator.
[0127] Based on the above method, the lowest historical OPSET version of the Relu operator in the original model can be determined.
[0128] The process of determining the lowest historical OPSET version of the Clip operator is as follows:
[0129] The Clip operator has 5 OPSET versions: historical OPSET versions 1, 6, 11, 12, and 13; use the operator version 13, which is closest to the original OPSET version 15, as the (first historical OPSET version) judgment benchmark:
[0130] Start to determine from historical OPSET version 1 (historical OPSET version 1 is used as the candidate historical OPSET version). Determine that the operator functions of historical OPSET versions 1 and 13 are the same, meeting the compatibility requirements; next, determine the number of operator inputs. The number of operator inputs is the same, and the definition has not changed, meeting the compatibility requirements; next, determine the operator attributes. The operator attributes of historical OPSET versions 1 and 13 are not compatible. Historical OPSET version 1 includes the consumed_inputs attribute. Therefore, historical OPSET version 1 does not meet the operator OPSET version selection conditions.
[0131] Start to determine version 6 (historical OPSET version 6 is used as the candidate historical OPSET version). The operator functions of version 6 and 13 are the same, meeting the compatibility requirements; next, determine the number of operator inputs. The number of operator inputs of historical OPSET version 6 is 1, while the number of inputs of historical OPSET version 13 is 3. Therefore, historical OPSET version 6 does not meet the operator OPSET version selection conditions;
[0132] Start to determine version 11 (historical OPSET version 11 is used as the candidate historical OPSET version). The operator functions of version 11 and version 13 are the same, meeting the compatibility requirements; next, determine the number of operator inputs. The number of operators is the same, and the definition has not changed, meeting the compatibility requirements; next, determine the operator attributes. The operator attributes are required to be exactly the same, meeting the compatibility requirements; next, determine the number of operator outputs. The numbers are the same, and the definition has not changed, meeting the compatibility requirements. Therefore, the historical OPSET version 11 meets the operator OPSET version selection conditions, and the historical OPSET version 11 can be used as the lowest historical OPSET version of the Clip operator.
[0133] Through the above method, the lowest historical OPSET version of the Clip operator in the original model can be determined.
[0134] In the embodiment of the present application, when traversing the lowest historical OPSET version of the second Sigmoid operator, the method of traversing the lowest historical OPSET version of the first Sigmoid operator can be referred to, which will not be elaborated here.
[0135] Through the above method, the lowest historical OPSET version of each operator in the original model can be screened out.
[0136] In a possible implementation manner, when screening out the lowest historical OPSET version of each operator, the following method can also be used:
[0137] First, in the set of historical OPSET versions, select the reference OPSET version to obtain the remaining set of historical OPSET versions. Among them, the reference OPSET version represents the highest historical OPSET version of the available operators in the set of historical OPSET versions. The selection method of the reference OPSET version can be the same as that of the first historical OPSET version, which will not be elaborated here;
[0138] Then, compare each remaining historical OPSET version in the remaining set of historical OPSET versions with the reference OPSET version, and screen out each remaining historical OPSET version that meets the operator OPSET version selection conditions. The operator OPSET version selection conditions and the comparison method are the same as above, which will not be elaborated here;
[0139] Finally, determine the lowest historical OPSET version from each remaining historical OPSET version; among them, the operator OPSET version selection conditions are:
[0140] The operator function of the remaining historical OPSET version is compatible with the operator function of the reference OPSET version;
[0141] The number of operator inputs and the definitions of the remaining historical OPSET versions are compatible with the number of operator inputs and the definitions of the baseline OPSET version;
[0142] The operator attributes of the remaining historical OPSET versions are compatible with the operator attributes of the baseline OPSET version;
[0143] The number of operator outputs and the definitions of the remaining historical OPSET versions are compatible with the number of operator outputs and the definitions of the baseline OPSET version.
[0144] In the above manner, the lowest historical OPSET version of each operator in the original model can be screened out.
[0145] S3. Select a target OPSET version from the lowest historical OPSET version of each operator, and replace the original OPSET version of the original model with the target OPSET version.
[0146] In the embodiment of the present application, when selecting a target OPSET version from the lowest historical OPSET version of each operator, specifically, the version number of the lowest historical OPSET version of each operator can be determined first. For example, Sigmoid(6) -> Relu(6) -> Clip(11) -> Sigmoid(6); then, sort the lowest historical OPSET version of each operator according to the version number, and finally select the lowest historical OPSET version with the largest version number as the target OPSET version, for example, OPSET version 11.
[0147] In summary, by calculating the lowest historical OPSET version of each operator in the original model and determining the lowest OPSET version of the original model according to the lowest historical OPSET version of each operator, this method of reducing the OPSET version of the original model can increase the conversion success rate of the ONNX model on the chip platform and improve the deployment success rate of the model on the chip platform.
[0148] Based on the method provided in the above embodiments, the embodiment of the present application also provides a data update device, as Figure 6 shown in the structural schematic diagram of a data update device in the embodiment of the present application. The device includes:
[0149] A data acquisition module 601, configured to determine the set of historical operator set (OPSET) versions of each operator included in the original model;
[0150] A data screening module 602, configured to screen out the lowest historical OPSET version of each operator from the set of historical OPSET versions of each operator.
[0151] The data update module 603 is configured to select a target OPSET version from the lowest historical OPSET versions of each operator respectively, and replace the original OPSET version of the original model with the target OPSET version.
[0152] In a possible implementation, the data screening module 602 is specifically configured to:
[0153] Determine a first historical OPSET version with the smallest difference from the original OPSET version from the set of historical OPSET versions, and determine each historical OPSET version whose historical OPSET version is lower than or equal to the first historical OPSET version;
[0154] Compare each of the historical OPSET versions with the first historical OPSET version, and screen out each candidate historical OPSET version that meets the operator OPSET version selection condition;
[0155] Screen out the lowest historical OPSET version among each of the candidate historical OPSET versions.
[0156] In a possible implementation, the data screening module 602 is further configured to:
[0157] Select a reference OPSET version from the set of historical OPSET versions to obtain a remaining set of historical OPSET versions, where the reference OPSET version represents the highest historical OPSET version of the available operators in the set of historical OPSET versions;
[0158] Compare each remaining historical OPSET version in the remaining set of historical OPSET versions with the reference OPSET version, and screen out each remaining historical OPSET version that meets the operator OPSET version selection condition;
[0159] And determine the lowest historical OPSET version from each of the remaining historical OPSET versions; wherein, the operator OPSET version selection condition is:
[0160] The operator function of the remaining historical OPSET version is compatible with the operator function of the reference OPSET version;
[0161] The number of operator inputs and the definition of the remaining historical OPSET version are compatible with the number of operator inputs and the definition of the reference OPSET version;
[0162] The operator attributes of the remaining historical OPSET version are compatible with the operator attributes of the reference OPSET version;
[0163] The number of operator outputs and the definitions of the remaining historical OPSET versions are compatible with the number of operator outputs and the definitions of the reference OPSET version.
[0164] In a possible implementation, the data update module 603 is specifically configured to:
[0165] Determine the version number of the lowest historical OPSET version for each operator;
[0166] Sort the lowest historical OPSET versions of each operator based on the version number, and select the lowest historical OPSET version with the largest version number as the target OPSET version.
[0167] Based on the same inventive concept, an embodiment of the present application also provides an electronic device, which can implement the functions of the foregoing data update device. Refer to Figure 7 , the electronic device includes:
[0168] At least one processor 701, and a memory 702 connected to at least one processor 701. In the embodiments of the present application, the specific connection medium between the processor 701 and the memory 702 is not limited. Figure 7 In Figure 7 it is taken as an example that the processor 701 and the memory 702 are connected through a bus 700. The bus 700 is represented by a thick line in Figure 7 . The connection manners between other components are only for illustrative purposes and are not limited thereto. The bus 700 can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation,
[0169] In the embodiments of the present application, the memory 702 stores instructions executable by at least one processor 701. By executing the instructions stored in the memory 702, at least one processor 701 can execute the data update method described above. The processor 701 can implement Figure 6 the functions of each module in the device shown.
[0170] Among them, the processor 701 is the control center of the device, and can connect various parts of the entire control device through various interfaces and lines. By running or executing the instructions stored in the memory 702 and calling the data stored in the memory 702, various functions of the device and process data, so as to monitor the device as a whole.
[0171] In a possible design, the processor 701 may include one or more processing units. The processor 701 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communications. It can be understood that the above-mentioned modem processor may not be integrated into the processor 701 either. In some embodiments, the processor 701 and the memory 702 may be implemented on the same chip, and in some embodiments, they may also be separately implemented on independent chips.
[0172] The processor 701 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application-specific integrated circuit, a field-programmable gate array, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the data update method disclosed in combination with the embodiments of the present application may be directly embodied as being executed by a hardware processor, or executed by a combination of hardware and software modules in the processor.
[0173] As a non-volatile computer-readable storage medium, the memory 702 can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The memory 702 may include at least one type of storage medium, for example, it may include flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (RAM), a static random access memory (SRAM), a programmable read-only memory (PROM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic memory, a magnetic disk, an optical disk, and so on. The memory 702 is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 702 in the embodiments of the present application may also be a circuit or any other device capable of implementing a storage function, for storing program instructions and / or data.
[0174] By programming the design of the processor 701, the code corresponding to the data update method introduced in the foregoing embodiments can be solidified into the chip, so that the chip can execute when running Figure 2Steps of the data update method of the illustrated embodiment. How to design and program the processor 701 is a well-known technology to those skilled in the art and will not be elaborated here.
[0175] Based on the same inventive concept, an embodiment of the present application further provides a storage medium storing computer instructions, which when run on a computer, cause the computer to execute the data update method discussed above.
[0176] In some possible implementation manners, each aspect of the data update method provided by the present application may also be implemented in the form of a program product, which includes program code. When the program product runs on a device, the program code is used to cause the control device to execute the steps in the data update method according to various exemplary embodiments of the present application described above in this specification.
[0177] Those skilled in the art should understand that the embodiments of the present application may be provided as a method, a system, or a computer program product. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0178] The present application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one or more flows Figure 1 or a combination of multiple flows and / or blocks
[0179] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device that implements the functions specified in Figure 1 one or more flows Figure 1 or a combination of multiple flows and / or blocks
[0180] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are executed on the computer or other programmable apparatus to produce a computer-implemented process, thereby providing instructions for implementing the steps specified in one process or a plurality of processes and / or blocks Figure 1 one process or a plurality of processes and / or blocks Figure 1 in one block or a plurality of blocks.
[0181] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these modifications and variations.
Claims
1. A data updating method, characterized in that: include: Determine the historical operator set OPSET version set for each operator included in the original model; From the respective historical OPSET version set of each operator, the lowest historical OPSET version of each operator is selected, including: Determine, from the historical OPSET version set, a first historical OPSET version with the smallest difference from the original OPSET version, and determine each historical OPSET version whose historical OPSET version is lower than or equal to the first historical OPSET version; Compare the historical OPSET versions with the first historical OPSET version to select the historical OPSET versions that meet the operator OPSET version selection condition; Filter out the lowest historical OPSET version from among the historical OPSET versions to be selected; A target OPSET version is selected from the lowest historical OPSET version of each operator, and the original OPSET version of the original model is replaced with the target OPSET version.
2. The method according to claim 1, characterized in that The step of selecting the lowest historical OPSET version of each operator from the historical OPSET version set of each operator includes: In the historical OPSET version set, a base OPSET version is selected to obtain a remaining historical OPSET version set, wherein the base OPSET version represents the highest historical OPSET version of the operator available in the historical OPSET version set; Compare each remaining historical OPSET version in the remaining historical OPSET version set with the benchmark OPSET version, and select each remaining historical OPSET version that meets the operator OPSET version selection condition; Determine the lowest historical OPSET version from the remaining historical OPSET versions; wherein the operator OPSET version selection condition is: The operator functions of the remaining historical OPSET versions are compatible with the operator functions of the baseline OPSET version; The number and definition of operator inputs of the remaining historical OPSET versions are compatible with the number and definition of operator inputs of the baseline OPSET version; The operator attributes of the remaining historical OPSET versions are compatible with the operator attributes of the baseline OPSET version; The operator output number and definition of the remaining historical OPSET version are compatible with the operator output number and definition of the baseline OPSET version.
3. The method according to claim 1, characterized in that The step of selecting a target OPSET version from the lowest historical OPSET version of each operator includes: Determine the version number of the lowest historical OPSET version for each operator; The lowest historical OPSET version of each operator is sorted based on the version number, and the lowest historical OPSET version with the largest version number is selected as the target OPSET version.
4. A data updating device, characterized in that: include: A data acquisition module is used to determine the version set of the historical operator set OPSET for each operator included in the original model; The data screening module is used to screen out the lowest historical OPSET version of each operator from the historical OPSET version set of each operator, including: Determine, from the historical OPSET version set, a first historical OPSET version with the smallest difference from the original OPSET version, and determine each historical OPSET version whose historical OPSET version is lower than or equal to the first historical OPSET version; Compare the historical OPSET versions with the first historical OPSET version to select the historical OPSET versions that meet the operator OPSET version selection condition; Filter out the lowest historical OPSET version from among the historical OPSET versions to be selected; The data updating module is used to select a target OPSET version from the lowest historical OPSET version of each operator, and replace the original OPSET version of the original model with the target OPSET version.
5. The device according to claim 4, characterized in that The data screening module is also used for: In the historical OPSET version set, a base OPSET version is selected to obtain a remaining historical OPSET version set, wherein the base OPSET version represents the highest historical OPSET version of the operator available in the historical OPSET version set; Compare each remaining historical OPSET version in the remaining historical OPSET version set with the benchmark OPSET version, and select each remaining historical OPSET version that meets the operator OPSET version selection condition; And determine the lowest historical OPSET version from the remaining historical OPSET versions; wherein the operator OPSET version selection condition is: The operator functions of the remaining historical OPSET versions are compatible with the operator functions of the baseline OPSET version; The number and definition of operator inputs of the remaining historical OPSET versions are compatible with the number and definition of operator inputs of the baseline OPSET version; The operator attributes of the remaining historical OPSET versions are compatible with the operator attributes of the baseline OPSET version; The operator output number and definition of the remaining historical OPSET version are compatible with the operator output number and definition of the baseline OPSET version.
6. The device according to claim 4, characterized in that The data updating module is specifically used for: Determine the version number of the lowest historical OPSET version for each operator; The lowest historical OPSET version of each operator is sorted based on the version number, and the lowest historical OPSET version with the largest version number is selected as the target OPSET version.
7. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to implement the method steps of any one of claims 1 to 3 when executing a computer program stored in the memory.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Deep learning model deployment method and device
CN116739040A