A cloud-based deep learning model conversion method, system, device and medium
Through the cloud-based deep learning model conversion method, the intermediate model format ONNX is used to perform cross-frame and cross-platform model conversion, solving the problems of complex and high cost in the existing technology, and achieving efficient model conversion and production efficiency improvement.
Patent Information
- Application Number
- CN202111275766.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2041-10-29
AI Technical Summary
In the prior art, the process of transitioning deep learning models from training frameworks to inference frameworks is complicated, resulting in low development efficiency and high cost, and poor universality between various inference frameworks, making it difficult to achieve cross-frame and cross-platform model conversion.
It provides a cloud-based deep learning model conversion method. By obtaining the model to be converted and the model conversion request information, obtaining the training and inference query ID, loading matching machine instances, analyzing and traversing the model network structure, converting it to the intermediate model format ONNX, and performing input and output preprocessing, and finally converting it into the model format of the target inference framework.
This method blocks the details of the conversion of different training frameworks to many inference frameworks, saves learning costs, development costs, environmental installation and deployment costs, and hardware preparation and debugging costs, improves production efficiency, and shortens the iteration cycle of model optimization.
Smart Images

Figure CN113780536B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of deep learning models, and in particular relates to a cloud-based deep learning model conversion method, system, device and medium. Background Art
[0002] Artificial Intelligence (AI) model development in the field of deep learning is generally divided into two separate stages, including:
[0003] (1) Use mainstream deep learning training frameworks such as PyTorch, TensorFlow, and MXNet to train models that meet business needs, which is called a training model;
[0004] (2) Deep learning training frameworks are generally not suitable for direct deployment into product / production environments. The training model needs to be converted into a model that can be used on an inference framework, which is called an inference model.
[0005] Based on the above existing mainstream development processes, there are still some pain points in the industry, including:
[0006] Applications are generally divided into front-end and back-end / server cloud. They have different hardware resources and often use different reasoning frameworks. In order to reasonably allocate computing, some AI models will be deployed and executed on the front-end / edge device, and some AI models will be deployed and executed on the back-end / server cloud. In the current traditional practice, algorithm engineers need to perform model conversion for different reasoning frameworks and hardware devices, resulting in low development efficiency, heavy burden on algorithm engineers, and affecting project progress. In addition, the versatility between various reasoning frameworks is poor and the cost of use is high. For example, each reasoning framework will launch a dedicated model conversion tool to support conversion from different training framework models to its own reasoning framework model, but will not support conversion to other reasoning frameworks; the model conversion tools dedicated to each reasoning framework will also have large differences in usage and principles, and even some of the usage experience between them is not yet meaningful for reference. The personnel who perform model conversion work need to learn the model conversion methods of different reasoning frameworks, and be familiar with the usage, principles, and common usage techniques of the model conversion tools dedicated to each reasoning framework. They need to learn and accumulate experience separately. The execution of model conversion work also requires the installation of the environment, the compilation of the reasoning framework and the code of the conversion tool into an executable program, which involves a lot of details, potential bugs or problems caused by environmental incompatibility, etc. Some training frameworks or reasoning frameworks have launched cloud model conversion services to eliminate the installation process, but they only support conversion to their own reasoning framework models (https: / / ai.baidu.com / easyedge / home, https: / / www.mnn.zone / #download-mnn-workstation, http: / / www.openailab.com / int / ability / list3.html, all of which highlight support for different systems and heterogeneous computing platforms, but the actual back-end deep learning reasoning engines are all their own and do not support other products).
[0007] In addition, in practical applications, it is usually necessary to preprocess the model input and postprocess the model output, while the calculation graph saved by the training model does not include the calculation steps of input preprocessing and output postprocessing (for interpretation, input preprocessing is generally placed in the training data loading module for processing; output postprocessing is generally not involved in training, so the training model is not saved); however, the inference model needs to include complete model input preprocessing and model output postprocessing calculation steps. Manually adding relevant calculation steps by developers will result in time-consuming and labor-intensive, and prone to errors. Summary of the invention
[0008] The purpose of the present invention is to provide a cloud-based deep learning model conversion method, system, device and medium to solve one or more of the above-mentioned technical problems. The method provided by the present invention shields users from the details of converting different training frameworks to multiple reasoning frameworks, which can save learning costs, development costs, environment installation and deployment costs, hardware preparation / debugging costs, etc., and can improve production efficiency.
[0009] In order to achieve the above object, the present invention adopts the following technical solutions:
[0010] The first aspect of the present invention provides a cross-framework, cross-platform cloud deep learning model conversion method, comprising the following steps:
[0011] Obtain the model to be converted and model conversion request information;
[0012] Acquire a training query ID based on the model conversion request information; query and obtain a matching training machine instance from a preset training machine instance library based on the training query ID; use the matching training machine instance obtained by query to load the model to be converted, parse and traverse the network structure of the model to be converted, and obtain an intermediate model;
[0013] Based on the model conversion request information, an inference query ID is obtained; based on the inference query ID, a matching inference machine instance is queried from a preset inference machine instance library; the intermediate model is loaded using the matching inference machine instance, the network structure of the intermediate model is parsed and traversed, and each layer thereof is converted into a model format used by an inference framework of the matching inference machine instance to obtain a converted model.
[0014] A further improvement of the method of the present invention is that the model conversion request information includes: hardware equipment, operating system, training framework and reasoning framework for model operation.
[0015] A further improvement of the method of the present invention is that the preset training machine instance library includes a plurality of preset training machine instances and a plurality of reasoning machine instances;
[0016] Among them, the training machine instance is a server or PC end on which an operating system and a training framework are installed; the inference machine instance is a server or PC end on which an operating system and an inference framework are installed; each training machine instance records a training query ID, and each inference machine instance records a inference query ID.
[0017] A further improvement of the method of the present invention is that the training query ID is named as a combination of the operating system name, CPU name, GPU name and training framework name; the reasoning query ID is named as a combination of the operating system name, CPU name, GPU name and reasoning framework name.
[0018] A further improvement of the method of the present invention is that the preset training machine instance library is provided with an API for calling a model conversion function;
[0019] The API is defined as a Python function interface as the path of the model conversion request information to be passed in.
[0020] A further improvement of the method of the present invention is that the steps of loading the model to be converted by using the matching training machine instance obtained by querying, parsing and traversing the network structure of the model to be converted, and obtaining the intermediate model specifically include:
[0021] The model to be converted is loaded using the matching training machine instance obtained by the query, the network structure of the model to be converted is parsed and traversed, each layer thereof is converted into a format defined by the specification of the model intermediate representation format ONNX, all converted layers are collected, and saved as an ONNX model as an initial intermediate model;
[0022] The initial intermediate model is subjected to input and output preprocessing based on the model conversion request information to obtain a processed intermediate model.
[0023] A further improvement of the method of the present invention is that the step of using a matching inference machine instance to load the intermediate model, parsing and traversing the network structure of the intermediate model, and converting each layer thereof into a model format used by the inference framework of the matching inference machine instance, and obtaining the converted model specifically includes:
[0024] The processed intermediate model is loaded by a matching inference machine instance, the network structure of the processed intermediate model is parsed and traversed, each layer thereof is converted into a model format used by an inference framework of the matching inference machine instance, all converted layers are collected and saved into a model format used by an inference framework of the matching inference machine instance, and a converted inference model is obtained.
[0025] The second aspect of the present invention provides a cross-framework, cross-platform cloud-based deep learning model conversion system, comprising:
[0026] A model and information acquisition module, used to obtain the model to be converted and model conversion request information;
[0027] An intermediate model acquisition module is used to obtain a training query ID based on the model conversion request information; query and obtain a matching training machine instance from a preset training machine instance library based on the training query ID; use the matching training machine instance obtained by query to load the model to be converted, parse and traverse the network structure of the model to be converted, and obtain an intermediate model;
[0028] A conversion model acquisition module is used to obtain an inference query ID based on the model conversion request information; based on the inference query ID, query and obtain a matching inference machine instance from a preset inference machine instance library; use the matching inference machine instance to load the intermediate model, parse and traverse the network structure of the intermediate model, convert each layer thereof into a model format used by the inference framework of the matching inference machine instance, and obtain a converted model.
[0029] An electronic device provided in the third aspect of the present invention comprises: a processor; a memory for storing computer program instructions; and is characterized in that when the computer program instructions are loaded and run by the processor, the processor executes any one of the above-mentioned cross-framework, cross-platform cloud-based deep learning model conversion methods of the present invention.
[0030] A fourth aspect of the present invention provides a readable storage medium, which stores computer program instructions, and is characterized in that when the computer program instructions are loaded and executed by a processor, the processor executes any of the above-mentioned cross-framework, cross-platform cloud-based deep learning model conversion methods of the present invention.
[0031] Compared with the prior art, the present invention has the following beneficial effects:
[0032] The method provided by the present invention shields users from the details of converting different training frameworks to numerous inference frameworks, saving learning costs, development costs, environment installation and deployment costs, and hardware preparation / debugging costs. It can greatly improve the production efficiency of users (generally algorithm model developers), shorten the cycle of continuous optimization and iteration of algorithm models, and is conducive to product upgrades and optimizations.
[0033] The ID format design in the method of the present invention can conveniently and quickly find a machine instance with corresponding functions to execute services according to user needs.
[0034] In the present invention, an intermediate model is used for conversion. According to the functional requirements defined by the user request information, the input pre-processing and output post-processing of the model can be automatically translated and converted into operators in the intermediate model format, and added and merged into the calculation graph of the intermediate model, and then saved as a new intermediate model for conversion, which can reduce work intensity and improve accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art; obviously, the drawings described below are some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0036] Figure 1 It is a flowchart of a cross-framework, cross-platform cloud-based deep learning model conversion method according to Embodiment 1 of the present invention;
[0037] Figure 2 It is a simplified schematic diagram of a cross-framework, cross-platform universal cloud-based deep learning model conversion service architecture in specific embodiment 2 of the present invention;
[0038] Figure 3 It is an example schematic diagram of a cross-framework, cross-platform universal cloud-based deep learning model conversion service architecture in specific embodiment 2 of the present invention;
[0039] Figure 4 It is a schematic diagram of a cross-framework, cross-platform cloud-based deep learning model conversion system according to Example 3 of the present invention. DETAILED DESCRIPTION
[0040] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0041] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0042] The present invention is further described in detail below in conjunction with the accompanying drawings:
[0043] Example 1
[0044] See also Figure 1 , a cross-framework, cross-platform cloud-based deep learning model conversion method according to Embodiment 1 of the present invention comprises the following steps:
[0045] Obtain the model to be converted and model conversion request information;
[0046] Acquire a training query ID based on the model conversion request information; query and obtain a matching training machine instance from a preset training machine instance library based on the training query ID; use the matching training machine instance obtained by query to load the model to be converted, parse and traverse the network structure of the model to be converted, and obtain an intermediate model;
[0047] Based on the model conversion request information, an inference query ID is obtained; based on the inference query ID, a matching inference machine instance is queried from a preset inference machine instance library; the intermediate model is loaded using the matching inference machine instance, the network structure of the intermediate model is parsed and traversed, and each layer thereof is converted into a model format used by an inference framework of the matching inference machine instance to obtain a converted model.
[0048] The method provided by the above embodiment of the present invention shields users from the details of converting different training frameworks to numerous inference frameworks, saving learning costs, development costs, environment installation and deployment costs, and hardware preparation / debugging costs. It can greatly improve the production efficiency of users (generally algorithm model developers), shorten the cycle of continuous optimization and iteration of algorithm models, and is conducive to product upgrades and optimizations.
[0049] The principles of the technical solution provided by the above-mentioned embodiment of the present invention include: the conversion service framework installs all training frameworks, reasoning frameworks, model conversion tools of various manufacturers, execution environments, and hardware equipment resources in the cloud (the following descriptions all take place in the cloud), and the user-specified training model will be uploaded to the cloud, and then automatically judge and select the appropriate target environment and hardware equipment, automatically generate a model conversion command that meets the target model conversion tool, and call the target model conversion tool to perform the actual model conversion operation, and wait for the result to be returned; during the waiting period, the progress and feedback information of the model conversion are sent to the user front end in real time; after the actual model conversion is completed, the obtained reasoning framework model file is collected and sent to the user front end, prompting that the model conversion is successful, and a service is completed.
[0050] Example 2
[0051] See also Figure 2 and 3Based on the above-mentioned embodiment 1, the embodiment 2 of the present invention provides a cross-framework, cross-platform general cloud-based deep learning model conversion service architecture. The service architecture is designed to provide a general model conversion service with a unified user interface for algorithm personnel / engineering developers on the cloud / server side. Users do not need to install any programs related to the reasoning framework. They can convert models of different deep learning training frameworks (exemplarily, PyTorch, TensorFlow, MXNet) to models of various reasoning frameworks (exemplarily, TensorRT, OpenVINO, ncnn, MNN, TVM, Tengine-lite) through a web browser or Python API. Accordingly, users only need to simply learn how to use the conversion service framework to perform model conversion work at will, which can reduce workload and difficulty and save labor costs.
[0052] The implementation steps of a cross-framework, cross-platform universal cloud-based deep learning model conversion service architecture of Embodiment 2 of the present invention specifically include the following steps:
[0053] 1. Obtain the model to be converted and model conversion request information; the model conversion request information includes the hardware device, operating system, training framework and reasoning framework for model operation; preferably, it may also include the storage path, etc.;
[0054] 2. Obtain a training query ID based on the model conversion request information; illustratively, the training query ID format is defined as follows: operating system name + CPU name + GPU name + training framework name; based on the training query ID, query and obtain a matching training machine instance from a preset training machine instance library; use the matching training machine instance obtained by the query to load the model to be converted, parse and traverse the network structure of the model to be converted (i.e., the calculation graph and obtain weight parameters), convert each layer thereof to the format defined by the specification of the model intermediate representation format ONNX, collect all converted layers, and save them as an ONNX model as an intermediate model; perform input and output preprocessing on the intermediate model based on the model conversion request information to obtain a processed intermediate model;
[0055] 3. Obtain an inference query ID based on the model conversion request information; exemplarily, the inference query ID format is defined as follows: operating system name + CPU name + GPU name + inference framework name; based on the inference query ID, query and obtain a matching inference machine instance from a preset inference machine instance library; use the matching inference machine instance to load the processed intermediate model, parse and traverse the network structure of the processed intermediate model (i.e., the calculation graph and obtain weight parameters), convert each layer thereof to the model format used by the inference framework, collect all converted layers, and save them in the model format used by the inference framework as the inference model obtained after the conversion is completed.
[0056] Based on the technical solution provided in the above-mentioned embodiment 2 of the present invention, it can be known that the core innovations of the present invention include: there are many combinations of machine instances and frameworks (training + reasoning), and the design of the ID format of the present invention can easily and quickly find the machine instance of the corresponding function to perform the service according to the needs of the user; in addition, the intermediate model is used for conversion, and according to the functional requirements defined in the user configuration file, the input pre-processing and output post-processing of the model are automatically translated and converted into operators in the intermediate model format, and added and merged into the calculation graph of the intermediate model, and then saved as a new intermediate model for conversion. Exemplarily, the intermediate model is loaded to build a calculation graph, and the operator in the converted intermediate model format corresponding to the "input pre-processing" is added to the input of the calculation graph; the operator in the converted intermediate model format corresponding to the "output post-processing" is added to the output of the calculation graph to obtain a new calculation graph.
[0057] In the embodiment of the present invention, as a further improvement and optimization, the steps of obtaining the preset training and reasoning machine instance library include:
[0058] (1) Prepare the hardware equipment commonly used in the product production environment, including: server side, PC side, and install the operating system.
[0059] For example, the server side may include: hardware including server-type Intel CPU, NVIDIA server-type GPU, and operating system Ubuntu Linux; the PC side may include: hardware including consumer-grade Intel CPU, AMD CPU, AMD GPU, NVIDIA consumer-grade GPU, and operating system Windows; each of the above installed devices is called a machine instance.
[0060] (2) Take some machine instances of step (1) and install the following training frameworks: PyTorch, TensorFlow, MXNet, which are referred to as training machine instances; take some machine instances of step (1) and install the following inference frameworks: TensorRT, OpenVINO, ncnn, MNN, TVM, Tengine-lite, which are referred to as inference machine instances.
[0061] (3) Server: Record the ID of the training machine instance. The ID format is defined as follows: operating system name + CPU name + GPU name + training framework name; for example, the ID is Ubuntu + Intel_core_i7 + TitanXp + PyTorch. Record the ID of the inference machine instance. The ID format is defined as follows: operating system name + CPU name + GPU name + inference framework name; for example, the ID is Ubuntu + Intel_core_i7 + TitanXp + TensorRT.
[0062] (4) Provide users with a unified API for calling the model conversion function. The API is defined as a Python function interface as follows: xengine_converter.convert(yaml_config_file_path); where the parameter yaml_config_file_path is the path of the interface configuration file that the user wants to pass in.
[0063] Exemplarily, the API uses a configuration file, and the user needs to fill in the configuration file: the hardware device (device) on which the model runs, the operating system (platform), the training framework (source_framework), the inference framework (destination_framework), the training model file path (input_network), the output result save path (output_dir), the output inference model file name (output_model_name), the definition of the input tensor (input.name, shape, dtype) and the input preprocessing parameters (mean_values, scale_values), the definition of the output tensor (output.name) and the optional output post-processing steps (output.postprocess); explanatory, the configuration file content here is the model conversion request information.
[0064] Optionally, you can enter multiple input and output items, indicating multiple input tensors and multiple output tensors, respectively. The above configuration file is a structured data definition, which is convenient for users to make clear definitions and specifications for the relevant details of model conversion.
[0065] Exemplarily, the client: (user) creates the interface configuration file defined in step (4), fills in the information related to the conversion model, and saves the file to the path FILE_PATH_A. (User) calls the Python API defined in step (4), and the parameter is the configuration file path FILE_PATH_A. Read the configuration file content, obtain the file path of the training model, and use TCP to connect the network transmission to send it to the server; read the configuration file content, and use TCP to connect the network transmission to send the content to the server.
[0066] Exemplarily, when defining the intermediate representation format of a model, there can be multiple representation formats; one of them is the open deep neural network model exchange representation format ONNX, which is a standard for representing deep learning models and enables models to be transferred between different frameworks. ONNX is an open file format. The ONNX specification and code are mainly jointly developed by companies such as Microsoft, Amazon, Facebook and IBM, and are hosted on Github in an open source manner.
[0067] In the embodiment of the present invention, input and output preprocessing, processing the saved ONNX intermediate model, includes:
[0068] 1) Set the name of the input tensor to input.name;
[0069] 2) Set the dimension (shape) of the input tensor to input.shape;
[0070] 3) Set the data type of the input tensor to input.dtype;
[0071] 4) Add a subtraction calculation layer to the input tensor input, and the calculation is: input-mean_values;
[0072] 5) Add a division calculation layer to the calculated result tensor, and the calculation is: (input-mean_values) / scale_values;
[0073] 6) Set the name of the output tensor to output.name;
[0074] 7) If the output post-processing step output.postprocess is not filled in, it is ignored;
[0075] 8) If the output postprocessing step output.postprocess has a relevant option set, the option is a predefined process. The only option is: norm; the postprocessing step norm operation is to perform normalization on the output tensor output. Specifically, a series of layers are appended to the output tensor output: multiplication Mul, sum ReduceSum, square root Sqrt, division Div, calculated as: Div(output, Sqrt(ReduceSum(Mul(output, output)))).
[0076] After adding the above processing steps, save the processed model as a new ONNX intermediate model.
[0077] In the technical solution provided by the embodiment of the present invention, the configuration file defines the minimum necessary information for the user to convert the model, and defines the input pre-processing and output post-processing of the model; the configuration file: has a concise format, is simple and easy to understand, and shields all frameworks (training / inference), machine hardware details and domain-related information. The user only needs to define the input and output, the source and target (framework, file, path) of the model conversion to complete the conversion.
[0078] To summarize, based on the technical solutions disclosed in the above embodiments of the present invention, the present invention provides users with a unified and concise interface to perform model conversion functions; the model conversion service architecture shields users from the details of converting different training frameworks to numerous inference frameworks, saving learning costs, development costs, environment installation and deployment costs, and hardware preparation / debugging costs, thereby greatly improving the production efficiency of users (generally algorithm model developers), shortening the cycle of continuous optimization and iteration of algorithm models, and facilitating product upgrades and optimizations.
[0079] Example 3
[0080] See also Figure 4 The following is an embodiment of the device of the present invention, which can be used to perform the method embodiment of the present invention. For details not disclosed in the device embodiment, please refer to the method embodiment of the present invention.
[0081] A cross-framework, cross-platform cloud-based deep learning model conversion system according to an embodiment of the present invention includes:
[0082] A model and information acquisition module, used to obtain the model to be converted and model conversion request information;
[0083] An intermediate model acquisition module is used to obtain a training query ID based on the model conversion request information; query and obtain a matching training machine instance from a preset training machine instance library based on the training query ID; use the matching training machine instance obtained by query to load the model to be converted, parse and traverse the network structure of the model to be converted, and obtain an intermediate model;
[0084] A conversion model acquisition module is used to obtain an inference query ID based on the model conversion request information; based on the inference query ID, query and obtain a matching inference machine instance from a preset inference machine instance library; use the matching inference machine instance to load the intermediate model, parse and traverse the network structure of the intermediate model, convert each layer thereof into a model format used by the inference framework of the matching inference machine instance, and obtain a converted model.
[0085] Example 4
[0086] In Embodiment 4 of the present invention, a computer device is provided, which includes a processor and a memory, the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, which is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions in a computer storage medium to implement the corresponding method flow or corresponding function; the processor described in the embodiment of the present invention can be used for the operation of a cross-framework, cross-platform cloud-based deep learning model conversion method.
[0087] Example 5
[0088] In Embodiment 5 of the present invention, a storage medium is provided, specifically a computer-readable storage medium (Memory), and the computer-readable storage medium is a memory device in a computer device for storing programs and data. It is understandable that the computer-readable storage medium here may include both a built-in storage medium in a computer device and, of course, an extended storage medium supported by the computer device. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by a processor are also stored in the storage space, and these instructions may be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here may be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The processor may load and execute one or more instructions stored in the computer-readable storage medium to implement the corresponding steps of the cross-framework, cross-platform cloud-based deep learning model conversion method in the above-mentioned embodiment.
[0089] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0090] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0091] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0092] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A cloud-based deep learning model conversion method, characterized in that: The following steps are involved: Obtain the model to be converted and model conversion request information; Acquire a training query ID based on the model conversion request information; Based on the training query ID, query and obtain matching training machine instances from a preset training machine instance library; Using the matching training machine instance obtained by querying to load the model to be converted, parsing and traversing the network structure of the model to be converted, and obtaining an intermediate model; Obtaining an inference query ID based on the model conversion request information; querying and obtaining a matching inference machine instance from a preset inference machine instance library based on the inference query ID; using the matching inference machine instance to load the intermediate model, parsing and traversing the network structure of the intermediate model, converting each layer thereof into a model format used by an inference framework of the matching inference machine instance, and obtaining a converted model; The model conversion request information includes: the hardware device, operating system, training framework and inference framework on which the model runs; The preset training machine instance library includes a plurality of preset training machine instances and a plurality of inference machine instances; wherein the training machine instance is a server or PC end on which an operating system and a training framework are installed; the inference machine instance is a server or PC end on which an operating system and an inference framework are installed; each training machine instance records a training query ID, and each inference machine instance records an inference query ID; The training query ID is named as a combination of the operating system name, CPU name, GPU name and training framework name; the reasoning query ID is named as a combination of the operating system name, CPU name, GPU name and reasoning framework name; The method of using the matching training machine instance obtained by query to load the model to be converted, parsing and traversing the network structure of the model to be converted, and obtaining the intermediate model includes: using the matching training machine instance obtained by query to load the model to be converted, parsing and traversing the network structure of the model to be converted, converting each layer thereof into a format defined by the specification of the model intermediate representation format ONNX, collecting all converted layers, and saving them as ONNX models as the initial intermediate model; performing input and output preprocessing on the initial intermediate model based on the model conversion request information to obtain the processed intermediate model.
2. A cloud-based deep learning model conversion method according to claim 1, characterized in that: The preset training machine instance library is provided with an API for calling a model conversion function; The API is defined as a Python function interface as the path of the model conversion request information to be passed in.
3. The cloud-based deep learning model conversion method according to claim 1, characterized in that: The method of using a matching inference machine instance to load the intermediate model, parsing and traversing the network structure of the intermediate model, converting each layer thereof into a model format used by the inference framework of the matching inference machine instance, and obtaining the converted model comprises: The processed intermediate model is loaded by a matching inference machine instance, the network structure of the processed intermediate model is parsed and traversed, each layer thereof is converted into a model format used by an inference framework of the matching inference machine instance, all converted layers are collected and saved into a model format used by an inference framework of the matching inference machine instance, and a converted inference model is obtained.
4. A cloud-based deep learning model conversion system, characterized in that: include: A model and information acquisition module, used to obtain the model to be converted and model conversion request information; An intermediate model acquisition module, used to acquire a training query ID based on the model conversion request information; Based on the training query ID, query and obtain a matching training machine instance from a preset training machine instance library; use the matching training machine instance obtained by query to load the model to be converted, parse and traverse the network structure of the model to be converted, and obtain an intermediate model; A conversion model acquisition module is used to obtain an inference query ID based on the model conversion request information; query and obtain a matching inference machine instance from a preset inference machine instance library based on the inference query ID; use the matching inference machine instance to load the intermediate model, parse and traverse the network structure of the intermediate model, convert each layer thereof into a model format used by the inference framework of the matching inference machine instance, and obtain a converted model; The model conversion request information includes: the hardware device, operating system, training framework and inference framework on which the model runs; The preset training machine instance library includes a plurality of preset training machine instances and a plurality of inference machine instances; wherein the training machine instance is a server or PC end on which an operating system and a training framework are installed; the inference machine instance is a server or PC end on which an operating system and an inference framework are installed; each training machine instance records a training query ID, and each inference machine instance records an inference query ID; The training query ID is named as a combination of the operating system name, CPU name, GPU name and training framework name; the reasoning query ID is named as a combination of the operating system name, CPU name, GPU name and reasoning framework name; The method of using the matching training machine instance obtained by query to load the model to be converted, parsing and traversing the network structure of the model to be converted, and obtaining the intermediate model includes: using the matching training machine instance obtained by query to load the model to be converted, parsing and traversing the network structure of the model to be converted, converting each layer thereof into a format defined by the specification of the model intermediate representation format ONNX, collecting all converted layers, and saving them as ONNX models as the initial intermediate model; performing input and output preprocessing on the initial intermediate model based on the model conversion request information to obtain the processed intermediate model.
5. An electronic device comprising: processor; A memory for storing computer program instructions; characterized in that: When the computer program instructions are loaded and executed by the processor, the processor executes the cloud-based deep learning model conversion method according to any one of claims 1 to 3.
6. A readable storage medium storing computer program instructions, characterized in that: When the computer program instructions are loaded and executed by the processor, the processor executes the cloud-based deep learning model conversion method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Deep learning model file conversion method and system, computer equipment and computer readable storage medium
CN111275199A
Apparatus and method for converting deep learning model for target device
KR102298766B1