Skip to content

Commit 8a07c86

Browse files
committed
update
1 parent 19df643 commit 8a07c86

File tree

10 files changed

+79
-79
lines changed

10 files changed

+79
-79
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ install:
112112
- source script/torch.sh
113113
- pip install flake8
114114
- pip install codecov
115-
- pip install .[test]
115+
- travis_wait 30 pip install -e .
116116
script:
117117
- flake8 .
118118
- python setup.py test
119119
after_success:
120-
- python setup.py bdist_wheel --dist-dir=dist/torch-${TORCH_VERSION}
121-
- python script/rename_wheel.py ${IDX}
120+
- python setup.py bdist_wheel --dist-dir=dist
121+
- ls -lah dist/
122122
- codecov
123123
deploy:
124124
provider: s3
@@ -127,8 +127,8 @@ deploy:
127127
access_key_id: ${S3_ACCESS_KEY}
128128
secret_access_key: ${S3_SECRET_ACCESS_KEY}
129129
bucket: pytorch-geometric.com
130-
local_dir: dist/torch-${TORCH_VERSION}
131-
upload_dir: whl/torch-${TORCH_VERSION}
130+
local_dir: dist
131+
upload_dir: whl/torch-${TORCH_VERSION}+${IDX}
132132
acl: public_read
133133
on:
134134
all_branches: true

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.0)
22
project(torchscatter)
33
set(CMAKE_CXX_STANDARD 14)
4-
set(TORCHSCATTER_VERSION 2.0.5)
4+
set(TORCHSCATTER_VERSION 2.0.6)
55

66
option(WITH_CUDA "Enable CUDA support" OFF)
77

csrc/scatter.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
#endif
1010

1111
#ifdef _WIN32
12-
PyMODINIT_FUNC PyInit__scatter(void) { return NULL; }
12+
#ifdef WITH_CUDA
13+
PyMODINIT_FUNC PyInit__scatter_cuda(void) { return NULL; }
14+
#else
15+
PyMODINIT_FUNC PyInit__scatter_cpu(void) { return NULL; }
16+
#endif
1317
#endif
1418

1519
torch::Tensor broadcast(torch::Tensor src, torch::Tensor other, int64_t dim) {

csrc/segment_coo.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
#endif
1010

1111
#ifdef _WIN32
12-
PyMODINIT_FUNC PyInit__segment_coo(void) { return NULL; }
12+
#ifdef WITH_CUDA
13+
PyMODINIT_FUNC PyInit__segment_coo_cuda(void) { return NULL; }
14+
#else
15+
PyMODINIT_FUNC PyInit__segment_coo_cpu(void) { return NULL; }
16+
#endif
1317
#endif
1418

1519
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>

csrc/segment_csr.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
#endif
1010

1111
#ifdef _WIN32
12-
PyMODINIT_FUNC PyInit__segment_csr(void) { return NULL; }
12+
#ifdef WITH_CUDA
13+
PyMODINIT_FUNC PyInit__segment_csr_cuda(void) { return NULL; }
14+
#else
15+
PyMODINIT_FUNC PyInit__segment_csr_cpu(void) { return NULL; }
16+
#endif
1317
#endif
1418

1519
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>

csrc/version.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
#endif
77

88
#ifdef _WIN32
9-
PyMODINIT_FUNC PyInit__version(void) { return NULL; }
9+
#ifdef WITH_CUDA
10+
PyMODINIT_FUNC PyInit__version_cuda(void) { return NULL; }
11+
#else
12+
PyMODINIT_FUNC PyInit__version_cpu(void) { return NULL; }
13+
#endif
1014
#endif
1115

1216
int64_t cuda_version() {

script/cuda.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if [ "${TRAVIS_OS_NAME}" = "osx" ] && [ "$IDX" = "cpu" ]; then
6969
fi
7070

7171
if [ "${IDX}" = "cpu" ]; then
72-
export FORCE_CPU=1
72+
export FORCE_ONLY_CPU=1
7373
else
7474
export FORCE_CUDA=1
7575
fi

script/rename_wheel.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

setup.py

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,76 @@
11
import os
2-
import os.path as osp
2+
import sys
33
import glob
4+
import os.path as osp
5+
from itertools import product
46
from setuptools import setup, find_packages
57

68
import torch
9+
from torch.__config__ import parallel_info
710
from torch.utils.cpp_extension import BuildExtension
811
from torch.utils.cpp_extension import CppExtension, CUDAExtension, CUDA_HOME
912

10-
WITH_CUDA = CUDA_HOME is not None
13+
WITH_CUDA = torch.cuda.is_available() and CUDA_HOME is not None
14+
suffices = ['cpu', 'cuda'] if WITH_CUDA else ['cpu']
1115
if os.getenv('FORCE_CUDA', '0') == '1':
12-
WITH_CUDA = True
13-
if os.getenv('FORCE_CPU', '0') == '1':
14-
WITH_CUDA = False
16+
suffices = ['cuda', 'cpu']
17+
if os.getenv('FORCE_ONLY_CUDA', '0') == '1':
18+
suffices = ['cuda']
19+
if os.getenv('FORCE_ONLY_CPU', '0') == '1':
20+
suffices = ['cpu']
1521

1622
BUILD_DOCS = os.getenv('BUILD_DOCS', '0') == '1'
1723

1824

1925
def get_extensions():
2026
extensions = []
21-
for with_cuda, supername in [
22-
(False, "cpu"),
23-
(True, "gpu"),
24-
]:
25-
if with_cuda and not WITH_CUDA:
26-
continue
27-
Extension = CppExtension
27+
28+
extensions_dir = osp.join(osp.dirname(osp.abspath(__file__)), 'csrc')
29+
main_files = glob.glob(osp.join(extensions_dir, '*.cpp'))
30+
31+
for main, suffix in product(main_files, suffices):
2832
define_macros = []
29-
extra_compile_args = {'cxx': []}
33+
extra_compile_args = {'cxx': ['-O2']}
34+
extra_link_args = ['-s']
35+
36+
info = parallel_info()
37+
if 'backend: OpenMP' in info and 'OpenMP not found' not in info:
38+
extra_compile_args['cxx'] += ['-DAT_PARALLEL_OPENMP']
39+
if sys.platform == 'win32':
40+
extra_compile_args['cxx'] += ['/openmp']
41+
else:
42+
extra_compile_args['cxx'] += ['-fopenmp']
43+
else:
44+
print('Compiling without OpenMP...')
3045

31-
if with_cuda:
32-
Extension = CUDAExtension
46+
if suffix == 'cuda':
3347
define_macros += [('WITH_CUDA', None)]
3448
nvcc_flags = os.getenv('NVCC_FLAGS', '')
3549
nvcc_flags = [] if nvcc_flags == '' else nvcc_flags.split(' ')
3650
nvcc_flags += ['-arch=sm_35', '--expt-relaxed-constexpr']
3751
extra_compile_args['nvcc'] = nvcc_flags
3852

39-
extensions_dir = osp.join(osp.dirname(osp.abspath(__file__)), 'csrc')
40-
main_files = glob.glob(osp.join(extensions_dir, '*.cpp'))
41-
for main in main_files:
42-
name = main.split(os.sep)[-1][:-4]
43-
44-
sources = [main]
53+
name = main.split(os.sep)[-1][:-4]
54+
sources = [main]
4555

46-
path = osp.join(extensions_dir, 'cpu', f'{name}_cpu.cpp')
47-
if osp.exists(path):
48-
sources += [path]
56+
path = osp.join(extensions_dir, 'cpu', f'{name}_cpu.cpp')
57+
if osp.exists(path):
58+
sources += [path]
4959

50-
path = osp.join(extensions_dir, 'cuda', f'{name}_cuda.cu')
51-
if with_cuda and osp.exists(path):
52-
sources += [path]
60+
path = osp.join(extensions_dir, 'cuda', f'{name}_cuda.cu')
61+
if suffix == 'cuda' and osp.exists(path):
62+
sources += [path]
5363

54-
extension = Extension(
55-
'torch_scatter._%s_%s' % (name, supername),
56-
sources,
57-
include_dirs=[extensions_dir],
58-
define_macros=define_macros,
59-
extra_compile_args=extra_compile_args,
60-
)
61-
extensions += [extension]
64+
Extension = CppExtension if suffix == 'cpu' else CUDAExtension
65+
extension = Extension(
66+
f'torch_scatter._{name}_{suffix}',
67+
sources,
68+
include_dirs=[extensions_dir],
69+
define_macros=define_macros,
70+
extra_compile_args=extra_compile_args,
71+
extra_link_args=extra_link_args,
72+
)
73+
extensions += [extension]
6274

6375
return extensions
6476

@@ -69,7 +81,7 @@ def get_extensions():
6981

7082
setup(
7183
name='torch_scatter',
72-
version='2.0.5',
84+
version='2.0.6',
7385
author='Matthias Fey',
7486
author_email='[email protected]',
7587
url='https://github.com/rusty1s/pytorch_scatter',

torch_scatter/__init__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@
44

55
import torch
66

7-
__version__ = '2.0.5'
7+
__version__ = '2.0.6'
88

9-
if torch.cuda.is_available():
10-
sublib = "gpu"
11-
else:
12-
sublib = "cpu"
9+
suffix = 'cuda' if torch.cuda.is_available() else 'cpu'
1310

1411
try:
1512
for library in ['_version', '_scatter', '_segment_csr', '_segment_coo']:
16-
library = "%s_%s" % (library, sublib)
1713
torch.ops.load_library(importlib.machinery.PathFinder().find_spec(
18-
library, [osp.dirname(__file__)]).origin)
14+
f'{library}_{suffix}', [osp.dirname(__file__)]).origin)
1915
except AttributeError as e:
2016
if os.getenv('BUILD_DOCS', '0') != '1':
2117
raise AttributeError(e)
@@ -45,7 +41,7 @@
4541
torch.ops.torch_scatter.segment_max_coo = segment_coo_arg_placeholder
4642
torch.ops.torch_scatter.gather_coo = gather_coo_placeholder
4743

48-
if torch.cuda.is_available() and torch.version.cuda: # pragma: no cover
44+
if torch.cuda.is_available(): # pragma: no cover
4945
cuda_version = torch.ops.torch_scatter.cuda_version()
5046

5147
if cuda_version == -1:

0 commit comments

Comments
 (0)