Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-sparse
Commits
468aea5b
Unverified
Commit
468aea5b
authored
Jun 23, 2020
by
Matthias Fey
Committed by
GitHub
Jun 23, 2020
Browse files
Merge pull request #68 from james77777778/master
Fixed the bug from metis if num_parts == 1
parents
6884191b
eb8c2ec0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
test/test_metis.py
test/test_metis.py
+5
-0
torch_sparse/metis.py
torch_sparse/metis.py
+7
-0
No files found.
test/test_metis.py
View file @
468aea5b
...
...
@@ -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
torch_sparse/metis.py
View file @
468aea5b
...
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment