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-cluster
Commits
28133ff5
Commit
28133ff5
authored
Apr 23, 2020
by
rusty1s
Browse files
cmake build [skip ci]
parent
2a628300
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
0 deletions
+156
-0
CMakeLists.txt
CMakeLists.txt
+74
-0
README.md
README.md
+13
-0
cmake/TorchClusterConfig.cmake.in
cmake/TorchClusterConfig.cmake.in
+38
-0
csrc/cluster.h
csrc/cluster.h
+31
-0
No files found.
CMakeLists.txt
0 → 100644
View file @
28133ff5
cmake_minimum_required
(
VERSION 3.0
)
project
(
torchcluster
)
set
(
CMAKE_CXX_STANDARD 14
)
set
(
TORCHCLUSTER_VERSION 1.5.4
)
option
(
WITH_CUDA
"Enable CUDA support"
OFF
)
if
(
WITH_CUDA
)
enable_language
(
CUDA
)
add_definitions
(
-D__CUDA_NO_HALF_OPERATORS__
)
endif
()
find_package
(
Python3 COMPONENTS Development
)
find_package
(
Torch REQUIRED
)
file
(
GLOB HEADERS csrc/cluster.h
)
file
(
GLOB OPERATOR_SOURCES csrc/cpu/*.h csrc/cpu/*.cpp csrc/*.cpp
)
if
(
WITH_CUDA
)
file
(
GLOB OPERATOR_SOURCES
${
OPERATOR_SOURCES
}
csrc/cuda/*.h csrc/cuda/*.cu
)
endif
()
add_library
(
${
PROJECT_NAME
}
SHARED
${
OPERATOR_SOURCES
}
)
target_link_libraries
(
${
PROJECT_NAME
}
PRIVATE
${
TORCH_LIBRARIES
}
Python3::Python
)
set_target_properties
(
${
PROJECT_NAME
}
PROPERTIES EXPORT_NAME TorchCluster
)
target_include_directories
(
${
PROJECT_NAME
}
INTERFACE
$<BUILD_INTERFACE:
${
HEADERS
}
>
$<INSTALL_INTERFACE:
${
CMAKE_INSTALL_INCLUDEDIR
}
>
)
include
(
GNUInstallDirs
)
include
(
CMakePackageConfigHelpers
)
set
(
TORCHCLUSTER_CMAKECONFIG_INSTALL_DIR
"share/cmake/TorchCluster"
CACHE STRING
"install path for TorchClusterConfig.cmake"
)
configure_package_config_file
(
cmake/TorchClusterConfig.cmake.in
"
${
CMAKE_CURRENT_BINARY_DIR
}
/TorchClusterConfig.cmake"
INSTALL_DESTINATION
${
TORCHCLUSTER_CMAKECONFIG_INSTALL_DIR
}
)
write_basic_package_version_file
(
${
CMAKE_CURRENT_BINARY_DIR
}
/TorchClusterConfigVersion.cmake
VERSION
${
TORCHCLUSTER_VERSION
}
COMPATIBILITY AnyNewerVersion
)
install
(
FILES
${
CMAKE_CURRENT_BINARY_DIR
}
/TorchClusterConfig.cmake
${
CMAKE_CURRENT_BINARY_DIR
}
/TorchClusterConfigVersion.cmake
DESTINATION
${
TORCHCLUSTER_CMAKECONFIG_INSTALL_DIR
}
)
install
(
TARGETS
${
PROJECT_NAME
}
EXPORT TorchClusterTargets
LIBRARY DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
)
install
(
EXPORT TorchClusterTargets
NAMESPACE TorchCluster::
DESTINATION
${
TORCHCLUSTER_CMAKECONFIG_INSTALL_DIR
}
)
install
(
FILES
${
HEADERS
}
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/
${
PROJECT_NAME
}
)
install
(
FILES
csrc/cpu/fps_cpu.h
csrc/cpu/graclus_cpu.h
csrc/cpu/grid_cpu.h
csrc/cpu/rw_cpu.h
csrc/cpu/sampler_cpu.h
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/
${
PROJECT_NAME
}
/cpu
)
if
(
WITH_CUDA
)
install
(
FILES
csrc/cuda/fps_cuda.h
csrc/cuda/graclus_cuda.h
csrc/cuda/grid_cuda.h
csrc/cuda/knn_cuda.h
csrc/cuda/nearest_cuda.h
csrc/cuda/radius_cuda.h
csrc/cuda/rw_cuda.h
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/
${
PROJECT_NAME
}
/cuda
)
endif
()
README.md
View file @
28133ff5
...
@@ -241,3 +241,16 @@ tensor([[0, 1, 2, 4],
...
@@ -241,3 +241,16 @@ tensor([[0, 1, 2, 4],
```
```
python setup.py test
python setup.py test
```
```
## C++ API
`torch-cluster`
also offers a C++ API that contains C++ equivalent of python models.
```
mkdir build
cd build
# Add -DWITH_CUDA=on support for the CUDA if needed
cmake ..
make
make install
```
cmake/TorchClusterConfig.cmake.in
0 → 100644
View file @
28133ff5
# TorchClusterConfig.cmake
# --------------------
#
# Exported targets:: Cluster
#
@PACKAGE_INIT@
set(PN TorchCluster)
set(${PN}_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@")
set(${PN}_LIBRARY "")
set(${PN}_DEFINITIONS USING_${PN})
check_required_components(${PN})
if(NOT (CMAKE_VERSION VERSION_LESS 3.0))
#-----------------------------------------------------------------------------
# Don't include targets if this file is being picked up by another
# project which has already built this as a subproject
#-----------------------------------------------------------------------------
if(NOT TARGET ${PN}::TorchCluster)
include("${CMAKE_CURRENT_LIST_DIR}/${PN}Targets.cmake")
if(NOT TARGET torch_library)
find_package(Torch REQUIRED)
endif()
if(NOT TARGET Python3::Python)
find_package(Python3 COMPONENTS Development)
endif()
target_link_libraries(TorchCluster::TorchCluster INTERFACE ${TORCH_LIBRARIES} Python3::Python)
if(@WITH_CUDA@)
target_compile_definitions(TorchCluster::TorchCluster INTERFACE WITH_CUDA)
endif()
endif()
endif()
csrc/cluster.h
0 → 100644
View file @
28133ff5
#pragma once
#include <torch/extension.h>
int64_t
cuda_version
();
torch
::
Tensor
fps
(
torch
::
Tensor
src
,
torch
::
Tensor
ptr
,
double
ratio
,
bool
random_start
);
torch
::
Tensor
graclus
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
torch
::
optional
<
torch
::
Tensor
>
optional_weight
);
torch
::
Tensor
grid
(
torch
::
Tensor
pos
,
torch
::
Tensor
size
,
torch
::
optional
<
torch
::
Tensor
>
optional_start
,
torch
::
optional
<
torch
::
Tensor
>
optional_end
);
torch
::
Tensor
knn
(
torch
::
Tensor
x
,
torch
::
Tensor
y
,
torch
::
Tensor
ptr_x
,
torch
::
Tensor
ptr_y
,
int64_t
k
,
bool
cosine
);
torch
::
Tensor
nearest
(
torch
::
Tensor
x
,
torch
::
Tensor
y
,
torch
::
Tensor
ptr_x
,
torch
::
Tensor
ptr_y
);
torch
::
Tensor
radius
(
torch
::
Tensor
x
,
torch
::
Tensor
y
,
torch
::
Tensor
ptr_x
,
torch
::
Tensor
ptr_y
,
double
r
,
int64_t
max_num_neighbors
);
torch
::
Tensor
random_walk
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
torch
::
Tensor
start
,
int64_t
walk_length
,
double
p
,
double
q
);
torch
::
Tensor
neighbor_sampler
(
torch
::
Tensor
start
,
torch
::
Tensor
rowptr
,
int64_t
count
,
double
factor
);
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