Deep learning model non-invasive reversible conversion method, device, equipment and medium

CN118569346BActive Publication Date: 2026-08-11SHANGHAI SUIYUAN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0004]显然,这样的实现方式严重依赖开发人员实际经验,人力成本高、繁琐且易出错,同时,这种依赖经验的手动实现方式很难泛化、扩展到更多的模型和应用场景中

Benefits of technology

[0021]本发明实施例的技术方案,通过获取目标深度学习模型的抽象语法树以及设定的可逆转换形式;根据所述可逆转换形式,分别生成用于将每个转换可逆结构转换为匹配的转换可逆转换模式的目标注入代码;生成与每个目标注入代码分别对应的转换子树,并根据各转换子树对目标深度学习模型的抽象语法树进行更新,得到与可逆转换形式对应的更新抽象语法树的技术手段,提供了一种以非侵入的方式自动化实现可逆化转换的新技术,无需人工参与,彻底避免了由人工操作所引起的各类错误,实现方式简单、灵活,进而可以有效泛化、扩展到更多的机器学习模型或者应用场景中。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118569346B_ABST
    Figure CN118569346B_ABST
Patent Text Reader

Abstract

This invention discloses a non-intrusive reversible transformation method, apparatus, device, and medium for deep learning models. The method includes: obtaining the abstract syntax tree of the target deep learning model and a set reversible transformation form; generating target injection code, based on the reversible transformation form, for converting each reversible transformation structure into a matching reversible transformation pattern; generating a transformation subtree corresponding to each target injection code, and updating the abstract syntax tree of the target deep learning model based on each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form. The technical solution of this invention provides a new technology for automatically implementing reversible transformations in a non-intrusive manner, requiring no manual intervention and completely avoiding various errors caused by manual operation. The implementation is simple and flexible, and can be effectively generalized and extended to more machine learning models or application scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a non-intrusive reversible transformation method, apparatus, device, and medium for deep learning models. Background Technology

[0002] The reversibility technique for deep learning models is a solution that effectively optimizes the utilization efficiency of computational, bandwidth, and storage resources during model training. Specifically, it involves converting certain local structures (also known as reversible structures) in a deep learning model into specific reversible modes.

[0003] In existing technologies, reversible structures and corresponding reversible patterns that can be reversibly transformed are primarily identified manually by developers with extensive knowledge and experience through model structure analysis. Then, the deep learning model's source code is manually and intrusively modified to achieve the aforementioned reversible transformation process. For example, RevNet and Reformer, two cutting-edge research areas in academia, both achieved reversible transformations by directly modifying the PyTorch model source code.

[0004] Clearly, this implementation method relies heavily on the practical experience of developers, resulting in high labor costs, tediousness, and a high risk of errors. Furthermore, this experience-based manual implementation method is difficult to generalize and extend to more models and application scenarios. Summary of the Invention

[0005] This invention provides a non-intrusive reversible transformation method, apparatus, device, and medium for deep learning models, so as to achieve the technical effect of non-intrusive reversible transformation.

[0006] According to one aspect of the present invention, a non-intrusive reversible transformation method for deep learning models is provided, comprising:

[0007] Obtain the abstract syntax tree of the target deep learning model and the defined reversible transformation form;

[0008] In this context, the nodes in the abstract syntax tree correspond to operators in the target deep learning model, and the reversible transformation form includes: at least one reversible transformation structure in the target deep learning model, and a unique reversible transformation pattern corresponding to each reversible transformation structure; the reversible transformation structure is a branchless structure containing at least one node.

[0009] Based on the reversible transformation form, target injection code is generated to convert each reversible transformation structure into a matching reversible transformation pattern.

[0010] Generate a transformation subtree corresponding to each target injection code, and update the abstract syntax tree of the target deep learning model according to each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form.

[0011] According to another aspect of the present invention, a non-intrusive reversible transformation apparatus for deep learning models is also provided, comprising:

[0012] The reversible transformation form acquisition module is used to obtain the abstract syntax tree of the target deep learning model and the set reversible transformation form;

[0013] In this context, the nodes in the abstract syntax tree correspond to operators in the target deep learning model, and the reversible transformation form includes: at least one reversible transformation structure in the target deep learning model, and a unique reversible transformation pattern corresponding to each reversible transformation structure; the reversible transformation structure is a branchless structure containing at least one node.

[0014] The target injection code generation module is used to generate target injection code for converting each reversible transformation structure into a matching reversible transformation pattern, based on the reversible transformation form.

[0015] The abstract syntax tree generation module is updated to generate a transformation subtree corresponding to each target injection code, and the abstract syntax tree of the target deep learning model is updated according to each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form.

[0016] According to another aspect of the present invention, an electronic device is also provided, the electronic device comprising:

[0017] At least one processor; and

[0018] A memory communicatively connected to the at least one processor; wherein,

[0019] The memory stores a computer program that can be executed by the at least one processor, which enables the at least one processor to perform the non-intrusive reversible transformation method for deep learning models according to any embodiment of the present invention.

[0020] According to another aspect of the present invention, a computer-readable storage medium is also provided, the computer-readable storage medium storing computer instructions, the computer instructions being configured to cause a processor to execute and implement the non-intrusive reversible transformation method for deep learning models according to any embodiment of the present invention.

[0021] The technical solution of this invention provides a new technology for automatically implementing reversible transformations in a non-intrusive manner. This involves obtaining the abstract syntax tree of the target deep learning model and a defined reversible transformation form; generating target injection code to convert each reversible transformation structure into a matching reversible transformation pattern based on the reversible transformation form; generating a transformation subtree corresponding to each target injection code; and updating the abstract syntax tree of the target deep learning model based on each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form. This provides a simple and flexible implementation method that can be effectively generalized and extended to more machine learning models or application scenarios.

[0022] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 This is a flowchart of a non-intrusive reversible transformation method for deep learning models provided in Embodiment 1 of the present invention;

[0025] Figure 2 This is a flowchart of another non-intrusive reversible transformation method for deep learning models provided in Embodiment 2 of the present invention;

[0026] Figure 3 This is a flowchart of another non-intrusive reversible transformation method for deep learning models provided in Embodiment 3 of the present invention;

[0027] Figure 4 This is a schematic diagram of the structure of a non-intrusive reversible transformation device for a deep learning model according to Embodiment 4 of the present invention;

[0028] Figure 5 This is a schematic diagram of the structure of an electronic device that implements the non-intrusive reversible transformation method for deep learning models according to embodiments of the present invention. Detailed Implementation

[0029] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0031] Example 1

[0032] Figure 1 This is a flowchart of a non-intrusive reversible transformation method for deep learning models provided in Embodiment 1 of the present invention. This embodiment is applicable to the situation where a new abstract syntax tree corresponding to the reversible transformation form is generated in a non-intrusive manner based on the abstract syntax tree of the target deep learning model and the set reversible transformation form. This method can be executed by a non-intrusive reversible transformation device for deep learning models. This device can be implemented in hardware and / or software and is generally configured in an electronic device with data processing capabilities.

[0033] Correspondingly, such as Figure 1 As shown, the method may include:

[0034] S110, Obtain the abstract syntax tree of the target deep learning model and the set reversible transformation form.

[0035] In this context, the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, and the reversible transformation form includes: at least one reversible transformation structure in the target deep learning model, and a unique reversible transformation mode corresponding to each reversible transformation structure; the reversible transformation structure is a branchless structure containing at least one node.

[0036] In this embodiment, the target deep learning model refers to a machine learning model that requires one or more reversible patterns to replace a given local structure in order to efficiently perform backpropagation computation. This replacement process is called reversible transformation. A reversible pattern is a specific subnetwork architecture that eliminates the need for accumulating activations by synthesizing gradients using the gradient tensor at the output location and the accompanying tensor passed through its own structure. Currently, various reversible patterns for different network structures have been developed, such as additive reversible patterns, affine reversible patterns, or momentum reversible patterns. This embodiment does not limit these to any particular pattern.

[0037] Specifically, in a target deep learning model, the local structure used to reversibly transform the reversible modes of the defined structure is called the reversible structure.

[0038] The reversible transformation form describes which reversible transformation patterns (i.e., transformation reversible transformation patterns) should be used to reversibly transform the matching reversible structure (i.e., transformation reversible structure) in the target deep learning model. In the reversible transformation form, a transformation reversible structure has a unique transformation reversible transformation pattern that matches it.

[0039] For example, assuming a reversible transformation form is: a reversible structure A and a reversible transformation pattern B1, it means that the reversible structure A in the target deep learning model is reversibly transformed using the reversible transformation pattern B1. As another example, assuming a reversible transformation form is: a reversible structure C and a reversible transformation pattern D1, and a reversible structure E and a reversible transformation pattern F1, it means that while using the reversible transformation pattern D1 to reversibly transform the reversible structure C in the target deep learning model, the reversible transformation pattern F1 is used to reversibly transform the reversible structure E in the target deep learning model.

[0040] In this embodiment, the dependency relationships between nodes in the abstract syntax tree corresponding to the target deep learning model can be analyzed, and the theoretically usable legal reversible structures and the reversible transformation pattern sets corresponding to each legal reversible structure can be generated based on the legality detection conditions and blacklists and whitelists.

[0041] Alternatively, a transformation reversible structure and its corresponding transformation reversible transformation mode can be generated by the actual test and available target reversible structure determined by the actual trial operation and the target reversible transformation mode set corresponding to each target reversible structure. This embodiment does not limit this.

[0042] In an optional implementation of this embodiment, the method for determining the set of reversible transformation modes corresponding to each legal reversible candidate structure may include:

[0043] Obtain the abstract syntax tree corresponding to the target deep learning model, and generate a directed acyclic graph (DAG) based on the abstract syntax tree; perform structural analysis on the DAG to determine the dependencies between nodes, and determine the reversible candidate structures corresponding to each node based on the dependencies; wherein, the reversible candidate structure is a branchless structure containing at least one node; among all reversible candidate structures, filter out the reversible candidate structures that do not meet the legality detection conditions to obtain legal reversible candidate structures, and determine the reversible transformation pattern set corresponding to each legal reversible candidate structure based on blacklists and whitelists.

[0044] An Abstract Syntax Tree (AST) is a tree-like representation of the abstract syntactic structure of source code, where each node in the tree represents a structure within the source code. In machine learning, we can use ASTs to represent the structure of machine learning models, and then construct or parse these models by traversing the AST. Specifically, when using an AST to represent a target deep learning model, each node in the AST represents an operator within the target deep learning model.

[0045] Accordingly, after obtaining the abstract syntax tree corresponding to the target deep learning model, a directed acyclic graph (DAG) corresponding to the target deep learning model can be generated based on the abstract syntax tree. A directed acyclic graph refers to a graph in which nodes are connected by edges with a definite direction (directed edges), and there are no multiple edges linked in a cycle.

[0046] The directed acyclic graph contains multiple nodes, which are connected by directed edges. Each node in the directed acyclic graph also corresponds to an operator in the target deep learning model.

[0047] As mentioned earlier, the edges connecting any two nodes in a directed acyclic graph (DAG) are directional. That is, when two nodes are connected by a directed edge with an arrow, the node where the arrow terminates depends on the node where the arrow begins. For example, in the target deep learning model, if convolution is first performed on the input data x and y to obtain the result z, and then normalization is performed on z to obtain the result k, it can be seen that the execution of the normalization operator depends on the result of the convolution operator. Therefore, in the DAG corresponding to the target deep learning model, in the directed edge formed by node A (corresponding to the convolution operator) and node B (corresponding to the normalization operator), the arrow points from node A to node B.

[0048] Correspondingly, after obtaining the directed acyclic graph corresponding to the target deep learning model, the dependencies between nodes can be determined by analyzing the directionality of the directed edges between each node in the directed acyclic graph.

[0049] The inventors discovered through research that if a local structure in a target deep learning model can be considered an invertible structure, then the subgraph corresponding to this local structure in a directed acyclic graph should be a branchless structure from a data topology perspective. That is, this local structure contains multiple nodes, and when considered as a whole, apart from the initial input edge (which may be one or more) and the final output edge (which may be one or more), there are no other directed edges flowing into or out of this local structure; in other words, the local structure as a whole is a branchless structure.

[0050] It is understandable that a branchless structure is a necessary condition for a local structure to serve as a usable invertible structure. Therefore, based on the dependencies between nodes defined in the directed acyclic graph, we can first identify all candidate structures that can serve as the final invertible structure for the target deep learning model, i.e., invertible candidate structures.

[0051] The inventors further discovered that reversible structures that can be reversibly transformed using reversible patterns also need to meet certain necessary conditions in terms of data capacity (total number of elements in a tensor), in-degree and out-degree, or mathematical properties (determinant value). Accordingly, in the embodiments of the invention, corresponding legality detection conditions can be constructed based on one or more of the aforementioned necessary conditions.

[0052] Therefore, based on the above-mentioned legality detection conditions, all reversible candidate structures can be screened once to obtain legal reversible candidate structures that meet each legality detection condition.

[0053] The set of reversible transformation modes includes one or more reversible transformation modes, and one set of reversible transformation modes corresponds to one legal reversible candidate structure. A reversible transformation mode can be understood as a reversible mode that can perform reversible transformation on the adapted legal reversible candidate structure.

[0054] In this embodiment, the blacklist and whitelist can be a pre-established whitelist of reversible transformation modes and a pre-established blacklist of reversible transformation modes. The whitelist defines all reversible modes corresponding to each reversible structure under the broadest conditions; that is, all reversible modes that can be used to reversibly transform a reversible structure without considering other limiting conditions. The blacklist defines invalid reversible modes that cannot be effectively reversibly transformed under each algorithm model scenario.

[0055] Specifically, the algorithm model scenario can include: Transformers model scenario, TorchVision model scenario, or PyTorch model scenario, etc., and this embodiment does not limit it.

[0056] By combining the target algorithm model scenario using the target deep learning model with the blacklist and whitelist, we can determine the set of reversible transformation modes corresponding to each legal reversible candidate structure under the target algorithm model scenario. In other words, we can determine all the reversible transformation modes that can theoretically be used to reversibly transform legal reversible candidate structures.

[0057] Furthermore, structural analysis is performed on the directed acyclic graph to determine the dependencies between nodes, and based on these dependencies, invertible candidate structures corresponding to each node are identified, which may include:

[0058] Perform structural analysis on the directed acyclic graph (DAG) to generate the corresponding dominator tree. Based on the dominator tree, generate the corresponding post-dominator tree. Perform a preorder traversal on the DAG to obtain a sorted list of nodes. Sequentially obtain a node from the sorted list as the current processing node. Query the post-dominator tree to obtain all subgraphs starting from the current processing node and ending at its post-dominator nodes, which are considered as reversible candidate structures corresponding to the current processing node. Return to the previous step and continue retrieving nodes from the sorted list as the current processing node until a reversible candidate structure corresponding to each node is obtained.

[0059] Furthermore, filtering out reversible candidate structures that do not meet the validity detection conditions from all reversible candidate structures can include:

[0060] Identify the in-degree and out-degree of the current reversible candidate structure; if either the in-degree or the out-degree is greater than 2, then determine that the current reversible candidate structure does not meet the legality detection conditions and filter out the current reversible candidate structure.

[0061] Furthermore, filtering out reversible candidate structures that do not meet the validity detection conditions from all reversible candidate structures can include:

[0062] Identify the total number of elements in the two input tensors and two output tensors of the currently processed reversible candidate structure; if it is determined that the total number of elements in the two input tensors or two output tensors is inconsistent, then the currently processed reversible candidate structure is determined to be a reversible candidate structure that does not meet the legality detection conditions, and the currently processed reversible candidate structure is filtered out.

[0063] Furthermore, filtering out reversible candidate structures that do not meet the validity detection conditions from all reversible candidate structures can include:

[0064] Obtain the transformation function matrix corresponding to the currently processed invertible candidate structure; and calculate the determinant of the transformation function matrix; if it is determined that the determinant is less than or equal to zero, then determine that the currently processed invertible candidate structure is an invertible candidate structure that does not meet the legality detection condition, and filter out the currently processed invertible candidate structure.

[0065] Furthermore, determining the set of reversible transformation patterns corresponding to each legitimate reversible candidate structure based on the blacklist and whitelist can include:

[0066] By querying a pre-established whitelist of reversible transformation patterns, a set of reversible transformation candidate patterns matching each legitimate reversible candidate structure is obtained; a target algorithm model scenario matching the target deep learning model is obtained, and by querying a pre-established blacklist of reversible transformation patterns, at least one invalid reversible transformation pattern matching the target algorithm model scenario is obtained; each invalid reversible transformation pattern is filtered out from each set of reversible transformation candidate patterns to obtain a set of reversible transformation patterns corresponding to each legitimate reversible candidate structure.

[0067] In a specific example, assuming the set of reversible transformation patterns corresponding to a legitimate reversible candidate structure A is {reversible transformation pattern B1, reversible transformation pattern B2}, then the legitimate reversible candidate structure A and reversible transformation pattern B1 can be used together as a reversible transformation form 1, indicating that the reversible transformation pattern B1 is used to perform a reversible transformation on the legitimate reversible candidate structure A in the target deep learning model; at the same time, the legitimate reversible candidate structure A and reversible transformation pattern B2 can also be used together as a reversible transformation form 2, indicating that the reversible transformation pattern B2 is used to perform a reversible transformation on the legitimate reversible candidate structure A in the target deep learning model.

[0068] Furthermore, in a reversible form, a single reversible transformation structure and a unique reversible transformation mode corresponding to the single reversible transformation structure can be defined; in a reversible form, multiple independent reversible transformation structures and a unique reversible transformation mode corresponding to each of the above reversible transformation structures can also be defined.

[0069] In this context, "mutually independent" means that after one transformable reversible structure undergoes a reversible transformation using a matching transformable reversible transformation pattern, it will not affect other transformable reversible structures from undergoing the same reversible transformation using the same matching transformable reversible transformation pattern. That is, no two mutually independent transformable reversible structures have any identical (overlapping) nodes.

[0070] S120. Based on the reversible transformation form, generate target injection code to convert each reversible transformation structure into a matching reversible transformation pattern.

[0071] As mentioned above, an abstract syntax tree is a tree-like representation of the abstract syntax structure of source code. The goal of each embodiment of the present invention is to update the abstract syntax tree of the target deep learning model to an updated abstract syntax tree corresponding to the reversible transformation form based on a set reversible transformation form.

[0072] Based on this updated abstract syntax tree, a reversible reconstruction model can be obtained by using the reversible transformation pattern in the reversible transformation form to perform a reversible transformation on the reversible structure in the target deep learning model.

[0073] To achieve the above objectives, each embodiment of the present invention considers first converting each reversible structure in the reversible transformation form and its corresponding reversible transformation mode into code form (i.e., target injection code). Then, in accordance with the method of generating an abstract syntax tree, generating subtree structures corresponding to each segment of target injection code, and then converting the subtree structures in the target deep learning model corresponding to the reversible structures in the reversible transformation form into the newly generated subtree structures to obtain an updated abstract syntax tree.

[0074] As mentioned above, the reversible transformation form may include only one reversible transformation structure A and a reversible transformation mode B corresponding to the reversible transformation structure A, in which case a target injection code C for converting the reversible transformation structure A into the reversible transformation mode B can be generated; or, the reversible transformation form may simultaneously include a reversible transformation structure A1 and a reversible transformation structure A2, a reversible transformation mode B1 corresponding to the reversible transformation structure A1, and a reversible transformation mode B2 corresponding to the reversible transformation structure A2, in which case a target injection code C1 for converting the reversible transformation structure A1 into the reversible transformation mode B1 can be generated, and a target injection code C2 for converting the reversible transformation structure A2 into the reversible transformation mode B2 can also be generated.

[0075] In an optional implementation of this embodiment, multiple reversible transformation code templates can be pre-built, each template matching a given reversible transformation structure and a given reversible transformation mode. Furthermore, matching target injection code can be constructed using appropriate reversible transformation code templates.

[0076] In another optional implementation of this embodiment, one or more reversible transformation rules can be pre-built, each reversible transformation rule matching a set reversible transformation structure and a set reversible transformation mode. Furthermore, matching target injection code can be constructed using appropriate reversible transformation rules.

[0077] Alternatively, the target injection code can be constructed by using both the reversible conversion code template and the reversible conversion rules. This embodiment does not impose any restrictions on this approach.

[0078] S130. Generate a transformation subtree corresponding to each target injection code, and update the abstract syntax tree of the target deep learning model according to each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form.

[0079] Optionally, generating a transformation subtree corresponding to each target injection code may include:

[0080] Invoke the pre-built code injector to generate a transformation subtree corresponding to each target injection code.

[0081] In this embodiment, after obtaining the target injection code, it can be used as source code to generate a corresponding abstract syntax tree (AST). However, compared to the AST of the target deep learning model, the AST of the target injection code is only a portion of the AST of the target deep learning model. Therefore, the AST generated based on the target injection code is called a transformation subtree. It can be understood that the transformation subtree is used to transform the reversible structures in the AST of the target deep learning model.

[0082] Correspondingly, by updating the abstract syntax tree of the target deep learning model according to each transformation subtree, an updated abstract syntax tree corresponding to the reversible transformation form can be obtained.

[0083] Furthermore, after obtaining the updated abstract syntax tree, a reversible reconstruction model corresponding to the target deep neural network can be generated based on the updated abstract syntax tree. Specific generation methods may include:

[0084] The deep learning compiler generates an intermediate representation of the computation graph corresponding to the updated abstract syntax tree. The optimization pipeline inside the deep learning compiler determines the intermediate computation layer level corresponding to the intermediate representation of the computation graph. Then, the deep learning encoder backend generates executable machine code or bytecode as the reversible reconstruction model for the intermediate representation of the computation graph and the intermediate computation layer level.

[0085] Furthermore, after obtaining the reversible reconstruction model, it can be loaded into the backend system for trial operation. Based on the trial operation results, the usability of the reversible transformation form can be verified. Alternatively, after verifying the usability of the reversible transformation form based on the trial operation results, it can be determined whether the reversible reconstruction model can be used to replace the target deep learning model based on the performance description information of the backend system when executing the reversible reconstruction model. If so, the reversible reconstruction model is loaded into the backend system for actual operation to perform equivalent model training operations.

[0086] The backend system can be understood as the physical execution device used to load and execute a given machine learning model. The trial run can be understood as loading the reversible reconstructible model onto the actual execution device and controlling the device to execute for a set duration (e.g., 10 minutes, 20 minutes, or 1 hour) or to reach a set computational goal (e.g., one round of model training). Simultaneously, it is necessary to detect whether the reversible reconstructible model can execute normally during the execution based on the set duration or computational goal. For example, checking for any abnormal errors during the test run.

[0087] The performance description information includes one or more of the following: computation time information, or memory usage information during the computation process.

[0088] The computation time information can be understood as the time spent completing the set computation goal (e.g., one round of backpropagation computation), and the memory usage information can be understood as the average amount of memory used by the backend system during the model's operation.

[0089] Clearly, the smaller the computation time and memory usage of a reversible reconfiguration model, the better its reconfiguration effect.

[0090] It is understandable that if the reversible reconstruction model achieves good reconstruction results, replacing the target deep neural network with the reversible reconstruction model and loading it into the backend system for actual operation can effectively optimize the backpropagation calculation during model training.

[0091] It is understandable that the aforementioned target deep learning model can be a machine learning model applied in various fields such as computer vision (e.g., image classification, object detection, or face recognition), natural language processing (e.g., text classification, sentiment analysis, machine translation, speech recognition, or speech-to-text), medical fields, or autonomous driving fields.

[0092] The technical solution of this invention provides a new technology for automatically implementing reversible transformations in a non-intrusive manner. This involves obtaining the abstract syntax tree of the target deep learning model and a defined reversible transformation form; generating target injection code to convert each reversible transformation structure into a matching reversible transformation pattern based on the reversible transformation form; generating a transformation subtree corresponding to each target injection code; and updating the abstract syntax tree of the target deep learning model based on each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form. This provides a simple and flexible implementation method that can be effectively generalized and extended to more machine learning models or application scenarios.

[0093] Based on the above embodiments, after obtaining the updated abstract syntax tree corresponding to the reversible transformation form, it may further include:

[0094] The compiler performs a validity check on the updated abstract syntax tree, and when the updated abstract syntax tree passes the check, a reversible reconstruction model corresponding to the target deep learning model is generated based on the updated abstract syntax tree; the reversible reconstruction model is loaded into the backend system for trial operation, and trial operation results matching the reversible transformation form are obtained.

[0095] Based on the above embodiments, after the compiler performs a validity check on the updated abstract syntax tree, it may further include: when it is determined that the updated abstract syntax tree fails the check, generating a prompt message prohibiting reversible transformation for the reversible transformation structure in the reversible transformation form and the matching reversible transformation mode.

[0096] Understandably, abstract syntax trees (ASTs) need to meet certain syntactic requirements. For example, they cannot have nodes with the same name, and the static type of each node (e.g., constant, variable, hash key-value pair, or structure field) must be set correctly. Based on this, a structure checker for the AST can be built using compiler technology, and this structure checker can be used to verify the validity of the automatically constructed and updated AST.

[0097] When it is determined that the updated abstract syntax tree passes the legality check, a reversible reconstruction model corresponding to the target deep learning model can be directly generated, and the reversible reconstruction model can be loaded into the backend system for trial operation. However, when it is determined that the updated abstract syntax tree fails the legality check, it is determined that the input reversible transformation form cannot be reversibly transformed using the method of this embodiment of the invention. At this time, a prompt message prohibiting reversible transformation corresponding to the reversible transformation form can be generated accordingly.

[0098] By using the above settings, some invalid reversible transformation forms can be filtered out in a simple and convenient way before generating a reversible refactoring model from the updated abstract syntax tree. This effectively reduces the amount of unnecessary work introduced when generating an unusable reversible refactoring model for such reversible transformation forms, thereby improving the efficiency of reversible transformation.

[0099] Example 2

[0100] Figure 2 This is a flowchart of another non-intrusive reversible transformation method for deep learning models provided in Embodiment 2 of the present invention. This embodiment is based on the above embodiments and is optimized. In this embodiment, the operation of "generating target injection code for converting each reversible transformation structure into a matching reversible transformation mode according to the reversible transformation form" is specified.

[0101] Correspondingly, such as Figure 2 As shown, the method may include:

[0102] S210, Obtain the abstract syntax tree of the target deep learning model and the set reversible transformation form.

[0103] In this context, the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, and the reversible transformation form includes: at least one reversible transformation structure in the target deep learning model, and a unique reversible transformation mode corresponding to each reversible transformation structure; the reversible transformation structure is a branchless structure containing at least one node.

[0104] S220. Obtain the current reversible structure and the current reversible transformation mode that matches the current reversible structure.

[0105] As mentioned earlier, a reversible transformation form can contain multiple reversible transformation structures and a unique reversible transformation mode corresponding to each reversible transformation structure.

[0106] Therefore, matching transformation subtrees can be generated for each transformation reversible structure, and the abstract syntax tree of the target deep learning model can be updated by using all transformation subtrees to obtain the updated abstract syntax tree.

[0107] In this embodiment, taking a reversible transformation structure (i.e., the current reversible transformation structure) in the reversible transformation form and the unique reversible transformation mode corresponding to the reversible transformation structure (i.e., the current reversible transformation mode) as examples, the specific generation process of the target injection code corresponding to the current reversible transformation structure and the current reversible transformation mode is described in detail.

[0108] In this embodiment, considering that using reversible transformation code templates to generate target injection code is more targeted and accurate, reversible transformation code templates are preferred for generating target injection code. However, considering that reversible transformation code templates have high customization requirements, reversible transformation rules are considered for generating target injection code only when no available reversible transformation code templates are available.

[0109] S230. In the preset reversible transformation code template library, check whether there is a target reversible transformation code template for converting the current reversible transformation structure into the current reversible transformation mode: if yes, execute S240; otherwise, execute S250.

[0110] In this embodiment, multiple reversible conversion code templates can be pre-built and added to the reversible conversion code template library, and reversible structures and reversible conversion modes corresponding to each reversible conversion code template can be established.

[0111] For example, a reversible transformation code template X1 is pre-established for reversibly converting reversible structure A into reversible transformation mode B1, and a reversible transformation code template X2 is pre-established for reversibly converting reversible structure B into reversible transformation mode B2, etc.

[0112] Correspondingly, by using a joint search of the current reversible transformation structure and the current reversible transformation mode, it is possible to detect whether there exists a target reversible transformation code template for converting the current reversible transformation structure into the current reversible transformation mode.

[0113] If so, the corresponding target injection code can be generated directly based on the target reversible conversion code template.

[0114] S240. Based on the target reversible transformation code template, generate the target injection code corresponding to the current reversible transformation structure, and execute S270.

[0115] Specifically, when the target reversible transformation code template is highly specific, it can be directly used as the target injection code corresponding to the current reversible transformation structure. Alternatively, if the target reversible transformation code template is a general template constructed for the same type of reversible structure, it may have one or more parameters to be filled, such as the number of layers, in-degree, out-degree, or dimension information of the input / output tensors of the reversible structure; or the level, in-degree, out-degree, or dimension information of the input / output tensors of the reversible transformation mode. In this case, based on the specific current reversible transformation structure and mode, the specific values ​​of the above-mentioned parameters to be filled need to be determined, and these values ​​are then filled into the target reversible transformation code template accordingly to obtain the target injection code.

[0116] S250. In the preset reversible transformation rule library, obtain the target reversible transformation rule used to transform the current reversible transformation structure into the current reversible transformation mode, and execute S260.

[0117] In this embodiment, if there is no pre-defined reversible conversion code template corresponding to the current reversible conversion structure and the current reversible conversion mode, the reversible conversion rule library can be queried to obtain the target reversible conversion rule that corresponds to both the current reversible conversion structure and the current reversible conversion mode.

[0118] Correspondingly, it is also necessary to pre-establish the reversible structure and reversible transformation mode corresponding to each reversible transformation rule.

[0119] For example, a reversible transformation rule Y1 is pre-established for reversibly converting reversible structure A into reversible transformation mode B1, and a reversible transformation rule Y2 is pre-established for reversibly converting reversible structure B into reversible transformation mode B2, etc.

[0120] Understandably, constructing reversible transformation rules is generally much easier than constructing reversible transformation code templates. Compared to reversible transformation code templates, reversible transformation rules are more universal, but their accuracy is lower.

[0121] Generally speaking, each reversible transformation rule can be understood as a code generator, which requires input parameters corresponding to the reversible transformation structure and the reversible transformation mode, and outputs the corresponding target injection code.

[0122] Of course, it is understandable that there may be situations where the target reversible transformation rule cannot be found in the reversible transformation rule base. In this case, a prompt message prohibiting reversible transformation can be generated directly for the reversible transformation structure in the reversible transformation form and the matching reversible transformation mode.

[0123] S260. According to the target reversible transformation rule, generate the target injection code corresponding to the current reversible transformation structure, and execute S270.

[0124] S270. Generate a transformation subtree corresponding to each target injection code, and update the abstract syntax tree of the target deep learning model according to each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form.

[0125] The technical solution of this invention generates target injection code by comprehensively using a reversible transformation code template library and a reversible transformation rule library. This method can more accurately construct the transformation subtree for updating the abstract syntax tree of the target deep learning model, and can effectively improve the generation effectiveness and accuracy of updating the abstract syntax tree.

[0126] Example 3

[0127] Figure 3 This is a flowchart of another non-intrusive reversible transformation method for deep learning models provided in Embodiment 3 of the present invention. This embodiment is based on the above embodiments and is optimized. In this embodiment, the operation of "updating the abstract syntax tree of the target deep learning model according to each transformation subtree to obtain the updated abstract syntax tree corresponding to the reversible transformation form" is specified.

[0128] Correspondingly, such as Figure 3 As shown, the method may include:

[0129] S310, Obtain the abstract syntax tree of the target deep learning model and the set reversible transformation form.

[0130] In this context, the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, and the reversible transformation form includes: at least one reversible transformation structure in the target deep learning model, and a unique reversible transformation mode corresponding to each reversible transformation structure; the reversible transformation structure is a branchless structure containing at least one node.

[0131] S320. Based on the reversible transformation form, generate target injection code for converting each reversible transformation structure into a matching reversible transformation pattern, and generate a transformation subtree corresponding to each target injection code.

[0132] S330. Sequentially obtain the current transformation subtree and the reversible transformation structure to be replaced that matches the current transformation subtree, and obtain the original identifier symbol corresponding to the reversible transformation structure to be replaced.

[0133] In this embodiment, if there are multiple reversible transformation structures, multiple target injection code segments can be generated, which in turn can generate multiple transformation subtrees. Furthermore, the abstract syntax tree of the target deep learning model can be updated for each transformation subtree.

[0134] After obtaining a current transformation subtree from all transformation subtrees, the corresponding transformation invertible structure can be obtained. Furthermore, this transformation invertible structure, located in the abstract syntax tree of the target deep learning model, can be directly used as the transformation invertible structure to be replaced.

[0135] In the syntactic structure of an abstract syntax tree, each node and subtree has a unique identifier (also called a symbol) to describe the dependencies between different nodes and subtrees. Accordingly, after locating the reversible structure of the transformation to be replaced, the identifier corresponding to the reversible structure of the transformation to be replaced, i.e., the original identifier, can be obtained from the abstract syntax tree of the target deep learning model.

[0136] S340. Add the current transformation subtree to the current abstract syntax tree of the target deep learning model, and set the replacement identifier corresponding to the current transformation subtree.

[0137] In this embodiment, when there are multiple transformation subtrees, multiple rounds of abstract syntax tree (AST) updates are required. The AST obtained after each update is called the current AST of the target deep learning model. Accordingly, during the first round of updates, the current AST used is the original AST of the target deep learning model without any update processing. After updating all transformation subtrees, the current AST obtained is the final updated AST.

[0138] Since the data structure of the current transformation subtree is consistent with the syntax structure of the abstract syntax tree, the current transformation subtree can be directly added to the current abstract syntax tree of the target deep learning model, and a unique identifier can be set for the current transformation subtree in the current abstract syntax tree, that is, the replacement identifier.

[0139] S350. Replace all nodes that the reversible structure to be replaced depends on with the corresponding parameter positions in the current transformation subtree.

[0140] In the syntactic structure of the abstract syntax tree, the nodes that each subtree depends on are written into the specified parameter positions within that subtree to describe the dependency relationship between that subtree and other nodes. Since the reversible structure to be replaced needs to be converted into the current transformation subtree, the current transformation subtree needs to inherit all the nodes that the reversible structure to be replaced depends on.

[0141] Correspondingly, at the parameter position used to record dependent nodes in the reversible structure to be replaced, all nodes that the reversible structure to be replaced depends on can be obtained, and the node information of all the above nodes can be written into the parameter position used to record dependent nodes in the current transformation subtree to achieve inheritance of dependent nodes.

[0142] S360. In the current abstract syntax tree, identify each user node that uses the original identifier, and after modifying the original identifier used by each user node to the replacement identifier, delete the reversible structure to be replaced.

[0143] Furthermore, other nodes in the current abstract syntax tree may record their dependencies on the reversible structure of the transformation to be replaced. Therefore, these dependencies need to be redirected to the current transformation subtree. Consequently, it is possible to identify each user node using the original identifier, that is, the node that depends on the reversible structure of the transformation to be replaced, and modify the original identifier used by each user node to the replacement identifier.

[0144] After completing the above operations, it is equivalent to completely removing the dependency relationship between the reversible structure of the transformation to be replaced and the other nodes in the current abstract syntax tree. At this point, the reversible structure of the transformation to be replaced in the current abstract syntax tree can be directly deleted to obtain a new current abstract syntax tree corresponding to the target deep learning model, so as to update the new current abstract syntax tree using the new current transformation subtree.

[0145] S370. Check if the processing of all transformation subtrees is complete: if yes, proceed to S380; otherwise, return to S330.

[0146] S380. Obtain the updated abstract syntax tree corresponding to the reversible transformation form.

[0147] After confirming that all transformation subtrees have been processed, the most recently generated current abstract syntax tree is used as the updated abstract syntax tree corresponding to the reversible transformation form.

[0148] The technical solution of this invention provides a new technology for automatically implementing reversible transformations in a non-intrusive manner. This involves obtaining the abstract syntax tree of the target deep learning model and a defined reversible transformation form; generating target injection code to convert each reversible transformation structure into a matching reversible transformation pattern based on the reversible transformation form; generating a transformation subtree corresponding to each target injection code; and updating the abstract syntax tree of the target deep learning model based on each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form. This provides a simple and flexible implementation method that can be effectively generalized and extended to more machine learning models or application scenarios.

[0149] Example 4

[0150] Figure 4 This is a schematic diagram of a non-intrusive reversible transformation device for a deep learning model provided in Embodiment 4 of the present invention. Figure 4 As shown, the device includes: a reversible conversion form acquisition module 410, a target injection code generation module 420, and an updated abstract syntax tree generation module 430, wherein:

[0151] The reversible transformation form acquisition module 410 is used to acquire the abstract syntax tree of the target deep learning model and the set reversible transformation form;

[0152] In this context, the nodes in the abstract syntax tree correspond to operators in the target deep learning model, and the reversible transformation form includes: at least one reversible transformation structure in the target deep learning model, and a unique reversible transformation pattern corresponding to each reversible transformation structure; the reversible transformation structure is a branchless structure containing at least one node.

[0153] The target injection code generation module 420 is used to generate target injection code for converting each reversible transformation structure into a matching reversible transformation mode according to the reversible transformation form.

[0154] The abstract syntax tree generation module 430 is used to generate a transformation subtree corresponding to each target injection code, and to update the abstract syntax tree of the target deep learning model according to each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form.

[0155] The technical solution of this invention provides a new technology for automatically implementing reversible transformations in a non-intrusive manner. This involves obtaining the abstract syntax tree of the target deep learning model and a defined reversible transformation form; generating target injection code to convert each reversible transformation structure into a matching reversible transformation pattern based on the reversible transformation form; generating a transformation subtree corresponding to each target injection code; and updating the abstract syntax tree of the target deep learning model based on each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form. This provides a simple and flexible implementation method that can be effectively generalized and extended to more machine learning models or application scenarios.

[0156] Based on the above embodiments, the target injection code generation module 420 can be specifically used for:

[0157] Obtain the current reversible structure and the current reversible transformation pattern that matches the current reversible structure;

[0158] In the preset reversible transformation code template library, check whether there is a target reversible transformation code template for converting the current reversible transformation structure into the current reversible transformation mode;

[0159] If it is determined to exist, then target injection code corresponding to the current reversible transformation structure is generated based on the target reversible transformation code template.

[0160] Based on the above embodiments, the target injection code generation module 420 can be further specifically used for:

[0161] After checking whether there is a target reversible transformation code template for converting the current reversible transformation structure into the current reversible transformation mode, if it is determined that there is no such template, then the target reversible transformation rule for converting the current reversible transformation structure into the current reversible transformation mode is obtained from the preset reversible transformation rule library.

[0162] According to the target reversible transformation rule, generate target injection code corresponding to the current reversible transformation structure.

[0163] Based on the above embodiments, the abstract syntax tree generation module 430 is updated and can be specifically used for:

[0164] Invoke the pre-built code injector to generate a transformation subtree corresponding to each target injection code.

[0165] Based on the above embodiments, the abstract syntax tree generation module 430 is updated to be further specifically used for:

[0166] Sequentially obtain the current transformation subtree and the reversible transformation structure to be replaced that matches the current transformation subtree, and obtain the original identifier symbol corresponding to the reversible transformation structure to be replaced;

[0167] Add the current transformation subtree to the current abstract syntax tree of the target deep learning model, and set the replacement identifier corresponding to the current transformation subtree;

[0168] Replace all nodes that the reversible structure to be replaced depends on with the corresponding parameter positions in the current transformation subtree;

[0169] In the current abstract syntax tree, identify each user node that uses the original identifier, and after modifying the original identifier used by each user node to the replacement identifier, delete the reversible structure to be replaced.

[0170] Return to the previous operation and retrieve the current transformation subtree in sequence until all transformation subtrees have been processed to obtain the updated abstract syntax tree corresponding to the reversible transformation form.

[0171] Based on the above embodiments, a legality detection module may also be included, used for:

[0172] After obtaining the updated abstract syntax tree corresponding to the reversible transformation form, the compiler performs a validity check on the updated abstract syntax tree, and when it is determined that the updated abstract syntax tree passes the check, a reversible reconstruction model corresponding to the target deep learning model is generated based on the updated abstract syntax tree.

[0173] The reversible reconfiguration model was loaded into the backend system for trial operation, and trial operation results matching the reversible transformation form were obtained.

[0174] Based on the above embodiments, the legality detection module can be further used for:

[0175] After the compiler performs a validity check on the updated abstract syntax tree, if it is determined that the updated abstract syntax tree fails the check, a prompt message prohibiting reversible transformation is generated for the reversible transformation structure in the reversible transformation form and the matching reversible transformation pattern.

[0176] The non-intrusive reversible transformation device for deep learning models provided in this embodiment of the invention can execute the non-intrusive reversible transformation method for deep learning models provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method.

[0177] Example 5

[0178] Figure 5 A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0179] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0180] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0181] Processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, central processing unit (CPU), graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as performing a non-intrusive reversible transformation method for deep learning models as described in any embodiment of the present invention. That is:

[0182] Obtain the abstract syntax tree of the target deep learning model and the defined reversible transformation form; wherein, the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, and the reversible transformation form includes: at least one reversible transformation structure in the target deep learning model, and a unique reversible transformation pattern corresponding to each reversible transformation structure; the reversible transformation structure is a branchless structure containing at least one node; according to the reversible transformation form, generate target injection code for converting each reversible transformation structure into a matching reversible transformation pattern; generate a transformation subtree corresponding to each target injection code, and update the abstract syntax tree of the target deep learning model according to each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form.

[0183] In some embodiments, a non-intrusive reversible transformation method for deep learning models, as described in any embodiment of the present invention, can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the non-intrusive reversible transformation method for deep learning models described above as described in any embodiment of the present invention can be performed. Alternatively, in other embodiments, processor 11 can be configured by any other suitable means (e.g., by means of firmware) to perform the non-intrusive reversible transformation method for deep learning models as described in any embodiment of the present invention.

[0184] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0185] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0186] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0187] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0188] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0189] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0190] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0191] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A non-intrusive reversible transformation method for deep learning models, characterized in that, include: Obtain the abstract syntax tree of the target deep learning model and the defined reversible transformation form; In this context, the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, and the reversible transformation form includes: at least one reversible transformation structure in the target deep learning model, and a unique reversible transformation pattern corresponding to each reversible transformation structure; the reversible transformation structure is a branchless structure containing at least one node. Based on the reversible transformation form, target injection code is generated to convert each reversible transformation structure into a matching reversible transformation pattern. Generate a transformation subtree corresponding to each target injection code, and update the abstract syntax tree of the target deep learning model according to each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form; Specifically, the abstract syntax tree of the target deep learning model is updated based on each transformation subtree to obtain an updated abstract syntax tree corresponding to the reversible transformation form, including: Sequentially obtain the current transformation subtree and the reversible transformation structure to be replaced that matches the current transformation subtree, and obtain the original identifier symbol corresponding to the reversible transformation structure to be replaced; Add the current transformation subtree to the current abstract syntax tree of the target deep learning model, and set the replacement identifier corresponding to the current transformation subtree; Replace all nodes that the reversible structure to be replaced depends on with the corresponding parameter positions in the current transformation subtree; In the current abstract syntax tree, identify each user node that uses the original identifier, and after modifying the original identifier used by each user node to the replacement identifier, delete the reversible structure to be replaced. Return to the previous operation and retrieve the current transformation subtree sequentially until all transformation subtrees have been processed to obtain the updated abstract syntax tree corresponding to the reversible transformation form.

2. The method according to claim 1, characterized in that, Based on the reversible transformation form, target injection code is generated to convert each reversible transformation structure into a matching reversible transformation pattern, including: Obtain the current reversible structure and the current reversible transformation pattern that matches the current reversible structure; In the preset reversible transformation code template library, check whether there is a target reversible transformation code template for converting the current reversible transformation structure into the current reversible transformation mode; If so, then based on the target reversible transformation code template, generate the target injection code corresponding to the current reversible transformation structure.

3. The method according to claim 2, characterized in that, After checking whether a target reversible transformation code template exists in the preset reversible transformation code template library to convert the current reversible transformation structure into the current reversible transformation mode, the following steps are also included: If not, then retrieve the target reversible transformation rule from the preset reversible transformation rule library to transform the current reversible transformation structure into the current reversible transformation mode; According to the target reversible transformation rule, generate target injection code corresponding to the current reversible transformation structure.

4. The method according to any one of claims 1-3, characterized in that, Generate a transformation subtree corresponding to each target injection code, including: Invoke the pre-built code injector to generate a transformation subtree corresponding to each target injection code.

5. The method according to claim 1, characterized in that, After obtaining the updated abstract syntax tree corresponding to the reversible transformation form, the following is also included: The compiler performs a validity check on the updated abstract syntax tree, and when the updated abstract syntax tree passes the check, a reversible reconstructed model corresponding to the target deep learning model is generated based on the updated abstract syntax tree. The reversible reconfiguration model was loaded into the backend system for trial operation, and trial operation results matching the reversible transformation form were obtained.

6. The method according to claim 5, characterized in that, After the compiler performs a validity check on the updated abstract syntax tree, the following is also included: When it is determined that updating the abstract syntax tree fails the detection, a prompt message prohibiting reversible transformation is generated for the reversible transformation structure in the reversible transformation form and the matching reversible transformation mode.

7. A non-intrusive reversible transformation device for deep learning models, characterized in that, include: The reversible transformation form acquisition module is used to obtain the abstract syntax tree of the target deep learning model and the set reversible transformation form; In this context, the nodes in the abstract syntax tree correspond to the operators in the target deep learning model, and the reversible transformation form includes: at least one reversible transformation structure in the target deep learning model, and a unique reversible transformation pattern corresponding to each reversible transformation structure; the reversible transformation structure is a branchless structure containing at least one node. The target injection code generation module is used to generate target injection code for converting each reversible transformation structure into a matching reversible transformation pattern, based on the reversible transformation form. The abstract syntax tree generation module is updated to generate a transformation subtree corresponding to each target injection code, and the abstract syntax tree of the target deep learning model is updated according to each transformation subtree to obtain the updated abstract syntax tree corresponding to the reversible transformation form. Specifically, the module for updating the abstract syntax tree generation is used for: Sequentially obtain the current transformation subtree and the reversible transformation structure to be replaced that matches the current transformation subtree, and obtain the original identifier symbol corresponding to the reversible transformation structure to be replaced; Add the current transformation subtree to the current abstract syntax tree of the target deep learning model, and set the replacement identifier corresponding to the current transformation subtree; Replace all nodes that the reversible structure to be replaced depends on with the corresponding parameter positions in the current transformation subtree; In the current abstract syntax tree, identify each user node that uses the original identifier, and after modifying the original identifier used by each user node to the replacement identifier, delete the reversible structure to be replaced. Return to the previous operation and retrieve the current transformation subtree sequentially until all transformation subtrees have been processed to obtain the updated abstract syntax tree corresponding to the reversible transformation form.

8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the non-intrusive reversible transformation method for deep learning models according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the non-intrusive reversible transformation method for deep learning models as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Smart contract processing method and device, medium and electronic equipment

    CN112104709A

  • Model code conversion method and device, equipment and storage medium

    CN117251164A