Processing method, device, equipment and storage medium for artificial intelligence learning
By merging the tasks performed by the graphics processor, constructing a directed graph model and merging directed acyclic subgraphs, the problem of too many central processor interrupts when the computer system processes the neural network model is solved, reducing power consumption and improving efficiency. processing efficiency.
Patent Information
- Application Number
- CN202011126557.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-20
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2040-10-20
AI Technical Summary
When a computer system processes and trains a neural network model, the central processor needs to process a large number of interrupt signals, resulting in increased power consumption.
By merging the tasks executed by the graphics processor, a directed graph model is constructed, the directed acyclic subgraph is determined, and the tasks are merged to reduce the number of interrupts of the central processor.
It effectively reduces the number of interrupts that the central processor needs to handle, reduces power consumption, and improves processing efficiency.
Smart Images

Figure CN114387150B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a processing method and device, equipment and storage medium for artificial intelligence learning. Background Art
[0002] A computer system generally includes multiple processors, namely a central processing unit and a graphics processing unit. The graphics processing unit is used to reduce the burden of the central processing unit on the processing program. At present, when the computer system processes and trains a neural network model, the central processing unit often executes the tasks represented by some nodes, while the tasks represented by other nodes are executed by the graphics processing unit. After executing the tasks represented by each node, the graphics processing unit sends an interrupt signal to the central processing unit so that the central processing unit processes the interrupt. The central processing unit stores the data before the interruption through registers and program counters, and after processing the interruption, it continues to execute the tasks before the interruption through the data in the registers and the program counter. However, in this way, the central processing unit will consume a lot of power in processing the interruption. Summary of the invention
[0003] In view of this, it is necessary to provide a processing method and apparatus, device and storage medium for artificial intelligence learning, which can merge at least two tasks performed by the graphics processor to reduce the interrupts that the central processor needs to handle.
[0004] The first aspect of the present application provides a processing method for artificial intelligence learning, comprising:
[0005] Constructing a model as a directed graph including a plurality of first nodes, wherein the model includes a plurality of tasks, and the tasks represented by the plurality of first nodes are executed by a central processing unit and a graphics processing unit;
[0006] Determine a second node subgraph consisting of second nodes corresponding to the tasks executed by the graphics processor in the first node;
[0007] Determining a directed acyclic subgraph in the second node subgraph;
[0008] Tasks represented by the at least two second nodes in the directed acyclic subgraph including the at least two second nodes are merged into one task.
[0009] Preferably, constructing the model as a directed graph including a plurality of first nodes comprises:
[0010] The model is constructed as a directed graph including a plurality of first nodes according to the order of executing the tasks.
[0011] Preferably, the determining of the second node subgraph composed of the second nodes corresponding to the tasks executed by the graphics processor in the first node comprises:
[0012] Determine a second node corresponding to the task executed by the graphics processor in the first node;
[0013] The third node in the second node having the same adjacent nodes in the execution order and the adjacent nodes are grouped together to form the second node subgraph, and the execution order includes a parallel execution order and a sequential execution order.
[0014] Preferably, the determining the directed acyclic subgraph in the second node subgraph comprises:
[0015] Determining sequential nodes in the second node subgraph;
[0016] A directed acyclic subgraph is determined according to the sequential nodes.
[0017] Preferably, the tasks represented by the at least two second nodes in the directed acyclic subgraph including at least two second nodes are merged into one task, including:
[0018] The tasks represented by the at least two second nodes in the directed acyclic subgraph including at least two second nodes are merged into one task according to the processing capability of the graphics processor.
[0019] Preferably, merging the tasks represented by the at least two second nodes in the directed acyclic subgraph including at least two second nodes into one task according to the processing capability of the graphics processor comprises:
[0020] Splitting the directed acyclic subgraph including at least two second nodes into directed acyclic subgraphs according to the processing capability of the graphics processor;
[0021] Tasks represented by the at least two second nodes in the sub-directed acyclic subgraph including the at least two second nodes are merged into one task.
[0022] Preferably, the method further comprises:
[0023] transmitting the merged tasks to the graphics processor for execution;
[0024] After the graphics processor completes the merged task, an interrupt signal is sent to the central processor.
[0025] A second aspect of the present application provides a processing device for artificial intelligence learning, the device comprising:
[0026] A construction module, configured to construct the model into a directed graph including a plurality of first nodes, wherein the model includes a plurality of tasks, and the tasks represented by the plurality of first nodes are executed by a central processing unit and a graphics processing unit;
[0027] A second node subgraph determining module, configured to determine a second node subgraph consisting of second nodes corresponding to the tasks executed by the graphics processor in the first node;
[0028] A directed acyclic subgraph determining module, used to determine a directed acyclic subgraph in the second node subgraph;
[0029] The merging module is used to merge the tasks represented by the at least two second nodes in the directed acyclic subgraph including the at least two second nodes into one task.
[0030] The third aspect of the present application provides a device, comprising one or more processors and a memory, wherein the processor is used to implement the processing method for artificial intelligence learning as described in any one of the above when executing at least one instruction stored in the memory.
[0031] A fourth aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor to implement a processing method for artificial intelligence learning as described in any one of the above.
[0032] In this case, a model is constructed as a directed graph including multiple first nodes, wherein the model includes multiple tasks, wherein the tasks represented by the first nodes are executed by a central processing unit and a graphics processing unit, a second node subgraph consisting of second nodes corresponding to the tasks executed by the graphics processing unit in the first node is determined, a directed acyclic subgraph in the second node subgraph is determined, and the tasks represented by at least two second nodes in the directed acyclic subgraph including at least two second nodes are merged into one task, and the tasks executed by the graphics processing unit which are executed sequentially without turning back or looping can be merged, so as to reduce the interruptions that the central processing unit needs to handle. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0034] Figure 1 It is a block diagram of a processing device for artificial intelligence learning provided in Embodiment 1 of the present invention.
[0035] Figure 2It is a flowchart of a processing method for artificial intelligence learning provided in Embodiment 2 of the present invention.
[0036] Figure 3 is a schematic diagram of a directed graph including a plurality of first nodes.
[0037] Figure 4 yes Figure 3 The directed graph includes a schematic diagram of a second node subgraph.
[0038] Figure 5 yes Figure 3 A directed graph includes a directed acyclic subgraph.
[0039] Figure 6 yes Figure 3 Schematic diagram of the task merging represented by the nodes in the directed graph.
[0040] Figure 7 yes Figure 3 Schematic diagram of the fourth node in the directed graph of .
[0041] Figure 8 yes Figure 3 The directed graph includes a schematic diagram of a second node subgraph.
[0042] Fig. 9 It is a block diagram of a device provided in Embodiment 3 of the present invention.
[0043] The following specific implementation manner will further illustrate the present invention in conjunction with the above-mentioned drawings.
[0044] Main component symbols
[0045] Processing device 10 for artificial intelligence learning
[0046] Building Blocks 101
[0047] Second node subgraph determination module 102
[0048] Directed acyclic subgraph determination module 103
[0049] Merge Module 104
[0050] Device 9
[0051] Memory 91
[0052] Processor 92
[0053] Computer Programs 93
[0054] The following specific implementation manner will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION
[0055] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0056] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. The embodiments described are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0057] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in the specification of the present invention herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0058] Figure 1 A processing device for artificial intelligence learning provided in the first embodiment of the present invention. The processing device 10 for artificial intelligence learning includes a construction module 101, a second node subgraph determination module 102, a directed acyclic subgraph determination module 103, and a merging module 104. The construction module 101 is used to construct the model as a directed graph including multiple first nodes, and the model includes multiple tasks, and the tasks represented by the multiple first nodes are executed by the central processing unit and the graphics processing unit. The second node subgraph determination module 102 is used to determine the second node subgraph composed of the second nodes corresponding to the tasks executed by the graphics processing unit in the first node. The directed acyclic subgraph determination module 103 is used to determine the directed acyclic subgraph in the second node subgraph. The merging module 104 is used to merge the tasks represented by the at least two second nodes in the directed acyclic subgraph including at least two second nodes into one task. The specific functions of the modules 101 to 104 will refer to Figure 2 The flowchart of the processing method for artificial intelligence learning is described in detail.
[0059] Please refer to Figure 2 , Figure 2 A flowchart of a processing method for artificial intelligence learning provided in Embodiment 2 of the present invention. The processing method for artificial intelligence learning is applied to a device. The device may be any device including a central processing unit and a graphics processing unit, such as a computer system and device. The processing method for artificial intelligence learning comprises the following steps:
[0060] S201: constructing a model into a directed graph including a plurality of first nodes, wherein the model includes a plurality of tasks, and the tasks represented by the plurality of first nodes are executed by a central processing unit and a graphics processing unit.
[0061] The model is a neural network model trained based on frameworks such as TensorFlow, MXNet, Caffe, and Pytorch. The first node may be a node or an instruction. The constructing the model as a directed graph including a plurality of first nodes includes: constructing the model as a directed graph including a plurality of first nodes according to the order of executing tasks. The order of executing tasks includes parallel execution and sequential execution. For example, in Figure 3 In the example, the task represented by node C is task c, the task represented by node D is task d, and the task represented by node E is task e. Then the order of executing task c and task d is parallel execution, and the order of executing task d and task e is sequential execution. Figure 3 In the figure, the tasks represented by node A, node H and node I are executed by the central processing unit, and the tasks represented by node B, node C, node D, node E, node F and node G are executed by the graphics processing unit.
[0062] S202: Determine a second node subgraph formed by second nodes corresponding to tasks executed by the graphics processor in the first node.
[0063] In this embodiment, determining the second node subgraph formed by the second nodes corresponding to the tasks executed by the graphics processor in the first node includes:
[0064] a1: Determine a second node corresponding to the task executed by the graphics processor in the first node.
[0065] For example, in Figure 3 In the embodiment, the second nodes corresponding to the tasks executed by the graphics processor in the first node include a B node, a C node, a D node, an E node, an F node and a G node.
[0066] a2: The third node in the second node having the same adjacent nodes in the execution order and the adjacent nodes are grouped together to form the second node subgraph, and the execution order includes a parallel execution order and a sequential execution order.
[0067] For example, in Figure 3 In the example, the C node and the D node have the same adjacent node in the parallel execution order, which is the B node, the B node and the E node have the same adjacent node in the sequential execution order, which is the D node, the D node and the F node have the same adjacent node in the sequential execution order, which is the E node, and the E node and the G node have the same adjacent node in the sequential execution order, which is the F node, then the third node in the second node that has the same adjacent node in the execution order and the adjacent nodes are grouped together to form the following Figure 4 The second node subgraph is surrounded by the dashed line.
[0068] S203: Determine a directed acyclic subgraph in the second node subgraph.
[0069] In this embodiment, determining the directed acyclic subgraph in the second node subgraph includes:
[0070] b1: Determine the sequential nodes in the second node subgraph.
[0071] For example, in Figure 4 In the embodiment, the sequential nodes in the second node subgraph include: node B-node C and node B-node D-node E-node F-node G.
[0072] b2: Determine a directed acyclic subgraph according to the sequential nodes.
[0073] In this embodiment, determining the directed acyclic subgraph according to the sequential nodes includes: determining the largest directed acyclic subgraph according to the sequential nodes. For example, Figure 4 Both sequential nodes in include node B, and the node B can only belong to one directed acyclic subgraph. Figure 4 The order of nodes B node-C node and B node-D node-E node-F node-G node in the sequence determines that the largest directed acyclic subgraph is the directed acyclic subgraph composed of C node, and the directed acyclic subgraph composed of B node, D node, E node, F node, and G node, such as Figure 5 Figure surrounded by dotted line.
[0074] In other embodiments, determining the directed acyclic subgraph according to the sequential nodes includes: randomly determining the directed acyclic subgraph according to the sequential nodes. For example, Figure 4 Both sequential nodes in include node B, and the node B can only belong to one directed acyclic subgraph. Figure 4 The sequential nodes B node-C node and B node-D node-E node-F node-G node determine that the directed acyclic subgraph includes the directed acyclic subgraph composed of the B node and the C node, and the directed acyclic subgraph composed of the D node, the E node, the F node, and the G node.
[0075] S204: Merge tasks represented by at least two second nodes in the directed acyclic subgraph including at least two second nodes into one task.
[0076] In this embodiment, the tasks represented by the at least two second nodes in the directed acyclic subgraph including at least two second nodes are merged into one task, including:
[0077] The tasks represented by the at least two second nodes in the directed acyclic subgraph including at least two second nodes are merged into one task according to the processing capability of the graphics processor.
[0078] In this embodiment, merging the tasks represented by the at least two second nodes in the directed acyclic subgraph including at least two second nodes into one task according to the processing capability of the graphics processor includes:
[0079] c1: dividing the directed acyclic subgraph including at least two second nodes into directed acyclic subgraphs according to the processing capability of the graphics processor.
[0080] For example, the processing capability of the graphics processor is to process three tasks, then the directed acyclic subgraph including at least two second nodes is divided into directed acyclic subgraphs according to the processing capability of the graphics processor, for example Figure 5 The directed acyclic subgraph composed of the B node, the D node, the E node, the F node, and the G node is divided into a sub-directed acyclic subgraph composed of the B node, the D node, and the E node, and a sub-directed acyclic subgraph composed of the F node and the G node.
[0081] c2: Merge tasks represented by at least two second nodes in the sub-directed acyclic subgraph including at least two second nodes into one task.
[0082] For example, Figure 5 The tasks represented by the at least two second nodes in the directed acyclic subgraph composed of the B node, the D node, and the E node in the subgraph are merged into one task. Figure 5 The tasks represented by the at least two second nodes in the directed acyclic subgraph formed by the F node and the G node in are merged into one task, such as Figure 6 As shown, the graph surrounded by the double-dotted line is the corresponding node after the original tasks are merged. Therefore, the six tasks that the graphics processor originally needs to process can be merged into three tasks, which will reduce the six interrupts that the central processor originally needs to process to three interrupts.
[0083] In this embodiment, in order to reduce the interrupts that the central processor needs to process, the method further includes:
[0084] d1: transmitting the merged tasks to the graphics processor for execution.
[0085] d2: After the graphics processor completes the merged task, an interrupt signal is sent to the central processing unit.
[0086] In another embodiment, determining a second node subgraph formed by second nodes corresponding to tasks executed by the graphics processor in the first node includes:
[0087] e1: Determine a second node corresponding to the task executed by the graphics processor in the first node.
[0088] For example, in Figure 3 In the embodiment, the second nodes corresponding to the tasks executed by the graphics processor in the first node include a B node, a D node, an F node and a G node.
[0089] e2: Determine that a fourth node whose other node is not after the second node in the execution order is excluded from the second node, and the execution order includes a parallel execution order and a sequential execution order.
[0090] For example, in Figure 3 In the parallel execution order, there is another node C in the D node that is not the second node, then the fourth node after the second node that excludes the other node that is not the second node in the execution order includes Figure 7 The dotted lines represent the B node, F node, and G node.
[0091] e3: combining the nodes in the fourth nodes that have a logical relationship together to form the second node subgraph, wherein the nodes in the fourth nodes that have a logical relationship include sequential nodes and parallel nodes.
[0092] For example, in Figure 7 In the example, nodes F and G are sequential nodes, so nodes F and G are combined to form Figure 8 The second node subgraph surrounded by the dotted line. In this example, the directed acyclic subgraph is Figure 8 The second node subgraph in .
[0093] Embodiment 2 constructs a model as a directed graph including multiple first nodes, the model includes multiple tasks, the tasks represented by the first nodes are executed by the central processing unit and the graphics processing unit, determines the second node subgraph consisting of the second nodes corresponding to the tasks executed by the graphics processing unit in the first node, determines the directed acyclic subgraph in the second node subgraph, and merges the tasks represented by the at least two second nodes in the directed acyclic subgraph including at least two second nodes into one task. Thus, this case can merge the tasks executed by the graphics processing unit that are executed sequentially, will not go back, and will not be executed cyclically, to reduce the interruptions that the central processing unit needs to handle.
[0094] Fig. 9is a block diagram of a device provided in Embodiment 3 of the present invention. The device 9 includes: a memory 91, at least one processor 92, and a computer program 93 stored in the memory 91 and executable on the at least one processor 92. When the at least one processor 92 executes the computer program 93, the steps in the above method embodiment are implemented. Alternatively, when the at least one processor 92 executes the computer program 93, the functions of each module in the above device embodiment are implemented.
[0095] Exemplarily, the computer program 93 may be divided into one or more modules / units, which are stored in the memory 91 and executed by the at least one processor 92 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program 93 in the device 9. For example, the computer program 93 may be divided into Figure 1 For the modules shown, please refer to Example 1 for the specific functions of each module.
[0096] The device 9 may be any electronic product, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), etc. Those skilled in the art will appreciate that the schematic Fig. 9 It is only an example of the device 9 and does not constitute a limitation on the device 9. The device 9 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the device 9 may also include a bus, etc.
[0097] The at least one processor 92 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 92 may be a microprocessor or any conventional processor, etc. The processor 92 is the control center of the device 9, and various interfaces and lines are used to connect various parts of the entire device 9.
[0098] The memory 91 can be used to store the computer program 93 and / or modules / units. The processor 92 implements various functions of the device 9 by running or executing computer-readable instructions and / or modules / units stored in the memory 91, and calling data stored in the memory 91. The memory 91 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the device 9 (such as audio data, etc.), etc. In addition, the memory 91 can include a non-volatile computer-readable memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices.
[0099] If the module / unit integrated in the device 9 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 present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), etc.
[0100] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A processing method for artificial intelligence learning, comprising: Constructing a model as a directed graph including a plurality of first nodes, wherein the model includes a plurality of tasks, and the tasks represented by the plurality of first nodes are executed by a central processing unit and a graphics processing unit; Determine a second node subgraph consisting of second nodes corresponding to the tasks executed by the graphics processor in the first node; Determining a directed acyclic subgraph in the second node subgraph; Merging tasks represented by at least two second nodes in a directed acyclic subgraph including at least two second nodes into one task; transmitting the merged tasks to the graphics processor for execution; After the graphics processor completes the merged task, an interrupt signal is sent to the central processor.
2. The processing method for artificial intelligence learning according to claim 1, characterized in that: The step of constructing the model as a directed graph including a plurality of first nodes comprises: The model is constructed as a directed graph including a plurality of first nodes according to the order of executing the tasks.
3. The processing method for artificial intelligence learning according to claim 1, characterized in that: The determining of a second node subgraph formed by second nodes corresponding to tasks executed by the graphics processor in the first node comprises: Determine a second node corresponding to the task executed by the graphics processor in the first node; The third node in the second node having the same adjacent nodes in the execution order and the adjacent nodes are grouped together to form the second node subgraph, and the execution order includes a parallel execution order and a sequential execution order.
4. The processing method for artificial intelligence learning according to claim 1, characterized in that: Determining the directed acyclic subgraph in the second node subgraph comprises: Determining sequential nodes in the second node subgraph; A directed acyclic subgraph is determined according to the sequential nodes.
5. The processing method for artificial intelligence learning according to claim 1, characterized in that: The tasks represented by the at least two second nodes in the directed acyclic subgraph including at least two second nodes are merged into one task, including: The tasks represented by the at least two second nodes in the directed acyclic subgraph including at least two second nodes are merged into one task according to the processing capability of the graphics processor.
6. The processing method for artificial intelligence learning according to claim 5, characterized in that: The step of merging the tasks represented by the at least two second nodes in the directed acyclic subgraph including at least two second nodes into one task according to the processing capability of the graphics processor includes: Splitting the directed acyclic subgraph including at least two second nodes into directed acyclic subgraphs according to the processing capability of the graphics processor; Tasks represented by the at least two second nodes in the sub-directed acyclic subgraph including the at least two second nodes are merged into one task.
7. A processing device for artificial intelligence learning, characterized in that: The device comprises: A construction module, configured to construct the model into a directed graph including a plurality of first nodes, wherein the model includes a plurality of tasks, and the tasks represented by the plurality of first nodes are executed by a central processing unit and a graphics processing unit; A second node subgraph determining module, configured to determine a second node subgraph consisting of second nodes corresponding to the tasks executed by the graphics processor in the first node; A directed acyclic subgraph determining module, used to determine a directed acyclic subgraph in the second node subgraph; A merging module is used to merge the tasks represented by at least two second nodes in a directed acyclic subgraph including at least two second nodes into one task; wherein the merged task is transmitted to the graphics processor for execution, and after the graphics processor completes the execution of the merged task, an interrupt signal is sent to the central processing unit.
8. A device for artificial intelligence learning, characterized in that: The device includes one or more processors and a memory, and the processor is used to implement the processing method for artificial intelligence learning as described in any one of claims 1 to 6 when executing at least one instruction stored in the memory.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and the at least one instruction is executed by a processor to implement the processing method for artificial intelligence learning as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Memory control method of graphic processor
CN101023445A
Data processing method and device
CN105721211A
Coordination and increased utilization of graphics processors during inference
CN108734286A
Task scheduling method, device and apparatus
CN109523187A
Task parallel processing method, storage medium, computer equipment, device and system
CN109814986A
