Method, device and apparatus for determining graph structure of Pytorch neural network

By obtaining the input data of the PyTorch neural network, identifying and obtaining the network graph structure, the problem of unfriendly quantization operation of the PyTorch neural network architecture is solved, efficient optimization and accurate identification are achieved, and code pollution is avoided.

CN115169522BActive Publication Date: 2025-08-29HANGZHOU ZHIHUI MANTU TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110357946.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-01
Publication Date
2025-08-29
Estimated Expiration
2041-04-01

AI Technical Summary

Technical Problem

In the prior art, the quantitative operation of the PyTorch neural network architecture and the search interface of the neural network architecture are unfriendly, and developers need to adapt mechanical code, resulting in large workloads, error-prone and contaminating the original code.

Method used

By obtaining the input data of the PyTorch neural network, the network operation is controlled to determine the node relationship, identify and obtain the network graph structure, and avoid directly modifying the original code.

Benefits of technology

Accurate identification and optimization of PyTorch neural network is achieved, reducing the tedious work of developers, improving optimization efficiency and quality, and avoiding code pollution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115169522B_ABST
    Figure CN115169522B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention provides a method, device, and apparatus for determining the graph structure of a Pytorch neural network. The method includes: obtaining input data; controlling the Pytorch neural network to run based on the input data, and determining the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network; based on the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network, determining the network graph structure corresponding to the Pytorch neural network, the network graph structure including: the connection relationship between network nodes in the Pytorch neural network. The technical solution provided by this embodiment can accurately obtain the network graph structure, and then facilitate network optimization operations based on the network graph structure, greatly improving the quality and efficiency of network optimization operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network technology, and in particular to a method, device and equipment for determining the graph structure of a Pytorch neural network. Background Art

[0002] With the rapid development of science and technology, the variety of neural network training frameworks in the field of deep learning is increasing, and a hundred flowers are blooming. Among them, PyTorch, known as a "defined by execution" framework, stands out from the crowd due to its dynamic graph-based nature and flexibility and ease of use, becoming one of the more popular training frameworks in the field of deep learning today. Therefore, based on PyTorch, neural networks can be easily defined and trained.

[0003] However, the current PyTorch interface for quantizing neural network architectures is not user-friendly. For example, to quantize the input data of a neural network architecture, in order to quantize a specific PyTorch network structure, the code data used to define the network must be directly modified. This not only requires developers to perform mechanical code adaptation, which is labor-intensive and error-prone, but also pollutes the original code. Summary of the Invention

[0004] In view of this, the embodiments of the present invention provide a method, device and equipment for determining the graph structure of a Pytorch neural network, which can accurately obtain the network graph structure and then facilitate network optimization operations based on the network graph structure, thereby freeing developers from tedious code adaptation work and greatly improving the quality and efficiency of network architecture optimization operations.

[0005] In a first aspect, an embodiment of the present invention provides a method for determining a graph structure of a Pytorch neural network, comprising:

[0006] Get the input data for the Pytorch neural network to be analyzed;

[0007] Controlling the Pytorch neural network to run based on the input data, and determining a predecessor node and a successor node corresponding to a network node in the Pytorch neural network;

[0008] Based on the predecessor nodes and successor nodes corresponding to the network nodes in the Pytorch neural network, a network graph structure corresponding to the Pytorch neural network is determined, where the network graph structure includes: the network nodes in the Pytorch neural network and the connection relationships between the network nodes.

[0009] In a second aspect, an embodiment of the present invention provides a device for determining a graph structure of a Pytorch neural network, comprising:

[0010] A first acquisition module is used to obtain input data for inputting into the Pytorch neural network to be analyzed;

[0011] A first control module is used to control the Pytorch neural network to run based on the input data, and determine the predecessor node and the successor node corresponding to the network node in the Pytorch neural network;

[0012] The first processing module is used to determine a network graph structure corresponding to the Pytorch neural network based on the predecessor nodes and successor nodes corresponding to the network nodes in the Pytorch neural network, where the network graph structure includes: network nodes in the Pytorch neural network and connection relationships between the network nodes.

[0013] In a third aspect, an embodiment of the present invention provides an electronic device comprising a processor and a memory, the memory being configured to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method for determining the graph structure of a PyTorch neural network described in the first aspect. The electronic device may also include a communication interface for communicating with other devices or a communication network.

[0014] In a fourth aspect, an embodiment of the present invention provides a computer storage medium for storing a computer program, which enables a computer to implement the graph structure determination method of the Pytorch neural network in the first aspect when executed.

[0015] In a fifth aspect, an embodiment of the present invention provides a network optimization method, including:

[0016] Get the network optimization request corresponding to the Pytorch neural network;

[0017] Determine a network graph structure corresponding to the Pytorch neural network, wherein the network graph structure includes: network nodes in the Pytorch neural network and connection relationships between the network nodes;

[0018] Optimizing the network graph structure based on the network optimization request to obtain a target network graph structure;

[0019] According to the target network graph structure, a target Pytorch neural network corresponding to the network optimization request is generated.

[0020] In a sixth aspect, an embodiment of the present invention provides a network optimization device, including:

[0021] The second acquisition module is used to obtain a network optimization request corresponding to the Pytorch neural network;

[0022] A second determination module is used to determine a network graph structure corresponding to the Pytorch neural network, wherein the network graph structure includes: network nodes in the Pytorch neural network and connection relationships between the network nodes;

[0023] A second optimization module is configured to optimize the network graph structure based on the network optimization request to obtain a target network graph structure;

[0024] The second processing module is used to generate a target Pytorch neural network corresponding to the network optimization request according to the target network graph structure.

[0025] In a seventh aspect, an embodiment of the present invention provides an electronic device comprising a processor and a memory, wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the network optimization method described in the fifth aspect. The electronic device may also include a communication interface for communicating with other devices or a communication network.

[0026] In an eighth aspect, an embodiment of the present invention provides a computer storage medium for storing a computer program, wherein the computer program enables a computer to implement the network optimization method in the fifth aspect when executed.

[0027] The technical solution provided in this embodiment obtains input data for input into the Pytorch neural network to be analyzed, controls the Pytorch neural network to run based on the input data, determines the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network, and then determines the network graph structure corresponding to the Pytorch neural network based on the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network, thereby effectively realizing accurate identification and acquisition operations of the network graph structure corresponding to the Pytorch neural network, so that the Pytorch neural network can be optimized based on the network graph structure. This not only frees developers from tedious code adaptation work, greatly improves the quality and efficiency of the optimization operation of the Pytorch neural network, but also does not pollute the original code corresponding to the Pytorch neural network. In addition, when modifying / updating the network structure of the Pytorch neural network, very tedious data processing operations are avoided, effectively improving the practicality and applicability of the method. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0029] Figure 1 A schematic diagram of a flow chart of a method for determining the graph structure of a Pytorch neural network provided by an embodiment of the present invention;

[0030] Figure 2 A schematic diagram illustrating the principle of a method for determining the graph structure of a Pytorch neural network provided by an embodiment of the present invention;

[0031] Figure 3 A schematic diagram of a flow chart of a method for determining the graph structure of a Pytorch neural network provided by an embodiment of the present invention;

[0032] Figure 4 Schematic diagram of using the target code to update the original code provided by the embodiment of the present invention Figure 1 ;

[0033] Figure 5 Schematic diagram of using the target code to update the original code provided by the embodiment of the present invention Figure 2 ;

[0034] Figure 6 Schematic diagram of using the target code to update the original code provided by the embodiment of the present invention Figure 3 ;

[0035] Figure 7 A schematic flow chart of another method for determining the graph structure of a Pytorch neural network is provided for an embodiment of the present invention;

[0036] Figure 8 A schematic flow chart of another method for determining the graph structure of a Pytorch neural network is provided for an embodiment of the present invention;

[0037] Figure 9 A schematic flow chart of another method for determining the graph structure of a Pytorch neural network is provided for an embodiment of the present invention;

[0038] Figure 10 A schematic flow chart of another method for determining the graph structure of a Pytorch neural network is provided for an embodiment of the present invention;

[0039] Figure 11 A schematic flow chart of another method for determining the graph structure of a Pytorch neural network is provided for an embodiment of the present invention;

[0040] Figure 12 A schematic flow chart of another method for determining the graph structure of a Pytorch neural network is provided for an embodiment of the present invention;

[0041] Figure 13 A schematic flow chart of another method for determining the graph structure of a Pytorch neural network is provided for an embodiment of the present invention;

[0042] Figure 14 A schematic flow chart of a method for determining the graph structure of a Pytorch neural network is provided for an application embodiment of the present invention;

[0043] Figure 15 A schematic diagram of a flow chart of a network optimization method is provided for an embodiment of the present invention;

[0044] Figure 16 A schematic diagram of the structure of a Pytorch neural network graph structure determination device provided by an embodiment of the present invention;

[0045] Figure 17 For Figure 16 A schematic structural diagram of an electronic device corresponding to the apparatus for determining the graph structure of a Pytorch neural network provided by the illustrated embodiment;

[0046] Figure 18 A schematic diagram of the structure of a network optimization device provided by an embodiment of the present invention;

[0047] Figure 19 For Figure 18 A schematic structural diagram of an electronic device corresponding to the network optimization device provided in the illustrated embodiment. DETAILED DESCRIPTION

[0048] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0049] The terms used in the embodiments of the present invention are for the purpose of describing specific embodiments only and are not intended to limit the present invention. The singular forms "a," "the," and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates otherwise. "A plurality" generally includes at least two, but does not exclude the inclusion of at least one.

[0050] It should be understood that the term "and / or" as used herein is merely a description of the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.

[0051] As used herein, the words “if” and “if” may be interpreted as “at the time of” or “when” or “in response to determining” or “in response to identifying,” depending on the context. Similarly, the phrases “if it is determined” or “if (stated condition or event) is identified” may be interpreted as “when it is determined” or “in response to determining” or “when identifying (stated condition or event)” or “in response to identifying (stated condition or event),” depending on the context.

[0052] It should also be noted that the terms "include," "comprises," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a product or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such product or system. In the absence of further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the product or system comprising the element.

[0053] To facilitate understanding of the technical solution of this embodiment, the following is a description of the prior art:

[0054] With the rapid development of science and technology, the variety of neural network training frameworks in the field of deep learning is increasing, and a hundred flowers are blooming. Among them, PyTorch, known as a "defined by execution" framework, stands out from the crowd due to its dynamic graph-based nature and flexibility and ease of use, becoming one of the more popular training frameworks in the field of deep learning today. Therefore, based on PyTorch, neural networks can be easily defined and trained.

[0055] However, PyTorch currently lacks a user-friendly interface for implementing Neural Architecture Search (NAS) and quantizing the input data of neural network architectures. For example, to quantize a specific PyTorch network structure, it is necessary to directly modify the code data when defining the network. Alternatively, to implement NAS operations, developers need to modify the original code and manually replace the corresponding module in the original network with the block type to be searched.

[0056] As can be seen from the above description, these network processing operations require developers to mechanically adapt code, which is labor-intensive, error-prone, and contaminates the original code. Furthermore, when the original network structure needs to be modified, the entire mechanical adaptation process must be started all over again, which is extremely tedious.

[0057] In order to free developers from the tedious work of code adaptation, this embodiment provides a method, apparatus, and device for determining the graph structure of a Pytorch neural network. The graph structure determination method obtains input data for inputting into the Pytorch neural network to be analyzed, controls the Pytorch neural network to run based on the input data, and determines the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network; then counts the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network, and determines the network graph structure corresponding to the Pytorch neural network based on the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network. The network graph structure includes: The network nodes in the Pytorch neural network and the connection relationship between the network nodes effectively realize the accurate identification and acquisition operations of the network graph structure corresponding to the Pytorch neural network, so that the corresponding optimization processing operations of the Pytorch neural network can be performed based on the network graph structure. This not only frees developers from the tedious code adaptation work, greatly improves the quality and efficiency of the optimization operations on the Pytorch neural network, but also does not pollute the original code corresponding to the Pytorch neural network. In addition, when modifying / updating the network structure of the Pytorch neural network, very tedious data processing operations are avoided, which effectively improves the practicality and applicability of the method.

[0058] In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.

[0059] Figure 1 A schematic diagram of a flow chart of a method for determining the graph structure of a Pytorch neural network provided by an embodiment of the present invention; Figure 2 A schematic diagram of the principle of a method for determining the graph structure of a Pytorch neural network provided by an embodiment of the present invention; see the attached Figure 1-2 As shown, this embodiment provides a method for determining the graph structure of a Pytorch neural network. The execution subject of the method for determining the graph structure of a Pytorch neural network is a graph structure determination device of a Pytorch neural network. It can be understood that the graph structure determination device can be implemented as software or a combination of software and hardware. Specifically, the method may include:

[0060] Step S101: Obtain input data for input into the Pytorch neural network to be analyzed.

[0061] Step S102: Control the Pytorch neural network to run based on the input data, and determine the predecessor node and the successor node corresponding to the network node in the Pytorch neural network.

[0062] Step S103: Based on the predecessor nodes and successor nodes corresponding to the network nodes in the Pytorch neural network, determine the network graph structure corresponding to the Pytorch neural network, where the network graph structure includes: the network nodes in the Pytorch neural network and the connection relationship between the network nodes.

[0063] The following is a detailed explanation of each of the above steps:

[0064] Step S101: Obtain input data for input into the Pytorch neural network to be analyzed.

[0065] Among them, the Pytorch neural network to be analyzed refers to the Pytorch neural network that needs to determine the network graph structure so as to implement the corresponding optimization processing operation on the Pytorch neural network through the network graph structure. In order to accurately determine the network graph structure corresponding to the Pytorch neural network, the input data for input to the Pytorch neural network can be obtained. Specifically, this embodiment does not limit the specific implementation method for obtaining the input data for input to the Pytorch neural network. Those skilled in the art can set it according to specific application requirements and design requirements. For example, the input data can be stored in a preset area, and the input data for input to the Pytorch neural network can be obtained by accessing the preset area. Alternatively, a sensor for collecting user input execution operations can be provided on the graph structure determination device. After the graph structure determination device obtains the execution operation input by the user, it can generate and obtain the input data for input to the Pytorch neural network to be analyzed according to the execution operation.

[0066] Of course, those skilled in the art may also adopt other methods to obtain input data for input into the Pytorch neural network to be analyzed, as long as the accuracy and reliability of the input data can be guaranteed, which will not be elaborated here.

[0067] Step S102: Control the Pytorch neural network to run based on the input data, and determine the predecessor node and the successor node corresponding to the network node in the Pytorch neural network.

[0068] After obtaining the input data, the input data can be input into the Pytorch neural network, and the Pytorch neural network can be controlled to run based on the input data. During the operation of the Pytorch neural network, the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network can be determined based on the running data flow. In order to facilitate the timely retrieval and viewing of the predecessor and successor nodes corresponding to the network nodes, after determining the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network, the predecessor and successor nodes corresponding to the network nodes can be stored. Figure 2 As shown, a storage area for storing data is pre-set in the network node, and the storage area can store the following relevant data corresponding to the network node: predecessor node, successor node, parent node, child node, path information, etc.

[0069] It can be understood that the Pytorch neural network can include multiple network nodes, and each of the multiple network nodes corresponds to a predecessor node and / or a successor node. Specifically, for the first network node in the Pytorch neural network, it can correspond to a successor node, but no corresponding predecessor node; for the intermediate network nodes in the Pytorch neural network, it can correspond to a predecessor node and a successor node; for the last network node in the Pytorch neural network, it can correspond to a predecessor node, but no corresponding successor node.

[0070] Step S103: Based on the predecessor nodes and successor nodes corresponding to the network nodes in the Pytorch neural network, determine the network graph structure corresponding to the Pytorch neural network, where the network graph structure includes: the network nodes in the Pytorch neural network and the connection relationship between the network nodes.

[0071] Since the network graph structure corresponding to the Pytorch neural network is related to the association relationship between network nodes, in order to accurately obtain the network graph structure corresponding to the Pytorch neural network, after determining the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network, the predecessor and successor nodes corresponding to the network nodes can be analyzed and processed to determine the network graph structure corresponding to the Pytorch neural network. The network graph structure may include the network nodes in the Pytorch neural network and the connection relationship between the network nodes, thereby effectively realizing the accurate and effective acquisition operation of the network graph structure corresponding to the Pytorch neural network.

[0072] In some instances, in order to ensure the accuracy and reliability of the acquisition of the network graph structure, after determining the predecessor nodes and successor nodes corresponding to the network nodes in the Pytorch neural network, the predecessor nodes and successor nodes corresponding to multiple network nodes (or all network nodes) in the Pytorch neural network can be counted, and then the predecessor nodes and successor nodes corresponding to the multiple network nodes (or all network nodes) are analyzed and processed to determine the network graph structure corresponding to the Pytorch neural network, which may include multiple network nodes (or all network nodes) in the Pytorch neural network and the connection relationship between the network nodes.

[0073] It should be noted that the above-mentioned graph structure determination method of the Pytorch neural network can be used on unmanned vehicles. In this case, the execution subject of the graph structure determination method for implementing the Pytorch neural network is a graph structure determination device of the Pytorch neural network, which can be set on the vehicle to be identified. Specifically, for the graph structure determination device, the graph structure determination device can be adjusted according to different types of vehicles, that is, the algorithm modules included in the graph structure determination device will be different depending on the type of vehicle. At this time, the graph structure determination device can not only determine the network graph structure corresponding to the Pytorch neural network, but also implement other operations. For example, different graph structure determination devices will be involved for logistics vehicles, public service vehicles, medical service vehicles, and terminal service vehicles. The following examples illustrate the algorithm modules included in the graph structure determination device for these four types of autonomous driving vehicles:

[0074] Logistics vehicles refer to vehicles used in logistics scenarios, such as those with automatic sorting, refrigeration, and measurement functions. These vehicles involve different algorithm modules.

[0075] For example, logistics vehicles can be equipped with automated sorting devices that automatically retrieve, transport, sort, and store goods upon arrival. This involves an algorithm module for cargo sorting, which primarily implements logical control over cargo retrieval, transportation, sorting, and storage.

[0076] For another example, for cold chain logistics scenarios, logistics vehicles can also be equipped with refrigeration and insulation devices, which can refrigerate or insulate the transported fruits, vegetables, aquatic products, frozen foods, and other perishable foods, so that they are in a suitable temperature environment, solving the problem of long-distance transportation of perishable foods. This involves an algorithm module for refrigeration and insulation control, which is mainly used to dynamically and adaptively calculate the appropriate temperature for cold meals or insulation based on information such as the nature of the food (or item), perishability, transportation time, current season, and climate, and automatically adjust the refrigeration and insulation device according to the appropriate temperature. In this way, when the vehicle transports different foods or items, the transportation personnel do not need to manually adjust the temperature, freeing the transportation personnel from the tedious temperature control and improving the efficiency of refrigerated and insulated transportation.

[0077] For example, in most logistics scenarios, charges are based on the volume and / or weight of the package. However, the number of logistics packages is very large. Simply relying on couriers to measure the volume and / or weight of the packages is very inefficient and has high labor costs. Therefore, in some logistics vehicles, measuring devices are added to automatically measure the volume and / or weight of logistics packages and calculate the fees for logistics packages. This involves an algorithm module for logistics package measurement, which is mainly used to identify the type of logistics package and determine the measurement method of the logistics package, such as volume measurement or weight measurement or a combination of volume and weight measurement. It can also complete the volume and / or weight measurement according to the determined measurement method, and complete the fee calculation based on the measurement results.

[0078] Public service vehicles refer to vehicles that provide certain public services, such as fire trucks, de-icing trucks, sprinkler trucks, snowplows, garbage disposal vehicles, traffic control vehicles, etc. These public service vehicles involve different algorithm modules.

[0079] For example, for an autonomous fire truck, its main task is to carry out reasonable fire-fighting tasks at the fire scene. This involves an algorithm module for fire-fighting tasks. The algorithm module must at least implement logic such as fire condition identification, fire-fighting plan planning, and automatic control of fire-fighting equipment.

[0080] For example, the main task of a de-icing vehicle is to clear ice and snow from the road surface, which involves a de-icing algorithm module. This algorithm module must at least be able to identify the ice and snow conditions on the road surface, formulate a de-icing plan based on the ice and snow conditions, such as which sections of the road require de-icing and which sections do not, whether to use salting and the amount of salt to spread, etc., as well as the logic for automatic control of the de-icing device when the de-icing plan is determined.

[0081] Among them, medical service vehicles refer to self-driving vehicles that can provide one or more medical services. Such vehicles can provide medical services such as disinfection, temperature measurement, medication, and isolation. This involves algorithm modules that provide various self-service medical services. These algorithm modules mainly realize the identification of disinfection needs and the control of disinfection devices so that the disinfection devices can disinfect patients, or identify the patient's position and control the temperature measuring device to automatically approach the patient's forehead and other positions to measure the patient's temperature, or are used to realize the judgment of the disease, give a prescription based on the judgment result, and need to realize the identification of drugs / drug containers, as well as the control of the drug-taking robot so that it can grab drugs for patients according to the prescription, etc.

[0082] Among them, terminal service vehicles refer to self-service autonomous driving vehicles that can replace some terminal devices to provide certain convenient services to users. For example, these vehicles can provide users with printing, attendance, scanning, unlocking, payment, retail and other services.

[0083] For example, in some application scenarios, users often need to go to a specific location to print or scan documents, which is time-consuming and labor-intensive. Therefore, a terminal service vehicle that can provide users with printing / scanning services has emerged. These service vehicles can be interconnected with the user's terminal device. The user issues a print instruction through the terminal device, and the service vehicle responds to the print instruction, automatically prints the document required by the user, and can automatically deliver the printed document to the user's location. The user does not need to queue at the printer, which can greatly improve printing efficiency. Alternatively, it can respond to the scanning instruction issued by the user through the terminal device and move to the user's location. The user places the document to be scanned on the scanning tool of the service vehicle to complete the scanning, without having to queue at the printer / scanner, saving time and effort. This involves an algorithm module that provides printing / scanning services. The algorithm module at least needs to identify the connection with the user's terminal device, the response to the print / scan instruction, the positioning of the user's location, and the travel control.

[0084] For example, with the development of new retail scenarios, more and more e-commerce companies are using self-service vending machines to deliver goods to office buildings and public areas. However, these vending machines are fixed in place and cannot be moved. Users need to visit the vending machine to purchase the items they need, which is still inconvenient. Therefore, self-driving vehicles that provide retail services have emerged. These service vehicles can carry goods and move automatically. They also provide corresponding self-service shopping apps or shopping portals. Users can use mobile devices or other terminals to place orders with the self-driving vehicles through the app or shopping portal. The order includes the name of the product to be purchased, the quantity, and the user's location. After receiving the order request, the vehicle can determine whether the product is available and whether the quantity is sufficient. If the product is available and the quantity is sufficient, it can automatically move to the user's location with the product and deliver it to the user, further improving shopping convenience for users, saving time and allowing them to spend more time on more important things. This involves the algorithm modules that provide retail services. These algorithm modules mainly implement logic such as responding to user order requests, order processing, maintaining product information, locating user location, and payment management.

[0085] The graph structure determination method of the Pytorch neural network provided in this embodiment obtains input data for input into the Pytorch neural network to be analyzed, controls the Pytorch neural network to run based on the input data, determines the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network, and then determines the network graph structure corresponding to the Pytorch neural network based on the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network, effectively realizing accurate identification and acquisition operations of the network graph structure corresponding to the Pytorch neural network, so that the Pytorch neural network can be optimized based on the network graph structure. This not only frees developers from tedious code adaptation work, greatly improves the quality and efficiency of the optimization operation of the Pytorch neural network, but also does not pollute the original code corresponding to the Pytorch neural network. In addition, when modifying / updating the network structure of the Pytorch neural network, very tedious data processing operations are avoided, effectively improving the practicality and applicability of the method.

[0086] Figure 3 A flowchart of a method for determining the graph structure of a Pytorch neural network provided by an embodiment of the present invention; based on the above embodiment, continue to refer to the attached Figure 3 As shown, before obtaining input data for inputting into the Pytorch neural network to be analyzed, the method in this embodiment may further include:

[0087] Step S301: Obtain the original code corresponding to the Pytorch neural network and the identity corresponding to the original code.

[0088] Step S302: Based on the identity identifier, determine the target code corresponding to the original code.

[0089] Step S303: The original code is updated using the target code to determine the predecessor node and the successor node corresponding to the network node in the Pytorch neural network through the target code.

[0090] Among them, for the Pytorch neural network, since the corresponding original code does not have a data flow tracking function, in order to accurately determine the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network, the original code in the Pytorch neural network can be updated so that the updated code for the Pytorch neural network has a data flow tracking function, thereby determining the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network. Specifically, the above-mentioned original code can correspond to at least one of the following: an input node for obtaining input data input to the Pytorch neural network to be analyzed; a processing node for controlling the Pytorch neural network to run based on the input data; an output node for generating an operation result corresponding to the input data. It can be understood that the number of input nodes, the number of processing nodes, and the number of output nodes can be one or more.

[0091] In order to be able to update the original code in the Pytorch neural network, the preset algorithm can be used to analyze and process the Pytorch neural network to obtain the original code corresponding to the Pytorch neural network and the identity corresponding to the original code. It can be understood that the Pytorch neural network can correspond to one or more original code information, and each original code can realize the preset function. Specifically, the above-mentioned original code can be related to the corresponding data flow direction in the Pytorch neural network, and each original code corresponds to a unique identity information.

[0092] In addition, for the original code corresponding to the Pytorch neural network, a target code with the same identity as the original code is pre-set. Therefore, after obtaining the identity corresponding to the original code, the target code corresponding to the original code can be determined based on the identity. After that, the original code can be replaced with the target code, so that the predecessor node and successor node corresponding to the network node in the Pytorch neural network can be determined through the target code.

[0093] For example, see the attached Figure 4 As shown, when the original code corresponds to an input node for obtaining input data input to the Pytorch neural network to be analyzed, the input data can be stored in the input node corresponding to the original code of the Pytorch neural network. The target code can be determined by the identity corresponding to the original code. The target node corresponding to the target code can store: input data and input node attributes. The input node attributes can include a successor node corresponding to the input node. After determining the target node, the input node can be updated to the target node, thereby implementing an update operation on the original code corresponding to the Pytorch neural network.

[0094] Similarly, see the attached Figure 5 As shown, when the original code corresponds to an output node for generating an operation result corresponding to the output data, the output node corresponding to the original code of the Pytorch neural network can store the operation result generated by the Pytorch neural network. The target code can be determined by the identity corresponding to the original code. The target node corresponding to the target code can store: the operation result and the output node attribute. The output node attribute can include the predecessor node corresponding to the output node. After determining the target node, the output node can be updated to the target node, thereby realizing the update operation of the original code corresponding to the Pytorch neural network.

[0095] Similarly, see the attached Figure 6 As shown, when the original code corresponds to a processing node for controlling the Pytorch neural network to run based on input data, the processing node corresponding to the original code of the Pytorch neural network may include: a first hook function, an operation function, and a second hook function for implementing the control of the Pytorch neural network to run based on the input data, wherein the first hook function is used to determine the predecessor node corresponding to the current network node, the operation function is used to determine the data processing operation corresponding to the Pytorch neural network based on the input data, and the second hook function is used to determine the successor node corresponding to the current network node, and input the operation result corresponding to the data operation operation to the successor node.

[0096] The target code can then be determined using the identity corresponding to the original code. The target node corresponding to the target code may include a storage area for storing node attributes of the network node, such as the predecessor node, successor node, parent node, child node, and path corresponding to the network node. After determining the target node, the processing node can be updated to the target node, thereby implementing an update operation on the original code corresponding to the Pytorch neural network.

[0097] In this embodiment, by obtaining the original code corresponding to the Pytorch neural network and the identity identifier corresponding to the original code, and then determining the target code corresponding to the original code based on the identity identifier, and using the target code to update the original code, the original code corresponding to the Pytorch neural network is effectively updated, so that the predecessor node and successor node corresponding to the network node in the Pytorch neural network are determined by the updated target code, thereby effectively ensuring the accuracy and reliability of the determination of the predecessor node and successor node corresponding to the network node.

[0098] Figure 7 The present invention provides another flowchart of a method for determining the graph structure of a Pytorch neural network; based on the above embodiment, continue to refer to the attached Figure 7 As shown, this embodiment provides an implementation method for obtaining input data. Specifically, in this embodiment, obtaining input data for input into the Pytorch neural network to be analyzed may include:

[0099] Step S701: Obtain raw data for input into a network layer in a Pytorch neural network to be analyzed.

[0100] Step S702: Determine the input node attribute of the input node corresponding to the original data.

[0101] Step S703: Determine input data for inputting into the Pytorch neural network to be analyzed based on the original data and input node attributes.

[0102] Among them, in order to be able to determine the graph structure of the Pytorch neural network, the original data for input into the network layer of the Pytorch neural network to be analyzed can be obtained. The original data can be data directly input into the Pytorch neural network by the user, or it can be data stored in a preset area for input into the Pytorch neural network. Specifically, a Pytorch neural network can correspond to one original data. When the Pytorch neural network includes multiple network layers (for example, a first network layer, a second network layer, etc.), after the first network layer obtains the original data, the first network layer can perform data processing operations based on the original data and obtain a first processing result corresponding to the first network layer; the first processing result can be input to the second network layer. After the second network layer obtains the first processing result, the second network layer can perform data processing operations based on the first processing result and obtain a second processing result corresponding to the second network layer. The second processing result can be used as input data for the next network layer, thereby realizing that the data flow of the Pytorch neural network can be tracked based on one original data.

[0103] After obtaining the original data, the input node attributes of the input node corresponding to the original data can be determined. The input node attributes may include the successor node corresponding to the input node. Of course, the input node attributes may include not only the above-mentioned successor node corresponding to the input node, but those skilled in the art may set them according to specific application requirements and design requirements. For example, the input node attributes may include the identity identifier corresponding to the current input node, etc. In addition, this embodiment does not limit the specific implementation method for determining the input node attributes of the input node corresponding to the original data. Those skilled in the art may set them according to specific application requirements and design requirements. For example, the input node attributes may be stored in a preset area, and the input node attributes may be obtained by accessing the preset area. It should be noted that when the input node in the Pytorch neural network does not perform any data processing operations, the information included in the input node attributes is empty.

[0104] After obtaining the original data and input node attributes, the original data and input node attributes can be analyzed and processed to determine the input data for input into the Pytorch neural network to be analyzed. Specifically, based on the original data and input node attributes, determining the input data for input into the Pytorch neural network to be analyzed can include: encapsulating the original data and input node attributes to obtain the input data for input into the Pytorch neural network to be analyzed.

[0105] In this embodiment, by obtaining the original data for input into the network layer of the Pytorch neural network to be analyzed, determining the input node attributes of the input node corresponding to the original data, and then determining the input data for input into the Pytorch neural network to be analyzed based on the original data and the input node attributes, the accurate and reliable acquisition of the input data is effectively achieved. Moreover, since the input data includes the original data and input node attributes for input into the Pytorch neural network, when the Pytorch neural network is controlled to run based on the input data, the predecessor node and the successor node corresponding to the network node can be determined, and the network graph structure corresponding to the Pytorch neural network can be determined based on the predecessor node and the successor node corresponding to the network node, thereby further improving the quality and efficiency of determining the network graph structure.

[0106] Figure 8 A flowchart of another method for determining the graph structure of a Pytorch neural network is provided for an embodiment of the present invention; based on the above embodiment, further reference is made to the attached Figure 8 As shown, after obtaining input data for inputting into the Pytorch neural network to be analyzed, the method in this embodiment may further include:

[0107] Step S801: Determine the network node that obtains the input data as the successor node of the input node corresponding to the input data.

[0108] Step S802: Store the correspondence between the input node and the successor node in the input node.

[0109] After the network node obtains the input data, at this time, for the input node corresponding to the input data, the network node is the successor node of the input node. Therefore, the network node that obtains the input data can be determined as the successor node of the input node corresponding to the input data. In order to be able to obtain the predecessor node and successor node corresponding to each network node in the Pytorch neural network in a timely manner, the correspondence between the input node and the successor node can be stored in the input node. Specifically, a storage area can be set in the input node. After obtaining the correspondence between the input node and the successor node, the correspondence between the input node and the successor node can be stored in the above-mentioned storage area, so that the correspondence between the input node and the successor node can be obtained by accessing the storage area.

[0110] In this embodiment, after obtaining the input data for input into the Pytorch neural network to be analyzed, the network node that obtains the input data is determined as the successor node of the input node corresponding to the input data, and then the correspondence between the input node and the successor node is stored in the input node, thereby facilitating the determination of the predecessor node and the successor node corresponding to the network node in the Pytorch neural network, and further improving the accuracy and reliability of determining the network graph structure corresponding to the Pytorch neural network.

[0111] Figure 9 The present invention provides another flowchart of a method for determining the graph structure of a Pytorch neural network; based on the above embodiment, continue to refer to the attached Figure 9 As shown, after determining the predecessor node and the successor node corresponding to the network node in the Pytorch neural network, the method in this embodiment may further include:

[0112] Step S901: Acquire a storage area for storing a predecessor node and a successor node corresponding to a network node.

[0113] After determining the predecessor node and successor node corresponding to the network node in the Pytorch neural network, in order to facilitate statistics of the predecessor node and successor node corresponding to the network node in the Pytorch neural network, the predecessor node and successor node corresponding to the network node can be stored. Specifically, a storage area for storing the predecessor node and successor node corresponding to the network node can be determined. The storage area can be located in the network node used to control the Pytorch neural network to run based on input data.

[0114] In addition, this embodiment does not limit the implementation method for obtaining the storage area. Those skilled in the art can set it according to specific application requirements and application scenarios. In some instances, obtaining the storage area for storing the predecessor node and the successor node corresponding to the network node may include: obtaining the network layer structure corresponding to the Pytorch neural network; according to the network layer structure, determining the storage area corresponding to the network node, wherein each network layer structure corresponds to a storage area.

[0115] Specifically, in different application scenarios, different Pytorch neural networks may correspond to different network graph structures, and different network graph structures may correspond to different numbers of network layer structures. In order to accurately and reliably determine the network graph structure in the Pytorch neural network, the network layer structure corresponding to the Pytorch neural network can be obtained, and then the number of network layer structures can be counted. Then, based on the number of network layer structures, the storage areas corresponding to the network nodes can be determined, where each network layer structure can correspond to one storage area, that is, the number of network layer structures is the same as the number of storage areas.

[0116] Step S902: Store the predecessor node and the successor node corresponding to the network node in a storage area.

[0117] Specifically, after obtaining the predecessor node and successor node and the storage area corresponding to the network node, the predecessor node and successor node corresponding to the network node can be stored in the storage area, so that the predecessor node and successor node corresponding to the network node can be obtained in a timely and effective manner through the storage area, further improving the timely reliability of determining the graph structure of the Pytorch neural network.

[0118] Figure 10 A flowchart of another method for determining the graph structure of a Pytorch neural network is provided for an embodiment of the present invention; based on the above embodiment, further reference is made to the attached Figure 10 As shown, in order to improve the practicality of the method, after controlling the Pytorch neural network to run based on the input data, the method in this embodiment may further include:

[0119] Step S1001: Generate an operation result corresponding to the input data.

[0120] Step S1002: Determine the output node attribute of the output node corresponding to the operation result.

[0121] Step S1003: Based on the output node attributes and the operation result, generate and output the target operation result corresponding to the input data.

[0122] Among them, after controlling the Pytorch neural network to run based on the input data, the Pytorch neural network can generate an operation result corresponding to the input data. After generating the operation result corresponding to the input data, the output node attribute of the output node corresponding to the operation result can be determined. The output node attribute may include: the predecessor node corresponding to the output node. It can be understood that the output node attribute can not only include the above-mentioned predecessor node corresponding to the output node, but those skilled in the art can set it according to specific application requirements and design requirements. For example, the output node attribute may include the identity identifier corresponding to the current output node, etc., which will not be repeated here. In addition, this embodiment does not limit the specific implementation method for determining the output node attribute of the output node corresponding to the operation result. Those skilled in the art can set it according to specific application requirements and design requirements. For example, the output node attribute can be stored in a preset area, and the output node attribute can be obtained by accessing the preset area.

[0123] After obtaining the output node attributes and the operation data, the output node attributes and the operation results may be analyzed and processed to generate and output a target operation result corresponding to the input data. Specifically, based on the output node attributes and the operation results, generating and outputting the target operation result corresponding to the input data may include: encapsulating the output node attributes and the operation results, and generating and outputting the target operation result corresponding to the input data.

[0124] In this embodiment, after controlling the Pytorch neural network to run based on the input data, by generating a running result corresponding to the input data, the output node attribute of the output node corresponding to the running result is determined, and based on the output node attribute and the running result, the target running result corresponding to the input data is generated and output, thereby effectively achieving the accuracy and reliability of obtaining the target running result. Moreover, since the target running result includes the running result and output node attributes output by the Pytorch neural network, when controlling the Pytorch neural network to run based on the input data, the predecessor node and successor node corresponding to the network node can be determined more accurately and effectively, and it is convenient to determine the network graph structure corresponding to the Pytorch neural network based on the predecessor node and successor node corresponding to the network node, further improving the quality and efficiency of determining the network graph structure.

[0125] Figure 11 The present invention provides another flowchart of a method for determining the graph structure of a Pytorch neural network; based on the above embodiment, refer to the attached Figure 11 As shown, after generating and outputting the target operation result corresponding to the input data, the method in this embodiment may further include:

[0126] Step S1101: Determine a network node used to generate a target operation result as a predecessor node of an output node corresponding to the target operation result.

[0127] Step S1102: Store the correspondence between the output node and the predecessor node in the output node.

[0128] After the network node generates the target operation result and determines the output node corresponding to the target operation result, for the output node corresponding to the target operation result, the network node is the predecessor node of the output node. Therefore, the network node used to generate the target operation result can be determined as the predecessor node of the output node corresponding to the target operation result. In order to be able to obtain the predecessor node and successor node corresponding to each network node in the Pytorch neural network in a timely manner, the corresponding relationship between the output node and the predecessor node can be stored in the output node. Specifically, a storage area can be set in the output node. After obtaining the corresponding relationship between the output node and the predecessor node, the corresponding relationship between the output node and the predecessor node can be stored in the above-mentioned storage area. In this way, the corresponding relationship between the output node and the predecessor node can be obtained by accessing the storage area.

[0129] In this embodiment, after generating and outputting the target operation result corresponding to the input data, the network node used to generate the target operation result is determined as the predecessor node of the output node corresponding to the target operation result, and then the correspondence between the output node and the predecessor node is stored in the output node, thereby facilitating the determination of the predecessor node and the successor node corresponding to the network node in the Pytorch neural network, and further improving the accuracy and reliability of determining the network graph structure corresponding to the Pytorch neural network.

[0130] Figure 12 A flowchart of another method for determining the graph structure of a Pytorch neural network is provided for an embodiment of the present invention; based on any of the above embodiments, refer to the attached Figure 12 As shown, after determining the network graph structure corresponding to the Pytorch neural network, in order to facilitate the processing operation of the Pytorch neural network based on the network graph structure, the method in this embodiment may further include:

[0131] Step S1201: Obtain a quantization request corresponding to the Pytorch neural network.

[0132] Step S1202: quantize the network graph structure based on the quantization request to obtain a target neural network corresponding to the Pytorch neural network.

[0133] Among them, when the user has a quantization requirement for the corresponding weight coefficients in the Pytorch neural network, a quantization request can be generated for the Pytorch neural network. Specifically, the user can input an execution operation on the graph structure determination device for implementing the graph structure determination method of the Pytorch neural network, and obtain the quantization request corresponding to the Pytorch neural network by executing the operation. After obtaining the quantization request, the network graph structure can be quantized based on the quantization request, so that the target network graph structure after quantization can be obtained, and then the target neural network corresponding to the Pytorch neural network can be determined based on the target network graph structure, thereby quickly realizing the quantization operation of the neural network and ensuring the accuracy and reliability of the determination of the target neural network.

[0134] Figure 13 The present invention provides another flowchart of a method for determining the graph structure of a Pytorch neural network; based on any of the above embodiments, refer to the attached Figure 13 As shown, after determining the network graph structure corresponding to the Pytorch neural network, in order to facilitate the processing operation of the Pytorch neural network based on the network graph structure, the method in this embodiment may further include:

[0135] Step S1301: Obtain a network search request.

[0136] Step S1302: Determine a target network graph structure corresponding to the network search request among the network graph structures corresponding to the multiple Pytorch neural networks to be selected.

[0137] Step S1303: Determine the Pytorch neural network corresponding to the target network graph structure as the target network corresponding to the network search request.

[0138] Among them, when the user has a network search demand for the Pytorch neural network, the graph structure determination device for implementing the graph structure determination method of the Pytorch neural network can be input to perform an operation, and the network search request corresponding to the Pytorch neural network can be obtained by performing the operation. After obtaining the network search request, the target network graph structure corresponding to the network search request is determined in the network graph structures corresponding to the multiple Pytorch neural networks to be selected. It can be understood that different network graph structures correspond to different Pytorch neural networks, and different Pytorch neural networks can implement different data processing functions, and the obtained target network graph structure can meet the network search demand corresponding to the network search request. After determining the target network graph structure, the Pytorch neural network corresponding to the target network graph structure can be determined as the target network corresponding to the network search request, thereby effectively achieving the ability to obtain the target network that meets the network search demand, further improving the practicality of the method.

[0139] For example, multiple Pytorch neural networks to be selected include: Pytorch neural network A, Pytorch neural network B, Pytorch neural network C and Pytorch neural network D. The network graph structure corresponding to the above Pytorch neural network A is structure a, the network graph structure corresponding to Pytorch neural network B is structure b, the network graph structure corresponding to Pytorch neural network C is structure c, and the network graph structure corresponding to Pytorch neural network D is structure d.

[0140] After obtaining the network search request, the target network graph structure corresponding to the network search request can be determined in the network graph structures corresponding to the multiple Pytorch neural networks to be selected. Assuming that the determined target network graph structure can be structure c, the Pytorch neural network C corresponding to structure c can then be determined as the target network corresponding to the network search request, thereby effectively ensuring the quality and efficiency of determining the target network.

[0141] For specific applications, refer to the attached Figure 14 As shown, this application embodiment provides a method for determining the graph structure of a pytorch neural network based on a hook function. This method can free algorithm developers from the tedious code adjustment and adaptation work when performing operations such as NAS / data quantization, which can greatly improve the quality and efficiency of data processing. Specifically, the method may include the following steps:

[0142] Step 1: Replace the original code corresponding to the Pytorch neural network.

[0143] Specifically, for the original code related to the data flow operation in the Pytorch neural network, a target code corresponding to the original code is configured. The target code can be located in the configuration code library. By accessing the configuration code library, the target code corresponding to the original code can be obtained, and then the original code can be replaced with the target code. In this way, the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network can be determined through the target code with data flow tracking function.

[0144] It should be noted that when replacing the original code corresponding to the Pytorch neural network, in order to follow the module definition structure of the Pytorch neural network, the uploaded target code can have the same name as the original code in the Pytorch neural network. In this way, the native syntax of the Pytorch code language can be used to directly replace the original code related to the data flow operation in the Pytorch neural network. That is, through the name corresponding to the original code, the original code defined in the Pytorch neural network can be automatically used with the updated target code, thereby achieving the goal of minimizing the changes to the original code while obtaining the network graph structure corresponding to the Pytorch neural network. The adaptation cost and adaptation error rate are almost 0. Compared with the implementation method of replacing the code by the algorithm developer, the adaptation quality and efficiency of the above implementation method are higher.

[0145] Step 2: Get the input data Qtensor for input to the Pytorch neural network.

[0146] Step 3: Input the input data Qtensor into the Pytorch neural network and perform network operation.

[0147] Reference Attachment Figure 2 As shown, the graph structure determination method utilizes the native hook mechanism of the Pytorch neural network to perform corresponding data processing operations. The hook mechanism may include a first hook function pre_hooks and a second hook function hooks. Specifically, after obtaining the input data Qtensor, each network node can first call pre_hooks (which can be customized) through the call function to pre-process the input data to determine the predecessor node of the network node corresponding to the current pre_hooks. Then, the execution function forward() can be called and the corresponding data processing operation can be performed based on the input data Qtensor, so as to obtain the operation result corresponding to the input data Qtensor. Finally, the operation result is output through the second hook function hooks, and the successor node of the current network node is determined.

[0148] It should be noted that when using pre_hooks (which can be customized) to preprocess the input data, the data flow in the Pytorch neural network can be tracked, and the predecessor and successor nodes stored in the preset area (for example: the calculation graph node QGraphNode) can be updated to count the predecessor and successor nodes corresponding to all network nodes, and determine the network graph structure corresponding to the Pytorch neural network based on the predecessor and successor nodes corresponding to all network nodes.

[0149] Step 4: Compute the network graph structure corresponding to the Pytorch neural network.

[0150] By counting the predecessor and successor nodes of all network nodes in the Pytorch neural network, the network graph structure corresponding to the Pytorch neural network can be calculated based on the predecessor and successor nodes corresponding to all the above network nodes.

[0151] The hook function-based graph structure determination method of the pytorch neural network provided in this application embodiment utilizes the native hook function mechanism of Pytorch to realize accurate and effective extraction operations on the graph structure of the pytorch neural network. In the process of determining the graph structure, the changed network structure is aligned with the original structure of the Pytorch neural network, so that the original code can be replaced by the native syntax of the Pytorch neural network. This effectively achieves the goal of obtaining the graph structure of the pytorch neural network while minimizing the pollution to the original code, further improving the flexibility, reliability and practicality of the method.

[0152] Figure 15 A flow chart of a network optimization method is provided for an embodiment of the present invention; Figure 15 As shown, this embodiment provides a network optimization method. The execution subject of the network optimization method is a network optimization device. It can be understood that the network optimization can be implemented as software or a combination of software and hardware. Specifically, the method may include:

[0153] Step S1501: Obtain a network optimization request corresponding to the Pytorch neural network.

[0154] Step S1502: Determine a network graph structure corresponding to the Pytorch neural network, where the network graph structure includes: network nodes in the Pytorch neural network and connection relationships between network nodes.

[0155] Step S1503: Optimize the network graph structure based on the network optimization request to obtain a target network graph structure.

[0156] Step S1504: Generate a target Pytorch neural network corresponding to the network optimization request based on the target network graph structure.

[0157] The following is a detailed explanation of each of the above steps:

[0158] Step S1501: Obtain a network optimization request corresponding to the Pytorch neural network.

[0159] Among them, when the user has optimization requirements for the Pytorch neural network, a network optimization request can be generated for the Pytorch neural network. Specifically, the network optimization request may include at least one of the following: a network search request for searching for a network that meets the user's needs, a quantization request for performing quantization operations on the weight coefficients in the Pytorch neural network, etc. It can be understood that different optimization requirements may correspond to different network optimization requests.

[0160] Specifically, when a user has an optimization requirement for a Pytorch neural network, the user can input and execute an operation on a graph structure determination device for implementing a graph structure determination method for a Pytorch neural network, and obtain a network optimization request corresponding to the Pytorch neural network by executing the operation. Of course, those skilled in the art can also adopt other implementation methods to obtain a network optimization request corresponding to a Pytorch neural network, as long as the accuracy and reliability of obtaining the network optimization request corresponding to the Pytorch neural network can be guaranteed, which will not be repeated here.

[0161] Step S1502: Determine a network graph structure corresponding to the Pytorch neural network, where the network graph structure includes: network nodes in the Pytorch neural network and connection relationships between network nodes.

[0162] After obtaining the network optimization request, the network graph structure corresponding to the Pytorch neural network can be determined based on the network optimization request. The network graph structure may include network nodes in the Pytorch neural network and connection relationships between network nodes.

[0163] In some instances, determining a network graph structure corresponding to a Pytorch neural network may include: obtaining input data for input to the Pytorch neural network to be analyzed; controlling the Pytorch neural network to run based on the input data, and determining predecessor nodes and successor nodes corresponding to network nodes in the Pytorch neural network; and determining a network graph structure corresponding to the Pytorch neural network based on the predecessor nodes and successor nodes corresponding to the network nodes in the Pytorch neural network.

[0164] Specifically, the specific implementation method and implementation effect of determining the network graph structure corresponding to the Pytorch neural network in this embodiment are the same as those described above. Figure 1 The specific implementation method and implementation effect of determining the network graph structure corresponding to the Pytorch neural network in the corresponding embodiment are similar. Please refer to the above statements for details and will not be repeated here.

[0165] Step S1503: Optimize the network graph structure based on the network optimization request to obtain a target network graph structure.

[0166] After obtaining the network graph structure, the network graph structure can be optimized based on the network optimization request. It can be understood that different network optimization requests may correspond to different optimization operations. After performing the optimization operation, the optimized target network graph structure can be obtained.

[0167] Step S1504: Generate a target Pytorch neural network corresponding to the network optimization request based on the target network graph structure.

[0168] After obtaining the target network graph structure, the target Pytorch neural network corresponding to the network optimization request can be generated based on the target network graph structure, thereby effectively achieving the optimization operation of the Pytorch neural network by adjusting the network graph structure corresponding to the Pytorch neural network. This not only frees developers from the tedious code adaptation work, but also greatly improves the quality and efficiency of the network architecture optimization operation, further improving the practicality of the method.

[0169] Figure 16 A schematic diagram of a graph structure determination device for a Pytorch neural network according to an embodiment of the present invention; see the attached Figure 16 As shown, this embodiment provides a device for determining the graph structure of a Pytorch neural network, which can perform the above Figure 1 The graph structure determination method of the Pytorch neural network shown in the figure, specifically, the graph structure determination device may include: a first acquisition module 11, a first control module 12 and a first processing module 13.

[0170] A first acquisition module 11 is used to acquire input data for inputting into the Pytorch neural network to be analyzed;

[0171] A first control module 12 is used to control the Pytorch neural network to run based on input data and determine the predecessor node and the successor node corresponding to the network node in the Pytorch neural network;

[0172] The first processing module 13 is used to determine the network graph structure corresponding to the Pytorch neural network based on the predecessor nodes and successor nodes corresponding to the network nodes in the Pytorch neural network, where the network graph structure includes: the network nodes in the Pytorch neural network and the connection relationship between the network nodes.

[0173] In some examples, before obtaining input data for input into the Pytorch neural network to be analyzed, the first acquisition module 11 and the first processing module 13 in this embodiment can be used to perform the following steps:

[0174] A first acquisition module 11 is used to obtain the original code corresponding to the Pytorch neural network and the identity corresponding to the original code;

[0175] The first processing module 13 is used to determine the target code corresponding to the original code based on the identity identifier; and update the original code using the target code to determine the predecessor node and successor node corresponding to the network node in the Pytorch neural network through the target code.

[0176] In some instances, the original code corresponds to at least one of: an input node for obtaining input data to be input to the Pytorch neural network to be analyzed; a processing node for controlling the Pytorch neural network to execute based on the input data; and an output node for generating an execution result corresponding to the input data.

[0177] In some instances, when the first acquisition module 11 acquires input data for input into the Pytorch neural network to be analyzed, the first acquisition module 11 is used to execute: acquiring raw data for input into the network layer in the Pytorch neural network to be analyzed; determining the input node attributes of the input node corresponding to the raw data; and determining the input data for input into the Pytorch neural network to be analyzed based on the raw data and the input node attributes.

[0178] In some examples, the input node attributes include: a successor node corresponding to the input node.

[0179] In some instances, when the first acquisition module 11 determines the input data for inputting into the Pytorch neural network to be analyzed based on the original data and the input node attributes, the first acquisition module 11 is used to execute: encapsulating the original data and the input node attributes to obtain the input data for inputting into the Pytorch neural network to be analyzed.

[0180] In some instances, after obtaining input data for input into the Pytorch neural network to be analyzed, the first processing module 13 in this embodiment is used to execute: determining the network node that obtains the input data as the successor node of the input node corresponding to the input data; and storing the correspondence between the input node and the successor node in the input node.

[0181] In some examples, after determining the predecessor node and the successor node corresponding to the network node in the Pytorch neural network, the first acquisition module 11 and the first processing module 13 in this embodiment can be used to perform the following steps:

[0182] A first acquisition module 11 is configured to acquire a storage area for storing a predecessor node and a successor node corresponding to a network node;

[0183] The first processing module 13 is configured to store a predecessor node and a successor node corresponding to the network node in a storage area.

[0184] In some instances, the storage area is located in a processing node that controls the execution of a Pytorch neural network based on input data.

[0185] In some instances, when the first acquisition module 11 acquires a storage area for storing predecessor nodes and successor nodes corresponding to a network node, the first acquisition module 11 can be used to execute: acquiring a network layer structure corresponding to a Pytorch neural network; and determining a storage area corresponding to the network node based on the network layer structure, wherein each network layer structure corresponds to a storage area.

[0186] In some instances, after controlling the Pytorch neural network to run based on the input data, the first processing module 13 in this embodiment can be used to perform: generating an operation result corresponding to the input data; determining the output node attributes of the output node corresponding to the operation result; and generating and outputting a target operation result corresponding to the input data based on the output node attributes and the operation result.

[0187] In some examples, the output node attributes include: a predecessor node corresponding to the output node.

[0188] In some instances, when the first processing module 13 generates and outputs a target operation result corresponding to the input data based on the output node attributes and the operation result, the first processing module 13 can be used to perform: encapsulating the output node attributes and the operation result, and generating and outputting the target operation result corresponding to the input data.

[0189] In some instances, after generating and outputting the target operation result corresponding to the input data, the first processing module 13 in this embodiment can be used to execute: determining the network node used to generate the target operation result as the predecessor node of the output node corresponding to the target operation result; and storing the correspondence between the output node and the predecessor node in the output node.

[0190] In some examples, after determining the network graph structure corresponding to the Pytorch neural network, the first acquisition module 11 and the first processing module 13 in this embodiment can be used to perform the following steps:

[0191] A first acquisition module 11 is used to obtain a quantization request corresponding to a Pytorch neural network;

[0192] The first processing module 13 is used to quantize the network graph structure based on the quantization request to obtain a target neural network corresponding to the Pytorch neural network.

[0193] In some examples, after determining the network graph structure corresponding to the Pytorch neural network, the first acquisition module 11 and the first processing module 13 in this embodiment can be used to perform the following steps:

[0194] A first acquisition module 11 is used to acquire a network search request;

[0195] The first processing module 13 is used to determine a target network graph structure corresponding to the network search request among the network graph structures corresponding to the multiple Pytorch neural networks to be selected; and determine the Pytorch neural network corresponding to the target network graph structure as the target network corresponding to the network search request.

[0196] Figure 16 The device shown can perform Figures 1 to 14 For the method of the embodiment shown in FIG. 1 , the part not described in detail in this embodiment can be referred to the Figures 1 to 14 The implementation process and technical effects of this technical solution can be found in Figures 1 to 14 The description in the illustrated embodiment will not be repeated here.

[0197] In one possible design, Figure 16 The structure of the graph structure determination device of the Pytorch neural network shown can be implemented as an electronic device, which can be a mobile phone, tablet computer, server and other devices. Figure 17 As shown, the electronic device may include: a first processor 21 and a first memory 22. The first memory 22 is used to store data that supports the electronic device to execute the above Figures 1-14In at least some of the embodiments shown, the program of the method for determining the graph structure of the Pytorch neural network is provided, and the first processor 21 is configured to execute the program stored in the first memory 22.

[0198] The program includes one or more computer instructions, wherein when the one or more computer instructions are executed by the first processor 21, the following steps can be implemented:

[0199] Get the input data for the Pytorch neural network to be analyzed;

[0200] Control the Pytorch neural network to run based on the input data, and determine the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network;

[0201] Based on the predecessor nodes and successor nodes corresponding to the network nodes in the Pytorch neural network, a network graph structure corresponding to the Pytorch neural network is determined. The network graph structure includes: the network nodes in the Pytorch neural network and the connection relationship between the network nodes.

[0202] Optionally, the first processor 21 is further configured to execute the aforementioned Figures 1-14 All or part of the steps in at least some of the embodiments shown.

[0203] The structure of the electronic device may further include a first communication interface 23 for the electronic device to communicate with other devices or a communication network.

[0204] In addition, an embodiment of the present invention provides a computer storage medium for storing computer software instructions used by electronic devices, which includes instructions for executing the above Figures 1-14 The program involved in the method for determining the graph structure of a Pytorch neural network in at least some of the embodiments shown.

[0205] Figure 18 A schematic diagram of the structure of a network optimization device provided by an embodiment of the present invention; Figure 18 As shown, this embodiment provides a network optimization device that can perform Figure 15 The network optimization method shown in the figure, specifically, the network optimization device may include: a second acquisition module 31, a second determination module 32, a second optimization module 33 and a second processing module 34.

[0206] The second acquisition module 31 is used to obtain a network optimization request corresponding to the Pytorch neural network.

[0207] The second determination module 32 is used to determine the network graph structure corresponding to the Pytorch neural network, where the network graph structure includes: network nodes in the Pytorch neural network and connection relationships between network nodes.

[0208] The second optimization module 33 is used to optimize the network graph structure based on the network optimization request to obtain a target network graph structure.

[0209] The second processing module 34 is used to generate a target Pytorch neural network corresponding to the network optimization request according to the target network graph structure.

[0210] In some instances, when the second determination module 32 determines the network graph structure corresponding to the Pytorch neural network, the second determination module 32 can be used to perform: obtaining input data for input into the Pytorch neural network to be analyzed; controlling the Pytorch neural network to run based on the input data, and determining the predecessor nodes and successor nodes corresponding to the network nodes in the Pytorch neural network; and determining the network graph structure corresponding to the Pytorch neural network based on the predecessor nodes and successor nodes corresponding to the network nodes in the Pytorch neural network.

[0211] Figure 18 The device shown can perform Figures 1 to 15 For the method of the embodiment shown in FIG. 1 , the part not described in detail in this embodiment can be referred to the Figures 1 to 15 The implementation process and technical effects of this technical solution can be found in Figures 1 to 15 The description in the illustrated embodiment will not be repeated here.

[0212] In one possible design, Figure 18 The structure of the network optimization device shown can be implemented as an electronic device, which can be a mobile phone, tablet computer, server and other devices. Figure 19 As shown, the electronic device may include: a second processor 41 and a second memory 42. The second memory 42 is used to store the data that supports the electronic device to execute the above Figures 1-15 The second processor 41 is configured to execute the program stored in the second memory 42 , which is a program of the network optimization method provided in at least some of the embodiments shown.

[0213] The program includes one or more computer instructions, wherein when the one or more computer instructions are executed by the second processor 41, the following steps can be implemented:

[0214] Get the network optimization request corresponding to the Pytorch neural network;

[0215] Determine the network graph structure corresponding to the Pytorch neural network, which includes: network nodes in the Pytorch neural network and the connection relationships between network nodes;

[0216] Optimize the network graph structure based on the network optimization request to obtain the target network graph structure;

[0217] Generate a target Pytorch neural network corresponding to the network optimization request based on the target network graph structure.

[0218] Optionally, the second processor 41 is further configured to execute the aforementioned Figures 1-15 All or part of the steps in at least some of the embodiments shown.

[0219] The structure of the electronic device may further include a second communication interface 43 for the electronic device to communicate with other devices or a communication network.

[0220] In addition, an embodiment of the present invention provides a computer storage medium for storing computer software instructions used by electronic devices, which includes instructions for executing the above Figures 1-15 The procedures involved in the network optimization method in at least some of the embodiments shown.

[0221] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0222] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by a combination of hardware and software. Based on this understanding, the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0223] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0224] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0225] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0226] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0227] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0228] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0229] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A method for determining the graph structure of a Pytorch neural network, comprising: Get the input data for the Pytorch neural network to be analyzed; Controlling the Pytorch neural network to run based on the input data, and determining a predecessor node and a successor node corresponding to a network node in the Pytorch neural network; Determine, based on the predecessor nodes and successor nodes corresponding to the network nodes in the Pytorch neural network, a network graph structure corresponding to the Pytorch neural network, wherein the network graph structure includes: the network nodes in the Pytorch neural network and the connection relationships between the network nodes; Before obtaining input data for inputting into the Pytorch neural network to be analyzed, the method further includes: Obtaining the original code corresponding to the Pytorch neural network and an identity corresponding to the original code; Based on the identity identifier, determining a target code corresponding to the original code; The original code is updated using the target code to determine the predecessor node and the successor node corresponding to the network node in the Pytorch neural network through the target code.

2. The method according to claim 1, wherein Obtain input data for the Pytorch neural network to be analyzed, including: Obtain raw data for input to the network layers of the Pytorch neural network to be analyzed; Determining an input node attribute of an input node corresponding to the original data; According to the original data and the input node attributes, input data for inputting into the Pytorch neural network to be analyzed is determined.

3. The method according to claim 1, wherein After obtaining input data for input into the Pytorch neural network to be analyzed, the method further includes: Determine the network node that obtains the input data as the successor node of the input node corresponding to the input data; The corresponding relationship between the input node and the successor node is stored in the input node.

4. The method according to claim 1, wherein After determining the predecessor node and the successor node corresponding to the network node in the Pytorch neural network, the method further includes: Acquire a storage area for storing a predecessor node and a successor node corresponding to the network node; A predecessor node and a successor node corresponding to the network node are stored in the storage area.

5. The method according to claim 4, wherein Acquiring a storage area for storing a predecessor node and a successor node corresponding to the network node, comprising: Obtain the network layer structure corresponding to the Pytorch neural network; According to the network layer structure, storage areas corresponding to the network nodes are determined, wherein each network layer structure corresponds to one storage area.

6. The method according to claim 1, wherein After controlling the Pytorch neural network to run based on the input data, the method further includes: generating an operating result corresponding to the input data; Determining an output node attribute of an output node corresponding to the operation result; Based on the output node attributes and the execution result, a target execution result corresponding to the input data is generated and output.

7. The method according to claim 6, wherein: After generating and outputting a target operation result corresponding to the input data, the method further includes: Determine the network node used to generate the target operation result as the predecessor node of the output node corresponding to the target operation result; The corresponding relationship between the output node and the predecessor node is stored in the output node.

8. The method according to any one of claims 1 to 7, wherein: After determining the network graph structure corresponding to the Pytorch neural network, the method further includes: Get a quantization request corresponding to the Pytorch neural network; The network graph structure is quantized based on the quantization request to obtain a target neural network corresponding to the Pytorch neural network.

9. The method according to any one of claims 1 to 7, wherein: After determining the network graph structure corresponding to the Pytorch neural network, the method further includes: Get network search requests; Determine, among the network graph structures corresponding to the plurality of Pytorch neural networks to be selected, a target network graph structure corresponding to the network search request; The Pytorch neural network corresponding to the target network graph structure is determined as the target network corresponding to the network search request.

10. A network optimization method, comprising: Get the network optimization request corresponding to the Pytorch neural network; Determine a network graph structure corresponding to the Pytorch neural network, wherein the network graph structure includes: network nodes in the Pytorch neural network and connection relationships between the network nodes; Optimizing the network graph structure based on the network optimization request to obtain a target network graph structure; Generate a target Pytorch neural network corresponding to the network optimization request according to the target network graph structure; The network graph structure is determined based on the predecessor and successor nodes corresponding to the network nodes in the Pytorch neural network, and the method further includes: Obtaining the original code corresponding to the Pytorch neural network and an identity corresponding to the original code; Based on the identity identifier, determining a target code corresponding to the original code; The original code is updated using the target code to determine the predecessor node and the successor node corresponding to the network node in the Pytorch neural network through the target code.

11. An electronic device comprising: Memory, processor; wherein, The memory is used to store one or more computer instructions, wherein when the one or more computer instructions are executed by the processor, the method for determining the graph structure of the Pytorch neural network according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Graph neural network training method, client device and system

    CN110751269A

  • Acceleration method for exploring optimization space in deep learning compiler

    CN112579063A