A sparse matrix operation programming method and device based on data flow

Through the sparse matrix operation programming method based on data flow, algorithms in the fields of graph computing, graph mining and graph learning are unifiedly expressed, which solves the problem that the existing system is difficult to uniformly support multiple graph applications, and realizes efficient graph analysis calculation and composite applications. support.

CN118409734BActive Publication Date: 2024-10-11ZHEJIANG LAB
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202410841907.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-10-11
Estimated Expiration
2044-06-27

AI Technical Summary

Technical Problem

It is difficult for existing graph analysis systems to uniformly and efficiently support multiple graph application algorithms in the fields of graph computing, graph mining and graph learning. Moreover, there are differences in computing processes, memory access modes and parallel strategies in each sub-field, and there is a lack of a unified graph analysis framework. Integrate algorithms from different subfields to solve complex application problems.

Method used

Using sparse matrix operation programming method based on data flow, by constructing sparse matrices, performing sparse matrix multiplication operations and updating graph attribute information, the unified representation and calculation of graph application algorithms in the fields of graph computing, graph pattern matching and graph neural networks are realized, using The 'Build-Execute-Update' paradigm performs multiple rounds of iterative operations to meet the convergence conditions or number of iteration rounds of the target graph application.

Benefits of technology

It realizes the unified expression and efficient calculation of graph application algorithms. With the help of sparse matrix optimization technology in the field of high-performance computing, it improves the calculation execution efficiency, provides general adaptability and generalization capabilities, and supports the differential steps and composite graphs of different graph application algorithms. Analytical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118409734B_ABST
    Figure CN118409734B_ABST
Patent Text Reader

Abstract

The present invention proposes a data flow-based sparse matrix operation programming method and device, which is a unified execution framework built for graph applications in the fields of graph computing, graph pattern matching, and graph neural networks to simplify the construction and execution logic of sparse graph applications. Specifically, the programming method uniformly maps graph application algorithms into generalized sparse matrix multiplication operations, converts the algorithm iteration process into three main steps of "building the required data structure, performing sparse matrix multiplication operations, and updating graph properties using calculation results", and provides a user-defined function interface for expressing different graph application logics, which unifies graph applications while ensuring the complete expression of graph algorithms. After rigorous evaluation, the programming method can effectively express graph applications in different fields such as graph computing, graph pattern matching, and graph convolutional neural networks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of sparse matrix analysis represented by graphs, and in particular to a sparse matrix operation programming method and device based on data flow. Background Art

[0002] Graphs are typical data structures that represent sparse matrices and consist of nodes and edges connecting nodes. Graphs can simulate various network structures and relationships between entities in the real world, such as interpersonal relationships in social networks, connections between cities in transportation networks, and interactions between genes or proteins in biological networks. Since there are a large number of graph data with complex topological structures in the real world, it is particularly important to analyze them effectively.

[0003] As an important branch of data science, graph analysis specializes in theoretical methods and algorithmic techniques for understanding and extracting valuable information and deep insights from graph structures. According to different research objectives and application scenarios, graph analysis can be divided into three main sub-fields: graph computing, graph mining, and graph learning. Graph computing studies and solves computational problems on graph structured data, such as graph traversal, shortest path and other algorithmic applications; graph mining focuses on discovering potential valuable patterns and regularities from graph structured data, such as subgraph mining, triangle counting and other algorithmic applications; graph learning uses deep learning technology to model and learn low-dimensional vector representations of graph structures to solve complex tasks such as node classification, graph classification and link prediction, such as graph convolutional networks, graph isomorphic networks and other algorithmic applications.

[0004] The algorithms in different sub-fields of graph analysis are complex and diverse, and the computational processes, memory access modes, and parallel strategies of each field are different, making it difficult for existing graph systems to efficiently and uniformly support the entire graph analysis field. However, a unified graph analysis framework not only allows developers to focus on the algorithmic logic of the graph application itself without paying too much attention to the underlying system implementation details; it also provides the possibility for the reuse of general computing modules for cross-domain applications, cross-platform portability adaptation, and unified and efficient management of graph data. More importantly, the unified framework is expected to support flexible composite graph analysis applications, organically integrate graph algorithms from different sub-fields into the same analysis pipeline, and collaboratively solve complex application problems in practice. Therefore, it is particularly necessary and urgent to build a unified graph analysis programming method and abstract representation. Summary of the invention

[0005] In view of the shortcomings of the prior art, the present invention provides a sparse matrix operation programming method based on data flow, a sparse matrix operation programming method and device based on data flow, the purpose of which is to uniformly represent various graph application algorithms in the fields of graph computing, graph mining and graph learning, and provide method support for a unified graph analysis system.

[0006] To achieve the above objectives, the present invention provides a data flow-based sparse matrix operation programming method, a data flow-based sparse matrix operation programming method, the method is oriented to graph applications in the fields of graph computing, graph pattern matching and graph neural network, and includes the following steps:

[0007] (1) Construct the input data structure required for matrix operations based on the input graph data and the algorithm logic of the target graph application, and perform preprocessing operations; the target graph application refers to a specific graph application that the developer needs to implement;

[0008] (2) Select and execute sparse matrix multiplication operations based on the data size, sparsity, and input data structure type of the input graph;

[0009] (3) Perform post-processing on the calculation results of the sparse matrix multiplication operation, and update the post-processed calculation results to the attribute information of the graph;

[0010] (4) Iterate steps (1) to (3) according to the algorithmic features of the target graph application. When the convergence condition or the number of iterations specified by the target graph application is met, the operation result of the target graph application is recorded in the attribute information of the graph. The convergence condition or the number of iterations is specified by the user implementation of the graph application iteration end judgment function interface.

[0011] Furthermore, the step (1) comprises the following steps:

[0012] (1.1) Based on the input graph topology data, a user implementation of the graph topology sparse matrix construction interface is used to construct a sparse matrix corresponding to the graph topology structure, namely, a graph topology sparse matrix; when constructing the sparse matrix, the nodes of the graph are converted into rows and columns of the matrix, and the edges are converted into non-zero elements of the matrix; the data format of the sparse matrix includes a coordinate tuple, a compressed sparse row, and a compressed sparse column; starting from the second iteration, the graph topology sparse matrix constructed by the input graph data in the first iteration needs to be used again;

[0013] (1.2) Construct an attribute vector / attribute matrix based on the current graph attribute information, the status of activated nodes, and the sparsity. According to the additional input data of the target graph application, the calculation results of the target graph application, and the algorithm characteristics of the graph application, use the graph attribute information to construct the user implementation of the function interface and construct the data structure corresponding to the graph attribute information. According to the characteristics of the graph application, each category of graph attribute information contains zero or more graph attribute information. According to the number of graph attribute information and the data dimension of the attribute information, construct the graph attribute information as a vector / matrix. The data structure corresponding to the graph attribute information is only constructed and initialized in the first iteration of the graph application, and only the data therein will be updated and replaced in subsequent iterations.

[0014] (1.3) Combining the current graph attribute information and activated nodes, using the user implementation of the message construction function interface, construct a message vector / message matrix; the graph attribute information is the data structure corresponding to the graph attribute information constructed in step (1.2); according to the data dimension of the attribute information, choose to construct a message vector / message matrix, and choose to construct a sparse vector / matrix or a dense vector / matrix according to the proportion of the number of activated nodes;

[0015] (1.4) When the target graph application has restrictions on the nodes or edges involved in the calculation in the input graph, combined with the message vector / message matrix constructed in step (1.3), the user implementation of the execution phase preprocessing function interface is used to perform data preprocessing operations on the graph topology sparse matrix and message vector / message matrix, that is, to select and filter the rows and columns of the sparse matrix;

[0016] (1.5) Packing the graph topology sparse matrix and the message vector / message matrix iteratively constructed in step (1.3), and adding them as an execution task to the task scheduling execution queue; the task scheduling execution queue is a system structure for scheduling and dispatching the packed graph topology sparse matrix and message vector / message matrix, and the structure is implemented using the computer hardware architecture and programming environment used by the system framework to achieve the purpose of scheduling the execution task to the hardware computing unit for execution.

[0017] Specifically, the graph topology data in step (1.1) is a file, and each line of the file records an edge of the graph, including the start node number and the end node number of the edge and the weight information of the edge.

[0018] Specifically, the graph attribute information in step (1.2) includes three categories: node attribute information, edge attribute information, and graph global attribute information, which are respectively bound to each node, each edge, or the entire graph of the input graph.

[0019] Specifically, the activated node in the step (1.3) is a node whose node attribute information or the edge attribute information connected to the node has changed in the current iteration round of the graph application compared with the previous iteration round, wherein the activated node is set according to the characteristics of the target graph application and user input in the initial iteration; or the activated node is specified by the algorithm logic of the graph application or by the user as input of the graph application and remains unchanged during the iteration process; and the message vector / message matrix is ​​usually directly constructed from part or all of the attribute information of the activated node, or is obtained after conversion based on the attribute information of the activated node in combination with the algorithm logic of the graph application.

[0020] Furthermore, the step (2) comprises the following steps:

[0021] (2.1) Obtain the graph topology sparse matrix and message vector / message matrix that need to be calculated from the task scheduling execution queue;

[0022] (2.2) According to the storage format and sparsity of the graph topology sparse matrix, the data structure type of the message vector / message matrix, the data scale of the attribute matrix and vector data structure, and the underlying hardware architecture information used by the system framework, select the corresponding operator implementation of the generalized sparse matrix multiplication operation;

[0023] (2.3) Using the operator implementation of the generalized sparse matrix multiplication operation selected in step (2.2), and taking the graph topology sparse matrix and message vector / message matrix obtained in step (2.1) as the input of the operator, perform the sparse matrix multiplication operation.

[0024] Furthermore, the step (3) comprises the following steps:

[0025] (3.1) Based on the algorithmic features of the target graph application, when it is necessary to calculate or transform the result vector / matrix of the sparse matrix multiplication operation, the user implementation of the post-processing function interface of the execution phase is used to perform the corresponding post-processing operation on the result vector / matrix;

[0026] (3.2) According to the algorithm logic of the target graph application, use the user implementation of the graph attribute update function interface to update the result vector / result matrix after the post-processing operation in step (3.1) to the corresponding data structure corresponding to the graph attribute information. Specifically, update the data in the result vector / result matrix to the node attribute, edge attribute or graph global attribute specified by the user according to its row and column position and the update condition specified by the graph application;

[0027] (3.3) According to the updated status of the graph attributes and the algorithmic features of the target graph application, the activation nodes in the next iteration of the graph are set using the user implementation of the activation node setting function interface; specifically, when the activation node is specified by the algorithmic logic of the graph application or by direct user input, the activation node for the next iteration remains unchanged; otherwise, the node whose node attribute information corresponding to the node or the edge attribute information connected to the node is updated in step (3.2) is used as the activation node for the next iteration.

[0028] The present invention also provides a sparse matrix operation programming device based on data flow, which is oriented to graph applications in the fields of graph computing, graph pattern matching and graph neural network, and includes the following modules:

[0029] Preprocessing module: constructs the input data structure required for matrix operations according to the input graph data and the algorithm logic of the target graph application, and performs preprocessing operations; the target graph application refers to a specific graph application that the developer needs to implement;

[0030] Matrix operation module: selects and performs sparse matrix multiplication operations based on the data size, sparsity and input data structure type of the input graph;

[0031] Post-processing module: perform post-processing operations on the calculation results of the sparse matrix multiplication operation, and update the post-processed calculation results to the attribute information of the graph;

[0032] Result recording module: Iterate the preprocessing module, matrix operation module and post-processing module according to the algorithm characteristics of the target graph application. When the convergence condition or number of iterations specified by the target graph application is met, the operation result of the target graph application is recorded in the attribute information of the graph; the convergence condition or number of iterations is specified by the user implementation of the graph application iteration end judgment function interface.

[0033] The present invention also provides an electronic device, comprising:

[0034] one or more processors;

[0035] A memory for storing one or more programs;

[0036] When the one or more programs are executed by the one or more processors, the one or more processors implement the data flow-based sparse matrix operation programming method.

[0037] And a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the data flow-based sparse matrix operation programming method.

[0038] The beneficial technical effects of the present invention are as follows:

[0039] The present invention is a sparse matrix operation programming method based on data flow, which is a unified general computing paradigm for the application of algorithms in the fields of graph analysis such as graph computing, graph mining and graph learning. Compared with the existing programming methods that support a single field or a specific algorithm, the graph application algorithms in different fields are innovatively expressed in a unified manner and compatible with the differences of different algorithms. In particular, the programming method maps the core logic of the graph application algorithm to a sparse matrix multiplication operation, so that a large number of mature sparse matrix multiplication optimization methods in the field of high-performance computing can be used and migrated, such as data partitioning, parallel strategies, etc., which greatly improves the computational execution efficiency of graph applications. Secondly, the programming method adopts the execution paradigm of "build-execute-update", orderly connects and coherently organizes sparse matrix operations, fully expresses the multi-round iterative logic in the graph algorithm, and provides scalable operations and interfaces for the difference steps of graph algorithms in different fields, so as to maximize compatibility and support for different graph application algorithms, and ensure the general adaptability and generalization ability of the programming method. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 An example diagram of a graph application algorithm execution process of a graph application unified programming method based on sparse matrix operations according to a preferred embodiment of the present invention;

[0041] Figure 2 is a flow chart of the pretreatment operation of the present invention;

[0042] Figure 3 It is the matrix operation flow chart of the present invention;

[0043] Figure 4 is a flow chart of the device of the present invention;

[0044] Figure 5 FIG. 1 is a diagram of an electronic device according to the present invention. DETAILED DESCRIPTION

[0045] The following is a detailed description with reference to the accompanying drawings.

[0046] The sparse matrix operation proposed in the present invention is the main technical solution for uniformly expressing the application of graph analysis algorithms in different fields. On the one hand, the graph data structure can be represented very naturally by a sparse matrix, mapping the nodes to the rows and columns of the matrix and the edges to the non-zero elements of the matrix, so as to efficiently encode the topological structure of the graph into a sparse matrix form. On the other hand, sparse matrix computing has many mature optimization technologies in the field of high-performance computing, such as sparse format optimization, parallelization strategy, heterogeneous operator-level acceleration, etc. Mapping graph analysis problems to sparse matrix representation and operations can maximize the reuse of technical accumulation in the field of high-performance computing, and obtain many benefits such as algorithm simplification and enhanced portability.

[0047] The present invention aims to propose a graph application programming method based on sparse matrix operations. Through the three main steps of "build-execute-update", various graph application algorithms in the fields of graph computing, graph mining and graph learning are mapped and calculated, the expression and implementation of graph applications in different fields are unified and simplified, and a methodological support is provided for the design and construction of a unified system for multi-field graph applications.

[0048] In view of the limitation that current graph application programming methods can only support a single graph field or specific graph algorithm, the present invention provides a unified graph application programming method based on sparse matrix operations, which aims to uniformly map the core logic of graph application algorithms into sparse matrix multiplication operations based on the graph data structure representation method of sparse matrices and the three main execution stages of "build-execute-update", so as to effectively express graph algorithm applications in different fields.

[0049] Specifically, see Figure 1 The unified programming method for graph applications based on sparse matrix operations provided by the present invention may include the following steps:

[0050] Step (1): Construct the sparse matrix, vector and other input data structures required for matrix operations based on the graph application algorithm logic and input graph data, and perform certain preprocessing;

[0051] Step (2): Execution, select and execute sparse matrix multiplication operations based on the input data size and sparsity;

[0052] Step (3): Update, post-process the calculation results of the sparse matrix multiplication operation, and update the attribute information of the graph;

[0053] Step (4): Iteration: Iterate the above three steps according to the algorithm characteristics until the convergence condition or the number of iterations specified by the graph algorithm is met.

[0054] According to a preferred embodiment, Figure 2 As shown, in the present invention, step (1) may include the following sub-steps:

[0055] Step (1.1): construct a sparse matrix corresponding to the graph topology structure according to the input graph data, or reuse the graph topology sparse matrix used in the previous iteration; specifically: construct a sparse matrix corresponding to the graph topology structure, that is, a graph topology sparse matrix, according to the input graph topology data using the user implementation of the graph topology sparse matrix construction interface; the graph topology data is a file, each line of the file records an edge of the graph, including the starting node sequence number of the edge, the ending node sequence number of the edge and the weight information of the edge; when constructing the sparse matrix, the nodes of the graph are converted to the rows and columns of the matrix, and the edges are converted to the non-zero elements of the matrix; the data format of the sparse matrix includes coordinate tuples (Coordinate, COO), compressed sparse rows (Compressed SparseRow, CSR), compressed sparse columns (Compressed Sparse Column, CSC), etc.; starting from the second iteration, the graph topology sparse matrix constructed by the input graph data in the first iteration can be reused;

[0056] Step (1.2): Construct an attribute vector / attribute matrix based on the current graph attribute information, the status of activated nodes, and the degree of sparsity; specifically: based on the additional input data of the target graph application (such as the data associated with each node in the graph), the need for the target graph application to calculate the results (for example, if the out-degree of each node needs to be calculated, the node attribute information includes the node out-degree), and the algorithmic characteristics of the graph application, use the graph attribute information to construct the user implementation of the function interface and construct the data structure corresponding to the graph attribute information. The graph attribute information includes three categories: node attribute information, edge attribute information, and graph global attribute information, which are respectively bound to each node, each edge, or the entire graph of the input graph; according to the characteristics of the graph application, each category of graph attribute information may contain zero or more. According to the number of graph attribute information and the data dimension of the attribute information, the graph attribute information is constructed as a vector (when a single attribute information is a scalar) or a matrix (when a single attribute information is a vector). In this programming method, the data structure of the graph attribute information is only constructed and initialized during the first iteration of the graph application, and only the data therein will be updated and replaced during subsequent iterations;

[0057] Step (1.3): According to the attribute vector or attribute matrix and in combination with the constraints of the graph application algorithm, perform data preprocessing operations such as selection and filtering on the rows and columns of the sparse matrix of the graph topology. This is an optional step; specifically: in combination with the current graph attribute information and the status of the activated nodes, use the user implementation of the message construction function interface to construct a message vector / message matrix. The graph attribute information is the data structure of the graph attribute information constructed in step (1.2); the activated node refers to the node whose node attribute information or the edge attribute information connected to the node has changed in the current iteration round of the graph application compared with the previous iteration, where the activated node is set according to the characteristics of the target graph application and the user input in the initial iteration; or the activated node is specified by the algorithm logic of the graph application or the user as the input of the graph application, and remains unchanged during the iteration process. The message vector or message matrix is ​​usually constructed directly from the attribute information (partial or complete) of the activated node, or is obtained by converting the attribute information of the activated node in combination with the algorithm logic of the graph application; according to the data dimension of the attribute information, choose to construct a message vector (when the attribute information is a scalar) or a message matrix (when the attribute information is a vector), and choose to construct a sparse vector or matrix (lower proportion) or a dense vector or matrix (higher proportion) according to the proportion of the number of activated nodes;

[0058] Step (1.4): Pack the graph topology sparse matrix and the corresponding attribute vector or attribute matrix, and add them to the task scheduling execution queue; specifically: when the target graph application has restrictions on the nodes or edges involved in the calculation in the input graph, combine the message vector or message matrix constructed in step (1.3), and use the user implementation of the execution phase preprocessing function interface to perform data preprocessing operations on the graph topology sparse matrix, message vector or message matrix, such as selecting and filtering the rows and columns of the sparse matrix;

[0059] Step (1.5): Pack the graph topology sparse matrix and the message vector or message matrix constructed in this round of iteration in step (1.3), and add it to the task scheduling execution queue as an execution task. The task scheduling execution queue is a system structure for scheduling and dispatching the packed graph topology sparse matrix and message vector or message matrix, which is usually implemented based on the computer hardware architecture and programming environment used by the system framework using the programming method, so as to achieve the purpose of scheduling the execution task to the hardware computing unit for execution.

[0060] According to a preferred embodiment, Figure 3 As shown, in the present invention, step (2) may include the following sub-steps:

[0061] Step (2.1): Obtain the graph topology sparse matrix and message vector or message matrix that need to be calculated from the task scheduling execution queue;

[0062] Step (2.2): According to the storage format of the graph topology sparse matrix and the sparsity of the graph topology sparse matrix, the data structure type of the message vector or message matrix, the attribute matrix, the data scale of the vector data structure, and the underlying hardware architecture information used by the system framework, select the corresponding generalized sparse matrix multiplication operator implementation; the generalized sparse matrix multiplication operator includes the generalized sparse matrix dense vector multiplication operator g-SpMV, the generalized sparse matrix sparse vector multiplication operator g-SpMSpV, the generalized sparse matrix dense matrix multiplication g-SpMM, the generalized sparse matrix sparse matrix multiplication g-SpGEMM, the generalized sparse sampling dense matrix Matrix multiplication operator g-SDDMM; the generalized multiplication and addition operations between row and column elements in matrix multiplication operations are generalized multiplication and addition operations, rather than being limited to multiplication and addition operations in algebraic operations, such as assignment operations, maximum value operations, subtraction operations, and vector addition operations; the multiplication and addition operations of elements in the generalized sparse matrix multiplication are expressed as element multiplication function interfaces and element addition function interfaces of sparse matrix multiplication operations, which are implemented by users; the operators of the sparse matrix multiplication operations are operators related to linear algebra in the field of high-performance computing of computers, which have been fully studied and have open source code repositories or hardware manufacturers providing implementations of their operators;

[0063] Step (2.3): Using the operator implementation of the sparse matrix multiplication operation selected in step (2.2), the graph topology sparse matrix and the message vector or message matrix obtained in step (2.1) are used as inputs of the operator to perform the sparse matrix multiplication operation.

[0064] According to a preferred embodiment, Figure 4 As shown, in the present invention, step (3) may include the following sub-steps:

[0065] Step (3.1): According to the algorithm characteristics of the target graph application, when it is necessary to calculate or transform the result vector or matrix of the sparse matrix multiplication operation, the user implementation of the post-processing function interface in the execution phase is used to perform the corresponding post-processing operation on the result vector or result matrix. Therefore, this is an optional step;

[0066] Step (3.2): According to the algorithm logic of the target graph application, use the user implementation of the graph attribute update function interface to update the result vector or result matrix after the post-processing operation of step (3.1) to the data structure of the graph attribute information described in step (1.2). Specifically, update the data in the result vector or result matrix to the node attribute, edge attribute or graph global attribute specified by the user according to its row and column position and the update condition specified by the graph application;

[0067] Step (3.3): According to the updated status of the graph attributes and the algorithmic features of the target graph application, use the user implementation of the activation node setting function interface to set the activation node in the next iteration graph; specifically, when the activation node is specified by the algorithmic logic of the graph application or by direct user input, the activation node for the next iteration remains unchanged; otherwise, the node whose corresponding node attribute information or the edge attribute information connected to the node is updated in step (3.2) is used as the activation node for the next iteration.

[0068] In addition, a set of user-defined function interfaces adapted to graph application algorithms in different fields provided in this embodiment can be used to implement a unified programming method for graph applications based on sparse matrix operations as provided in Example 1.

[0069] Specifically, the user-defined function interface adapted to different fields of graph application algorithms provided in this embodiment may at least include a graph topology construction function interface, a graph attribute construction function interface, an execution phase preprocessing function interface, a sparse matrix multiplication operation multiplication operator function interface, a sparse matrix multiplication operation addition operator function interface, an execution phase postprocessing interface function, an update graph attribute function interface, an activation node setting function interface, and a graph application iteration end judgment function interface. This embodiment also provides the specific implementation logic of this group of custom function interfaces in a single-source shortest path graph application.

[0070] According to a preferred embodiment, the graph topology sparse matrix construction function interface is configured to return the sparse matrix corresponding to the input graph in a single-source shortest path graph application by specifying the construction method of the sparse matrix corresponding to the graph topology by the user.

[0071] According to a preferred embodiment, the graph attribute information construction function interface is composed of the composition of the graph attribute information corresponding to the graph application specified by the user and the way of constructing the corresponding data set of the graph attribute information according to the algorithm characteristics of the graph application and additional inputs. In the single-source shortest path graph application, it is configured to return a vector consisting of node distance attributes.

[0072] According to a preferred embodiment, the message construction function interface is specified by the user to construct a message vector or message matrix from the current graph attribute information and activated nodes, and is configured in the single-source shortest path graph algorithm to return a vector composed of distance attributes of the activated nodes.

[0073] According to a preferred embodiment, the preprocessing function interface in the execution phase is specified by the user to perform preprocessing operations on the graph topology sparse matrix and attribute vector or attribute matrix, which is configured as a no-operation in the single-source shortest path graph algorithm and does not require additional preprocessing.

[0074] According to a preferred embodiment, a sparse matrix multiplication operator function interface is used by the user to specify the execution logic of the multiplication operator in the generalized sparse matrix multiplication operation, and is configured as an accumulation operation in the single-source shortest path graph algorithm, representing the sum of the node distance attribute and the edge weight.

[0075] According to a preferred embodiment, a sparse matrix multiplication operation plus operator function interface is provided, in which the user specifies the execution logic of the plus operator in the generalized sparse matrix multiplication operation, and is configured as a minimum operation in the single-source shortest path graph algorithm, indicating that a path with the shortest distance to the source node is selected.

[0076] According to a preferred embodiment, in the execution phase post-processing interface function, the user specifies the post-processing operation on the result of the sparse matrix multiplication operation, which is configured as a no-operation in the single-source shortest path graph algorithm and does not require additional post-processing.

[0077] According to a preferred implementation, the graph attribute function interface is updated, and the user specifies the execution logic for updating the graph attribute information by the result of the sparse matrix multiplication operation. The single-source shortest path graph algorithm is configured to take the minimum operation, which represents the minimum value of the calculated shortest distance and the shortest distance previously calculated for the node as the shortest distance of the node from the source node.

[0078] According to a preferred implementation, the activation node setting function interface is used, and the user specifies the judgment logic for setting the next round of iterative activation node according to the update of the graph attribute information. The nodes configured for distance attribute update in the single-source shortest path graph algorithm are activated.

[0079] According to a preferred implementation, a graph application iteration end judgment function interface is used, in which the user specifies the judgment logic for the end of the graph application algorithm iteration, and the single-source shortest path graph algorithm is configured to have the number of activated nodes be zero, indicating that the distance attributes of all nodes have been updated.

[0080] The present invention also provides a sparse matrix operation programming device based on data flow, which is oriented to graph applications in the fields of graph computing, graph pattern matching and graph neural network, and includes the following modules:

[0081] Preprocessing module: constructs the input data structure required for matrix operations according to the input graph data and the algorithm logic of the target graph application, and performs preprocessing operations; the target graph application refers to a specific graph application that the developer needs to implement;

[0082] Matrix operation module: selects and performs sparse matrix multiplication operations based on the data size, sparsity and input data structure type of the input graph;

[0083] Post-processing module: perform post-processing operations on the calculation results of the sparse matrix multiplication operation, and update the post-processed calculation results to the attribute information of the graph;

[0084] Result recording module: Iterate the preprocessing module, matrix operation module and post-processing module according to the algorithm characteristics of the target graph application. When the convergence condition or number of iterations specified by the target graph application is met, the operation result of the target graph application is recorded in the attribute information of the graph; the convergence condition or number of iterations is specified by the user implementation of the graph application iteration end judgment function interface.

[0085] like Figure 5 As shown, an electronic device is also provided, including:

[0086] one or more processors;

[0087] A memory for storing one or more programs;

[0088] When the one or more programs are executed by the one or more processors, the one or more processors implement the data flow-based sparse matrix operation programming method.

[0089] And a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the data flow-based sparse matrix operation programming method.

[0090] It should be noted that the above-mentioned specific embodiments are exemplary, and those skilled in the art can come up with various solutions inspired by the disclosure of the present invention, and these solutions also belong to the disclosure scope of the present invention and fall within the protection scope of the present invention. Those skilled in the art should understand that the present invention specification and its drawings are illustrative and do not constitute a limitation on the claims. The scope of protection of the present invention is defined by the claims and their equivalents. The present invention specification contains multiple inventive concepts, such as "preferably", "according to a preferred embodiment" or "optionally", all of which indicate that the corresponding paragraph discloses an independent concept, and the applicant reserves the right to file a divisional application based on each inventive concept.

Claims

1. A sparse matrix operation programming method based on data flow, It is characterized in that This method is aimed at graph applications in the fields of graph computing, graph pattern matching, and graph neural networks, and includes the following steps: (1) Construct the input data structure required for matrix operations based on the input graph data and the algorithm logic of the target graph application, and perform preprocessing operations; the target graph application refers to a specific graph application that the developer needs to implement; specifically, the following sub-steps are included: (1.1) Based on the input graph topology data, a user implementation of the graph topology sparse matrix construction interface is used to construct a sparse matrix corresponding to the graph topology structure, namely, a graph topology sparse matrix; when constructing the sparse matrix, the nodes of the graph are converted into rows and columns of the matrix, and the edges are converted into non-zero elements of the matrix; the data format of the sparse matrix includes a coordinate tuple, a compressed sparse row, and a compressed sparse column; starting from the second iteration, the graph topology sparse matrix constructed by the input graph data in the first iteration needs to be used again; (1.2) Construct an attribute vector / attribute matrix based on the current graph attribute information, the status of activated nodes, and the sparsity. According to the additional input data of the target graph application, the calculation results of the target graph application, and the algorithm characteristics of the graph application, use the graph attribute information to construct the user implementation of the function interface and construct the data structure corresponding to the graph attribute information. According to the characteristics of the graph application, each category of graph attribute information contains zero or more graph attribute information. According to the number of graph attribute information and the data dimension of the attribute information, construct the graph attribute information as a vector / matrix. The data structure corresponding to the graph attribute information is only constructed and initialized in the first iteration of the graph application, and only the data therein will be updated and replaced in subsequent iterations. (1.3) Combining the current graph attribute information and activated nodes, using the user implementation of the message construction function interface, construct a message vector / message matrix; the graph attribute information is the data structure corresponding to the graph attribute information constructed in step (1.2); according to the data dimension of the attribute information, choose to construct a message vector / message matrix, and choose to construct a sparse vector / matrix or a dense vector / matrix according to the proportion of the number of activated nodes; (1.4) When the target graph application has restrictions on the nodes or edges involved in the calculation in the input graph, combined with the message vector / message matrix constructed in step (1.3), the user implementation of the execution phase preprocessing function interface is used to perform data preprocessing operations on the graph topology sparse matrix and message vector / message matrix, that is, to select and filter the rows and columns of the sparse matrix; (1.5) Packing the graph topology sparse matrix and the message vector / message matrix iteratively constructed in step (1.3), and adding them as an execution task to the task scheduling execution queue; the task scheduling execution queue is a system structure for scheduling and dispatching the packed graph topology sparse matrix and message vector / message matrix, and the structure is implemented using the computer hardware architecture and programming environment used by the system framework to achieve the purpose of scheduling the execution task to the hardware computing unit for execution; (2) Select and perform sparse matrix multiplication operations based on the data size, sparsity, and input data structure type of the input graph; specifically, the following sub-steps are included: (2.1) Obtain the graph topology sparse matrix and message vector / message matrix that need to be calculated from the task scheduling execution queue; (2.2) According to the storage format and sparsity of the graph topology sparse matrix, the data structure type of the message vector / message matrix, the data scale of the attribute matrix and vector data structure, and the underlying hardware architecture information used by the system framework, select the corresponding operator implementation of the generalized sparse matrix multiplication operation; (2.3) using the operator implementation of the generalized sparse matrix multiplication operation selected in step (2.2), and then using the graph topology sparse matrix and message vector / message matrix obtained in step (2.1) as inputs of the operator, to perform the sparse matrix multiplication operation; (3) Perform post-processing on the calculation results of the sparse matrix multiplication operation, and update the post-processed calculation results to the attribute information of the graph; (4) Iterate steps (1) to (3) according to the algorithmic features of the target graph application. When the convergence condition or the number of iterations specified by the target graph application is met, the operation result of the target graph application is recorded in the attribute information of the graph. The convergence condition or the number of iterations is specified by the user implementation of the graph application iteration end judgment function interface.

2. A sparse matrix operation programming method based on data flow according to claim 1, It is characterized in that In the step (1.1), the graph topology data is a file, and each line of the file records an edge of the graph, including the start node number and the end node number of the edge and the weight information of the edge.

3. A sparse matrix operation programming method based on data flow according to claim 1, It is characterized in that The graph attribute information in step (1.2) includes three categories: node attribute information, edge attribute information and graph global attribute information, which are respectively bound to each node, each edge or the entire graph of the input graph.

4. The data flow-based sparse matrix operation programming method according to claim 1, It is characterized in that The activated nodes in the step (1.3) are nodes whose node attribute information or edge attribute information connected to the nodes in the current iteration round of the graph application has changed compared with the previous iteration round, wherein the activated nodes are set according to the characteristics of the target graph application and user input in the initial iteration; or the activated nodes are specified by the algorithm logic of the graph application or by the user as input of the graph application and remain unchanged during the iteration process; and the message vector / message matrix is ​​usually directly constructed from part or all of the attribute information of the activated node, or is obtained after conversion based on the attribute information of the activated node in combination with the algorithm logic of the graph application.

5. The data flow-based sparse matrix operation programming method according to claim 1, It is characterized in that The step (3) comprises the following steps: (3.1) Based on the algorithmic features of the target graph application, when it is necessary to calculate or transform the result vector / matrix of the sparse matrix multiplication operation, the user implementation of the post-processing function interface of the execution phase is used to perform the corresponding post-processing operation on the result vector / matrix; (3.2) According to the algorithm logic of the target graph application, use the user implementation of the graph attribute update function interface to update the result vector / result matrix after the post-processing operation in step (3.1) to the data structure corresponding to the graph attribute information. Specifically, update the data in the result vector / result matrix to the node attribute, edge attribute or graph global attribute specified by the user according to its row and column position and the update condition specified by the graph application; (3.3) According to the updated status of the graph attributes and the algorithmic features of the target graph application, the activation nodes in the next iteration of the graph are set using the user implementation of the activation node setting function interface; specifically, when the activation node is specified by the algorithmic logic of the graph application or by direct user input, the activation node for the next iteration remains unchanged; otherwise, the node whose node attribute information corresponding to the node or the edge attribute information connected to the node is updated in step (3.2) is used as the activation node for the next iteration.

6. A sparse matrix operation programming device based on data flow, It is characterized in that The device is aimed at graph applications in the fields of graph computing, graph pattern matching, and graph neural networks, and includes the following modules: Preprocessing module: constructs the input data structure required for matrix operations based on the input graph data and the algorithm logic of the target graph application, and performs preprocessing operations; the target graph application refers to a specific graph application that the developer needs to implement; specifically: According to the input graph topology data, a sparse matrix corresponding to the graph topology structure, i.e., a graph topology sparse matrix, is constructed using a user implementation of a graph topology sparse matrix construction interface; when constructing the sparse matrix, the nodes of the graph are converted into rows and columns of the matrix, and the edges are converted into non-zero elements of the matrix; the data format of the sparse matrix includes a coordinate tuple, a compressed sparse row, and a compressed sparse column; starting from the second iteration, the graph topology sparse matrix constructed by the input graph data in the first iteration needs to be used again; Build an attribute vector / attribute matrix based on the current graph attribute information, the status of activated nodes, and the sparsity. Build a user implementation of the function interface using the graph attribute information according to the additional input data of the target graph application, the calculation results of the target graph application, and the algorithm characteristics of the graph application, and build a data structure corresponding to the graph attribute information. According to the characteristics of the graph application, each category of graph attribute information contains zero or more graph attribute information. According to the number of graph attribute information and the data dimension of the attribute information, build the graph attribute information into a vector / matrix. The data structure corresponding to the graph attribute information is only built and initialized in the first iteration of the graph application, and only the data therein will be updated and replaced in subsequent iterations. Combine the current graph attribute information and activated nodes, and use the user implementation of the message construction function interface to construct a message vector / message matrix; the graph attribute information is the data structure corresponding to the constructed graph attribute information; according to the data dimension of the attribute information, choose to construct a message vector / message matrix, and choose to construct a sparse vector / matrix or a dense vector / matrix according to the proportion of the number of activated nodes; When the target graph application has restrictions on the nodes or edges involved in the calculation in the input graph, combined with the message vector / message matrix constructed in step (1.3), the user implementation of the execution phase preprocessing function interface is used to perform data preprocessing operations on the graph topology sparse matrix and message vector / message matrix, that is, to select and filter the rows and columns of the sparse matrix; Packing the graph topology sparse matrix and the iteratively constructed message vector / message matrix, and adding them as an execution task to the task scheduling execution queue; the task scheduling execution queue is a system structure for scheduling and dispatching the packed graph topology sparse matrix and message vector / message matrix, and the structure is implemented using the computer hardware architecture and programming environment used by the system framework to achieve the purpose of scheduling the execution task to the hardware computing unit for execution; Matrix operation module: selects and performs sparse matrix multiplication operations based on the data size, sparsity and input data structure type of the input graph; specifically: Obtain the graph topology sparse matrix and message vector / message matrix that need to be calculated from the task scheduling execution queue; According to the storage format and sparsity of the graph topology sparse matrix, the data structure type of the message vector / message matrix, the attribute matrix, the data scale of the vector data structure, and the underlying hardware architecture information used by the system framework, the corresponding operator implementation of the generalized sparse matrix multiplication operation is selected; Using the selected operator implementation of the generalized sparse matrix multiplication operation, and then taking the obtained graph topology sparse matrix and the message vector / message matrix as the input of the operator, the sparse matrix multiplication operation is performed; Post-processing module: perform post-processing operations on the calculation results of the sparse matrix multiplication operation, and update the post-processed calculation results to the attribute information of the graph; Result recording module: Iterate the preprocessing module, matrix operation module and post-processing module according to the algorithm characteristics of the target graph application. When the convergence condition or number of iterations specified by the target graph application is met, the operation result of the target graph application is recorded in the attribute information of the graph; the convergence condition or number of iterations is specified by the user implementation of the graph application iteration end judgment function interface.

7. An electronic device, It is characterized in that include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the data flow-based sparse matrix operation programming method as described in any one of claims 1 to 5.

8. A computer-readable storage medium having computer instructions stored thereon, It is characterized in that When the instruction is executed by the processor, the steps of the data flow-based sparse matrix operation programming method as described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Method optimizing sparse matrix vector multiplication to improve incompressible pipe flow simulation efficiency

    CN103984527A

  • Wireless network data missing attribute recovery method and device based on graph neural network

    CN113194493A

  • Parallel processing method and device for optimizing sparse matrix-vector multiplication

    CN113360188A

  • Sparse dense matrix multiplication array with high multiplier utilization rate of graph neural network based on FPGA (Field Programmable Gate Array)

    CN114860192A

  • Node classification method based on mixed regular graph neural network

    CN116484073A