Graph data computation method and apparatus, storage medium, and computer program product

By updating the node values ​​of graph data using tensor computation methods, the problem of low computational efficiency of graph data is solved, and more efficient computational performance is achieved.

WO2026149551A1PCT designated stage Publication Date: 2026-07-16HUAWEI TECH CO LTD

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2026-01-09
Publication Date
2026-07-16

AI Technical Summary

Technical Problem

The computational efficiency of graph data in existing technologies is relatively low, mainly due to the large amount of adjacency matrix data and the complexity of calculation.

Method used

The tensor computation method is adopted. The node connection relationship in the subgraph is obtained by obtaining the second tensor, and the node value of the reference node in the first tensor and the node value of the node to be updated in the second tensor are updated. The computation is performed using processors such as CPU, GPU, and NPU.

Benefits of technology

It improves the computational efficiency of graph data, makes full use of various processing resources, and enhances computational performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2026071729_16072026_PF_FP_ABST
    Figure CN2026071729_16072026_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure relates to the technical field of databases, and provides a graph data computation method. In the present disclosure, graph data corresponds to a first tensor, the first tensor is used for representing the node value of each node in the graph data, and the node value is a numerical value that can be dynamically updated with the computation process and is maintained for each node when a specified type of computation is performed on the graph data. The graph data computation method comprises: acquiring a second tensor, wherein the second tensor is used for representing a node connection relationship in a subgraph, and the subgraph consists of a node to be updated in graph data, a reference node used for updating the node to be updated, and an edge used for connecting the node to be updated and the reference node; on the basis of the node value of a reference node in a first tensor and the second tensor, updating the node value of a node to be updated in the first tensor; and determining a computation result on the basis of the updated first tensor. In the method, tensors are computed to implement graph computation, so that various processing resources can be well utilized, thereby improving graph computation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Methods, apparatus, storage media, and computer program products for calculating graph data.

[0001] This disclosure claims priority to Chinese Patent Application No. 202510045774.4, filed on January 12, 2025, entitled "Method, Apparatus, Storage Medium and Computer Program Product for Calculating Graph Data", the entire contents of which are incorporated herein by reference. Technical Field

[0002] This disclosure relates to the field of database technology, and in particular to a method, apparatus, storage medium, and computer program product for calculating graph data. Background Technology

[0003] With the advent of the big data era, graph data is being used more and more widely. Currently, graph data is usually stored in the form of adjacency matrices. When performing graph data calculations, the adjacency matrix used to represent the graph data is usually calculated directly. However, the adjacency matrix has a large data volume and is computationally complex, resulting in low computational efficiency. Summary of the Invention

[0004] This disclosure provides a method, apparatus, storage medium, and computer program product for calculating graph data, which can improve the efficiency of graph data calculation.

[0005] Firstly, a computation method for graph data is provided. The graph data corresponds to a first tensor, which represents the node value of each node in the graph data. The node value is a numerical value maintained for each node during a specified type of computation and can be dynamically updated as the computation process proceeds. The method includes:

[0006] Obtain the second tensor, which represents the node connections in the subgraph. The subgraph consists of the node to be updated in the graph data, the reference node used to update the node to be updated, and the edges connecting the node to be updated and the reference node. Update the node values ​​of the node to be updated in the first tensor based on the node values ​​of the reference node in the first tensor and the second tensor. Determine the calculation result based on the updated first tensor.

[0007] In the technical solution provided in this disclosure, all computations of graph data are performed by tensor computations. Since various processors such as CPU, GPU, and NPU can support tensor computations, this method can make good use of various processing resources to improve the computational efficiency of graph data.

[0008] In one possible implementation, the method further includes the following steps before retrieving the second tensor:

[0009] Invoke the first quantity operator to determine the reference node in the graph data.

[0010] In one possible implementation, determining the reference node in the graph data includes:

[0011] Reference nodes are determined based on the third tensor corresponding to the graph data. Each element in the third tensor corresponds to a node in the graph data. Each element is a first value or a second value. The first value is used to indicate that the corresponding node is a reference node, and the second value is used to indicate that the corresponding node is not a reference node.

[0012] In one possible implementation, the method also includes:

[0013] If the value of the first node to be updated in the first tensor has been updated, and the corresponding element of the first node to be updated in the third tensor has the second value, then update the corresponding element of the first node to be updated in the third tensor to the first value. If the value of the second node to be updated in the second tensor has not been updated, and the corresponding element of the second node to be updated in the third tensor has the first value, then update the corresponding element of the second node to be updated in the third tensor to the second value.

[0014] In one possible implementation, the graph data corresponds to a fourth tensor, which includes a first neighbor node tensor and a first offset tensor. The first neighbor node tensor includes the identifiers of the outgoing neighbor nodes of each node in the graph data. The i-th and (i+1)-th elements of the first offset tensor are used to indicate the positions of the outgoing neighbor nodes of the i-th node in the graph data within the first neighbor node tensor. Correspondingly, obtaining the second tensor includes:

[0015] The second tensor operator is invoked, and based on the fourth tensor corresponding to the graph data, the outgoing neighbor nodes of the reference node are determined as the nodes to be updated; the third tensor operator is invoked, and based on the reference node and the node to be updated, the second tensor is generated.

[0016] In one possible implementation, the second tensor includes a reference node tensor, a second neighbor node tensor, and a second offset tensor. The reference node tensor includes the identifier of the reference node, and the second neighbor node tensor includes the identifiers of the outgoing neighbor nodes of the reference node. The nth and (n+1)th elements of the second offset tensor are used to indicate the position of the outgoing neighbor node of the nth reference node in the second neighbor node tensor.

[0017] In one possible implementation, the node value of the node to be updated in the first tensor is updated based on the node value of the reference node in the first tensor and the second tensor, including:

[0018] The fourth tensor operator is invoked to aggregate the node values ​​of the reference nodes in the first tensor based on the second tensor, resulting in an aggregated value tensor. The m-th element of this aggregated value tensor is the aggregated value corresponding to the m-th node in the graph data. The aggregated value of the node to be updated is obtained based on the node values ​​of the reference nodes in the first tensor. The fifth tensor operator is then invoked to update the node values ​​of the node to be updated in the first tensor based on the aggregated value tensor.

[0019] In one possible implementation, the node values ​​of the nodes to be updated in the first tensor are updated based on the aggregate value tensor, including:

[0020] Use the aggregated value tensor as the first tensor after the update.

[0021] In one possible implementation, the node values ​​of the nodes to be updated in the first tensor are updated based on the aggregate value tensor, including:

[0022] For each node value in the first tensor, if the node value is different from the corresponding element in the aggregate value tensor, then the node value is updated based on the corresponding element in the aggregate value tensor.

[0023] Secondly, a data query apparatus is provided, the apparatus comprising at least one module for implementing the method provided in the first aspect and its possible implementations.

[0024] Thirdly, a computing device cluster is provided, including at least one computing device, each computing device including a processor and a memory; the processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, such that the computing device cluster performs the methods provided by the first aspect and its possible implementations described above.

[0025] Fourthly, a computer-readable storage medium is provided, the computer-readable storage medium including computer program instructions that, when executed by a cluster of computing devices, perform the methods provided by the first aspect and its possible implementations.

[0026] Fifthly, a computer program product containing instructions is provided, which, when run by a cluster of computing devices, causes the cluster of computing devices to perform the method provided in the first aspect and its possible implementations. Attached Figure Description

[0027] Figure 1 is a schematic diagram of graph data according to an embodiment of the present disclosure;

[0028] Figure 2 is a schematic diagram of tensor storage of graph data according to an embodiment of the present disclosure;

[0029] Figure 3 is a schematic diagram of tensor storage of graph data according to an embodiment of the present disclosure;

[0030] Figure 4 is a flowchart of a graph data calculation method according to an embodiment of the present disclosure;

[0031] Figure 5 is a flowchart of a graph data calculation method according to an embodiment of the present disclosure;

[0032] Figure 6 is a flowchart of a graph data calculation method according to an embodiment of the present disclosure;

[0033] Figure 7 is a flowchart of a graph data calculation method according to an embodiment of the present disclosure;

[0034] Figure 8 is a flowchart of a graph data calculation method according to an embodiment of the present disclosure;

[0035] Figure 9 is a flowchart of a graph data calculation method according to an embodiment of the present disclosure;

[0036] Figure 10 is a schematic diagram of tensor storage of graph data according to an embodiment of the present disclosure;

[0037] Figure 11 is a flowchart of a graph data calculation method according to an embodiment of the present disclosure;

[0038] Figure 12 is a schematic diagram of a graph data computing device according to an embodiment of the present disclosure;

[0039] Figure 13 is a schematic diagram of a computing device provided in an embodiment of this disclosure;

[0040] Figure 14 is a schematic diagram of a computing device cluster provided in an embodiment of this disclosure;

[0041] Figure 15 is a schematic diagram of a computing device cluster provided in an embodiment of this disclosure. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this disclosure clearer, the embodiments of this disclosure will be described in further detail below with reference to the accompanying drawings.

[0043] The concepts involved in this disclosure are explained below:

[0044] Image data

[0045] Graph data consists of a large number of nodes and edges.

[0046] Nodes can be used to represent people, things, knowledge, etc.

[0047] In graph data, edges are used to connect two nodes and represent the relationship between them. For example, edges can represent friendship or colleague relationships between accounts, or connections between devices, and so on. Edges can be divided into undirected edges and directed edges. For example, the friendship between account A and account B can be represented as an undirected edge between A and B, and account A following account B can be represented as a directed edge from A to B. In data processing, an undirected edge can be considered as a combination of two directed edges for appropriate processing.

[0048] In this way, graph data can be used to represent relationships between people, between people and things, between things, and between knowledge. Figure 1 shows an example of graph data. For example, graph data can be used to represent social networks, communication network topologies, and knowledge graphs, etc.

[0049] Neighbor

[0050] In the case of directed edges (either directed or undirected), the two nodes connected by an edge are neighbors. For directed edges, the terminating node of the directed edge is called the outgoing neighbor of the starting node, and the starting node is called the incoming neighbor of the terminating node. For directed edges that are undirected or bidirectional, the two nodes connected by the edge are both outgoing and incoming neighbors of each other.

[0051] Spend

[0052] Degree is used to indicate the number of edges connected to a node. Degree can be divided into out-degree and in-degree.

[0053] Out-degree: For a given node, the out-degree is the number of edges that are neighbors with that node as an incoming edge. For example, in the example in Figure 1, node V0 has a degree of 3 and an out-degree of 1, while node V5 has a degree of 6 and an out-degree of 5.

[0054] In-degree: For a given node, the in-degree is the number of edges that have nodes as outgoing neighbors. For example, in the example in Figure 1, the in-degree of node V0 is 3, and the in-degree of node V5 is 3.

[0055] Activate node

[0056] In graph computation, multiple rounds of iterative computation may be involved. The active node in the first round of iterative computation is the node specified during initialization. Depending on the type of graph computation, the active node specified in the first round of iterative computation during initialization may also be different. The active node in the Nth round of iterative computation (N is an integer greater than 1) is the node whose value was updated in the (N-1)th round of iterative computation.

[0057] tensor

[0058] In mathematics, a tensor is a one-dimensional or multi-dimensional array. In computer science, tensors generally have a specific data format.

[0059] tensor operators

[0060] Tensor operators are fundamental functions used to perform tensor computations. Various tensor computation runtime (TCR) frameworks, such as PyTorch and TVM, provide a large number of tensor operators.

[0061] Tensor operators are characterized by performing a large number of repetitive simple operations and generally support running on various processors, such as central processing units (CPUs), graphics processing units (GPUs), and neural processing units (NPUs).

[0062] In addition to the tensor operators provided by the various tensor computation runtime frameworks mentioned above, this disclosure also provides several tensor operators in its embodiments. These tensor operators can be used to implement the processing in the graph data computation method provided in this disclosure. The functions of these tensor operators will be described in the following embodiments. In some possible implementations, the tensor operators provided in this disclosure can call the tensor operators provided by the various tensor computation runtime frameworks mentioned above to implement specified tensor processing.

[0063] With the advent of the big data era, graph data is being used more and more widely. Currently, graph data is usually stored in the form of adjacency matrices. When performing graph data calculations, the adjacency matrix used to represent the graph data is usually calculated directly. However, the adjacency matrix has a large data volume and is computationally complex, resulting in low computational efficiency.

[0064] This disclosure provides a method for calculating graph data. In this method, the graph data corresponds to a first tensor, which includes the node value of each node in the graph data. The node value is a numerical value maintained for each node during a specified type of calculation on the graph data and can be dynamically updated during the calculation process. Based on this, when performing calculations on the graph data, a second tensor is first obtained. The second tensor represents the node connection relationships in a subgraph, which consists of nodes to be updated in the graph data, reference nodes used to update the nodes to be updated, and edges connecting the nodes to be updated and the reference nodes. Then, based on the node values ​​of the reference nodes in the first tensor and the second tensor, the node values ​​of the nodes to be updated in the first tensor are updated. Furthermore, the calculation result can be determined based on the updated first tensor. It is evident that the calculation method provided in this disclosure involves tensor calculations. Since various processors such as CPUs, GPUs, and NPUs can support tensor calculations, this method can effectively utilize various processing resources to improve the computational efficiency of graph data.

[0065] This method can be executed by a computer device, which can be a server or a terminal device. A database master program can run on the computer device to implement the method. This disclosure uses a server providing cloud services as an example to illustrate the solution; other cases are similar and will not be described in detail.

[0066] This disclosure provides several storage methods for graph data using tensors, which are described below:

[0067] Storage Method 1

[0068] Graph data is stored using three one-dimensional tensors: a first node tensor, a first offset tensor, and a first neighbor node tensor. Assuming the graph data contains X nodes, the first node tensor also contains X elements, each element being an identifier of a node in the graph data. These identifiers are arranged in a specified order within the first node tensor. The first neighbor node tensor contains the identifiers of the outgoing neighbor nodes of each node in the graph data, with multiple outgoing neighbor nodes of the same node arranged consecutively within the first neighbor node tensor. The first offset tensor contains X+1 elements. The i-th and (i+1)-th elements of the first offset tensor indicate the positions of the outgoing neighbor nodes of the i-th node in the graph data within the first neighbor node tensor. Specifically, the i-th element of the first offset tensor indicates the starting position of the outgoing neighbor node of the i-th node in the graph data within the first neighbor node tensor, and the (i+1)-th element indicates the ending position of the outgoing neighbor node of the i-th node in the graph data within the first neighbor node tensor. The following example illustrates this storage method:

[0069] Referring to Figure 2, the graph data includes 7 nodes, labeled V0, V1, V2, V3, V4, V5, and V6. Correspondingly, the first node tensor can be [V0, V1, V2, V3, V4, V5, V6]. The outgoing neighbor of node V0 is node V3, corresponding to the first element of the first neighbor node tensor; the outgoing neighbors of node V1 are nodes V2, V4, and V5, corresponding to the second to fourth elements of the first neighbor node tensor; the outgoing neighbors of node V2 are nodes V4, V5, and V6, corresponding to the fifth to seventh elements of the first neighbor node tensor, and so on. Therefore, the first neighbor node tensor can be [V3, V2, V4, V5, V4, V5, V6, V1, V0, V1, V2, V3, V5, V6, V0, V1, V2, V3, V6, V0, V3]. The first node in the graph data is node V0. The outgoing neighbor node of node V0 is the first element in the first neighbor node tensor. Therefore, the first element of the first offset tensor is 0, indicating that the starting position of the outgoing neighbor node of node V0 in the first neighbor node tensor is the (0+1)th element. The second element of the first offset tensor is 1, indicating that the ending position of the outgoing neighbor node of node V0 in the first neighbor node tensor is the first element. The second node in the graph data is V1. The outgoing neighbor nodes of node V1 are the 2nd to 4th elements in the first neighbor node tensor. Therefore, the second element of the first offset tensor is 1, indicating that the starting position of the outgoing neighbor node of node V1 in the first neighbor node tensor is the (1+1)th element. The third element of the first offset tensor is 4, indicating that the ending position of the outgoing neighbor node of node V0 in the first neighbor node tensor is the 4th element. And so on, the first offset tensor can be calculated as [0, 1, 4, 7, 8, 14, 19, 21].

[0070] In one possible implementation, when storing the complete graph data, it may not be necessary to store the aforementioned first node tensor.

[0071] Storage Method Two

[0072] Graph data is stored using three one-dimensional tensors: a first node tensor, a second offset tensor, and a second neighbor node tensor. Assuming the graph data contains X nodes, the first node tensor also contains X elements, each element being an identifier of a node in the graph data. These identifiers are arranged in a specified order within the first node tensor. The second neighbor node tensor contains the identifiers of the incoming neighbor nodes of each node in the graph data. Multiple incoming neighbor nodes of the same node are arranged consecutively in the first neighbor node tensor. The first offset tensor contains X+1 elements. The i-th and (i+1)-th elements of the first offset tensor indicate the position of the incoming neighbor node of the i-th node in the graph data within the second neighbor node tensor. Specifically, the i-th element of the second offset tensor indicates the starting position of the incoming neighbor node of the i-th node in the graph data within the second neighbor node tensor, and the (i+1)-th element indicates the ending position of the incoming neighbor node of the i-th node in the graph data within the second neighbor node tensor. The following example illustrates this storage method two:

[0073] Referring to Figure 3, the graph data includes 7 nodes, which are labeled V0, V1, V2, V3, V4, V5 and V6 respectively. Correspondingly, the tensor of the first node can be [V0, V1, V2, V3, V4, V5, V6]. The incoming neighbors of node V0 are nodes V4, V5, and V6, corresponding to the 1st to 3rd elements in the tensor of the second neighbor node; the incoming neighbors of node V1 are nodes V3, V4, and V5, corresponding to the 4th to 6th elements in the tensor of the second neighbor node; the incoming neighbors of node V2 are nodes V1, V4, and V5, corresponding to the 7th to 9th elements in the tensor of the second neighbor node, and so on. Therefore, the tensor of the second neighbor node is [V4, V5, V6, V3, V4, V5, V1, V4, V5, V0, V4, V5, V6, V1, V2, V1, V2, V4, V2, V4, V5]. The first node in the graph data is node V0. The incoming neighbor nodes of node V0 are the 1st to 3rd elements in the second neighbor node tensor. Therefore, the first element of the first offset tensor is 0, indicating that the starting position of the incoming neighbor node of node V0 in the second neighbor node tensor is the 0+1th element. The second element of the second offset tensor is 3, indicating that the ending position of the outgoing neighbor node of node V0 in the second neighbor node tensor is the 3rd element. The second node in the graph data is V1. The outgoing neighbor nodes of node V1 are the 4th to 6th elements in the first neighbor node tensor. Therefore, the second element of the second offset tensor is 3, indicating that the starting position of the incoming neighbor node of node V1 in the second neighbor node tensor is the 3+1th element. The third element of the second offset tensor is 6, indicating that the ending position of the incoming neighbor node of node V0 in the second neighbor node tensor is the 6th element. And so on, the second offset tensor can be obtained as [0, 3, 6, 9, 13, 15, 18, 21].

[0074] In one possible implementation, when storing the complete graph data, it may not be necessary to store the aforementioned first node tensor.

[0075] The first storage method described above can be used in push computing mode, and the second storage method described above can be used in pull computing mode. The following describes the calculation method for graph data provided in the embodiments of this disclosure, specifically for push computing mode and pull computing mode.

[0076] In push computation mode, embodiments of this disclosure provide a computation method for graph data. In this method, in each iteration, subgraphs can be extracted from the graph data and stored using the storage method described above. Then, based on the tensor used to store the subgraph, the node values ​​of the nodes to be updated in the subgraph are updated. Referring to Figure 4, the method may include the following steps:

[0077] 401. In the graph data, determine the reference node.

[0078] In push computation mode, in each round of iteration, the node value of the node to be updated is updated by the node value of the reference node, where the node to be updated is the outgoing neighbor node of the reference node.

[0079] In the first round of iterative computation, reference nodes are specified during initialization. The number of reference nodes and the strategy for specifying them can differ across graph algorithms. This embodiment does not limit how reference nodes are specified during initialization. Furthermore, during initialization, a third tensor corresponding to the graph data is generated. Each element in the third tensor corresponds to a node in the graph data, and each element has either a first value or a second value. The first value indicates that the corresponding node is a reference node, and the second value indicates that the corresponding node is not a reference node. For example, if node V2 is specified as a reference node during initialization, the element corresponding to node V2 in the generated third tensor will have the first value, and the remaining values ​​in the third tensor will have the second values. This third tensor, generated during initialization, can be stored. After each round of iterative computation, the reference node used in the next round of iterative computation can be determined. If the reference node used in the next round of iterative computation is different from the reference node used in the current round, the stored third tensor can be updated.

[0080] In the Nth iteration (N is an integer greater than 1), the reference node is determined based on the stored third tensor. Specifically, in the Nth iteration, the stored third tensor can be obtained, and the node corresponding to the element with the first value in the third tensor is used as the reference node in the Nth iteration.

[0081] In one possible implementation, step 401 can be achieved by calling the first tensor operator, which is an operator provided in the embodiments of this disclosure, and can also be called the first graph operator or the vertex select operator.

[0082] 402, Get the second tensor.

[0083] The second tensor is used to represent the node connection relationship in the subgraph, which consists of the node to be updated in the graph data, the reference node used to update the node to be updated, and the edge used to connect the node to be updated and the reference node.

[0084] For graph data, a fourth tensor corresponding to the graph data can be stored. This fourth tensor may include the first neighbor node tensor and the first offset tensor. The first neighbor node tensor and the first offset tensor have already been introduced in the first storage method above, and will not be repeated here.

[0085] After identifying the reference node, its outgoing neighbor nodes can be determined as nodes to be updated based on the fourth tensor corresponding to the graph data. Specifically, the identifiers of the reference node's outgoing neighbor nodes can be determined in the first neighbor node tensor based on the first offset tensor. Then, the corresponding element can be read from the target position in the first neighbor node tensor, which is the identifier of the reference node's outgoing neighbor node.

[0086] Then, the identifiers of the outgoing neighbor nodes of each reference node are combined to generate a third neighbor node tensor. Next, based on the position of the outgoing neighbor node identifiers of each reference node within the third neighbor node tensor, a third offset tensor is generated. The nth element and the (n+1)th element in the third offset tensor indicate the position of the outgoing neighbor node of the nth reference node within the third neighbor node tensor. Alternatively, the identifiers of the reference nodes can also be combined to generate a reference node tensor.

[0087] The reference node tensor, the third offset tensor, and the third neighbor node tensor obtained above can be collectively referred to as the second tensor.

[0088] In one possible implementation, the process of determining the identifiers of the outgoing neighbor nodes of the reference node in step 402 can be implemented by calling the second tensor operator. The second tensor operator is a tensor operator provided in the embodiments of this disclosure, which can also be called the second graph operator or the neighbor selection operator.

[0089] In another possible implementation, the process of generating the reference node tensor, the third offset tensor, and the third neighbor node tensor in step 402 can be achieved by calling the third tensor operator. The third tensor operator is a tensor operator provided in the embodiments of this disclosure, which can also be called the third graph operator or the reconstruct operator.

[0090] 403. Based on the node values ​​of the reference nodes in the first tensor and the second tensor, update the node values ​​of the nodes to be updated in the first tensor.

[0091] The graph data corresponds to a first tensor, which includes the node value of each node in the graph data. The node value is a numerical value maintained for each node during a specified type of computation on the graph data and can be dynamically updated as the computation process proceeds. Before the first round of iteration computation begins, the first tensor is generated through initialization. In each subsequent round of iteration computation, the node values ​​in the first tensor are updated. Step 403 is the step of updating the node values ​​in the first tensor.

[0092] Based on the second tensor, the node values ​​of the reference nodes in the first tensor are aggregated to generate an aggregate value tensor. The number of elements in the aggregate value tensor is the same as the number of nodes in the graph data. The m-th element in the aggregate value tensor is the aggregate value corresponding to the m-th node in the graph data. The aggregate value corresponding to the node to be updated is obtained based on the node values ​​of the reference nodes in the first tensor. The specific calculation method can be configured according to the actual situation; for example, it can be aggregation calculation such as summation, minimum value, maximum value, or average value. This embodiment does not limit this.

[0093] After obtaining the aggregate value tensor, the node values ​​of the nodes to be updated in the first tensor are updated based on the aggregate value tensor. Here, the specific update method can be configured according to the actual situation. For example, the aggregate value tensor can be directly used as the updated first tensor. Alternatively, for each node value in the first tensor, if the node value to be updated differs from the corresponding element in the aggregate value tensor, the node value is updated based on the corresponding element in the aggregate value tensor. This disclosure does not limit the specific update method.

[0094] In addition, the stored third tensor can also be updated. Specifically, if the node value of the first node in the first tensor is updated, and the element corresponding to the first node in the third tensor is the second value, then the element corresponding to the first node in the third tensor is updated to the first value; if the node value of the second node in the first tensor is not updated, and the element corresponding to the second node in the third tensor is the first value, then the element corresponding to the second node in the third tensor is updated to the second value.

[0095] In one possible implementation, the process of generating the aggregate value tensor in step 403 can be achieved by calling the fourth tensor operator. The fourth tensor operator is a tensor operator provided in the embodiments of this disclosure, and can also be called the fourth graph operator or the aggregation operator.

[0096] In another possible implementation, the process of updating the node values ​​of the nodes to be updated in the first tensor based on the aggregate value tensor in step 403 can be achieved by calling the fifth tensor operator. The fifth tensor operator is a tensor operator provided in this embodiment of the disclosure; it can also be called the fifth graph operator or the update operator. Furthermore, the above-described process of updating the stored third tensor can also be achieved by calling this fifth tensor operator.

[0097] 404, the calculation result is determined based on the updated first tensor.

[0098] When the iteration stopping condition is met, the iteration calculation stops, and the calculation result is determined based on the node value of each node in the updated first tensor. Here, the specific processing for determining the calculation result based on the updated node values ​​can be configured according to the actual situation, and this embodiment does not limit it.

[0099] The following is an example of the process described in Figure 4, which implements the Breadth-First Search (BFS) algorithm using the method shown in Figure 4. Assume the graph data is as shown in Figure 5, stored using a fourth tensor. This fourth tensor includes a first node tensor, a first offset tensor, and a first neighbor node tensor. Additionally, the graph data has a corresponding first tensor used to record the node values ​​of each node in the graph data, which are included in the first tensor.

[0100] Corresponding to step 401 above, referring to Figure 5, before performing the first round of iterative calculation, initialization is performed to generate the third tensor and the first tensor. In the third tensor, if an element is the first value "T", then the node corresponding to that element is the reference node used in the first round of iterative calculation. In Figure 5, the third element of the third tensor is "T", and the remaining elements are all the second value "F". The third element in the third tensor corresponds to node V2, so node V2 is determined as the reference node used in the first round of iterative calculation.

[0101] Referring to Figure 6, in the Nth iteration (N is an integer greater than 1), the stored third tensor [F, F, F, F, T, T, T] is obtained. At this time, the stored third tensor is the third tensor updated after the (N-1)th iteration. In the third tensor, the last three elements are "T", and the nodes V4, V5, and V6 corresponding to the last three elements are taken as reference nodes.

[0102] Corresponding to step 402 above, reference nodes V4, V5, and V6 can be combined to generate a reference node tensor [V4, V5, V6]. Based on the fourth tensor shown in Figure 5, the outgoing neighbor nodes of reference node V4 are determined to be V0, V1, V2, V3, V5, and V6, the neighbor nodes of reference node V5 are V0, V1, V2, V3, and V6, and the outgoing neighbor nodes of reference node V6 are V0 and V3. Combining V0, V1, V2, V3, V5, V6, V0, V1, V2, V3, V6, and V0 and V3 generates a third neighbor node tensor.

[0103] Then, based on the position of the identifier of the outgoing neighbor node of each reference node in the third neighbor node, the third offset tensor [0, 6, 11, 13] is generated.

[0104] The reference node tensor, the third offset tensor, and the third neighbor node tensor obtained above can be collectively referred to as the second tensor.

[0105] Corresponding to step 403 above, referring to Figure 6, based on the third offset tensor, the number of outgoing neighbor nodes for each reference node is determined. Specifically, V4 has 6 outgoing neighbor nodes, V5 has 5, and V6 has 2. Then, based on the node values ​​of the reference nodes in the first tensor and the number of outgoing neighbor nodes for each reference node, a first tensor to be aggregated is generated. The first 6 elements of the first tensor to be aggregated are the node value of V4 + 1, the 7th to 11th elements are the node value of V5 + 1, and the 12th to 13th elements are the node value of V6 + 1. The third neighbor node tensor is used as the first aggregation indicator tensor, and the elements in the first aggregation indicator tensor correspond one-to-one with the elements in the first tensor to be aggregated. Then, based on the first aggregation indicator tensor and the first tensor to be aggregated, an aggregated value tensor is generated. The m-th element in the aggregate value tensor is the aggregate value corresponding to the m-th node in the graph data. The aggregate value corresponding to the node to be updated is obtained by taking the minimum value of the element corresponding to the node to be updated in the first aggregate tensor. The aggregate value of other nodes besides the node to be updated is the node value corresponding to that node in the first tensor. In this way, the aggregate value tensor [2, 2, 2, 2, ∞, 2, 2] can be obtained.

[0106] Then, for each node value in the first tensor, the minimum value between that node's value and its corresponding aggregate value in the aggregate value tensor is taken. If the minimum value is the same as the node value in the first tensor, the node value is not updated. If the minimum value is different from the node value in the first tensor, the minimum value is used as the updated node value. In this way, the updated first tensor [2, 2, 0, 2, 1, 1, 1] can be obtained.

[0107] Furthermore, for each node, if the node's value is updated (i.e., changes), the element corresponding to that node's value in the third tensor is updated to "T"; if the node's value is not updated (i.e., does not change), the element corresponding to that node's value in the third tensor is updated to "F". Thus, the updated third tensor [T, T, F, T, F, F, F] can be obtained.

[0108] In the push computation mode, this disclosure also provides a method for computing graph data. In this method, the graph data is stored in the storage method described above. In each iteration of the computation, all nodes in the graph data are taken as nodes to be updated. Therefore, there is no need to extract subgraphs from the graph data; instead, the graph data is directly used as a subgraph. That is, based on the tensor used to store the graph data, the node values ​​of the nodes to be updated in the graph data are updated. In this method, only steps 402-404 need to be executed. The following example illustrates the processing of steps 402-404 in this method. This example uses steps 402-404 to implement the PageRank algorithm. Assume the graph data is as shown in Figure 7, stored using a fourth tensor. The fourth tensor includes a first node tensor, a first offset tensor, and a first neighbor node tensor. Furthermore, the graph data has a corresponding first tensor used to record the node values ​​of each node in the graph data.

[0109] Corresponding to step 402 above, in any round of calculation, the fourth tensor corresponding to the stored graph data is directly obtained as the second tensor in step 402.

[0110] The third tensor corresponding to the graph data is generated during initialization. This third tensor is [T, T, T, T, T, T, T], indicating that all nodes in the graph data are reference nodes. In this example, the third tensor will not be updated in subsequent iterations.

[0111] Corresponding to step 403 above, aggData is generated for each node, where aggData[i] = vData[i] / G.degree[i], vData[i] represents the node value of the i-th node in the first tensor, and G.degree[i] represents the degree of the i-th node. Then, for each node, the aggData of the reference node (i.e., the incoming edge neighbor node) corresponding to that node is summed to obtain the aggregate value corresponding to each node. The aggregate values ​​of each node are combined to obtain the aggregate value tensor [0.87, 1.37, 0.70, 1.87, 0.67, 0.83, 0.70].

[0112] Then, the first tensor is updated based on the aggregate value tensor. Specifically, for each node, the aggregate value corresponding to that node is multiplied by α and then added by (1-α). The resulting value is used as the updated node value in the first tensor. Here, α is a preset value that can be configured according to actual needs. The value of α is usually between 0 and 1, for example, α is 0.85.

[0113] Corresponding to step 404 above, for example, each node in the graph data represents a webpage. The purpose of the graph computation task is to find the webpage with the highest priority. When the iteration stopping condition is met, the webpage represented by the node corresponding to the maximum value in the first tensor after the last iteration is calculated is taken as the webpage with the highest priority.

[0114] In the pull computation mode, embodiments of this disclosure provide a computation method for graph data. In this method, in each iteration, subgraphs can be extracted from the graph data and stored using the storage method described above (method two). Then, based on the tensor used to store the subgraph, the node values ​​of the nodes to be updated in the subgraph are updated. Referring to Figure 8, the method may include the following steps:

[0115] 801. In the graph data, identify the node to be updated.

[0116] In the pull computation mode, in each round of iteration, the node value of the node to be updated is updated by the node value of the reference node, where the node to be updated is the outgoing neighbor node of the reference node.

[0117] In the first round of iterative computation, the nodes to be updated are specified during initialization. Different graph algorithms may have different numbers of nodes to be updated and different strategies for specifying them. This embodiment does not limit how nodes to be updated are specified during initialization. Furthermore, during initialization, a third tensor corresponding to the graph data is generated. Each element in the third tensor corresponds to a node in the graph data, and each element has either a first value or a second value. The first value indicates that the corresponding node is a node to be updated, and the second value indicates that the corresponding node is not a node to be updated. For example, if node V2 is specified as a node to be updated during initialization, then the element corresponding to node V2 in the generated third tensor will have the first value, and the remaining values ​​in the third tensor will have the second values. This third tensor, generated during initialization, can be stored. After each round of iterative computation, the nodes to be updated in the next round of iterative computation can be determined. If the nodes to be updated in the next round of iterative computation are different from those in the current round, the stored third tensor can be updated.

[0118] In the Nth iteration (N is an integer greater than 1), the node to be updated is determined based on the stored third tensor. Specifically, in the Nth iteration, the stored third tensor can be obtained, and the node corresponding to the element with the first value in the third tensor is used as the node to be updated in the Nth iteration.

[0119] In one possible implementation, step 801 can be achieved by calling the first tensor operator mentioned above.

[0120] 802, retrieve the second tensor.

[0121] The second tensor is used to represent the node connection relationship in the subgraph, which consists of the node to be updated in the graph data, the reference node used to update the node to be updated, and the edge used to connect the node to be updated and the reference node.

[0122] For graph data, a fifth tensor corresponding to the graph data can be stored. This fifth tensor may include the second offset tensor and the second neighbor node tensor. The second offset tensor and the second neighbor node tensor have already been introduced in the storage method two above, and will not be repeated here.

[0123] After identifying the node to be updated, the incoming neighbor nodes of the node to be updated can be determined as reference nodes based on the fifth tensor corresponding to the graph data. Specifically, the target position of the identifier of the incoming neighbor node of the node to be updated in the second neighbor node tensor can be determined based on the second offset tensor. Then, the corresponding element is read from the target position in the second neighbor node tensor, which is the identifier of the incoming neighbor node of the node to be updated.

[0124] Then, the identifiers of the incoming neighbor nodes of each node to be updated are combined to generate a fourth neighbor node tensor. Next, based on the position of the identifiers of the incoming neighbor nodes of each node to be updated within the fourth neighbor node tensor, a fourth offset tensor is generated. The nth element and the (n+1)th element in the fourth offset tensor are used to indicate the position of the incoming neighbor node of the nth node to be updated within the fourth neighbor node tensor. Alternatively, the identifiers of the nodes to be updated can also be combined to generate a tensor for the nodes to be updated.

[0125] The tensor of the node to be updated, the fourth offset tensor, and the fourth neighbor node tensor obtained above can be collectively referred to as the second tensor.

[0126] In one possible implementation, the process of determining the identifiers of the incoming neighbor nodes of the node to be updated in step 802 can be achieved by calling the second tensor operator mentioned above.

[0127] In another possible implementation, the process of generating the node tensor to be updated, the fourth offset tensor, and the fourth neighbor node tensor in step 802 can be achieved by calling the third tensor operator mentioned above.

[0128] 803. Based on the node values ​​of the reference nodes in the first tensor and the second tensor, update the node values ​​of the nodes to be updated in the first tensor.

[0129] The graph data corresponds to a first tensor, which includes the node value of each node in the graph data. The node value is a numerical value maintained for each node during a specified type of computation on the graph data and can be dynamically updated as the computation process proceeds. Before the first round of iteration computation begins, the first tensor is generated through initialization. In each subsequent round of iteration computation, the node values ​​in the first tensor are updated. Step 803 is the step of updating the node values ​​in the first tensor.

[0130] Based on the second tensor, the node values ​​of the reference nodes in the first tensor are aggregated to generate an aggregate value tensor. The number of elements in the aggregate value tensor is the same as the number of nodes in the graph data. The m-th element in the aggregate value tensor is the aggregate value corresponding to the m-th node in the graph data. The aggregate value corresponding to the node to be updated is obtained based on the node values ​​of the reference nodes in the first tensor. The specific calculation method can be configured according to the actual situation; for example, it can be aggregation calculation such as summation, minimum value, maximum value, or average value. This embodiment does not limit this.

[0131] After obtaining the aggregate value tensor, the node values ​​of the nodes to be updated in the first tensor are updated based on the aggregate value tensor. Here, the specific update method can be configured according to the actual situation. For example, the aggregate value tensor can be directly used as the updated first tensor. Alternatively, for each node value in the first tensor, if the node value to be updated differs from the corresponding element in the aggregate value tensor, the node value is updated based on the corresponding element in the aggregate value tensor. This disclosure does not limit the specific update method.

[0132] In addition, the stored third tensor can also be updated. Specifically, if the node value of the first node in the first tensor is updated, and the element corresponding to the first node in the third tensor is the second value, then the element corresponding to the first node in the third tensor is updated to the first value; if the node value of the second node in the first tensor is not updated, and the element corresponding to the second node in the third tensor is the first value, then the element corresponding to the second node in the third tensor is updated to the second value.

[0133] In one possible implementation, the process of generating the aggregate value tensor in step 803 can be achieved by calling the fourth tensor operator described above.

[0134] In another possible implementation, the process of updating the node values ​​of the nodes to be updated in the first tensor based on the aggregate value tensor in step 803 can be achieved by calling the fifth tensor operator mentioned above. Furthermore, the process of updating the stored third tensor described above can also be achieved by calling this fifth tensor operator.

[0135] 804. Determine the calculation result based on the updated first tensor.

[0136] When the iteration stopping condition is met, the iteration calculation stops, and the calculation result is determined based on the node value of each node in the updated first tensor. Here, the specific processing for determining the calculation result based on the updated node values ​​can be configured according to the actual situation, and this embodiment does not limit it.

[0137] In the pull computation mode, this disclosure also provides a method for computing graph data. In this method, the graph data is stored using the storage method described above. In each iteration, all nodes in the graph data are taken as nodes to be updated. Therefore, subgraph extraction is unnecessary; the graph data is directly used as a subgraph. That is, the node values ​​of the nodes to be updated in the graph data are updated based on the tensor used to store the graph data. In this method, only steps 802-804 need to be executed. An example is provided below to illustrate the processing of steps 802-804 in this method. This example implements the BFS algorithm using steps 802-804. Assume the graph data is as shown in Figure 9, stored using a fifth tensor. The fourth tensor includes a first node tensor, a second offset tensor, and a second neighbor node tensor. Furthermore, the graph data has a corresponding first tensor used to record the node values ​​of each node in the graph data.

[0138] Corresponding to step 802 above, in any round of calculation, the fifth tensor corresponding to the stored graph data is directly obtained as the second tensor in step 802.

[0139] The third tensor corresponding to the graph data is generated during initialization. This third tensor is [T, T, T, T, T, T, T], indicating that all nodes in the graph data are nodes to be updated. In this example, the third tensor will not be updated in subsequent iterations.

[0140] Corresponding to step 803 above, referring to Figure 9, based on the fourth offset tensor, the number of incoming neighbor nodes of each node to be updated is determined. Among them, the number of incoming neighbor nodes of V0 is 3, the number of incoming neighbor nodes of V1 is 3, the number of incoming neighbor nodes of V2 is 3, the number of incoming neighbor nodes of V3 is 4, the number of incoming neighbor nodes of V4 is 2, the number of incoming neighbor nodes of V5 is 3, and the number of incoming neighbor nodes of V6 is 3. Then, based on the number of incoming neighbor nodes of each node to be updated, a second aggregation indicator tensor is generated. The first 3 elements of the second aggregation indicator tensor are the identifiers of node V0, the 4th to 6th elements of the second aggregation indicator tensor are the identifiers of node V1, and so on. That is, for any node, the number of the node's identifiers in the second aggregation indicator tensor is the number of the node's incoming neighbor nodes, and the identifiers of the same node are arranged consecutively in the second aggregation indicator tensor. Then, based on the second aggregation indicator tensor, a second tensor to be aggregated is generated, wherein the i-th element in the second tensor to be aggregated is the node value of the incoming neighbor node corresponding to the node indicated by the i-th element in the second aggregation indicator tensor in the first tensor + 1.

[0141] Then, based on the second aggregation indicator tensor and the second tensor to be aggregated, an aggregation value tensor is generated. The m-th element in the aggregation value tensor is the aggregation value corresponding to the m-th node in the graph data. The aggregation value corresponding to the m-th node is obtained by taking the minimum value of the element corresponding to the m-th node in the second tensor to be aggregated. The aggregation values ​​of other nodes, except for the node to be updated, are the node values ​​corresponding to that node in the first tensor. In this way, the aggregation value tensor [2, 2, 2, 2, 1, 1, 2] can be obtained.

[0142] Then, for each node value in the first tensor, the minimum value between that node's value and its corresponding aggregate value in the aggregate value tensor is taken. If the minimum value is the same as the node value in the first tensor, the node value is not updated. If the minimum value is different from the node value in the first tensor, the minimum value is used as the updated node value. In this way, the updated first tensor [2, 2, 0, 2, 1, 1, 1] can be obtained.

[0143] Furthermore, if the next iteration uses the push computation mode, then for each node, if its value is updated (i.e., changes), the corresponding element in the third tensor is updated to "T"; if its value is not updated (i.e., remains unchanged), the corresponding element is updated to "F". This results in the updated third tensor [T, T, F, T, F, F, F]. If the next iteration still uses the pull computation mode, then no update to the third tensor is needed.

[0144] In one possible implementation, the graph data computation method provided in this disclosure, for a graph computation task, can use either pull mode or push mode for each iteration of the graph computation task. Alternatively, before executing the next iteration, the method can determine whether to use pull or push mode based on the ratio of the number of active nodes to the total number of nodes in the graph data. Specifically, if the ratio is greater than or equal to a threshold, the next iteration will use pull mode; if the ratio is less than the threshold, the next iteration will use push mode. The threshold can be configured according to actual needs; an exemplary threshold could be 1 / 2.

[0145] In one possible implementation, as shown in Figure 9 above, when generating the aggregated value tensor based on the second aggregation indicator tensor and the second tensor to be aggregated, the `segment_csr` operator can be invoked. Specifically, the `segment_csr` operator is invoked to group the second tensor to be aggregated based on the second aggregation indicator tensor. For example, referring to Figure 9, if the first three elements of the second aggregation indicator tensor are the same, then the first three elements of the second tensor to be aggregated are grouped together; if the fourth to sixth elements of the second aggregation indicator tensor are the same, then the fourth to sixth elements of the second tensor to be aggregated are grouped together, and so on, grouping the elements in the second tensor to be aggregated. For each group of elements, the `segment_csr` operator performs aggregation calculations on the group of elements to obtain an aggregated value. When the `segment_csr` operator performs aggregation calculations on each group of elements, the computing resources allocated for the aggregation calculation of each group of elements are related to the number of elements in that group; the more elements in that group, the more computing resources are allocated for the aggregation calculation of that group. In this way, we can ensure the efficiency of aggregate calculation without wasting computing resources.

[0146] In the pull computation mode, this disclosure also provides a method for computing graph data. In this method, the graph data can first be compressed and layered based on the fifth tensor corresponding to the graph data to obtain multiple compressed graphs. Each compressed graph is stored using the storage method two described above. During compression and layering, if multiple nodes correspond to a first incoming neighbor node and a second incoming neighbor node, a first virtual node is generated, and the first and second incoming neighbor nodes are represented as the first virtual node. Furthermore, the first and second incoming neighbor nodes are used as the incoming neighbor nodes of the first virtual node to generate a compressed graph including the first incoming neighbor node, the second incoming neighbor node, and the first virtual node. This compressed graph is stored using the storage method two described above. An example is provided below to illustrate this:

[0147] Taking the graph data shown in Figure 3 as an example, the incoming neighbors of nodes V5 and V6 both include nodes V1 and V2, and the incoming neighbors of nodes V0, V1, and V6 both include nodes V4 and V5. Therefore, the node sequence [V1, V2] can be represented as virtual node V7, and the node sequence [V4, V5] as virtual node V8. During compression, nested virtual nodes may occur, meaning that a node sequence represented by a certain virtual node also includes virtual nodes. For example, the incoming neighbors of nodes V0 and V2 both contain the node sequence {V4, V5, V6}, and the node sequence [V4, V5] is represented by virtual node V8. In this case, the node sequence {V8, V6} can be represented by virtual node V9. By representing recurring node sequences as virtual nodes, compressed storage of graph data can be achieved to save storage space.

[0148] For the compressed graph data, we divide it into multiple compressed graphs based on its nesting depth for hierarchical storage. Each layer is a subgraph composed of nodes at the same nesting depth. The nesting depth of each node depends on the nesting depth of the nodes in the node sequence it represents. For non-virtual nodes (the original nodes in the graph data), their nesting depth is 0. For virtual nodes V7 and V8, whose represented node sequences are all non-virtual nodes, their nesting depth is 1. For nodes V1, V2, V4, V5, V6, and virtual node V9, whose represented node sequences include either virtual node V8 or virtual node V7, their nesting depth is 2. For nodes V0 and V3, whose incoming neighbor nodes all include virtual node V9, their nesting depth is 3.

[0149] Then, for nodes at the same nesting depth, a compressed graph is constructed based on these nodes as a subgraph, as shown in Figure 10. This can result in a three-layer subgraph. Each subgraph consists of a tensor of the node to be updated, an offset tensor, and a neighbor node tensor, which is stored using the storage method described above.

[0150] In pull computation mode, the BFS algorithm is implemented. When calculating the multi-level subgraph shown in Figure 10, each subgraph is calculated sequentially from smallest to largest according to the nesting depth of the nodes to be updated in the subgraph. As shown in Figure 11, assuming that the first tensor used to record the node values ​​is [∞,∞,0,∞,1,1,1,∞,∞,∞], for the calculation of the first level subgraph, the minimum value of the node values ​​of nodes V1 and V2 is taken as the aggregate value corresponding to node V7, and the minimum value of the node values ​​of nodes V4 and V5 is taken as the aggregate value corresponding to V8. In this way, the aggregate value tensor [∞,∞,0,∞,1,1,1,0,1,∞] can be obtained. Then, based on the aggregate value tensor, the first tensor is updated. The update method is the same as that in Figure 9, and will not be repeated here. In this way, the updated first tensor [∞,∞,0,∞,1,1,1,0,1,∞] can be obtained. The same calculation is performed on the second and third subgraphs. After calculating the third subgraph, the updated first tensor is [2,2,0,2,1,1,1,0,1,1]. The first few elements are taken to form a new first tensor, which represents the updated node values ​​of the original nodes in the graph data. It should also be noted that the calculation of the corresponding aggregate values ​​for non-virtual nodes is the same as in Figure 9, and will not be repeated here.

[0151] In one possible implementation, the graph data to be computed can be first sliced ​​to obtain multiple sliced ​​subgraphs. Then, for each sliced ​​subgraph, the computation method described in Figure 4 or Figure 8 can be used for computation. The slicing method can be either the Edge-Balanced Partition (EBP) algorithm or the Well-Connected Partition (WCP) algorithm.

[0152] Based on this, the calculation method provided in this disclosure can employ a load queue and a computation queue to schedule the computation of the cut subgraphs. The load queue stores the identifiers of the cut subgraphs to be computed. The computing device retrieves the identifier of the cut subgraph to be computed from the load queue and then loads the corresponding cut subgraph from memory into the computation queue to await computation. During the computation process, the computing device retrieves the cut subgraph to be computed from the computation queue and performs the computation using the method described in Figure 4 or Figure 8. Furthermore, a data sharing area can be partitioned in the storage space to record the node values ​​of all nodes in the graph data to be computed. Before computation of each cut subgraph, the computing device retrieves the node values ​​of each node in the cut subgraph from the data sharing area, performs the computation, and updates the calculated node values ​​in the data sharing area. When the computation of all cut subgraphs meets the iteration stopping condition, the computation stops, and the computation result is determined based on the final node values.

[0153] This disclosure also provides a computational apparatus for graph data, wherein the graph data corresponds to a first tensor, the first tensor being used to represent the node value of each node in the graph data, the node value being a value maintained for each node during a specified type of computation on the graph data and capable of being dynamically updated during the computation process. Referring to Figure 12, the apparatus includes a tensor module 1210 and an update module 1220, wherein:

[0154] Tensor quantization module 1210 is used to obtain a second tensor, wherein the second tensor is used to represent the node connection relationship in the subgraph, the subgraph is composed of the node to be updated in the graph data, the reference node for updating the node to be updated, and the edge for connecting the node to be updated and the reference node.

[0155] The update module 1220 is used to update the node value of the node to be updated in the first tensor based on the node value of the reference node in the first tensor and the second tensor; and to determine the calculation result based on the updated first tensor.

[0156] In one possible implementation, the tensor quantization module 1210 is further configured to:

[0157] The reference node is determined in the graph data.

[0158] In one possible implementation, the quantization module 1210 is used for:

[0159] The first tensor operator is invoked to determine the reference node based on the third tensor corresponding to the graph data. Each element in the third tensor corresponds to a node in the graph data. Each element is a first value or a second value. The first value is used to indicate that the corresponding node is a reference node, and the second value is used to indicate that the corresponding node is not a reference node.

[0160] In one possible implementation, the update module 1220 is further configured to:

[0161] If the node value of the first node to be updated in the first tensor is updated, and the element corresponding to the first node to be updated in the third tensor is the second value, then the element corresponding to the first node to be updated in the third tensor is updated to the first value.

[0162] If the node value of the second node to be updated in the second tensor has not been updated, and the element corresponding to the second node to be updated in the third tensor is the first value, then the element corresponding to the second node to be updated in the third tensor is updated to the second value.

[0163] In one possible implementation, the graph data corresponds to a fourth tensor, which includes a first neighbor node tensor and a first offset tensor. The first neighbor node tensor includes the identifiers of the outgoing neighbor nodes of each node in the graph data. The i-th element and the (i+1)-th element in the first offset tensor are used to indicate the position of the outgoing neighbor node of the i-th node in the graph data in the first neighbor node tensor.

[0164] The tensor quantization module 1210 is used for:

[0165] The second tensor operator is invoked, and based on the fourth tensor corresponding to the graph data, the outgoing neighbor nodes of the reference node are determined as nodes to be updated.

[0166] The third tensor operator is invoked to generate the second tensor based on the reference node and the node to be updated.

[0167] In one possible implementation, the second tensor includes a reference node tensor, a second neighbor node tensor, and a second offset tensor. The reference node tensor includes the identifier of the reference node, and the second neighbor node tensor includes the identifiers of the outgoing neighbor nodes of the reference node. The nth and (n+1)th elements of the second offset tensor are used to indicate the position of the outgoing neighbor node of the nth reference node in the second neighbor node tensor.

[0168] In one possible implementation, the update module 1220 is used to:

[0169] The fourth tensor operator is invoked to perform aggregation calculations on the node values ​​of the reference nodes in the first tensor based on the second tensor, resulting in an aggregated value tensor. The m-th element in the aggregated value tensor is the aggregated value corresponding to the m-th node in the graph data, and the aggregated value corresponding to the node to be updated is obtained based on the node values ​​of the reference nodes in the first tensor.

[0170] The fifth tensor operator is invoked to update the node value of the node to be updated in the first tensor based on the aggregate value tensor.

[0171] In one possible implementation, the update module 1220 is used to:

[0172] Use the aggregated value tensor as the first tensor after the update.

[0173] In one possible implementation, the update module 1220 is used to:

[0174] For each node value in the first tensor, if the node value to be updated is different from the corresponding element in the aggregated value tensor, then the node value is updated based on the corresponding element in the aggregated value tensor.

[0175] Both the quantization module 1210 and the update module 1220 can be implemented in software or in hardware. For example, the implementation of the quantization module 1210 will be described below. Similarly, the implementation of the update module 1220 can refer to the implementation of the quantization module 1210.

[0176] As an example of a software functional unit, the quantization module 1210 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, or a container. Further, the aforementioned computing instance may be one or more. For example, the acquisition module 3110 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Further, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region may include multiple AZs.

[0177] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Communication between two VPCs within the same region, as well as between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.

[0178] As an example of a hardware functional unit, the tensor quantization module 1210 may include at least one computing device, such as a server. Alternatively, the tensor quantization module 1210 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The aforementioned PLD may be implemented using a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.

[0179] The multiple computing devices included in the tensor quantization module 1210 can be distributed within the same region or in different regions. Similarly, the multiple computing devices included in the tensor quantization module 1210 can be distributed within the same Availability Zone (AZ) or in different AZs. Likewise, the multiple computing devices included in the tensor quantization module 1210 can be distributed within the same Virtual Private Cloud (VPC) or in multiple VPCs. These multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.

[0180] It should be noted that, in other embodiments, the quantization module 1210 and the update module 1220 can be used to execute any step in the graph data calculation method. The steps implemented by the quantization module 1210 and the update module 1220 can be specified as needed. By implementing different steps in the graph data calculation method through the quantization module 1210 and the update module 1220 respectively, the full functions of the graph data calculation device can be realized.

[0181] This disclosure also provides a computing device 100. As shown in FIG13, the computing device 100 includes: a bus 102, a processor 104, a memory 106, and a communication interface 108. The processor 104, the memory 106, and the communication interface 108 communicate with each other via the bus 102. The computing device 100 may be a server or a terminal device. It should be understood that this disclosure does not limit the number of processors and memories in the computing device 100.

[0182] Bus 102 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, only one line is used in Figure 14, but this does not imply that there is only one bus or one type of bus. Bus 102 can include pathways for transmitting information between various components of computing device 100 (e.g., memory 106, processor 104, communication interface 108).

[0183] The processor 104 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0184] The memory 106 may include volatile memory, such as random access memory (RAM). The memory 106 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0185] The memory 106 stores executable program code, which the processor 104 executes to implement the functions of the aforementioned tensor quantization module 1210 and update module 1220, thereby realizing the graph data calculation method. In other words, the memory 106 stores instructions for the graph data calculation method.

[0186] The communication interface 108 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 100 and other devices or communication networks.

[0187] This disclosure also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.

[0188] As shown in Figure 14, the computing device cluster includes at least one computing device 100. The memory 106 of one or more computing devices 100 in the computing device cluster may store the same instructions for performing calculations on graph data.

[0189] In some possible implementations, the memory 106 of one or more computing devices 100 in the computing device cluster may also store partial instructions for executing computation methods for graph data. In other words, a combination of one or more computing devices 100 can be used together to execute instructions for computation methods for graph data.

[0190] It should be noted that the memory 106 in different computing devices 100 within the computing device cluster can store different instructions, each used to execute a portion of the functions of the graph data computing device. That is, the instructions stored in the memory 106 of different computing devices 100 can implement the functions of one or more modules of the aforementioned tensor quantization module 1210 and update module 1220.

[0191] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), and can be a Transmission Control Protocol (TCP) network or a Remote Direct Memory Access (RDMA) network. Figure 15 illustrates one possible implementation. As shown in Figure 15, two computing devices 100A and 100B are connected via a network. Specifically, they are connected to the network through communication interfaces in each computing device. In this type of possible implementation, the memory 106 in computing device 100A stores instructions for executing the functions of the tensor module 1210. Simultaneously, the memory 106 in computing device 100B stores instructions for executing the functions of the update module 1220.

[0192] The connection method between the computing device clusters shown in Figure 15 can be considered as follows: taking into account that the graph data computing method provided in this disclosure requires a large amount of data storage, the function implemented by the update module 1220 is to be executed by the computing device 100B.

[0193] It should be understood that the functions of computing device 100A shown in Figure 15 can also be performed by multiple computing devices 100. Similarly, the functions of computing device 100B can also be performed by multiple computing devices 100.

[0194] This disclosure also provides another computing device cluster. The connection relationship between the computing devices in this computing device cluster can be similarly referred to the connection method of the computing device clusters shown in Figures 14 and 15. The difference is that the memory 106 of one or more computing devices 100 in this computing device cluster can store the same instructions for performing calculations on graph data.

[0195] This disclosure also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions capable of running on a computing device or stored on any usable medium. When the computer program product is run on at least one computing device, it causes the at least one computing device to perform a method for calculating graph data.

[0196] This disclosure also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium capable of being stored by a computing device, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disk (DVD)), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device on methods for data manipulation, or instruct the computing device to perform calculations on graph data.

[0197] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this disclosure, and are not intended to limit them. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of this disclosure.

Claims

1. A method for calculating graph data, characterized in that, The graph data corresponds to a first tensor, which represents the node value of each node in the graph data. The node value is a numerical value maintained for each node during a specified type of computation on the graph data and can be dynamically updated as the computation process proceeds. The method includes: Obtain a second tensor, wherein the second tensor is used to represent the node connection relationship in the subgraph, the subgraph is composed of the node to be updated in the graph data, the reference node for updating the node to be updated, and the edge for connecting the node to be updated and the reference node; Based on the node value of the reference node in the first tensor and the second tensor, the node value of the node to be updated in the first tensor is updated; The calculation result is determined based on the updated first tensor.

2. The method according to claim 1, characterized in that, Before obtaining the second tensor, the method further includes: The first tensor operator is invoked to determine the reference node in the graph data.

3. The method according to claim 2, characterized in that, Determining the reference node in the graph data includes: The reference node is determined based on the third tensor corresponding to the graph data, wherein each element in the third tensor corresponds to a node in the graph data, and each element is a first value or a second value, wherein the first value is used to indicate that the corresponding node is a reference node, and the second value is used to indicate that the corresponding node is not a reference node.

4. The method according to claim 3, characterized in that, The method further includes: If the node value of the first node to be updated in the first tensor is updated, and the element corresponding to the first node to be updated in the third tensor is the second value, then the element corresponding to the first node to be updated in the third tensor is updated to the first value. If the node value of the second node to be updated in the second tensor has not been updated, and the element corresponding to the second node to be updated in the third tensor is the first value, then the element corresponding to the second node to be updated in the third tensor is updated to the second value.

5. The method according to any one of claims 2-4, characterized in that, The graph data corresponds to a fourth tensor, which includes a first neighbor node tensor and a first offset tensor. The first neighbor node tensor includes the identifier of the outgoing neighbor node of each node in the graph data. The i-th element and the (i+1)-th element in the first offset tensor are used to indicate the position of the outgoing neighbor node of the i-th node in the graph data in the first neighbor node tensor. The process of obtaining the second tensor includes: The second tensor operator is invoked, and based on the fourth tensor corresponding to the graph data, the outgoing neighbor nodes of the reference node are determined as nodes to be updated. The third tensor operator is invoked to generate the second tensor based on the reference node and the node to be updated.

6. The method according to claim 5, characterized in that, The second tensor includes a reference node tensor, a second neighbor node tensor, and a second offset tensor. The reference node tensor includes the identifier of the reference node, and the second neighbor node tensor includes the identifiers of the outgoing neighbor nodes of the reference node. The nth element and the (n+1)th element of the second offset tensor are used to indicate the position of the outgoing neighbor node of the nth reference node in the second neighbor node tensor.

7. The method according to any one of claims 1-6, characterized in that, The step of updating the node value of the node to be updated in the first tensor based on the node value of the reference node in the first tensor and the second tensor includes: The fourth tensor operator is invoked to perform aggregation calculations on the node values ​​of the reference nodes in the first tensor based on the second tensor, resulting in an aggregated value tensor. The m-th element in the aggregated value tensor is the aggregated value corresponding to the m-th node in the graph data, and the aggregated value corresponding to the node to be updated is obtained based on the node values ​​of the reference nodes in the first tensor. The fifth tensor operator is invoked to update the node value of the node to be updated in the first tensor based on the aggregate value tensor.

8. The method according to claim 7, characterized in that, The step of updating the node values ​​of the nodes to be updated in the first tensor based on the aggregated value tensor includes: Use the aggregated value tensor as the first tensor after the update.

9. The method according to claim 6, characterized in that, The step of updating the node values ​​of the nodes to be updated in the first tensor based on the aggregated value tensor includes: For each node value in the first tensor, if the node value to be updated is different from the corresponding element in the aggregated value tensor, then the node value is updated based on the corresponding element in the aggregated value tensor.

10. A computing device for graph data, characterized in that, The graph data corresponds to a first tensor, which represents the node value of each node in the graph data. The node value is a value maintained for each node during a specified type of computation on the graph data and can be dynamically updated as the computation process proceeds. The device includes: The tensor quantization module is used to obtain a second tensor, wherein the second tensor is used to represent the node connection relationship in the subgraph, the subgraph is composed of the node to be updated in the graph data, the reference node for updating the node to be updated, and the edge for connecting the node to be updated and the reference node. The update module is used to update the node value of the node to be updated in the first tensor based on the node value of the reference node in the first tensor and the second tensor; and to determine the calculation result based on the updated first tensor.

11. The apparatus according to claim 10, characterized in that, The tensor quantization module is also used for: The first tensor operator is invoked to determine the reference node in the graph data.

12. The apparatus according to claim 11, characterized in that, The quantization module is used for: The first tensor operator is invoked to determine the reference node based on the third tensor corresponding to the graph data. Each element in the third tensor corresponds to a node in the graph data. Each element is a first value or a second value. The first value is used to indicate that the corresponding node is a reference node, and the second value is used to indicate that the corresponding node is not a reference node.

13. The apparatus according to claim 12, characterized in that, The update module is also used for: If the node value of the first node to be updated in the first tensor is updated, and the element corresponding to the first node to be updated in the third tensor is the second value, then the element corresponding to the first node to be updated in the third tensor is updated to the first value. If the node value of the second node to be updated in the second tensor has not been updated, and the element corresponding to the second node to be updated in the third tensor is the first value, then the element corresponding to the second node to be updated in the third tensor is updated to the second value.

14. The apparatus according to any one of claims 11-13, characterized in that, The graph data corresponds to a fourth tensor, which includes a first neighbor node tensor and a first offset tensor. The first neighbor node tensor includes the identifier of the outgoing neighbor node of each node in the graph data. The i-th element and the (i+1)-th element in the first offset tensor are used to indicate the position of the outgoing neighbor node of the i-th node in the graph data in the first neighbor node tensor. The tensor quantization module is used for: The second tensor operator is invoked, and based on the fourth tensor corresponding to the graph data, the outgoing neighbor nodes of the reference node are determined as nodes to be updated. The third tensor operator is invoked to generate the second tensor based on the reference node and the node to be updated.

15. The apparatus according to claim 14, characterized in that, The second tensor includes a reference node tensor, a second neighbor node tensor, and a second offset tensor. The reference node tensor includes the identifier of the reference node, and the second neighbor node tensor includes the identifiers of the outgoing neighbor nodes of the reference node. The nth element and the (n+1)th element of the second offset tensor are used to indicate the position of the outgoing neighbor node of the nth reference node in the second neighbor node tensor.

16. The apparatus according to any one of claims 10-15, characterized in that, The update module is used for: The fourth tensor operator is invoked to perform aggregation calculations on the node values ​​of the reference nodes in the first tensor based on the second tensor, resulting in an aggregated value tensor. The m-th element in the aggregated value tensor is the aggregated value corresponding to the m-th node in the graph data, and the aggregated value corresponding to the node to be updated is obtained based on the node values ​​of the reference nodes in the first tensor. The fifth tensor operator is invoked to update the node value of the node to be updated in the first tensor based on the aggregate value tensor.

17. The apparatus according to claim 16, characterized in that, The step of updating the node values ​​of the nodes to be updated in the first tensor based on the aggregated value tensor includes: Use the aggregated value tensor as the first tensor after the update.

18. The apparatus according to claim 15, characterized in that, The update module is used for: For each node value in the first tensor, if the node value to be updated is different from the corresponding element in the aggregated value tensor, then the node value is updated based on the corresponding element in the aggregated value tensor.

19. A computing device cluster, characterized in that, It includes at least one computing device, each computing device including a processor and memory; The processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to cause the cluster of computing devices to perform the method as described in any one of claims 1-9.

20. A computer-readable storage medium, characterized in that, Includes computer program instructions, which, when executed by a cluster of computing devices, perform the method as described in any one of claims 1-9.

21. A computer program product containing instructions, characterized in that, When the instruction is executed by the computing device cluster, the computing device cluster causes the computing device cluster to perform the method as described in any one of claims 1-9.