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
04f797ea
Commit
04f797ea
authored
Oct 07, 2021
by
rusty1s
Browse files
either load GPU or CPU libraries
parent
9fcdff3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
torch_cluster/__init__.py
torch_cluster/__init__.py
+14
-11
No files found.
torch_cluster/__init__.py
View file @
04f797ea
...
@@ -5,21 +5,24 @@ import torch
...
@@ -5,21 +5,24 @@ import torch
__version__
=
'1.5.9'
__version__
=
'1.5.9'
suffix
=
'cuda'
if
torch
.
cuda
.
is_available
()
else
'cpu'
for
library
in
[
for
library
in
[
'_version'
,
'_grid'
,
'_graclus'
,
'_fps'
,
'_rw'
,
'_sampler'
,
'_nearest'
,
'_version'
,
'_grid'
,
'_graclus'
,
'_fps'
,
'_rw'
,
'_sampler'
,
'_nearest'
,
'_knn'
,
'_radius'
'_knn'
,
'_radius'
]:
]:
torch
.
ops
.
load_library
(
importlib
.
machinery
.
PathFinder
().
find_spec
(
cuda_spec
=
importlib
.
machinery
.
PathFinder
().
find_spec
(
f
'
{
library
}
_
{
suffix
}
'
,
[
osp
.
dirname
(
__file__
)]).
origin
)
f
'
{
library
}
_cuda'
,
[
osp
.
dirname
(
__file__
)])
cpu_spec
=
importlib
.
machinery
.
PathFinder
().
find_spec
(
if
torch
.
cuda
.
is_available
():
# pragma: no cover
f
'
{
library
}
_cpu'
,
[
osp
.
dirname
(
__file__
)])
cuda_version
=
torch
.
ops
.
torch_cluster
.
cuda_version
()
spec
=
cuda_spec
or
cpu_spec
if
spec
is
not
None
:
if
cuda_version
==
-
1
:
torch
.
ops
.
load_library
(
spec
.
origin
)
major
=
minor
=
0
else
:
# pragma: no cover
elif
cuda_version
<
10000
:
raise
ImportError
(
f
"Could not find module '
{
library
}
_cpu' in "
f
"
{
osp
.
dirname
(
__file__
)
}
"
)
cuda_version
=
torch
.
ops
.
torch_sparse
.
cuda_version
()
if
torch
.
cuda
.
is_available
()
and
cuda_version
!=
-
1
:
# pragma: no cover
if
cuda_version
<
10000
:
major
,
minor
=
int
(
str
(
cuda_version
)[
0
]),
int
(
str
(
cuda_version
)[
2
])
major
,
minor
=
int
(
str
(
cuda_version
)[
0
]),
int
(
str
(
cuda_version
)[
2
])
else
:
else
:
major
,
minor
=
int
(
str
(
cuda_version
)[
0
:
2
]),
int
(
str
(
cuda_version
)[
3
])
major
,
minor
=
int
(
str
(
cuda_version
)[
0
:
2
]),
int
(
str
(
cuda_version
)[
3
])
...
...
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