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
dgl
Commits
0ef85f28
Commit
0ef85f28
authored
May 13, 2023
by
lisj
Browse files
恢复ctx转换中的代码,tests中对device的处理在cpu和cpu:0时判断为非同一设备
parent
351f7588
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
10 deletions
+4
-10
python/dgl/backend/pytorch/tensor.py
python/dgl/backend/pytorch/tensor.py
+4
-10
No files found.
python/dgl/backend/pytorch/tensor.py
View file @
0ef85f28
...
@@ -89,18 +89,12 @@ def device_id(ctx):
...
@@ -89,18 +89,12 @@ def device_id(ctx):
else
:
else
:
return
ctx
.
index
return
ctx
.
index
__devtype_th_map
=
{
1
:
"cpu"
,
2
:
"cuda"
,
# cuda device
10
:
"cuda"
# rocm device
}
def
to_backend_ctx
(
dglctx
):
def
to_backend_ctx
(
dglctx
):
dev_type
=
dglctx
.
device_type
dev_type
=
dglctx
.
device_type
if
dev_type
in
__devtype_th_map
:
if
dev_type
==
1
:
th_type
=
__devtype_th_map
[
dev_type
]
return
th
.
device
(
'cpu'
)
return
th
.
device
(
th_type
,
dglctx
.
device_id
)
elif
dev_type
==
2
or
dev_type
==
10
:
return
th
.
device
(
'cuda'
,
dglctx
.
device_id
)
else
:
else
:
raise
ValueError
(
'Unsupported DGL device context:'
,
dglctx
)
raise
ValueError
(
'Unsupported DGL device context:'
,
dglctx
)
...
...
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