pylibcugraphops.make_csc_hg#

pylibcugraphops.make_csc_hg = <nanobind.nb_func object>#

Creates a heterogenous Full-Graph representation using CSR from the graph structure tensors.

make_csc_csc_hg(
    offsets: device array, indices: device array, n_node_types: int,
    n_edge_types: int, node_types: device array, edge_types: device array,
    map_csc_to_coo: Optional[device array]
) -> pylibcugraphops.fg_csc_hg_int[32|64]
Parameters:
offsetsdevice array type

Monotonically increasing array with each location pointing to the start offset of the neighborhood of that node in the indices. Shape: (n_dst_nodes + 1, ).

indicesdevice array type

Contains the adjacency lists of all the out nodes. Shape: (n_indices, ).

n_node_typesint

Number of node types in the graph.

n_edge_typesint

Number of edge types in the graph.

node_typesdevice array type

Node types of each node in the graph. Shape: (n_dst_nodes, ).

edge_typesdevice array type

Edge types of each edge in the graph. Follows the same indexing as indices. Shape: (n_indices, ).

map_csc_to_coodevice array type | None

Contains edge feature indices for each of the above edge, pointing to that row in the edge embedding table. This can be used to avoid having to reorder edge features when we sort edges while creating CSR, or apply other transformations on the graph structure. Shape: (n_indices, ) if set.

Returns:
FG

An opaque python object representing the FG to be used in aggregators.

Examples

>>> import cupy
>>> from pylibcugraphops import make_csc_csc_hg
...
>>> cupy.random.seed(0)
>>> n_dst_nodes = 15
>>> avg_deg = 5
>>> fg_dtype = cupy.int32
>>> # use any distribution to generate n_edges (with non-negative values)
>>> n_edges = cupy.random.randint(0, 2 * avg_degree, n_dst_nodes, dtype=fg_dtype)
>>> offsets = cupy.zeros(n_dst_nodes+1, dtype=fg_dtype)
>>> offsets[1:] = cupy.cumsum(n_edges)
>>> indices = cupy.random.randint(0, n_dst_nodes, offsets[-1].item(), dtype=fg_dtype)
...
>>> n_node_types = 3
>>> n_edge_types = 7
>>> node_types = cupy.random.randint(0, n_node_types, n_dst_nodes, dtype=cupy.int32)
>>> edge_types = cupy.random.randint(0, n_edge_types, indices.shape[0], dtype=cupy.int32)
>>>
>>> graph = make_csc_csc_hg(offsets, indices, n_node_types, n_edge_types, node_types, edge_types)
>>> # call aggregator with `graph` here