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
1e959269
Commit
1e959269
authored
Apr 12, 2020
by
bowendeng
Browse files
fix for unweighted graph partition
parent
49e0a6d6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
9 deletions
+5
-9
csrc/cpu/metis_cpu.cpp
csrc/cpu/metis_cpu.cpp
+2
-6
csrc/cpu/metis_cpu.h
csrc/cpu/metis_cpu.h
+1
-1
torch_sparse/metis.py
torch_sparse/metis.py
+2
-2
No files found.
csrc/cpu/metis_cpu.cpp
View file @
1e959269
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
#include "utils.h"
#include "utils.h"
torch
::
Tensor
partition_cpu
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
int64_t
num_parts
,
torch
::
Tensor
partition_cpu
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
int64_t
num_parts
,
torch
::
optional
<
torch
::
Tensor
>
edge_wgt
,
bool
recursive
)
{
torch
::
Tensor
edge_wgt
,
bool
recursive
)
{
#ifdef WITH_METIS
#ifdef WITH_METIS
CHECK_CPU
(
rowptr
);
CHECK_CPU
(
rowptr
);
CHECK_CPU
(
col
);
CHECK_CPU
(
col
);
...
@@ -17,11 +17,7 @@ torch::Tensor partition_cpu(torch::Tensor rowptr, torch::Tensor col,int64_t num_
...
@@ -17,11 +17,7 @@ torch::Tensor partition_cpu(torch::Tensor rowptr, torch::Tensor col,int64_t num_
auto
*
xadj
=
rowptr
.
data_ptr
<
int64_t
>
();
auto
*
xadj
=
rowptr
.
data_ptr
<
int64_t
>
();
auto
*
adjncy
=
col
.
data_ptr
<
int64_t
>
();
auto
*
adjncy
=
col
.
data_ptr
<
int64_t
>
();
if
(
edge_wgt
==
nullptr
){
adjwgt
=
nullptr
}
else
{
auto
*
adjwgt
=
edge_wgt
.
data_ptr
<
int64_t
>
();
auto
*
adjwgt
=
edge_wgt
.
data_ptr
<
int64_t
>
();
}
int64_t
ncon
=
1
;
int64_t
ncon
=
1
;
int64_t
objval
=
-
1
;
int64_t
objval
=
-
1
;
...
...
csrc/cpu/metis_cpu.h
View file @
1e959269
...
@@ -3,5 +3,5 @@
...
@@ -3,5 +3,5 @@
#include <torch/extension.h>
#include <torch/extension.h>
torch
::
Tensor
partition_cpu
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
torch
::
Tensor
partition_cpu
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
int64_t
num_parts
,
torch
::
optional
<
torch
::
Tensor
>
edge_wgt
,
int64_t
num_parts
,
torch
::
Tensor
edge_wgt
,
bool
recursive
);
bool
recursive
);
torch_sparse/metis.py
View file @
1e959269
...
@@ -7,11 +7,11 @@ from torch_sparse.utils import cartesian1d
...
@@ -7,11 +7,11 @@ from torch_sparse.utils import cartesian1d
def
metis_wgt
(
x
):
def
metis_wgt
(
x
):
if
len
(
x
.
unique
())
==
1
:
return
None
t1
,
t2
=
cartesian1d
(
x
,
x
)
t1
,
t2
=
cartesian1d
(
x
,
x
)
diff
=
t1
-
t2
diff
=
t1
-
t2
diff
=
diff
[
diff
!=
0
]
diff
=
diff
[
diff
!=
0
]
if
len
(
diff
)
==
0
:
return
x
.
long
()
res
=
diff
.
abs
().
min
()
res
=
diff
.
abs
().
min
()
bod
=
x
.
max
()
-
x
.
min
()
bod
=
x
.
max
()
-
x
.
min
()
scale
=
(
res
/
bod
).
item
()
scale
=
(
res
/
bod
).
item
()
...
...
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