Graph processing method and device, data processing method and device and electronic equipment
By obtaining device support information and connection status in the neural network model, and dividing operator nodes to adapt to different hardware devices, the problem of insufficient universality of operator division is solved and the running speed of the neural network model is improved.
Patent Information
- Application Number
- CN202310246935.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-07
- Publication Date
- 2024-09-10
AI Technical Summary
In the existing technology, when operators are divided in neural network models, adjacent operators are divided into different hardware devices, resulting in reduced running speed, and the improvement method is not universal enough and cannot be applied to all types of neural network models.
By obtaining the device support information in the neural network operator association graph, the reference operator nodes that are not supported in the acceleration device are determined, and the operator nodes to be divided are divided according to the connection status and device support information to form a target operator that supports the acceleration device operation. Set the child nodes, update the association graph until it no longer changes, and store the association between the target operator node and the device to determine the computing device.
It improves the universality and accuracy of operator division, reduces complexity, avoids dividing adjacent operator nodes into different hardware devices, and improves the running speed of the neural network model.
Smart Images

Figure CN118627558A
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a graph processing method, a data processing method, a device and an electronic device. Background Art
[0002] At present, the efficiency of information processing by the neural network model can be improved by dividing the operators in the neural network model and then dispatching the divided operators to various acceleration hardware devices for computing the neural network model. The acceleration hardware devices may be various acceleration hardware devices such as DSP (Digital Signal Processor, a unique microprocessor), GPU (Graphics Processing Unit, graphics processor), NPU (Neural-network Processing Unit, embedded neural network processor). When dividing the operators in the neural network model, if adjacent operators are divided into different hardware devices, the running speed of the neural network model will be slowed down. In the related art, in order to solve the above problems, there are also some methods to improve the accuracy of operator division. However, these methods are often only applicable to some types of neural network models. When applied to inapplicable neural network models, the accuracy of operator division will be reduced, thereby reducing the running speed of the neural network model. Summary of the invention
[0003] The following is a summary of the subject matter described in detail in this application. This summary is not intended to limit the scope of the claims.
[0004] The embodiments of the present application provide a graph processing method, a data processing method, a device and an electronic device, which can improve the universality of operator division, thereby improving the accuracy of operator division and improving the running speed of the neural network model.
[0005] On the one hand, an embodiment of the present application provides a graph processing method, including:
[0006] Obtaining device support information for each operator node in a neural network operator association graph, and determining reference operator nodes that are not supported for operation in an acceleration device according to the device support information;
[0007] Determine a first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, divide the operator node to be divided according to the first connection state and the device support information, and obtain a target operator node set that supports operation in the acceleration device;
[0008] Using the target operator node set as the reference operator node to update the neural network operator association graph, and again dividing the to-be-divided operator nodes in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, thereby obtaining a plurality of target operator node sets;
[0009] An association relationship between the target operator node set and the target device is stored, wherein the association relationship is used to determine the target device for performing an operation on the target operator node set when a neural network operation request is received.
[0010] On the other hand, the embodiment of the present application also provides a data processing method, including:
[0011] In response to a neural network operation request for operating a target neural network, obtaining a preset association relationship;
[0012] According to the association relationship, each target operator node set in the target neural network is sent to the target device for calculation;
[0013] Among them, the association relationship is obtained through the following steps: obtaining device support information of each operator node in the neural network operator association graph, determining the reference operator node that does not support operation in the acceleration device according to the device support information, determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, dividing the operator node to be divided according to the first connection state and the device support information, obtaining a set of target operator nodes that support operation in the acceleration device, updating the neural network operator association graph with the target operator node set as the reference operator node, and again dividing the operator node to be divided in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, obtaining multiple sets of the target operator node, and storing the association relationship between the target operator node set and the target device.
[0014] On the other hand, an embodiment of the present application further provides a graph processing device, including:
[0015] A reference operator node determination module, used to obtain device support information of each operator node in the neural network operator association diagram, and determine reference operator nodes that are not supported for operation in the acceleration device according to the device support information;
[0016] A first partitioning module is used to determine a first connection state between the operator node to be partitioned and the reference operator node in the neural network operator association graph, and partition the operator node to be partitioned according to the first connection state and the device support information to obtain a target operator node set that supports operation in the acceleration device;
[0017] A second partitioning module is used to update the neural network operator association graph by using the target operator node set as the reference operator node, and again partition the operator nodes to be partitioned in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, thereby obtaining a plurality of target operator node sets;
[0018] An association relationship storage module is used to store the association relationship between the target operator node set and the target device, wherein the association relationship is used to determine the target device that performs operations on the target operator node set when a neural network operation request is received.
[0019] Furthermore, the first division module is specifically used for:
[0020] Acquire a first node depth of an operator node to be divided in the neural network operator association graph, and a second node depth of a divided operator node adjacent to the operator node to be divided, wherein the divided operator node belongs to the target operator node set;
[0021] The magnitude relationship between the second node depth and the first node depth is compared to obtain a comparison result, and a first connection state between the operator node to be divided and the reference operator node is determined according to the comparison result.
[0022] Furthermore, the first division module is specifically used for:
[0023] Obtaining a node ordering of the neural network operator association graph, and traversing the neural network operator association graph according to the node ordering;
[0024] Adding a first operator node that supports operations in the acceleration device as a divided operator node to the target operator node set, and obtaining a second node depth of the divided operator node;
[0025] An operator node adjacent to the divided operator node is used as an operator node to be divided, and a first node depth of the operator node to be divided is obtained.
[0026] Furthermore, the first division module is specifically used for:
[0027] Determining a first path direction between the operator node to be divided and the reference operator node according to the comparison result;
[0028] A first connection state between the to-be-divided operator node and the reference operator node is determined according to the first path direction.
[0029] Furthermore, the first division module is specifically used for:
[0030] When the comparison result is that the second node depth is less than the first node depth, determining that the first path direction between the to-be-divided operator node and the reference operator node is from the reference operator node to the to-be-divided operator node;
[0031] Alternatively, when the comparison result is that the second node depth is greater than the first node depth, it is determined that the first path direction between the to-be-divided operator node and the reference operator node is from the to-be-divided operator node to the reference operator node.
[0032] Furthermore, the first division module is specifically used for:
[0033] When the first connection state is unconnected, and the device support information indicates that the operator node to be divided supports calculation in the acceleration device, adding the operator node to be divided to the target operator node set;
[0034] Alternatively, when the first connection state is connected, the second connection state between the split operator node and the reference operator node is determined according to the comparison result; when the second connection state is disconnected and the device support information indicates that the operator node to be split supports calculations in the acceleration device, the operator node to be split is added to the target operator node set.
[0035] Furthermore, the first division module is specifically used for:
[0036] Determining a second path direction between the divided operator node and the reference operator node according to the comparison result;
[0037] A second connection state between the divided operator node and the reference operator node is determined according to the second path direction.
[0038] Furthermore, the first division module is specifically used for:
[0039] When the comparison result is that the second node depth is less than the first node depth, determining that the second path direction between the divided operator node and the reference operator node is from the divided operator node to the reference operator node;
[0040] Alternatively, when the comparison result is that the second node depth is greater than the first node depth, it is determined that the second path direction between the divided operator node and the reference operator node is from the reference operator node to the divided operator node.
[0041] Furthermore, the first division module is specifically used for:
[0042] Obtaining resource occupancy parameters when processing the neural network operator association graph;
[0043] When the magnitude relationship between the resource occupancy parameter and the preset candidate parameter threshold satisfies a preset condition, a first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph is determined.
[0044] Furthermore, the first division module is also used for:
[0045] When the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, obtaining a second node depth of a divided operator node adjacent to the operator node to be divided and a first node depth of the operator node to be divided, determining the continuity between the second node depth and the first node depth, and dividing the operator node to be divided according to the continuity and the device support information;
[0046] Alternatively, when the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, determining a first affiliation relationship between all preceding operator nodes of the operator node to be divided and the target operator node set, and dividing the operator node to be divided according to the first affiliation relationship and the device support information;
[0047] Alternatively, when the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, determine the second affiliation relationship between all successor operator nodes of the operator node to be divided and the target operator node set, and divide the operator node to be divided according to the second affiliation relationship and the device support information.
[0048] On the other hand, an embodiment of the present application further provides a data processing device, including:
[0049] An association relationship acquisition module, used to obtain a preset association relationship in response to a neural network operation request for operating a target neural network;
[0050] A computing module, used for sending each target operator node set in the target neural network to a target device for computing according to the association relationship;
[0051] Among them, the association relationship is obtained through the following steps: obtaining device support information of each operator node in the neural network operator association graph, determining the reference operator node that does not support operation in the acceleration device according to the device support information, determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, dividing the operator node to be divided according to the first connection state and the device support information, obtaining a set of target operator nodes that support operation in the acceleration device, updating the neural network operator association graph with the target operator node set as the reference operator node, and again dividing the operator node to be divided in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, obtaining multiple sets of the target operator node, and storing the association relationship between the target operator node set and the target device.
[0052] On the other hand, an embodiment of the present application further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned image processing method or data processing method when executing the computer program.
[0053] On the other hand, an embodiment of the present application further provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is executed by a processor to implement the above-mentioned graph processing method or data processing method.
[0054] On the other hand, the embodiment of the present application further provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned graph processing method or data processing method.
[0055] The embodiments of the present application include at least the following beneficial effects: by obtaining the device support information of each operator node in the neural network operator association graph, determining the reference operator node that does not support operation in the acceleration device according to the device support information, determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, dividing the operator node to be divided according to the first connection state and the device support information, and obtaining a target operator node set that supports operation in the acceleration device. Since the reference operator node does not support operation in the acceleration device, it is possible to determine whether there may be an illegal path connected between the operator node to be divided and other operator nodes in the target operator node set through the first connection state, and make the operator node that the operator node to be divided input depends on as much as possible in the target operator node set, effectively improving the universality of operator division, and thus improving the accuracy of operator division. In addition, by updating the neural network operator association graph by using the target operator node set as the reference operator node, it is convenient to obtain multiple target operator node sets when the operator nodes to be divided in the updated neural network operator association graph are divided again according to the first connection state. In addition, by determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, compared with the method of traversing and exploring all paths of the operator node to be divided, it can effectively reduce the complexity and improve the efficiency of operator division. On this basis, the association relationship between the target operator node set and the target device is further stored. When a neural network operation request is received later, the target device for operating the target operator node set can be accurately determined based on the association relationship, which more effectively avoids dividing adjacent operator nodes into different hardware devices for operation, thereby improving the running speed of the neural network model.
[0056] Other features and advantages of the present application will be set forth in the following description, and in part will become apparent from the description, or may be understood by practicing the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0058] Figure 1 A schematic diagram of an optional implementation environment provided for an embodiment of the present application;
[0059] Figure 2 An optional flowchart of the graph processing method provided in the embodiment of the present application;
[0060] Figure 3 An optional update schematic diagram of a neural network operator association graph provided in an embodiment of the present application;
[0061] Figure 4 A schematic diagram of an optional principle of node depth determination provided in an embodiment of the present application;
[0062] Figure 5 A schematic diagram of an optional division process provided in an embodiment of the present application;
[0063] Figure 6 An optional schematic diagram for determining the direction of a first path provided in an embodiment of the present application;
[0064] Figure 7 A schematic diagram of an optional second path direction determination provided in an embodiment of the present application;
[0065] Figure 8 An optional flowchart of the data processing method provided in the embodiment of the present application;
[0066] Fig. 9 A detailed flow chart of dividing the operator nodes to be divided provided in the embodiment of the present application;
[0067] Fig.10 Another detailed flow chart of dividing the operator nodes to be divided provided in the embodiment of the present application;
[0068] Fig.11 A schematic diagram of an optional neural network operator association graph partitioning process provided in an embodiment of the present application;
[0069] Fig.12 A schematic diagram of an optional neural network operator association graph structure provided for this application;
[0070] Fig.13 A schematic diagram of an optional structure of a graph processing device provided in an embodiment of the present application;
[0071] Fig.14 An optional structural diagram of a data processing device provided in an embodiment of the present application;
[0072] Fig.15 A partial structural block diagram of a terminal provided in an embodiment of the present application;
[0073] Fig.16 A partial structural block diagram of the server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0074] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0075] It should be noted that, in each specific embodiment of the present application, when it comes to the need to perform relevant processing based on data related to the characteristics of the target object such as target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with the relevant laws, regulations and standards of the relevant countries and regions. Among them, the target object can be a user. In addition, when the embodiment of the present application needs to obtain the target object attribute information, the separate permission or separate consent of the target object will be obtained by means of a pop-up window or jumping to a confirmation page, and after the separate permission or separate consent of the target object is clearly obtained, the necessary target object-related data for enabling the normal operation of the embodiment of the present application will be obtained.
[0076] To facilitate understanding of the technical solutions provided in the embodiments of the present application, some key terms used in the embodiments of the present application are explained here:
[0077] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0078] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. Basic artificial intelligence technologies generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operating / interactive systems, mechatronics and other technologies. Artificial intelligence software technologies mainly include computer vision technology, speech processing technology, natural language processing technology, as well as machine learning / deep learning, autonomous driving, smart transportation and other major directions.
[0079] Computer Vision Technology (CV) Computer vision is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision such as using cameras and computers to replace human eyes to identify and measure targets, and further perform graphic processing so that computer processing becomes an image that is more suitable for human eye observation or transmission to instrument detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multi-dimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and map construction, automatic driving, smart transportation and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.
[0080] The key technologies of speech technology include automatic speech recognition technology, speech synthesis technology and voiceprint recognition technology. Enabling computers to listen, see, speak and feel is the development direction of human-computer interaction in the future, among which speech has become one of the most promising human-computer interaction methods in the future.
[0081] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.
[0082] In order to avoid dividing adjacent operators into different hardware devices, which will slow down the running speed of the neural network model, there are some methods in the related technology to improve the accuracy of operator division. However, these methods are often only applicable to some types of neural network models. When applied to inapplicable neural network models, the accuracy of operator division will be reduced, thereby reducing the running speed of the neural network model.
[0083] Based on this, the embodiments of the present application provide a graph processing method, a data processing method, a device and an electronic device, which can improve the universality of operator division, thereby improving the accuracy of operator division and improving the running speed of the neural network model.
[0084] Reference Figure 1 , Figure 1A schematic diagram of an optional implementation environment provided for an embodiment of the present application, the implementation environment includes a terminal 101 and a server 102, wherein the terminal 101 and the server 102 are connected via a communication network.
[0085] Exemplarily, the terminal 101 may send a neural network operator partitioning request to the server 102, and the server 102 may obtain the neural network operator association graph corresponding to the neural network operator partitioning request, obtain the device support information of each operator node in the neural network operator association graph, determine the reference operator node that does not support operation in the acceleration device according to the device support information, determine the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, divide the operator node to be divided according to the first connection state and the device support information, obtain a target operator node set that supports operation in the acceleration device, update the neural network operator association graph using the target operator node set as the reference operator node, and again divide the operator node to be divided in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, obtain multiple target operator node sets, and store the association relationship between the target operator node sets and the target devices, wherein the association relationship is used to determine the target device for operating the target operator node set when a neural network operation request is received.
[0086] Among them, the server 102 obtains the device support information of each operator node in the neural network operator association graph, determines the reference operator node that does not support operation in the acceleration device according to the device support information, determines the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, divides the operator node to be divided according to the first connection state and the device support information, and obtains a target operator node set that supports operation in the acceleration device. Since the reference operator node does not support operation in the acceleration device, the first connection state can be used to determine whether there may be an illegal path connected between the operator node to be divided and other operator nodes in the target operator node set, and the operator nodes that the operator node to be divided input depends on are made in the target operator node set as much as possible, which effectively improves the universality of operator division and thus improves the accuracy of operator division. In addition, by updating the neural network operator association graph by using the target operator node set as the reference operator node, it is convenient to obtain multiple target operator node sets when the operator nodes to be divided in the updated neural network operator association graph are divided again according to the first connection state. In addition, by determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, compared with the method of traversing and exploring all paths of the operator node to be divided, it can effectively reduce the complexity and improve the efficiency of operator division. On this basis, the association relationship between the target operator node set and the target device is further stored. When a neural network operation request is received later, the target device for operating the target operator node set can be accurately determined based on the association relationship, which more effectively avoids dividing adjacent operator nodes into different hardware devices for operation, thereby improving the running speed of the neural network model.
[0087] Server 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. In addition, server 102 can also be a node server in a blockchain network.
[0088] The terminal 101 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, a vehicle-mounted terminal, etc., but is not limited thereto. The terminal 101 and the server 102 may be directly or indirectly connected via wired or wireless communication, which is not limited in the present embodiment.
[0089] The method provided in the embodiments of the present application can be applied to various technical fields, including but not limited to computer vision technology, speech technology, and natural language processing in artificial intelligence.
[0090] Reference Figure 2 , Figure 2 An optional flowchart of a graph processing method provided in an embodiment of the present application, the graph processing method can be executed by a terminal, or can also be executed by a server, or can also be executed by a terminal and a server in cooperation, and the graph processing method includes but is not limited to the following steps 201 to 203.
[0091] Step 201: Obtain device support information of each operator node in the neural network operator association diagram, and determine reference operator nodes that are not supported for operation in the acceleration device based on the device support information.
[0092] Among them, the neural network operator association graph is the operator association graph corresponding to the neural network, and the operator association graph is a computing network graph composed of operators. Operator (OP) refers to a computing unit, which is a symbol describing the calculation. For example, the convolution operation in the convolutional neural network layer is an operator, and the weight summation operation in the fully connected neural network layer is an operator. The neural network operator association graph is also a neural network calculation graph, and the neural network operator association graph refers to a directed acyclic graph composed of various computing units corresponding to the neural network. The neural network can be a neural network of various structures, for example, a tree-structured neural network, a standard structured neural network, a recurrent neural network, a convolutional network, etc., which is not limited in the embodiments of the present application.
[0093] Among them, the operator node is the node corresponding to the operator in the neural network. Each operator corresponds to an operator node. There are the same number of operator nodes as the number of computing units in the neural network.
[0094] For a certain operator node, the corresponding attribute data is device support information, which is used to indicate whether the operator node supports operations in acceleration devices. If the operator corresponding to a certain operator node supports operations in acceleration devices, the device support information is support for acceleration devices. For example, the operator corresponding to the operator node can be operated in DSP, GPU or NPU. If the operator corresponding to a certain operator node does not support operations in acceleration devices, the device support information is not support for acceleration devices. For example, the operator corresponding to the operator node can be operated in CPU (Central Processing Unit).
[0095] Among them, the reference operator node is an operator node that is not supported for operation in the acceleration device. Specifically, the reference operator node in the neural network operator association graph can be determined based on the device support information. And, in this step, all reference operator nodes in the neural network operator association graph that are not supported for operation in the acceleration device are determined. Specifically, a set of unsupported acceleration nodes can be created, and all operator nodes in the neural network operator association graph are traversed. When the device support information of the operator node is that the acceleration device is not supported, the operator node is used as a reference operator node and added to the set of unsupported acceleration nodes. When determining the reference operator node, by creating a set of unsupported acceleration nodes, it is possible to quickly read the reference operator node later.
[0096] In a possible implementation, the server may search for the device support information corresponding to each operator node from a device support information data table in a database, or the server may obtain the device support information corresponding to each operator node from a service provider that provides data services.
[0097] Step 202: Determine a first connection state between an operator node to be divided and a reference operator node in a neural network operator association graph, divide the operator node to be divided according to the first connection state and device support information, and obtain a target operator node set that supports operations in an acceleration device.
[0098] Among them, the operator node to be divided is the operator node that needs to be divided in the neural network operator association diagram, and the first connection state is used to indicate whether there is a connection relationship between the operator node to be divided and the reference operator node, that is, the data flow relationship between the operator node to be divided and the reference operator node. For example, if the operation result output by the operator node to be divided is the input of the reference operator node, or the operation result output by the reference operator node is the input of the operator node to be divided, then there is a connection relationship between the operator node to be divided and the reference operator node. At this time, the first connection state can be that the operator node to be divided is connected to the reference operator node. Otherwise, there is no connection relationship between the operator node to be divided and the reference operator node. At this time, the first connection state can be that the operator node to be divided is not connected to the reference operator node.
[0099] In a possible implementation, the first connection state can be represented by a connection matrix, which is used to indicate whether there is a connection path between two operator nodes. For example, for any two operator nodes A and operator node B, if there is a path from operator node A to operator node B, the connection matrix L[A][B]=true, otherwise the connection matrix L[A][B]=false. In addition, since the neural network operator association graph is a directed acyclic graph, the connection matrix has directionality. If there is a path from operator node A to operator node B, the connection matrix L[A][B]=true, and L[B][A]=false.
[0100] Among them, the target operator node set is used to store the operator nodes that support operations in the acceleration device, and in any operator node sequence of the target operator node set (the operator node sequence is an ordered linear sequence obtained by sorting a directed acyclic graph according to the node sorting, and the operator node sequence can represent the order of each operator node during operation), for the operator nodes other than the operator nodes at the two ends, if the operator nodes that the input depends on can be in the target operator node set as much as possible (that is, not outside the target operator node set), then when the target operator node set is sent to the acceleration device for operation, there is no need to switch the device, so that the operator nodes in the target operator node set can be smoothly executed. In other words, assuming that G = (V, E) is a neural network operator association graph, {Sp = {Vp1, ..., Vpn}, ...} is the target operator node set that is finally handed over to the acceleration device, and all of Sp are operator nodes that support operations in the acceleration device. Then for any two operator nodes Vpi, Vpj in Sp, if there exists a set of paths {E1, V1, E2, V2, ..., Vn-1, En}∈G from Vpi to Vpj, then {V1, V2, ..., Vn-1}∈Sp, E1 to En represents the interconnected paths between the two operator nodes.
[0101] Based on this, when the operator node to be divided is divided according to the first connection state and the device support information to obtain the target operator node set that supports operation in the acceleration device, specifically, when the first connection state is not connected and the device support information indicates that the operator node to be divided supports operation in the acceleration device, the operator node to be divided is added to the target operator node set, wherein, since the operator node to be divided supports operation in the acceleration device and the first connection state is not connected, it indicates that the operator node to be divided will not be connected to an illegal path, wherein the illegal path is a path connected to the reference operator node. Assuming that an illegal path is connected between the operator node to be divided and the operator nodes in the target operator node set, if the operator node to be divided is added to the target operator node set, and the target operator node set is sent to the target device for operation, due to the existence of the illegal path, it is necessary to switch to the CPU to process the operator node corresponding to the illegal path during the operation process, thereby generating the cost of device switching.
[0102] Therefore, when the operator node to be divided is added to the target operator node set, no illegal path will be connected between the operator node to be divided and the operator nodes in the target operator node set, and the operator nodes on which the operator node to be divided input depends can be included in the target operator node set as much as possible. In the process of sending the target operator node set to the target device for calculation, there is no need to switch the device.
[0103] Step 203: Use the target operator node set as the reference operator node to update the neural network operator association graph, and again divide the operator nodes to be divided in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, thereby obtaining multiple target operator node sets.
[0104] Among them, the target operator node set is divided into multiple rounds. Every time a target operator node set is obtained, the target operator node set is used as a reference operator node to update the neural network operator association graph. The number of operator nodes in the updated neural network operator association graph will be less than the number of operator nodes in the neural network operator association graph before the update.
[0105] For example, refer to Figure 3 , Figure 3An optional update schematic diagram of a neural network operator association graph provided in an embodiment of the present application, the neural network operator association graph includes operator node A to operator node M, operator node G is an operator node that does not support an acceleration device, after a target operator node set is obtained through step 202, the target operator node set includes operator node A to operator node E, then operator node A to operator node E are merged into operator node A', and then an updated neural network operator association graph is obtained, then, based on the updated neural network operator association graph, the operator nodes in the updated neural network operator association graph are new operator nodes to be divided, and the first connection state between the operator node to be divided and the reference operator node in the updated neural network operator association graph is re-determined, and the operator node to be divided is divided again according to the first connection state and the device support information to obtain the next target operator node set, and the iterative processing is repeated until the neural network operator association graph no longer changes, and multiple target operator node sets can be obtained, see Figure 3 In the example shown, what is finally obtained may be a target operator node set consisting of operator node A to operator node E, and a target operator node set consisting of operator node I to operator node M.
[0106] It is understandable that the number of the target operator node set finally obtained is determined according to the specific structure of the neural network operator association graph. Figure 3 It is only used for illustrative purposes and is not intended to be limiting in the embodiments of the present application.
[0107] By taking the target operator node set as a new operator node to update the neural network operator association graph, the number of operator nodes to be processed can be effectively reduced in the next round of partitioning, thereby significantly improving the partitioning efficiency of the neural network operator association graph.
[0108] Moreover, since the embodiment of the present application divides the operator nodes to be divided through the first connection state between the operator nodes to be divided and the reference operator nodes, by taking the target operator node set as the reference operator node, it is possible to provide a reliable loop iteration basis for dividing the operator nodes to be divided according to the first connection state.
[0109] Step 204: Store the association relationship between the target operator node set and the target device.
[0110] The association relationship between the target operator node set and the target device is used to determine the target device for performing operations on the target operator node set when a neural network operation request is received. Since the operator nodes in the target operator node set are all operator nodes that support operations in acceleration devices, the target device for performing operations on the target operator node set is an acceleration device, such as a DSP, GPU, or NPU.
[0111] In addition, in addition to the target operator node set, the association relationship between the unsupported acceleration node set and the target device is also stored. Since the operator nodes in the unsupported acceleration node set are all operator nodes that are not supported to operate in the acceleration device, the target device for operating on the unsupported acceleration node set can be a CPU or other device.
[0112] For example, assuming that the neural network operator association graph can eventually be divided into target operator node set one and target operator node set two, the stored association relationships can be "[target operator node set one, GPU]", "[target operator node set two, GPU]", "[unsupported acceleration node set, CPU]".
[0113] By obtaining the device support information of each operator node in the neural network operator association graph, determining the reference operator node that does not support operation in the acceleration device according to the device support information, determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, dividing the operator node to be divided according to the first connection state and the device support information, and obtaining a target operator node set that supports operation in the acceleration device. Since the reference operator node does not support operation in the acceleration device, the first connection state can be used to determine whether there may be an illegal path connected between the operator node to be divided and other operator nodes in the target operator node set, and the operator nodes that the operator node to be divided input depends on are made in the target operator node set as much as possible, which effectively improves the universality of operator division and thus improves the accuracy of operator division. In addition, by updating the neural network operator association graph by using the target operator node set as the reference operator node, it is convenient to obtain multiple target operator node sets when the operator nodes to be divided in the updated neural network operator association graph are divided again according to the first connection state. In addition, by determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, compared with the method of traversing and exploring all paths of the operator node to be divided, it can effectively reduce the complexity and improve the efficiency of operator division. On this basis, the association relationship between the target operator node set and the target device is further stored. When a neural network operation request is received later, the target device for operating the target operator node set can be accurately determined based on the association relationship, which more effectively avoids dividing adjacent operator nodes into different hardware devices for operation, thereby improving the running speed of the neural network model.
[0114] In one possible implementation, when determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, the first node depth of the operator node to be divided in the neural network operator association graph and the second node depth of the divided operator node adjacent to the operator node to be divided can be obtained, and the size relationship between the second node depth and the first node depth can be compared to obtain a comparison result, and the first connection state between the operator node to be divided and the reference operator node can be determined according to the comparison result.
[0115] Among them, the node depth is used to indicate the distance between the operator node and the operator node that first receives the data input in the neural network operator association graph. The node depth can be determined based on the operator node dependency information. The operator node dependency information refers to the dependency information corresponding to the operator node. The dependency information refers to the information of other operator nodes that the operator node depends on during operation, that is, the current operator node needs to rely on the operation results of other operator nodes during operation. The other operator nodes can be zero, that is, the current operator node does not need to rely on the operation results of other operator nodes during operation. For example, the current operator node can be the operator node that first receives the data input in the neural network operator association graph. The other operator nodes can also be one or more, that is, the current operator node needs to rely on the operation results of one or more operator nodes during operation.
[0116] In a possible implementation, the first node depth of the operator to be divided and the second node depth of the divided operator node can be determined according to the node sorting and the operator node dependency information, wherein the operator nodes to be divided can be determined in sequence according to the order of the operator node sequence, and the operator nodes on which the operator to be divided depends can be determined using the dependency information of the operator nodes to be divided, and the first node depth can be calculated according to the node depth of the operator nodes on which the operator nodes to be divided depend, and the second node depth can be obtained in the same way. By determining the first node depth of the operator node to be divided and the second node depth of the divided operator node according to the node sorting and the operator node dependency information, the accuracy of the first node depth and the second node depth can be effectively improved.
[0117] Among them, when the same operator node is in different operator node sequences, the node depth of the operator node will be different. At this time, the maximum node depth corresponding to the operator node can be used as the node depth of the operator node. Specifically, for an operator node Vx that does not depend on other nodes (that is, a node that accepts external input), its node depth is recorded as Depth(Vx)=0. For other nodes Vq, the node set that Vq depends on is recorded as Dep={V0,…,Vn-1}, and its node depth is recorded as Depth(Vq)=max(Depth(V0),…,Depth(Vn-1))+1.
[0118] For example, refer to Figure 4 , Figure 4 A schematic diagram of an optional principle of node depth determination provided in an embodiment of the present application, wherein: Figure 4 The example shown is an operator node sequence consisting of operator node A, operator node B, and operator node C. The node depth of operator node A is 0, the node depth of operator node B is 1, and the node depth of operator node C is 2.
[0119] Among them, the divided operator node belongs to the target operator node set, that is, the divided operator node has been divided into the target operator node set. For one of the target operator sets, multiple rounds of division are also required. Based on this, when obtaining the first node depth of the operator node to be divided in the neural network operator association graph, and the second node depth of the divided operator node adjacent to the operator node to be divided, the node sorting of the neural network operator association graph can be obtained, and the neural network operator association graph is traversed according to the node sorting. The first operator node that supports calculations in the acceleration device is added to the target operator node set as a divided operator node, and the second node depth of the divided operator node is obtained. The operator node adjacent to the divided operator node is used as the operator node to be divided, and the first node depth of the operator node to be divided is obtained.
[0120] In other words, the current operator node to be divided can also be determined based on the divided operator nodes in the target operator node set. At the beginning, an empty target operator node set can be created, and the first operator node that supports operation in the acceleration device is added to the target operator node set as a divided operator node according to the node sorting.
[0121] Furthermore, when the first operator node that supports operations in an acceleration device is added to the target operator node set as a divided operator node, the historical division information of the first operator node that supports operations in an acceleration device can be obtained, wherein the historical division information is used to indicate whether the operator node has been divided. For example, historical division information VisitTable can be created. For one of the operator nodes i, VisitTable[i]=true indicates that the operator node has been divided, and VisitTable[i]=false indicates that the operator node has not been divided.
[0122] When the historical partitioning information indicates that the first operator node that supports operations in the acceleration device has not been partitioned, the first operator node that supports operations in the acceleration device is added to the target operator node set as a partitioned operator node. At the same time, when the operator node to be partitioned is partitioned according to the first connection state and the device support information, the operator node to be partitioned can be further partitioned according to the first connection state, the device support information and the historical partitioning information. When the first connection state is not connected, and the operator node to be partitioned supports operations in the acceleration device, and the operator node to be partitioned has not been partitioned, the operator node to be partitioned is added to the target operator node set.
[0123] By introducing historical partitioning information, we can avoid repeated partitioning of operator nodes and improve the partitioning efficiency of the neural network operator association graph.
[0124] For example, refer to Figure 5 , Figure 5 A schematic diagram of an optional partitioning process is provided for an embodiment of the present application, wherein a neural network operator association diagram includes operator node A, operator node B, and operator node C, all of which support operations in an acceleration device. Operator node A, operator node B, and operator node C, in sequence, form an operator node sequence. After creating an empty target operator node set, operator node A is determined to be the first operator node that supports operations in an acceleration device and has not been partitioned based on the node sorting, then operator node A is added to the target operator node set as a partitioned operator node. At this time, the operator node adjacent to operator node A is determined to be operator node B, then operator node B is the operator node to be partitioned, and the second node depth of operator node A (0 in this example) is obtained, as well as the first node depth of operator node B (1 in this example).
[0125] Next, if the current operator node to be divided is added to the target operator node set, and the target operator node set includes the first operator node that supports operation in the acceleration device and the current operator node to be divided, then in the next round, the first operator node that supports operation in the acceleration device and the operator node to be divided that was historically divided into the target operator node set are both taken as divided operator nodes, and then the operator nodes adjacent to the divided operator nodes are taken as the operator nodes to be divided, and the second node depth of the divided operator node and the first node depth of the operator node to be divided are obtained. It can be understood that the historical division information can also be used for judgment at this time.
[0126] For example, take over Figure 5In the example shown, if operator node B is added to the target operator node set, the operator nodes adjacent to operator node B are operator node A and operator node C. Since operator node A has been divided, operator node A can be ignored. Operator node C is the operator node to be divided, and the second node depth of operator node B (1 in this example) and the first node depth of operator node C (2 in this example) are obtained. Operator node C is then added to the target operator node set.
[0127] Since the first connection state between the operator node to be divided and the reference operator node is directional, by comparing the size relationship between the second node depth and the first node depth and then determining the first connection state based on the comparison result, the accuracy and reliability of the first connection state can be effectively improved.
[0128] Specifically, when determining the first connection state between the operator node to be divided and the reference operator node according to the comparison result, the first path direction between the operator node to be divided and the reference operator node can be determined according to the comparison result, and the first connection state between the operator node to be divided and the reference operator node can be determined according to the first path direction.
[0129] Among them, the path direction is used to indicate the connection direction of the path between any two operator nodes. Since the first node depth and the second node depth are determined based on the operator node dependency information, the positional relationship between the operator node to be divided and the divided operator node can be determined by comparing the size relationship between the first node depth and the second node depth, and then the first path direction between the operator node to be divided and the reference operator node can be determined.
[0130] The first path direction includes two situations, one is from the reference operator node to the operator node to be divided, that is, the output of the reference operator node is used as the input of the operator node to be divided, and the other is from the operator node to be divided to the reference operator node, that is, the output of the operator node to be divided is used as the input of the reference operator node. Based on this, when determining the first path direction between the operator node to be divided and the reference operator node according to the comparison result, the following two situations can be specifically included:
[0131] When the comparison result is that the second node depth is less than the first node depth, it indicates that the operator node to be divided is the successor node of the divided operator node. At this time, it can be determined that the first path direction between the operator node to be divided and the reference operator node is from the reference operator node to the operator node to be divided.
[0132] Specifically, since the operator node to be divided is the successor node of the divided operator node, when the first connection state of the first path direction from the reference operator node to the operator node to be divided is not connected (that is, the data is input from the operator node to be divided at this time), it indicates that there can be no path passing through the reference operator node between the divided operator node and the operator node to be divided. Therefore, the first connection state corresponding to the comparison result can be quickly determined through the first path direction from the reference operator node to the operator node to be divided, so as to judge whether the characteristics of the operator nodes in the target operator node set can be met after the operator node to be divided is added to the target operator node set.
[0133] When the comparison result is that the second node depth is greater than the first node depth, it indicates that the operator node to be divided is the predecessor node of the divided operator node. At this time, it can be determined that the first path direction between the operator node to be divided and the reference operator node is from the operator node to be divided to the reference operator node.
[0134] Specifically, since the operator node to be divided is the predecessor node of the divided operator node, when the first connection state of the first path direction from the operator node to be divided to the reference operator node is not connected (that is, data is output from the operator node to be divided at this time), it indicates that there can be no path passing through the reference operator node between the divided operator node and the operator node to be divided. Therefore, the first connection state corresponding to the comparison result can be quickly determined through the first path direction from the reference operator node to the operator node to be divided, so as to judge whether the characteristics of the operator nodes in the aforementioned target operator node set can be met after the operator node to be divided is added to the target operator node set.
[0135] For example, refer to Figure 6 , Figure 6An optional first path direction determination schematic diagram provided for an embodiment of the present application, wherein operator node A is a divided operator node in a target operator node set, operator node B is an operator node to be divided, operator node C and operator node D are reference operator nodes, and when operator node B is a successor node of operator node A, it is necessary to confirm whether the first path directions from operator node C and operator node D to operator node B are connected respectively. Once the first path directions from operator node C and operator node D to operator node B are not connected, it indicates that after operator node B is added to the target operator node set, operator node There can be no path between A and operator node B that passes through the reference operator node; and when operator node B is the predecessor node of operator node A, it is necessary to confirm whether the first path directions from operator node B to operator node C and operator node D are connected respectively. Once the first path direction from operator node B to operator node C and the first path direction from operator node B to operator node D are not connected, it means that after operator node B is added to the target operator node set, there can be no path between operator node A and operator node B that passes through the reference operator node, otherwise operator node B will not be added to the target operator node set.
[0136] In one possible implementation, when the first connection state is connected, the operator node to be divided is not directly not added to the target operator node set, but the second connection state between the divided operator node and the reference operator node is determined based on the comparison result. When the second connection state is not connected and the device support information indicates that the operator node to be divided supports calculations in the acceleration device, the operator node to be divided is added to the target operator node set.
[0137] Among them, the second connection state between the divided operator node and the reference operator node is determined according to the comparison result. Specifically, the second path direction between the divided operator node and the reference operator node can be determined according to the comparison result, and the second connection state between the divided operator node and the reference operator node is determined according to the second path direction.
[0138] Similarly, since the first node depth and the second node depth are determined based on the operator node dependency information, the positional relationship between the operator node to be divided and the divided operator node can be determined by comparing the size relationship between the first node depth and the second node depth, thereby determining the second path direction between the divided operator node and the reference operator node.
[0139] The second path direction also includes two cases, one is from the reference operator node to the divided operator node, that is, the output of the reference operator node is used as the input of the divided operator node, and the other is from the divided operator node to the reference operator node, that is, the output of the divided operator node is used as the input of the reference operator node. Based on this, when determining the second path direction between the divided operator node and the reference operator node according to the comparison result, the following two cases can be specifically included:
[0140] When the comparison result is that the second node depth is less than the first node depth, it indicates that the operator node to be divided is the successor node of the divided operator node. At this time, it can be determined that the second path direction between the divided operator node and the reference operator node is from the divided operator node to the reference operator node.
[0141] Specifically, since the operator node to be divided is the successor node of the divided operator node, when the first connection state is connected, it indicates that there may be a path passing through the reference operator node between the divided operator node and the operator node to be divided. At this time, if the second connection state of the second path direction from the divided operator node to the reference operator node is unconnected, it indicates that there cannot be a path passing through the reference operator node between the divided operator node and the operator node to be divided. Therefore, the second connection state corresponding to the comparison result can be further determined quickly through the second path direction to determine whether the operator node to be divided can meet the characteristics of the operator nodes in the target operator node set after being added to the target operator node set.
[0142] When the comparison result is that the second node depth is greater than the first node depth, it indicates that the operator node to be divided is the predecessor node of the divided operator node. At this time, it can be determined that the second path direction between the divided operator node and the reference operator node is from the reference operator node to the divided operator node.
[0143] Specifically, since the operator node to be divided is the predecessor node of the divided operator node, when the first connection state is connected, it indicates that there may be a path passing through the reference operator node between the divided operator node and the operator node to be divided. At this time, if the second connection state of the second path direction from the reference operator node to the divided operator node is unconnected, it indicates that there cannot be a path passing through the reference operator node between the divided operator node and the operator node to be divided. Therefore, the second connection state corresponding to the comparison result can be further determined quickly through the second path direction to determine whether the operator node to be divided can meet the characteristics of the operator nodes in the target operator node set after being added to the target operator node set.
[0144] For example, refer to Figure 7 , Figure 7A schematic diagram for determining an optional second path direction is provided for an embodiment of the present application, wherein operator node A is a divided operator node in a target operator node set, operator node B is an operator node to be divided, operator node C and operator node D are reference operator nodes, and when operator node B is a successor node of operator node A, it is necessary to confirm whether the first path directions from operator node C and operator node D to operator node B are connected respectively. If the first path directions from operator node C and operator node D to operator node B are both connected, it indicates that after operator node B is added to the target operator node set, there may be a path between operator node A and operator node B that passes through the reference operator node. At this time, it is further confirmed whether the second path direction from operator node A to operator node C and operator node D is connected. If the second path directions from operator node A to operator node C and operator node D are not connected, it indicates that operator node B is added to the target operator node set. Afterwards, there can be no path between operator node A and operator node B that passes through the reference operator node; and when operator node B is the predecessor node of operator node A, it is necessary to confirm whether the first path direction from operator node B to operator node C and operator node D is connected. If the first path directions from operator node B to operator node C and operator node D are connected, it indicates that after operator node B is added to the target operator node set, there may be a path between operator node A and operator node B that passes through the reference operator node. At this time, it is further confirmed whether the second path direction from operator node C and operator node D to operator node A is connected. If the second path directions from operator node C and operator node D to operator node A are not connected, it indicates that after operator node B is added to the target operator node set, there can be no path between operator node A and operator node B that passes through the reference operator node, otherwise operator node B will not be added to the target operator node set.
[0145] It can be seen that in the embodiment of the present application, for a combination of a divided operator node and an operator node to be divided, it is only necessary to judge the connection status twice (the first connection status and the second connection status) at most to divide the operator node to be divided, thereby significantly reducing the complexity of dividing the operator node to be divided and improving the efficiency of dividing the operator node to be divided.
[0146] In one possible implementation, when determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, the resource occupancy parameter when processing the neural network operator association graph can be specifically obtained. When the size relationship between the resource occupancy parameter and the preset candidate parameter threshold meets the preset condition, the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph is determined.
[0147] Among them, the resource occupancy parameter is used to indicate the information of the processing device resource occupancy when processing the neural network operator association graph. The information of the processing device resource occupancy can be the information of the resources of the processing device that the neural network operator association graph needs to occupy, or it can also be the information of the resources that are currently occupied by the processing device.
[0148] For example, the resource occupancy parameter may be the number of operator nodes in a neural network operator association graph, or the data packet volume of a neural network operator association graph, or the number of processes currently running on a processing device, or the used memory space of a processing device, and so on.
[0149] The candidate parameter threshold is determined based on the specific type of the resource occupancy parameter. Different types of resource occupancy parameters correspond to different candidate parameter thresholds, and different types of resource occupancy parameters have different preset conditions. For example:
[0150] When the resource occupancy parameter is the number of operator nodes in the neural network operator association graph, the candidate parameter threshold may be the operator node number threshold. Accordingly, the preset condition may be that the number of operator nodes in the neural network operator association graph is greater than or equal to the operator node number threshold. Since the universality and accuracy of dividing the operator nodes to be divided through the first connection state are high, when the number of operator nodes in the neural network operator association graph is greater than or equal to the operator node number threshold, it indicates that the structure of the neural network operator association graph is relatively complex, and therefore it is more suitable to divide the operator nodes to be divided through the first connection state.
[0151] Similarly, when the resource occupancy parameter is the data packet volume of the neural network operator association graph, the candidate parameter threshold may be the data packet volume threshold. Accordingly, the preset condition may be that the data packet volume of the neural network operator association graph is greater than or equal to the data packet volume threshold. When the data packet volume of the neural network operator association graph is greater than or equal to the data packet volume threshold, it indicates that the structure of the neural network operator association graph is relatively complex, and therefore it is more suitable to divide the operator nodes to be divided through the first connection state.
[0152] When the resource occupancy parameter is the number of processes currently running on the processing device, the candidate parameter threshold may be a process number threshold. Accordingly, the preset condition may be that the number of processes currently running on the processing device is less than or equal to the process number threshold. When the number of processes currently running on the processing device is less than or equal to the process number threshold, it indicates that the processing device still has a large amount of idle resources. When the operator node to be divided is divided through the first connection state, the stability of the division of the operator node to be divided can be improved.
[0153] Similarly, when the resource occupancy parameter is the used memory space of the processing device, the candidate parameter threshold may be the used memory space threshold. Accordingly, the preset condition may be that the used memory space of the processing device is less than or equal to the used memory space threshold. When the used memory space of the processing device is less than or equal to the used memory space threshold, it indicates that the processing device still has a lot of free resources. When the operator node to be divided is divided through the first connection state, the stability of the division of the operator node to be divided can be improved.
[0154] In a possible implementation, different types of resource occupancy parameters can be combined and judged to improve rationality. For example, the number of operator nodes in the neural network operator association graph and the number of currently running processes can be combined to judge. When the number of operator nodes in the neural network operator association graph is greater than or equal to the operator node number threshold, and the number of currently running processes is less than or equal to the process number threshold, the operator nodes to be divided are divided according to the first connection state. It can be understood that the specific combination of different types of resource occupancy parameters can be determined according to actual conditions, and the embodiments of this application are not limited thereto.
[0155] In one possible implementation, before or after determining the first connection state between the operator node to be divided and the reference operator node, when the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, the second node depth of the divided operator node and the first node depth of the operator node to be divided are obtained, the continuity between the second node depth and the first node depth is determined, and the operator node to be divided is divided according to the continuity and device support information.
[0156] Specifically, the continuity between the second node depth and the first node depth can be determined by the difference between the second node depth and the first node depth. When the difference between the second node depth and the first node depth is 1, it indicates that the second node depth is continuous with the first node depth. For example, for operator node A and operator node B, if Depth(A)=Depth(B)±1, Depth(A) represents the first node depth of operator node A, and Depth(B) represents the second node depth of operator node B, then the first node depth of operator node A and the second node depth of operator node B are continuous. When the second node depth is continuous with the first node depth, the operator to be divided can be added to the target operator node set.
[0157] When the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset conditions, the operator nodes to be divided are divided by further introducing the continuity between the second node depth and the first node depth, which is equivalent to introducing the node depth based on the judgment of the first connection state, thereby achieving the effect of expanding the division conditions of the operator nodes to be divided, improving the diversity of the division conditions of the operator nodes to be divided, and further improving the universality of the division of the operator nodes to be divided.
[0158] In one possible implementation, before or after determining the first connection state between the operator node to be divided and the reference operator node, when the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, the first affiliation relationship between all the predecessor operator nodes of the operator node to be divided and the target operator node set can be determined, and the operator node to be divided can be divided according to the first affiliation relationship and the device support information.
[0159] Specifically, the first belonging relationship between all the predecessor operator nodes of the operator node to be divided and the target operator node set, that is, whether the predecessor operator node belongs to the target operator node set. When all the predecessor operator nodes of the operator node to be divided belong to the target operator node set, the operator to be divided can be added to the target operator node set.
[0160] Similarly, when the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset conditions, the operator node to be divided is divided by further introducing the first belonging relationship between all the predecessor operator nodes of the operator node to be divided and the target operator node set. This is equivalent to introducing the first belonging relationship based on the judgment of the first connection state, thereby achieving the effect of expanding the division conditions of the operator node to be divided, improving the diversity of the division conditions of the operator node to be divided, and further improving the universality of the division of the operator node to be divided.
[0161] In one possible implementation, before or after determining the first connection state between the operator node to be divided and the reference operator node, when the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, the second affiliation relationship between all successor operator nodes of the operator node to be divided and the target operator node set can be determined, and the operator node to be divided can be divided according to the second affiliation relationship and the device support information.
[0162] Specifically, the second belonging relationship between all successor operator nodes of the operator node to be divided and the target operator node set, that is, whether the successor operator node belongs to the target operator node set. When all successor operator nodes of the operator node to be divided belong to the target operator node set, the operator to be divided can be added to the target operator node set.
[0163] Similarly, when the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset conditions, the operator node to be divided is divided by further introducing a second belonging relationship between all successor operator nodes of the operator node to be divided and the target operator node set. This is equivalent to introducing the second belonging relationship based on the judgment of the first connection state, thereby achieving the effect of expanding the division conditions of the operator node to be divided, improving the diversity of the division conditions of the operator node to be divided, and further improving the universality of the division of the operator node to be divided.
[0164] It can be understood that the method of dividing the operator node to be divided according to the first connection state provided in the embodiment of the present application can be combined with at least one of the method of dividing the operator node to be divided according to the continuity between the second node depth and the first node depth, the method of dividing the operator node to be divided according to the first belonging relationship, and the method of dividing the operator node to be divided according to the second belonging relationship. Based on this, for the same type of resource occupancy parameter, multiple different candidate parameter thresholds can also be set. Based on this, when the size relationship between the resource occupancy parameter and the preset candidate parameter threshold meets the preset condition, the first connection state between the operator node to be divided and the reference operator node is determined. Specifically, multiple preset candidate parameter thresholds can be obtained. When the size relationship between the resource occupancy parameter and the target parameter threshold meets the preset condition, the first connection state between the operator node to be divided and the reference operator node is determined.
[0165] Among them, different candidate parameter thresholds are used to indicate different resource occupancy levels. The way of dividing the operator node to be divided according to the first connection state, the way of dividing the operator node to be divided according to the continuity between the second node depth and the first node depth, the way of dividing the operator node to be divided according to the first belonging relationship, and the way of dividing the operator node to be divided according to the second belonging relationship can correspond to different candidate parameter thresholds respectively. One of the division methods can be determined from multiple division methods according to the size relationship between the resource occupancy parameter and different candidate parameter thresholds. Exemplarily, the target parameter threshold is the candidate parameter threshold corresponding to the way of dividing the operator node to be divided according to the first connection state. When the size relationship between the resource occupancy parameter and the target parameter threshold meets the preset conditions, the way of dividing the operator node to be divided according to the first connection state is selected to improve universality and accuracy. Otherwise, the size relationship between the resource occupancy parameter and other candidate parameter thresholds is judged respectively, and then the corresponding division method is determined.
[0166] In addition, refer to Figure 8 , Figure 8An optional flowchart of a data processing method provided in an embodiment of the present application. The data processing method can be executed by a terminal, or can also be executed by a terminal and a server in cooperation. The data processing method includes but is not limited to the following steps 801 to 802.
[0167] Step 801: In response to a neural network operation request for operating a target neural network, a preset association relationship is obtained.
[0168] Step 802: According to the association relationship, each target operator node set in the target neural network is sent to the target device for calculation.
[0169] Among them, the neural network operation request can be used to initiate operation on the information to be operated, and the neural network operation request can be sent by the terminal to the server.
[0170] Among them, the association relationship is obtained through the following steps: obtaining device support information of each operator node in the neural network operator association graph, determining the reference operator node that does not support operation in the acceleration device according to the device support information, determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, dividing the operator node to be divided according to the first connection state and the device support information, obtaining a set of target operator nodes that support operation in the acceleration device, updating the neural network operator association graph with the target operator node set as the reference operator node, and again dividing the operator nodes to be divided in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, obtaining multiple target operator node sets, and storing the association relationship between the target operator node sets and the target devices.
[0171] In a possible implementation, the information to be operated may be text information, and accordingly, the neural network operator association graph may be a text processing model, such as a text recognition model, a text classification model, or a text prediction model, etc. After receiving the neural network operation request, the server may determine the target device for operating each target operator node set in the text processing model according to the association relationship, and then send the target operator node set to the target device for operation, while the operator node set that does not support operation on the acceleration device is sent to the CPU for operation, and finally obtains the text operation result corresponding to the text information.
[0172] In a possible implementation, the information to be calculated may be image information, and accordingly, the neural network operator association graph may be an image processing model, such as an image recognition model, an image classification model, or an image prediction model, etc. After receiving the neural network operation request, the server may determine the target device for calculating each target operator node set in the image processing model according to the association relationship, and then send the target operator node set to the target device for calculation, while the operator node set that does not support calculation on the acceleration device is sent to the CPU for calculation, and finally obtains the image calculation result corresponding to the image information.
[0173] In a possible implementation, the information to be calculated may be voice information, and accordingly, the neural network operator association graph may be a voice processing model, such as a voice recognition model, a voice classification model, or a voice prediction model, etc. After receiving the neural network operation request, the server may determine the target device for calculating each target operator node set in the voice processing model according to the association relationship, and then send the target operator node set to the target device for calculation, while the operator node set that does not support calculation on the acceleration device is sent to the CPU for calculation, and finally obtains the voice calculation result corresponding to the voice information.
[0174] Figure 8 The data processing method shown is similar to Figure 2The graph processing method shown is based on the same inventive concept, by obtaining the device support information of each operator node in the neural network operator association graph, determining the reference operator node that does not support operation in the acceleration device according to the device support information, determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, dividing the operator node to be divided according to the first connection state and the device support information, and obtaining a target operator node set that supports operation in the acceleration device. Since the reference operator node does not support operation in the acceleration device, the first connection state can be used to determine whether there may be an illegal path connected between the operator node to be divided and other operator nodes in the target operator node set, so that the operator nodes that the operator node to be divided input depends on are in the target operator node set as much as possible, which effectively improves the universality of the operator division, and thus improves the accuracy of the operator division. In addition, by updating the neural network operator association graph by using the target operator node set as the reference operator node, it is convenient to obtain multiple target operator node sets when the operator nodes to be divided in the updated neural network operator association graph are divided again according to the first connection state. In addition, by determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, compared with the method of traversing and exploring all paths of the operator node to be divided, it can effectively reduce the complexity and improve the efficiency of operator division. On this basis, the association relationship between the target operator node set and the target device is further stored. When a neural network operation request is received later, the target device for operating the target operator node set can be accurately determined based on the association relationship, which more effectively avoids dividing adjacent operator nodes into different hardware devices for operation, thereby improving the running speed of the neural network model.
[0175] The principle of partitioning the operator nodes to be partitioned provided by the embodiments of the present application is fully described below.
[0176] Reference Fig. 9 , Fig. 9 A detailed flow chart of partitioning the operator nodes to be partitioned provided in an embodiment of the present application specifically includes the following steps 901 to 907.
[0177] Step 901: Calculate the node order of the neural network operator association graph;
[0178] Step 902: traverse all operator nodes, and add the operator nodes Zk that do not support operation on the acceleration device to the InVaild set;
[0179] Step 903: When the InVaild set is empty, the entire neural network operator association graph is sent to the acceleration device for execution;
[0180] Step 904: Calculate the connection matrix L between any two operator nodes, calculate the node depth Depth of each operator node according to the node sorting, and initialize a partition record VisitTable;
[0181] Step 905: traverse the neural network operator association graph according to the node order, take the first operator node Vi that is not in the InVaild set and VisitTable[Vi]=false as the starting node, initialize a set S, and add the operator node Vi to the set S;
[0182] Step 906: Obtain all operator nodes Dj adjacent to the operator nodes Si in the set S, and make a judgment on each operator node Dj;
[0183] Specifically, in step 906:
[0184] If the operator node Dj has not been divided and is not in the InVaild set, the following judgment is made:
[0185] When the node depth of operator node Dj is greater than the node depth of operator node Si (i.e. Dj is the successor node of Si), if L[Zk][Dj]=false, Dj is added to set S; otherwise, L[Si][Zk] is further judged. If L[Zk][Dj]=true and L[Si][Zk]=false, Dj is added to set S;
[0186] When the node depth of operator node Dj is less than the node depth of operator node Si (i.e. Dj is the predecessor node of Si), if L[Dj][Zk]=false, Dj is added to set S; otherwise, L[Zk][Si] is further judged. If L[Dj][Zk]=true and L[Zk][Si]=false, Dj is added to set S.
[0187] Mark the VisitTable of the operator node Dj added to S as true;
[0188] Jump to step 906 again until the set S does not change any more;
[0189] Use the set S as an operator node Zk to update the neural network operator association graph;
[0190] Step 907: Re-jump to step 901 until the entire neural network operator association graph no longer changes.
[0191] Reference Fig.10 , Fig.10 Another detailed flow chart of dividing the operator nodes to be divided provided in an embodiment of the present application specifically includes the following steps 1001 to 1007.
[0192] Step 1001: Calculate the node order of the neural network operator association graph;
[0193] Step 1002: traverse all operator nodes, and add operator nodes Zk that do not support operation on the acceleration device to the InVaild set;
[0194] Step 1003: When the InVaild set is empty, the entire neural network operator association graph is sent to the acceleration device for execution;
[0195] Step 1004: Calculate the connection matrix L between any two operator nodes, calculate the node depth Depth of each operator node according to the node sorting, and initialize a partition record VisitTable;
[0196] Step 1005: traverse the neural network operator association graph according to the node order, take the first operator node Vi that is not in the InVaild set and VisitTable[Vi]=false as the starting node, initialize a set S, and add the operator node Vi to the set S;
[0197] Step 1006: Obtain all operator nodes Dj adjacent to the operator nodes Si in the set S, and make a judgment on each operator node Dj;
[0198] Specifically, in step 1006:
[0199] If the operator node Dj has not been divided and is not in the InVaild set, the following modes are judged, and Dj can be added to the set S if any of the following modes is met:
[0200] ① If Depth[Si]=Depth[Dj]±1, add Dj to the set S;
[0201] ② If all the operator nodes that Dj input depends on are in the set S, then Dj is added to the set S;
[0202] ③ If all the operator nodes whose input depends on Dj are in the set S, Dj is added to the set S;
[0203] ④ When the node depth of operator node Dj is greater than the node depth of operator node Si (that is, Dj is the successor node of Si), if L[Zk][Dj]=false, Dj is added to set S; otherwise, further judge L[Si][Zk], if L[Zk][Dj]=true and L[Si][Zk]=false, Dj is added to set S;
[0204] When the node depth of operator node Dj is less than the node depth of operator node Si (i.e. Dj is the predecessor node of Si), if L[Dj][Zk]=false, Dj is added to set S; otherwise, L[Zk][Si] is further judged. If L[Dj][Zk]=true and L[Zk][Si]=false, Dj is added to set S.
[0205] Mark the VisitTable of the operator node Dj added to S as true;
[0206] Jump back to step 1006 until the set S does not change any more;
[0207] Use the set S as an operator node Zk to update the neural network operator association graph;
[0208] Step 1007: Re-jump to step 1001 until the entire neural network operator association graph no longer changes.
[0209] In addition, in addition to judging from mode ① to mode ④, a resource occupancy parameter may be further introduced, and one of the modes from mode ① to mode ④ may be selected for judgment according to the resource occupancy parameter.
[0210] The following is an actual example to illustrate the principle of dividing the operator nodes to be divided provided by the embodiment of the present application.
[0211] Reference Fig.11 , Fig.11 A schematic diagram of an optional neural network operator association graph partitioning process provided for an embodiment of the present application. In this example, the neural network operator association graph includes operator node A, operator node B, operator node C, operator node D, operator node E, operator node F, operator node G and operator node H, wherein operator node C, operator node F and operator node H are operator nodes that do not support operations in acceleration devices (indicated by dotted lines), and the remaining operator nodes are operator nodes that support operations in acceleration devices (indicated by solid lines). The node depth of operator node A and operator node B is 0, the node depth of operator node C, operator node D, and operator node E is 1, the node depth of operator node F is 2, the node depth of operator node G is 3, and the node depth of operator node H is 4.
[0212] Create a set of unsupported acceleration nodes, which includes operator node C, operator node F, and operator node H.
[0213] When dividing the neural network operator association graph, start with operator node A or operator node B according to the node order. In this example, start with operator node A. Since operator node A supports calculations in the acceleration device and operator node A has not been divided, operator node A is added to the target operator node set.
[0214] Next, the target operator node set includes operator node A, so the preceding node and the succeeding node of operator node A are determined, which are operator node C in this example;
[0215] For operator node C, since operator node C does not support computing in the acceleration device, operator node C is not added to the target operator node set, and the historical partitioning information of operator node A is marked as partitioned;
[0216] At this time, the target operator node set no longer changes, so operator node A is used as a target operator node set alone, and updates the neural network operator association graph as operator node A' that does not support operation in the acceleration device;
[0217] In the updated neural network operator association graph, since operator node A' has been divided, it is determined that operator node B is to be processed according to the node sorting. Since operator node B supports operation in the acceleration device and operator node B has not been divided, operator node B is added to the target operator node set.
[0218] Next, the target operator node set includes operator node B, so the preceding node and the succeeding node of operator node B are determined, which are operator node D and operator node E in this example.
[0219] For operator node D, since operator node D supports computing in the acceleration device and operator node D is not divided, the relationship between the node depths of operator node D and operator node B is further determined. Since the node depths of operator node D and operator node B are continuous, operator node D is added to the target operator node set.
[0220] For operator node E, since operator node E supports computing in the acceleration device and operator node E has not been divided, the relationship between the node depths of operator node E and operator node B is further determined. Since the node depths of operator node E and operator node B are continuous, operator node E is added to the target operator node set, and the historical division information of operator node B, operator node D, and operator node E is marked as divided.
[0221] Next, the target operator node set includes operator node B, operator node D, and operator node E. For operator node B, its adjacent operator nodes are operator node D and operator node E. Since operator node D and operator node E have been divided, operator node D and operator node E are no longer processed. For operator node D, its adjacent operator nodes are operator node B and operator node G. Since operator node B has been divided, operator node B is no longer processed.
[0222] For operator node G, since operator node G supports operations in acceleration devices and operator node G is not divided, the relationship between the node depths of operator node D and operator node G is further determined. Since the node depths between operator node D and operator node G are not continuous, it is determined whether all the operator nodes that the input of operator node G depends on are in set S. Since the operator node that operator node G depends on for input is operator node F, and operator node F is not in set S, it is determined that all the operator nodes that depend on operator node G for input are in set S. Since the operator node that the input depends on operator node G is operator node H, and operator node H is not in set S, it is determined that the operator node The connection status of G and the operator nodes in the unsupported acceleration node set. Since operator node G is the successor node of operator node D, the connection status of the path direction from operator node F to operator node G, the connection status of the path direction from operator node C to operator node G, and the connection status of the path direction from operator node H to operator node G are determined. Since the connection status of the path direction from operator node F to operator node G is connected, the connection status of the path direction from operator node D to operator node F is further determined. Since the connection status of the path direction from operator node D to operator node F is not connected, the operator node G is added to the set S, and the historical partition information of the operator node G is marked as partitioned.
[0223] For operator node E, its adjacent operator nodes are operator node B and operator node G. Since operator node B and operator node G have been divided, operator node B and operator node G are no longer processed;
[0224] For operator node G, since operator node G has been divided, operator node G is no longer processed;
[0225] At this time, the target operator node set no longer changes, so operator node B, operator node D, operator node E, and operator node G are used as another target operator node set, and the neural network operator association graph is updated as operator node B' that does not support operation in the acceleration device;
[0226] At this point, the neural network operator association graph no longer changes, and the division of the neural network operator association graph is completed. It can finally be divided into the target operator node set {A}, the target operator node set {B, D, E, G} and the unsupported acceleration node set {C, F, H}. When a neural network operation request is received, the target operator node set {A} and the target operator node set {B, D, E, G} are sent to the acceleration device for calculation, and the unsupported acceleration node set {C, F, H} is sent to the CPU for calculation.
[0227] It can be seen that in the related technology, when judging whether the node depth is continuous or judging whether there is a unique dependency between the divided operator node and the operator node to be divided, for the operator node G in the above example, it is impossible to divide it into the same target operator node set with the operator node B, operator node D, and operator node E. Therefore, the present application can significantly improve the universality and accuracy of the division by introducing the connection relationship with the reference operator node to perform the division.
[0228] Moreover, the method provided in the embodiment of the present application also has significant improvements in processing complexity. Specifically, when dividing the neural network operator association graph, it is also possible to take operator node A that supports operations on the acceleration device as the starting point, and use a breadth search method to determine operator node B that supports operations on the acceleration device from its successor nodes, and then use a reverse depth exploration method starting from operator node B to find out whether there are other paths from operator node B to operator node A in addition to the path from operator node A to operator node B.
[0229] However, referring to Fig.12 , Fig.12 A schematic diagram of an optional neural network operator association graph structure provided in this application, there are n operator nodes between operator node A1 and operator node A2, there are n operator nodes between operator node A2 and operator node A3, when encountering Fig.12 When the neural network operator association graph has a large number of operator nodes and dense connections, the processing complexity will be significantly increased by combining the breadth search with the reverse depth exploration, which will greatly reduce the efficiency of dividing the neural network operator association graph. In the embodiment of the present application, at most, the operator nodes to be divided can be divided by determining the first connection state and the second connection state, thereby significantly reducing the processing complexity and being able to adapt Fig.12 This neural network operator association graph with a large number of operator nodes and dense connections also reflects that the method provided in the embodiment of the present application has relatively good universality.
[0230] It is to be understood that, although the steps in the above-mentioned various flow charts are shown in sequence according to the indication of the arrows, these steps are not necessarily performed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in the present embodiment, the execution of these steps does not have a strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above-mentioned flow charts can include a plurality of steps or a plurality of stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of the steps or stages in other steps or other steps.
[0231] Reference Fig.13 , Fig.13 This is an optional structural diagram of a graph processing device provided in an embodiment of the present application. The graph processing device 1300 includes:
[0232] The reference operator node determination module 1301 is used to obtain device support information of each operator node in the neural network operator association diagram, and determine the reference operator node that is not supported for operation in the acceleration device according to the device support information;
[0233] The first partitioning module 1302 is used to determine a first connection state between an operator node to be partitioned and a reference operator node in a neural network operator association graph, and partition the operator node to be partitioned according to the first connection state and device support information to obtain a target operator node set that supports operations in an acceleration device;
[0234] The second division module 1303 is used to update the neural network operator association graph by taking the target operator node set as the reference operator node, and again divide the operator nodes to be divided in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, thereby obtaining multiple target operator node sets;
[0235] The association relationship storage module 1304 is used to store the association relationship between the target operator node set and the target device, wherein the association relationship is used to determine the target device for performing operations on the target operator node set when a neural network operation request is received.
[0236] Furthermore, the first division module 1302 is specifically used for:
[0237] Obtaining a first node depth of an operator node to be divided in a neural network operator association graph, and a second node depth of a divided operator node adjacent to the operator node to be divided, wherein the divided operator node belongs to a target operator node set;
[0238] The magnitude relationship between the second node depth and the first node depth is compared to obtain a comparison result, and a first connection state between the operator node to be divided and the reference operator node is determined according to the comparison result.
[0239] Furthermore, the first division module 1302 is specifically used for:
[0240] Obtain the node order of the neural network operator association graph, and traverse the neural network operator association graph according to the node order;
[0241] Adding the first operator node that supports operations in the acceleration device as a divided operator node to the target operator node set, and obtaining the second node depth of the divided operator node;
[0242] An operator node adjacent to the divided operator node is used as an operator node to be divided, and a first node depth of the operator node to be divided is obtained.
[0243] Furthermore, the first division module 1302 is specifically used for:
[0244] Determine a first path direction between the operator node to be divided and the reference operator node according to the comparison result;
[0245] A first connection state between the operator node to be divided and the reference operator node is determined according to the first path direction.
[0246] Furthermore, the first division module 1302 is specifically used for:
[0247] When the comparison result is that the second node depth is less than the first node depth, determining that the first path direction between the operator node to be divided and the reference operator node is from the reference operator node to the operator node to be divided;
[0248] Alternatively, when the comparison result is that the second node depth is greater than the first node depth, it is determined that the first path direction between the operator node to be divided and the reference operator node is from the operator node to be divided to the reference operator node.
[0249] Furthermore, the first division module 1302 is specifically used for:
[0250] When the first connection state is unconnected, and the device support information indicates that the operator node to be divided supports calculation in the acceleration device, adding the operator node to be divided to the target operator node set;
[0251] Alternatively, when the first connection state is connected, the second connection state between the split operator node and the reference operator node is determined based on the comparison result; when the second connection state is disconnected and the device support information indicates that the operator node to be split supports calculations in the acceleration device, the operator node to be split is added to the target operator node set.
[0252] Furthermore, the first division module 1302 is specifically used for:
[0253] Determining a second path direction between the divided operator node and the reference operator node according to the comparison result;
[0254] A second connection state between the divided operator node and the reference operator node is determined according to the second path direction.
[0255] Furthermore, the first division module 1302 is specifically used for:
[0256] When the comparison result is that the second node depth is less than the first node depth, determining that the second path direction between the divided operator node and the reference operator node is from the divided operator node to the reference operator node;
[0257] Alternatively, when the comparison result is that the second node depth is greater than the first node depth, it is determined that the direction of the second path between the split operator node and the reference operator node is from the reference operator node to the split operator node.
[0258] Furthermore, the first division module 1302 is specifically used for:
[0259] Obtain resource usage parameters when processing the neural network operator association graph;
[0260] When the size relationship between the resource occupancy parameter and the preset candidate parameter threshold meets the preset condition, the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph is determined.
[0261] Furthermore, the first division module 1302 is further used for:
[0262] When the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, obtain the second node depth of the divided operator node and the first node depth of the operator node to be divided, determine the continuity between the second node depth and the first node depth, and divide the operator node to be divided according to the continuity and device support information;
[0263] Alternatively, when the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, determining the first belonging relationship between all the predecessor operator nodes of the operator node to be divided and the target operator node set, and dividing the operator node to be divided according to the first belonging relationship and the device support information;
[0264] Alternatively, when the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, determine the second belonging relationship between all successor operator nodes of the operator node to be divided and the target operator node set, and divide the operator node to be divided according to the second belonging relationship and device support information.
[0265] The above-mentioned graph processing device 1300 and Figure 2 The graph processing method shown is based on the same inventive concept, by obtaining the device support information of each operator node in the neural network operator association graph, determining the reference operator node that does not support operation in the acceleration device according to the device support information, determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, dividing the operator node to be divided according to the first connection state and the device support information, and obtaining a target operator node set that supports operation in the acceleration device. Since the reference operator node does not support operation in the acceleration device, the first connection state can be used to determine whether there may be an illegal path connected between the operator node to be divided and other operator nodes in the target operator node set, so that the operator nodes that the operator node to be divided input depends on are in the target operator node set as much as possible, which effectively improves the universality of the operator division, and thus improves the accuracy of the operator division. In addition, by updating the neural network operator association graph by using the target operator node set as the reference operator node, it is convenient to obtain multiple target operator node sets when the operator nodes to be divided in the updated neural network operator association graph are divided again according to the first connection state. In addition, by determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, compared with the method of traversing and exploring all paths of the operator node to be divided, it can effectively reduce the complexity and improve the efficiency of operator division. On this basis, the association relationship between the target operator node set and the target device is further stored. When a neural network operation request is received later, the target device for operating the target operator node set can be accurately determined based on the association relationship, which more effectively avoids dividing adjacent operator nodes into different hardware devices for operation, thereby improving the running speed of the neural network model.
[0266] Reference Fig.14 , Fig.14 This is an optional structural diagram of a data processing device provided in an embodiment of the present application. The data processing device 1400 includes:
[0267] The association relationship acquisition module 1401 is used to obtain a preset association relationship in response to a neural network operation request for operating a target neural network;
[0268] The operation module 1402 is used to send each target operator node set in the target neural network to the target device for operation according to the association relationship;
[0269] Among them, the association relationship is obtained through the following steps: obtaining device support information of each operator node in the neural network operator association graph, determining the reference operator node that does not support operation in the acceleration device according to the device support information, determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, dividing the operator node to be divided according to the first connection state and the device support information, obtaining a set of target operator nodes that support operation in the acceleration device, updating the neural network operator association graph with the target operator node set as the reference operator node, and again dividing the operator nodes to be divided in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, obtaining multiple target operator node sets, and storing the association relationship between the target operator node sets and the target devices.
[0270] The data processing device 1400 and Figure 8 The data processing method shown is based on the same inventive concept, by obtaining the device support information of each operator node in the neural network operator association graph, determining the reference operator node that does not support operation in the acceleration device according to the device support information, determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, dividing the operator node to be divided according to the first connection state and the device support information, and obtaining a target operator node set that supports operation in the acceleration device. Since the reference operator node does not support operation in the acceleration device, the first connection state can be used to determine whether there may be an illegal path connected between the operator node to be divided and other operator nodes in the target operator node set, and the operator nodes that the operator node to be divided input depends on are made in the target operator node set as much as possible, which effectively improves the universality of the operator division, and thus improves the accuracy of the operator division. In addition, by updating the neural network operator association graph by using the target operator node set as the reference operator node, it is convenient to obtain multiple target operator node sets when the operator nodes to be divided in the updated neural network operator association graph are divided again according to the first connection state. In addition, by determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, compared with the method of traversing and exploring all paths of the operator node to be divided, it can effectively reduce the complexity and improve the efficiency of operator division. On this basis, the association relationship between the target operator node set and the target device is further stored. When a neural network operation request is received later, the target device for operating the target operator node set can be accurately determined based on the association relationship, which more effectively avoids dividing adjacent operator nodes into different hardware devices for operation, thereby improving the running speed of the neural network model.
[0271] The electronic device for executing the above-mentioned image processing method or data processing method provided in the embodiment of the present application may be a terminal. Fig.15 , Fig.15 This is a partial structural block diagram of a terminal provided in an embodiment of the present application. The terminal includes: a camera assembly 1510, a memory 1520, an input unit 1530, a display unit 1540, a sensor 1550, an audio circuit 1560, a wireless fidelity (WiFi) module 1570, a processor 1580, and a power supply 1590. Those skilled in the art can understand that Fig.15 The terminal structure shown in the figure does not constitute a limitation on the terminal, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0272] The camera assembly 1510 can be used to capture images or videos. Optionally, the camera assembly 1510 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and the VR (Virtual Reality) shooting function or other fusion shooting functions.
[0273] The memory 1520 may be used to store software programs and modules. The processor 1580 executes various functional applications and data processing of the terminal by running the software programs and modules stored in the memory 1520 .
[0274] The input unit 1530 may be used to receive input digital or character information and generate key signal input related to the terminal's settings and function control. Specifically, the input unit 1530 may include a touch panel 1531 and other input devices 1532 .
[0275] The display unit 1540 may be used to display input information or provided information and various menus of the terminal. The display unit 1540 may include a display panel 1541 .
[0276] The audio circuit 1560 , the speaker 1561 , and the microphone 1562 may provide an audio interface.
[0277] The power source 1590 may be alternating current, direct current, a disposable battery, or a rechargeable battery.
[0278] The number of sensors 1550 may be one or more, and the one or more sensors 1550 include but are not limited to: acceleration sensors, gyroscope sensors, pressure sensors, optical sensors, etc. Among them:
[0279] The acceleration sensor can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the terminal. For example, the acceleration sensor can be used to detect the components of gravity acceleration on the three coordinate axes. The processor 1580 can control the display unit 1540 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor. The acceleration sensor can also be used for collecting game or user motion data.
[0280] The gyroscope sensor can detect the body direction and rotation angle of the terminal, and the gyroscope sensor can cooperate with the acceleration sensor to collect the user's 3D actions on the terminal. The processor 1580 can implement the following functions based on the data collected by the gyroscope sensor: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
[0281] The pressure sensor can be set in the side frame of the terminal and / or the lower layer of the display unit 1540. When the pressure sensor is set in the side frame of the terminal, the user's holding signal of the terminal can be detected, and the processor 1580 performs left and right hand recognition or shortcut operation according to the holding signal collected by the pressure sensor. When the pressure sensor is set in the lower layer of the display unit 1540, the processor 1580 controls the operability controls on the UI interface according to the user's pressure operation on the display unit 1540. The operability control includes at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0282] The optical sensor is used to collect the ambient light intensity. In one embodiment, the processor 1580 can control the display brightness of the display unit 1540 according to the ambient light intensity collected by the optical sensor. Specifically, when the ambient light intensity is high, the display brightness of the display unit 1540 is increased; when the ambient light intensity is low, the display brightness of the display unit 1540 is decreased. In another embodiment, the processor 1580 can also dynamically adjust the shooting parameters of the camera assembly 1510 according to the ambient light intensity collected by the optical sensor.
[0283] In this embodiment, the processor 1580 included in the terminal can execute the image processing method or the data processing method of the previous embodiment.
[0284] The electronic device for executing the above-mentioned graph processing method or data processing method provided in the embodiment of the present application may also be a server. Fig.16 , Fig.16This is a partial structural block diagram of a server provided in an embodiment of the present application. The server 1600 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPUs) 1622 (for example, one or more processors) and a memory 1632, and one or more storage media 1630 (for example, one or more mass storage devices) storing application programs 1642 or data 1644. Among them, the memory 1632 and the storage medium 1630 can be short-term storage or permanent storage. The program stored in the storage medium 1630 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the server 1600. Furthermore, the central processing unit 1622 can be configured to communicate with the storage medium 1630 and execute a series of instruction operations in the storage medium 1630 on the server 1600.
[0285] The server 1600 may also include one or more power supplies 1626, one or more wired or wireless network interfaces 1650, one or more input and output interfaces 1658, and / or one or more operating systems 1641, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0286] The processor in the server 1600 can be used to execute a graph processing method or a data processing method.
[0287] An embodiment of the present application also provides a computer-readable storage medium, which is used to store program code, and the program code is used to execute the graph processing method or data processing method of the aforementioned embodiments.
[0288] The embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned graph processing method or data processing method.
[0289] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0290] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0291] It should be understood that in the description of the embodiments of the present application, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood to not include the number, and above, below, within, etc. are understood to include the number.
[0292] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0293] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0294] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0295] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store program codes.
[0296] It should also be understood that the various implementations provided in the embodiments of the present application can be combined arbitrarily to achieve different technical effects.
[0297] The above is a specific description of the preferred implementation of the present application, but the present application is not limited to the above implementation mode. Technical personnel familiar with the field can also make various equivalent modifications or substitutions under the shared conditions without violating the spirit of the present application. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present application.
Claims
1. A graph processing method, It is characterized in that include: Obtaining device support information for each operator node in a neural network operator association graph, and determining reference operator nodes that are not supported for operation in an acceleration device according to the device support information; Determine a first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, divide the operator node to be divided according to the first connection state and the device support information, and obtain a target operator node set that supports operation in the acceleration device; Using the target operator node set as the reference operator node to update the neural network operator association graph, and again dividing the to-be-divided operator nodes in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, thereby obtaining a plurality of target operator node sets; An association relationship between the target operator node set and the target device is stored, wherein the association relationship is used to determine the target device for performing an operation on the target operator node set when a neural network operation request is received.
2. The graph processing method according to claim 1, It is characterized in that The determining of a first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph includes: Acquire a first node depth of an operator node to be divided in the neural network operator association graph, and a second node depth of a divided operator node adjacent to the operator node to be divided, wherein the divided operator node belongs to the target operator node set; The magnitude relationship between the second node depth and the first node depth is compared to obtain a comparison result, and a first connection state between the operator node to be divided and the reference operator node is determined according to the comparison result.
3. The graph processing method according to claim 2, It is characterized in that The obtaining of the first node depth of the operator node to be divided in the neural network operator association graph and the second node depth of the divided operator node adjacent to the operator node to be divided comprises: Obtaining a node ordering of the neural network operator association graph, and traversing the neural network operator association graph according to the node ordering; Adding a first operator node that supports operations in the acceleration device as a divided operator node to the target operator node set, and obtaining a second node depth of the divided operator node; An operator node adjacent to the divided operator node is used as an operator node to be divided, and a first node depth of the operator node to be divided is obtained.
4. The graph processing method according to claim 2, It is characterized in that The determining, according to the comparison result, a first connection state between the operator node to be divided and the reference operator node comprises: Determining a first path direction between the operator node to be divided and the reference operator node according to the comparison result; A first connection state between the to-be-divided operator node and the reference operator node is determined according to the first path direction.
5. The graph processing method according to claim 4, It is characterized in that The determining, according to the comparison result, a first path direction between the operator node to be divided and the reference operator node comprises: When the comparison result is that the second node depth is less than the first node depth, determining that the first path direction between the to-be-divided operator node and the reference operator node is from the reference operator node to the to-be-divided operator node; Alternatively, when the comparison result is that the second node depth is greater than the first node depth, it is determined that the first path direction between the to-be-divided operator node and the reference operator node is from the to-be-divided operator node to the reference operator node.
6. The graph processing method according to claim 2, It is characterized in that The step of dividing the operator node to be divided according to the first connection state and the device support information to obtain a target operator node set that supports operations in the acceleration device includes: When the first connection state is unconnected, and the device support information indicates that the operator node to be divided supports calculation in the acceleration device, adding the operator node to be divided to the target operator node set; Alternatively, when the first connection state is connected, the second connection state between the split operator node and the reference operator node is determined according to the comparison result; when the second connection state is disconnected and the device support information indicates that the operator node to be split supports calculations in the acceleration device, the operator node to be split is added to the target operator node set.
7. The graph processing method according to claim 6, It is characterized in that The determining, according to the comparison result, a second connection state between the divided operator node and the reference operator node comprises: Determining a second path direction between the divided operator node and the reference operator node according to the comparison result; A second connection state between the divided operator node and the reference operator node is determined according to the second path direction.
8. The graph processing method according to claim 7, It is characterized in that The determining, according to the comparison result, a second path direction between the divided operator node and the reference operator node comprises: When the comparison result is that the second node depth is less than the first node depth, determining that the second path direction between the divided operator node and the reference operator node is from the divided operator node to the reference operator node; Alternatively, when the comparison result is that the second node depth is greater than the first node depth, it is determined that the second path direction between the divided operator node and the reference operator node is from the reference operator node to the divided operator node.
9. The graph processing method according to any one of claims 1 to 8, It is characterized in that The determining of a first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph includes: Obtaining resource occupancy parameters when processing the neural network operator association graph; When the magnitude relationship between the resource occupancy parameter and the preset candidate parameter threshold satisfies a preset condition, a first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph is determined.
10. The graph processing method according to claim 9, It is characterized in that Before or after determining the first connection state between the to-be-divided operator node and the reference operator node, the graph processing method further includes at least one of the following: When the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, obtaining a second node depth of a divided operator node adjacent to the operator node to be divided and a first node depth of the operator node to be divided, determining the continuity between the second node depth and the first node depth, and dividing the operator node to be divided according to the continuity and the device support information; Alternatively, when the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, determining a first affiliation relationship between all preceding operator nodes of the operator node to be divided and the target operator node set, and dividing the operator node to be divided according to the first affiliation relationship and the device support information; Alternatively, when the size relationship between the resource occupancy parameter and the parameter threshold does not meet the preset condition, determine the second affiliation relationship between all successor operator nodes of the operator node to be divided and the target operator node set, and divide the operator node to be divided according to the second affiliation relationship and the device support information.
11. A data processing method, It is characterized in that include: In response to a neural network operation request for operating a target neural network, obtaining a preset association relationship; According to the association relationship, each target operator node set in the target neural network is sent to the target device for calculation; Among them, the association relationship is obtained through the following steps: obtaining device support information of each operator node in the neural network operator association graph, determining the reference operator node that does not support operation in the acceleration device according to the device support information, determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, dividing the operator node to be divided according to the first connection state and the device support information, obtaining a set of target operator nodes that support operation in the acceleration device, updating the neural network operator association graph with the target operator node set as the reference operator node, and again dividing the operator node to be divided in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, obtaining multiple sets of the target operator node, and storing the association relationship between the target operator node set and the target device.
12. A graph processing device, It is characterized in that include: A reference operator node determination module, used to obtain device support information of each operator node in the neural network operator association diagram, and determine reference operator nodes that are not supported for operation in the acceleration device according to the device support information; A first partitioning module is used to determine a first connection state between the operator node to be partitioned and the reference operator node in the neural network operator association graph, and partition the operator node to be partitioned according to the first connection state and the device support information to obtain a target operator node set that supports operation in the acceleration device; A second partitioning module is used to update the neural network operator association graph by using the target operator node set as the reference operator node, and again partition the operator nodes to be partitioned in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, thereby obtaining a plurality of target operator node sets; An association relationship storage module is used to store the association relationship between the target operator node set and the target device, wherein the association relationship is used to determine the target device that performs operations on the target operator node set when a neural network operation request is received.
13. A data processing device, It is characterized in that include: An association relationship acquisition module, used to obtain a preset association relationship in response to a neural network operation request for operating a target neural network; A computing module, used for sending each target operator node set in the target neural network to a target device for computing according to the association relationship; Among them, the association relationship is obtained through the following steps: obtaining device support information of each operator node in the neural network operator association graph, determining the reference operator node that does not support operation in the acceleration device according to the device support information, determining the first connection state between the operator node to be divided and the reference operator node in the neural network operator association graph, dividing the operator node to be divided according to the first connection state and the device support information, obtaining a set of target operator nodes that support operation in the acceleration device, updating the neural network operator association graph with the target operator node set as the reference operator node, and again dividing the operator node to be divided in the updated neural network operator association graph according to the first connection state until the neural network operator association graph no longer changes, obtaining multiple sets of the target operator node, and storing the association relationship between the target operator node set and the target device.
14. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, It is characterized in that When the processor executes the computer program, it implements the graph processing method described in any one of claims 1 to 10, or implements the data processing method described in claim 11.
15. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, it implements the graph processing method described in any one of claims 1 to 10, or implements the data processing method described in claim 11.
16. A computer program product comprising a computer program, It is characterized in that When the computer program is executed by a processor, it implements the graph processing method described in any one of claims 1 to 10, or implements the data processing method described in claim 11.
Citation Information
Patent Citations
Information processing method and terminal equipment
CN109726806A
A calculation graph node division method and device and a computer readable storage medium
CN113553287A
Neural network model deployment method and device, electronic equipment and storage medium
CN115099399A
Neural network processing method and device, neural network information processing method and device and computer equipment
CN115358379A
Hierarchical partitioning of operators
US20210158131A1
