US 11,941,507 B2
Data flow method and apparatus for neural network computation by determining input variables and output variables of nodes of a computational graph of a neural network
Hongsheng Wang, Hangzhou (CN); and Guang Chen, Hangzhou (CN)
Assigned to ZHEJIANG LAB, Hangzhou (CN)
Filed by ZHEJIANG LAB, Hangzhou (CN)
Filed on Sep. 27, 2022, as Appl. No. 17/954,109.
Application 17/954,109 is a continuation of application No. PCT/CN2022/116171, filed on Aug. 31, 2022.
Claims priority of application No. 202210952808.4 (CN), filed on Aug. 10, 2022.
Prior Publication US 2024/0054319 A1, Feb. 15, 2024
Int. Cl. G06N 3/04 (2023.01); G06F 18/20 (2023.01)
CPC G06N 3/04 (2013.01) [G06F 18/29 (2023.01)] 3 Claims
OG exemplary drawing
 
1. A data flow method for neural network computation, comprising the following steps:
step 1, initializing a lifecycle of a variable in a computational graph, which comprises initializing a time period from a start of a definition of the variable to an end of use as the lifecycle of the variable in the computational graph;
step 2, defining a propagation rule for a variable in use to flow through a node in the computational graph, which comprises defining that, when the variable at the node in the computational graph is used, a definition of the variable is produced at a precursor node of the node, such that an input set of valid variables flowing through the node contains the variable;
step 3, designing the propagation rule for a redefined variable to flow through the node, which comprises, when the variable is redefined at the node in the computational graph, ending the lifecycle of the variable at the precursor node of the node while the variable flows through the node;
step 4, defining the propagation rule for an associated variable to flow through the node in the computational graph;
step 5, analyzing valid variables input and output at each node in the computation graph based on a data stream; wherein the step 5 comprises the following specific sub-steps
step 5.1, initializing a set of input valid variables of the each node, wherein for the each node in the computational graph, a set of output valid variables is an empty set, and the set of input valid variables is derived by removing variables redefined at the each node from the set of output valid variables, and taking a union with all variables used at the each node;
step 5.2, initializing the set of output valid variables of the each node, which comprises, for the each node in the computational graph, initializing elements of the set of output valid variables as variables defined at the each node;
step 5.3, deriving a set of output valid variables of an intermediate node in the computational graph, wherein the set of output valid variables of the intermediate node is obtained by taking a union of input valid variables of all successor nodes of the intermediate node; and
step 5.4, deriving a set of input valid variables of the intermediate node, wherein the set of input invalid variables at the intermediate node is obtained by removing variables redefined at the intermediate node from the set of output valid variables of the intermediate node, and taking a union with variables used at the intermediate node;
step 6, collecting a set of valid variables before and after flowing through the node, and collecting the set of valid variables flowing through the each node obtained by analysis based on lifecycles of variables in the computational graph;
step 7, allocating memory cell blocks for valid variables on edges of the computational graph; wherein in the step 7, conditions for allocating the memory cell blocks for the variable at the certain node in the computational graph are defined as follows: the memory cell blocks are only allocated for the valid variables on the edges of the computational graph during the lifecycle of the variable at the node, and during compilation of the computational graph, the memory cell blocks are allocated for each variable in advance according to a number of variables in the set of valid variables collected;
step 8, defining the propagation rule for available expressions in the computational graph;
step 9, analyzing the available expressions input and output at the each node based on the data stream; and
step 10, optimizing the available expressions in the computational graph, which comprises saving computation results of the available expressions at the nodes in the computational graph into intermediate variables, and replacing the available expressions appearing again in a successor node with the intermediate variables;
configuring a computer system according to the computational graph such that the computer system implements the neural network.