Model optimization method and device, equipment, storage medium and program product

Through automatic identification and matching optimization strategies, the problem of low efficiency of accelerated optimization of multi-frame model inference is solved, an efficient and flexible optimization process is achieved, and the model execution efficiency and accuracy is improved.

CN119150941AActive Publication Date: 2024-12-17BEIJING QINGCHENG JIZHI TECHNOLOGY CO LTD
View PDF 12 Cites 0 Cited by

Patent Information

Application Number
CN202411137679.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2024-12-17
Estimated Expiration
2044-08-19

AI Technical Summary

Technical Problem

The existing artificial intelligence model framework is inefficient and lacks flexibility in the inference acceleration optimization of multi-frame models, and requires manual adaptation of different optimization engines to each component, resulting in low optimization efficiency and high complexity.

Method used

By identifying the framework types and structure types of each component in the target model, using the preset optimization strategy mapping table to automatically match and execute optimization strategies, a fully automated optimization process is achieved, ensuring that each component applies the most appropriate optimization strategy.

Benefits of technology

It improves the efficiency and flexibility of model optimization, ensures the accuracy and targetedness of optimization strategies, enables multi-frame models to perform inference tasks more efficiently, and reduces the complexity and time cost of developers' manual operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119150941A_ABST
    Figure CN119150941A_ABST
Patent Text Reader

Abstract

The invention discloses a model optimization method and device, equipment, a storage medium and a program product, and relates to the technical field of artificial intelligence, and the disclosed model optimization method comprises the steps: recognizing a frame type and a structure type of each component in a to-be-optimized target model; according to a preset optimization strategy mapping table, a matched optimization strategy is called for each component, and the optimization strategies are stored in the optimization strategy mapping table in a mapping mode with the frame types and the structure types of the components; and respectively optimizing each component according to the optimization strategy so as to complete reasoning acceleration optimization of the target model. The effect of improving the efficiency and flexibility of model optimization can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to model optimization methods, devices, equipment, storage media and program products. Background Art

[0002] With the diversification of task requirements, the structure of artificial intelligence models has become more complex, involving multiple components working together to form a complex pipeline structure. These different components correspond to different categories of model structures.

[0003] Existing AI model frameworks, such as PyTorch, TensorFlow, and ONNX Runtime, use different file formats to describe the model structure and its operating logic. When multiple framework types are included in one model, the multi-framework model has advantages in model representation and execution. However, in terms of model reasoning acceleration optimization, different optimization engines need to be manually adapted for each component during model optimization, resulting in low optimization efficiency and lack of flexibility.

[0004] In summary, how to improve the efficiency and flexibility of model optimization has become a technical problem that needs to be urgently solved in this field. Summary of the invention

[0005] The main purpose of this application is to provide a model optimization method, device, equipment, storage medium and program product, aiming to improve the efficiency and flexibility of model optimization.

[0006] To achieve the above objectives, the present application proposes a model optimization method, which includes:

[0007] Identify the framework type and structure type of each component in the target model to be optimized;

[0008] According to a preset optimization strategy mapping table, a matching optimization strategy is respectively called for each of the components, wherein the optimization strategy is stored in the optimization strategy mapping table in a mapping manner with the framework type and the structure type of the component;

[0009] Each of the components is optimized separately according to the optimization strategy to complete the reasoning acceleration optimization of the target model.

[0010] In one embodiment, the step of identifying the framework type and structure type of each component in the target model to be optimized includes:

[0011] For a target component in each component of the target model to be optimized, a preset component framework classification identifier is used to perform framework identification on the target component to determine the framework type of the target component;

[0012] The target component is structurally identified by a preset model structure classification identifier to determine the structural type of the target component.

[0013] In one embodiment, before the step of performing structural recognition on the target component by a preset model structure classification identifier to determine the structural type of the target component, the step further includes:

[0014] When the target component has multiple framework types, the target component is structurally split according to different framework types to obtain various partial target components;

[0015] The step of performing structural identification on the target component by a preset model structure classification identifier to determine the structural type of the target component includes:

[0016] The structure of each of the partial target components is respectively identified by a preset model structure classification identifier to determine the structural type of each of the partial target components.

[0017] In one embodiment, before the step of respectively calling a matching optimization strategy for each of the components according to a preset optimization strategy mapping table, the method further includes:

[0018] Based on a preset user description component optimization rule interface, receiving an input optimization rule, wherein the optimization rule includes a correspondence between a framework type and a structure type and an optimization strategy;

[0019] An optimization strategy mapping table is created according to the optimization rules.

[0020] In one embodiment, the step of respectively calling a matching optimization strategy for each of the components according to a preset optimization strategy mapping table includes:

[0021] For a target component in each component of the target model to be optimized, according to the framework type and structure type of the target component and in accordance with a preset optimization strategy mapping table, an optimization strategy matching the target component is determined;

[0022] When there are multiple matching optimization strategies, a target optimization strategy is selected from the multiple matching optimization strategies according to the received optimization request conditions and the running time of the optimization strategies;

[0023] The target optimization strategy is invoked for the target component.

[0024] In one embodiment, after the step of optimizing each of the components according to the optimization strategy to complete the inference acceleration optimization of the target model, the process further includes:

[0025] Recording the overall optimization strategy for the inference acceleration optimization of the target model;

[0026] After receiving the optimization request for the target model, the target model is optimized according to the overall optimization strategy.

[0027] In addition, to achieve the above purpose, the present application also proposes a model optimization device, which includes:

[0028] An identification module, used to identify the framework type and structure type of each component in the target model to be optimized;

[0029] An optimization strategy matching module, used to call a matching optimization strategy for each of the components according to a preset optimization strategy mapping table, wherein the optimization strategy is stored in the optimization strategy mapping table in a mapping manner with the framework type and structure type of the component;

[0030] The optimization module is used to optimize each of the components according to the optimization strategy to complete the reasoning acceleration optimization of the target model.

[0031] In addition, to achieve the above objectives, the present application also proposes an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the model optimization method as described above.

[0032] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the model optimization method as described above are implemented.

[0033] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the model optimization method as described above are implemented.

[0034] The present application proposes a model optimization method, in which the various components in the target model to be optimized are first identified, and their framework types and structural types are determined. Then, a preset optimization strategy mapping table is used, which associates different framework types and structural types with specific optimization strategies. According to the optimization strategy mapping table, the corresponding optimization strategy is automatically applied to each component of the target model without human intervention, thereby achieving optimization of all components in the target model, completing reasoning acceleration optimization of the target model, and improving the execution efficiency of the model in practical applications.

[0035] Compared with traditional model optimization methods that require developers to manually select and adapt different optimization strategies for each component in a multi-framework model, this not only requires developers to have deep professional knowledge and rich experience, but also greatly increases the complexity and time cost of model optimization. In addition, manual optimization often fails to achieve global optimality, resulting in unsatisfactory optimization results.

[0036] In this application, by automatically identifying component frameworks and structural types, and automatically matching and executing optimization strategies according to preset optimization strategy mapping tables, a fully automated process from identification to optimization is achieved, which improves optimization efficiency and ensures the accuracy and pertinence of optimization strategies, thereby effectively solving the problems of low optimization efficiency and insufficient flexibility faced by multi-framework models in reasoning acceleration optimization, enabling multi-framework models to perform reasoning tasks more efficiently. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

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

[0039] Figure 1 A schematic diagram of a process flow provided for the first embodiment of the model optimization method of the present application;

[0040] Figure 2 A schematic diagram of a model optimization process provided in Example 2 of the model optimization method of this application;

[0041] Figure 3 A schematic diagram of the user description component optimization rule interface structure provided in Example 2 of the model optimization method of this application;

[0042] Figure 4 A schematic diagram of the model structure provided for the second embodiment of the model optimization method of the present application;

[0043] Figure 5 This is a schematic diagram of the module structure of the model optimization device of the embodiment of the present application;

[0044] Figure 6 Schematic diagram of the device structure of the hardware operating environment involved in the model optimization method in the embodiment of the present application.

[0045] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0046] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0047] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0048] The main solution of the embodiment of the present application is: identifying the framework type and structure type of each component in the target model to be optimized; calling a matching optimization strategy for each component according to a preset optimization strategy mapping table, wherein the optimization strategy is stored in the optimization strategy mapping table in a mapping with the framework type and structure type of the component; optimizing each component according to the optimization strategy to complete the reasoning acceleration optimization of the target model.

[0049] Since existing artificial intelligence model frameworks, such as PyTorch, TensorFlow, and ONNX Runtime, describe the model structure and its operating logic through different file formats, when multiple framework types are included in one model, the multi-framework model has advantages in model representation and execution. However, in terms of model reasoning acceleration optimization, different optimization engines need to be manually adapted for each component during model optimization, which results in low optimization efficiency and lack of flexibility.

[0050] The embodiment of the present application provides a solution by automatically identifying component frameworks and structural types, and automatically matching and executing optimization strategies according to a preset optimization strategy mapping table, thereby realizing a fully automated process from identification to optimization, improving optimization efficiency, and ensuring the accuracy and pertinence of optimization strategies, thereby effectively solving the problems of low optimization efficiency and insufficient flexibility faced by multi-framework models in reasoning acceleration optimization, and enabling multi-framework models to perform reasoning tasks more efficiently.

[0051] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, etc., or an electronic device capable of realizing the above functions, etc. The following takes the model optimization terminal as an example to illustrate this embodiment and the following embodiments.

[0052] Based on this, the present application embodiment provides a model optimization method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the model optimization method of the present application.

[0053] In this embodiment, the model optimization method includes steps S10 to S30:

[0054] Step S10, identifying the framework type and structure type of each component in the target model to be optimized;

[0055] It should be noted that the target model is a multi-framework model, that is, different parts of the model use a variety of different deep learning model frameworks such as PyTorch, ONNX Runtime and TensorFlow (three mainstream model frameworks).

[0056] For the target model to be optimized, identify the framework types used by each component in the target model, such as PyTorch, TensorFlow, ONNX Runtime, etc., as well as their respective structure types, such as ControlNet (a neural network structure for image segmentation tasks), U-Net (a convolutional neural network structure), etc. This step is the basis for the subsequent optimization strategy selection, ensuring that the most appropriate optimization strategy can be applied to different types of components.

[0057] Step S20, calling a matching optimization strategy for each of the components according to a preset optimization strategy mapping table, wherein the optimization strategy is stored in the optimization strategy mapping table in a mapping manner with the framework type and structure type of the component;

[0058] According to the pre-defined optimization strategy mapping table, a corresponding optimization strategy is assigned to each component in the target model. The optimization strategy mapping table records in detail the optimization strategies applicable to components of different framework types and structural types, ensuring that each component can obtain the best optimization solution.

[0059] It should be noted that in the optimization strategy mapping table, optimization strategies can be divided into two categories: native optimization strategies and customized optimization strategies. For components with relatively uniform model structure descriptions, they can be directly matched with native optimization strategies that are natively supported by this format. For example, for components of the ONNX framework, the TensorRT deep learning inference engine can be directly used for optimization; for components with relatively specialized model structures, customized optimization strategies can be directly matched, such as components that use the PyTorch framework or the Tensorflow framework. This contains framework-specific features and is not easy to port across frameworks or use general optimization strategies. It is necessary to use customized optimization strategies customized for a specific framework to fully utilize the advantages of the framework.

[0060] Step S30, optimizing each of the components separately according to the optimization strategy to complete the reasoning acceleration optimization of the target model.

[0061] After determining the optimization strategy for each component, optimization measures are implemented for each component one by one, such as operator fusion, precision optimization, memory management improvement, parallel processing, etc.

[0062] In this embodiment, compared with the traditional model optimization method that requires developers to manually select and adapt different optimization strategies for each component in the multi-frame model, this not only requires developers to have deep professional knowledge and rich experience, but also greatly increases the complexity and time cost of model optimization. In addition, manual optimization is often difficult to achieve global optimization, resulting in unsatisfactory optimization results.

[0063] In this application, by automatically identifying component frameworks and structural types, and automatically matching and executing optimization strategies according to preset optimization strategy mapping tables, a fully automated process from identification to optimization is achieved, which improves optimization efficiency and ensures the accuracy and pertinence of optimization strategies, thereby effectively solving the problems of low optimization efficiency and insufficient flexibility faced by multi-framework models in reasoning acceleration optimization, enabling multi-framework models to perform reasoning tasks more efficiently.

[0064] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. On this basis, step S10 can include steps S101 to S102:

[0065] Step S101, for a target component in each component of the target model to be optimized, framework identification is performed on the target component by a preset component framework classification identifier to determine the framework type of the target component;

[0066] The preset component framework classification identifier is used to perform framework identification on each target component in the target model. The component framework classification identifier determines the framework type to which the target component belongs by analyzing the code or model representation of the target component.

[0067] For example, if the target component is implemented using the PyTorch framework, the component framework classification identifier can identify it as the PyTorch framework by checking specific API calls or component structures.

[0068] Step S102: Performing structural recognition on the target component by using a preset model structure classification identifier to determine the structural type of the target component.

[0069] Use the preset model structure classification identifier to analyze the internal structure of the target component and identify its structural type based on the component's functions and operator characteristics.

[0070] In a feasible embodiment, step S103 may be further included before step S102:

[0071] Step S103, when the target component has multiple framework types, the target component is structurally split according to different framework types to obtain various partial target components;

[0072] When the target component contains multiple frame types, the target component is structurally split according to different frame types to obtain partial target components. This splitting process ensures that each part of the target component can be independently identified and optimized in the subsequent structure.

[0073] For example, if a component contains both PyTorch and TensorFlow frameworks, separate the component into two independent parts so that they can be processed separately.

[0074] On this basis, step S102 may include step S1021:

[0075] Step S1021: Perform structural identification on each of the partial target components respectively through a preset model structure classification identifier to determine the structural type of each of the partial target components.

[0076] For each partial target component obtained by splitting, the model structure classification identifier is used to perform structural recognition to ensure that the structural type of each partial target component can be accurately identified, so as to customize the most appropriate optimization strategy for each partial target component.

[0077] For example, if a partial target component after splitting is a convolutional neural network structure implemented by PyTorch, this structure is identified and a matching optimization strategy is selected for the partial target component.

[0078] Specifically, each component in the target component may be built based on different frameworks, such as PyTorch, TensorFlow, etc. These frameworks have different representation methods and performance characteristics. The component framework classification identifier is used to analyze and identify the framework type used by each component in the target model. If a component uses multiple frameworks, the component framework classification identifier will identify these different parts and split the parts of these different frameworks. Then, the model structure classification identifier will classify the components into more specific categories according to their specific structural characteristics, so as to select appropriate optimization strategies for each component in the target model according to the framework type and structure type.

[0079] In this way, this embodiment can accurately identify the framework and structure type of each component in the target model, providing an efficient, flexible and automated optimization solution for multi-frame models, which not only improves the accuracy of model optimization, but also significantly improves the optimization efficiency through automated identification and matching processes.

[0080] For example, in a feasible embodiment, as Figure 2As shown, given that the target model includes a variety of different components (component A, component B, component C, component D), the component framework classification identifier will obtain the main call structure that becomes the performance bottleneck of the component by decomposing the call, and identify the artificial intelligence model framework representation used by the structure. For the case where multiple framework representations appear in the component, such as ONNX, PyTorch, and Tensorflow frameworks, the component framework classification identifier will further optimize the parts of different frameworks / different structures in subsequent steps through structural split calls. Then, the model structure classification identifier will further refine and classify the component modules of the corresponding component framework that have passed the component framework classification identifier, so that some model-specific component compilation optimization methods, or even some cross-platform optimization methods, can be better applied.

[0081] Among them, the component framework classification identifier identifies different component framework representations through the calling object category judgment of the programming language, recursively obtains the category calls that appear in the calls, and classifies the identified optimizable component framework representations. In this classification process, multiple component framework representations that appear in the same component will be automatically decomposed and enter the next stage of optimization; the model structure classification identifier distinguishes different model structures based on the operator features in the model graph representation and the existing main model structure naming.

[0082] Finally, different optimization methods can be applied according to the component structure type and framework type in the target model: for components with relatively uniform model structure description (such as components using the ONNX framework), some native optimization strategies (such as TensorRT), that is, the device native optimization method in the figure, can be used; for components with relatively specialized model structures (such as components using PyTorch or Tensorflow), customized optimization strategies (such as stable fast), that is, the cross-platform component customized tuning method in the figure, can be used to call the tuning execution engine according to the selected optimization strategy to achieve cross-platform component optimization of the target model.

[0083] In a feasible embodiment, before step S20, steps S40 to S50 may also be included:

[0084] Step S40, receiving an input optimization rule based on a preset user description component optimization rule interface, wherein the optimization rule includes a correspondence between a framework type and a structure type and an optimization strategy;

[0085] Based on the preset user description component optimization rule interface, this interface allows users to input specific optimization rules. The input optimization rules are a set of clear instructions that define the correspondence between different framework types and structure types and optimization strategies. Users can provide customized rules through this interface.

[0086] For example, based on the optimization rules received by the interface, it is specified that a specific operator fusion optimization strategy should be adopted for a convolutional neural network structure implemented using a specific version of the PyTorch framework.

[0087] In addition, the user description component optimization rule interface can receive and parse input in natural language or a specific format to ensure accurate entry of optimization rules.

[0088] Step S50: creating an optimization strategy mapping table according to the optimization rule.

[0089] An optimization strategy mapping table is created based on the optimization rules input by the user. The optimization strategy mapping table is used to store the mapping relationship between the framework type, the structure type and the optimization strategy. The received optimization rules are automatically processed and converted into entries in the mapping table. Each entry clearly indicates which optimization strategy should be adopted for a specific combination of framework and structure type.

[0090] In this way, this embodiment allows users to input customized optimization rules according to their own needs and the characteristics of the model, and ensures that these rules are understood and executed by the system, thereby improving the adaptability and effectiveness of the optimization process. At the same time, it also provides users with control over the optimization process, so that the optimization strategy can better meet specific business goals and performance requirements.

[0091] For example, in a feasible implementation manner, the structural block diagram of the user description component optimization rule interface is as follows: Figure 3 As shown, the framework type is described through the model framework representation type definition window, the structure type is described through the model structure category description window, and the type of optimization strategy is selected as the device native compilation optimization method or the component customized compilation optimization method. Then, the specific optimization strategy is entered to realize the introduction of new rules, which can flexibly adapt to the user's optimization needs.

[0092] Specifically, new components, new optimization methods, and even new model frameworks encountered in actual optimization scenarios can all be described through new component optimization rule methods. In the actual execution of model optimization, similar items in the optimization rules are traversed in each individual step, classified, and appropriate optimization rules are selected for optimization. In the case where multiple rules are met, one of them is selected for execution according to the priority set by the rule. In order to select the best optimization strategy, all optimization strategies can be evaluated to measure their running time under the corresponding request conditions and platform environment. This evaluation method can ensure that new model components and model frameworks can be adapted, and a better tuning method can be selected.

[0093] In a feasible embodiment, step S20 may include steps S201 to S203:

[0094] Step S201, for a target component in each component of the target model to be optimized, according to the framework type and structure type of the target component and in accordance with a preset optimization strategy mapping table, determining an optimization strategy that matches the target component;

[0095] Conduct in-depth analysis on each target component to be optimized in the target model to determine its framework type and structure type. Based on this information and the optimization strategy mapping table, find and determine the optimization strategy that matches the target component.

[0096] Step S202, when there are multiple matching optimization strategies, selecting a target optimization strategy from the multiple matching optimization strategies according to the received optimization request conditions and the running time of the optimization strategies;

[0097] When a target component corresponds to multiple matching optimization strategies, the most appropriate target optimization strategy is selected from the multiple matching strategies based on the received optimization request conditions, such as performance requirements, resource constraints, or specific user preferences, and the expected running time of various optimization strategies.

[0098] Step S203: calling the target optimization strategy for the target component.

[0099] The corresponding target optimization strategy is called for the selected target component. In this way, the target optimization strategy finally selected takes into account the balance between optimization effect and efficiency, ensuring that the optimization result not only meets user needs but also can be completed within a reasonable time.

[0100] In a feasible embodiment, step S30 may further include steps S60 to S70:

[0101] Step S60, recording the overall optimization strategy for the inference acceleration optimization of the target model;

[0102] Step S70: After receiving the optimization request for the target model, optimize the target model according to the overall optimization strategy.

[0103] Record the overall optimization strategy for inference acceleration optimization of the target model, which includes specific optimization measures applied to each component of the target model and the decision basis for selecting the strategy.

[0104] Upon receiving a new optimization request for the target model, the target model is automatically optimized according to the recorded overall optimization strategy, allowing the system to quickly reuse previous optimization strategies, thereby significantly improving optimization efficiency and reducing the need for repetitive work.

[0105] In this way, this embodiment not only provides accurate and efficient optimization strategy matching and execution during the initial optimization, but also realizes the memorization of optimization experience, so that future optimization requests can be processed quickly and automatically, thereby improving the flexibility and scalability of multi-framework model optimization and reducing the complexity and time cost of optimization work.

[0106] For example, in a feasible implementation, in order to help understand the implementation process of the model optimization method obtained by combining this embodiment with the above embodiments, this embodiment provides a model optimization implementation process of a Wensheng graph model + face-changing model application pipeline in an actual production application:

[0107] Models such as Figure 4 As shown, the model includes three inputs (target face shape, control picture and prompt word), two components (component A and component B) and one output (target picture), wherein component A is a stablediffusion (a deep learning text-to-image generation model) structure with a controlNet structure under a pytroch framework, and component B is a face-changing model with Inswapper.onnx (an image restoration and face-changing model represented by the ONNX framework) as the main model.

[0108] For component A, after being identified by the component framework classification identifier, the nn.module structure (a basic structure in the PyTorch framework) is identified, and it is classified as a model under the PyTorch framework. After that, the model structure classification identifier continues to process and identifies the controlnet structure and unet structure. Both structures can be optimized by applying corresponding customized optimization strategies respectively. For component B, the component framework classification identifier identifies its call to the onnxruntime library, and thus classifies it as a model under the onnx framework. For models of this type of framework, the existing tensorrt already supports the corresponding optimization, and the matching native optimization strategy can be directly used for optimization. Finally, the tuning execution engine is called according to the selected optimization strategy to complete the optimization of components A and B one by one. In addition, the optimization of components A and B is memorized, so that the excessive delay caused by repeated compilation optimization of the same type of components can be avoided when the model is optimized next time.

[0109] In this way, this embodiment can decompose the model representation differences and model structure diversification in various model components, and apply different optimization strategies for local optimization after decomposition, thereby integrating various existing optimization strategies, avoiding additional optimization workload, and solving the problem of inflexible optimization deployment. It has the advantages of strong deployment compatibility, flexibility and portability. This embodiment also adapts to the increasing components and corresponding new optimization method extensions in the complex pipeline of the artificial intelligence model, and can incrementally supplement the model optimization rules in a regular format. Through the memorized deployment optimization strategy, the optimal solution corresponding to the user request and platform environment is selected, which solves the problem of limited optimization scalability. It has the advantages of strong scalability and good overall optimization effect.

[0110] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the model optimization method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0111] The present application also provides a model optimization device, please refer to Figure 5 , the model optimization device includes:

[0112] An identification module 10 is used to identify the framework type and structure type of each component in the target model to be optimized;

[0113] An optimization strategy matching module 20, for calling a matching optimization strategy for each of the components according to a preset optimization strategy mapping table, wherein the optimization strategy is stored in the optimization strategy mapping table in a mapping manner with the framework type and structure type of the component;

[0114] The optimization module 30 is used to optimize each of the components according to the optimization strategy to complete the reasoning acceleration optimization of the target model.

[0115] Optionally, the model building module 10 is further used to:

[0116] For a target component in each component of the target model to be optimized, a preset component framework classification identifier is used to perform framework identification on the target component to determine the framework type of the target component;

[0117] The target component is structurally identified by a preset model structure classification identifier to determine the structural type of the target component.

[0118] Optionally, the model optimization device further includes a splitting module (not shown), which is used to:

[0119] When the target component has multiple framework types, the target component is structurally split according to different framework types to obtain various partial target components;

[0120] Optionally, the model building module 10 is further used to:

[0121] The structure of each of the partial target components is respectively identified by a preset model structure classification identifier to determine the structural type of each of the partial target components.

[0122] Optionally, the model optimization device further includes a mapping table creation module (not shown), and the mapping table creation module is used to:

[0123] Based on a preset user description component optimization rule interface, receiving an input optimization rule, wherein the optimization rule includes a correspondence between a framework type and a structure type and an optimization strategy;

[0124] An optimization strategy mapping table is created according to the optimization rules.

[0125] Optionally, the optimization strategy matching module 20 is further used to:

[0126] For a target component in each component of the target model to be optimized, according to the framework type and structure type of the target component and in accordance with a preset optimization strategy mapping table, an optimization strategy matching the target component is determined;

[0127] When there are multiple matching optimization strategies, a target optimization strategy is selected from the multiple matching optimization strategies according to the received optimization request conditions and the running time of the optimization strategies;

[0128] The target optimization strategy is invoked for the target component.

[0129] Optionally, the model optimization device further includes a memory module (not shown), and the memory module is used to:

[0130] Recording the overall optimization strategy for the inference acceleration optimization of the target model;

[0131] After receiving the optimization request for the target model, the target model is optimized according to the overall optimization strategy.

[0132] The model optimization device provided in the embodiment of the present application adopts the model optimization method in the above embodiment to improve the efficiency and flexibility of model optimization. Compared with the prior art, the beneficial effects of the model optimization device provided in the embodiment of the present application are the same as the beneficial effects of the model optimization method provided in the above embodiment, and other technical features in the model optimization device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0133] An embodiment of the present application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the model optimization method in the above-mentioned embodiment 1.

[0134] Reference below Figure 6 , which shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present application. The electronic devices in the embodiments of the present application may include but are not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The model optimization device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0135] like Figure 6 As shown, the electronic device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the electronic device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following devices can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an electronic device with various devices, it should be understood that it is not required to implement or have all the devices shown. More or fewer devices can be implemented or provided alternatively.

[0136] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0137] The electronic device provided in the embodiment of the present application adopts the model optimization method in the above embodiment to improve the efficiency and flexibility of model optimization. Compared with the prior art, the beneficial effects of the electronic device provided in the embodiment of the present application are the same as the beneficial effects of the model optimization method provided in the above embodiment, and the other technical features in the electronic device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0138] It should be understood that the various parts disclosed in the embodiments of the present application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0139] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0140] An embodiment of the present application provides a computer-readable storage medium having computer-readable program instructions (ie, a computer program) stored thereon, wherein the computer-readable program instructions are used to execute the model optimization method in the above-mentioned embodiment.

[0141] The computer-readable storage medium provided in the embodiment of the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including, but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.

[0142] The computer-readable storage medium may be included in the electronic device, or may exist independently without being installed in the electronic device.

[0143] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by an electronic device, the electronic device: identifies the framework type and structure type of each component in the target model to be optimized; calls a matching optimization strategy for each component according to a preset optimization strategy mapping table, wherein the optimization strategy is stored in the optimization strategy mapping table in a mapping with the framework type and structure type of the component; optimizes each component according to the optimization strategy to complete the reasoning acceleration optimization of the target model.

[0144] The computer program code for performing the operation of the embodiment of the present application can be written in one or more programming languages ​​or a combination thereof, and the above-mentioned programming languages ​​include object-oriented programming languages, such as Java, Smalltalk, C++, and also include conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on the remote computer, or completely on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0145] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the device, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based device that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0146] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0147] The readable storage medium provided in the embodiment of the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned model optimization method, and can improve the efficiency and flexibility of model optimization. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the embodiment of the present application are the same as the beneficial effects of the model optimization method provided in the above-mentioned embodiment, and will not be repeated here.

[0148] An embodiment of the present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned model optimization method when executed by a processor.

[0149] The computer program product provided in the embodiment of the present application can improve the efficiency and flexibility of model optimization. Compared with the prior art, the beneficial effects of the computer program product provided in the embodiment of the present application are the same as the beneficial effects of the model optimization method provided in the above embodiment, which will not be repeated here.

[0150] The above are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A model optimization method, It is characterized in that The model optimization method comprises: Identify the framework type and structure type of each component in the target model to be optimized; According to a preset optimization strategy mapping table, a matching optimization strategy is respectively called for each of the components, wherein the optimization strategy is stored in the optimization strategy mapping table in a mapping manner with the framework type and the structure type of the component; Each of the components is optimized separately according to the optimization strategy to complete the reasoning acceleration optimization of the target model.

2. The model optimization method according to claim 1, It is characterized in that The step of identifying the framework type and structure type of each component in the target model to be optimized includes: For a target component in each component of the target model to be optimized, a preset component framework classification identifier is used to perform framework identification on the target component to determine the framework type of the target component; The target component is structurally identified by a preset model structure classification identifier to determine the structural type of the target component.

3. The model optimization method according to claim 2, It is characterized in that Before the step of performing structural identification on the target component by a preset model structure classification identifier to determine the structural type of the target component, the step further includes: When the target component has multiple framework types, the target component is structurally split according to different framework types to obtain various partial target components; The step of performing structural identification on the target component by a preset model structure classification identifier to determine the structural type of the target component includes: The structure of each of the partial target components is respectively identified by a preset model structure classification identifier to determine the structural type of each of the partial target components.

4. The model optimization method according to claim 1, It is characterized in that Before the step of respectively calling the matching optimization strategy for each of the components according to the preset optimization strategy mapping table, the method further includes: Based on a preset user description component optimization rule interface, receiving an input optimization rule, wherein the optimization rule includes a correspondence between a framework type and a structure type and an optimization strategy; An optimization strategy mapping table is created according to the optimization rules.

5. The model optimization method according to claim 1, It is characterized in that The step of respectively calling a matching optimization strategy for each of the components according to a preset optimization strategy mapping table includes: For a target component in each component of the target model to be optimized, according to the framework type and structure type of the target component and in accordance with a preset optimization strategy mapping table, an optimization strategy matching the target component is determined; When there are multiple matching optimization strategies, a target optimization strategy is selected from the multiple matching optimization strategies according to the received optimization request conditions and the running time of the optimization strategies; The target optimization strategy is invoked for the target component.

6. The model optimization method according to any one of claims 1 to 5, It is characterized in that After the step of optimizing each of the components according to the optimization strategy to complete the inference acceleration optimization of the target model, the method further includes: Recording the overall optimization strategy for the inference acceleration optimization of the target model; After receiving the optimization request for the target model, the target model is optimized according to the overall optimization strategy.

7. A model optimization device, It is characterized in that The model optimization device comprises: An identification module, used to identify the framework type and structure type of each component in the target model to be optimized; An optimization strategy matching module, used to call a matching optimization strategy for each of the components according to a preset optimization strategy mapping table, wherein the optimization strategy is stored in the optimization strategy mapping table in a mapping manner with the framework type and structure type of the component; The optimization module is used to optimize each of the components according to the optimization strategy to complete the reasoning acceleration optimization of the target model.

8. An electronic device, It is characterized in that The electronic device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the model optimization method according to any one of claims 1 to 6.

9. A storage medium, It is characterized in that The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the model optimization method according to any one of claims 1 to 6 are implemented.

10. A computer program product, It is characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the model optimization method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Deep learning neural network deployment system and method

    CN110942139A

  • Model optimization recommendation method and device and computer storage medium

    CN111708810A

  • Multi-target tracking acceleration method based on time-space optimization in edge calculation environment

    CN113723279A

  • Network model reasoning method and device, storage medium and electronic equipment

    CN116258205A

  • Back-end extensible framework and method for deep learning model parsing, optimization and deployment

    CN116306812A