Computational graph node fusion method, device, electronic device and storage medium

Building a custom fusion strategy through regular expressions solves the problem of lack of flexibility in graph fusion strategy in deep learning compilers, and achieves efficient performance optimization and computational performance improvement.

CN116909573BActive Publication Date: 2024-11-05BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310979973.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-04
Publication Date
2024-11-05
Estimated Expiration
2043-08-04

AI Technical Summary

Technical Problem

The existing deep learning compilers lack customization and flexibility in graph fusion strategies, which limits users' performance optimization capabilities, and has high learning costs and poor configuration flexibility, which hinders the ecological development of the compiler.

Method used

By introducing regular expressions to build target fusion strategies, allowing users to customize the graph fusion mechanism of deep learning compilers. Users only need to enter simple regular expressions to map to the underlying implementation of deep learning compilers, realizing flexible configuration of fusion strategies.

Benefits of technology

It reduces the development and debugging costs of fusion strategies, improves the flexibility and ease of use of deep learning compilers, reduces function call overhead, improves computing performance, and provides greater optimization space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116909573B_ABST
    Figure CN116909573B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method, device, electronic device and storage medium for node fusion of a computation graph, and relates to the field of artificial intelligence technology, and in particular to the field of deep learning. The specific implementation scheme is: in response to receiving a regular expression associated with a computation graph in a deep learning compiler, parsing the regular expression to obtain a target fusion strategy, the regular expression is obtained according to a customized setting of a candidate fusion strategy for fusing operator nodes in the computation graph; and fusing the operator nodes in the computation graph based on the target fusion strategy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to the field of deep learning, and specifically to a method, device, electronic device and storage medium for node fusion of a computational graph. Background Art

[0002] The deep learning compiler is used to build a bridge between artificial intelligence algorithm models and machine code. It is one of the core components of the deep learning framework and plays a vital role in the deep learning system. The deep learning compiler accepts the ever-changing model algorithms designed by researchers and adapts to the machine binary code output in multiple hardware scenarios to meet the resource constraints of different hardware backends.

[0003] The deep learning model built by the developer will be converted into a computational graph by the compiler front end, which is equivalent to abstracting the computational logic and control flow in the model into a graph structure. Summary of the invention

[0004] The present disclosure provides a method, device, electronic device and storage medium for node fusion of a computational graph.

[0005] According to one aspect of the present disclosure, a method for node fusion of a computation graph is provided, comprising: in response to receiving a regular expression associated with a computation graph in a deep learning compiler, parsing the regular expression to obtain a target fusion strategy, wherein the regular expression is obtained by customizing a candidate fusion strategy for fusing operator nodes in the computation graph; and fusing the operator nodes in the computation graph based on the target fusion strategy.

[0006] According to another aspect of the present disclosure, a node fusion device for a computation graph is provided, comprising: a parsing module for parsing a regular expression associated with a computation graph in a deep learning compiler in response to receiving the regular expression to obtain a target fusion strategy, wherein the regular expression is obtained by customizing a candidate fusion strategy for fusing operator nodes in the computation graph; and a fusion module for fusing operator nodes in the computation graph based on the target fusion strategy.

[0007] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the node fusion method of the computational graph of the present disclosure.

[0008] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the node fusion method of the computational graph of the present disclosure.

[0009] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein the computer program is stored on at least one of a readable storage medium and an electronic device, and when the computer program is executed by a processor, the node fusion method of the computational graph of the present disclosure is implemented.

[0010] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0012] Figure 1 Schematically illustrates an exemplary system architecture of a node fusion method and device that can apply a computational graph according to an embodiment of the present disclosure;

[0013] Figure 2 A flowchart of a method for node fusion of a computational graph according to an embodiment of the present disclosure is schematically shown;

[0014] Figure 3 A schematic diagram schematically shows horizontal fusion and vertical fusion according to an embodiment of the present disclosure;

[0015] Figure 4 Schematically shows an AST node class diagram according to an embodiment of the present disclosure;

[0016] Figure 5 The structure diagram of the AST syntax tree obtained by parsing a regular expression according to an embodiment of the present disclosure is schematically shown;

[0017] Figure 6 Schematically shows an execution flow chart of the WhileRegexNode2 node corresponding to the ([HV]I)* strategy according to an embodiment of the present disclosure;

[0018] Figure 7 Schematically shows a policy parsing diagram corresponding to the H*([HV]I)*([RV]I)* fusion policy according to an embodiment of the present disclosure;

[0019] Figure 8 A block diagram schematically shows a node fusion device for a computation graph according to an embodiment of the present disclosure; and

[0020] Fig. 9 A schematic block diagram of an example electronic device 900 that may be used to implement embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0021] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0022] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision, disclosure and application of user personal information involved comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.

[0023] In the technical solution of the present disclosure, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.

[0024] Developers and algorithm researchers have put forward various requirements for deep learning compilers, such as versatility, flexibility, and high performance. Versatility is used to control the compiler to support a variety of model structures and adapt to different operators called by upper-level users. Flexibility means that in the optimization process of the compiler, users are given enough flexibility, so that users can freely control the optimization process and selectively apply optimization strategies. In addition, users have a strong demand for high performance, and the deep learning compiler tries its best to ensure the efficient execution of the algorithm, improve computing performance, and reduce hardware energy consumption.

[0025] The optimization strategy of the deep learning compiler plays a key role in the performance of the final generated code. Computational graph fusion is an important optimization method for deep learning compilers. The design solutions for graph fusion strategies in deep learning compiler products include MLIR (compiler infrastructure software), TVM (model compiler for deep learning), Triton (an inference server), and other solutions.

[0026] MLIR provides the Pass affine-loop-fusion for graph fusion. This Pass supports producer-consumer fusion and sibling fusion. MLIR presents the following three fusion methods: Producer-consumer fusion alone. Sibling fusion alone. Producer-consumer fusion first, then sibling fusion.

[0027] TVM provides Pass FuseOps (operator-based fusion strategy) for graph fusion. This Pass performs fusion based on the OpPatternKind (operator type information) of the Group (operator group). If two groups meet specific OpPatternKind constraints, the groups are fused. However, since the OpPatternKind value of the Group has a fixed semantics, it cannot be modified at the user level.

[0028] Triton adopts a scoring method, embedding the fusion constraints and fusion priorities between nodes into the scoring function, and selecting the fusion node through the scoring function. The Triton solution includes: scoring any two nodes, and then selecting the two nodes with the highest scores for fusion.

[0029] In the process of implementing the concept of the present disclosure, the inventor discovered that the combination of the above fusion strategies is fixed and embedded in the low-level implementation of the compiler, which can only be controlled by the compiler developers. The upper-level users have no space to customize the fusion mechanism and cannot freely configure the fusion strategy. Users have to learn the implementation scheme of the fusion strategy and then adapt the fusion strategy in the optimization algorithm, which has high learning cost and poor configuration flexibility. The above fusion strategy limits the flexibility of the compiler, limits the performance optimization ability of the upper-level users, and also brings resistance to the ecological development of deep learning compilers.

[0030] Figure 1 An exemplary system architecture of a node fusion method and device that can apply a computational graph according to an embodiment of the present disclosure is schematically shown.

[0031] It should be noted that Figure 1The examples shown are only examples of system architectures to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but do not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios. For example, in another embodiment, an exemplary system architecture to which the method and apparatus for node fusion of a computational graph can be applied may include a terminal device, but the terminal device may implement the method and apparatus for node fusion of a computational graph provided by the embodiments of the present disclosure without interacting with a server.

[0032] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.

[0033] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as knowledge reading applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software, etc. (only as examples).

[0034] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0035] The server 105 may be a server that provides various services, such as a background management server that provides support for the content browsed by the user using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (for example only). The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device. 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 ("Virtual Private Server", or "VPS" for short). The server may also be a server for a distributed system, or a server combined with a blockchain.

[0036] It should be noted that the node fusion method of the computation graph provided in the embodiment of the present disclosure can generally be executed by the first terminal device 101, the second terminal device 102 or the third terminal device 103. Correspondingly, the node fusion device of the computation graph provided in the embodiment of the present disclosure can also be set in the first terminal device 101, the second terminal device 102 or the third terminal device 103.

[0037] Alternatively, the node fusion method of the computational graph provided in the embodiment of the present disclosure may also be generally executed by the server 105. Accordingly, the node fusion device of the computational graph provided in the embodiment of the present disclosure may generally be arranged in the server 105. The node fusion method of the computational graph provided in the embodiment of the present disclosure may also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the node fusion device of the computational graph provided in the embodiment of the present disclosure may also be arranged in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.

[0038] For example, when it is necessary to fuse the nodes of the computation graph, the first terminal device 101, the second terminal device 102, and the third terminal device 103 can obtain a regular expression associated with the computation graph in the deep learning compiler, and the regular expression is obtained according to the custom setting of the candidate fusion strategy for fusing the operator nodes in the computation graph. Then the obtained regular expression is sent to the server 105, and the server 105 parses the regular expression in response to receiving the regular expression, obtains the target fusion strategy, and fuses the operator nodes in the computation graph based on the target fusion strategy. Alternatively, a server or server cluster that can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105 parses the regular expression, and fuses the operator nodes in the computation graph based on the target fusion strategy obtained by the analysis.

[0039] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0040] Figure 2 The flowchart of the node fusion method of the computational graph according to the embodiment of the present disclosure is schematically shown.

[0041] like Figure 2 As shown, the method includes operations S210 to S220.

[0042] In operation S210, in response to receiving a regular expression associated with a computation graph in a deep learning compiler, the regular expression is parsed to obtain a target fusion strategy, where the regular expression is obtained based on a custom setting of candidate fusion strategies for fusing operator nodes in the computation graph.

[0043] In operation S220, based on the target fusion strategy, the operator nodes in the computation graph are fused.

[0044] According to an embodiment of the present disclosure, a computational graph may be composed of one or more operator nodes. An operator node may be a node representing at least one of addition calculations, multiplication calculations, division calculations, reduse calculations, sum calculations, etc., and may not be limited thereto. The node fusion method of the computational graph provided in the present disclosure may be a node fusion method defined for a computational graph composed of multiple operator nodes, which may be used to select operator nodes for fusion, or to fuse nodes that meet constraints into a subgraph. It should be noted that subgraphs without data dependencies can be executed in parallel, which is beneficial to improving execution efficiency.

[0045] According to an embodiment of the present disclosure, during the node fusion process, there are multiple fusion strategies to choose from, such as horizontal fusion, vertical fusion, recalculation, etc. The candidate fusion strategy may include at least one of horizontal fusion, vertical fusion, recalculation, and other defined fusion strategies, custom fusion strategies, and the like.

[0046] According to the embodiments of the present disclosure, the execution order, execution rounds, and fusion methods of different fusion strategies have an important impact on the result of generating a subgraph. The above regular expression can be obtained by formalizing at least one of the execution order and execution number of one or more fusion strategies and the fusion method into a state machine, and then describing the state machine with a regular expression.

[0047] According to an embodiment of the present disclosure, the fusion strategy in the deep learning compiler is implemented based on two mechanisms: fusion strategy definition and fusion mechanism implementation. The fusion strategy definition can be used to clarify which fusion methods are included, as well as the role and constraints of each fusion method. The fusion mechanism implementation can be used to combine fusion strategies, as well as to specify details such as the execution order and rounds of the fusion strategy. At the user level, the user can first select the required candidate fusion strategy. Then, according to the fusion method, execution order, and execution number of the selected candidate fusion strategy, the regular expression can be obtained by custom settings.

[0048] According to an embodiment of the present disclosure, the above-mentioned process of parsing the regular expression can be performed in the form of execution after parsing or traversal or execution. By traversing or parsing the regular expression, a target fusion strategy based on the traversal or parsing can be implemented to fuse the operator nodes in the calculation graph.

[0049] Through the above-mentioned embodiments of the present disclosure, a flexibly configurable deep learning compiler graph fusion mechanism is realized by introducing regular expressions to construct a target fusion strategy for fusing operator nodes in the computational graph. Under this mechanism, upper-level users only need to enter simple regular expressions to customize the target fusion strategy and map it to the underlying implementation of the deep learning compiler. The development cost for users is close to 0, which reduces the development cost and debugging cost of the fusion strategy, is user-friendly, and improves the flexibility and ease of use of the deep learning compiler. In addition, since each operator node corresponds to a generated Kernel function, after the fusion between the operator nodes is completed, the function call overhead can be reduced, the consumption of computer memory can be reduced, and the computing performance can be improved. It can also provide a larger optimization space for the subsequent optimization work of the compiler.

[0050] In conjunction with specific embodiments, Figure 2 The method shown is further explained.

[0051] According to the embodiments of the present disclosure, the basic unit of graph fusion can be a Group, which can be understood as a subgraph of a computational graph. Groups without dependencies can be executed in parallel. Before fusing the operator nodes in the computational graph, each operator node in the computational graph can be preprocessed to encapsulate the Op (operator) node as a Group operator node. A Group can include one or more Ops.

[0052] According to an embodiment of the present disclosure, before performing the above operations S210 to S220, a candidate fusion strategy, a target fusion strategy, and a regular expression may be determined first.

[0053] According to an embodiment of the present disclosure, the candidate fusion strategies may include at least one of the following: vertical fusion, horizontal fusion, recalculation, input fusion, etc., and may not be limited thereto.

[0054] According to the embodiments of the present disclosure, a producer-consumer relationship can be constructed based on the front-end dependency of a group. For example, a group may have one or more producers, and the output of the producer can be used as the input of the current group. For example, a group may have one or more consumers, and the output of the current group can be used as the input of the consumer.

[0055] Figure 3 The schematic diagram schematically shows horizontal fusion and vertical fusion according to an embodiment of the present disclosure.

[0056] like Figure 3As shown, the computation graph 300 includes a first group 310, a second group 320, a third group 330, and a fourth group 340. The first group 310 can act as a producer, the second group 320, the third group 330, and the fourth group 340 can act as consumers, and the output of the first group 310 can be used as the input of the second group 320, the third group 330, and the fourth group 340.

[0057] According to an embodiment of the present disclosure, the fusion strategy of horizontal fusion may include: taking a certain Group as an anchor point, such as Figure 3 The first Group 310 in traverses all consumers of the Group, such as Figure 3 The second group 320, the third group 330 and the fourth group 340 in the example are as follows. Based on the type information between the consumers and the number of data in the tensors of each consumer, it is determined whether the consumers can be fused, and then the fusion candidate set is selected and fused. For example, when it is determined that the fusion conditions are met, Figure 3 The third Group 330 and the fourth Group 340 can be horizontally merged.

[0058] According to an embodiment of the present disclosure, input fusion is a special case of horizontal fusion. Input fusion is aimed at groups without producers, and these groups can directly process the tensors of the user input model. The fusion strategy of input fusion may include: according to the input tensor, obtaining multiple initial operator nodes that share the input tensor. According to the first input and output type information and the first tensor information of each of the multiple initial operator nodes, determine multiple target operator nodes with matching information. Fusion of multiple target operator nodes.

[0059] For example, input fusion can traverse consumers that share the same input tensor, filter out candidate sets for fusion based on the type relationship between consumers, and fuse the groups in the candidate sets into a large group.

[0060] According to an embodiment of the present disclosure, the fusion strategy of vertical fusion may include: taking a certain Group as an anchor point, such as Figure 3 The first Group 310 in traverses all consumers of the anchor Group, such as Figure 3The second group 320, the third group 330 and the fourth group 340 in the example are as follows. According to the type information between the anchor group and each consumer, as well as the number of data in the anchor group and each consumer's internal tensor, it is determined whether the anchor group can be fused with each consumer, and then the fusion candidate set is screened and fused. For example, when it is determined that the fusion conditions are met, Figure 3 The first Group 310 and the second Group 320 can be vertically integrated.

[0061] According to an embodiment of the present disclosure, recalculation is a special case of vertical fusion. The fusion strategy of recalculation may include: according to the operator group node, obtaining all consumer nodes corresponding to the operator group node. In response to determining that the operator group node and all consumer nodes have information matching according to the second input-output type information and the second tensor information of the operator group node, and the third input-output type information and the third tensor information of the consumer node, the operator group node and each consumer node in all consumer nodes are fused respectively.

[0062] For example, see Figure 3 The calculation graph 300 shown can take the first group 310 as an anchor point and traverse all consumers of the group: the second group 320, the third group 330 and the fourth group 340. When the first group 310 and all consumers meet the fusion condition, the second group 320, the third group 330 and the fourth group 340 are fused with the first group 310 respectively to obtain three fused groups.

[0063] It should be noted that the above fusion strategy based on recalculation may perform repeated calculations on the fused groups, but it can save the memory overhead of interactions between groups and improve computing performance.

[0064] According to an embodiment of the present disclosure, the above-mentioned type information (including the first input-output type information, the second input-output type information and the third input-output type information, etc., and may not be limited thereto) may include at least one of the following: ElementWise, Broadcast, Injective, Reduction. ElementWise can characterize that the relationship between the input tensor index and the output tensor index is a one-to-one correspondence. Broadcast can characterize that the relationship between the input tensor index and the output tensor index is a one-to-many correspondence. Injective can characterize the single-shot mapping of the axis of the output tensor to the axis of the input tensor. Reduction can characterize that the relationship between the input tensor index and the output tensor index is a many-to-one correspondence.

[0065] According to the embodiments of the present disclosure, the above information matching can be expressed in any of the following forms: In the scenario where the type information of the two groups to be matched is ElementWise and Broadcast respectively, all outputs of the previous group are required to be inputs of the second group. In the scenario where the type information of the two groups to be matched is Reduction and Broadcast respectively, the number of output tensors of the Broadcast Group is required to be consistent with the number of input tensors of the Reduction Group. In the scenario where the type information of the two groups to be matched is both Elementwise, the number of input tensors of the two groups is required to be consistent.

[0066] It should be noted that the above-mentioned information matching forms are only exemplary embodiments, but are not limited thereto, and may also include other forms known in the art, as well as forms determined by rearranging and combining the above-mentioned forms, as long as it is possible to decide whether the information matches.

[0067] According to an embodiment of the present disclosure, the fusion process of the computational graph may be composed of a plurality of fusion strategies, which may include both permutations and combinations of strategies and execution rounds of strategies. After determining the candidate fusion strategies, the target fusion strategy may be determined based on the candidate fusion strategies, and the determination method may include: determining the number of execution rounds for the customized settings of the candidate fusion strategies. In response to the determination that there are multiple candidate fusion strategies based on which the customized settings are determined, determine a strategy permutation and combination method for the customized settings of the multiple candidate fusion strategies. Determine the target fusion strategy based on at least one of the number of execution rounds and the strategy permutation and combination method, as well as the candidate fusion strategies.

[0068] According to an embodiment of the present disclosure, the number of execution rounds may be set by setting a predefined value, or may be set based on programming technology, for a certain or a certain candidate fusion process, according to a preset constraint condition, by setting a while loop or an until loop, and may not be limited thereto. The preset constraint condition may, for example, include: continuously performing a certain fusion strategy until the computation graph is no longer updated.

[0069] According to an embodiment of the present disclosure, the candidate fusion strategy may be one or more. When there is one candidate fusion strategy, only the one candidate fusion strategy may be determined as the target fusion strategy. When there is one candidate fusion strategy, the multiple candidate fusions may be arranged and combined to obtain the target fusion strategy. The method for determining the target fusion strategy may not be limited to that described in this embodiment and the aforementioned embodiments.

[0070] According to an embodiment of the present disclosure, after determining the target fusion strategy, for example, the target fusion strategy may be regularized according to a predefined regularization rule to obtain a regular expression.

[0071] According to an embodiment of the present disclosure, the predefined regularization rules may be used to define symbols in a regular expression, and may include, for example, the following predefined content:

[0072] H: Horizontal Fusion, horizontal fusion strategy.

[0073] V: Vertical Fusion, vertical fusion strategy.

[0074] R: Recompute, recomputation strategy.

[0075] I: Input Fusion, input fusion strategy.

[0076] []: Sequence semantics. The semantics of [] is slightly different from that of regular expressions. [] can include the above-mentioned H, V, and R strategies, indicating that the output of the previous strategy is the input of the next strategy.

[0077] Furthermore, the outputs of the three strategies H, V, and R are explained:

[0078] H: Consumers are merged into one group. The output of the H strategy is the merged group.

[0079] V: The Producer Group and its consumers merge and eventually merge into one Group. The output of the V strategy is the merged Group.

[0080] R: The Producer Group is fused with each of its consumers. If the Producer has N consumers, the output of the R strategy is also N groups. Each output group is the fusion result of the Producer and one of its consumers. In the [] sequence semantics scenario, an output of an R strategy is randomly selected as the input of the subsequent optimization strategy. It should be noted that the random selection process can also be replaced by a process determined according to custom rules. For example, the first output of the R strategy can be selected each time as the input of the subsequent optimization strategy, etc., and it is not limited to this.

[0081] It should be noted that the input fusion strategy does not satisfy the sequence semantics, because the input fusion strategy does not require input Group, the strategy does not use any Group as an anchor point, and there is no common ProducerGroup between the groups that perform input fusion. Furthermore, since the H, V, and R strategies will access each Group in the computation graph, when executing the H, V, and R strategies, the computation graph needs to be traversed by a for loop. When executing the I strategy, no for loop traversal is required.

[0082] *: while (or until) loop semantics, * means repeated execution until the computation graph is no longer updated or other constraints are met.

[0083] According to an embodiment of the present disclosure, after determining the target fusion strategy, a regular expression corresponding to the target fusion strategy may be generated based on the above-mentioned predefined regularization rules.

[0084] For example, the target fusion strategy is to repeatedly apply the horizontal fusion strategy until no Group can be horizontally fused. Based on the above predefined regularization rules, the target fusion strategy is regularized and transformed to obtain a regular expression: H*.

[0085] For example, when the target fusion strategy is to apply the fusion strategy to the Group, the output Group after applying the horizontal fusion strategy is used as the input of the subsequent vertical fusion strategy. Based on the above predefined regularization rules, the target fusion strategy is regularized and transformed to obtain the regular expression: [HV].

[0086] Through the above embodiments of the present disclosure, by defining predefined regularization rules, a mechanism for customizing fusion strategies can be implemented. From the user level, only the semantic concept of each symbol in the regular expression needs to be understood, and the upper-level user can control the underlying graph fusion strategy through the custom regular expression. Regular expressions can also facilitate users to freely modify the fusion order, thereby improving the flexibility of fusion strategy configuration.

[0087] According to an embodiment of the present disclosure, after the fusion mechanism is abstracted into a regular expression based on the definition of the fusion strategy and the general logic abstraction of the fusion mechanism, a process of parsing the regular expression may be performed.

[0088] According to an embodiment of the present disclosure, the parsing process may be in the form of execution after parsing, and corresponding to this form, the above operation S210 may include: parsing the regular expression to generate a syntax tree, and determining a target fusion strategy according to the execution program represented by the syntax tree.

[0089] According to an embodiment of the present disclosure, in response to receiving a regular expression, the deep learning compiler layer may first parse the regular expression. If the parsing result is correct, the target fusion strategy may be run normally; otherwise, the user may be prompted and the default fusion strategy may be adopted.

[0090] According to an embodiment of the present disclosure, the regular expression may be converted into an abstract syntax tree (abstract syntax code, AST for short) to implement the above parsing process.

[0091] Figure 4 The AST node class diagram according to an embodiment of the present disclosure is schematically shown.

[0092] like Figure 4 As shown, the definition of the UML class diagram (classification between general elements and special elements) related to the abstract syntax tree may include the following:

[0093] The root node for parsing regular expressions is FusionRegexRoot 410. Each regular expression corresponds to a unique root node. The root node can have one or more FusionRegexNode 420. FusionRegexNode is a virtual base class that only provides the Run interface for subsequent execution strategies. FusionRegexNode can have multiple derived classes.

[0094] SequentialRegexNode 430: indicates a sequence node, which may correspond to a single H, V, R fusion strategy, or indicate sequence semantics. For example, when type_=[RV], it indicates that the node corresponds to the emphasis calculation + vertical fusion strategy.

[0095] WhileRegexNode 440: represents a while (or until) loop node, which may have multiple FusionRegexNode member variables, and the node may execute the Run functions in the member variables in sequence until the Group in the computation graph is not updated.

[0096] InputRegexNode 450: represents the input fusion strategy.

[0097] According to the embodiment of the present disclosure, when parsing a regular expression, the entire regular expression can be traversed from beginning to end, and then a corresponding AST can be generated according to the string content. Afterwards, the target fusion strategy can be determined according to the execution program represented by the AST.

[0098] According to an embodiment of the present disclosure, if a V, H, R or I mark is scanned and there is no symbol nesting in the outer layer, then each symbol can correspond to a separate node. V, H, and R can correspond to a SequentialRegexNode node respectively, and the type_ value of each node can be "V", "H", and "R" respectively. I can correspond to an InputRegexNode node, and the type_ value can be "I", indicating an input fusion strategy.

[0099] For example, the regular expression may be H, and a node may be determined according to H, and the syntax tree of the regular expression H may be obtained by combining the FusionRegexRoot node in the UML class diagram. It may also be determined that the target fusion strategy in this embodiment is to execute a horizontal fusion strategy.

[0100] Through the above-mentioned embodiments of the present disclosure, by parsing the regular expression into a syntax tree, it is possible to facilitate mapping the regular expression to the bottom layer of the deep learning compiler and realize the process of automatically executing the target fusion strategy.

[0101] According to an embodiment of the present disclosure, the above-mentioned parsing of the regular expression and generating the syntax tree may include: parsing the string in the regular expression. In response to determining that the currently parsed string is a first string representing the first fusion strategy, the first string is determined as a child node. In response to determining that the currently parsed string is a second string representing the execution round of the first fusion strategy, the second string is determined as the parent node of the child node. According to the parent node and the child node, a syntax tree is determined.

[0102] According to an embodiment of the present disclosure, if a “*” mark is scanned, the character string wrapped by the “*” may correspond to a WhileRegexNode node and may serve as a parent node.

[0103] For example, the regular expression may be H*, the first character string may be H, the second character string may be *, H may be taken as a child node, and * may be taken as a parent node of H to obtain a syntax tree of the regular expression H*.

[0104] According to an embodiment of the present disclosure, in response to determining that the currently parsed string is a first string representing a first fusion strategy, determining the first string as a child node may include: in response to determining that the currently parsed first string includes a first substring representing a sequence string start mark and a second substring representing a sequence string end mark, obtaining a target sequence string located between the first substring and the second substring, the sequence string start mark and the sequence string end mark corresponding one to one. Determining the target sequence string as a child node.

[0105] According to an embodiment of the present disclosure, the first string may be a partial string or the entire string in the regular expression, which is not limited here. Based on the above predefined regularization rules, it can be obtained that the sequence string start mark may be "[" and the sequence string end mark may be "]".

[0106] According to an embodiment of the present disclosure, if the "[" and "]" marks are scanned, the string wrapped by the "[" and "]" may correspond to a SequentialRegexNode node and may be used as a child node. The type_ in the node may be the string within the "[" and "]", indicating sequence semantics.

[0107] For example, the regular expression may be [HV]I, and the first character string may be [HV] or I.

[0108] For example, if the first string is [HV], it can be determined that the first string includes a first substring "[" and a second substring "]", and the target sequence string can be determined to be HV. In this implementation, the target sequence string HV can be determined as a subnode as a whole.

[0109] According to an embodiment of the present disclosure, determining a target fusion strategy according to an execution program represented by a syntax tree may include: performing a pre-order traversal on the syntax tree to obtain semantic information represented by each tree node in the syntax tree. Determining an execution program according to the semantic information represented by each tree node. Determining the execution program as the target fusion strategy.

[0110] According to an embodiment of the present disclosure, the semantic information may represent at least one of the following information: the execution mode of the target fusion strategy, the execution round of the target fusion strategy for a certain child node, etc., and may not be limited thereto. Based on the semantic information obtained by the predecessor traversal, the execution formula may be determined, thereby determining the target fusion strategy.

[0111] For example, the regular expression is H*([HV]I)*([RV]I)*, and the AST syntax tree structure generated for this regular expression can be as shown in Figure 5 shown.

[0112] Figure 5 The structure diagram of the AST syntax tree obtained by parsing a regular expression according to an embodiment of the present disclosure is schematically shown.

[0113] like Figure 5As shown, the execution entry of AST 500 can be FusionRegexRoot root node 510, and the Run function in root node 510 can sequentially traverse and execute its member variable roots_, for example, can sequentially traverse WhileRegexNode1520, WhileRegexNode2 530 and WhileRegexNode3 540. Since WhileRegexNode is a nested structure, when executing WhileRegexNode, the child nodes in WhileRegexNode can also be sequentially traversed based on the pre-order traversal method. For example, for WhileRegexNode2 530, the SequentialRegexNode2 531 and InputRegexNode1 532 nodes therein can be sequentially traversed.

[0114] According to an embodiment of the present disclosure, a target fusion strategy may be determined based on a pre-order traversal result for AST 500. Based on the target fusion strategy, operator nodes in a computation graph may be fused.

[0115] Figure 6 The execution flow chart of the WhileRegexNode2 node corresponding to the ([HV]I)* strategy according to an embodiment of the present disclosure is schematically shown.

[0116] like Figure 6 As shown, the process may include operations S610 to S670.

[0117] In operation S610, all Groups in the computation graph are traversed.

[0118] In operation S620, it is determined whether the next Group can be traversed. If yes, operation S630 is executed; if no, operation S660 is executed.

[0119] In operation S630 , the type type in SequentialRegexNode2 is traversed.

[0120] In operation S640, it is determined whether the next type can be traversed. If so, operation S650 is executed; if not, operation S620 is executed.

[0121] In operation S650, horizontal fusion, vertical fusion or recalculation is performed on the current Group according to the type.

[0122] In operation S660, input fusion is performed on the current computation graph.

[0123] In operation S670, it is determined whether the computation graph has not been updated. If so, the process ends; if not, operation S610 is executed.

[0124] According to the embodiments of the present disclosure, see Figure 6 As shown in the flowchart, it can be seen that ([HV]I)* corresponds to a nested structure, the outer layer is WhileRegexNode2, and the inner layer is SequentialRegexNode2 and InputRegexNode1. The execution termination condition of the outer layer WhileRegexNode1 can be that the calculation graph is no longer updated, otherwise the two nested nodes in the inner layer can be continuously executed. The above operations S610 to S650 can be executed based on SequentialRegexNode2, including: traversing all Groups in the calculation graph, each time a Group is accessed, the type parameter saved in SequentialRegexNode2 can be scanned once, and the corresponding fusion strategy can be executed in sequence according to the characters in type. The above operation S660 can be executed based on InputRegexNode1, including: when all Groups in the calculation graph are traversed once, InputRegexNode1 is executed again to perform an input fusion on the current calculation graph.

[0125] Through the above-mentioned embodiments of the present disclosure, by executing the AST syntax tree, the fusion strategy is automatically executed according to the semantics corresponding to different tree nodes. The target fusion strategy that the user wants to execute can be mapped to the bottom layer of the deep learning compiler through regular expressions and automatically executed.

[0126] According to an embodiment of the present disclosure, the parsing process may also be performed in a traversal and execution form. Corresponding to this form, the above operation S210 may include: traversing the string in the regular expression. In response to determining that the currently traversed string is a third string representing the second fusion strategy, the second fusion strategy is determined as the target fusion strategy.

[0127] For example, the regular expression may be V, the third string may be V, and the target fusion strategy may be to execute a vertical fusion strategy. Corresponding to this embodiment, the above operation S220 may be performed as follows: executing a vertical fusion strategy on the operator nodes in the computation graph.

[0128] According to an embodiment of the present disclosure, the third string may include at least a third substring and a fourth substring arranged in sequence, the third substring represents the first sub-fusion strategy, and the fourth substring represents the second sub-fusion strategy. The above operation S220 may include: based on the first sub-fusion strategy, fusing the operator nodes in the calculation graph to obtain a first fusion calculation graph. Based on the second sub-fusion strategy, fusing the operator nodes in the first fusion calculation graph.

[0129] For example, the regular expression may be RV, and the third string may be RV. The third substring may be R, and the first sub-fusion strategy may be a redirection strategy. The fourth substring may be V, and the second sub-fusion strategy may be a vertical fusion strategy. Corresponding to this embodiment, the above operation S220 may be performed as follows: the redirection strategy is first executed on the operator nodes in the calculation graph to obtain a first fusion calculation graph. Then, the vertical fusion strategy is executed on the first fusion calculation graph.

[0130] According to an embodiment of the present disclosure, based on the first sub-fusion strategy, the operator nodes in the calculation graph are fused to obtain a first fused calculation graph, and based on the second sub-fusion strategy, the process of fusing the operator nodes in the first fused calculation graph can be expressed as: firstly executing the first sub-fusion strategy on all the operator nodes in the calculation graph to obtain the first fused calculation graph, and then executing the second sub-fusion strategy on all the operator nodes in the first fused calculation graph. It can also be expressed as: first determining an anchor point, executing the first sub-fusion strategy on the operator nodes determined based on the anchor point, obtaining the first fused calculation graph, and then executing the second sub-fusion strategy on the first fused calculation graph. It should be noted that the first fused calculation graph obtained by the former may be a fused calculation graph including complete operator nodes, and the first fused calculation graph obtained by the latter may be a fused calculation graph including only a subgraph of some operator nodes determined based on the anchor point. In the case where the operator nodes determined by the latter based on the anchor point include all the operator nodes of the calculation graph, the first fused calculation graph obtained by the latter may also be a fused calculation graph including complete operator nodes.

[0131] According to an embodiment of the present disclosure, when parsing a regular expression based on the form of traversal and execution, the above operation S210 may also include: in response to determining that the currently traversed string includes a third string and a fourth string representing the execution round of the second fusion strategy, determining the target fusion strategy according to the second fusion strategy and the second fusion strategy execution round.

[0132] For example, the regular expression may be V*, the third character string may be V, and the fourth character string may be “*”. The target fusion strategy may be to repeatedly execute the vertical fusion strategy for the computation graph until the computation graph is not updated.

[0133] According to an embodiment of the present disclosure, based on the above embodiment, the above operation S220 may include: based on the second fusion strategy, performing the i+1th round of fusion on the operator nodes in the i-th round fusion calculation graph to obtain the i+1th round fusion calculation graph, the first round fusion calculation graph is obtained by performing the first round of fusion on the operator nodes in the calculation graph based on the second fusion strategy, and i is an integer greater than 1. In response to determining that the fusion information of the i+1th round meets the preset constraint condition, the i+1th round fusion calculation graph is used as the fusion result of fusing the operator nodes in the calculation graph based on the second fusion strategy and the second fusion strategy execution round.

[0134] For example, the regular expression is V*, by calculating Figure 1 The operator nodes of execute the vertical fusion strategy of the first round to obtain the first round of fusion calculation graph. When it is determined that the first round of fusion calculation graph does not meet the preset constraint conditions, the vertical fusion strategy of the second round can be continued for the first round of fusion calculation graph to obtain the second round of fusion calculation graph. And so on, until the fusion information of the i+1th round meets the preset constraint conditions.

[0135] For example, the regular expression may be H*([HV]I)*([RV]I)*, where three “*” symbols indicate that three while loops will be performed.

[0136] Figure 7 A policy parsing diagram corresponding to the H*([HV]I)*([RV]I)* fusion policy according to an embodiment of the present disclosure is schematically shown.

[0137] like Figure 7 As shown, the H*([HV]I)*([RV]I)* fusion strategy 700 may include fusion loop 1, fusion loop 2, and fusion loop 3, corresponding to three layers of while loops. The nested for loop in the while loop can be used to traverse all Groups in the computation graph.

[0138] Fusion loop 1 can traverse each Group in the computation graph, and repeatedly execute the horizontal fusion strategy for the consumer nodes retrieved with each Group as the anchor point, including: each time the horizontal fusion strategy is executed, the computation graph is updated. If the Group relationship in the computation graph does not change when the computation graph is updated, the current while loop can be jumped out; otherwise, if the Group relationship in the computation graph is updated when the computation graph is updated, it means that the horizontal fusion process can still be performed, and the while loop can continue to iterate.

[0139] Fusion loop 2 can first execute [HV] semantics, that is, traverse each group on the computation graph, perform horizontal fusion on the group, and then perform vertical fusion on the group output by the horizontal fusion. After completing one traversal of the groups on the computation graph, perform input fusion. The while loop will not be jumped out until the computation graph is not updated after one round of [HV]I execution.

[0140] The execution process of fusion loop 3 is similar to that of fusion loop 2, except that when executing [RV] semantics, recalculation is performed first, and then a group is randomly selected from the multiple output results of the recalculation as the input of the subsequent vertical fusion. This while loop will not be jumped out until the calculation graph is not updated after [RV]I is executed for one round.

[0141] It should be noted that the horizontal fusion strategy is still executed in fusion loop 2 because when other fusion strategies occur, the Group relationship of the computation graph may change, and at this time, there is a possibility of horizontal fusion between the Groups again.

[0142] Through the above embodiments of the present disclosure, users can customize and flexibly control the fusion strategy by entering regular expressions, which effectively improves the usability and flexibility of the deep learning compiler in the node fusion process. In addition, from the perspective of usability and flexibility, the above method is also of great significance for improving the overall competitiveness of the PaddlePaddle framework.

[0143] According to an embodiment of the present disclosure, the fusion information may include at least one of the fusion round and the fusion result. The preset constraint condition may include at least one of the following: i+1 is equal to the preset value, the fusion calculation graph of the i+1th round is the same as the fusion calculation graph of the i-th round, and the update flag of the i+1th round indicates that the fusion calculation graph of the i+1th round has not been updated. The update flag is used to record the first characterization information or the second characterization information. The first characterization information indicates that the calculation graph of the corresponding round has been updated, and the second characterization information indicates that the calculation graph of the corresponding round has not been updated.

[0144] According to an embodiment of the present disclosure, an update flag may be predefined to record whether the computation graph has been updated during the fusion process. For example, flag = 0 may be set to indicate no update, and flag = 1 may be set to indicate an update. By reading the value of Flag, it is possible to quickly and easily determine whether a loop needs to be exited.

[0145] Through the above-mentioned embodiments of the present disclosure, by predefining preset constraints, it can be relatively easy to determine whether it is necessary to jump out of the loop, and the loop can be jumped out in time if it is determined that the loop needs to be jumped out.

[0146] Figure 8A block diagram of a node fusion device for a computational graph according to an embodiment of the present disclosure is schematically shown.

[0147] like Figure 8 As shown, the node fusion device 800 of the computational graph includes a parsing module 810 and a fusion module 820 .

[0148] The parsing module 810 is used to parse the regular expression in response to receiving a regular expression associated with a computational graph in a deep learning compiler to obtain a target fusion strategy, where the regular expression is obtained based on a customized setting of a candidate fusion strategy for fusing operator nodes in the computational graph.

[0149] The fusion module 820 is used to fuse the operator nodes in the computation graph based on the target fusion strategy.

[0150] According to an embodiment of the present disclosure, the parsing module includes a syntax tree generating submodule and a first strategy determining submodule.

[0151] The syntax tree generation submodule is used to parse regular expressions and generate syntax trees.

[0152] The first strategy determination submodule is used to determine a target fusion strategy according to the execution program represented by the syntax tree.

[0153] According to an embodiment of the present disclosure, the syntax tree generation submodule includes a parsing unit, a child node determination unit, a parent node determination unit, and a syntax tree determination unit.

[0154] Parsing unit, used to parse the string in the regular expression.

[0155] The child node determination unit is configured to, in response to determining that the currently parsed character string is a first character string representing a first fusion strategy, determine the first character string as a child node.

[0156] The parent node determination unit is configured to, in response to determining that the currently parsed character string is a second character string representing an execution round of the first fusion strategy, determine the second character string as a parent node of the child node.

[0157] The syntax tree determination unit is used to determine the syntax tree according to the parent node and the child node.

[0158] According to an embodiment of the present disclosure, the subnode determination unit includes a sequence character string acquisition subunit and a subnode determination subunit.

[0159] The sequence string acquisition subunit is used to obtain a target sequence string located between the first substring and the second substring in response to determining that the first string currently being parsed includes a first substring representing a sequence string start mark and a second substring representing a sequence string end mark, and the sequence string start mark corresponds to the sequence string end mark one by one.

[0160] The child node determination subunit is used to determine the target sequence string as a child node.

[0161] According to an embodiment of the present disclosure, the first strategy determination submodule includes a traversal unit, an execution formula determination unit and a strategy determination unit.

[0162] The traversal unit is used to perform a pre-order traversal on the syntax tree to obtain the semantic information represented by each tree node in the syntax tree.

[0163] The execution program determination unit is used to determine the execution program according to the semantic information represented by each tree node.

[0164] The strategy determination unit is used to determine the execution program as a target fusion strategy.

[0165] According to an embodiment of the present disclosure, the parsing module includes a traversal submodule and a second strategy determination submodule.

[0166] The traversal submodule is used to traverse the string in the regular expression.

[0167] The second strategy determination submodule is configured to determine the second fusion strategy as a target fusion strategy in response to determining that the currently traversed character string is a third character string representing the second fusion strategy.

[0168] According to an embodiment of the present disclosure, the third string includes at least a third substring and a fourth substring arranged in sequence, the third substring represents the first sub-fusion strategy, and the fourth substring represents the second sub-fusion strategy; the fusion module includes a first fusion submodule and a second fusion submodule.

[0169] The first fusion submodule is used to fuse the operator nodes in the calculation graph based on the first sub-fusion strategy to obtain a first fusion calculation graph.

[0170] The second fusion submodule is used to fuse the operator nodes in the first fusion calculation graph based on the second sub-fusion strategy.

[0171] According to an embodiment of the present disclosure, the parsing module further includes a third strategy determination submodule.

[0172] The third strategy determination submodule is used to determine the target fusion strategy according to the second fusion strategy and the second fusion strategy execution round in response to determining that the currently traversed character string includes the third character string and the fourth character string representing the second fusion strategy execution round.

[0173] According to an embodiment of the present disclosure, the fusion module includes a third fusion submodule and a definition submodule.

[0174] The third fusion submodule is used to perform the i+1th round of fusion on the operator nodes in the i-th round fusion calculation graph based on the second fusion strategy to obtain the i+1th round of fusion calculation graph. The first round of fusion calculation graph is obtained by performing the first round of fusion on the operator nodes in the calculation graph based on the second fusion strategy, and i is an integer greater than 1.

[0175] A submodule is defined, which is used to, in response to determining that the fusion information of the i+1th round satisfies the preset constraints, use the i+1th round fusion calculation graph as a fusion result of fusing the operator nodes in the calculation graph based on the second fusion strategy and the second fusion strategy execution round.

[0176] According to an embodiment of the present disclosure, the preset constraints include at least one of the following: i+1 is equal to a preset value, the fusion calculation graph of the i+1th round is the same as the fusion calculation graph of the i-th round, and the update flag of the i+1th round indicates that there is no update to the fusion calculation graph of the i+1th round; the update flag is used to record the first representation information or the second representation information, the first representation information indicates that there is an update to the calculation graph of the corresponding round, and the second representation information indicates that there is no update to the calculation graph of the corresponding round.

[0177] According to an embodiment of the present disclosure, the node fusion device of the computational graph also includes an execution round number determination module, a strategy arrangement and combination method determination module and a strategy determination module.

[0178] The execution round number determination module is used to determine the execution round number customized for the candidate fusion strategy.

[0179] The strategy arrangement and combination mode determination module is used to determine the strategy arrangement and combination mode for the customized settings of the multiple candidate fusion strategies in response to the multiple candidate fusion strategies based on which the process of determining the customized settings is based.

[0180] The strategy determination module is used to determine the target fusion strategy according to at least one of the number of execution rounds and the strategy arrangement and combination mode, and the candidate fusion strategies.

[0181] According to an embodiment of the present disclosure, the node fusion device of the computational graph also includes a regular conversion module.

[0182] The regularization conversion module is used to perform regularization conversion on the target fusion strategy according to predefined regularization rules to obtain a regular expression.

[0183] According to an embodiment of the present disclosure, the candidate fusion strategies include at least one of the following: vertical fusion, horizontal fusion, recalculation, and input fusion.

[0184] According to an embodiment of the present disclosure, a fusion strategy of input fusion includes: obtaining multiple initial operator nodes that share the input tensor according to the input tensor; determining multiple target operator nodes with matching information according to first input and output type information and first tensor information of each of the multiple initial operator nodes; and fusing the multiple target operator nodes.

[0185] According to an embodiment of the present disclosure, the redirected fusion strategy includes: according to the operator group node, obtaining all consumer nodes corresponding to the operator group node. In response to determining that the operator group node and all consumer nodes have information matching according to the second input-output type information and the second tensor information of the operator group node, and the third input-output type information and the third tensor information of the consumer node, the operator group node and each of the consumer nodes in all the consumer nodes are fused respectively.

[0186] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0187] According to an embodiment of the present disclosure, an electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the node fusion method of the computational graph of the present disclosure.

[0188] According to an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the node fusion method of the computational graph of the present disclosure.

[0189] According to an embodiment of the present disclosure, a computer program product includes a computer program, wherein the computer program is stored on at least one of a readable storage medium and an electronic device, and when the computer program is executed by a processor, the node fusion method of the computational graph of the present disclosure is implemented.

[0190] Fig. 9A schematic block diagram of an example electronic device 900 that can be used to implement an embodiment of the present disclosure 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, 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 disclosure described and / or required herein.

[0191] like Fig. 9 As shown, the device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0192] A number of components in the device 900 are connected to an input / output (I / O) interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the device 900 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0193] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 901 performs the various methods and processes described above, such as the node fusion method of the computing graph. For example, in some embodiments, the node fusion method of the computing graph may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the node fusion method of the computing graph described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to perform the node fusion method of the computing graph by any other appropriate means (e.g., by means of firmware).

[0194] 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), complex 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.

[0195] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code 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.

[0196] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. 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.

[0197] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer 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 can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the 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 acoustic input, voice input, or tactile input).

[0198] The systems and techniques described herein may be implemented in a computing system that includes back-end 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 front-end 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 back-end components, middleware components, or front-end 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), and the Internet.

[0199] A computer system may include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises through computer programs running on respective computers and having a client-server relationship to each other. The server may be a cloud server, a server in a distributed system, or a server combined with a blockchain.

[0200] 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 recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0201] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. 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 disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A node fusion method for computational graphs applied to deep learning compilers, include: In response to receiving a regular expression associated with a computation graph in a deep learning compiler from an upper-level user, parsing the regular expression using a terminal device or a server to obtain a target fusion strategy, wherein the computation graph is obtained by converting a deep learning model using the deep learning compiler, the regular expression is obtained by the upper-level user according to a customized setting of a candidate fusion strategy for fusing operator nodes in the computation graph, the computation graph includes at least one operator node, the at least one operator node represents at least one calculation performed by the deep learning compiler, the candidate fusion strategy includes a fusion strategy for input fusion, the fusion strategy for input fusion corresponds to at least one operator group node that directly processes an input tensor, the operator group node includes the at least one operator node, the input tensor is input by a user into the deep learning model, and the input tensor is determined according to at least one of an acoustic input, a voice input, and a tactile input of the user; Based on the target fusion strategy, using the terminal device or the server to fuse the operator nodes in the calculation graph to obtain a fused calculation graph; and The terminal device or the server is used to map the fused computation graph to the bottom layer of the deep learning compiler, so that the deep learning compiler outputs a machine binary code corresponding to the fused computation graph, and the machine binary code is executed by the back-end hardware device of the deep learning compiler.

2. The method according to claim 1, in, The using of a terminal device or a server to parse the regular expression to obtain a target fusion strategy includes: Parsing the regular expression using the terminal device or the server to generate a syntax tree; and The target fusion strategy is determined by using the terminal device or the server according to the execution program represented by the syntax tree.

3. The method according to claim 2, in, Parsing the regular expression using the terminal device or the server to generate a syntax tree includes: Parsing the character string in the regular expression using the terminal device or the server; In response to determining that the currently parsed character string is a first character string representing a first fusion strategy, using the terminal device or the server to determine the first character string as a child node; In response to determining that the currently parsed character string is a second character string representing an execution round of the first fusion strategy, using the terminal device or the server to determine the second character string as a parent node of the child node; and The syntax tree is determined by using the terminal device or the server according to the parent node and the child node.

4. The method according to claim 3, in, In response to determining that the currently parsed character string is a first character string representing a first fusion strategy, using the terminal device or the server to determine the first character string as a child node includes: In response to determining that the first string currently being parsed includes a first substring representing a sequence string start mark and a second substring representing a sequence string end mark, obtaining, using the terminal device or the server, a target sequence string located between the first substring and the second substring, the sequence string start mark and the sequence string end mark corresponding one to one; and The target sequence character string is determined as the child node by using the terminal device or the server.

5. The method according to claim 2, in, The step of determining the target fusion strategy by using the terminal device or the server according to the executable program represented by the syntax tree includes: Using the terminal device or the server to perform a pre-order traversal on the syntax tree to obtain semantic information represented by each tree node in the syntax tree; Determining the execution program using the terminal device or the server according to the semantic information represented by each tree node; and The terminal device or the server is used to determine the execution program as the target fusion strategy.

6. The method according to claim 1, in, The using of a terminal device or a server to parse the regular expression to obtain a target fusion strategy includes: traversing the character string in the regular expression by using the terminal device or the server; and In response to determining that the currently traversed character string is a third character string representing a second fusion strategy, the second fusion strategy is determined as the target fusion strategy by using the terminal device or the server.

7. The method according to claim 6, in, The third string at least includes a third substring and a fourth substring arranged in sequence, the third substring represents the first sub-fusion strategy, and the fourth substring represents the second sub-fusion strategy; The fusing the operator nodes in the computation graph by using the terminal device or the server based on the target fusion strategy includes: Based on the first sub-fusion strategy, using the terminal device or the server to fuse the operator nodes in the calculation graph to obtain a first fused calculation graph; as well as Based on the second sub-fusion strategy, the operator nodes in the first fusion computation graph are fused using the terminal device or the server.

8. The method according to claim 6, in, The using a terminal device or a server to parse the regular expression to obtain a target fusion strategy also includes: In response to determining that the currently traversed string includes the third string and a fourth string representing a second fusion strategy execution round, the target fusion strategy is determined using the terminal device or the server according to the second fusion strategy and the second fusion strategy execution round.

9. The method according to claim 8, in, The fusing the operator nodes in the computation graph by using the terminal device or the server based on the target fusion strategy includes: Based on the second fusion strategy, using the terminal device or the server to perform an (i+1)-th round of fusion on the operator nodes in the (i)-th round of fusion calculation graph, to obtain an (i+1)-th round of fusion calculation graph, wherein the first round of fusion calculation graph is obtained by performing a first round of fusion on the operator nodes in the calculation graph based on the second fusion strategy, and i is an integer greater than 1; and In response to determining that the fusion information of the i+1th round satisfies the preset constraints, the terminal device or the server uses the i+1th round fusion calculation graph as a fusion result of fusing the operator nodes in the calculation graph based on the second fusion strategy and the execution round of the second fusion strategy.

10. The method according to claim 9, in, The preset constraint conditions include at least one of the following: i+1 is equal to a preset value, the fusion calculation graph of the i+1th round is the same as the fusion calculation graph of the i-th round, and the update flag of the i+1th round indicates that the fusion calculation graph of the i+1th round has not been updated; the update flag is used to record the first representation information or the second representation information, the first representation information indicates that the calculation graph of the corresponding round has been updated, and the second representation information indicates that the calculation graph of the corresponding round has not been updated.

11. The method according to any one of claims 1 to 10, further comprising: include: Before, in response to receiving a regular expression associated with a computation graph in a deep learning compiler, parsing the regular expression using the terminal device or the server to obtain a target fusion strategy, Determine, by using the terminal device or the server, the number of execution rounds for the custom setting of the candidate fusion strategy; In response to the number of candidate fusion strategies based on which the process of determining the customized setting is based, determining, by using the terminal device or the server, a policy arrangement and combination mode for customized settings of the plurality of candidate fusion strategies; as well as The target fusion strategy is determined by using the terminal device or the server according to at least one of the execution round number and the strategy arrangement and combination mode, and the candidate fusion strategy.

12. The method according to claim 11, further comprising: include: According to the predefined regularization rule, the target fusion strategy is regularized using the terminal device or the server to obtain the regular expression.

13. The method according to any one of claims 1 to 10, in, The candidate fusion strategies include at least one of the following: vertical fusion, horizontal fusion, and recalculation.

14. The method according to claim 13, in, The fusion strategy of the input fusion includes: According to the input tensor, obtain a plurality of initial operator nodes that share the input tensor; Determining a plurality of target operator nodes matching the information according to the first input / output type information and the first tensor information of each of the plurality of initial operator nodes; and The multiple target operator nodes are merged.

15. The method according to claim 13, in, The recalculation fusion strategy includes: According to the operator group node, obtaining all consumer nodes corresponding to the operator group node; and In response to the second input-output type information and the second tensor information of the operator group node, and the third input-output type information and the third tensor information of the consumer node, it is determined that the operator group node and all the consumer nodes have information matching, and the operator group node and each consumer node in all the consumer nodes are fused respectively.

16. A node fusion device for a computational graph applied to a deep learning compiler, include: A parsing module, configured to parse the regular expression associated with a computation graph in a deep learning compiler in response to receiving a regular expression from an upper-level user, using a terminal device or a server to obtain a target fusion strategy, wherein the computation graph is obtained by converting a deep learning model using the deep learning compiler, the regular expression is obtained by the upper-level user according to a customized setting of a candidate fusion strategy for fusing operator nodes in the computation graph, the computation graph includes at least one operator node, the at least one operator node represents at least one calculation performed by the deep learning compiler, the candidate fusion strategy includes a fusion strategy for input fusion, the fusion strategy for input fusion corresponds to at least one operator group node that directly processes an input tensor, the operator group node includes the at least one operator node, the input tensor is input by a user into the deep learning model, and the input tensor is determined according to at least one of an acoustic input, a voice input, and a tactile input of the user; A fusion module is used to fuse the operator nodes in the computation graph using the terminal device or the server based on the target fusion strategy to obtain a fused computation graph; and to map the fused computation graph to the bottom layer of the deep learning compiler using the terminal device or the server, so that the deep learning compiler outputs a machine binary code corresponding to the fused computation graph, and the machine binary code is executed by the back-end hardware device of the deep learning compiler.

17. The device according to claim 16, in, The parsing module comprises: a syntax tree generation submodule, configured to parse the regular expression using the terminal device or the server to generate a syntax tree; and The first strategy determination submodule is used to determine the target fusion strategy using the terminal device or the server according to the execution program represented by the syntax tree.

18. The device according to claim 17, in, The syntax tree generation submodule includes: A parsing unit, used for parsing the character string in the regular expression using the terminal device or the server; a child node determining unit, configured to, in response to determining that the currently parsed character string is a first character string representing a first fusion strategy, determine the first character string as a child node by using the terminal device or the server; a parent node determination unit, configured to, in response to determining that the currently parsed character string is a second character string representing an execution round of the first fusion strategy, determine the second character string as a parent node of the child node using the terminal device or the server; and A syntax tree determination unit is used to determine the syntax tree according to the parent node and the child node using the terminal device or the server.

19. The device according to claim 18, in, The child node determination unit comprises: a sequence string acquisition subunit, configured to, in response to determining that the first string currently being parsed includes a first substring representing a sequence string start mark and a second substring representing a sequence string end mark, acquire, using the terminal device or the server, a target sequence string located between the first substring and the second substring, the sequence string start mark corresponding to the sequence string end mark in one-to-one correspondence; and The subnode determination subunit is used to determine the target sequence character string as the subnode by using the terminal device or the server.

20. The device according to claim 17, in, The first strategy determination submodule includes: A traversal unit, configured to perform a pre-order traversal on the syntax tree using the terminal device or the server to obtain semantic information represented by each tree node in the syntax tree; an execution formula determination unit, configured to determine the execution formula using the terminal device or the server according to the semantic information represented by each tree node; and A strategy determination unit is used to determine the execution program as the target fusion strategy using the terminal device or the server.

21. The device according to claim 16, in, The parsing module comprises: a traversal submodule, configured to traverse the character string in the regular expression using the terminal device or the server; and The second strategy determination submodule is configured to, in response to determining that the currently traversed character string is a third character string representing a second fusion strategy, determine the second fusion strategy as the target fusion strategy using the terminal device or the server.

22. The device according to claim 21, in, The third string at least includes a third substring and a fourth substring arranged in sequence, the third substring represents the first sub-fusion strategy, and the fourth substring represents the second sub-fusion strategy; The fusion module includes: A first fusion submodule, configured to fuse the operator nodes in the computation graph using the terminal device or the server based on the first sub-fusion strategy to obtain a first fused computation graph; as well as The second fusion submodule is used to fuse the operator nodes in the first fusion calculation graph using the terminal device or the server based on the second sub-fusion strategy.

23. The device according to claim 21, in, The parsing module also includes: The third strategy determination submodule is used to determine the target fusion strategy using the terminal device or the server in response to determining that the currently traversed string includes the third string and a fourth string representing the execution round of the second fusion strategy according to the second fusion strategy and the execution round of the second fusion strategy.

24. The device according to claim 23, in, The fusion module includes: a third fusion submodule, configured to perform an (i+1)-th round of fusion on the operator nodes in the fusion calculation graph of the i-th round using the terminal device or the server based on the second fusion strategy to obtain an (i+1)-th round of fusion calculation graph, wherein the first round of fusion calculation graph is obtained by performing a first round of fusion on the operator nodes in the calculation graph based on the second fusion strategy, and i is an integer greater than 1; and A submodule is defined, which is used to, in response to determining that the fusion information of the i+1th round satisfies the preset constraints, use the terminal device or the server to use the i+1th round fusion calculation graph as a fusion result of fusing the operator nodes in the calculation graph based on the second fusion strategy and the execution round of the second fusion strategy.

25. The device according to claim 24, in, The preset constraint conditions include at least one of the following: i+1 is equal to a preset value, the fusion calculation graph of the i+1th round is the same as the fusion calculation graph of the i-th round, and the update flag of the i+1th round indicates that the fusion calculation graph of the i+1th round has not been updated; the update flag is used to record the first representation information or the second representation information, the first representation information indicates that the calculation graph of the corresponding round has been updated, and the second representation information indicates that the calculation graph of the corresponding round has not been updated.

26. The device according to any one of claims 16 to 25, further comprising: include: An execution round number determination module, used to determine the execution round number of the custom setting for the candidate fusion strategy by using the terminal device or the server; a strategy arrangement and combination mode determination module, configured to determine, in response to the number of candidate fusion strategies based on which the process of determining the custom setting is based, a strategy arrangement and combination mode for custom settings of the plurality of candidate fusion strategies using the terminal device or the server; as well as A strategy determination module is used to determine the target fusion strategy using the terminal device or the server according to at least one of the execution round number and the strategy arrangement and combination method, and the candidate fusion strategy.

27. The device according to claim 26, further comprising: include: A regularization conversion module is used to perform regularization conversion on the target fusion strategy according to a predefined regularization rule using the terminal device or the server to obtain the regular expression.

28. The device according to any one of claims 16 to 25, in, The candidate fusion strategies include at least one of the following: vertical fusion, horizontal fusion, and recalculation.

29. The device according to claim 28, in, The fusion strategy of the input fusion includes: According to the input tensor, obtain a plurality of initial operator nodes that share the input tensor; Determining a plurality of target operator nodes matching the information according to the first input / output type information and the first tensor information of each of the plurality of initial operator nodes; and The multiple target operator nodes are merged.

30. The device according to claim 28, in, The recalculation fusion strategy includes: According to the operator group node, obtaining all consumer nodes corresponding to the operator group node; and In response to the second input-output type information and the second tensor information of the operator group node, and the third input-output type information and the third tensor information of the consumer node, it is determined that the operator group node and all the consumer nodes have information matching, and the operator group node and each consumer node in all the consumer nodes are fused respectively.

31. An electronic device, include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 15.

32. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-15.

33. A computer program product, comprising a computer program, wherein the computer program is stored on at least one of a readable storage medium and an electronic device, and when the computer program is executed by a processor, the method according to any one of claims 1 to 15 is implemented.