Reversible structure recognition method, device, equipment and medium in deep learning model
By analyzing the abstract syntax tree and directed acyclic graph of the deep learning model, it automatically identifies and constructs reversible structures and conversion patterns, solves the problem of low manual recognition efficiency in the existing technology, and realizes the optimization and backpropagation of the deep learning model. Computational improvements.
Patent Information
- Application Number
- CN202410789231.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-06-19
AI Technical Summary
When optimizing the backpropagation calculation of a deep learning model, the existing technology relies on manual identification of reversible structures, which is inefficient and easy to miss, resulting in the inability to achieve full optimization.
By obtaining the abstract syntax tree of the deep learning model, generate a directed acyclic graph, analyze node dependencies, determine reversible candidate structures, filter out illegal structures, and build a reversible transformation pattern set based on the black and white list to automatically identify and build reversibility Reconstruct the model and conduct trial runs to screen for practical reversible structures and transformation patterns.
It can realize automatic identification of legal reversible structures in deep learning models without manual operation, maximize the mining of reversible structures and conversion patterns, optimize backpropagation calculations, and improve model training efficiency.
Smart Images

Figure CN118364891B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a reversible structure recognition method, device, equipment and medium in a deep learning model. Background Art
[0002] As deep learning (DL) models rapidly evolve in size and complexity, the requirements for overall system performance are increasing. The training of deep learning models involves forward computation for inference and backpropagation computation for gradient computation, which is critical for updating parameters. Backpropagation computation accounts for about 2 / 3 of the total computational load and introduces a large amount of additional storage requirements to cache intermediate activation values. Therefore, backpropagation computation is not only a bottleneck for computing resources in deep learning model training, but also a bottleneck for storage and bandwidth resources.
[0003] In the prior art, reversible patterns can be used to optimize the back propagation calculation of deep learning models. By converting certain local structures (also called reversible structures) in deep learning models into reversible patterns, the need for accumulated storage activations can be effectively eliminated. Figure 1 A schematic diagram of a reversible mode in the prior art is shown in FIG. Figure 1 As shown, in the reversible mode, when performing forward calculation, Y1 and Y2 can be obtained by normal calculation of X1 and X2. At the same time, when performing back propagation calculation, the gradients of X1 and X2 can also be obtained by calculating the gradients of Y1 and Y2 without the need for assistance from other calculation results.
[0004] However, when using reversible modes to optimize deep learning models, existing technologies often rely on developers to visually identify reversible structures in deep learning models that can undergo reversible mode conversion. This implementation method is highly dependent on the actual experience of developers and has very high labor costs. At the same time, this manual identification method often misses many reversible structures in deep learning models and cannot fully optimize backpropagation calculations. Summary of the invention
[0005] The present invention provides a method, device, equipment and medium for identifying reversible structures in a deep learning model, so as to realize automatic identification of legal and effective reversible structures in the deep learning model.
[0006] According to one aspect of an embodiment of the present invention, a method for identifying a reversible structure in a deep learning model is provided, comprising:
[0007] Obtain an abstract syntax tree corresponding to the target deep learning model, and generate a directed acyclic graph according to the abstract syntax tree, wherein nodes in the abstract syntax tree correspond to operators in the target deep learning model;
[0008] Performing structural analysis on the directed acyclic graph to determine the dependency relationship between nodes, and determining a reversible candidate structure corresponding to each node based on the dependency relationship; wherein the reversible candidate structure is a branchless structure containing at least one node;
[0009] Among all the reversible candidate structures, the reversible candidate structures that do not meet the legality detection conditions are filtered out to obtain legal reversible candidate structures, and the reversible transformation pattern sets corresponding to each legal reversible candidate structure are determined according to the black and white lists;
[0010] According to the reversible transformation pattern set corresponding to each legal reversible candidate structure, multiple reversible reconstruction models corresponding to the target deep learning model are constructed;
[0011] Each reversible reconstruction model is loaded into the back-end system for trial operation, and the target reversible structures that can be measured and the target reversible conversion pattern set corresponding to the target reversible structures are screened out according to the trial operation results.
[0012] According to another aspect of an embodiment of the present invention, a reversible structure recognition device in a deep learning model is also provided, comprising:
[0013] A directed acyclic graph generation module, used to obtain an abstract syntax tree corresponding to a target deep learning model, and generate a directed acyclic graph according to the abstract syntax tree, wherein nodes in the abstract syntax tree correspond to operators in the target deep learning model;
[0014] A reversible candidate structure determination module is used to perform structural analysis on the directed acyclic graph, determine the dependency relationship between each node, and determine the reversible candidate structure corresponding to each node according to the dependency relationship; wherein the reversible candidate structure is a branchless structure containing at least one node;
[0015] A reversible conversion pattern set determination module is used to filter out reversible candidate structures that do not meet the legality detection conditions from all reversible candidate structures, obtain legal reversible candidate structures, and determine the reversible conversion pattern set corresponding to each legal reversible candidate structure according to the black and white lists;
[0016] A reversible reconstruction model construction module is used to construct multiple reversible reconstruction models corresponding to the target deep learning model according to the reversible transformation pattern set corresponding to each legal reversible candidate structure;
[0017] The target reversible transformation pattern set screening module is used to load each reversible reconstruction model into the back-end system for trial operation, and screen out each target reversible structure that is actually available and the target reversible transformation pattern set corresponding to the target reversible structure according to the trial operation results.
[0018] According to another aspect of an embodiment of the present invention, an electronic device is provided, the electronic device comprising:
[0019] at least one processor; and
[0020] a memory communicatively connected to the at least one processor; wherein,
[0021] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the reversible structure recognition method in the deep learning model described in any embodiment of the present invention.
[0022] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the reversible structure recognition method in the deep learning model described in any embodiment of the present invention when executed.
[0023] The technical solution of the embodiment of the present invention determines all reversible candidate structures by analyzing the dependencies between each node in the target deep learning model; filters out the reversible candidate structures that do not meet the legitimacy detection conditions to obtain legal reversible candidate structures, and determines the reversible transformation pattern sets corresponding to each legal reversible candidate structure according to the black and white lists; constructs multiple reversible reconstruction models corresponding to the target deep learning model according to the reversible transformation pattern sets corresponding to each legal reversible candidate structure, and runs them in the back-end system for trial operation, and screens out the target reversible structures that are actually available and the target reversible transformation pattern sets corresponding to the target reversible structures according to the trial operation results. Without any manual operation, the automatic identification of legal and valid reversible structures in the deep learning model can be realized, and all available reversible structures in the deep learning model and the reversible transformation pattern sets corresponding to the reversible structures can be mined to the greatest extent, thereby providing accurate and effective data preparation for finally obtaining the optimal reversible transformation form for a specific deep learning model.
[0024] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0026] Figure 1 It is a structural schematic diagram of a reversible mode in the prior art;
[0027] Figure 2 is a flowchart of a reversible structure recognition method in a deep learning model provided according to Embodiment 1 of the present invention;
[0028] Figure 3 is a flowchart of another reversible structure recognition method in a deep learning model provided according to Embodiment 2 of the present invention;
[0029] Figure 4 It is a schematic diagram of conversion from a directed acyclic graph to a post-dominator tree applicable to an embodiment of the present invention;
[0030] Figure 5 is a structural schematic diagram of a reversible structure recognition device in a deep learning model provided according to Embodiment 3 of the present invention;
[0031] Figure 6 It is a structural schematic diagram of an electronic device for implementing the reversible structure recognition method in the deep learning model of an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0033] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0034] Embodiment 1
[0035] Figure 2This is a flowchart of a reversible structure recognition method in a deep learning model provided in the first embodiment of the present invention. This embodiment can be applied to the case where all the reversible structures that can be measured and used are automatically recognized in a specific deep learning model, as well as the reversible patterns corresponding to each reversible structure. This method can be performed by a reversible structure recognition device in a deep learning model. The device can be implemented in the form of hardware and / or software and can generally be configured in an electronic device with data processing functions. Figure 2 As shown, the method includes:
[0036] S210, obtaining an abstract syntax tree corresponding to the target deep learning model, and generating a directed acyclic graph according to the abstract syntax tree, wherein the nodes in the abstract syntax tree correspond to the operators in the target deep learning model.
[0037] In this embodiment, the target deep learning model refers to a machine learning model that needs to use one or more reversible modes to replace the set local structure in order to efficiently perform back propagation calculations, wherein the above-mentioned replacement process is called a reversible transformation. The reversible mode refers to a specific subnet architecture that can use the gradient tensor of the output position and the accompanying tensor transmitted through its own structure to synthesize the gradient to eliminate the accumulated storage activation. At present, reversible modes of various network structures have been developed, such as additive reversible mode, affine reversible mode, or momentum reversible mode, etc., which are not limited in this embodiment.
[0038] Specifically, in the target deep learning model, the local structure that is used to be reversibly transformed by the reversible mode of the set structure is called a reversible structure.
[0039] The Abstract Syntax Tree (AST) is a tree representation of the abstract syntax structure of the source code. Each node in the tree represents a structure in the source code. In the field of machine learning, we can use AST to represent the structure of the machine learning model, and then build or parse the machine learning model by traversing the AST. When using AST to represent the target deep learning model, each node in the AST represents each operator in the target deep learning model.
[0040] 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 there are directional edge links (directed edges) between the nodes of the graph, and there are no multiple edges linked to form a ring in the form of a cycle.
[0041] Among them, the directed acyclic graph contains multiple nodes, and each node is connected by a directed edge. Each node in the directed acyclic graph also corresponds to each operator in the target deep learning model.
[0042] S220: Perform structural analysis on the directed acyclic graph to determine the dependency relationship between nodes, and determine a reversible candidate structure corresponding to each node according to the dependency relationship, wherein the reversible candidate structure is a branchless structure including at least one node.
[0043] As mentioned above, the edge links connecting two nodes in a directed acyclic graph are directional, that is, two nodes are connected by a directed edge with an arrow, where the node in the direction where the arrow ends depends on the node in the direction where the arrow starts. For example, if in the target deep learning model, a convolution calculation is first performed on the input data x and y to obtain the calculation result z, and then the calculation result z is normalized to obtain the calculation result k. It can be seen that the execution of the normalization operator depends on the execution result of the convolution operator. Therefore, in the directed acyclic graph corresponding to the target deep learning model, in the directed edge composed of node A corresponding to the convolution operator and node B corresponding to the normalization operator, the arrow points from node A to node B.
[0044] Correspondingly, after obtaining the directed acyclic graph corresponding to the target deep learning model, the dependency relationship between the nodes can be determined by analyzing the directionality of each directed edge between the nodes in the directed acyclic graph.
[0045] The inventors have found through research that if a local structure in the target deep learning model can be used as a reversible structure, then the subgraph corresponding to this local structure in the directed acyclic graph should be a branchless structure from the perspective of data topology. That is, this local structure contains multiple nodes, and after taking this local structure as a whole, this local structure has no directed edges flowing into the local structure or out of the local structure except the initial input edge (which may be one or more) and the final output edge (which may be one or more), that is, the local structure as a whole is a branchless structure.
[0046] It is understandable that a branchless structure is a necessary condition for a local structure to be a final reversible structure. Therefore, firstly, based on the dependency relationship between the nodes defined in the directed acyclic graph, all candidate structures that can be used as the final reversible structure corresponding to the target deep learning model, that is, reversible candidate structures, can be determined.
[0047] S230, among all reversible candidate structures, filter out reversible candidate structures that do not meet the legality detection conditions to obtain legal reversible candidate structures, and determine the reversible conversion pattern set corresponding to each legal reversible candidate structure according to the black and white lists.
[0048] The inventors further discovered that the reversible structure that can be reversibly converted using the reversible mode also needs to meet certain necessary conditions in terms of data capacity, data size or mathematical properties. Accordingly, in the embodiments of the invention, corresponding legality detection conditions can be constructed based on one or more of the necessary conditions that need to be met.
[0049] Furthermore, all reversible candidate structures can be screened once based on the above-mentioned legality detection conditions to obtain legal reversible candidate structures that meet each legality detection condition.
[0050] The reversible conversion mode set includes one or more reversible conversion modes, and one reversible conversion mode set corresponds to one legal reversible candidate structure. The reversible conversion mode can be understood as a reversible mode that can reversibly convert the adapted legal reversible candidate structure.
[0051] In this embodiment, the black and white list can be a pre-established reversible conversion mode white list and a pre-established reversible conversion mode black list. In the reversible conversion mode white list, all reversible modes corresponding to each reversible structure under the broadest conditions are defined, that is, all reversible modes that can be used to reversibly convert a reversible structure without considering other limiting conditions; in the reversible conversion mode black list, invalid reversible modes that cannot be effectively reversibly converted under each algorithm model scenario are defined.
[0052] Specifically, the algorithm model scenario may include: a Transformers model scenario, a TorchVision model scenario, or a Pytorch model scenario, etc., which is not limited in this embodiment.
[0053] By combining the target algorithm model scenario using the target deep learning model, and the black and white lists, it is possible to determine the reversible transformation pattern set corresponding to each legal reversible candidate structure under the target algorithm model scenario, that is, to determine all reversible transformation patterns that can theoretically reversibly transform the legal reversible candidate structures.
[0054] S240. Construct multiple reversible reconstruction models corresponding to the target deep learning model according to the reversible transformation pattern sets corresponding to each legal reversible candidate structure.
[0055] It can be understood that the reversible transformation pattern set corresponding to each legal reversible candidate structure determined by the above operation is a set of theoretically available reversible transformation patterns, but the availability of such reversible transformation cannot be guaranteed in the actual operation of the model. Therefore, in an embodiment of the present invention, a reversible reconstruction model after the target deep learning model is reversibly transformed can be constructed according to the reversible transformation pattern set corresponding to each legal reversible candidate structure. By trial running these reversible reconstruction models, the target reversible structures that are actually available can be screened out, as well as one or more target reversible transformation patterns corresponding to each target reversible structure.
[0056] In a specific example, after determining a legal reversible candidate structure A and a reversible transformation pattern set {reversible transformation pattern B1, reversible transformation pattern B2} corresponding to the legal reversible candidate structure A, the reversible candidate structure A in the target deep learning model can be reversibly transformed using the reversible transformation pattern B1 to obtain a reversible reconstruction model C1. At the same time, the reversible candidate structure A in the target deep learning model can also be reversibly transformed using the reversible transformation pattern B2 to obtain a reversible reconstruction model C2. It can be understood that the total number of reversible reconstruction models finally constructed is the cumulative sum of the number of reversible transformation patterns contained in each reversible transformation pattern set corresponding to each legal reversible candidate structure.
[0057] In this embodiment, after obtaining a specific legal reversible candidate structure and a specific reversible transformation pattern corresponding to the specific legal reversible candidate structure, an invasive transformation method can be used to construct a corresponding reversible reconstruction model, or a non-invasive transformation method can be used to construct the reversible reconstruction model. This embodiment does not limit this.
[0058] Specifically, the intrusive conversion method can be understood as a method of modifying the source code of the target deep learning model to achieve the construction of the reversible reconstruction model, while the non-intrusive conversion method can be understood as the need to modify the source code of the target deep learning model. By using compiler technology, the corresponding reversible reconstruction model is automatically generated after the source code of the target deep learning model is input.
[0059] S250, loading each reversible reconstruction model into the back-end system for trial operation, and screening out each target reversible structure that is actually available and a target reversible conversion pattern set corresponding to the target reversible structure according to the trial operation result.
[0060] Among them, the backend system can be understood as a physical execution device for loading and executing the set machine learning model. The trial run can be understood as loading the set reversible reconstruction model to the actual execution device, and controlling the execution device to execute the set time (for example, 10 minutes, 20 minutes or 1 hour, etc.) or controlling the execution device to reach the set calculation target (for example, one round of model training). At the same time, it is necessary to detect whether the set reversible reconstruction model can be executed normally during the execution process based on the set time or the set calculation target. For example, check whether there are abnormal errors during the test run.
[0061] Specifically, the trial operation result may be normal operation or abnormal operation. Assuming that the trial operation result of the reversible reconstruction model A is abnormal operation, after extracting the legal reversible candidate structure a1 and the corresponding reversible transformation mode a2 corresponding to the reversible reconstruction model A, the reversible transformation mode a2 is deleted from the reversible transformation mode set corresponding to the legal reversible candidate structure a1. When the reversible transformation mode set corresponding to a legal reversible candidate structure X does not contain any reversible transformation mode, the legal reversible candidate structure X can be directly filtered out accordingly.
[0062] After completing the trial run of the reversible reconstruction model, the legal reversible candidate structures remaining after screening based on the trial run results can be determined as target reversible structures, and the reversible conversion modes remaining after screening of each target reversible structure can be combined and added to the matching target reversible conversion mode set.
[0063] The technical solution of the embodiment of the present invention determines all reversible candidate structures by analyzing the dependencies between each node in the target deep learning model; filters out the reversible candidate structures that do not meet the legitimacy detection conditions to obtain legal reversible candidate structures, and determines the reversible transformation pattern sets corresponding to each legal reversible candidate structure according to the black and white lists; constructs multiple reversible reconstruction models corresponding to the target deep learning model according to the reversible transformation pattern sets corresponding to each legal reversible candidate structure, and runs them in the back-end system for trial operation, and screens out the target reversible structures that are actually available and the target reversible transformation pattern sets corresponding to the target reversible structures according to the trial operation results. Without any manual operation, the automatic identification of legal and valid reversible structures in the deep learning model can be realized, and all available reversible structures in the deep learning model and the reversible transformation pattern sets corresponding to the reversible structures can be mined to the greatest extent, thereby providing accurate and effective data preparation for finally obtaining the optimal reversible transformation form for a specific deep learning model.
[0064] On the basis of the above embodiments, after screening out the target reversible structures and the target reversible conversion mode set corresponding to the target reversible structures that are actually available according to the test operation results, the following may also be included:
[0065] Obtaining the operating performance description information of the backend system when executing each reversible reconstruction model;
[0066] According to the operation performance description information, at least one target replacement reversible structure and a target replacement reversible conversion mode corresponding to the target replacement reversible structure are determined from the target reversible structures and the target reversible conversion mode corresponding to the target replacement reversible structure;
[0067] According to the target replacement reversible structure and the target replacement reversible transformation pattern corresponding to the target replacement reversible structure, a target reversible reconstruction model corresponding to the target deep learning model is constructed;
[0068] The target reversible reconstruction model is loaded into the backend system for actual operation to perform model training operations.
[0069] In this optional implementation, during the process of executing each reversible reconstruction model by the backend system, the operation performance description information corresponding to each reversible reconstruction model may be recorded accordingly, wherein the operation performance description information includes: one or more of the calculation time information or the memory usage information during the calculation process.
[0070] The computing time information can be understood as the time required to complete the set computing target (for example, one round of back-propagation calculation), and the memory usage information can be understood as the average usage of the back-end system memory during the model running process.
[0071] Obviously, the smaller the values of the computation time information and memory usage information of a reversible reconstruction model are, the better the reconstruction effect of the reversible reconstruction model is.
[0072] Correspondingly, after obtaining each reversible reconstruction model that is available in actual measurement, the operating performance description information of these reversible reconstruction models during trial operation can be sorted from large to small, and one or several optimal reversible reconstruction models can be selected according to the sorting results, and the target replacement reversible structure corresponding to each optimal reversible reconstruction model and the target replacement reversible conversion mode corresponding to the target replacement reversible structure can be obtained.
[0073] It is understandable that if the number of target replacement reversible structures selected is multiple, it is necessary to ensure that there are no overlapping nodes between different target replacement reversible structures, that is, the target replacement reversible structures do not affect each other. Otherwise, the target deep learning model is replaced once using the target replacement reversible conversion mode of all target replacement reversible structures, which will result in a non-unique replacement method for overlapping nodes.
[0074] Finally, by using the above one or more target replacement reversible structures and the target replacement reversible conversion mode corresponding to the target replacement reversible structure, a target reversible reconstruction model corresponding to the target deep learning model can be constructed, that is, the final model obtained after the reversible conversion. By running the target reversible reconstruction model for actual model training, the back propagation calculation in the model training process can be effectively optimized.
[0075] It is understandable that the above-mentioned target deep learning model can be a machine learning model applied in various fields such as computer vision (for example, image classification, target detection or face recognition, etc.), natural language processing (for example, text classification, sentiment analysis, machine translation, speech recognition or speech-to-text, etc.), medical field or autonomous driving field.
[0076] Embodiment 2
[0077] Figure 3 A flowchart of another method for identifying a reversible structure in a deep learning model provided in Example 2 of the present invention. This embodiment is refined on the basis of the above-mentioned embodiment, and specifically refines the operations of determining the reversible candidate structure corresponding to each node, filtering out the reversible candidate structures that do not meet the legality detection conditions among all reversible candidate structures, and determining the reversible conversion pattern set corresponding to each legal reversible candidate structure according to the black and white lists.
[0078] Correspondingly, such as Figure 3 As shown, the method includes:
[0079] S310. Obtain an abstract syntax tree corresponding to the target deep learning model, and generate a directed acyclic graph based on the abstract syntax tree.
[0080] In graph theory, if a directed graph cannot return to any vertex through several edges, then the graph is a directed acyclic graph. Any directed tree is a directed acyclic graph.
[0081] S320 , performing structural analysis on the directed acyclic graph to generate a dominator tree corresponding to the directed acyclic graph, and generating a post-dominator tree corresponding to the directed acyclic graph based on the dominator tree.
[0082] In a directed acyclic graph, for a node n, all paths from the initial node s to n pass through a node m, then m is the dominating point of n. The dominating point closest to n is called the immediate dominating point. With r as the root, all the immediate dominating points are connected according to the dominating relationship to form a dominating tree. The immediate post-dominant point is the closest node passed by all paths from a point n to the terminal node. The dominating tree formed using the immediate post-dominant point is the post-dominant tree.
[0083] Accordingly, a directed acyclic graph can be transformed into a matching post-dominator tree by using the dominator tree as an intermediary. Figure 4 A schematic diagram of a conversion from a directed acyclic graph to a post-dominant tree applicable to an embodiment of the present invention is shown in FIG. The post-dominant tree is determined based on post-dominant node information. The post-dominant node refers to a node A (for example, Figure 4 The outgoing edge of node 5 in must pass through a node B (such as Figure 4 6), then node A is the post-dominant node of node B. For example, Figure 4 Node 2, node 4 and node 5 in are all post-dominant nodes of node 6. That is, in the post-dominant tree, the post-dominant node is the parent node or ancestor node of the node being dominated.
[0084] S330, perform a pre-order traversal on the directed acyclic graph to obtain a sorted node list.
[0085] In this embodiment, according to the mutual dependence relationship between nodes defined in the directed acyclic graph, each node can be traversed in the direction from the dependent node to the dependent node to obtain a sorted node list.
[0086] Accordingly, for Figure 4 The directed acyclic graph shown can construct a sorted node list of the form: {1, 2, 3, 4, 5, 6, 7}.
[0087] S340 , sequentially obtain a node in the sorting node list as the current processing node.
[0088] S350 , query the post-dominant tree, and obtain all subgraphs starting from the current processing node and ending at the post-dominant node of the current processing node as reversible candidate structures corresponding to the current processing node.
[0089] Continuing with the previous example, further, Figure 4 As shown, nodes 1 to 5 have no post-dominant nodes. When traversing to node 6, node 6 and one, two or all of its three post-dominant nodes (i.e., node 2, node 4 and node 5) can be used to try to construct a reversible candidate structure without a branching structure.
[0090] A simple analysis shows that the subgraph composed of nodes 4 and 6, and the subgraph composed of nodes 5 and 6 are not branchless structures, and only the subgraph composed of nodes 2, 4, 5 and 6 is a branchless structure. Therefore, the subgraph composed of the above four nodes can be determined as a reversible candidate structure.
[0091] S360, determine whether to obtain reversible candidate structures corresponding to each node respectively: if so, execute S370; otherwise, return to execute S340.
[0092] S370. Among all reversible candidate structures, filter out reversible candidate structures that do not meet the legality detection conditions to obtain legal reversible candidate structures.
[0093] In an optional implementation of this embodiment, filtering out reversible candidate structures that do not meet the legality detection condition from all reversible candidate structures may include:
[0094] Identify the in-degree and out-degree of the candidate structure that is currently being processed;
[0095] If it is determined that any one of the in-degree and the out-degree is greater than 2, the currently processed reversible candidate structure is determined to be a reversible candidate structure that does not meet the legality detection condition, and the currently processed reversible candidate structure is filtered out.
[0096] In graph theory, the degree of a node refers to the number of edges associated with the node. In a directed graph, the degree is divided into in-degree and out-degree. In-degree refers to the number of arcs that end at a certain node, while out-degree refers to the number of arcs that start at a certain node and end at the vertex.
[0097] Similarly, the inventors discovered through research that the data capacity of various reversible structures that can be reversibly converted using existing reversible patterns have a common feature, namely, the in-degree or out-degree of each reversible structure can only be 1 or 2. When the in-degree or out-degree of a subnet structure is greater than 2, this subnet structure has no applicable reversible pattern.
[0098] Based on this, the in-degree and out-degree of each reversible candidate structure can be identified, and the reversible candidate structures with in-degree or out-degree greater than or equal to 3 can be directly filtered out.
[0099] On the basis of the above embodiments, filtering out reversible candidate structures that do not meet the legality detection condition from all reversible candidate structures may also include:
[0100] Identify the total number of elements in the two input tensors and the two output tensors currently processing the reversible candidate structure;
[0101] If it is determined that the total number of elements in the two input tensors or the two output tensors is inconsistent, the currently processed reversible candidate structure is determined to be a reversible candidate structure that does not meet the legality detection condition, and the currently processed reversible candidate structure is filtered out.
[0102] Furthermore, the inventors also discovered that when the in-degree of a reversible candidate structure is 2, the reversible candidate structure can only be reversibly transformed using the reversible mode when the total number of elements in the two input tensors of the reversible candidate structure is consistent; similarly, when the out-degree of a reversible candidate structure is 2, the reversible candidate structure can only be reversibly transformed using the reversible mode when the total number of elements in the two output tensors of the reversible candidate structure is consistent. Based on this, the capacity constraints of the input and output tensors can be used to construct matching legitimacy detection conditions.
[0103] The total number of elements in a tensor is usually called the "number of elements", "volume" or "cardinality" of the tensor, which can be obtained by calculating the product of the sizes of each dimension of the tensor. For example, tensor A can be expressed as <3*4*5,f32>, then the total number of elements in tensor A is 3*4*5=60, and the data type of each element in tensor A is float32, that is, single-precision floating point.
[0104] On the basis of the above embodiments, filtering out reversible candidate structures that do not meet the legality detection condition from all reversible candidate structures may also include:
[0105] Obtaining a transfer function matrix corresponding to the currently processed reversible candidate structure; and calculating the determinant of the transfer function matrix;
[0106] If it is determined that the determinant is less than or equal to zero, the currently processed reversible candidate structure is determined to be a reversible candidate structure that does not meet the legality detection condition, and the currently processed reversible candidate structure is filtered out.
[0107] Furthermore, the inventors conducted further research and found that another necessary condition for a reversible candidate structure to be reversibly transformed using a reversible mode is that the determinant of the transformation function matrix of the reversible candidate structure itself needs to be greater than 0. Therefore, based on this mathematical property, a matching legitimacy detection condition can be constructed accordingly.
[0108] Generally speaking, the determinant of the transfer function matrix of a reversible candidate structure can be determined by the determinants of each node (operator) contained in the reversible candidate structure. Generally speaking, the determinants of some commonly used operators are known a priori, so the determinant calculation method of some operators can be pre-encoded to achieve fast calculation of the determinant of the transfer function matrix.
[0109] The embodiment of the present invention fully explores the common features of reversible structures that cannot be reversibly transformed. On the basis of fully acquiring all reversible candidate structures, the legitimacy detection conditions constructed based on these common features can effectively screen out reversible candidate structures that are obviously unusable among all reversible candidate structures, greatly reducing the workload of subsequent operations and effectively improving the efficiency of automatic recognition of reversible structures.
[0110] S380: Obtain a set of reversible conversion candidate patterns that match each legal reversible candidate structure by querying a pre-established reversible conversion pattern whitelist.
[0111] At present, a large number of reversible structures and various reversible modes available for these reversible structures have been published in various existing academic papers. By aggregating this information, a whitelist of reversible conversion modes can be constructed accordingly.
[0112] That is, in the reversible conversion pattern whitelist, multiple reversible structures and reversible pattern sets corresponding to each reversible structure are recorded. By matching the legal reversible candidate structure with each reversible structure in the reversible conversion pattern whitelist, the reversible pattern set corresponding to the successfully matched reversible structure can be used as the reversible conversion candidate pattern set corresponding to the legal reversible candidate structure.
[0113] S390. Obtain a target algorithm model scenario that matches the target deep learning model, and obtain at least one invalid reversible conversion pattern that matches the target algorithm model scenario by querying a pre-established reversible conversion pattern blacklist.
[0114] As mentioned above, in the reversible conversion mode blacklist, various invalid reversible modes that cannot be effectively reversible converted are defined in each algorithm model scenario. Furthermore, after obtaining the target algorithm model scenario that matches the target deep learning model, by matching the target algorithm model scenario with each algorithm model scenario in the reversible conversion mode blacklist, the invalid reversible modes corresponding to the successfully matched algorithm model scenario can be used as at least one invalid reversible conversion mode that matches the target algorithm model scenario.
[0115] S3100, filtering out invalid reversible conversion patterns in each reversible conversion candidate pattern set, and obtaining a reversible conversion pattern set corresponding to each legal reversible candidate structure.
[0116] In a specific example, assuming that the target algorithm model scenario is the Transformers model scenario, and the legal reversible candidate structure currently being processed is the legal reversible candidate structure A, by querying the reversible transformation pattern whitelist, the reversible transformation pattern B1, reversible transformation pattern B2 and reversible transformation pattern B3 corresponding to the legal reversible candidate structure A can be obtained, and by querying the reversible transformation pattern blacklist, the invalid reversible mode B2 and invalid reversible mode B4 corresponding to the Transformers model scenario can be obtained.
[0117] Furthermore, by filtering out the invalid reversible mode B2 from the reversible mode B1, the reversible mode B2 and the reversible mode B3, the reversible mode set corresponding to the legal reversible candidate structure A can be obtained as {reversible mode B1, reversible mode B3}.
[0118] The advantage of this setting is that by directly using black and white lists to self-define the acquisition of known valid, or self-define the filtering of known invalid reversible conversion modes, the effect of automatic recognition of reversible structures can be effectively improved, and the recognition efficiency of reversible structures can be effectively improved.
[0119] It needs to be emphasized again that by combining the use of legitimacy detection conditions and black and white lists, the theoretical availability of each reversible candidate structure can be effectively constrained while retaining all reversible candidate structures as much as possible.
[0120] S3110. Construct multiple reversible reconstruction models corresponding to the target deep learning model based on the reversible transformation pattern sets corresponding to each legal reversible candidate structure.
[0121] In an optional implementation of this embodiment, constructing multiple reversible reconstruction models corresponding to the target deep learning model according to the reversible transformation pattern set corresponding to each legal reversible candidate structure may include:
[0122] Constructing a plurality of reversible conversion forms according to each reversible candidate structure and each reversible conversion mode corresponding to each reversible candidate structure;
[0123] Input the abstract syntax tree of the target deep learning model and each reversible transformation form into the non-intrusive reversible converter respectively;
[0124] Outputting updated abstract syntax trees obtained by reversibly transforming the target deep learning model according to each reversible transformation form through a non-intrusive reversible transformer;
[0125] Based on each updated abstract syntax tree, multiple reversible reconstruction models corresponding to the target deep learning model are constructed.
[0126] Specifically, continuing with the previous example, assuming that the reversible transformation pattern set corresponding to the legal reversible candidate structure A is {reversible transformation pattern B1, reversible transformation pattern B2}, the legal reversible candidate structure A and the 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 legal reversible candidate structure A in the target deep learning model; at the same time, the legal reversible candidate structure A and the 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 legal reversible candidate structure A in the target deep learning model.
[0127] In this embodiment, a pre-built non-intrusive reversible converter can be used. Based on the abstract syntax tree of the target deep learning model and each reversible transformation form, an updated abstract syntax tree corresponding to each reversible transformation form can be generated, and then a reversible reconstruction model corresponding to each reversible transformation form can be generated according to each updated abstract syntax tree.
[0128] Among them, the method of generating a reversible reconstruction model based on the updated abstract syntax tree can be: generating an intermediate representation of a computational graph corresponding to the updated abstract syntax tree through a deep learning compiler, and determining an intermediate computational graph hierarchy corresponding to the intermediate representation of the computational graph through an optimization pipeline inside the deep learning compiler, and then generating executable machine code or bytecode as the reversible reconstruction model for the intermediate representation of the computational graph and the intermediate computational graph hierarchy through a deep learning encoder backend.
[0129] S3120, loading each reversible reconstruction model into the back-end system for trial operation, and screening out each target reversible structure that is actually available and a target reversible conversion pattern set corresponding to the target reversible structure according to the trial operation result.
[0130] Furthermore, after obtaining the target reversible structures that are actually available and the target reversible transformation pattern set corresponding to the target reversible structures, an optimal reversible transformation form can be traversed through global optimization, and the reversible reconstruction model corresponding to the global optimal reversible transformation form can be used to replace the target neural network model, and the model training operation can be performed in the back-end system.
[0131] The technical solution of the embodiment of the present invention determines all reversible candidate structures by analyzing the dependencies between each node in the target deep learning model; filters out the reversible candidate structures that do not meet the legitimacy detection conditions to obtain legal reversible candidate structures, and determines the reversible transformation pattern sets corresponding to each legal reversible candidate structure according to the black and white lists; constructs multiple reversible reconstruction models corresponding to the target deep learning model according to the reversible transformation pattern sets corresponding to each legal reversible candidate structure, and runs them in the back-end system for trial operation, and screens out the target reversible structures that are actually available and the target reversible transformation pattern sets corresponding to the target reversible structures according to the trial operation results. Without any manual operation, the automatic identification of legal and valid reversible structures in the deep learning model can be realized, and all available reversible structures in the deep learning model and the reversible transformation pattern sets corresponding to the reversible structures can be mined to the greatest extent, thereby providing accurate and effective data preparation for finally obtaining the optimal reversible transformation form for a specific deep learning model.
[0132] Embodiment 3
[0133] Figure 5 This is a schematic diagram of the structure of a reversible structure recognition device in a deep learning model provided by the third embodiment of the present invention. Figure 5 As shown, the device includes: a directed acyclic graph generation module 510, a reversible candidate structure determination module 520, a reversible transformation pattern set determination module 530, a reversible reconstruction model construction module 540 and a target reversible transformation pattern set screening module 550, wherein:
[0134] A directed acyclic graph generation module 510, used to obtain an abstract syntax tree corresponding to a target deep learning model, and generate a directed acyclic graph according to the abstract syntax tree, wherein nodes in the abstract syntax tree correspond to operators in the target deep learning model;
[0135] The reversible candidate structure determination module 520 is used to perform structural analysis on the directed acyclic graph, determine the dependency relationship between the nodes, and determine the reversible candidate structure corresponding to each node according to the dependency relationship; wherein the reversible candidate structure is a branchless structure including at least one node;
[0136] The reversible conversion pattern set determination module 530 is used to filter out the reversible candidate structures that do not meet the legality detection conditions from all the reversible candidate structures, obtain legal reversible candidate structures, and determine the reversible conversion pattern set corresponding to each legal reversible candidate structure according to the black and white lists;
[0137] A reversible reconstruction model construction module 540 is used to construct multiple reversible reconstruction models corresponding to the target deep learning model according to the reversible transformation pattern set corresponding to each legal reversible candidate structure;
[0138] The target reversible transformation pattern set screening module 550 is used to load each reversible reconstruction model into the backend system for trial operation, and screen out each target reversible structure that is actually available and the target reversible transformation pattern set corresponding to the target reversible structure according to the trial operation result.
[0139] The technical solution of the embodiment of the present invention determines all reversible candidate structures by analyzing the dependencies between each node in the target deep learning model; filters out the reversible candidate structures that do not meet the legitimacy detection conditions to obtain legal reversible candidate structures, and determines the reversible transformation pattern sets corresponding to each legal reversible candidate structure according to the black and white lists; constructs multiple reversible reconstruction models corresponding to the target deep learning model according to the reversible transformation pattern sets corresponding to each legal reversible candidate structure, and runs them in the back-end system for trial operation, and screens out the target reversible structures that are actually available and the target reversible transformation pattern sets corresponding to the target reversible structures according to the trial operation results. Without any manual operation, the automatic identification of legal and valid reversible structures in the deep learning model can be realized, and all available reversible structures in the deep learning model and the reversible transformation pattern sets corresponding to the reversible structures can be mined to the greatest extent, thereby providing accurate and effective data preparation for finally obtaining the optimal reversible transformation form for a specific deep learning model.
[0140] Based on the above embodiments, the reversible candidate structure determination module 520 can be specifically used for:
[0141] Performing structural analysis on the directed acyclic graph, generating a dominator tree corresponding to the directed acyclic graph, and generating a post-dominator tree corresponding to the directed acyclic graph based on the dominator tree;
[0142] Perform a pre-order traversal of the directed acyclic graph to obtain a sorted node list;
[0143] Sequentially obtain a node in the sorting node list as the current processing node;
[0144] Query the post-dominator tree to obtain all subgraphs starting from the current processing node and ending at the post-dominator node of the current processing node as the reversible candidate structure corresponding to the current processing node;
[0145] Return to the operation of obtaining a node in the sorted node list in execution order as the current processing node until the reversible candidate structure corresponding to each node is obtained.
[0146] Based on the above embodiments, the reversible conversion mode set determination module 530 can be specifically used to:
[0147] Identify the in-degree and out-degree of the candidate structure that is currently being processed;
[0148] If it is determined that any one of the in-degree and the out-degree is greater than 2, the currently processed reversible candidate structure is determined to be a reversible candidate structure that does not meet the legality detection condition, and the currently processed reversible candidate structure is filtered out.
[0149] Based on the above embodiments, the reversible conversion mode set determination module 530 can be specifically used to:
[0150] Identify the total number of elements in the two input tensors and the two output tensors currently processing the reversible candidate structure;
[0151] If it is determined that the total number of elements in the two input tensors or the two output tensors is inconsistent, the currently processed reversible candidate structure is determined to be a reversible candidate structure that does not meet the legality detection condition, and the currently processed reversible candidate structure is filtered out.
[0152] Based on the above embodiments, the reversible conversion mode set determination module 530 can be specifically used to:
[0153] Obtaining a transfer function matrix corresponding to the currently processed reversible candidate structure; and calculating the determinant of the transfer function matrix;
[0154] If it is determined that the determinant is less than or equal to zero, the currently processed reversible candidate structure is determined to be a reversible candidate structure that does not meet the legality detection condition, and the currently processed reversible candidate structure is filtered out.
[0155] Based on the above embodiments, the reversible conversion mode set determination module 530 can be specifically used to:
[0156] By querying a pre-established reversible transformation pattern whitelist, a set of reversible transformation candidate patterns that match each legal reversible candidate structure is obtained;
[0157] Obtain a target algorithm model scenario that matches the target deep learning model, and obtain at least one invalid reversible conversion mode that matches the target algorithm model scenario by querying a pre-established reversible conversion mode blacklist;
[0158] In each reversible transformation candidate pattern set, invalid reversible transformation patterns are filtered out respectively to obtain a reversible transformation pattern set corresponding to each legal reversible candidate structure.
[0159] Based on the above embodiments, the reversible reconstruction model building module 540 can be specifically used for:
[0160] Constructing a plurality of reversible conversion forms according to each reversible candidate structure and each reversible conversion mode corresponding to each reversible candidate structure;
[0161] Input the abstract syntax tree of the target deep learning model and each reversible transformation form into the non-intrusive reversible converter respectively;
[0162] Outputting updated abstract syntax trees obtained by reversibly transforming the target deep learning model according to each reversible transformation form through a non-intrusive reversible transformer;
[0163] Based on each updated abstract syntax tree, multiple reversible reconstruction models corresponding to the target deep learning model are constructed.
[0164] On the basis of the above embodiments, a target reversible reconstruction model generation module may also be included, which is used to:
[0165] After screening out the target reversible structures that are actually available and the target reversible conversion pattern set corresponding to the target reversible structures according to the test operation results, obtaining the operation performance description information of the back-end system when executing each reversible reconstruction model;
[0166] According to the operation performance description information, at least one target replacement reversible structure and a target replacement reversible conversion mode corresponding to the target replacement reversible structure are determined from the target reversible structures and the target reversible conversion mode corresponding to the target replacement reversible structure;
[0167] According to the target replacement reversible structure and the target replacement reversible transformation pattern corresponding to the target replacement reversible structure, a target reversible reconstruction model corresponding to the target deep learning model is constructed;
[0168] The target reversible reconstruction model is loaded into the backend system for actual operation to perform model training operations.
[0169] The reversible structure recognition device in the deep learning model provided in the embodiment of the present invention can execute the reversible structure recognition method in the deep learning model provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0170] Embodiment 4
[0171] Figure 6A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment 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 processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0172] like Figure 6 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0173] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0174] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, for example, executing the reversible structure recognition method in the deep learning model described in any embodiment of the present invention.
[0175] In some embodiments, the reversible structure recognition method in the deep learning model as described in any embodiment of the present invention may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the reversible structure recognition method in the deep learning model as described in any embodiment of the present invention described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the reversible structure recognition method in the deep learning model as described in any embodiment of the present invention in any other appropriate manner (e.g., by means of firmware).
[0176] That is, an abstract syntax tree corresponding to the target deep learning model is obtained, and a directed acyclic graph is generated according to the abstract syntax tree, wherein the nodes in the abstract syntax tree correspond to the operators in the target deep learning model;
[0177] Performing structural analysis on the directed acyclic graph to determine the dependency relationship between nodes, and determining a reversible candidate structure corresponding to each node based on the dependency relationship; wherein the reversible candidate structure is a branchless structure containing at least one node;
[0178] Among all the reversible candidate structures, the reversible candidate structures that do not meet the legality detection conditions are filtered out to obtain legal reversible candidate structures, and the reversible transformation pattern sets corresponding to each legal reversible candidate structure are determined according to the black and white lists;
[0179] According to the reversible transformation pattern set corresponding to each legal reversible candidate structure, multiple reversible reconstruction models corresponding to the target deep learning model are constructed;
[0180] Each reversible reconstruction model is loaded into the back-end system for trial operation, and the target reversible structures that can be measured and the target reversible conversion pattern set corresponding to the target reversible structures are screened out according to the trial operation results.
[0181] Various implementations 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 chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0182] Computer programs for implementing 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, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0183] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0184] To provide interaction with a user, the systems and techniques described herein may 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 a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0185] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0186] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0187] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0188] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A reversible structure recognition method in a deep learning model, It is characterized in that include: Obtain an abstract syntax tree corresponding to the target deep learning model, and generate a directed acyclic graph according to the abstract syntax tree, wherein nodes in the abstract syntax tree correspond to operators in the target deep learning model; The target deep learning model is applied in the fields of image classification, target detection, face recognition, text classification, machine translation or speech recognition; Performing structural analysis on the directed acyclic graph to determine the dependency relationship between nodes, and determining a reversible candidate structure corresponding to each node based on the dependency relationship; wherein the reversible candidate structure is a branchless structure containing at least one node; Among all the reversible candidate structures, the reversible candidate structures that do not meet the legality detection conditions are filtered out to obtain legal reversible candidate structures, and the reversible transformation pattern sets corresponding to each legal reversible candidate structure are determined according to the black and white lists; According to the reversible transformation pattern set corresponding to each legal reversible candidate structure, multiple reversible reconstruction models corresponding to the target deep learning model are constructed; Load each reversible reconstruction model into the back-end system for trial operation, and screen out each target reversible structure that can be measured and the target reversible conversion pattern set corresponding to the target reversible structure according to the trial operation result; The back-end system is a physical execution device. The trial operation refers to loading the set reversible reconstruction model into the execution device and controlling the execution device to execute for a set time or control the execution device to achieve a set calculation target, detecting whether the set reversible reconstruction model can be executed normally. The trial operation result includes normal operation or abnormal operation.
2. The method according to claim 1, It is characterized in that Perform structural analysis on the directed acyclic graph to determine the dependencies between nodes, and based on the dependencies, determine the reversible candidate structures corresponding to each node, including: Performing structural analysis on the directed acyclic graph, generating a dominator tree corresponding to the directed acyclic graph, and generating a post-dominator tree corresponding to the directed acyclic graph based on the dominator tree; Perform a pre-order traversal of the directed acyclic graph to obtain a sorted node list; Sequentially obtain a node in the sorting node list as the current processing node; Query the post-dominator tree to obtain all subgraphs starting from the current processing node and ending at the post-dominator node of the current processing node as the reversible candidate structure corresponding to the current processing node; Return to the operation of obtaining a node in the sorted node list in execution order as the current processing node until the reversible candidate structure corresponding to each node is obtained.
3. The method according to claim 1, It is characterized in that Among all reversible candidate structures, filter out those that do not meet the legality detection conditions, including: Identify the in-degree and out-degree of the candidate structure that is currently being processed; If it is determined that any one of the in-degree and the out-degree is greater than 2, the currently processed reversible candidate structure is determined to be a reversible candidate structure that does not meet the legality detection condition, and the currently processed reversible candidate structure is filtered out.
4. The method according to claim 1, It is characterized in that Among all reversible candidate structures, filter out those that do not meet the legality detection conditions, including: Identify the total number of elements in the two input tensors and the two output tensors currently processing the reversible candidate structure; If it is determined that the total number of elements in the two input tensors or the two output tensors is inconsistent, the currently processed reversible candidate structure is determined to be a reversible candidate structure that does not meet the legality detection condition, and the currently processed reversible candidate structure is filtered out.
5. The method according to claim 1, It is characterized in that Among all reversible candidate structures, filter out those that do not meet the legality detection conditions, including: Obtaining a transfer function matrix corresponding to the currently processed reversible candidate structure; and calculating the determinant of the transfer function matrix; If it is determined that the determinant is less than or equal to zero, the currently processed reversible candidate structure is determined to be a reversible candidate structure that does not meet the legality detection condition, and the currently processed reversible candidate structure is filtered out.
6. The method according to claim 1, It is characterized in that The reversible conversion pattern set corresponding to each legal reversible candidate structure is determined according to the black and white lists, including: By querying a pre-established reversible transformation pattern whitelist, a set of reversible transformation candidate patterns that match each legal reversible candidate structure is obtained; Obtain a target algorithm model scenario that matches the target deep learning model, and obtain at least one invalid reversible conversion mode that matches the target algorithm model scenario by querying a pre-established reversible conversion mode blacklist; In each reversible transformation candidate pattern set, invalid reversible transformation patterns are filtered out respectively to obtain a reversible transformation pattern set corresponding to each legal reversible candidate structure.
7. The method according to claim 1, It is characterized in that According to the reversible transformation pattern set corresponding to each legal reversible candidate structure, multiple reversible reconstruction models corresponding to the target deep learning model are constructed, including: Constructing a plurality of reversible conversion forms according to each reversible candidate structure and each reversible conversion mode corresponding to each reversible candidate structure; Input the abstract syntax tree of the target deep learning model and each reversible transformation form into the non-intrusive reversible converter respectively; Outputting updated abstract syntax trees obtained by reversibly transforming the target deep learning model according to each reversible transformation form through a non-intrusive reversible transformer; Based on each updated abstract syntax tree, multiple reversible reconstruction models corresponding to the target deep learning model are constructed.
8. The method according to any one of claims 1 to 7, It is characterized in that After screening out the target reversible structures and the target reversible conversion mode sets corresponding to the target reversible structures according to the test run results, it also includes: Obtaining the operating performance description information of the backend system when executing each reversible reconstruction model; According to the operation performance description information, at least one target replacement reversible structure and a target replacement reversible conversion mode corresponding to the target replacement reversible structure are determined from the target reversible structures and the target reversible conversion mode corresponding to the target replacement reversible structure; According to the target replacement reversible structure and the target replacement reversible transformation pattern corresponding to the target replacement reversible structure, a target reversible reconstruction model corresponding to the target deep learning model is constructed; The target reversible reconstruction model is loaded into the backend system for actual operation to perform model training operations.
9. A reversible structure recognition device in a deep learning model, It is characterized in that include: A directed acyclic graph generation module, used to obtain an abstract syntax tree corresponding to a target deep learning model, and generate a directed acyclic graph according to the abstract syntax tree, wherein nodes in the abstract syntax tree correspond to operators in the target deep learning model; The target deep learning model is applied in the fields of image classification, target detection, face recognition, text classification, machine translation or speech recognition; A reversible candidate structure determination module is used to perform structural analysis on the directed acyclic graph, determine the dependency relationship between each node, and determine the reversible candidate structure corresponding to each node according to the dependency relationship; wherein the reversible candidate structure is a branchless structure containing at least one node; A reversible conversion pattern set determination module is used to filter out reversible candidate structures that do not meet the legality detection conditions from all reversible candidate structures, obtain legal reversible candidate structures, and determine the reversible conversion pattern set corresponding to each legal reversible candidate structure according to the black and white lists; A reversible reconstruction model construction module is used to construct multiple reversible reconstruction models corresponding to the target deep learning model according to the reversible transformation pattern set corresponding to each legal reversible candidate structure; A target reversible conversion pattern set screening module is used to load each reversible reconstruction model into the back-end system for trial operation, and screen out each target reversible structure that can be measured and the target reversible conversion pattern set corresponding to the target reversible structure according to the trial operation result; The back-end system is a physical execution device. The trial operation refers to loading the set reversible reconstruction model into the execution device and controlling the execution device to execute for a set time or control the execution device to achieve a set calculation target, detecting whether the set reversible reconstruction model can be executed normally. The trial operation result includes normal operation or abnormal operation.
10. An electronic device, It is characterized in that The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the reversible structure recognition method in the deep learning model described in any one of claims 1-8.
11. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, which are used to enable a processor to implement the reversible structure recognition method in the deep learning model described in any one of claims 1 to 8 when executed.
