Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/test_metis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ def test_metis(device):
weighted=False)
assert partptr.numel() == 3
assert perm.numel() == 6

_, partptr, perm = mat.partition(num_parts=1, recursive=False,
weighted=True)
assert partptr.numel() == 2
assert perm.numel() == 6
7 changes: 7 additions & 0 deletions torch_sparse/metis.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ def weight2metis(weight: torch.Tensor) -> Optional[torch.Tensor]:
def partition(src: SparseTensor, num_parts: int, recursive: bool = False,
weighted=False
) -> Tuple[SparseTensor, torch.Tensor, torch.Tensor]:

assert num_parts >= 1
if num_parts == 1:
partptr = torch.tensor([0, src.size(0)], device=src.device())
perm = torch.arange(src.size(0), device=src.device())
return src, partptr, perm

rowptr, col, value = src.csr()
rowptr, col = rowptr.cpu(), col.cpu()

Expand Down