Graph structure file processing method and device and nonvolatile storage medium
By identifying and parsing algebraic rings in the graph structure file and determining the execution order, the problem of the inability to deal with algebraic rings in the prior art is solved, and the parsing efficiency and calculation performance of the graph structure file are improved.
Patent Information
- Application Number
- CN202510404602.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-07-25
AI Technical Summary
In the prior art, the graph structure file analysis method cannot effectively process specific computing structures such as algebraic rings, resulting in low parsing efficiency or failure to successfully parse, affecting the performance and stability of the simulation system.
By receiving the graph structure file, the relevant information of the module is extracted, the algebraic ring is identified and parsed, the execution order is determined, and the execution order is determined by using the execution order determination method is used to process the pending module, and the sequence of time-series modules is converted to a sequence of time-series modules to eliminate the ring-like dependencies.
The analysis method of graph structure files is optimized, infinite loops caused by algebraic rings are avoided, and the calculation efficiency is improved.
Smart Images

Figure CN120371310A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and in particular, to a method and device for processing a graph structure file, and a non-volatile storage medium. Background Art
[0002] In a graphical programming environment, a user constructs a complex computational model by intuitively dragging and dropping modules and connection lines. This process greatly simplifies the difficulty of traditional programming and improves work efficiency. Especially in system simulation software, a user can easily build a model reflecting the behavior of a physical system. These models often consist of numerous computational units, and the units are interconnected through clear signal flow paths to form a complete graph structure. In related technologies, when parsing a graph structure file generated by the above method, there is a problem that specific computational structures such as algebraic loops cannot be processed, resulting in low parsing efficiency of the graph structure file or even the inability to successfully parse it.
[0003] For the above problems, no effective solution has been proposed yet. Summary of the Invention
[0004] Embodiments of this application provide a method and device for processing a graph structure file, and a non-volatile storage medium, so as to at least solve the technical problem that the graph structure file parsing method in related technologies cannot parse specific computational structures such as algebraic loops.
[0005] According to one aspect of the embodiments of this application, a method for processing a graph structure file is provided, including: receiving a target file, where the target file is a graph structure file composed of multiple modules and straight lines for connecting the modules, and each module represents a computational unit; processing the target file to obtain relevant information of the multiple modules included in the target file, and determining whether there is an algebraic loop in the target file according to the relevant information, where an algebraic loop is a cyclic structure composed of multiple modules of an algebraic operation type; in the case where there is an algebraic loop in the target file, first parse the algebraic loop to obtain an algebraic loop parsing result; determine the algebraic loop parsing result and other modules in the target file as the to-be-processed modules corresponding to the target file, and use an execution order determination method to determine the execution order of each to-be-processed module.
[0006] Optionally, process the target file, including: parsing the target file to obtain relevant information for each module, where the relevant information includes: the type of the module, the input port information of the module, the output port information of the module, and the associated modules connected to the module by a straight line; filling each type of relevant information into the fields included in the reference file to obtain a target reference file, where the fields corresponding to different types of relevant information are different, and the format of the reference file is any format readable by a computer device. In the target reference file, multiple fields corresponding to each module are stored as an object.
[0007] Optionally, determine whether there is an algebraic loop in the target file according to the relevant information, including: performing a connection relationship check on each module based on the relevant information of each module to obtain a check result; in the case where the check result indicates passing the check, traverse all the modules included in the target file to obtain a traversal result, and determine whether there is an algebraic loop in the target file according to the traversal result.
[0008] Optionally, the relevant information of each module includes: the associated modules connected to the module by a straight line; performing a connection relationship check on each module based on the relevant information of each module to obtain a check result, including: for each module, determining whether the relevant information contains an associated module; in the case where the relevant information does not contain an associated module, determining the type of the module according to the relevant information; in the case where the type of the module is an input signal module or an output signal calculation module, determining that the check result is passing the check; in the case where the type of the module is not an input signal module and an output signal calculation module, determining that the check result is not passing the check; in the case where the relevant information contains an associated module, determining that the check result is passing the check.
[0009] Optionally, traverse all the modules included in the target file to obtain a traversal result, including: performing the following traversal steps: determining any module as the starting module, where the starting module is the first module to be added with an access mark during the traversal process; determining the first type of modules directly connected to the starting module and the second type of modules indirectly connected to the starting module, and adding access marks to the first type of modules and the second type of modules; determining whether there are remaining modules in the target file, where the remaining modules are the modules that have not been added with access marks; in the case where there are no remaining modules, determining the dependency graph generated with the starting module, the first type of modules, and the second type of modules as nodes and the straight lines representing the connection relationships between the starting module, the first type of modules, and the second type of modules as edges as the traversal result; in the case where there are remaining modules, repeatedly perform the above traversal steps on the remaining modules until there are no remaining modules in the target file to obtain multiple execution results, where each execution result is a dependency graph; determining the multiple dependency graphs corresponding to the multiple execution results as the traversal result.
[0010] Optionally, determining whether there is an algebraic loop in the target file according to the traversal result includes: for each dependency graph included in the traversal result, sequentially accessing each module in the dependency graph according to the access order recorded in the dependency graph, and recording the access times of each module; determining whether there is a target module whose access times are greater than the preset access times and whose type is an algebraic operation type; in the case where there is a target module, determining whether there is an algebraic loop in the target file; in the case where there is no target module, determining that there is no algebraic loop in the target file.
[0011] Optionally, parsing the algebraic loop includes: parsing the algebraic loop according to the mathematical attributes of the algebraic loop to obtain the output values of the respective modules in the algebraic loop; replacing each module in the algebraic loop with the output value corresponding to the module to obtain a sequential module sequence corresponding to the algebraic loop, where there is no cyclic dependency among the multiple modules in the sequential module sequence.
[0012] Optionally, using an execution order determination method to determine the execution order of each module to be processed includes: classifying the modules to be processed into a first type of module to be processed and a second type of module to be processed according to the attribute information of the modules to be processed, where the attribute information is used to indicate the relationship between the calculation process of the module to be processed and the input signal at the current moment, the first type of module to be processed is a module whose calculation process does not depend on the input signal at the current moment, and the second type of module to be processed is a module whose calculation process depends on the input signal at the current moment; randomly sorting each module to be processed in the first type of module to be processed to obtain a first sorting result; sorting each module to be processed in the second type of module to be processed to obtain a second sorting result, where the smallest sorting serial number in the second sorting result is greater than the largest sorting serial number in the first sorting result; determining the execution order according to the first sorting result and the second sorting result.
[0013] Optionally, sorting each module to be processed in the second type of module to be processed includes: performing the following sorting steps: traversing each module to be processed in the second type of module to be processed, and during the traversal, determining the module connected to the input end of the module to be processed in the second type of module to be processed as the input module; in the case where the input module has been marked with a sorting serial number, determining the sum of the largest sorting serial number in the current sorting result and a preset value as the sorting serial number of the module to be processed in the second type of module to be processed, where the largest sorting serial number in the current sorting result is determined according to the first sorting result and the modules to be processed in the second type of module to be processed that have been sorted; in the case where the input module has not been marked with a sorting serial number, classifying the module to be processed in the second type of module to be processed into a secondary sorting set; in the case where it is determined that each module to be processed in the second type of module to be processed has been traversed once, repeatedly performing the above sorting steps on the modules to be processed in the second type of module to be processed in the secondary sorting set until each module to be processed in the second type of module to be processed is marked with a sorting serial number.
[0014] Optionally, the method for processing the graph structure file further includes: in the case where there is no algebraic loop in the target file, determining all modules in the target file as the modules to be processed in the target file; and using an execution order determination method to determine the execution order of each module to be processed.
[0015] According to another aspect of the embodiments of the present application, there is also provided a device for processing a graph structure file, including: a receiving module, configured to receive a target file, where the target file is a graph structure file composed of a plurality of modules and straight lines for connecting the modules, and each module represents a computing unit; a processing module, configured to process the target file to obtain relevant information of the plurality of modules included in the target file, and determine whether there is an algebraic loop in the target file according to the relevant information, where the algebraic loop is a circular structure composed of a plurality of modules of an algebraic operation type; an analysis module, configured to, in the case where there is an algebraic loop in the target file, first analyze the algebraic loop to obtain an algebraic loop analysis result; a determination module, configured to determine the algebraic loop analysis result and other modules in the target file as the modules to be processed corresponding to the target file, and use an execution order determination method to determine the execution order of each module to be processed.
[0016] According to another aspect of the embodiments of the present application, there is also provided a non-volatile storage medium in which a computer program is stored, where the method for processing the graph structure file as described above is executed by a device where the non-volatile storage medium is located by running the computer program.
[0017] According to another aspect of the embodiments of the present application, there is also provided an electronic device including a memory and a processor, where a computer program is stored in the memory, and the processor is configured to execute the method for processing the graph structure file as described above through the computer program.
[0018] According to another aspect of the embodiments of the present application, there is also provided a computer program product including computer instructions, and when the computer instructions are executed by a processor, the steps of the method for processing the graph structure file as described above are implemented.
[0019] In the embodiments of the present application, a target file is received, where the target file is a graph structure file composed of multiple modules and straight lines for connecting the modules, and each module represents a computing unit; the target file is processed to obtain relevant information of the multiple modules included in the target file, and it is determined whether there is an algebraic loop in the target file according to the relevant information, where the algebraic loop is a circular structure composed of multiple modules of the algebraic operation type; in the case where there is an algebraic loop in the target file, the algebraic loop is first analyzed to obtain an algebraic loop analysis result; the algebraic loop analysis result and other modules in the target file are determined as the modules to be processed corresponding to the target file, and by using the execution order determination method to determine the execution order of each module to be processed, the parsing method of the graph structure file is optimized by identifying and analyzing the algebraic loop in the graph structure file, achieving the purpose of avoiding infinite loops in the calculation due to the circular dependency relationship of the algebraic loop during the execution of the graph structure file, thereby realizing the technical effect of improving the calculation efficiency, and further solving the technical problem that the parsing method of the graph structure file in the related art cannot parse a specific calculation structure such as an algebraic loop. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present application, and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0021] Figure 1 is a hardware structure block diagram of a computer terminal for implementing a method for processing a graph structure file according to an embodiment of the present application;
[0022] Figure 2 is a step flowchart of a method for processing a graph structure file according to an embodiment of the present application;
[0023] Figure 3 is a schematic diagram of a graph structure file according to an embodiment of the present application;
[0024] Figure 4 is a schematic structural diagram of a reference file according to an embodiment of the present application;
[0025] Figure 5 is a json data example according to an embodiment of the present application;
[0026] Figure 6 is a schematic diagram of analyzing an algebraic loop according to an embodiment of the present application;
[0027] Figure 7 is a structural diagram of a device for processing a graph structure file according to an embodiment of the present application;
[0028] Figure 8It is a schematic diagram of a graph structure file without an algebraic loop according to an embodiment of the present application. Detailed implementation manners
[0029] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily need to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0031] In order to better understand the embodiments of the present application, the technical terms involved in the embodiments of the present application are explained as follows:
[0032] Algebraic loop: An algebraic loop refers to a closed-loop dependency relationship formed between certain calculation units in a model (i.e., a graph structure file). The output of each calculation unit in the algebraic loop is used as the input of another calculation unit to participate in the calculation.
[0033] In the related art, although the parsing method for graph structure files can read and understand the models in the graphical programming environment, in the face of specific calculation structures, such as algebraic loops, there are often problems of low processing efficiency or even inability to parse. The cyclic relationship existing in the algebraic loop may cause the solution process to fall into an infinite loop or generate non-linear dependencies, thereby affecting the performance and stability of the simulation system. In addition, when the related art parses the graph structure file, there is a lack of effective means for quickly and accurately identifying the characteristics of each calculation unit and the dependency relationship between modules. Therefore, there is also a problem of long time consumption for determining the calculation order. To solve this problem, relevant solutions are provided in the embodiments of the present application, which will be described in detail below.
[0034] According to an embodiment of the present application, a method embodiment for processing a graph structure file is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0035] The method embodiment provided by the embodiment of the present application can be executed on a mobile terminal, a computer terminal or a similar computing device. Figure 1 The hardware structure block diagram of a computer terminal for implementing the method for processing a graph structure file is shown. As Figure 1 shown, the computer terminal 10 may include one or more (shown as 102a, 102b,..., 102n in the figure) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may further include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which can be included as one of the ports of the BUS bus), a network interface, a power supply, and / or a camera. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above electronic device. For example, the computer terminal 10 may further include more or fewer components than Figure 1 shown, or have a different configuration from Figure 1 shown.
[0036] It should be noted that the above one or more processors 102 and / or other data processing circuits can generally be referred to as "data processing circuits" in this article. The data processing circuit can be embodied in software, hardware, firmware, or any combination thereof, in whole or in part. In addition, the data processing circuit can be a single independent processing module, or be incorporated in whole or in part into any one of the other elements in the computer terminal 10. As involved in the embodiment of the present application, the data processing circuit is a kind of processor control (such as the selection of a variable resistance terminal path connected to an interface).
[0037] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the processing method of the graph structure file in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the above-mentioned processing method of the graph structure file. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories can be connected to the computer terminal 10 through a network. Examples of the above-mentioned network include but are not limited to the Internet, intranet, local area network, mobile communication network, and combinations thereof.
[0038] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of the computer terminal 10. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station and thus communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0039] The display can be, for example, a touch-screen liquid crystal display (LCD), which enables a user to interact with the user interface of the computer terminal 10.
[0040] The embodiments of the present application provide a processing method of a graph structure file that can run in the above-mentioned operating environment. Figure 2 It is a step flowchart of the processing method of the graph structure file provided by the embodiments of the present application, as Figure 2 shown, and the method includes the following steps:
[0041] Step S202, receive a target file, where the target file is a graph structure file composed of multiple modules and straight lines for connecting the modules, and each module represents a computing unit.
[0042] The graph structure file provided by the embodiments of the present application is applicable to graph structure files in different data formats generated by different simulation software. Therefore, the target file received in step S202 can be a graph structure file (also referred to as a graphical programming model) generated in any simulation software and then sent by the simulation software, or can be a graph structure file (also referred to as a graphical programming model) generated in any simulation software exported to the terminal device by the user and then sent by the terminal device. Figure 3It is a schematic diagram of a graph structure file. Figure 3 The graph structure file shown is a simulation model (i.e., the graph structure file) created for the anti-skid control simulation experiment of an automobile, as Figure 3 shown. The graph structure file (i.e., the target file) is composed of multiple modules and straight lines connecting the multiple modules; among them, the module can be a computing unit, representing the operations that need to be performed when executing the graph structure file. For example, Figure 3 the graph structure file shown includes: slip rate calculation (slip), addition operation (sum), one-dimensional lookup (oneDlookup), merging multiple signals into one signal (mux), division operation (divide), detecting the sign of the input signal (sign): if the signal is positive, output +1; if the signal is 0, output 0; if the signal is negative, output -1, and many other operations. The module can also be a parameter participating in the simulation and the operations of the parameter. For example, Figure 3 the calculation of the vehicle weight distribution (m*g / 4) shown in calculates the vehicle weight (m*g) and redistributes the load on each wheel, and calculates the reciprocal (1 / Rr) of the rolling radius (Rr) of the tire. The straight lines used to connect different modules in the graph structure file are used to indicate the connection of signals or the flow of data between modules; by connecting multiple modules with straight lines, a complete data processing flow is constructed.
[0043] Step S204: Process the target file to obtain the relevant information of the multiple modules included in the target file, and determine whether there is an algebraic loop in the target file according to the relevant information. Among them, the algebraic loop is a ring structure composed of multiple modules of the algebraic operation type.
[0044] After receiving the graph structure file (i.e., the target file) in step S202, in step S204, the backend processes the graph structure file to extract the information recorded in the graph structure file. As mentioned in step S202, the graph structure file consists of multiple modules and the straight lines connecting the modules. Then, the information recorded in the graph structure file is mainly the relevant information of each module included therein. For example, the attribute information of the module (such as the type of the module, input and output ports), the association relationship between each module and other modules, etc. In step S204, through processing the target file, the relevant information of each module in a computer-readable format is extracted, and based on this information, it is determined whether there is a closed-loop dependency structure (i.e., an algebraic loop) formed by connecting multiple modules of algebraic operation types through straight lines in the complete data processing flow recorded in the graph structure file. Among them, a module of algebraic operation type refers to that each computing unit (i.e., module) forming the algebraic loop indicates an algebraic type of operation; the algebraic type of operation includes basic arithmetic operations such as addition, subtraction, multiplication, and division, algebraic equation solving, recursive operations: the output of the module directly or indirectly references its own output, feedback and closed-loop control: the output signal becomes an input signal again through the feedback link to participate in the calculation, signal processing operations: such as filters (such as first-order or second-order low-pass filters) and integrators, state variable operations: the update of the state variable depends on the value of itself or other state variables, logical operations: AND, OR, NOT, look-up table operations, etc.
[0045] According to some optional embodiments of the present application, processing the target file includes: parsing the target file to obtain the relevant information of each module, where the relevant information includes: the type of the module, the input port information of the module, the output port information of the module, and the associated modules connected to the module through straight lines; filling each type of relevant information into the fields included in the reference file to obtain a target reference file, where the fields corresponding to different types of relevant information are different, and the format of the reference file is any format readable by a computer device. In the target reference file, multiple fields corresponding to each module are stored as an object.
[0046] The graph structure file is a file used to describe the modules and their connection relationships in a graphical programming environment. It usually contains rich graphical information and algorithm descriptions, such as module types, port connections, parameter settings, etc. However, the original graph structure file may adopt a specific binary or custom text format, which is not easy to share and parse between different software or platforms. Therefore, in step S204, the received graph structure file (i.e., the target file) is processed, mainly by extracting the information recorded in the graph structure file and storing it in a format readable by any computer device (such as json format). In this embodiment, the graph structure file can be stored in json format through the following method. First, parse the graph structure file generated by the front end (such as an interactive interface) to obtain the relevant information of each module recorded in the graph structure file. Further, fill the relevant information of the parsed module into each field in the reference file correspondingly. After filling all the parsed information into the reference file, the target reference file can be obtained. Figure 4 is a schematic diagram of the structure of the reference file, as Figure 4 shown, the fields included in the above reference file are: Module (Block), Solver (solver), Simulation Time (Time). Among them, in the Module (Block) field, all the calculation unit (i.e., module) information contained in the target file is filled. The data type in this field is a list (i.e., a list collection), and the information of each module is encapsulated in an element in the list. The information in each element describes the characteristics and connection relationships of a module. In the Solver (solver) field, all the information of the solution algorithms contained in the target file is filled. For fields such as algorithm type and parameter settings, the data type is a dictionary (dict). In the Simulation Time (Time) field, the simulation duration corresponding to the entire target file is filled. The data type filled in this field is double-precision floating-point number (double) type. Still as Figure 4 shown, the reference file also includes a File Name (FileName) field, which is used to fill the name of the file after the target file is converted to json format (i.e., the target reference file). The data type in this field is a string (string). For each module (Block), its relevant information includes: Module Type (BlockType), Input Port Information (inputPort), Output Port Information (outputPort), associated modules, etc. Since the Module (Block) is a data of list (i.e., list collection) type, the information of each module can be stored as Figure 4The data structure shown, where the module type (BlockType) is used to indicate the function of the module, such as an adder, integrator, etc., and the field "module type (BlockType)" itself is a data of string type; the module ID (ID) is the unique identifier of the module, used to distinguish different modules, and the data type of this field itself is an integer (int); the name (Name) is the custom name of the module, and its data type is also a string (string); the data types of the module input port (inputPort) and the module output port (outputPort) are lists (i.e., list sets) to record connection details of ports such as port numbers and data stream identifiers. inputPort and outputPort use a list set, containing two primary keys, "Line" and "PortID". The "Line" field is a data of string type, used to identify the source or destination of the data stream. Line usually contains a descriptive label, which can be a combination of the module name and the port, or a unique code number to represent the data stream line. For example, "gain_1_1" in {"Line": "gain_1_1"} refers to a specific output or input line of a module named gain (the gain module indicates a multiplication operation). The first 1 represents the instance number of the gain module, and the second 1 identifies the specific port number of the gain module. The "PortID" field is an integer type (int) field, used to clearly indicate which input or output port of the module is the target of the data stream connection. For example, {"PortID": 1} means that the data stream is connected to the position with port number 1. In a graphical programming environment, a module may have multiple input or output ports. The use of PortID ensures that the data stream is accurately connected to the correct position, avoiding ambiguity during connection. When the fields {"Line": "gain_1_1", "PortID": 1} are stored in inputPort or outputPort, it can be used to represent an output / input line of the graph structure file, whose name is gain_1_1 and is connected to port number 1. Additionally, as Figure 4 shown, the relevant information of the module may also include the execution priority (Order). The priority recorded in Order is the priority defined according to the order of connecting each module with a straight line in the graph structure file, which is an initial execution order, rather than the execution order finally determined by the method provided in the embodiments of the present application.
[0047] It should be noted that, in this embodiment, the information used to determine whether there is an algebraic loop in the target file is extracted from a file in JSON format. After the target file is converted into a file in JSON format, each module is regarded as an object, and its relevant information such as module type, module parameters, module connection relationship, etc. are stored in the JSON object. Figure 5 is an example of JSON data. In the Figure 5 code shown, "fruit" is equivalent to the module field, and different module-related information is stored in this field. Each set of curly braces {} represents an object (i.e., a type of module), and the data within the curly braces {} describes various attributes (i.e., relevant information) of the module in the form of key-value pairs. In this key-value pair data structure, the key name represents the name of the attribute, which is represented by a string. For example Figure 5 "type", "shape", "color", and "number" in Figure 5 are key names; the value can be represented using data structures such as arrays, strings, numerical values, etc.; for example
[0048] According to some other optional embodiments of the present application, determining whether there is an algebraic loop in the target file according to the relevant information includes: checking the connection relationship of each module based on the relevant information of each module to obtain a check result; in the case where the check result indicates passing the check, traversing all the modules included in the target file to obtain a traversal result, and determining whether there is an algebraic loop in the target file according to the traversal result.
[0049] In this embodiment, the method of depth-first traversal can be used to determine whether there is an algebraic loop in the target file. Specifically, before performing the depth-first search, first determine whether there is a straight line connected to each module in all the modules included in the graph structure file (i.e., the target file) to obtain a check result; if the check result is passing the check, it means that the graph structure file format is correct. At this time, further perform a depth-first search on the graph structure file, find the sequential dependency relationship of all the modules in the graph structure file through the depth-first search, find all the node information (i.e., the relevant information of all the modules) to obtain a traversal result, and determine whether there is an algebraic loop in the graph structure file according to the traversal result. If the check result indicates that the check fails, it means that the graph structure file format is incorrect. At this time, output a prompt message for prompting to modify the target file. For example, prompt the user to add the connection relationship of the module in the graph structure file.
[0050] Optionally, the relevant information of each module includes: the associated modules connected to the module by a straight line; performing a connection relationship check on each module based on the relevant information of each module, and obtaining a check result, including: for each module, determining whether the relevant information contains an associated module; in the case where the relevant information does not contain an associated module, determining the type of the module according to the relevant information; in the case where the type of the module is an input signal module or an output signal calculation module, determining that the check result is passed; in the case where the type of the module is not an input signal module and an output signal calculation module, determining that the check result is not passed; in the case where the relevant information contains an associated module, determining that the check result is passed.
[0051] In this embodiment, since the relevant information of each module records the input port, output port, and associated module of the module, and the input port and output port are the basic attribute information of the module, usually the relevant information of each module contains the input port and the output port. Therefore, after obtaining the relevant information of the module, the connection relationship of the module can be checked by checking whether the relevant information contains an associated module connected by a straight line; specifically, if the relevant information of a module contains both an input port, an output port, and an associated module at the same time, it means that there is a straight line connected to the module in the graph structure file, and the module passes the check; otherwise, if its relevant information does not contain an associated module, then further judge the type of the relevant information without an associated module. If the type of the module is an input or output signal module, it is regarded as passing the check, because the input signal module is used to provide data, and the output signal calculation module is used to display the calculation result. The existence or connection status of the input signal module and the output signal calculation module will not affect the dependency relationship and calculation order between the modules.
[0052] According to some optional embodiments of the present application, traverse all the modules included in the target file, and obtain a traversal result, including: performing the following traversal steps: determining any module as the starting module, where the starting module is the first module to be added with an access mark during the traversal process; determining the first type of modules directly connected to the starting module and the second type of modules indirectly connected to the starting module, and adding access marks to the first type of modules and the second type of modules; determining whether there are remaining modules in the target file, where the remaining modules are the modules that have not been added with access marks; in the case where there are no remaining modules, determining the dependency graph generated with the starting module, the first type of modules, and the second type of modules as nodes and the straight lines representing the connection relationships between the starting module, the first type of modules, and the second type of modules as edges as the traversal result; in the case where there are remaining modules, repeating the above traversal steps for the remaining modules until there are no remaining modules in the target file, obtaining multiple execution results, where each execution result is a dependency graph; determining the multiple dependency graphs corresponding to the multiple execution results as the traversal result.
[0053] The principle of depth - first search is to start from the starting node, visit nodes as deep as possible along a path until reaching the deepest node, then backtrack to the previous node and continue exploring other unvisited paths. Therefore, in this embodiment, when performing depth - first search on the graph structure file, it is necessary to first determine a starting node (i.e., the starting module). When starting to execute the depth - first search method, all the modules included in the graph structure file are unvisited modules. Therefore, any module in the graph structure file can be used as the starting node (i.e., the starting module) and start the visit from this starting module. During the depth - first search process, an access mark is added to each visited module. The starting module is the first module in the graph structure file to which an access mark is added when traversing the graph structure file. After determining the starting module, determine the access path according to the connection relationship between the starting module and other modules, and sequentially visit multiple modules connected to the starting module by a straight line along the access path (including the first - type modules directly connected to the starting module by a straight line and the second - type modules connected to the starting module by a straight line but with other modules in between) and add access marks to these modules until the last module on this access path is visited. Then check whether there are still unvisited modules (i.e., remaining modules) in the graph structure file (i.e., the target file). Since the visited modules will be added with access marks, it is possible to determine whether a module is a remaining module by identifying whether the module has been added with an access mark. In the above - mentioned way, if it is determined that there are still unvisited modules (i.e., remaining modules) in the graph structure file after traversing once along its access path starting from the starting module, perform the above - mentioned depth - first search steps again (i.e., determine the starting module and sequentially visit multiple modules connected to the starting module by a straight line along an access path of the starting module) until all the modules in the graph structure file are added with access marks, and then end the depth - first search. Since the number of traversals is different when performing depth - first search on the graph structure file, the obtained traversal results are also different. If all the modules in the graph structure file have been added with access marks after one depth - first search, the traversal result is the execution result output by this one - time depth - first search; if there are still remaining modules without added access marks in the graph structure file after one depth - first search and multiple depth - first searches need to be performed, the traversal result is the multiple execution results output by performing multiple depth - first searches. In this embodiment, the execution result output each time depth - first search is performed is a dependency graph. In the dependency graph, the modules visited during the depth - first search process are used as nodes, and the straight lines representing the access order are used as edges.
[0054] In this embodiment, the depth-first search can also be implemented through the following steps. Step 1: Create a marker array (visited), which is used to record the access status of each module. Initially, set the access status of all modules to unvisited. Step 2: Select a starting module as the current module (the module being accessed is the current module), and mark it as visited. Step 3: For the current module, traverse its adjacent modules. If an adjacent module has not been visited, use that adjacent module as the new current module and repeat Step 2; if all adjacent modules have been visited, perform backtracking. Step 4: During backtracking, return to the previous module that has not been fully visited and continue to traverse its unvisited adjacent modules. If there are still unvisited modules after backtracking to the starting module, select one of the unvisited modules as the new starting module and repeat Step 2; if backtracking reaches the starting node and all nodes have been visited, end the depth-first search.
[0055] According to some other optional embodiments of the present application, determining whether there is an algebraic loop in the target file according to the traversal result includes: for each dependency graph included in the traversal result, sequentially access each module in the dependency graph according to the access order recorded in the dependency graph, and record the access times of each module; determining whether there is a target module whose access times are greater than the preset access times and whose type is an algebraic operation type; in the case of the existence of the target module, determining whether there is an algebraic loop in the target file; in the case of the non-existence of the target module, determining that there is no algebraic loop in the target file.
[0056] As mentioned in the previous embodiment, the result output by executing the depth-first search method is a dependency graph that records the access order of each module in the graph structure file. Since the depth-first search method uses the order in which modules are connected by straight lines as the access order for access, and the straight lines in the dependency graph record the access order, the edges in the dependency graph are the association relationships between the modules. Whether there is an algebraic loop in the graph structure file can be determined by accessing the dependency graph. For example, analyze the dependency graph to check whether there is a cyclic path that starts from a certain module and returns to itself, and all modules in this cyclic path are of the algebraic operation type. If so, it is determined that there is an algebraic loop. In this embodiment, when analyzing each dependency graph in the traversal result, each module can be specifically accessed in the access order and the access times are recorded. Whether there is an algebraic loop is judged by the access times of each module. This is because, for the closed-loop structure of the algebraic loop, once accessed, it will loop infinitely, that is, each module in the algebraic loop will be accessed more than once. Then, check whether there is an access time exceeding the preset number of times (for example, 1 time) in the recorded access times. If it exists, and the type of the module corresponding to this access time is still the algebraic operation type, it indicates that there is an algebraic loop structure in the target file. On the contrary, if the above two conditions (the access time exceeds the preset number of times and the type is the algebraic operation type) cannot be satisfied at the same time, it is determined that there is no algebraic loop in the target file.
[0057] Step S206, in the case where there is an algebraic loop in the target file, first parse the algebraic loop to obtain an algebraic loop parsing result.
[0058] If it is detected in step S204 that the received target file contains an algebraic loop structure, then in step S206, the algebraic loop parsing method is executed. By executing the algebraic loop parsing method, the algebraic loop is parsed into multiple modules without cyclic dependencies. That is, the algebraic loop parsing result obtained by parsing the algebraic loop in step S206 contains multiple modules and the association relationships between these modules, but the association relationships included in the parsing result are not cyclic dependencies and will not cause the multiple modules to form an algebraic loop.
[0059] Optionally, parsing the algebraic loop includes: parsing the algebraic loop according to the mathematical attributes of the algebraic loop to obtain the output values of each module in the algebraic loop; replacing each module in the algebraic loop with the output value corresponding to the module to obtain a timing module sequence corresponding to the algebraic loop, where there are no cyclic dependencies among the multiple modules in the timing module sequence.
[0060] The method provided by the embodiments of the present application includes an analytical method for algebraic loops. By executing the analytical method, the algebraic loops are analyzed to eliminate the circular dependencies in the target file. In this embodiment, when analyzing an algebraic loop, first, according to the mathematical properties of the algebraic loop (i.e., the calculation methods represented by each module in the algebraic loop and the connection relationships between each module), the equations corresponding to the algebraic loop are determined; further, according to the characteristics of the equations (such as linearity, non-linearity, the scale of the equations, etc.), the solution methods are determined (for example, Gaussian elimination method, Gauss-Seidel iteration), and the above solution methods are used to solve the equations corresponding to the algebraic loop to obtain the output values of each module in the algebraic loop. After obtaining the output values of each module in the algebraic loop, each module in the algebraic loop is replaced with the corresponding solution result (i.e., the output value), that is, the output value of the module is directly used to replace the module; through the replacement, the original relationship between the modules with circular dependencies is converted into a sequence of timing modules composed of multiple modules connected by linear dependencies, achieving the purpose of eliminating circular dependencies. It should also be noted that in the method provided by the embodiments of the present application, after each module in the algebraic loop is replaced with its corresponding output value, the new execution order of the modules can also be determined by re-traversing the adjusted model to ensure that there are no circular dependencies between all modules. Figure 6 It is a schematic diagram for analyzing an algebraic loop. Figure 6 It shows an algebraic loop structure composed of a sum module and a gain module. The sin module, as a generator of the time series signal sin(t), is used to input the time series signal to the sum module and is also used as a calculation unit for indicating the calculation of the sine value sin(t); the sum module is also used as a calculation unit for indicating the summation operation; the print module is used to display the output data. According to the mathematical properties of the algebraic loop, the linear equation corresponding to the algebraic loop is determined by using the algebraic loop analysis method as: X = sin(t) + 2*X. During the analysis process, the algebraic loop is replaced with the above linear equation, and the above linear equation is located in Figure 6 the position of the algebraic unit in it. Through analysis, the output value of the gain module is -1, and the output value of the sum module is the iterative process of x. Then, through analysis, the analysis result of this linear equation can generate a sequence of timing modules generated by the iterative process of x. Replacing the algebraic loop structure with Figure 6 the algebraic loop unit in it, replacing the sum module that causes the circular structure with the iterative process of x, and the initial value of x is user-defined and can be included in the target file. Since the algebraic loop is converted into the corresponding linear equation, the circular dependency relationship is eliminated.
[0061] Step S208: Determine the modules to be processed corresponding to the target file by using the algebraic loop analysis result and other modules in the target file, and determine the execution order of each module to be processed by using the execution order determination method.
[0062] To execute the target file, it is necessary to determine the execution order of each module involved in the execution of the target file (i.e., the module to be processed corresponding to the target file). If an algebraic loop is detected in the graph structure file in step S204, then after parsing the algebraic loop, it is necessary to re-determine the multiple modules whose execution order is to be determined (i.e., the modules to be processed). Specifically, in step S208, the modules included in the algebraic loop parsing result and the other modules in the target file that do not belong to the algebraic loop structure are determined as the modules whose execution order is to be determined (i.e., the modules to be processed), and an execution order determination method is further used to determine the execution order of each module to be processed.
[0063] According to some optional embodiments of the present application, using the execution order determination method to determine the execution order of each module to be processed includes: classifying the modules to be processed into a first type of module to be processed and a second type of module to be processed according to the attribute information of the module to be processed, where the attribute information is used to indicate the relationship between the calculation process of the module to be processed and the input signal at the current moment, the first type of module to be processed is a module whose calculation process does not depend on the input signal at the current moment, and the second type of module to be processed is a module whose calculation process depends on the input signal at the current moment; randomly sorting each module to be processed in the first type of module to be processed to obtain a first sorting result; sorting each module to be processed in the second type of module to be processed to obtain a second sorting result, where the smallest sorting serial number in the second sorting result is greater than the largest sorting serial number in the first sorting result; determining the execution order according to the first sorting result and the second sorting result.
[0064] The ultimate goal of the method provided by the embodiments of this application is to determine the execution order of each module in the graph structure file (i.e., the target file). If there is an algebraic loop, the algebraic loop parsing method is implemented first and then the execution order determination method. As mentioned in the above embodiments, when parsing an algebraic loop, each module in the algebraic loop is replaced with its corresponding output value. That is, when there is an algebraic loop in the target file, after the algebraic loop is parsed, the modules whose execution order needs to be determined (i.e., the modules to be processed) change to all the modules in the algebraic loop parsing result and the modules that originally did not belong to the algebraic loop in the target file (i.e., other modules). The specific steps to determine the execution order for the above-mentioned modules to be processed using the execution order are as follows: First, according to the attribute information of the module (whether the calculation process depends on the input signal at the current moment), all the modules to be processed are divided into type-a modules (i.e., the first type of modules) whose calculation process depends on the input signal at the current moment and type-b modules (i.e., the second type of modules) whose calculation process does not depend on the input signal at the current moment; in this embodiment, it is defined that type-a modules are calculated before type-b modules. Therefore, after classifying the modules to be processed, it is necessary to first determine the execution order of each type-a module, and then determine the execution order of type-b modules after each type-a module has determined its execution order. Therefore, the largest sorting serial number in the sorting result of type-a modules (i.e., the first sorting result) is smaller than the smallest sorting serial number in the sorting result of type-b modules (i.e., the second sorting result). The execution order of the final obtained target file is jointly determined by combining the two groups of sorting results. In this embodiment, there is no calculation sequence priority among type-a modules and they can be sorted arbitrarily. Therefore, multiple type-a modules can be sorted in sequence by traversing type-a modules, and the serial number of each module is recorded. When determining the calculation order of type-a modules, the sorted type-a modules are marked as sorted, put into the ordered list (ordered_list), and the current maximum serial number (order) is recorded; the unsorted type-b modules are put into the unordered list (unordered_list).
[0065] Optionally, sort each module to be processed in the second type of modules to be processed, including: performing the following sorting steps: traverse each module to be processed in the second type of modules, and during the traversal, determine the module connected to the input end of the module to be processed in the second type of modules as the input module; when the input module has been marked with a sorting serial number, determine the sum of the maximum sorting serial number in the current sorting result and a preset value as the sorting serial number of the module to be processed in the second type of modules, where the maximum sorting serial number in the current sorting result is determined according to the first sorting result and the modules to be processed in the second type of modules that have been sorted; when the input module is not marked with a sorting serial number, classify the module to be processed in the second type of modules into the secondary sorting set; when it is determined that each module to be processed in the second type of modules has been traversed once, repeat the above sorting steps for the modules to be processed in the second type of modules in the secondary sorting set until each module to be processed in the second type of modules is marked with a sorting serial number.
[0066] In this embodiment, after the sorting of type-a modules is completed, it can be determined whether there are type-b modules by judging whether the unordered list is empty. If the list is not empty, traverse the unordered list and sort the type-b modules (i.e., the second type of modules); otherwise, if the list is empty, it means that the calculation order of all modules has been determined, and the determination of the execution order is stopped. When determining the execution order of each type-b module, judge whether the module connected to the input end of each type-b module (i.e., the input module) has been sorted. If the module connected to the input end has been sorted, update the maximum sorting serial number in the current sorting result and assign a sorting serial number to the current module: for example, add 1 (i.e., the preset value) to the current maximum serial number (i.e., the maximum sorting serial number) as the sorting serial number of the current module. If the current module is the first type-b module to be sorted, the current maximum serial number is the maximum sorting serial number in the sorting result of type-a modules (i.e., the first sorting result); if the current module is not the first type-b module to be sorted, the current maximum serial number is the maximum sorting serial number among the sorting serial numbers of all the modules that have been sorted (including all type-a modules and the sorted type-b modules). On the other hand, if it is determined that the module connected to the input end of a certain type-b module (i.e., the input module) has not been sorted, skip this module first and classify this module into the secondary sorting set. Until all type-b modules have been traversed once, check whether the secondary sorting set records type-b modules. If it does, perform the above sorting steps (determine whether the input-end module has been sorted, determine the sorting serial number assigned to the current module according to whether the input-end module has been sorted, or skip) for each type-b module in the secondary sorting set until all type-b modules to be processed have obtained sorting serial numbers.
[0067] According to some alternative embodiments of the present application, the method for processing a graph structure file further includes: when there is no algebraic loop in the target file, determining all modules in the target file as the modules to be processed of the target file; and using an execution order determination method to determine the execution order of each module to be processed.
[0068] In this embodiment, when determining the execution order of the graph structure file (i.e., the target file) in the case where there is no algebraic loop in the graph structure file, it is necessary to determine the execution order of each module included in the target file respectively, that is, each module included in the target file is a module whose execution order is to be determined (i.e., a module to be processed). In this embodiment, an execution order determination method is still used to determine the execution order of each module included in the target file. Specifically, when using the execution order determination method, first, according to the attribute information of the module (whether the calculation process depends on the input signal at the current moment), all modules to be processed are divided into type-a modules (i.e., the first type of modules) whose calculation process depends on the input signal at the current moment and type-b modules (i.e., the second type of modules) whose calculation process does not depend on the input signal at the current moment; in this embodiment, it is defined that type-a modules are calculated before type-b modules. Therefore, after classifying the modules to be processed, it is necessary to first determine the execution order of each type-a module, and then determine the execution order of type-b modules after the execution order of each type-a module is determined. Therefore, the largest sorting serial number in the sorting result of type-a modules (i.e., the first sorting result) is smaller than the smallest sorting serial number in the sorting result of type-b modules (i.e., the second sorting result). And the final execution order of the target file is jointly determined by integrating the two groups of sorting results.
[0069] Through the above steps, it is possible to effectively identify the algebraic loop structure in the file, parse the algebraic loop and re-determine the execution order of the file in the case of the existence of the algebraic loop, avoiding the problem of infinite loop in the execution of the graph structure file caused by the circular dependency relationship of the algebraic loop during the execution process, improving the efficiency of parsing the graph structure file, and optimizing the execution process at the same time.
[0070] Figure 7 is a structural diagram of a processing device for a graph structure file provided according to an embodiment of the present application, as Figure 7As shown in the figure, the processing device for the graph structure file includes: a receiving module 70, configured to receive a target file, where the target file is a graph structure file composed of multiple modules and straight lines for connecting the modules, and each module represents a computing unit; a processing module 72, configured to process the target file to obtain relevant information of the multiple modules included in the target file, and determine whether there is an algebraic loop in the target file according to the relevant information, where the algebraic loop is a circular structure composed of multiple modules of algebraic operation types; an analysis module 74, configured to, when there is an algebraic loop in the target file, first analyze the algebraic loop to obtain an algebraic loop analysis result; and a determination module 76, configured to determine the algebraic loop analysis result and other modules in the target file as the to-be-processed modules corresponding to the target file, and determine the execution order of each to-be-processed module by using an execution order determination method.
[0071] Figure 8 is a schematic diagram of a graph structure file that does not contain an algebraic loop. When the processing device for the graph structure file determines the execution order for Figure 8 the graph structure file shown in the figure, first, the receiving module 70 receives Figure 8 the graph structure file shown in the figure and uses it as the target file for which the execution order is to be determined. Next, after receiving the graph structure file, the receiving module 70 transmits it to the processing module 72, and the processing module 72 processes the graph structure file. Specifically, the front end extracts the information recorded in the graph structure file, especially the relevant information of each module and each module recorded in the graph structure file, and stores this information as a file in a format readable by a computer device (such as the json format); the back end analyzes the file in a format readable by a computer device (such as the json format), extracts the relevant information of each module from it, and based on this, analyzes whether there is an algebraic loop in the graph structure file. If the received graph structure file is Figure 6 the file containing an algebraic loop shown on the left in the figure, then after the algebraic loop is analyzed by the analysis module 74, the determination module 76 determines the execution order of the graph structure file. Otherwise, for Figure 8 the file shown in the figure that does not contain an algebraic loop, the determination module 76 directly determines the execution order of the graph structure file. In this embodiment, the execution order of the graph structure file determined by the processing device for the graph structure file for Figure 8 the graph structure file shown in the figure is: sine module (sin) → cosine module (cos) → summation module (sum) → multiplication operation module (gain) → output information display module (print). And the execution order of the graph structure file determined by the processing device for the graph structure file for Figure 6 the graph structure file shown in the figure is: sine module (sin) & determine the initial value of X (X n module) → multiplication operation module (gain) → output information display module (print).
[0072] It should be noted that Figure 7 For the preferred implementation manners of the illustrated embodiments, reference may be made to Figure 2 the relevant descriptions of the illustrated embodiments, which will not be elaborated herein.
[0073] The embodiments of the present application further provide a non-volatile storage medium, in which a computer program is stored. Among them, on the device where the non-volatile storage medium is located, the above processing method of the graph structure file is executed by running the computer program.
[0074] The above non-volatile storage medium is used to store a program for executing the following functions: receiving a target file, where the target file is a graph structure file composed of multiple modules and straight lines for connecting the modules, and each module represents a computing unit; processing the target file to obtain relevant information of the multiple modules included in the target file, and determining whether there is an algebraic loop in the target file according to the relevant information, where the algebraic loop is a circular structure composed of multiple modules of algebraic operation types; in the case where there is an algebraic loop in the target file, first analyze the algebraic loop to obtain an algebraic loop analysis result; determine the algebraic loop analysis result and other modules in the target file as the to-be-processed modules corresponding to the target file, and use an execution order determination method to determine the execution order of each to-be-processed module.
[0075] The embodiments of the present application further provide an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to execute the above processing method of the graph structure file through the computer program.
[0076] The processor in the above electronic device is used to run a program for executing the following functions: receiving a target file, where the target file is a graph structure file composed of multiple modules and straight lines for connecting the modules, and each module represents a computing unit; processing the target file to obtain relevant information of the multiple modules included in the target file, and determining whether there is an algebraic loop in the target file according to the relevant information, where the algebraic loop is a circular structure composed of multiple modules of algebraic operation types; in the case where there is an algebraic loop in the target file, first analyze the algebraic loop to obtain an algebraic loop analysis result; determine the algebraic loop analysis result and other modules in the target file as the to-be-processed modules corresponding to the target file, and use an execution order determination method to determine the execution order of each to-be-processed module.
[0077] The embodiments of the present application further provide a computer program product, including computer instructions, and when the computer instructions are executed by a processor, the steps of the above processing method of the graph structure file are implemented.
[0078] It should be noted that each module in the above device for processing the graph structure file can be a program module (for example, a set of program instructions for implementing a specific function), or a hardware module. For the latter, it can be presented in the following forms, but not limited to: the manifestation of each of the above modules is a processor, or the functions of each of the above modules are implemented by a processor.
[0079] The serial numbers of the embodiments of the present application above are only for description and do not represent the superiority or inferiority of the embodiments.
[0080] In the above embodiments of the present application, the descriptions of each embodiment have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0081] In the several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces. The indirect coupling or communication connection of units or modules can be in an electrical or other form.
[0082] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0083] In addition, the functional units in each embodiment of the present application can be integrated into a processing unit, or each unit exists physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0084] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the related technology, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), mobile hard disks, magnetic disks, or optical discs.
[0085] The foregoing are only the preferred embodiments of this application. It should be noted that for those of ordinary skill in the art of this technology, without departing from the principle of this application, several improvements and refinements can still be made, and these improvements and refinements should also be regarded as the protection scope of this application.
Claims
1. A method for processing a graph structure file, characterized in that Including: Receiving a target file, where the target file is a graph structure file composed of multiple modules and straight lines for connecting the modules, and each module represents a computing unit; Processing the target file to obtain relevant information of the multiple modules included in the target file, and determining whether there is an algebraic loop in the target file according to the relevant information, where the algebraic loop is a cyclic structure composed of multiple modules of algebraic operation types; When there is the algebraic loop in the target file, first parsing the algebraic loop to obtain an algebraic loop parsing result; Determining the algebraic loop parsing result and other modules in the target file as the to-be-processed modules corresponding to the target file, and using an execution order determination method to determine the execution order of each to-be-processed module.
2. The method according to claim 1, wherein Processing the target file includes: Parsing the target file to obtain relevant information of each module, where the relevant information includes: the type of the module, the input port information of the module, the output port information of the module, and the associated modules connected to the module by a straight line; Filling each type of the relevant information into fields included in a reference file to obtain a target reference file, where the fields corresponding to different types of the relevant information are different, the format of the reference file is any format readable by a computer device, and in the target reference file, multiple fields corresponding to each module are stored as an object.
3. The method according to claim 1, characterized in that, Determining whether there is an algebraic loop in the target file according to the relevant information includes: Performing a connection relationship check on each module according to the relevant information of each module to obtain a check result; When the check result indicates passing the check, traversing all the modules included in the target file to obtain a traversal result, and determining whether there is the algebraic loop in the target file according to the traversal result.
4. The method according to claim 3, wherein The relevant information of each module includes: the associated modules connected to the module by a straight line; Performing a connection relationship check on each module according to the relevant information of each module to obtain a check result, including: for each module, determining whether the relevant information contains the associated module; when the relevant information does not contain the associated module, determining the type of the module according to the relevant information; when the type of the module is an input signal module or an output signal calculation module, determining the check result as passing the check; when the type of the module is not the input signal module and the output signal calculation module, determining the check result as not passing the check; when the relevant information contains the associated module, determining the check result as passing the check.
5. The method according to claim 3, wherein Traversing all the modules included in the target file to obtain a traversal result, including: Execute the following traversal steps: Determine any one of the modules as the starting module, where the starting module is the first module to be added with an access mark during the traversal process; Determine the first type of modules directly connected to the starting module and the second type of modules indirectly connected to the starting module, and add the access mark to the first type of modules and the second type of modules; Determine whether there are remaining modules in the target file, where the remaining modules are the modules that have not been added with the access mark. In the case where there are no remaining modules, determine the dependency graph generated with the starting module, the first type of modules, and the second type of modules as nodes and the straight lines representing the connection relationships between the starting module, the first type of modules, and the second type of modules as edges as the traversal result. In the case where there are remaining modules, repeatedly execute the above traversal steps for the remaining modules until there are no remaining modules in the target file, obtaining multiple execution results, where each execution result is a dependency graph; Determine the multiple dependency graphs corresponding to the multiple execution results as the traversal result.
6. The method according to claim 5, wherein Determine whether there is an algebraic loop in the target file according to the traversal result, including: For each dependency graph included in the traversal result, sequentially access each module in the dependency graph according to the access order recorded in the dependency graph, and record the access times of each module. Determine whether there is a target module whose access times are greater than the preset access times and whose type is the algebraic operation type. In the case where there is a target module, determine whether there is an algebraic loop in the target file; In the case where there is no target module, determine that there is no algebraic loop in the target file.
7. The method according to claim 1, characterized in that, Analyze the algebraic loop, including: Analyze the algebraic loop according to the mathematical attributes of the algebraic loop to obtain the output values of each module in the algebraic loop. Replace each module in the algebraic loop with the output value corresponding to the module to obtain the timing module sequence corresponding to the algebraic loop, where there is no cyclic dependency among the multiple modules in the timing module sequence.
8. The method according to claim 1, wherein Adopt an execution order determination method to determine the execution order of each to-be-processed module, including: Classify the to-be-processed modules into the first type of to-be-processed modules and the second type of to-be-processed modules according to the attribute information of the to-be-processed modules, where the attribute information is used to indicate the relationship between the calculation process of the to-be-processed module and the input signal at the current moment, the first type of to-be-processed modules are the modules whose calculation processes do not depend on the input signal at the current moment, and the second type of to-be-processed modules are the modules whose calculation processes depend on the input signal at the current moment. Randomly sort each to-be-processed module in the first type of to-be-processed modules to obtain a first sorting result. Sort each to-be-processed module in the second type of to-be-processed modules to obtain a second sorting result, where the smallest sorting serial number in the second sorting result is greater than the largest sorting serial number in the first sorting result. Determine the execution order according to the first sorting result and the second sorting result.
9. The method according to claim 8, wherein Sort each to-be-processed module in the second type of to-be-processed modules, including: Execute the following sorting steps: Traverse each of the second type of to-be-processed modules. During the traversal, determine the module connected to the input end of the second type of to-be-processed module as the input module; when the input module has been marked with the sorting serial number, determine the sum of the maximum sorting serial number in the current sorting result and a preset value as the sorting serial number of the second type of to-be-processed module, where the maximum sorting serial number in the current sorting result is determined according to the first sorting result and the second type of to-be-processed modules that have completed sorting; when the input module is not marked with the sorting serial number, classify the second type of to-be-processed module into the secondary sorting set. When it is determined that each of the second type of to-be-processed modules has been traversed once, repeatedly execute the above sorting steps for the second type of to-be-processed modules in the secondary sorting set until each of the second type of to-be-processed modules is marked with the sorting serial number.
10. The method according to claim 1, characterized in that, The method further includes: When the algebraic loop does not exist in the target file, determine all the modules in the target file as the to-be-processed modules of the target file. Use the execution order determination method to determine the execution order of each of the to-be-processed modules.
11. A processing device for a graph structure file, characterized in that Include: A receiving module, configured to receive a target file, where the target file is a graph structure file composed of multiple modules and straight lines for connecting the modules, and each of the modules represents a computing unit. A processing module, configured to process the target file to obtain relevant information of the multiple modules included in the target file, and determine whether there is an algebraic loop in the target file according to the relevant information, where the algebraic loop is a circular structure composed of multiple modules of the algebraic operation type. An analysis module, configured to, when the algebraic loop exists in the target file, first analyze the algebraic loop to obtain the algebraic loop analysis result. A determination module, configured to determine the algebraic loop analysis result and other modules in the target file as the to-be-processed modules corresponding to the target file, and use the execution order determination method to determine the execution order of each of the to-be-processed modules.
12. A non-volatile storage medium, characterized in that, A computer program is stored in the non-volatile storage medium, where the method for processing the graph structure file according to any one of claims 1 to 10 is executed by the device where the non-volatile storage medium is located by running the computer program.
13. An electronic device, comprising a memory and a processor, characterized in that, A computer program is stored in the memory, and the processor is configured to execute the method for processing the graph structure file according to any one of claims 1 to 10 through the computer program.
14. A computer program product comprising computer instructions, characterized in that, When the computer instruction is executed by the processor, the steps of the method for processing the graph structure file according to any one of claims 1 to 10 are implemented.