Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BTS-MTGNN
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhlj
BTS-MTGNN
Commits
23c66289
Commit
23c66289
authored
Dec 22, 2023
by
Onlynagesha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds LDG graph partitioning algorithm
parent
8768fe6f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
3 deletions
+68
-3
.gitignore
+4
-0
.gitmodules
+3
-0
CMakeLists.txt
+14
-1
csrc/export.cpp
+3
-0
csrc/include/partition.h
+9
-2
csrc/partition/neighbor_clustering
+1
-0
csrc/partition/neighbor_clustering.cpp
+34
-0
No files found.
.gitignore
View file @
23c66289
...
...
@@ -26,6 +26,10 @@ share/python-wheels/
*.egg
MANIFEST
# IDE temporary files (generated by IDEs like CLion, etc.)
.idea/
cmake-build-*/
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
...
...
.gitmodules
0 → 100644
View file @
23c66289
[submodule "csrc/partition/neighbor_clustering"]
path = csrc/partition/neighbor_clustering
url = https://gitee.com/onlynagesha/graph-partition-v4
CMakeLists.txt
View file @
23c66289
...
...
@@ -6,6 +6,7 @@ option(WITH_PYTHON "Link to Python when building" ON)
option
(
WITH_CUDA
"Link to CUDA when building"
ON
)
option
(
WITH_METIS
"Link to METIS when building"
ON
)
option
(
WITH_MTMETIS
"Link to multi-threaded METIS when building"
ON
)
option
(
WITH_LDG
"Link to (multi-threaded optionally) LDG when building"
ON
)
set
(
CMAKE_CXX_STANDARD 17
)
set
(
CMAKE_CXX_STANDARD_REQUIRED ON
)
...
...
@@ -54,7 +55,8 @@ if(WITH_METIS)
include_directories
(
${
METIS_INCLUDE_DIRS
}
)
add_library
(
metis SHARED
"csrc/partition/metis.cpp"
)
add_library
(
metis SHARED
"csrc/partition/metis.cpp"
csrc/partition/neighbor_clustering.cpp
)
target_link_libraries
(
metis PRIVATE
${
TORCH_LIBRARIES
}
)
target_link_libraries
(
metis PRIVATE
${
GKLIB_LIBRARIES
}
)
target_link_libraries
(
metis PRIVATE
${
METIS_LIBRARIES
}
)
...
...
@@ -78,6 +80,11 @@ if(WITH_MTMETIS)
target_compile_definitions
(
mtmetis PRIVATE -DMTMETIS_64BIT_PARTITIONS
)
endif
()
if
(
WITH_LDG
)
# Imports neighbor-clustering based (e.g. LDG algorithm) graph partitioning implementation
add_subdirectory
(
./csrc/partition/neighbor_clustering
)
endif
()
include_directories
(
"csrc/include"
)
add_library
(
${
PROJECT_NAME
}
SHARED csrc/export.cpp
)
...
...
@@ -94,13 +101,19 @@ if (WITH_CUDA)
endif
()
if
(
WITH_METIS
)
message
(
STATUS
"Current project '
${
PROJECT_NAME
}
' uses METIS graph partitioning algorithm."
)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE metis
)
endif
()
if
(
WITH_MTMETIS
)
message
(
STATUS
"Current project '
${
PROJECT_NAME
}
' uses multi-threaded METIS graph partitioning algorithm."
)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE mtmetis
)
endif
()
if
(
WITH_LDG
)
message
(
STATUS
"Current project '
${
PROJECT_NAME
}
' uses LDG graph partitioning algorithm."
)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE ldg-vertex-partition
)
endif
()
# add libsampler.so
set
(
SAMLPER_NAME
"
${
PROJECT_NAME
}
_sampler"
)
...
...
csrc/export.cpp
View file @
23c66289
...
...
@@ -12,6 +12,9 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m
.
def
(
"metis_partition"
,
&
metis_partition
,
"metis graph partition"
);
m
.
def
(
"mt_metis_partition"
,
&
mt_metis_partition
,
"multi-threaded metis graph partition"
);
// Note: the switch WITH_MULTITHREADING=ON shall be triggered during compilation
// to enable multi-threading functionality.
m
.
def
(
"ldg_partition"
,
&
ldg_partition
,
"(multi-threaded optionally) LDG graph partition"
);
py
::
enum_
<
cudaMemoryAdvise
>
(
m
,
"cudaMemoryAdvise"
)
.
value
(
"cudaMemAdviseSetAccessedBy"
,
cudaMemoryAdvise
::
cudaMemAdviseSetAccessedBy
)
...
...
csrc/include/partition.h
View file @
23c66289
...
...
@@ -21,4 +21,12 @@ at::Tensor mt_metis_partition(
int64_t
num_parts
,
int64_t
num_workers
,
bool
recursive
);
\ No newline at end of file
);
at
::
Tensor
ldg_partition
(
at
::
Tensor
edges
,
at
::
optional
<
at
::
Tensor
>
vertex_weights
,
at
::
optional
<
at
::
Tensor
>
initial_partition
,
int64_t
num_parts
,
int64_t
num_workers
);
neighbor_clustering
@
5e8dd2eb
Subproject commit 5e8dd2ebda4b0e3b3dec8f43c8ced67785646eef
csrc/partition/neighbor_clustering.cpp
0 → 100644
View file @
23c66289
#include "neighbor_clustering/vertex_partition/vertex_partition.h"
#include "neighbor_clustering/vertex_partition/params.h"
at
::
Tensor
ldg_partition
(
at
::
Tensor
edges
,
at
::
optional
<
at
::
Tensor
>
vertex_weights
,
at
::
optional
<
at
::
Tensor
>
initial_partition
,
int64_t
num_parts
,
int64_t
num_workers
)
{
AT_ASSERT
(
edges
.
dim
()
==
2
);
auto
edges_n_cols
=
edges
.
size
(
1
);
AT_ASSERT
(
edges_n_cols
>=
2
&&
edges_n_cols
<=
3
);
// Note: other checks are performed in the implementation of vp::ldg_partition function series.
auto
n
=
edges
.
slice
(
1
,
0
,
2
).
max
().
item
<
int64_t
>
()
+
1
;
auto
params
=
vp
::
LDGParams
{.
N
=
n
,
.
K
=
num_parts
,
.
openmp_n_threads
=
static_cast
<
int
>
(
num_workers
)};
auto
edges_clone
=
edges
.
clone
();
if
(
vertex_weights
.
has_value
())
{
auto
vertex_weights_clone
=
vertex_weights
->
clone
();
if
(
initial_partition
.
has_value
())
{
auto
initial_partition_clone
=
initial_partition
->
clone
();
return
vp
::
ldg_partition_v_init
(
edges_clone
,
vertex_weights_clone
,
initial_partition_clone
,
params
);
}
else
{
return
vp
::
ldg_partition_v
(
edges_clone
,
vertex_weights_clone
,
params
);
}
}
else
{
if
(
initial_partition
.
has_value
())
{
auto
initial_partition_clone
=
initial_partition
->
clone
();
return
vp
::
ldg_partition_init
(
edges_clone
,
initial_partition_clone
,
params
);
}
else
{
return
vp
::
ldg_partition
(
edges_clone
,
params
);
}
}
}
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