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-scatter
Commits
d305ecc0
Commit
d305ecc0
authored
Nov 25, 2018
by
rusty1s
Browse files
nested extensions
parent
15afee0d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
setup.py
setup.py
+2
-2
torch_scatter/utils/ext.py
torch_scatter/utils/ext.py
+6
-3
No files found.
setup.py
View file @
d305ecc0
...
@@ -4,14 +4,14 @@ from torch.utils.cpp_extension import CppExtension, CUDAExtension, CUDA_HOME
...
@@ -4,14 +4,14 @@ from torch.utils.cpp_extension import CppExtension, CUDAExtension, CUDA_HOME
ext_modules
=
[
ext_modules
=
[
CppExtension
(
CppExtension
(
'scatter_cpu'
,
[
'cpu/scatter.cpp'
],
'
torch_scatter.
scatter_cpu'
,
[
'cpu/scatter.cpp'
],
extra_compile_args
=
[
'-Wno-unused-variable'
])
extra_compile_args
=
[
'-Wno-unused-variable'
])
]
]
cmdclass
=
{
'build_ext'
:
torch
.
utils
.
cpp_extension
.
BuildExtension
}
cmdclass
=
{
'build_ext'
:
torch
.
utils
.
cpp_extension
.
BuildExtension
}
if
CUDA_HOME
is
not
None
:
if
CUDA_HOME
is
not
None
:
ext_modules
+=
[
ext_modules
+=
[
CUDAExtension
(
'scatter_cuda'
,
CUDAExtension
(
'
torch_scatter.
scatter_cuda'
,
[
'cuda/scatter.cpp'
,
'cuda/scatter_kernel.cu'
])
[
'cuda/scatter.cpp'
,
'cuda/scatter_kernel.cu'
])
]
]
...
...
torch_scatter/utils/ext.py
View file @
d305ecc0
import
torch
import
torch
import
scatter_cpu
import
torch_scatter.
scatter_cpu
if
torch
.
cuda
.
is_available
():
if
torch
.
cuda
.
is_available
():
import
scatter_cuda
import
torch_scatter.
scatter_cuda
def
get_func
(
name
,
tensor
):
def
get_func
(
name
,
tensor
):
module
=
scatter_cuda
if
tensor
.
is_cuda
else
scatter_cpu
if
tensor
.
is_cuda
:
module
=
torch_scatter
.
scatter_cuda
else
:
module
=
torch_scatter
.
scatter_cpu
return
getattr
(
module
,
name
)
return
getattr
(
module
,
name
)
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