Model conversion method, model conversion device, and readable storage medium

By obtaining operator classification information within the original framework and replacing it with the target operator, combined with input and output dimension verification, the problems of low model conversion efficiency and dimension mismatch are solved, achieving efficient model conversion and anomaly detection.

CN116029376BActive Publication Date: 2026-06-09PENG CHENG LAB

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PENG CHENG LAB
Filing Date
2023-01-10
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing model conversion methods are inefficient and suffer from dimension mismatch and memory leaks on embedded platforms, resulting in low conversion efficiency and difficulty in locating anomalies.

Method used

By reasoning about the original model within the original framework, operator classification information for each original operator is obtained. Then, the original operator is replaced with the target operator according to the target framework. The mapping relationship is recorded. Reasoning is performed within the target framework, and the input and output dimensions are verified to ensure dimensional consistency and avoid anomalies.

Benefits of technology

It improves model conversion efficiency, avoids the tedious process of locating abnormal results, and ensures that the model runs normally within the target framework.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116029376B_ABST
    Figure CN116029376B_ABST
Patent Text Reader

Abstract

This application discloses a model conversion method, a model conversion device, and a readable storage medium. The model conversion method includes the following steps: performing inference on the original model under the original framework, and obtaining operator classification information for each original operator in the original model under the target framework based on the target framework; replacing the original operators with target operators under the target framework based on the operator classification information to obtain a target model, and recording the mapping relationship between the target operators and the original operators; performing inference on the target model under the target framework, and verifying the input and output dimensions of the original operators and the target operators based on the mapping relationship to obtain a verification result; and completing the inference of the target model based on the verification result. This application improves the efficiency of model conversion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of machine learning technology, and in particular to a model conversion method, a model conversion device, and a readable storage medium. Background Technology

[0002] AI inference frameworks running on embedded platforms, such as Tengine and TVM, have been adapted to chip-level processors and intelligent acceleration hardware, improving the inference capabilities of embedded platforms. However, these inference frameworks do not support model training. General-purpose AI frameworks, such as TensorFlow and PyTorch, are not adapted for the specific hardware of embedded platforms, but they can perform model training conveniently and efficiently. Because different AI frameworks use different model formats, model conversion is required to deploy models trained by general-purpose AI frameworks to embedded platforms.

[0003] Current model conversion methods involve overly cumbersome recording of operator computation information from the original model, including the entire forward propagation call stack, function names, parameters, and return values. Furthermore, the target operator uses the processing data from the original model's inference process, resulting in poor efficiency and adaptability. In addition, embedded platform AI inference frameworks are mostly implemented in C / C++ to improve performance. Current model conversion methods do not consider the possibility of dimensional mismatches in certain operator connections after the target framework graph structure is restructured. This can lead to memory leaks during inference without affecting the overall model inference operation. The problem is only discovered when the final inference result is abnormal, making it difficult to pinpoint the issue and severely impacting conversion efficiency. Summary of the Invention

[0004] The main objective of this application is to provide a model conversion method, a model conversion device, and a readable storage medium, aiming to solve the problem of low efficiency in model conversion.

[0005] To achieve the above objectives, this application provides a model conversion method, which includes the following steps:

[0006] Reasoning is performed on the original model within the original framework, and operator classification information for each original operator in the original model under the target framework is obtained based on the target framework.

[0007] Based on the operator classification information, the original operator is replaced with the target operator under the target framework to obtain the target model, and the mapping relationship between the target operator and the original operator is recorded.

[0008] Reasoning is performed on the target model within the target framework, and the input and output dimensions of the original operator and the target operator are verified according to the mapping relationship to obtain the verification result;

[0009] The inference of the target model is completed based on the verification results.

[0010] Optionally, the step of reasoning about the original model within the original framework and obtaining the operator classification information of each original operator in the original model within the target framework according to the target framework includes:

[0011] The original model is inferred within the original framework, and the operator information of each original operator is recorded during the inference process;

[0012] The operator information is classified according to the operator support of the target framework to obtain the operator classification information of the original operator under the target framework.

[0013] Optionally, the step of replacing the original operator with the target operator under the target framework based on the operator classification information includes:

[0014] When the operator classification information indicates that the original operator has a matching operator within the target framework, and neither the target operator nor the original operator has any input parameters, then the original operator is replaced with the target operator in the target model.

[0015] Optionally, the step of replacing the original operator with the target operator under the target framework based on the operator classification information further includes:

[0016] When the operator classification information indicates that the original operator has a matching operator within the target frame, and both the target operator and the original operator have input parameters, then the types of the input parameters of the target operator and the original operator are obtained respectively.

[0017] When the input parameter of the target operator is a newly added parameter, the input parameter of the target operator is assigned an invalid value;

[0018] When the input parameters of the primitive operator are untrained parameters, the input parameters of the primitive operator are assigned invalid values;

[0019] The original operator after the input parameters have been assigned is replaced with the target operator after the input parameters have been assigned.

[0020] Optionally, the step of replacing the original operator with the target operator under the target framework based on the operator classification information further includes:

[0021] When the operator classification information indicates that there is no matching operator for the original operator within the target framework, but there is a replaceable operator, then one original operator corresponding to the target operator will be replaced with the target operator or the target operator corresponding to the fusion operator of multiple original operators.

[0022] Optionally, the step of replacing the original operator with the target operator under the target framework based on the operator classification information further includes:

[0023] If the operator classification information indicates that there is no matching operator for the original operator within the target frame, then the original operator is deleted.

[0024] Obtain the dimension information of the operators that are positioned before and after the original operator after deletion;

[0025] When the dimensional information is inconsistent, a preset operator is added to make the dimensional information of the operators before and after the original operator consistent.

[0026] Optionally, the step of reasoning about the target model within the target framework, verifying the input-output dimensions of the original operator and the target operator according to the mapping relationship, and obtaining the verification result includes:

[0027] Reasoning is performed on the target model within the target framework to obtain the first input-output dimension of the target operator in the target model during the reasoning process.

[0028] The second input-output dimension of the original operator corresponding to the target operator is obtained based on the mapping relationship;

[0029] The first input / output dimension and the second input / output dimension are compared and verified to obtain the verification result.

[0030] Optionally, the step of completing the inference of the target model based on the verification result includes:

[0031] If the verification result shows that the first input / output dimension is inconsistent with the second input / output dimension, then the target operator dimension is determined to be abnormal, and the inference is terminated.

[0032] If the verification result shows that the first input / output dimension is consistent with the second input / output dimension, then the reasoning continues until the calculation of the target model is completed.

[0033] In addition, to achieve the above objectives, the present invention also provides a model conversion apparatus, characterized in that the model conversion apparatus includes: a memory, a processor, and a model conversion program stored in the memory and executable on the processor, wherein when the model conversion program is executed by the processor, it implements the steps of the model conversion method as described above.

[0034] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium storing a model conversion program, which, when executed by a processor, implements the steps of the model conversion method as described above.

[0035] This invention provides a model conversion method, a model conversion device, and a readable storage medium. By performing inference on the original model within the original framework and obtaining operator classification information for each original operator in the original model within the target framework, the method can quickly provide an overview of the original model's support within the target framework. This also facilitates targeted processing based on the category of each operator during the model conversion stage. By replacing the original operators with target operators within the target framework according to the operator classification information, a target model is obtained, and the mapping relationship between the target operators and the original operators is recorded. This enables the conversion of the original model within the original framework into a target model within the target framework, completing the model conversion process. By performing inference on the target model within the target framework and verifying the input and output dimensions of the original and target operators according to the mapping relationship, a verification result is obtained. Based on the verification result, the inference of the target model is completed. This allows inference using the target model within the target framework, performing dimension verification on each operator. If a dimension anomaly is found, the method reports the operator conversion anomaly and exits the inference process, avoiding the tedious process of locating abnormal inference results and thus improving the conversion efficiency during the model conversion process. Attached Figure Description

[0036] Figure 1 This is a schematic diagram of the hardware operating environment involved in the embodiment of the model conversion method of the present invention;

[0037] Figure 2 This is a flowchart illustrating one embodiment of the model conversion method of the present invention;

[0038] Figure 3 This is a detailed flowchart of step S10 in one embodiment of the model conversion method of the present invention;

[0039] Figure 4 This is a detailed flowchart of step S20 in one embodiment of the model conversion method of the present invention;

[0040] Figure 5 This is a detailed flowchart of step S30 in one embodiment of the model conversion method of the present invention.

[0041] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0043] like Figure 1 As shown, Figure 1 This is a schematic diagram of the terminal structure of the hardware operating environment involved in the embodiments of the present invention.

[0044] In this embodiment of the invention, the terminal is a model conversion device.

[0045] like Figure 1 As shown, the terminal may include: a processor 1001, such as a CPU; a communication bus 1002; a user interface 1003; a DVI interface 1004; a USB interface 1005; and a memory 1006. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen and an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The DVI interface 1004 may optionally include a standard wired interface for connecting to other external devices via a DVI cable. The USB interface 1005 may optionally include a standard wired interface for connecting to other external devices via a USB cable. The memory 1006 may be high-speed RAM or non-volatile memory, such as a disk drive. Optionally, the memory 1006 may also be a storage device independent of the aforementioned processor 1001.

[0046] Optionally, the terminal may also include audio circuitry, etc., which will not be elaborated here.

[0047] Those skilled in the art will understand that Figure 1 The terminal structure shown does not constitute a limitation on the terminal and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0048] like Figure 1 As shown, the memory 1006, which serves as a computer storage medium, may include an operating system, a DVI interface module, a USB interface module, a user interface module, and a model conversion program.

[0049] exist Figure 1 In the terminal shown, the DVI interface 1004 is mainly used to connect to external devices and communicate with them; the USB interface 1005 is mainly used to connect to external devices and communicate with them; the user interface 1003 is mainly used to connect to clients and communicate with them; and the processor 1001 can be used to call the model conversion program stored in the memory 1006 and perform the following operations:

[0050] Reasoning is performed on the original model within the original framework, and operator classification information for each original operator in the original model under the target framework is obtained based on the target framework.

[0051] Based on the operator classification information, the original operator is replaced with the target operator under the target framework to obtain the target model, and the mapping relationship between the target operator and the original operator is recorded.

[0052] Reasoning is performed on the target model within the target framework, and the input and output dimensions of the original operator and the target operator are verified according to the mapping relationship to obtain the verification result;

[0053] The inference of the target model is completed based on the verification results.

[0054] Furthermore, the processor 1001 can call the model conversion program stored in the memory 1006 and also perform the following operations:

[0055] The original model is inferred within the original framework, and the operator information of each original operator is recorded during the inference process;

[0056] The operator information is classified according to the operator support of the target framework to obtain the operator classification information of the original operator under the target framework.

[0057] Furthermore, the processor 1001 can call the model conversion program stored in the memory 1006 and also perform the following operations:

[0058] When the operator classification information indicates that the original operator has a matching operator within the target framework, and neither the target operator nor the original operator has any input parameters, then the original operator is replaced with the target operator in the target model.

[0059] Furthermore, the processor 1001 can call the model conversion program stored in the memory 1006 and also perform the following operations:

[0060] When the operator classification information indicates that the original operator has a matching operator within the target frame, and both the target operator and the original operator have input parameters, then the types of the input parameters of the target operator and the original operator are obtained respectively.

[0061] When the input parameter of the target operator is a newly added parameter, the input parameter of the target operator is assigned an invalid value;

[0062] When the input parameters of the primitive operator are untrained parameters, the input parameters of the primitive operator are assigned invalid values;

[0063] The original operator after the input parameters have been assigned is replaced with the target operator after the input parameters have been assigned.

[0064] Furthermore, the processor 1001 can call the model conversion program stored in the memory 1006 and also perform the following operations:

[0065] When the operator classification information indicates that there is no matching operator for the original operator within the target framework, but there is a replaceable operator, then one original operator corresponding to the target operator will be replaced with the target operator or the target operator corresponding to the fusion operator of multiple original operators.

[0066] Furthermore, the processor 1001 can call the model conversion program stored in the memory 1006 and also perform the following operations:

[0067] If the operator classification information indicates that there is no matching operator for the original operator within the target frame, then the original operator is deleted.

[0068] Obtain the dimension information of the operators that are positioned before and after the original operator after deletion;

[0069] When the dimensional information is inconsistent, a preset operator is added to make the dimensional information of the operators before and after the original operator consistent.

[0070] Furthermore, the processor 1001 can call the model conversion program stored in the memory 1006 and also perform the following operations:

[0071] Reasoning is performed on the target model within the target framework to obtain the first input-output dimension of the target operator in the target model during the reasoning process.

[0072] The second input-output dimension of the original operator corresponding to the target operator is obtained based on the mapping relationship;

[0073] The first input / output dimension and the second input / output dimension are compared and verified to obtain the verification result.

[0074] Furthermore, the processor 1001 can call the model conversion program stored in the memory 1006 and also perform the following operations:

[0075] If the verification result shows that the first input / output dimension is inconsistent with the second input / output dimension, then the target operator dimension is determined to be abnormal, and the inference is terminated.

[0076] If the verification result shows that the first input / output dimension is consistent with the second input / output dimension, then the reasoning continues until the calculation of the target model is completed.

[0077] The specific embodiments of the model conversion device of the present invention are basically the same as the embodiments of the model conversion program described below, and will not be repeated here.

[0078] Please see Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the model conversion method of the present invention. The model conversion method provided in this embodiment includes the following steps:

[0079] Step S10: Infer the original model under the original framework, and obtain the operator classification information of each original operator in the original model under the target framework according to the target framework;

[0080] In one embodiment, step S10 further includes:

[0081] Step S11: Perform reasoning on the original model within the original framework and record the operator information of each original operator during the reasoning process;

[0082] A framework, or AI inference framework, is used for training network models. Different frameworks correspond to different network model formats; for example, TensorFlow, Caffe, PyTorch, and PaddlePaddle frameworks correspond to different model formats. The original framework is the framework corresponding to the format of the original model. The purpose of model conversion in this embodiment is to achieve mutual conversion between models under different frameworks, so that the model can flow between different frameworks. Deep learning algorithms are composed of individual computational units, which are called operators (Op). In a network model, operators correspond to computational logic; for example, a convolutional layer is an operator; the weight summation process in a fully connected layer is an operator. The original model in this invention is a network model composed of multiple operators sequentially.

[0083] In this embodiment, input data is first passed in according to the input dimension requirements of the original model. The original model is then inferred within the original framework to obtain operator information for each operator. This operator information includes the name, category, input dimension, and output dimension of each operator, recorded in the format (operator name, operator category, input dimension, output dimension). The operator name is unique within the entire model. The input data can be an image, and the input dimensions are the image's width, height, and number of channels.

[0084] Step S12: Classify the operator information according to the operator support of the target framework to obtain the operator classification information of the original operator under the target framework.

[0085] To confirm whether the target framework supports the operators of the original model, the recorded operator information can be passed to the operator classification module. The module will output operator classification information according to the support status of the operators in the target framework. The display format is as follows: The model has X operators, Y type operators, operators that match completely and have no parameters: "opt1, opt2...", operators that match completely and have parameters: "opt3, opt4...", operators that can be replaced: "opt5, opt6, opt7...", and operators that do not match: "opt8, opt9...", where opt is the abbreviation of the operator.

[0086] Step S20: Based on the operator classification information, replace the original operator with the target operator under the target framework to obtain the target model, and record the mapping relationship between the target operator and the original operator;

[0087] In the specific process of model conversion, it is necessary to replace the target operators in the target framework into the original model based on the operator classification information, so as to replace the original operators and obtain the target model composed of the target operators. The replacement relationship between the original operators and the target operators in the conversion process is the mapping relationship between the target operators and the original operators.

[0088] In one embodiment, the specific conversion process is as follows: the step of replacing the original operator with the target operator under the target framework based on the operator classification information includes:

[0089] Step A21: When the operator classification information indicates that the original operator has a matching target operator within the target frame, and neither the target operator nor the original operator has any input parameters, then the original operator is replaced with the target operator.

[0090] Since operators represent computational logic, and each operator in the network model has a hierarchical connection, each operator has inputs and outputs; that is, the output of the operator in the previous layer becomes the input of the next operator. However, in this embodiment, the input parameters refer to some fixed parameters other than the input of the operator in the previous layer, not the output of the operator in the previous layer. Therefore, there are cases where both the target operator and the original operator have no input parameters. When the operator classification information meets the above conditions, the original operator is replaced with the target operator, and the relationship between the operator and the target operator remains unchanged in the graph structure of the target model after the replacement. Here, the graph structure represents the connection between each operator in the model from the initial operator to the final operator. The unchanged relationship means that the connection between the target operator and the operators in the previous and next layers of the original operator remains unchanged.

[0091] In one embodiment, step S20, which involves replacing the original operator with the target operator under the target framework based on the operator classification information, further includes:

[0092] Step S22: When the operator classification information indicates that the original operator has a matching operator within the target frame, and the target operator and the original operator have input parameters, then the types of the input parameters of the target operator and the original operator are obtained respectively.

[0093] Step S23: When the input parameter of the target operator is a newly added parameter, the input parameter of the target operator is assigned an invalid value;

[0094] In this embodiment, the newly added parameter is a parameter that exists in the target operator but not in the original operator. To prevent memory leaks, the input parameter is assigned an invalid value. The input parameter can be marked to avoid directly obtaining the input parameter for calculation and outputting a random value, which would lead to memory leaks. Setting the input parameter to an invalid value has no effect on the parameter.

[0095] Step S24: When the input parameters of the original operator are untrained parameters, assign invalid values ​​to the input parameters of the original operator.

[0096] The untrained parameters are the null values ​​of the original operator that have not been trained. They cannot be directly assigned to the target operator. The corresponding parameter values ​​of the target operator need to be set to invalid values ​​to avoid memory leaks.

[0097] Step S25: Replace the original operator after the input parameter assignment is completed with the target operator after the input parameter assignment is completed.

[0098] After the parameter assignment and replacement are completed, similarly, referring to the above embodiment, the relationship of the operator in the target model graph structure remains unchanged.

[0099] In this embodiment, various exception handling methods are applied to the replaced operator parameters, including operator dimension matching, handling invalid newly added parameters of the target operator, and handling invalid original operator parameters, to prevent memory leaks caused by incorrect parameter assignment and abnormal results.

[0100] In one embodiment, step S20, which involves replacing the original operator with the target operator under the target framework based on the operator classification information, further includes:

[0101] Step A26: When the operator classification information indicates that there is no matching operator for the original operator within the target framework, but there is a replaceable operator, then one original operator corresponding to the target operator is replaced with the target operator or the target operator corresponding to the fusion operator of multiple original operators.

[0102] In this embodiment, operator matching means that the target operator and the original operator are the same. When there is no target operator matching the original operator within the target framework, but there is a replaceable operator corresponding to the original operator, the original operator in the original model is directly replaced with the target operator. If the replaced target operator needs to be...

[0103] If multiple consecutive primitive operators in the original framework are fused, the target operator is replaced with multiple primitive operators, and the parameters of the replaced operators are replaced or integrated accordingly.

[0104] In one embodiment, step S20, which involves replacing the original operator with the target operator under the target framework based on the operator classification information, further includes:

[0105] Step A27, where the operator classification information indicates that the original operator does not exist within the target frame.

[0106] If a matching operator is found, then the original operator is deleted;

[0107] If no matching operator exists, it means there is no replaceable operator either, so the original model is directly replaced.

[0108] The original operators in the code are deleted.

[0109] Step A28: Obtain the dimension information of the operators that are located before and after the original operator after deleting the original operator;

[0110] Step A29: When the dimension information is inconsistent, add a preset operator to make the dimension information of the operators before and after the original operator 5 consistent.

[0111] Since multiple operators are connected, after deleting an operator, it is necessary to connect the operators above and below that operator. If the inputs of the operators above and below that operator are not in the same dimension, a preset operator is added to make the dimensions consistent. The preset operator can be resize / reshape, which can be used to change the model dimensions.

[0112] Step S30: Infer the target model within the target framework and based on the mapping.

[0113] The relationship is used to verify the input and output dimensions of the original operator and the target operator, and the verification result is obtained.

[0114] In one embodiment, step S30 further includes:

[0115] Step S31: Infer the target model under the target framework to obtain the first input-output dimension of the target operator in the target model during the inference process;

[0116] 5. The target model is the model obtained after model transformation. Reasoning within the target framework allows us to obtain the first input-output dimensions of each target operator in the target model.

[0117] Step S32: Obtain the second input-output dimension of the original operator corresponding to the target operator according to the mapping relationship;

[0118] Since the target operator and the original operator are transformed in a one-to-one correspondence, there will be a mapping relationship between the target operator and the original operator if there is 0. After obtaining the first input-output dimension of the target operator, the second input-output dimension of the original operator corresponding to the target operator is obtained. It should be noted that the second input-output dimension is the input-output dimension of the original operator in the original model, and therefore can be obtained according to the operator information in the above embodiment.

[0119] Step S33: Compare and verify the first input / output dimension and the second input / output dimension to obtain the verification result.

[0120] The first input / output dimension and the second input / output dimension are compared to obtain a verification result, and the verification result includes cases where the first input / output dimension and the second input / output dimension are inconsistent and cases where the first input / output dimension and the second input / output dimension are consistent.

[0121] Step S40: Complete the inference of the target model based on the verification result.

[0122] 0 In one embodiment, step S40 further includes:

[0123] Step A41: When the verification result shows that the first input-output dimension and the second input-output dimension are inconsistent, the target operator dimension is determined to be abnormal, and the inference is exited.

[0124] Step A42: When the verification result shows that the first input-output dimension is consistent with the second input-output dimension, the reasoning continues until the calculation of the target model is completed.

[0125] 5. In this embodiment, after the model conversion is completed, a model verification step is added to enable the model to be validated within the target framework.

[0126] Inference is performed using the target model, and dimensionality is verified for each operator. If dimensional anomalies are found, the operator is reported as having a transformation anomaly and the inference process is terminated, thus avoiding the tedious process of locating abnormal results in inference.

[0127] This invention provides a model conversion method, a model conversion device, and a readable storage medium. By performing inference on the original model within the original framework and obtaining the operator classification information of each original operator in the original model within the target framework based on the target framework, it is possible to quickly gain an overview of the support of the original model within the target framework.

[0128] Furthermore, it facilitates targeted processing according to the category of each operator during the model conversion stage; by replacing the original operator with the target operator under the target framework based on the operator classification information, the target model is obtained, and the mapping relationship between the target operator and the original operator is recorded, thus enabling the conversion of the original framework into a target model.

[0129] The original model is converted into a target model under the target framework, completing the model conversion process. Reasoning is performed on the target model under the target framework, and the input and output dimensions of the original and target operators are verified according to the mapping relationship to obtain verification results. Reasoning of the target model is completed based on the verification results, enabling reasoning using the target model under the target framework. Dimension verification is performed on each operator; if a dimension anomaly exists, the operator conversion anomaly is reported and the reasoning process exits.

[0130] This approach avoids the tedious process of locating abnormal results in reasoning, thereby improving the conversion efficiency of 0 during model transformation.

[0131] Furthermore, embodiments of the present invention also propose a computer-readable storage medium storing a model conversion program, which, when executed by a processor, performs the following operations:

[0132] Reasoning is performed on the original model within the original framework, and operator classification information for each original operator in the original model under the target framework is obtained based on the target framework.

[0133] Based on the operator classification information, the original operator is replaced with the target operator under the target framework to obtain the target model, and the mapping relationship between the target operator and the original operator is recorded.

[0134] Reasoning is performed on the target model within the target framework, and the input and output dimensions of the original operator and the target operator are verified according to the mapping relationship to obtain the verification result;

[0135] The inference of the target model is completed based on the verification results.

[0136] Furthermore, when the position detection program is executed by the processor, it also performs the following operations:

[0137] The original model is inferred within the original framework, and the operator information of each original operator is recorded during the inference process;

[0138] The operator information is classified according to the operator support of the target framework to obtain the operator classification information of the original operator under the target framework.

[0139] Furthermore, when the position detection program is executed by the processor, it also performs the following operations:

[0140] If the operator classification information indicates that the original operator has a matching target operator within the target framework, and neither the target operator nor the original operator has any input parameters, then the original operator is replaced with the target operator.

[0141] Furthermore, when the position detection program is executed by the processor, it also performs the following operations:

[0142] When the operator classification information indicates that the original operator has a matching operator within the target frame, and both the target operator and the original operator have input parameters, then the types of the input parameters of the target operator and the original operator are obtained respectively.

[0143] When the input parameter of the target operator is a newly added parameter, the input parameter of the target operator is assigned an invalid value;

[0144] When the input parameters of the primitive operator are untrained parameters, the input parameters of the primitive operator are assigned invalid values;

[0145] The original operator after the input parameters have been assigned is replaced with the target operator after the input parameters have been assigned.

[0146] Furthermore, when the position detection program is executed by the processor, it also performs the following operations:

[0147] When the operator classification information indicates that there is no matching operator for the original operator within the target framework, but there is a replaceable operator, then one original operator corresponding to the target operator will be replaced with the target operator or the target operator corresponding to the fusion operator of multiple original operators.

[0148] Furthermore, when the position detection program is executed by the processor, it also performs the following operations:

[0149] If the operator classification information indicates that there is no matching operator for the original operator within the target frame, then the original operator is deleted.

[0150] Obtain the dimension information of the operators that are positioned before and after the original operator after deletion;

[0151] When the dimensional information is inconsistent, a preset operator is added to make the dimensional information of the operators before and after the original operator consistent.

[0152] Furthermore, when the position detection program is executed by the processor, it also performs the following operations:

[0153] Reasoning is performed on the target model within the target framework to obtain the first input-output dimension of the target operator in the target model during the reasoning process.

[0154] The second input-output dimension of the original operator corresponding to the target operator is obtained based on the mapping relationship;

[0155] The first input / output dimension and the second input / output dimension are compared and verified to obtain the verification result.

[0156] Furthermore, when the position detection program is executed by the processor, it also performs the following operations:

[0157] If the verification result shows that the first input / output dimension is inconsistent with the second input / output dimension, then the target operator dimension is determined to be abnormal, and the inference is terminated.

[0158] If the verification result shows that the first input / output dimension is consistent with the second input / output dimension, then the reasoning continues until the calculation of the target model is completed.

[0159] The present invention also proposes a computer-readable storage medium having a computer program stored thereon. The computer-readable storage medium may be... Figure 1 The memory 02 in the mass spectrometer can also be at least one of ROM (Read-Only Memory) / RAM (Random Access Memory), magnetic disk, optical disk, etc. The computer-readable storage medium includes several information to enable the mass spectrometer to perform the methods described in the various embodiments of the present invention.

[0160] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0161] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0162] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0163] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.

Claims

1. A model conversion method, characterized in that, The model conversion method includes the following steps: The original model is inferred within the original framework, and the operator classification information of each original operator in the original model under the target framework is obtained according to the target framework. The input data of the model is an image, and the input dimensions are the length, width and number of channels of the image. Based on the operator classification information, the original operator is replaced with the target operator under the target framework to obtain the target model, and the mapping relationship between the target operator and the original operator is recorded. Reasoning is performed on the target model within the target framework, and the input and output dimensions of the original operator and the target operator are verified according to the mapping relationship to obtain the verification result; If the verification result shows that the first input-output dimension and the second input-output dimension are inconsistent, then the target operator dimension is determined to be abnormal, and the inference is terminated. If the verification result shows that the first input-output dimension is consistent with the second input-output dimension, then the reasoning continues until the calculation of the target model is completed; The step of replacing the original operator with the target operator under the target framework based on the operator classification information includes: When the operator classification information indicates that the original operator has a matching target operator within the target frame, and neither the target operator nor the original operator has any input parameters, then the original operator is replaced with the target operator. When the operator classification information indicates that the original operator has a matching target operator within the target framework, and both the target operator and the original operator have input parameters, then the types of the input parameters of the target operator and the original operator are obtained respectively; when the input parameter of the target operator is a newly added parameter, the input parameter of the target operator is assigned an invalid value; when the input parameter of the original operator is an untrained parameter, the input parameter of the original operator is assigned an invalid value; the original operator after the input parameter assignment is completed is replaced with the target operator after the input parameter assignment is completed. When the operator classification information indicates that there is no matching target operator for the original operator within the target framework, but there is a replaceable operator, then one original operator corresponding to the target operator will be replaced with the target operator or the target operator corresponding to the fusion operator of multiple original operators. If the operator classification information indicates that there is no matching target operator for the original operator within the target frame, then the original operator is deleted; the dimension information of the operators before and after the original operator is obtained after deletion; if the dimension information is inconsistent, a preset operator is added to make the dimension information of the operators before and after the original operator consistent.

2. The model conversion method as described in claim 1, characterized in that, The steps of reasoning about the original model within the original framework and obtaining the operator classification information of each original operator in the original model within the target framework according to the target framework include: The original model is inferred within the original framework, and the operator information of each original operator is recorded during the inference process; The operator information is classified according to the operator support of the target framework to obtain the operator classification information of the original operator under the target framework.

3. The model conversion method as described in claim 1, characterized in that, The steps of reasoning about the target model within the target framework and verifying the input-output dimensions of the original operator and the target operator according to the mapping relationship to obtain the verification result include: Reasoning is performed on the target model within the target framework to obtain the first input-output dimension of the target operator in the target model during the reasoning process. The second input-output dimension of the original operator corresponding to the target operator is obtained based on the mapping relationship; The first input / output dimension and the second input / output dimension are compared and verified to obtain the verification result.

4. A model conversion device, characterized in that, The model conversion apparatus includes: a memory, a processor, and a model conversion program stored in the memory and executable on the processor, wherein the model conversion program, when executed by the processor, implements the steps of the model conversion method as described in any one of claims 1 to 3.

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