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
4ad2b395
Commit
4ad2b395
authored
Feb 23, 2021
by
rusty1s
Browse files
build separate cpu and cuda images
parent
2ce0f235
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
97 additions
and
79 deletions
+97
-79
.travis.yml
.travis.yml
+8
-7
CMakeLists.txt
CMakeLists.txt
+1
-1
csrc/fps.cpp
csrc/fps.cpp
+5
-1
csrc/graclus.cpp
csrc/graclus.cpp
+5
-1
csrc/grid.cpp
csrc/grid.cpp
+5
-1
csrc/knn.cpp
csrc/knn.cpp
+5
-1
csrc/nearest.cpp
csrc/nearest.cpp
+5
-1
csrc/radius.cpp
csrc/radius.cpp
+5
-1
csrc/rw.cpp
csrc/rw.cpp
+5
-1
csrc/sampler.cpp
csrc/sampler.cpp
+5
-1
csrc/version.cpp
csrc/version.cpp
+5
-1
script/cuda.sh
script/cuda.sh
+1
-1
script/rename_wheel.py
script/rename_wheel.py
+0
-24
setup.cfg
setup.cfg
+1
-1
setup.py
setup.py
+36
-33
torch_cluster/__init__.py
torch_cluster/__init__.py
+5
-3
No files found.
.travis.yml
View file @
4ad2b395
...
...
@@ -110,25 +110,26 @@ install:
-
source activate test
-
conda install pytorch=${TORCH_VERSION} ${TOOLKIT} -c pytorch --yes
-
source script/torch.sh
-
pip install flake8 codecov
-
pip install flake8
-
pip install codecov
-
pip install scipy==1.4.1
-
python setup.py
install
-
python setup.py
.[test]
script
:
-
flake8 .
-
python setup.py test
after_success
:
-
python setup.py bdist_wheel --dist-dir=dist
/torch-${TORCH_VERSION}
-
python script/rename_wheel.py ${IDX}
-
python setup.py bdist_wheel --dist-dir=dist
-
ls -lah dist/
-
codecov
deploy
:
provider
:
s3
edge
:
true
region
:
eu-central-1
edge
:
true
access_key_id
:
${S3_ACCESS_KEY}
secret_access_key
:
${S3_SECRET_ACCESS_KEY}
bucket
:
pytorch-geometric.com
local_dir
:
dist
/torch-${TORCH_VERSION}
upload_dir
:
whl/torch-${TORCH_VERSION}
local_dir
:
dist
upload_dir
:
whl/torch-${TORCH_VERSION}
+${IDX}
acl
:
public_read
on
:
all_branches
:
true
...
...
CMakeLists.txt
View file @
4ad2b395
cmake_minimum_required
(
VERSION 3.0
)
project
(
torchcluster
)
set
(
CMAKE_CXX_STANDARD 14
)
set
(
TORCHCLUSTER_VERSION 1.5.
8
)
set
(
TORCHCLUSTER_VERSION 1.5.
9
)
option
(
WITH_CUDA
"Enable CUDA support"
OFF
)
...
...
csrc/fps.cpp
View file @
4ad2b395
...
...
@@ -8,7 +8,11 @@
#endif
#ifdef _WIN32
PyMODINIT_FUNC
PyInit__fps
(
void
)
{
return
NULL
;
}
#ifdef WITH_CUDA
PyMODINIT_FUNC
PyInit__fps_cuda
(
void
)
{
return
NULL
;
}
#else
PyMODINIT_FUNC
PyInit__fps_cpu
(
void
)
{
return
NULL
;
}
#endif
#endif
torch
::
Tensor
fps
(
torch
::
Tensor
src
,
torch
::
Tensor
ptr
,
torch
::
Tensor
ratio
,
...
...
csrc/graclus.cpp
View file @
4ad2b395
...
...
@@ -8,7 +8,11 @@
#endif
#ifdef _WIN32
PyMODINIT_FUNC
PyInit__graclus
(
void
)
{
return
NULL
;
}
#ifdef WITH_CUDA
PyMODINIT_FUNC
PyInit__graclus_cuda
(
void
)
{
return
NULL
;
}
#else
PyMODINIT_FUNC
PyInit__graclus_cpu
(
void
)
{
return
NULL
;
}
#endif
#endif
torch
::
Tensor
graclus
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
...
...
csrc/grid.cpp
View file @
4ad2b395
...
...
@@ -8,7 +8,11 @@
#endif
#ifdef _WIN32
PyMODINIT_FUNC
PyInit__grid
(
void
)
{
return
NULL
;
}
#ifdef WITH_CUDA
PyMODINIT_FUNC
PyInit__grid_cuda
(
void
)
{
return
NULL
;
}
#else
PyMODINIT_FUNC
PyInit__grid_cpu
(
void
)
{
return
NULL
;
}
#endif
#endif
torch
::
Tensor
grid
(
torch
::
Tensor
pos
,
torch
::
Tensor
size
,
...
...
csrc/knn.cpp
View file @
4ad2b395
...
...
@@ -8,7 +8,11 @@
#endif
#ifdef _WIN32
PyMODINIT_FUNC
PyInit__knn
(
void
)
{
return
NULL
;
}
#ifdef WITH_CUDA
PyMODINIT_FUNC
PyInit__knn_cuda
(
void
)
{
return
NULL
;
}
#else
PyMODINIT_FUNC
PyInit__knn_cpu
(
void
)
{
return
NULL
;
}
#endif
#endif
torch
::
Tensor
knn
(
torch
::
Tensor
x
,
torch
::
Tensor
y
,
...
...
csrc/nearest.cpp
View file @
4ad2b395
...
...
@@ -6,7 +6,11 @@
#endif
#ifdef _WIN32
PyMODINIT_FUNC
PyInit__nearest
(
void
)
{
return
NULL
;
}
#ifdef WITH_CUDA
PyMODINIT_FUNC
PyInit__nearest_cuda
(
void
)
{
return
NULL
;
}
#else
PyMODINIT_FUNC
PyInit__nearest_cpu
(
void
)
{
return
NULL
;
}
#endif
#endif
torch
::
Tensor
nearest
(
torch
::
Tensor
x
,
torch
::
Tensor
y
,
torch
::
Tensor
ptr_x
,
...
...
csrc/radius.cpp
View file @
4ad2b395
...
...
@@ -8,7 +8,11 @@
#endif
#ifdef _WIN32
PyMODINIT_FUNC
PyInit__radius
(
void
)
{
return
NULL
;
}
#ifdef WITH_CUDA
PyMODINIT_FUNC
PyInit__radius_cuda
(
void
)
{
return
NULL
;
}
#else
PyMODINIT_FUNC
PyInit__radius_cpu
(
void
)
{
return
NULL
;
}
#endif
#endif
torch
::
Tensor
radius
(
torch
::
Tensor
x
,
torch
::
Tensor
y
,
...
...
csrc/rw.cpp
View file @
4ad2b395
...
...
@@ -8,7 +8,11 @@
#endif
#ifdef _WIN32
PyMODINIT_FUNC
PyInit__rw
(
void
)
{
return
NULL
;
}
#ifdef WITH_CUDA
PyMODINIT_FUNC
PyInit__rw_cuda
(
void
)
{
return
NULL
;
}
#else
PyMODINIT_FUNC
PyInit__rw_cpu
(
void
)
{
return
NULL
;
}
#endif
#endif
std
::
tuple
<
torch
::
Tensor
,
torch
::
Tensor
>
...
...
csrc/sampler.cpp
View file @
4ad2b395
...
...
@@ -4,7 +4,11 @@
#include "cpu/sampler_cpu.h"
#ifdef _WIN32
PyMODINIT_FUNC
PyInit__sampler
(
void
)
{
return
NULL
;
}
#ifdef WITH_CUDA
PyMODINIT_FUNC
PyInit__sampler_cuda
(
void
)
{
return
NULL
;
}
#else
PyMODINIT_FUNC
PyInit__sampler_cpu
(
void
)
{
return
NULL
;
}
#endif
#endif
torch
::
Tensor
neighbor_sampler
(
torch
::
Tensor
start
,
torch
::
Tensor
rowptr
,
...
...
csrc/version.cpp
View file @
4ad2b395
...
...
@@ -6,7 +6,11 @@
#endif
#ifdef _WIN32
PyMODINIT_FUNC
PyInit__version
(
void
)
{
return
NULL
;
}
#ifdef WITH_CUDA
PyMODINIT_FUNC
PyInit__version_cuda
(
void
)
{
return
NULL
;
}
#else
PyMODINIT_FUNC
PyInit__version_cpu
(
void
)
{
return
NULL
;
}
#endif
#endif
int64_t
cuda_version
()
{
...
...
script/cuda.sh
View file @
4ad2b395
...
...
@@ -69,7 +69,7 @@ if [ "${TRAVIS_OS_NAME}" = "osx" ] && [ "$IDX" = "cpu" ]; then
fi
if
[
"
${
IDX
}
"
=
"cpu"
]
;
then
export
FORCE_CPU
=
1
export
FORCE_
ONLY_
CPU
=
1
else
export
FORCE_CUDA
=
1
fi
...
...
script/rename_wheel.py
deleted
100644 → 0
View file @
2ce0f235
import
sys
import
os
import
os.path
as
osp
import
glob
import
shutil
idx
=
sys
.
argv
[
1
]
assert
idx
in
[
'cpu'
,
'cu92'
,
'cu101'
,
'cu102'
,
'cu110'
]
dist_dir
=
osp
.
join
(
osp
.
dirname
(
osp
.
abspath
(
__file__
)),
'..'
,
'dist'
)
wheels
=
glob
.
glob
(
osp
.
join
(
'dist'
,
'**'
,
'*.whl'
),
recursive
=
True
)
for
wheel
in
wheels
:
if
idx
in
wheel
:
continue
paths
=
wheel
.
split
(
osp
.
sep
)
names
=
paths
[
-
1
].
split
(
'-'
)
name
=
'-'
.
join
(
names
[:
-
4
]
+
[
'latest+'
+
idx
]
+
names
[
-
3
:])
shutil
.
copyfile
(
wheel
,
osp
.
join
(
*
paths
[:
-
1
],
name
))
name
=
'-'
.
join
(
names
[:
-
4
]
+
[
names
[
-
4
]
+
'+'
+
idx
]
+
names
[
-
3
:])
os
.
rename
(
wheel
,
osp
.
join
(
*
paths
[:
-
1
],
name
))
setup.cfg
View file @
4ad2b395
...
...
@@ -5,4 +5,4 @@ description-file = README.md
test = pytest
[tool:pytest]
addopts =
--capture=no
--cov
addopts = --cov
setup.py
View file @
4ad2b395
import
os
import
os.path
as
osp
import
sys
import
glob
import
os.path
as
osp
from
itertools
import
product
from
setuptools
import
setup
,
find_packages
import
torch
...
...
@@ -10,44 +11,46 @@ from torch.utils.cpp_extension import BuildExtension
from
torch.utils.cpp_extension
import
CppExtension
,
CUDAExtension
,
CUDA_HOME
WITH_CUDA
=
torch
.
cuda
.
is_available
()
and
CUDA_HOME
is
not
None
suffices
=
[
'cpu'
,
'cuda'
]
if
WITH_CUDA
else
[
'cpu'
]
if
os
.
getenv
(
'FORCE_CUDA'
,
'0'
)
==
'1'
:
WITH_CUDA
=
True
if
os
.
getenv
(
'FORCE_CPU'
,
'0'
)
==
'1'
:
WITH_CUDA
=
False
suffices
=
[
'cuda'
,
'cpu'
]
if
os
.
getenv
(
'FORCE_ONLY_CUDA'
,
'0'
)
==
'1'
:
suffices
=
[
'cuda'
]
if
os
.
getenv
(
'FORCE_ONLY_CPU'
,
'0'
)
==
'1'
:
suffices
=
[
'cpu'
]
BUILD_DOCS
=
os
.
getenv
(
'BUILD_DOCS'
,
'0'
)
==
'1'
def
get_extensions
():
Extension
=
CppExtension
define_macros
=
[]
extra_compile_args
=
{
'cxx'
:
[
'-O2'
]}
extra_link_args
=
[
'-s'
]
info
=
parallel_info
()
if
'parallel backend: OpenMP'
in
info
and
'OpenMP not found'
not
in
info
:
extra_compile_args
[
'cxx'
]
+=
[
'-DAT_PARALLEL_OPENMP'
]
if
sys
.
platform
==
'win32'
:
extra_compile_args
[
'cxx'
]
+=
[
'/openmp'
]
else
:
extra_compile_args
[
'cxx'
]
+=
[
'-fopenmp'
]
else
:
print
(
'Compiling without OpenMP...'
)
if
WITH_CUDA
:
Extension
=
CUDAExtension
define_macros
+=
[(
'WITH_CUDA'
,
None
)]
nvcc_flags
=
os
.
getenv
(
'NVCC_FLAGS'
,
''
)
nvcc_flags
=
[]
if
nvcc_flags
==
''
else
nvcc_flags
.
split
(
' '
)
nvcc_flags
+=
[
'-arch=sm_35'
,
'--expt-relaxed-constexpr'
,
'-O2'
]
extra_compile_args
[
'nvcc'
]
=
nvcc_flags
extensions
=
[]
extensions_dir
=
osp
.
join
(
osp
.
dirname
(
osp
.
abspath
(
__file__
)),
'csrc'
)
main_files
=
glob
.
glob
(
osp
.
join
(
extensions_dir
,
'*.cpp'
))
extensions
=
[]
for
main
in
main_files
:
name
=
main
.
split
(
os
.
sep
)[
-
1
][:
-
4
]
for
main
,
suffix
in
product
(
main_files
,
suffices
):
define_macros
=
[]
extra_compile_args
=
{
'cxx'
:
[
'-O2'
]}
extra_link_args
=
[
'-s'
]
info
=
parallel_info
()
if
'backend: OpenMP'
in
info
and
'OpenMP not found'
not
in
info
:
extra_compile_args
[
'cxx'
]
+=
[
'-DAT_PARALLEL_OPENMP'
]
if
sys
.
platform
==
'win32'
:
extra_compile_args
[
'cxx'
]
+=
[
'/openmp'
]
else
:
extra_compile_args
[
'cxx'
]
+=
[
'-fopenmp'
]
else
:
print
(
'Compiling without OpenMP...'
)
if
suffix
==
'cuda'
:
define_macros
+=
[(
'WITH_CUDA'
,
None
)]
nvcc_flags
=
os
.
getenv
(
'NVCC_FLAGS'
,
''
)
nvcc_flags
=
[]
if
nvcc_flags
==
''
else
nvcc_flags
.
split
(
' '
)
nvcc_flags
+=
[
'-arch=sm_35'
,
'--expt-relaxed-constexpr'
,
'-O2'
]
extra_compile_args
[
'nvcc'
]
=
nvcc_flags
name
=
main
.
split
(
os
.
sep
)[
-
1
][:
-
4
]
sources
=
[
main
]
path
=
osp
.
join
(
extensions_dir
,
'cpu'
,
f
'
{
name
}
_cpu.cpp'
)
...
...
@@ -58,8 +61,9 @@ def get_extensions():
if
WITH_CUDA
and
osp
.
exists
(
path
):
sources
+=
[
path
]
Extension
=
CppExtension
if
suffix
==
'cpu'
else
CUDAExtension
extension
=
Extension
(
'torch_cluster._
'
+
name
,
f
'torch_cluster._
{
name
}
_
{
suffix
}
'
,
sources
,
include_dirs
=
[
extensions_dir
],
define_macros
=
define_macros
,
...
...
@@ -77,7 +81,7 @@ tests_require = ['pytest', 'pytest-cov', 'scipy']
setup
(
name
=
'torch_cluster'
,
version
=
'1.5.
8
'
,
version
=
'1.5.
9
'
,
author
=
'Matthias Fey'
,
author_email
=
'matthias.fey@tu-dortmund.de'
,
url
=
'https://github.com/rusty1s/pytorch_cluster'
,
...
...
@@ -97,8 +101,7 @@ setup(
extras_require
=
{
'test'
:
tests_require
},
ext_modules
=
get_extensions
()
if
not
BUILD_DOCS
else
[],
cmdclass
=
{
'build_ext'
:
BuildExtension
.
with_options
(
no_python_abi_suffix
=
True
,
use_ninja
=
False
)
'build_ext'
:
BuildExtension
.
with_options
(
no_python_abi_suffix
=
True
)
},
packages
=
find_packages
(),
)
torch_cluster/__init__.py
View file @
4ad2b395
...
...
@@ -3,16 +3,18 @@ import os.path as osp
import
torch
__version__
=
'1.5.8'
__version__
=
'1.5.9'
suffix
=
'cuda'
if
torch
.
cuda
.
is_available
()
else
'cpu'
for
library
in
[
'_version'
,
'_grid'
,
'_graclus'
,
'_fps'
,
'_rw'
,
'_sampler'
,
'_nearest'
,
'_knn'
,
'_radius'
]:
torch
.
ops
.
load_library
(
importlib
.
machinery
.
PathFinder
().
find_spec
(
library
,
[
osp
.
dirname
(
__file__
)]).
origin
)
f
'
{
library
}
_
{
suffix
}
'
,
[
osp
.
dirname
(
__file__
)]).
origin
)
if
torch
.
version
.
cuda
is
not
None
:
# pragma: no cover
if
torch
.
cuda
.
is
_available
()
:
# pragma: no cover
cuda_version
=
torch
.
ops
.
torch_cluster
.
cuda_version
()
if
cuda_version
==
-
1
:
...
...
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