A method and related products for fusing operators of a neural network

By segmenting tensor data and fusing operators, the problem of low utilization of multi-level high-speed on-chip storage in neural networks is solved, thereby improving operating efficiency and storage resource utilization.

CN115409678BActive Publication Date: 2026-11-27CAMBRICON TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110578471.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-26
Publication Date
2026-11-27
Estimated Expiration
2041-05-26

AI Technical Summary

Technical Problem

In existing technologies, the utilization rate of multi-level high-speed on-chip memory is low during the operation of neural networks, and the acceleration effect is not obvious.

Method used

Tensor data is divided into sub-tensor data, and operator fusion in the neural network is optimized by determining the splitting scheme and preset storage space. This includes constructing a directed computation graph, establishing an optimization search sequence, determining whether nodes meet the fusion conditions, and splitting the tensor data.

Benefits of technology

It improves the overall operating efficiency of neural networks, saves time, and optimizes the utilization of storage resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115409678B_ABST
    Figure CN115409678B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method and system for fusing operators of a neural network, wherein the system and method can be included in a combined processing device, which can further include a general-purpose interconnect interface and other processing devices. The computing device interacts with the other processing devices to collectively complete a user-specified computing operation. The combined processing device can further include storage devices connected to the device and the other processing devices, respectively, for storing data of the device and the other processing devices. The present disclosure can improve the operational efficiency of various data processing fields, including, for example, the field of artificial intelligence, thereby reducing the overall cost and expense of the operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer science, and more specifically, to operator fusion of neural networks. Background Technology

[0002] Image oversampling is the process of recovering a high-resolution image from a low-resolution image, and it is a very important technique in computer vision and image processing. It has wide applications in fields such as medical imaging, surveillance, and security. To date, numerous classic oversampling methods have been proposed in both academic and practical applications, including prediction-based methods, edge-based methods, statistical methods, block-based methods, and sparse representation methods.

[0003] With the rapid development of deep learning technology in recent years, deep learning-based supersampling techniques have achieved remarkable results. Different deep learning methods have been applied to image supersampling problems, such as convolutional neural networks (CNNs) and generative adversarial networks (GANs). Convolutional operations are fundamental to deep learning neural networks. Although deep learning supersampling networks differ significantly, they are essentially a combination of computational components involving a large number of convolutional calculations. The output of supersampling deep learning networks is typically a high-resolution image with a large amount of data, which results in significant space and computational requirements during the operation.

[0004] Due to the computationally intensive nature of deep learning neural networks, they are currently typically accelerated using GPUs or dedicated deep learning processors with multi-level on-chip storage, including deep learning-based supersampling networks. However, the inputs, outputs, and intermediate computation results of deep learning-based supersampling networks are very large, generally unable to reside in the processor's multi-level high-speed on-chip storage. This results in low utilization of multi-level high-speed on-chip storage and insignificant acceleration effects. Summary of the Invention

[0005] One objective of this disclosure is to address the problem of low utilization of multi-level high-speed on-chip memory and insignificant acceleration effect during the operation of neural networks in the prior art.

[0006] According to a first aspect of this disclosure, a method is provided for segmenting tensor data into sub-tensor data for computation in a neural network, comprising: determining a segmentation scheme for the tensor data, the segmentation scheme including sub-tensor functions represented by sub-tensor dimension variables; determining the sub-tensor dimension variables according to the segmentation scheme and a preset storage space; and segmenting the tensor data according to the determined sub-tensor dimension variables to form sub-tensor data.

[0007] According to a second aspect of this disclosure, an electronic device is provided, comprising: one or more processors; and a memory storing computer-executable instructions that, when executed by the one or more processors, cause the electronic device to perform the method as described above.

[0008] According to a third aspect of this disclosure, a computer-readable storage medium is provided, including computer-executable instructions that, when executed by one or more processors, perform the method described above.

[0009] At least one beneficial effect of this disclosure is that it enables the fusion of qualified operators in a neural network, thereby saving the overall running time of the neural network. Attached Figure Description

[0010] The above and other objects, features, and advantages of this disclosure will become readily apparent from the following detailed description of exemplary embodiments with reference to the accompanying drawings. In the drawings, several embodiments of this disclosure are illustrated by way of example and not limitation, and like or corresponding reference numerals denote like or corresponding parts, wherein:

[0011] Figure 1 A flowchart of a method for fusing operators of a neural network according to one embodiment of the present disclosure is shown;

[0012] Figure 2 A schematic diagram is shown illustrating the construction of a directed computation graph based on an operator of a neural network according to one embodiment of the present disclosure;

[0013] Figure 3 A flowchart illustrating the establishment of an optimized search sequence according to one embodiment of the present disclosure is shown;

[0014] Figure 4 This illustration shows a flowchart of an embodiment of the present disclosure, in which nodes with zero output edges are added to a first queue as candidate nodes to establish an optimized search sequence.

[0015] Figure 5 A flowchart illustrating a method for traversing the plurality of nodes to determine whether a traversed node satisfies a preset condition, according to one embodiment of the present disclosure.

[0016] Figure 6 A flowchart illustrating a method for determining whether a candidate node meets preset conditions according to one embodiment of the present disclosure is shown.

[0017] Figure 7a and Figure 7b A schematic diagram illustrating the fusion of nodes (operators) according to one embodiment of the present disclosure is shown;

[0018] Figure 8 An exemplary flowchart illustrating the segmentation of tensor data according to one embodiment of the present disclosure is shown;

[0019] Figure 9 A flowchart illustrating a method for determining a segmentation scheme for tensor data of an operator to be fused, according to one embodiment of the present disclosure, is shown.

[0020] Figure 10 A flowchart of a method for determining the sub-tensor dimension variable based on the segmentation scheme and a preset storage space according to an embodiment of the present disclosure is shown.

[0021] Figure 11 A flowchart is shown of a method for fusing operators of a neural network according to one embodiment of the present disclosure;

[0022] Figure 12 A combined processing apparatus is shown;

[0023] Figure 13 An exemplary board is shown;

[0024] Figure 14 An exemplary flowchart illustrating the segmentation of tensor data according to one embodiment of the present disclosure is shown. Detailed Implementation

[0025] The technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, not all of them. Based on the embodiments in this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0026] It should be understood that the terms "first," "second," "third," and "fourth," etc., in the claims, specification, and drawings of this disclosure are used to distinguish different objects, not to describe a specific order. The terms "comprising" and "including" as used in the specification and claims of this disclosure indicate the presence of the described features, integrals, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or collections thereof.

[0027] It should also be understood that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this disclosure. As used in this disclosure and claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this disclosure and claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes such combinations.

[0028] As used in this specification and claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0029] Figure 1 A flowchart illustrating a method for fusing operators of a neural network according to one embodiment of the present disclosure is shown.

[0030] like Figure 1 As shown, the method disclosed herein includes: in operation S110, constructing a directed computation graph of the neural network, the directed computation graph including multiple nodes connected by directed edges; in operation S120, traversing the multiple nodes to determine whether the traversed nodes satisfy a preset condition; and in operation S130, using the operators corresponding to the nodes that satisfy the preset condition as fusion operators to be fused to generate a fusion operator.

[0031] To help better understand the technical solutions disclosed herein, some concepts and methods involved in this disclosure will be introduced first.

[0032] Figure 2 A schematic diagram is shown illustrating the construction of a directed computation graph based on an operator of a neural network according to one embodiment of the present disclosure.

[0033] Taking TensorFlow as an example, it uses a directed graph containing a set of nodes and edges to describe the computation process; this directed graph can also be called a directed computation graph. The essence of a computation graph is the relationship between nodes and edges. Nodes can represent the starting point of data input, the ending point of output, model parameters, etc. Edges represent the input / output relationships between nodes. There are two types of edges: one type transmits actual data, which is a tensor; the other type represents control dependencies between nodes. This type of edge does not transmit data but only indicates the execution order between nodes; a subsequent node can only begin computation after the preceding node has completed its computation.

[0034] Figure 2 The directed computation graph in the diagram includes multiple operators, each of which can be represented as a node, connected by directed edges. For example, the output nodes of node Conv_first are Conv1 and Add1, the input node of node Conv1 is Conv_first, and its output node is Relu1. The input nodes of Add2 are nodes Conv4 and Add1. In this disclosure, input nodes can also be called parent nodes; for example, the parent nodes of Add2 are nodes Conv4 and Add1. Similarly, the input nodes of a node can be called child nodes or subordinate nodes; for example, the child node of node Conv4 is Add2.

[0035] After establishing the directed computation graph, each node in the graph can be traversed to determine its own characteristics and the relationships between it and other nodes, thereby determining whether the traversed node meets the preset conditions for fusion. If the traversed node meets the preset conditions, the operator corresponding to that node can be fused. It should be understood that in this paper, the terms operator and node are essentially the same; a node is merely a symbolic representation of an operator, and therefore the two can be used interchangeably.

[0036] According to one embodiment of this disclosure, in order to facilitate the fusion of operators, an optimized search sequence can be established based on the plurality of nodes; and the plurality of nodes in the optimized search sequence can be traversed to determine whether the traversed nodes meet preset conditions.

[0037] When determining whether operators can be fused, it is necessary to... Figure 2 The nodes form an ordered, rather than random, queue, which is referred to in this paper as the optimization search sequence. In this sequence, the nodes are sorted according to specific rules, and these ordered nodes can be traversed to find nodes or operators that can be merged.

[0038] According to one embodiment of this disclosure, the directed computation graph can be traversed in reverse to establish an optimized search sequence. Establishing the optimized search sequence based on the plurality of nodes includes: determining the number of output edges in the directed edges of each node; adding nodes with zero output edges to a first queue as candidate nodes to establish the optimized search sequence. Traversing the directed computation graph in reverse means starting from the final output node of the computation graph and traversing each node from downstream to upstream.

[0039] Still with Figure 2 Let's take an example to illustrate. Figure 2The nodes in the set are represented, for example, by a set E0, which includes {add2, conv4, relu2, conv3, add1, conv2, relu1, conv1, conv_first}. Figure 2 The directed computation graph shown allows us to determine the number of output edges for each node. For example, node Conv1 has 1 output edge, node Add1 has 2 output edges, node add2 has 0 output edges, and so on. Therefore, the number of output edges for the nine nodes can be represented as {0, 1, 1, 1, 2, 1, 1, 1, 2}. For a node with 0 output edges, its storage space essentially depends on the input data. Therefore, if the storage space occupied by the input node of a node with 0 output edges is no greater than the storage space occupied by the node itself, then theoretically, the two can be merged.

[0040] Therefore, when establishing an optimized search sequence, the node with an output edge of 0 can be added to the optimized search sequence as an initial node, and then the nodes in set E0 can be gradually searched to see which nodes can be merged with the initial node.

[0041] Figure 3 A flowchart illustrating the establishment of an optimized search sequence according to one embodiment of the present disclosure is shown.

[0042] like Figure 3 As shown, Figure 3 As shown, adding nodes with zero output edges to the first queue as candidate nodes to establish an optimized search sequence may include: in operation S310, adding nodes with zero initial output edges to the first queue as initial candidate nodes; in operation S320, subtracting 1 from the number of output edges of the input nodes of the initial candidate nodes to obtain updated nodes with updated output edge counts; and in operation S330, adding updated nodes with zero updated output edges to the first queue as candidate nodes, until all nodes are added to the first queue, thereby establishing an optimized search sequence.

[0043] Suppose the optimization search sequence is represented by the sequence Qi, where i is the index. As mentioned above, this sequence Qi is initially empty, denoted as Q0. Since the output edge of node Add2 is 0, we can first add node Add2 to the sequence Q0, thus forming the sequence Q1 = {Add2}.

[0044] Next, node Add2 can be removed from set E0, so set E0 is updated to E1 = {conv4, relu2, conv3, add1, conv2, relu1, conv1, conv_first}. The number of output edges of the input nodes of the initial node Add2 is reduced by 1. Since the input nodes of node Add2 are node Add1 and node Conv4, the number of output edges of these two nodes is reduced by 1, and the updated output edges of nodes Add1 and Conv4 are 1 and 0 respectively. Therefore, the number of output edges of all nodes in set E1 is {0, 1, 1, 1, 1, 1, 1, 2}.

[0045] At this point, the number of output edges of node Conv4 is 0, so node Conv4 can be added to sequence Q1 to form sequence Q2 = {Add2, Conv4}.

[0046] Next, node Conv4 can be removed from set E1, so set E1 is updated to E2 = {relu2, conv3, add1, conv2, relu1, conv1, conv_first}. The number of output edges of the input nodes of node Conv4 is subtracted by 1. The input node of node Conv4 is node Relu2, so the number of output edges of node Relu2 is subtracted by 1. Therefore, the number of output edges for all nodes in set E2 are {0, 1, 1, 1, 1, 1, 2}.

[0047] At this point, the number of output edges of node relu2 is 0, so node relu2 can be added to sequence Q2 to form sequence Q3 = {Add2,Conv4,Relu2}.

[0048] Next, we can remove node Relu2 from set E2, so set E2 is updated to E3 = {conv3, add1, conv2, relu1, conv1, conv_first}. We then subtract 1 from the number of output edges of the input nodes of node Relu2. Since node Relu2's input node is node Conv3, we subtract 1 from the number of output edges of node Conv3. Therefore, the number of output edges for all nodes in set E3 are {0, 1, 1, 1, 1, 2}.

[0049] At this point, the number of output edges of node Conv3 is 0, so node Conv3 can be added to sequence Q3 to form sequence Q4 = {Add2,Conv4,Relu2,Conv3}.

[0050] In this way, all nodes in the directed computation graph can be added to the sequence Qi, thus forming an optimization search sequence. It can be understood that the final optimization search sequence is Q9 = {add2, conv4, relu2, conv3, add1, conv2, relu1, conv1, conv_first}.

[0051] The above is merely a combination Figure 2 The exemplary explanation provided illustrates that different optimization search sequences can be formed for neural networks with different structures. In this way, each node can be sorted to facilitate determining whether it is a fusion-worthy node in subsequent operations.

[0052] Figure 4 This diagram illustrates a process according to one embodiment of the present disclosure of adding nodes with zero output edges to a first queue as candidate nodes to establish an optimized search sequence. According to one embodiment of the present disclosure, adding nodes with zero output edges to the first queue as candidate nodes to establish an optimized search sequence may further include: in operation S410, establishing a first stack for storing at least one of the plurality of nodes; in operation S420, in response to the node's output edge count or an updated output edge count being zero, popping the node from the first stack; and in operation S430, adding the popped node to the tail of the first queue as a candidate node to establish an optimized search sequence.

[0053] Still with Figure 2 Take the directed computation graph shown as an example. A stack can be built, and nodes can be placed into the stack. If the output edge of a node (including the updated output edge) is 0, then the node with the output edge of 0 is popped from the stack and placed at the tail of the optimization search queue mentioned above, thus gradually forming a complete optimization search queue.

[0054] For example, node Add2 is pushed onto the stack first, followed by node Conv4, node Relu2, and node Conv3, and so on. Thus, when the number of output edges of a node becomes zero, or when the number of output edges of a node is updated to zero, it is popped from the stack. It's important to understand that creating a stack is merely a convenient operation method, and not a necessary requirement.

[0055] Once all nodes have been set up in the optimized search sequence in an orderly manner as described above, the next step is to determine which nodes in the optimized search sequence can be merged.

[0056] Figure 5 A flowchart illustrating a method for traversing a plurality of nodes to determine whether a traversed node satisfies a preset condition, according to one embodiment of the present disclosure.

[0057] like Figure 5 As shown, the method includes: in operation S510, establishing a second queue; in operation S520, adding the initial candidate nodes of the first queue to the second queue as nodes to be merged; in operation S530, traversing the candidate nodes in the first queue to determine whether the traversed candidate nodes meet preset conditions; and in operation S540, if the traversed candidate nodes meet the preset conditions, adding the candidate nodes that meet the preset conditions to the second queue as nodes to be merged.

[0058] First, an empty second queue can be created. Then, the first node in the optimized search sequence (e.g., node Add2) can be added to this second queue as the first node to be merged.

[0059] Next, starting from the second node of the optimized search sequence (first queue), all nodes are traversed, and it is determined whether the traversed node meets the preset conditions. If the preset conditions are met, the traversed node is added to the second queue so that it can be merged with the first node in the second queue. If the traversed node does not meet the preset conditions, it is considered that the traversed node cannot be merged with the nodes in the second queue.

[0060] It is important to understand that establishing a second queue is merely a more intuitive approach, and it is not necessary to establish a second queue to accommodate nodes that can be merged.

[0061] Next, we will describe in detail the various scenarios of the preset conditions mentioned above.

[0062] According to one embodiment of this disclosure, if the first storage space occupied by the traversed candidate node is less than or equal to the second storage space occupied by the child candidate node of the candidate node, then the traversed candidate node satisfies a preset condition.

[0063] Let's take the optimization of the search sequence Q9 = {add2, conv4, relu2, conv3, add1, conv2, relu1, conv1, conv_first} as an example for further explanation.

[0064] First, add node add2 to the second queue. Then, starting from node conv4, traverse all other nodes. Node add2 is an addition node, and its output data size is usually no larger than the input data size.

[0065] Next, the process iterates to node conv4, which is a convolution operation node. Based on the characteristics of convolution operations, the output data of node conv4 is usually larger than its input data. Therefore, the storage space required for node conv4 should not be less than the storage space occupied by its output data. It can be seen that in this case, the storage space occupied by node conv4 is not greater than (less than or equal to) the storage space occupied by its child node add2. Therefore, node conv4 can be added to the second queue to facilitate merging with node add2.

[0066] Next, we traverse to node relu2, which is an in-place operation node. In-place operations mean that the operation occurs at the original storage location of the data involved in the operation, and such operations do not cause data expansion or contraction. Therefore, the storage space occupied by node relu2 is no greater than (less than or equal to) the storage space occupied by its child node conv4. Thus, node relu2 can be added to the second queue to facilitate merging with nodes add2 and conv4.

[0067] Next, we iterate to node conv3, which is a convolution operation node. Based on the characteristics of convolution operations, the output data of node conv3 is usually larger than its input data. Therefore, the storage space required for node conv3 should not be less than the storage space occupied by its output data. It can be seen that in this case, the storage space occupied by node conv3 is not greater than (less than or equal to) the storage space occupied by its child node relu2. Therefore, node conv3 can be added to the second queue to facilitate merging with nodes add2, conv4, and relu2.

[0068] Next, iterate to node add1, which is the addition node. Figure 2As shown, the input of add1 includes the outputs from node conv2 and node conv_first. Therefore, the space occupied by node add1 is the greater of the sum of the storage space occupied by the output data of node conv2 and node conv_first, and the storage space occupied by the output data of node add1. Typically, the sum of the storage space occupied by the output data of node conv2 and node conv_first is greater than the storage space occupied by the output data of node add1, so the storage space occupied by node add1 exceeds the storage space occupied by its child node conv1. Therefore, node add1 cannot be merged with nodes add2, conv4, relu2, and conv3.

[0069] It is important to understand that the storage space occupied by each node can be assessed based on the characteristics of the node, or it can be determined based on the actual storage space occupied by each node during operation.

[0070] Based on the above principles, it can be determined that nodes add1, conv2, relu1, and conv1 are also nodes that can be merged, which will not be elaborated here.

[0071] The above method uses the storage space occupied by each node as a standard to determine whether nodes can be merged, which is a basic criterion. According to another embodiment of this disclosure, if the candidate node traversed is the input node of the node to be merged in the second queue and is an in-situ operation node, then it is determined that the first storage space is less than or equal to the second storage space.

[0072] A simpler and more direct method can be used to determine whether a node can be merged with a node in the second queue. In this implementation, if the traversed node is an input node of a node in the second queue and the traversed node is an in-place operation node, then it can be directly determined that the traversed node meets the preset conditions. This is because the storage space occupied by the output data of the in-place operation node is not greater than the storage space occupied by the input data of the in-place operation node, therefore the storage space occupied by the in-place operation node is not greater than the storage space occupied by its child nodes.

[0073] The following method can also be used to determine whether the traversed node meets the preset conditions. According to one embodiment of this disclosure, if the traversed candidate node is the input node of the node to be merged in the second queue and is a non-in-place operation node, but all the nodes to be merged in the second queue are in-place operation nodes, then it is determined that the first storage space is less than or equal to the second storage space.

[0074] In this implementation, when a node is encountered in the optimized search sequence, if the node is not an in-place operation node, it is first determined whether the node's child nodes are nodes to be merged that have already been added to the second queue, and whether all nodes in the second queue are in-place operation nodes. If this condition is met, it means that all nodes after the encountered node will not increase the storage space occupied, thereby enabling the encountered node to be merged with all in-place operation nodes in the second queue.

[0075] The above implementation methods all determine whether nodes can be merged by judging the storage space occupied by the nodes. According to another implementation method of this disclosure, the decision on whether nodes can be merged can also be based on the running time of each operator (node).

[0076] According to one embodiment of this disclosure, if the fusion running time after merging the traversed candidate node with the node to be merged in the second queue is less than or equal to the first running time, then the traversed candidate node satisfies the preset condition, wherein the first running time is the running time of the traversed candidate node and the node to be merged in the second queue before fusion.

[0077] Still with Figure 2 The directed computation graph shown above is used to explain the above implementation method.

[0078] First, add node add2 to the second queue, and then start traversing and optimizing the nodes in the search queue from node conv4.

[0079] It can be seen that node conv4 is the parent node of node add2. Testing revealed that the runtime for nodes add2 and conv4 is 5ms, while the runtime for the merged nodes is 3ms. The time is reduced after merging, therefore these two nodes can be merged. Thus, we continue traversing ReLU2.

[0080] Node relu2 is the parent node of node conv4, so it can be merged with nodes add2 and conv4. Therefore, we continue traversing conv3.

[0081] Node conv3 is the parent node of node relu2. Testing shows that merging nodes add2, conv4, and relu2 with conv3 takes 6ms, while merging nodes add2, conv4, relu2, and conv3 takes 5ms. The merging process reduces the time, therefore nodes add2, conv4, relu2, and conv3 are the most efficient. Thus, we continue traversing the sequence.

[0082] Node add1 is the parent node of nodes add2 and conv3. Tests show that merging nodes add2, conv4, relu2, and conv3 with node add1 takes 6ms, while merging nodes add2, conv4, relu2, conv3 with add1 takes 7ms. The merging process increases the time, therefore node add1 cannot be merged with add2, conv4, relu2, and conv3.

[0083] In the above text, we only focus on the running time of a node individually and the running time of a node after merging. According to another embodiment of this disclosure, the storage space occupied by a node and the running time of the node can be combined to determine whether a node can be merged.

[0084] Figure 6 A flowchart illustrating a method for determining whether a candidate node meets preset conditions according to one embodiment of the present disclosure is shown.

[0085] like Figure 6 As shown, in operation S610, it is determined whether the candidate node traversed is the input node of the node to be merged in the second queue. If it is, then operation S620 is performed; otherwise, the node cannot be merged with the node in the second queue.

[0086] Next, in operation S620, it is determined whether the candidate node traversed is a non-in-place operation node. If it is, then proceed to operation S630; otherwise, if the candidate node traversed is an in-place operation node, then the in-place operation node can be added to the second queue for fusion.

[0087] Next, in operation S630, it is determined whether all the nodes to be merged in the second queue are in-place operation nodes. If so, operation S640 is performed. If not, that is, if it is determined that all the nodes to be merged in the second queue are in-place operation nodes, then the traversed nodes can be added to the second queue for merging.

[0088] Next, in operation S640, if the fusion running time after merging the traversed candidate node with the node to be merged in the second queue is less than or equal to the first running time, then the traversed candidate node meets the preset condition, wherein the first running time is the running time of the traversed candidate node and the node to be merged in the second queue before merging. In this case, the traversed node can be added to the second queue for fusion.

[0089] Next, still using Figure 2 The directed computation graph shown is used as an example to illustrate this. Figure 6 The implementation method shown.

[0090] First, add node add2 to the second queue, and then start traversing and optimizing the nodes in the search queue from node conv4.

[0091] It can be seen that node conv4 is the parent node of node add2 (the candidate nodes traversed are the input nodes of the nodes to be merged in the second queue). Nodes conv4 and add2 are not in-place operation nodes (the candidate nodes traversed are non-in-place operation nodes). The node added to the second queue (node ​​add2) is not an in-place operation node (that is, not all nodes to be merged in the second queue are in-place operation nodes). After testing, the running time of nodes add2 and conv4 is 5ms, while the running time of nodes add2 and conv4 after merging is 3ms. The time is reduced after merging, so these two nodes can be merged. Therefore, we continue to traverse ReLU2.

[0092] Node relu2 is the parent node of node conv4 and is an in-place operation node, so it can be merged with nodes add2 and conv4. Therefore, we continue traversing conv3.

[0093] Node conv3 is the parent node of node relu2. conv3 and conv4 are not in-place operation nodes, and not all nodes in the second queue are in-place operation nodes. Testing showed that merging nodes add2, conv4, and relu2 with conv3 takes 6ms, while merging nodes add2, conv4, relu2, and conv3 takes 5ms. The merging process reduces the time; therefore, nodes add2, conv4, relu2, and conv3 are the preferred choices. Thus, the traversal continues.

[0094] Node add1 is the parent node of nodes add2 and conv3. Nodes add1 and conv3 are not in-place operation nodes, and not all nodes in the second queue are in-place operation nodes. Testing showed that merging nodes add2, conv4, relu2, and conv3 with node add1 takes 6ms, while merging nodes add2, conv4, relu2, conv3, and add1 takes 7ms. The merging process increases the time; therefore, node add1 cannot be merged with add2, conv4, relu2, and conv3.

[0095] It is important to understand that the computation time of a node can be obtained through actual measurement or estimated by establishing a computational model of the operator. Any known or unknown method can be used in this field to obtain the computation time of an operator node.

[0096] It is also important to understand that, for operations S610-S630, although the existing order is shown above, such judgment operations do not necessarily follow the order shown above. Figure 6 The operations S610-S630 can be performed in any order, not in the order shown.

[0097] Figure 7a and Figure 7b A schematic diagram illustrating the fusion of nodes (operators) according to one embodiment of the present disclosure is shown.

[0098] like Figure 7a As shown, after node (operator) fusion, they can be replaced by new nodes. For example, the fusionable nodes add2, conv4, relu2, and conv3 can be replaced by fusion node block 1, while the fusionable nodes conv1, relu2, conv2, and add1 can be replaced by fusion node block 2. Thus, after node fusion, Figure 2 The neural network shown becomes as follows Figure 7a The neural network shown includes node conv_first, fusion node block 1, and fusion node block 2.

[0099] Furthermore, such as Figure 7b As shown, merged nodes and node blocks can be further merged. Assuming node conv_first, merged node block 1 and merged node block 2 are also mergeable nodes (node ​​blocks), then we can determine whether they can be merged based on the rules above. If these nodes (node ​​blocks) are mergeable, they can be merged into merged node block 3.

[0100] The above section described methods for determining fusionable nodes and the corresponding operations. For large tensor datasets, how to efficiently split the data to match fusionable nodes is also a noteworthy issue.

[0101] Figure 8 An exemplary flowchart of segmenting tensor data according to one embodiment of the present disclosure is shown.

[0102] like Figure 8 As shown, the method of this disclosure may alone or may further include: in operation S810, determining a segmentation scheme for the tensor data of the operator to be fused, the segmentation scheme including sub-tensor functions represented by sub-tensor dimension variables; in operation S820, determining the sub-tensor dimension variables according to the segmentation scheme and a preset storage space; and in operation S830, segmenting the tensor data according to the determined sub-tensor dimension variables to form sub-tensor data.

[0103] In the above text, the term "subtensor" refers to a subtensor formed after tensor data has been partitioned, such as a smaller image formed by splitting an image. Subtensor dimension variables refer to the various variables that represent the dimensions of the subtensor; through these variables, subtensor functions can be formed.

[0104] It is important to understand that the above operations can exist independently, meaning they can be performed on tensor data without relying on the node fusion described above, or they can rely on the node fusion described above.

[0105] Understandably, tensor data can be represented in multiple dimensions. For example, a tensor with the shape (720, 1080, 3) indicates that its height h is 720, its width w is 1080, and its number of channels c is 3. The number of channels in a tensor typically does not change depending on the operator, so the number of channels c can be considered constant. However, the height h and width w may differ depending on the data being processed by each operator, so for each operator, the height h and width w can be considered variables.

[0106] Therefore, the input and output data of each operator can be represented by functions of h and w. The storage space occupied by each operator can also be represented by variables h and w. For multiple operators that can be fused, since the functions of each operator may be different, but their maximum storage space is a fixed value, the specific variables h and w need to be determined based on the tensor data partitioning scheme for each operator and the preset storage space size. Once h and w are determined, the tensor data can be partitioned. The preset storage space can be on-chip storage space in the hardware.

[0107] Figure 9 A flowchart illustrating a method for determining a segmentation scheme for tensor data of an operator to be fused, according to one embodiment of the present disclosure, is shown.

[0108] like Figure 9 As shown, the scheme for determining the segmentation of tensor data of the operators to be merged may include: in operation S8110, forming a directed computation subgraph of the operators to be merged in the second queue, the directed computation subgraph including multiple child nodes to be merged connected by directed edges; in operation S8120, determining the sub-tensor function of the output tensor of the first child node to be merged, wherein the first child node to be merged is the child node to be merged with an output node of 0; and in operation S8130, deriving the sub-tensor function of each other child node to be merged in reverse based on the directed computation subgraph.

[0109] For the S8110 operation, it only involves forming a directed computational subgraph for the operators that need to be fused, which is consistent with the above-mentioned combination. Figure 2The methods for forming directed computational graphs are the same, so they will not be repeated here.

[0110] Next, determine the sub-tensor function of the output tensor of the first child node to be merged. Taking the child operators (nodes) to be merged (add2, conv4, relu2, and conv3) as examples, we can first determine the sub-tensor function of the output tensor of node add2 (the output node of this node is 0), for example, F(h, w, 32).

[0111] Once the sub-tensor function of the first child node to be fused is determined, the sub-tensor function of the input data of each operator can be derived in a depth-first manner. For example, the sub-tensor function of the input data of node add2 can be derived as (F(h, w, 32), F(h, w, 32)), the sub-tensor function of the input data of node conv4 can be derived as (h+2, w+2, 32), the sub-tensor function of the input data of node relu2 can be derived as F(h+2, w+2, 32), and the sub-tensor function of the input data of node conv3 can be derived as F(h+4, w+4, 32). Therefore, the shape of the tensors of the input and output data of all nodes can be an expression based on the variables h and w.

[0112] It is important to understand that, in this context, the symbol "F" is used to represent various subtensor functions, but the function symbol F is merely a general term for functions and does not mean that every function must be the same.

[0113] In one particular implementation, the process of deriving the sub-tensor function of each other child node to be merged from the directed computational subgraph may include: when there are multiple outputs of the child node to be merged, deriving the maximum sub-tensor function of each other child node to be merged.

[0114] A node may have multiple outputs. In this case, one cannot simply deduce its input from a single output using a depth-first approach. Instead, one should deduce the maximum sub-tensor function of the node to be merged based on all the outputs, and then deduce the maximum tensor functions of all other nodes to be merged. Determining the maximum tensor function will help to obtain the maximum storage space occupied by each node.

[0115] Figure 10 A flowchart illustrating a method for determining the sub-tensor dimension variable based on the segmentation scheme and a preset storage space according to one embodiment of the present disclosure is shown.

[0116] like Figure 10As shown, determining the sub-tensor dimension variable based on the segmentation scheme and preset storage space may include: in operation S8310, calculating the storage space occupied by the sub-tensor data represented by the sub-tensor function of each sub-node to be merged; in operation S8320, determining the largest sub-tensor dimension variable when the storage space occupied by the sub-tensor data is less than or equal to the preset storage space; wherein, the sub-tensor data represented by the sub-tensor function includes: the output sub-tensor data of the sub-node to be merged; the intermediate sub-tensor data generated by the sub-node to be merged during runtime; and the input sub-tensor data of the sub-node to be merged.

[0117] Once the sub-tensor function of each child node to be merged is determined, the storage space occupied by the data represented by that sub-tensor function can be determined. For example, if the sub-tensor function of the output data of node add2 is (h, w, 32), then the storage space occupied by the output data can be represented as h*w*32. It should be understood that the expression for calculating the storage space here is only an exemplary representation, and it may not be exactly the same as the actual way of calculating the occupied storage space. For example, this expression may omit certain constants, etc. For example, the size of each pixel is 2 bytes, so the storage space occupied by the output data of node add2 can actually be represented as h*w*32*2B. Here, the constant 2B is omitted for the sake of simplicity.

[0118] Once each sub-tensor function is obtained, the optimal value for each variable within that sub-tensor function can be determined based on the size of the sub-tensor function and its storage space. Considering the use of temporary scalars and the function call stack for storage space, we can start iterating through w from a certain value, here starting with 1. For each w, we can find the largest h that satisfies h*w*32 <= the preset storage space, stopping the iteration when no h satisfying the constraint exists. In practice, we can choose the (h, w) value that has the shortest actual test runtime.

[0119] It's important to understand that the sub-tensor functions mentioned above include not only the sub-tensor functions for the output data of a node, but also the sub-tensor functions for the input data of that node, as well as the sub-tensor functions for the intermediate data generated during the process. For ease of understanding, this article mainly provides illustrative descriptions of the sub-tensor functions for the output data and the input data.

[0120] According to one embodiment of this disclosure, determining the largest sub-tensor dimension variable corresponding to a storage space occupied by sub-tensor data that is less than or equal to a preset storage space may include: determining the maximum storage space occupied by the output sub-tensor data, intermediate sub-tensor data, and input sub-tensor data; and, when the maximum storage space is not greater than the preset storage space, determining the tensor dimension variable of the sub-tensor data corresponding to the maximum storage space as the largest sub-tensor dimension variable.

[0121] Furthermore, in order to calculate the maximum storage space required by a certain node, it is necessary to calculate the maximum storage space occupied by all the input data, output data and intermediate data of that node.

[0122] Here, let the maximum storage space required by a certain node be m. Then, the storage space occupied by the output data of node add2 is h*w*32. Node add2 is connected to two nodes, namely nodes conv4 and conv3, and their maximum storage spaces are represented by m respectively. conv4 and m conv3 Therefore, the maximum storage space occupied by node add2 is m. add2 =max{m conv4 +m conv3 ,h*w*32}.

[0123] Assume all convolution operators have 32 input / output channels, a kernel size of (3, 3), and padding of (1, 1). According to the mathematical definition of convolution, the sub-tensor function of one input data point of node add2 is F(h+2, w+2, 32), and correspondingly, the sub-tensor function of the output data of node conv4 is also F(h+2, w+2, 32). Therefore, the storage space occupied by the output data of node conv4 is F((h+2)*(w+2)*32); the storage space occupied by the input data of node conv4 is represented as m. relu2 Therefore, the maximum storage space occupied by node conv4 is m. conv4 =max{m relu2 ,(h+2)*(w+2)*32}.

[0124] The sub-tensor function of the input data of node conv4 is (h+2, w+2, 32), and correspondingly, the sub-tensor function of the output data of node relu2 is (h+2, w+2, 32). Therefore, the storage space occupied by the output data of node relu2 is (h+2)*(w+2)*32; the storage space occupied by the input data of node relu2 is represented as m. conv3 Therefore, the maximum storage space occupied by node ReLU2 is m. relu2 =max{m conv3,(h+2)*(w+2)*32}.

[0125] The sub-tensor function of the output data of node conv3 is F(h+4, w+4, 32), therefore the storage space occupied by the output data of node conv3 is (h+4)*(w+4)*32; the storage space occupied by the input data of node conv3 is represented as m. add1 Therefore, the maximum storage space occupied by node conv3 is m. conv3 =max{m add1 ,(h+4)*(w+4)*32}.

[0126] By following this logic, the maximum storage space occupied by all nodes can be obtained.

[0127] For the operators (nodes) to be merged, it is desirable that the total storage space occupied by all nodes does not exceed a preset storage space. This can be achieved by selecting the largest sub-tensor function such that the storage space corresponding to that sub-tensor function does not exceed the preset storage space. Therefore, by using the method described above, the optimal values ​​of h and w can be found.

[0128] According to one embodiment of this disclosure, when there are multiple inputs to the sub-node to be merged, the maximum storage space occupied by the output sub-tensor data, the intermediate sub-tensor data, and the sum of the multiple input sub-tensor data is determined.

[0129] As shown above, the input data of node add2 includes the output data from node conv4 and the output data from node add1. Therefore, in the technical solution of this disclosure, it is necessary to calculate the sum of multiple input sub-tensor data as the total space occupied by the input data, for example, as shown in the formula above m. add2 =max{m conv4 +m add1 ,h*w*32}.

[0130] Figure 11 A flowchart is shown of a method for fusing operators of a neural network according to one embodiment of the present disclosure.

[0131] like Figure 11 As shown, after determining the operators (nodes) that can be fused and the partitioning scheme of the tensor data, according to one embodiment of this disclosure, the method further includes: in operation S1110, fusing the operators to be fused corresponding to the sub-nodes to be fused to obtain a fusion operator; and in operation S1120, obtaining the running time of the sub-tensor data formed by the fusion operator; or, in operation S1130, evaluating the running time of the sub-tensor data formed by the fusion operator.

[0132] For operating the S1110, please refer to... Figure 7a and Figure 7b After node (operator) fusion, they can be replaced by new nodes (i.e., fused nodes or fused operators). For example, fused nodes add2, conv4, relu2, and conv3 can be replaced by fused node block 1, while fused nodes conv1, relu2, conv2, and add1 can be replaced by fused node block 2. Thus, after node fusion, Figure 2 The neural network shown becomes as follows Figure 7a The neural network shown includes node conv_first, fusion node block 1, and fusion node block 2.

[0133] After fusion, the segmented data can be actually run, thus obtaining the actual running time of the segmented data. This facilitates the evaluation of the data segmentation effect or the fusion effect of the neural network operator. In another implementation, instead of actually running the neural network, the running time of the segmented data in the fusion operator can be estimated using the neural network model.

[0134] In another embodiment of this disclosure, after determining the partitioning scheme of the tensor data, the partitioned tensor data can be run in both the operator-fused neural network and the unfused neural network to compare the performance differences between operator-fused and unfused networks.

[0135] Let's continue using the example of optimizing the search sequence Q9 = {add2, conv4, relu2, conv3, add1, conv2, relu1, conv1, conv_first}. For instance, we can merge nodes add2 and conv4, add2, conv4 and relu2, add2, conv4, relu2 and conv3, and add2, conv4, relu2, conv3 and add1, etc., to evaluate the running time of each fusion scheme for a specific sub-tensor, thereby obtaining the optimal fusion scheme. Furthermore, the running time of each fusion scheme for a specific sub-tensor can be used to determine the running time of the candidate node after fusion with the operators in the second queue, thus determining the preset conditions for whether the candidate node is fused with an operator.

[0136] Furthermore, according to one embodiment of this disclosure, generating the fusion operator includes code for generating the fusion operator.

[0137] Before fusion, each operator can be coded separately. For example, before fusion, the four operators add2, conv4, relu2, and conv3 are executed as follows:

[0138]

[0139]

[0140] The omission of some parameters in the conv, relu, add2, and slice_padding functions does not affect the description of this implementation method.

[0141] After fusion, the code for the fusion operator can be generated. The execution method of the new fusion operator block after fusion can be as follows:

[0142]

[0143] The code above is merely an exemplary description of this disclosure. Depending on the different operators and neural network structures, the expression of each individual operator and the fusion operator block will vary.

[0144] This disclosure also provides an electronic device, including: one or more processors; and a memory storing computer-executable instructions that, when executed by the one or more processors, cause the electronic device to perform the method described above.

[0145] This disclosure also provides a computer-readable storage medium including computer-executable instructions that, when executed by one or more processors, perform the method described above.

[0146] The technical solution disclosed herein was tested in a Linux-based computer using an AI chip and an SRResNet oversampling network. The tests showed that the running time of the entire network using the method disclosed herein is 31ms, which is half the running time without this method, while the running time of other existing methods is all greater than 31ms. Therefore, the solution disclosed herein significantly improves the operating efficiency of the neural network.

[0147] This disclosure presents a data locality optimization method for deep learning oversampling networks. It reduces the runtime of image oversampling networks on multi-level on-chip memory processors, particularly GPUs or dedicated deep learning processors, through operator fusion and data partitioning. The method can be applied to GPUs and other dedicated deep learning processors with multi-level high-speed on-chip memory.

[0148] It is necessary to understand that Figure 8 The scheme for splitting tensor data shown is applicable not only to the operators to be fused mentioned above, but also to operators in general neural networks, regardless of whether the operators can be fused.

[0149] Figure 14 An exemplary flowchart illustrating the segmentation of tensor data according to one embodiment of the present disclosure is shown.

[0150] like Figure 14 As shown, the method includes: in operation S1410, determining a segmentation scheme for tensor data, the segmentation scheme including sub-tensor functions represented by sub-tensor dimension variables; in operation S1420, determining the sub-tensor dimension variables according to the segmentation scheme and a preset storage space; and in operation S1430, segmenting the tensor data according to the determined sub-tensor dimension variables to form sub-tensor data.

[0151] It is necessary to understand that Figure 14 and Figure 8 The difference between the embodiments shown is that, Figure 14 This approach does not require operators to be capable of fusion; it can be used when partitioning tensor data in any neural network. Figure 14 The scheme shown is used to segment tensor data.

[0152] According to one embodiment of this disclosure, determining a segmentation scheme for tensor data may include: forming a directed computational subgraph from the operators of the neural network, the directed computational subgraph including multiple child nodes connected by directed edges; determining a sub-tensor function for the output tensor of the first child node, wherein the first child node is a child node whose output node is 0; and deriving the sub-tensor function for each of the other child nodes in reverse from the directed computational subgraph.

[0153] According to one embodiment of this disclosure, the process of deriving the sub-tensor function of each other sub-node to be merged from the directed computation subgraph includes: when there are multiple outputs of the operator, deriving the maximum sub-tensor function of each other operator from the reverse.

[0154] According to one embodiment of this disclosure, determining the sub-tensor dimension variable based on the segmentation scheme and the preset storage space includes: calculating the storage space occupied by the sub-tensor data represented by the sub-tensor function of each child node; determining the largest sub-tensor dimension variable when the storage space occupied by the sub-tensor data is less than or equal to the preset storage space; wherein the sub-tensor data represented by the sub-tensor function includes: the output sub-tensor data of the child node; the intermediate sub-tensor data generated by the child node during runtime; and the input sub-tensor data of the child node.

[0155] According to one embodiment of this disclosure, determining the largest sub-tensor dimension variable when the storage space occupied by the sub-tensor data is less than or equal to a preset storage space includes: determining the maximum storage space occupied by the output sub-tensor data, intermediate sub-tensor data, and input sub-tensor data; and when the maximum storage space is not greater than the preset storage space, taking the tensor dimension variable of the sub-tensor data corresponding to the maximum storage space as the largest sub-tensor dimension variable.

[0156] According to one embodiment of this disclosure, when there are multiple inputs to a child node, the maximum storage space occupied by the output sub-tensor data, the intermediate sub-tensor data, and the sum of the multiple input sub-tensor data is determined.

[0157] According to one embodiment of this disclosure, the neural network includes operators capable of fusion.

[0158] According to one embodiment of this disclosure, it further includes: fusing the operators corresponding to the child nodes to obtain a fusion operator; and running the sub-tensor data formed by the segmentation through the fusion operator to obtain the running time; or evaluating the running time of the sub-tensor data formed by the segmentation in the operator.

[0159] The technical solution disclosed herein can be applied to the field of artificial intelligence, and can be implemented as or in an artificial intelligence chip. This chip can exist independently or be included in a computing device.

[0160] Figure 12 A combined processing device 1200 is shown, which includes the aforementioned computing device 1202, a general interconnect interface 1204, and other processing devices 1206. The computing device according to this disclosure interacts with the other processing devices to jointly perform user-specified operations. Figure 12 This is a schematic diagram of the combined processing device.

[0161] Other processing devices include one or more processor types such as central processing unit (CPU), graphics processing unit (GPU), and neural network processor. There is no limit to the number of processors included in other processing devices. These other processing devices serve as interfaces between the machine learning computing device and external data and control, including data transfer and basic control such as starting and stopping the machine learning computing device. Other processing devices can also collaborate with the machine learning computing device to complete computational tasks.

[0162] A general interconnect interface is used to transfer data and control commands between a computing device (including, for example, a machine learning computing device) and other processing devices. The computing device can obtain required input data from other processing devices and write it to on-chip storage; it can obtain control commands from other processing devices and write them to on-chip control caches; and it can read data from the computing device's storage modules and transmit it to other processing devices.

[0163] Optionally, the structure may further include a storage device 1208, which is connected to both the computing device and the other processing device. The storage device is used to store data in the computing device and the other processing device, and is particularly suitable for data that cannot be fully stored in the internal storage of the computing device or other processing device, requiring computation.

[0164] This combined processing device can serve as a System-on-a-Chip (SoC) for devices such as mobile phones, robots, drones, and video surveillance equipment, effectively reducing the core area of ​​the control unit, increasing processing speed, and lowering overall power consumption. In this case, the universal interconnect interface of the combined processing device connects to certain components of the device, such as cameras, monitors, mice, keyboards, network cards, and Wi-Fi interfaces.

[0165] In some embodiments, this disclosure also discloses a chip packaging structure that includes the aforementioned chip.

[0166] In some embodiments, this disclosure also discloses a circuit board that includes the aforementioned chip packaging structure. See also... Figure 13 The present invention provides an exemplary board, which, in addition to the chip 1302, may also include other supporting components, including but not limited to: a storage device 1304, an interface device 1306, and a controller 1308.

[0167] The storage device is connected to the chip within the chip package structure via a bus for storing data. The storage device may include multiple sets of storage cells 1310. Each set of storage cells is connected to the chip via a bus. It is understood that each set of storage cells may be DDR SDRAM (Double Data Rate SDRAM).

[0168] DDR can double the speed of SDRAM without increasing the clock frequency. DDR allows data to be read on both the rising and falling edges of the clock pulse. DDR is twice as fast as standard SDRAM. In one embodiment, the storage device may include four groups of storage cells. Each group of storage cells may include multiple DDR4 chips. In one embodiment, the chip may internally include four 72-bit DDR4 controllers, of which 64 bits are used for data transmission and 8 bits are used for ECC verification. In one embodiment, each group of storage cells includes multiple Double Data Rate Synchronous Dynamic Random Access Memory (DRAM) units connected in parallel. DDR can transmit data twice per clock cycle. A controller for controlling DDR is provided in the chip for controlling data transmission and data storage in each storage cell.

[0169] The interface device is electrically connected to the chip within the chip package structure. The interface device is used to realize data transmission between the chip and an external device 1312 (e.g., a server or computer). For example, in one embodiment, the interface device can be a standard PCIe interface. For instance, data to be processed is transferred from the server to the chip via a standard PCIe interface, realizing data transfer. In another embodiment, the interface device can also be other interfaces; this disclosure does not limit the specific form of the other interfaces mentioned above, as long as the interface unit can realize the switching function. Furthermore, the calculation results of the chip are still transmitted back to the external device (e.g., the server) by the interface device.

[0170] The controller is electrically connected to the chip. The controller monitors the state of the chip. Specifically, the chip and the controller can be electrically connected via an SPI interface. The controller may include a microcontroller (MCU). The chip may include multiple processing chips, multiple processing cores, or multiple processing circuits, capable of driving multiple loads. Therefore, the chip can operate in different states, such as high load and low load. The controller can regulate the operating states of multiple processing chips, multiple processing cores, and / or multiple processing circuits within the chip.

[0171] In some embodiments, this disclosure also discloses an electronic device or apparatus that includes the aforementioned board.

[0172] Electronic devices or apparatuses include data processing devices, robots, computers, printers, scanners, tablet computers, smart terminals, mobile phones, dashcams, navigators, sensors, cameras, servers, cloud servers, cameras, camcorders, projectors, watches, headphones, mobile storage, wearable devices, vehicles, home appliances, and / or medical devices.

[0173] The means of transportation include airplanes, ships and / or vehicles; the household appliances include televisions, air conditioners, microwave ovens, refrigerators, rice cookers, humidifiers, washing machines, lights, gas stoves, and range hoods; the medical equipment includes MRI scanners, ultrasound scanners and / or electrocardiographs.

[0174] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this disclosure is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this disclosure. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are optional embodiments, and the actions and modules involved are not necessarily essential to this disclosure.

[0175] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0176] In the embodiments provided in this disclosure, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between devices or units may be electrical, optical, acoustic, magnetic, or other forms.

[0177] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0178] Furthermore, the functional units in the various embodiments disclosed herein can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software program module.

[0179] If the integrated unit is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, when the technical solution disclosed herein can be embodied in the form of a software product, the computer software product is stored in a storage device and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage device includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0180] The embodiments of this disclosure have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this disclosure. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this disclosure. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this disclosure. Therefore, the content of this specification should not be construed as a limitation of this disclosure.

Claims

1. A method for segmenting tensor data in an image oversampling network into sub-tensor data for computation of the sub-tensor data in a neural network, comprising: Determine a partitioning scheme for tensor data, wherein the partitioning scheme includes sub-tensor functions represented by sub-tensor dimension variables; The sub-tensor dimension variable is determined based on the segmentation scheme and the preset storage space; The tensor data is segmented according to the determined sub-tensor dimension variables to form sub-tensor data; The determination of the tensor data partitioning scheme includes: The operators of the neural network are formed into a directed computational subgraph, which includes multiple child nodes connected by directed edges. Determine the sub-tensor function of the output tensor of the first child node, where the first child node is the child node whose output node is 0; The sub-tensor function of each other child node is derived in reverse from the directed computational subgraph.

2. The method according to claim 1, wherein, The sub-tensor function of each other child node is derived by reverse engineering from the directed computational subgraph, including: When there are multiple outputs of an operator, the maximum sub-tensor function of each of the other operators is derived in reverse.

3. The method according to claim 1, wherein, The sub-tensor dimension variables are determined based on the segmentation scheme and the preset storage space, including: The storage space occupied by the sub-tensor data represented by the sub-tensor function is calculated based on the sub-tensor function of each child node. Determine the largest sub-tensor dimension variable when the storage space occupied by the sub-tensor data is less than or equal to the preset storage space; The subtensor data represented by the subtensor function includes: The output sub-tensor data of the child node; Intermediate sub-tensor data generated by child nodes at runtime; and The input sub-tensor data of the child node.

4. The method according to claim 3, wherein, The largest sub-tensor dimension variables that determine whether the storage space occupied by the sub-tensor data is less than or equal to the preset storage space include: Determine the maximum storage space occupied by the output sub-tensor data, intermediate sub-tensor data, and input sub-tensor data; When the maximum storage space is not greater than the preset storage space, the tensor dimension variable of the sub-tensor data corresponding to the maximum storage space is taken as the largest sub-tensor dimension variable.

5. The method according to claim 4, wherein, When there are multiple inputs to a child node, determine the maximum storage space occupied by the output sub-tensor data, intermediate sub-tensor data, and the sum of multiple input sub-tensor data.

6. The method according to any one of claims 1-5, wherein, The neural network includes operators capable of fusion.

7. The method of claim 6, further comprising: The operators corresponding to the child nodes are fused to obtain a fused operator; as well as The running time is obtained by running the sub-tensor data formed by the segmentation through the fusion operator; or The runtime of the segmented sub-tensor data in the operator is evaluated.

8. An electronic device, comprising: One or more processors; as well as A memory storing computer-executable instructions that, when executed by the one or more processors, cause the electronic device to perform the method as described in any one of claims 1-7.

9. A computer-readable storage medium comprising computer-executable instructions that, when executed by one or more processors, perform the method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Neural network model splitting method and device, storage medium and computer system

    CN111562977A

  • Communication method, device and system suitable for heterogeneous environment

    CN111680791A