Program synthesis method and device, equipment and storage medium

By building a Bayesian network to analyze and optimize the API combination of TensorFlow programs, the problem of simple enumeration methods ignoring dependencies and overfitting is solved, and the generated program is more reasonable and universal.

CN119473236AInactive Publication Date: 2025-02-18SHANDONG UNIV
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510039350.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-10
Publication Date
2025-02-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The simple enumeration method ignores the dependencies between different alternative programs in the program, resulting in overfitting possible under a single input and output use case. The generated program combination only meets specific use cases and is not universal.

Method used

By obtaining the TensorFlow program, analyzing the composition of the API and its calling relationship, building a Bayesian network to describe the probability relationship between APIs, obtaining dependencies, establishing a ring-free dependency graph, and performing structure and parameter learning to obtain the probability distribution. Then, the enumeration selection is performed in the order of high probability from low probability, and the high probability API combination is preferred, and the optimal one is selected from the candidate results as the program synthesis result.

Benefits of technology

The generated program is more reasonable, reducing the phenomenon of overfitting, and ensuring that the program combination has a high probability of meeting the preset conditions under multiple input and output use cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119473236A_ABST
    Figure CN119473236A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computer programs, and discloses a program synthesis method and device, equipment and a storage medium, the method comprises the following steps: obtaining a TensorFlow program, and analyzing the composition of an application programming interface, the analysis of the composition of the application programming interface comprises the analysis of the API composition of the program and the calling relationship between APIs; constructing a Bayesian network, and describing a probability relationship between the application programming interfaces, the construction of the probability relationship including obtaining a dependency relationship, establishing an acyclic dependency graph, structure learning, parameter learning and obtaining probability distribution; and during program synthesis, enumeration selection is carried out according to a sequence from high probability to low probability, high-probability application programming interfaces are synthesized preferentially, and an optimal result is selected from candidate results according to the probability to serve as a synthesis program result. Therefore, the generated program is more reasonable, and the over-fitting phenomenon is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer program technology, for example, to a program synthesis method, apparatus, device and storage medium. Background Art

[0002] Enumerative program synthesis is a method of program synthesis that involves selecting candidate programs one by one and determining whether the combination of candidate programs satisfies the input-output relationship. It is simple to implement and has a wide range of applications.

[0003] However, the simple enumeration method ignores the dependencies between different alternative programs in the program. Common alternative programs may not be prioritized during the enumeration process. When there is only a single input and output use case for program synthesis, overfitting will occur.

[0004] Overfitting refers to the generation of an alternative program combination that only satisfies the current single input and output use case. If the content of the current input and output use case is changed, the alternative program combination will not satisfy our desired synthetic program.

[0005] During the implementation of the embodiments of the present disclosure, it was found that at least the following problems exist in the related art: The simple enumeration method ignores the dependencies between different alternative programs in the program. Common alternative programs may not be prioritized during the enumeration process. When there is only a single input and output use case for program synthesis, overfitting will occur.

[0006] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of this application. Summary of the Invention

[0007] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical elements or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.

[0008] The present disclosure provides a program synthesis method, the method comprising: Obtaining a TensorFlow program and analyzing the composition of an application programming interface, wherein analyzing the composition of the application programming interface includes analyzing the composition of the APIs of the TensorFlow program and the calling relationships between the APIs; Constructing a Bayesian network to describe the probabilistic relationships between application programming interfaces. This involves capturing dependencies, building acyclic dependency graphs, learning structures, learning parameters, and obtaining probability distributions. The enumeration selection is performed in order of probability from high to low, the application programming interface whose synthesis probability meets the preset conditions is given priority, and the candidate result that meets the optimal conditions is selected from the candidate results according to the probability as the program synthesis result.

[0009] In some embodiments, obtaining dependency relationships for constructing a Bayesian network includes: Get the TensorFlow project and filter the supported expressions. Analyze the calling relationships between operators, find situations where multiple operators are called, and record the calling relationships between multiple operators, where the operators are APIs of TensorFlow programs; If there is an indirect call, it is recorded together. Indirect call means that the result of the previous operator calculation is the parameter of the next operator. The relationship between the two operators and their calls is recorded.

[0010] In some embodiments, establishing an acyclic dependency graph for constructing a Bayesian network includes: Convert the call relationship into a directed graph; Remove the cycles of the directed graph to obtain a directed acyclic graph of the call relationship.

[0011] In some embodiments, converting the call relationship into a directed graph includes: Set up a directed graph, where the nodes are operators, the edges are the call relationships of the relational expressions, and the weight is the frequency of the call relationship. Sort the edges of the graph by weight from large to small. The step of removing the loop of the directed graph to obtain a directed acyclic graph of the call relationship includes: Initially, an empty graph is set up, and edges are selected in descending order of weight. If a cycle appears in the graph after adding an edge, the corresponding edge is not selected. Otherwise, the edge is added to the graph until all edges are selected to generate a directed acyclic graph.

[0012] In some embodiments, obtaining a probability distribution for constructing a Bayesian network includes: Based on the directed acyclic graph, constructing a Bayesian network; Using the edge set of the directed acyclic graph as the initial edge set of the Bayesian network, and using the supported operator set as the node set of the network; According to the occurrence of operators in each TensorFlow project, the hill climbing algorithm is applied for structural learning, combined with the maximum likelihood estimation method for parameter learning to construct a Bayesian network and obtain the corresponding probability distribution relationship. Based on the probability distribution relationship, the probability of the remaining operators appearing as parameters when the target operator appears is obtained.

[0013] In some embodiments, enumeration and selection are performed in descending order of probability, application programming interfaces whose synthesis probabilities meet preset conditions are prioritized, and candidate results that meet the optimal conditions are selected from the candidate results according to the probabilities as the program synthesis results, including: Based on the probability distribution relationship, the enumeration process is modified to add probability information and give priority to enumerating expressions with high probability; When a program result is consistent with the expected output, the corresponding program is used as a candidate program; The candidate results that meet the optimal conditions are selected from the candidate programs according to the probability distribution as the program synthesis results.

[0014] The present disclosure provides a program synthesis device, which includes: An acquisition module is used to acquire a TensorFlow program and analyze the composition of an application programming interface, wherein analyzing the composition of the application programming interface includes analyzing the API composition of the TensorFlow program and the calling relationship between the APIs; A construction module for constructing a Bayesian network to describe the probabilistic relationship between application programming interfaces, wherein the constructed probabilistic relationship includes obtaining dependency relationships, establishing an acyclic dependency graph, structure learning, parameter learning, and obtaining probability distribution; The synthesis module is used to enumerate and select in order of probability from high to low, give priority to the application programming interface whose synthesis probability meets the preset conditions, and select the candidate result that meets the optimal conditions from the candidate results according to the probability as the program synthesis result.

[0015] In some embodiments, the building module is further used to obtain a TensorFlow project and filter expressions to retain support; Analyze the calling relationships between operators, find situations where multiple operators are called, and record the calling relationships between multiple operators, where the operators are APIs of TensorFlow programs; If there is an indirect call, it is recorded together. Indirect call means that the result of the previous operator calculation is the parameter of the next operator. The relationship between the two operators and their calls is recorded.

[0016] An embodiment of the present disclosure provides an electronic device, the device including at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor to enable the at least one processor to perform the above-mentioned program synthesis method.

[0017] An embodiment of the present disclosure provides a storage medium storing program instructions, which, when run, execute the above-mentioned program synthesis method.

[0018] The program synthesis method, apparatus, device, and storage medium provided by the embodiments of the present disclosure can achieve the following technical effects: The present invention obtains a TensorFlow program and analyzes the composition of an application programming interface, wherein analyzing the composition of the application programming interface includes analyzing the API composition of the TensorFlow program and the calling relationship between the APIs; constructing a Bayesian network to describe the probabilistic relationship between the application programming interfaces, and constructing the probabilistic relationship includes obtaining dependency relationships, establishing an acyclic dependency graph, structural learning, parameter learning, and obtaining probability distribution; when synthesizing the program, enumerating and selecting in descending order of probability, giving priority to synthesizing high-probability application programming interfaces, and selecting the best one from the candidate results according to probability as the synthesized program result. This can make the generated program more reasonable and reduce overfitting.

[0019] The above general description and the following description are exemplary and explanatory only and are not intended to limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] One or more embodiments are exemplarily described by corresponding drawings. These exemplary descriptions and drawings do not limit the embodiments. Elements with the same reference numerals in the drawings are shown as similar elements. The drawings do not constitute a scale limitation. In addition, Figure 1 It is a flowchart of a program synthesis method provided by an embodiment of the present disclosure; Figure 2 This is a flow chart of constructing a Bayesian network to obtain dependency relationships provided by an embodiment of the present disclosure; Figure 3 This is a flow chart of constructing a Bayesian network and establishing an acyclic dependency graph, provided by an embodiment of the present disclosure; Figure 4 This is a flow chart of constructing a Bayesian network to obtain a probability relationship according to an embodiment of the present disclosure; Figure 5 is a flow chart of a synthesis process result provided by an embodiment of the present disclosure; Figure 6 is a schematic structural diagram of a program synthesis device provided by an embodiment of the present disclosure; Figure 7 It is a structural diagram of a program synthesis device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0021] In order to be able to understand the features and technical content of the embodiments of the present disclosure in more detail, the implementation of the embodiments of the present disclosure is described in detail below in conjunction with the accompanying drawings. The accompanying drawings are for reference only and are not used to limit the embodiments of the present disclosure. In the following technical description, for the sake of convenience of explanation, a full understanding of the disclosed embodiments is provided through multiple details. However, one or more embodiments can still be implemented without these details. In other cases, to simplify the drawings, well-known structures and devices can be simplified for display.

[0022] The terms "first," "second," and the like in the embodiments of the present disclosure are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate to facilitate the description of the embodiments of the present disclosure herein. Furthermore, the terms "including," "having," and any variations thereof are intended to cover non-exclusive inclusions.

[0023] Unless otherwise stated, the term "plurality" means two or more.

[0024] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B means: A or B.

[0025] The term "and / or" describes an association between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or A and B.

[0026] The term "correspondence" may refer to an association relationship or a binding relationship. The correspondence between A and B means that there is an association relationship or a binding relationship between A and B.

[0027] In order to solve the above problems, the present disclosure provides a program synthesis method, apparatus, device and storage medium.

[0028] The program synthesis method, apparatus, device, and storage medium provided by the embodiments of the present disclosure are described below with reference to the accompanying drawings.

[0029] Figure 1 It is a flowchart of a program synthesis method provided by an embodiment of the present disclosure.

[0030] like Figure 1 As shown, the program synthesis method may include: S101, obtain a TensorFlow program and analyze the composition of the application programming interface.

[0031] Specifically, the TensorFlow program can be 100 programs whose programming language is Python and which are actual development projects (excluding teaching projects, sample projects, e-books or video explanation projects) on a code hosting platform, with the number of stars ranging from high to low. The number of programs can also be adjusted according to actual conditions.

[0032] Specifically, an API refers to the TensorFlow Application Programming Interface (API), such as tf.add and tf.divide. S101 obtains a TensorFlow program. Analyzing the composition of the API involves crawling the TensorFlow program and then analyzing it to identify the APIs it consists of and the calling relationships between these APIs. For example, if we obtain the line of program code "tf.where(tf.equal(in1, 0.0), tf.zeros([2, 3]), tf.multiply(tf.cast(in1,tf.float32), in2))", we analyze that this line of code consists of five operators: tf.where, tf.equal, tf.zeros, tf.multiply, and tf.cast. Furthermore, there is a calling relationship where tf.where calls tf.equal, tf.zeros, and tf.multiply, and tf.multiply calls tf.cast.

[0033] S102, constructing a Bayesian network to describe the probabilistic relationship between application programming interfaces, wherein the constructed probabilistic relationship includes obtaining dependency relationships, establishing an acyclic dependency graph, structure learning, parameter learning, and obtaining probability distribution.

[0034] S103 , enumerating and selecting in descending order of probability, giving priority to synthesizing application programming interfaces whose probabilities meet preset conditions, and selecting the candidate results that meet the optimal conditions as the program synthesis result from the candidate results according to the probability.

[0035] In S103 , the probability of satisfying the preset condition may specifically be a portion with a high probability, and the portion may be one or more.

[0036] In some embodiments, constructing a Bayesian network to obtain dependency relationships may specifically include: Get the TensorFlow project and filter the supported expressions. Analyze the calling relationships between operators, find situations where multiple operators are called, and record the calling relationships between multiple operators, where the operators are APIs of TensorFlow programs; If there is an indirect call, it is recorded together. Indirect call means that the result of the previous operator calculation is the parameter of the next operator. The relationship between the two operators and their calls is recorded.

[0037] In some embodiments, establishing an acyclic dependency graph for constructing a Bayesian network may specifically include: Convert the call relationship into a directed graph; Remove the cycles of the directed graph to obtain a directed acyclic graph of the call relationship.

[0038] In some embodiments, converting the call relationship into a directed graph may include: Set up a directed graph, where the nodes are operators, the edges are the call relationships of the relational expressions, and the weight is the frequency of the call relationship. Sort the edges of the graph by weight from large to small. Remove the loops from the directed graph to obtain a directed acyclic graph of the call relationship, which may include: Initially, an empty graph is set up, and edges are selected in descending order of weight. If a cycle appears in the graph after adding an edge, the corresponding edge is not selected. Otherwise, the edge is added to the graph until all edges are selected to generate a directed acyclic graph.

[0039] In some embodiments, constructing a Bayesian network to obtain a probability distribution may specifically include: Construct a Bayesian network based on a directed acyclic graph; Use the edge set of the directed acyclic graph as the initial edge set of the Bayesian network and the supported operator set as the node set of the network; According to the occurrence of operators in each TensorFlow project, the hill climbing algorithm is applied for structural learning, combined with the maximum likelihood estimation method for parameter learning to construct a Bayesian network and obtain the corresponding probability distribution relationship. Based on the probability distribution relationship, the probability of the remaining operators appearing as parameters when the target operator appears is obtained.

[0040] In some embodiments, enumeration and selection are performed in descending order of probability, application programming interfaces whose synthesis probabilities meet preset conditions are prioritized, and candidate results that meet the optimal conditions are selected from the candidate results according to the probability as the program synthesis result. Specifically, the following may be included: Based on the probability distribution relationship, the enumeration process is modified to add probability information and give priority to enumerating expressions with high probability; When a program result is consistent with the expected output, the corresponding program is used as a candidate program; The candidate results that meet the optimal conditions are selected from the candidate programs according to the probability distribution as the program synthesis results.

[0041] Furthermore, in the embodiments of the present disclosure, for ease of understanding, the five processes of constructing the probability relationship described above may be exemplarily described with reference to the accompanying drawings.

[0042] Specifically, combined Figure 2 As shown, for constructing a Bayesian network to obtain dependency relationships in S102, it may specifically include step 21A and step 22A: Step 21A: Filter and retain supported expressions.

[0043] Specifically, we retrieve all application programming interfaces (APIs) in the TensorFlow project and compare them to the operators in this disclosure. If the expression exists, we retain it; otherwise, we filter it out. The operators in this disclosure refer to the TensorFlow APIs supported by our program, that is, the APIs that our program can combine. In this solution, we don't support every TensorFlow operator; we only support over a hundred commonly used APIs.

[0044] Step 22A: Analyze and record the calling relationships between multiple operators.

[0045] Specifically, the mathematical operators in the expression are first extracted and converted into equivalent TensorFlow operators. If multiple operators are in the same position and have a call relationship, the call relationship between the multiple operators is directly recorded; if there is an indirect call relationship, all operators in the indirect call and their call relationship are recorded.

[0046] The above extraction of mathematical operators and conversion to equivalent TensorFlow operators refers to extracting the addition, subtraction, multiplication, division, exponentiation, and comparison symbols in the expression and converting them to tf.add, tf.subtract, tf.multiply, tf.divide, tf.pow, tf.equal, tf.greater, tf.greater_equal, or tf.not_equal, respectively. For example, the expression a + b is converted to tf.add(a, b).

[0047] In Python, the term "co-location" refers to the presence of code on the same line after code compression and formatting. The formatting process preserves the semantics of the code, removing only aesthetically pleasing line breaks. If multiple operators appear on the same line, and the result of one operator is used as an argument for another, the two operators are co-located and have a call relationship.

[0048] For example, in the expression tf.add(tf.multiply(in1, in2), in3), tf.add and tf.multiply are two operators at the same position, and the dependency relationship is that the former calls the latter.

[0049] Indirect call means that the result of the calculation of the previous operator is used as the parameter of the next operator. In this case, there is an indirect call relationship between the two operators. The specific relationship is that the previous operator depends on the next operator.

[0050] For example, in the two expressions o1 = tf.add(in1, in2) and o2 = tf.multiply(o1, in3), the result o1 of tf.add is the parameter of tf.multiply. Therefore, there is an indirect calling relationship between tf.add and tf.multiply, and the specific relationship is that the latter calls the former.

[0051] Based on the above steps 21A and 22A, in the embodiment of the present disclosure, dependency relationships are obtained for constructing a Bayesian network. The dependency relationships include calling relationships of common operators, and common expressions can be enumerated first in enumeration program synthesis.

[0052] Combine Figure 3 As shown, for the Bayesian network constructed in S102, an acyclic dependency graph is established, which may specifically include step 21B and step 22B: Step 21B: Convert the call relationship into a directed graph.

[0053] Specifically, a directed graph can be set up, where the points in the graph are operators and the edges are the dependencies of the operators. If operator A calls operator B, there is an edge from A to B in the graph. The directed graph may have loops, self-loops, and isolated points that are not connected by any edges.

[0054] For the convenience of explanation, the edge set of the graph is sorted, and the weight of the edge is set to the number of occurrences of this call relationship. The sorting rule is to sort from large to small according to the weight of the edge, that is, to sort from large to small according to the frequency of operator call relationship.

[0055] Step 22B: Remove the loops of the directed graph to obtain a directed acyclic graph of the call relationship.

[0056] Specifically, you can initialize an empty graph without any edges, select edges from the edge set of the call relationship and add them to the graph. If there is a cycle in the graph, delete the edge; otherwise, add the edge to the graph until all edges are selected. The final graph is the desired one.

[0057] Based on the above steps 21B and 22B, in the embodiment of the present disclosure, an acyclic dependency graph is established for constructing a Bayesian network. Since loops are not allowed in a Bayesian network, it is necessary to break the loops in the graph. In order to retain as many and more meaningful call relationships as possible, call relationships with a high frequency should be retained. In this way, all loops in the graph can be removed while retaining as many call relationships as possible.

[0058] Combine Figure 4 As shown, for constructing a Bayesian network to obtain a probability relationship in S102, it may specifically include step 21C and step 22C: Step 21C: Construct a Bayesian network based on the obtained directed dependency graph.

[0059] Specifically, the edges of the directed acyclic graph are used as the initial edge set of the Bayesian network, and the set of operators supported by the disclosed embodiments is used as the node set of the network. Based on the occurrence of operators in each TensorFlow project, a comma-separated values ​​(CSV) file is constructed for structure learning, where the x-axis represents the project name and the y-axis represents the set of operators supported by the disclosed embodiments, with a value of 1 indicating the presence of the operator in the project. Subsequently, a hill climbing algorithm is applied to perform structure learning.

[0060] Step 22C: Use maximum likelihood estimation as a parameter learning method to obtain the probability distribution.

[0061] Specifically, based on the probabilistic graphical model obtained through structural learning, maximum likelihood estimation is used for parameter learning. This method estimates the conditional probability distribution between the variables in the model, thereby obtaining a conditional probability table. For each node, the conditional probability table describes the probability distribution of that node given its parent node (i.e., the dependent variable). By processing the conditional probability table, the probability of each operator being a parameter of a specific operator can be obtained, sorted from high to low.

[0062] Combine Figure 5 As shown, the acquired probability information is added to the enumeration process, and the best one is selected from the candidate results according to the probability as the synthesis program result, that is, S103, which may specifically include step 21D and step 22D: Step 21D: Use the probability information to optimize the enumeration process.

[0063] Specifically, the traditional enumeration process does not involve probability information. Instead, the expressions obtained by enumeration at each stage are directly stored in an array in the order in which they are generated. In this case, if the subsequent enumeration process needs to use the intermediate results in the array, it is performed in the order in which they are generated, without considering the call probability relationship between operators. By introducing probability information, the shortcomings of traditional enumeration can be remedied. After the enumeration process of a stage is completed, the generated array is processed, adopting a strategy of trading space for time. For each operator, the elements in the array are rearranged from high to low according to the probability of other operators as parameters, and the rearranged array is retained for each operator. In this way, the next time the array is used in the enumeration process, enumeration will be performed according to the probability information.

[0064] For example, consider an intermediate process array consisting of [result1 generated by tf.add, result2 generated by tf.multiply, result3 generated by tf.subtract]. These three operators serve as arguments to tf.divide. Their call probabilities, from highest to lowest, are tf.multiply, tf.add, and tf.subtract. Therefore, a probability-sorted array [result2, result1, result3] is stored for tf.divide. The next time the arguments to tf.divide are enumerated, the result generated by tf.multiply is prioritized because it has the highest probability and represents the most likely outcome.

[0065] Step 22D: Select the best one from the candidate results according to probability as the result of the synthesis process.

[0066] Specifically, when a program's result matches the expected output, it is considered a candidate program. For each candidate, a weight is assigned, representing its likelihood. The weight is derived from the call relationships between operators within the candidate. For example, a candidate of the form tf.add(tf.multiply()) with tf.multiply as the argument to tf.add is ranked fifth in terms of likelihood, so the weight of this expression is 5. A higher weight actually indicates a lower likelihood. Finally, the optimal solution from the candidate programs is selected based on the probability distribution as the result of the synthesized program.

[0067] It should be noted that the embodiments of the present disclosure do not limit the execution subject of the program synthesis method. For example, the program synthesis method of the embodiments of the present disclosure can be applied to data processing devices such as terminal devices or servers. The terminal device refers to an electronic device with a wireless connection function. In some embodiments, the terminal device is, for example, a mobile device, a computer, or a vehicle-mounted device built into a hover car, or any combination thereof. Mobile devices may include, for example, mobile phones, smart home devices, wearable devices, smart mobile devices, virtual reality devices, etc., or any combination thereof. Wearable devices include, for example, smart watches, smart bracelets, pedometers, etc.

[0068] This paper obtains TensorFlow programs, analyzes the composition of application programming interfaces (APIs), constructs a Bayesian network to describe the probabilistic relationships between APIs, and constructs probabilistic relationships, including obtaining dependencies, building an acyclic dependency graph, structural learning, parameter learning, and obtaining probability distributions. During program synthesis, the program selects APIs in descending order of probability, prioritizing the synthesis of high-probability APIs, and selects the best candidate from the candidate results according to probability as the synthesized program result. This can generate more reasonable programs and reduce overfitting.

[0069] and Figure 1 Corresponding to the program synthesis method in the present disclosure, a program synthesis device is also provided, such as Figure 6 As shown, the device may specifically include: An acquisition module 601 is configured to acquire a TensorFlow program and analyze the composition of an application programming interface (API), wherein analyzing the composition of the application programming interface (API) includes analyzing the composition of the TensorFlow program's APIs and the calling relationships between the APIs. A construction module 602 is used to construct a Bayesian network to describe the probabilistic relationship between application programming interfaces, wherein the constructed probabilistic relationship includes obtaining dependency relationships, establishing an acyclic dependency graph, structure learning, parameter learning, and obtaining probability distribution; The synthesis module 603 is used to enumerate and select in descending order of probability, give priority to the application programming interface whose synthesis probability meets the preset conditions, and select the candidate result that meets the optimal conditions from the candidate results according to the probability as the program synthesis result.

[0070] In some embodiments, the construction module 602 is further used to obtain a TensorFlow project and filter expressions to retain support; Analyze the calling relationships between operators, find situations where multiple operators are called, and record the calling relationships between multiple operators, where the operators are APIs of TensorFlow programs; If there is an indirect call, it is recorded together. Indirect call means that the result of the previous operator calculation is the parameter of the next operator. The relationship between the two operators and their calls is recorded.

[0071] In some embodiments, the construction module 602 is further configured to convert the call relationship into a directed graph; Remove the cycles of the directed graph to obtain a directed acyclic graph of the call relationship.

[0072] In some embodiments, converting the call relationship into a directed graph includes: Set up a directed graph, where the nodes are operators, the edges are the call relationships of the relational expressions, and the weight is the frequency of the call relationship. Sort the edges of the graph by weight from large to small. Remove the loops from the directed graph to obtain a directed acyclic graph of the call relationship, including: Initially, an empty graph is set up, and edges are selected in descending order of weight. If a cycle appears in the graph after adding an edge, the corresponding edge is not selected. Otherwise, the edge is added to the graph until all edges are selected to generate a directed acyclic graph.

[0073] In some embodiments, the construction module 602 is further configured to construct a Bayesian network based on the directed acyclic graph; Use the edge set of the directed acyclic graph as the initial edge set of the Bayesian network and the supported operator set as the node set of the network; According to the occurrence of operators in each TensorFlow project, the hill climbing algorithm is applied for structural learning, combined with the maximum likelihood estimation method for parameter learning to construct a Bayesian network and obtain the corresponding probability distribution relationship. Based on the probability distribution relationship, the probability of the remaining operators appearing as parameters when the target operator appears is obtained.

[0074] In some embodiments, enumeration and selection are performed in descending order of probability, application programming interfaces whose synthesis probabilities meet preset conditions are prioritized, and candidate results that meet the optimal conditions are selected from the candidate results according to the probabilities as the program synthesis results, including: Based on the probability distribution relationship, the enumeration process is modified to add probability information and give priority to enumerating expressions with high probability; When a program result is consistent with the expected output, the corresponding program is used as a candidate program; The candidate results that meet the optimal conditions are selected from the candidate programs according to the probability distribution as the program synthesis results.

[0075] Combine Figure 7As shown, an embodiment of the present disclosure further provides a program synthesis device 700, comprising a processor 704 and a memory 701. Optionally, the system may further include a communication interface 702 and a bus 703. The processor 704, the communication interface 702, and the memory 701 may communicate with each other via the bus 703. The communication interface 702 may be used for information transmission. The processor 704 may invoke logic instructions in the memory 701 to execute the program synthesis method of the above embodiment.

[0076] In addition, the logic instructions in the memory 701 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.

[0077] Memory 701, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present disclosure. Processor 704 executes the program instructions / modules stored in memory 701 to perform functional applications and data processing, thereby implementing the program synthesis method in the above-mentioned embodiments.

[0078] The memory 701 may include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data generated based on the use of the terminal device. Furthermore, the memory 701 may include high-speed random access memory and non-volatile memory.

[0079] An embodiment of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to execute a program synthesis method.

[0080] The aforementioned computer-readable storage medium may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.

[0081] The technical solutions of the embodiments of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method of the embodiments of the present disclosure. The aforementioned storage medium may be a non-transitory storage medium, including: a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and other media that can store program code, or a transient storage medium.

[0082] The above description and accompanying drawings sufficiently illustrate the embodiments of the present disclosure to enable those skilled in the art to practice them. Other embodiments may include structural, logical, electrical, process, and other changes. The embodiments are merely representative of possible variations. Unless expressly required, individual components and functions are optional, and the order of operations may vary. Portions and features of some embodiments may be included in or substituted for portions and features of other embodiments. As used in the description of the embodiments, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. Similarly, the term "and / or," as used in this application, is intended to encompass any and all possible combinations of one or more of the associated listed items. Furthermore, when used in this application, the terms "comprise" and its variations "comprises" and / or "comprising" refer to the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. In the absence of further limitations, the phrase "comprising a..." does not preclude the presence of other identical elements in the process, method, or device comprising the elements. In this document, each embodiment may focus on the differences from other embodiments, and similar parts between the embodiments can be referenced to each other. For methods, products, etc. disclosed in the embodiments, if they correspond to the method section disclosed in the embodiments, then the relevant parts can be referenced to the description of the method section.

[0083] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. Technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. Technicians can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0084] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices and equipment) can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units may be merely a logical functional division. In actual implementation, other division methods may be used, such as combining or integrating multiple units or components into another system, or omitting or disabling certain features. Furthermore, the coupling or direct coupling or communication connection shown or discussed between each other may be through some interface, or indirect coupling or communication connection between devices or units, and may be electrical, mechanical, or other forms. Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, i.e., they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to implement the embodiments according to actual needs. Furthermore, the functional units in the embodiments disclosed herein may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit.

[0085] The flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions and operations of the systems, methods and computer program products according to the embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment or part of the code, and the module, program segment or part of the code contains one or more executable instructions for implementing the specified logical functions. In some alternative implementations, the functions marked in the boxes can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, which can depend on the functions involved. In the descriptions corresponding to the flowcharts and block diagrams in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in an order different from that disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, or they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified function or action, or may be implemented by a combination of dedicated hardware and computer instructions.

[0086] Various embodiments of the systems and techniques described 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), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system comprising 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.

[0087] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0088] 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, apparatus, or device. 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, apparatus, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, 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), optical fibers, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0089] 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).

[0090] The systems and techniques described herein can 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 can 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.

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

[0092] It should be understood that the various forms of processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions of this disclosure can be achieved, and this document is not limited here.

[0093] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.

Claims

1. A program synthesis method, characterized in that: The method comprises: Obtaining a TensorFlow program and analyzing the composition of an application programming interface, wherein analyzing the composition of the application programming interface includes analyzing the API composition of the TensorFlow program and the calling relationship between the APIs; Constructing a Bayesian network to describe the probabilistic relationship between application programming interfaces, where the constructed probabilistic relationship includes obtaining dependency relationships, building acyclic dependency graphs, structure learning, parameter learning, and obtaining probability distributions; The enumeration selection is performed in order of probability from high to low, the application programming interface whose synthesis probability meets the preset conditions is given priority, and the candidate result that meets the optimal conditions is selected from the candidate results according to the probability as the program synthesis result.

2. The method according to claim 1, characterized in that Obtain dependencies for building a Bayesian network, including: Get the TensorFlow project and filter the supported expressions. Analyze the calling relationship between operators, find the situation of calling multiple operators, and record the calling relationship between multiple operators, where the operator is the API of the TensorFlow program; If there is an indirect call, it will be recorded together. Indirect call means that the result of the previous operator calculation is the parameter of the next operator. The relationship between the two operators and their calls is recorded.

3. The method according to claim 2, characterized in that Establish an acyclic dependency graph for building a Bayesian network, including: Convert the call relationship into a directed graph; Remove the loops of the directed graph and obtain a directed acyclic graph of the call relationship.

4. The method according to claim 3, characterized in that: The converting the call relationship into a directed graph includes: Set up a directed graph, where the nodes of the graph are operators, the edges are relational call relationships, and the weights are the frequency of the call relationships. Sort the edges of the graph from large to small according to the weights. The step of removing the loop of the directed graph to obtain a directed acyclic graph of the call relationship includes: Initially, an empty graph is set up, and edges are selected in descending order of weight. If a cycle appears in the graph after adding edges, the corresponding edge is not selected. Otherwise, the edge is added to the graph until all edges are selected to generate a directed acyclic graph.

5. The method according to claim 3, characterized in that: Obtain probability distribution for building Bayesian networks, including: Based on the directed acyclic graph, constructing a Bayesian network; Using the edge set of the directed acyclic graph as the initial edge set of the Bayesian network, and using the supported operator set as the node set of the network; According to the occurrence of operators in each TensorFlow project, the hill climbing algorithm is applied for structural learning, combined with the maximum likelihood estimation method for parameter learning, to build a Bayesian network and obtain the corresponding probability distribution relationship. Based on the probability distribution relationship, the probability of the remaining operators appearing as parameters when the target operator appears is obtained.

6. The method according to claim 5, characterized in that The enumeration and selection are performed in descending order of probability, the application programming interface with the probability of synthesis meeting the preset condition is given priority, and the candidate result meeting the optimal condition is selected from the candidate results according to the probability as the program synthesis result, including: Based on the probability distribution relationship, modify the enumeration process, add probability information, and give priority to enumerating expressions with high probability; When a program result is consistent with the expected output, the corresponding program is used as a candidate program; The candidate results that meet the optimal conditions are selected from the candidate programs according to the probability distribution as the program synthesis results.

7. A program synthesis device, characterized in that: The device comprises: An acquisition module is used to acquire a TensorFlow program and analyze the composition of an application programming interface, wherein analyzing the composition of the application programming interface includes analyzing the API composition of the TensorFlow program and the calling relationship between the APIs; A construction module, used for constructing a Bayesian network to describe the probabilistic relationship between application programming interfaces, wherein the constructed probabilistic relationship includes obtaining dependency relationships, establishing an acyclic dependency graph, structure learning, parameter learning, and obtaining probability distribution; The synthesis module is used to enumerate and select in order of probability from high to low, give priority to the application programming interface whose synthesis probability meets the preset conditions, and select the candidate results that meet the optimal conditions from the candidate results according to the probability as the program synthesis result.

8. The device according to claim 7, characterized in that The building module is also used to obtain the TensorFlow project and filter the expressions that retain support; Analyze the calling relationship between operators, find the situation of calling multiple operators, and record the calling relationship between multiple operators, where the operator is the API of the TensorFlow program; If there is an indirect call, it will be recorded together. Indirect call means that the result of the previous operator calculation is the parameter of the next operator. The relationship between the two operators and their calls is recorded.

9. An electronic device, characterized in that: include: at least one processor; and a memory communicatively coupled to the at least one processor; It is characterized in that 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 so that the at least one processor can execute the method according to any one of claims 1 to 6.

10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Software error hierarchical diagnosis method based on Bayes network reasoning

    CN107025169A

  • Systems and methods for providing deeply stacked automated program synthesis

    CN110383296A

  • Dependence graph generation method and device, equipment, storage medium and program product

    CN112925522A

  • System and method for session framework for program synthesis

    CN118786411A

  • System and method for program induction using probabilistic neural programs

    US20190034785A1