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
ab0cee58
Commit
ab0cee58
authored
Apr 11, 2020
by
bwdeng20
Browse files
weighted undirected graph support
parent
a1ae9033
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
5 deletions
+8
-5
csrc/cpu/metis_cpu.cpp
csrc/cpu/metis_cpu.cpp
+5
-3
csrc/cpu/metis_cpu.h
csrc/cpu/metis_cpu.h
+1
-1
torch_sparse/metis.py
torch_sparse/metis.py
+2
-1
No files found.
csrc/cpu/metis_cpu.cpp
View file @
ab0cee58
...
...
@@ -7,7 +7,8 @@
#include "utils.h"
torch
::
Tensor
partition_cpu
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
int64_t
num_parts
,
bool
recursive
)
{
int64_t
num_parts
,
torch
::
Tensor
adjwgt
,
bool
recursive
)
{
#ifdef WITH_METIS
CHECK_CPU
(
rowptr
);
CHECK_CPU
(
col
);
...
...
@@ -17,15 +18,16 @@ torch::Tensor partition_cpu(torch::Tensor rowptr, torch::Tensor col,
auto
*
xadj
=
rowptr
.
data_ptr
<
int64_t
>
();
auto
*
adjncy
=
col
.
data_ptr
<
int64_t
>
();
auto
*
adjwgt
=
adjwgt
.
data_ptr
<
int64_t
>
();
int64_t
ncon
=
1
;
int64_t
objval
=
-
1
;
auto
part_data
=
part
.
data_ptr
<
int64_t
>
();
if
(
recursive
)
{
METIS_PartGraphRecursive
(
&
nvtxs
,
&
ncon
,
xadj
,
adjncy
,
NULL
,
NULL
,
NULL
,
METIS_PartGraphRecursive
(
&
nvtxs
,
&
ncon
,
xadj
,
adjncy
,
NULL
,
NULL
,
adjwgt
,
&
num_parts
,
NULL
,
NULL
,
NULL
,
&
objval
,
part_data
);
}
else
{
METIS_PartGraphKway
(
&
nvtxs
,
&
ncon
,
xadj
,
adjncy
,
NULL
,
NULL
,
NULL
,
METIS_PartGraphKway
(
&
nvtxs
,
&
ncon
,
xadj
,
adjncy
,
NULL
,
NULL
,
adjwgt
,
&
num_parts
,
NULL
,
NULL
,
NULL
,
&
objval
,
part_data
);
}
...
...
csrc/cpu/metis_cpu.h
View file @
ab0cee58
...
...
@@ -3,4 +3,4 @@
#include <torch/extension.h>
torch
::
Tensor
partition_cpu
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
int64_t
num_parts
,
bool
recursive
);
int64_t
num_parts
,
torch
::
Tensor
adjwgt
,
bool
recursive
);
torch_sparse/metis.py
View file @
ab0cee58
...
...
@@ -10,7 +10,8 @@ def partition(
)
->
Tuple
[
SparseTensor
,
torch
.
Tensor
,
torch
.
Tensor
]:
rowptr
,
col
=
src
.
storage
.
rowptr
().
cpu
(),
src
.
storage
.
col
().
cpu
()
cluster
=
torch
.
ops
.
torch_sparse
.
partition
(
rowptr
,
col
,
num_parts
,
adjwgt
=
src
.
storage
.
value
().
cpu
()
cluster
=
torch
.
ops
.
torch_sparse
.
partition
(
rowptr
,
col
,
num_parts
,
adjwgt
,
recursive
)
cluster
=
cluster
.
to
(
src
.
device
())
...
...
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