Skip to content

Commit

Permalink
remove nn folders
Browse files Browse the repository at this point in the history
  • Loading branch information
tingyu66 committed Jan 14, 2025
1 parent 6c0fc07 commit ac58c90
Show file tree
Hide file tree
Showing 29 changed files with 2 additions and 4,099 deletions.
109 changes: 0 additions & 109 deletions python/cugraph-dgl/cugraph_dgl/nn/conv/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,112 +277,3 @@ def to(self, device: Union[torch.device, str, int]) -> "cugraph_dgl.nn.SparseGra
)

return sg


def conditional_class(import_name):
def decorator(cls):
try:
__import__(import_name)
return cls
except ImportError:
return None

return decorator


@conditional_class("pylibcugraphops")
class BaseConv(torch.nn.Module):
r"""An abstract base class for cugraph-ops nn module."""

def __init__(self):
super().__init__()

def reset_parameters(self):
r"""Resets all learnable parameters of the module."""
raise NotImplementedError

def forward(self, *args):
r"""Runs the forward pass of the module."""
raise NotImplementedError

def get_cugraph_ops_CSC(
self,
g: Union[SparseGraph, dgl.DGLHeteroGraph],
is_bipartite: bool = False,
max_in_degree: Optional[int] = None,
) -> "ops_torch.CSC":
"""Create CSC structure needed by cugraph-ops."""

if not isinstance(g, (SparseGraph, dgl.DGLHeteroGraph)):
raise TypeError(
f"The graph has to be either a 'cugraph_dgl.nn.SparseGraph' or "
f"'dgl.DGLHeteroGraph', but got '{type(g)}'."
)

# TODO: max_in_degree should default to None in pylibcugraphops
if max_in_degree is None:
max_in_degree = -1

if isinstance(g, SparseGraph):
offsets, indices, _ = g.csc()
else:
offsets, indices, _ = g.adj_tensors("csc")

graph = ops_torch.CSC(
offsets=offsets,
indices=indices,
num_src_nodes=g.num_src_nodes(),
dst_max_in_degree=max_in_degree,
is_bipartite=is_bipartite,
)

return graph

def get_cugraph_ops_HeteroCSC(
self,
g: Union[SparseGraph, dgl.DGLHeteroGraph],
num_edge_types: int,
etypes: Optional[torch.Tensor] = None,
is_bipartite: bool = False,
max_in_degree: Optional[int] = None,
) -> "ops_torch.HeteroCSC":
"""Create HeteroCSC structure needed by cugraph-ops."""

if not isinstance(g, (SparseGraph, dgl.DGLHeteroGraph)):
raise TypeError(
f"The graph has to be either a 'cugraph_dgl.nn.SparseGraph' or "
f"'dgl.DGLHeteroGraph', but got '{type(g)}'."
)

# TODO: max_in_degree should default to None in pylibcugraphops
if max_in_degree is None:
max_in_degree = -1

if isinstance(g, SparseGraph):
offsets, indices, etypes = g.csc()
if etypes is None:
raise ValueError(
"SparseGraph must have 'values' to create HeteroCSC. "
"Pass in edge types as 'values' when creating the SparseGraph."
)
etypes = etypes.int()
else:
if etypes is None:
raise ValueError(
"'etypes' is required when creating HeteroCSC "
"from dgl.DGLHeteroGraph."
)
offsets, indices, perm = g.adj_tensors("csc")
etypes = etypes[perm].int()

graph = ops_torch.HeteroCSC(
offsets=offsets,
indices=indices,
edge_types=etypes,
num_src_nodes=g.num_src_nodes(),
num_edge_types=num_edge_types,
dst_max_in_degree=max_in_degree,
is_bipartite=is_bipartite,
)

return graph
Loading

0 comments on commit ac58c90

Please sign in to comment.