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
cac25f63
Unverified
Commit
cac25f63
authored
Oct 29, 2021
by
Quan (Andy) Gan
Committed by
GitHub
Oct 29, 2021
Browse files
fix compatibility with PyTorch 1.10 (#3454)
parent
9067565a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
python/dgl/backend/pytorch/tensor.py
python/dgl/backend/pytorch/tensor.py
+9
-3
No files found.
python/dgl/backend/pytorch/tensor.py
View file @
cac25f63
...
@@ -27,7 +27,7 @@ def data_type_dict():
...
@@ -27,7 +27,7 @@ def data_type_dict():
'int16'
:
th
.
int16
,
'int16'
:
th
.
int16
,
'int32'
:
th
.
int32
,
'int32'
:
th
.
int32
,
'int64'
:
th
.
int64
,
'int64'
:
th
.
int64
,
'bool'
:
th
.
uint8
}
'bool'
:
th
.
bool
}
def
cpu
():
def
cpu
():
return
th
.
device
(
'cpu'
)
return
th
.
device
(
'cpu'
)
...
@@ -330,8 +330,14 @@ def zerocopy_to_numpy(input):
...
@@ -330,8 +330,14 @@ def zerocopy_to_numpy(input):
def
zerocopy_from_numpy
(
np_array
):
def
zerocopy_from_numpy
(
np_array
):
return
th
.
as_tensor
(
np_array
)
return
th
.
as_tensor
(
np_array
)
def
zerocopy_to_dgl_ndarray
(
data
):
if
LooseVersion
(
th
.
__version__
)
>=
LooseVersion
(
"1.10.0"
):
return
nd
.
from_dlpack
(
dlpack
.
to_dlpack
(
data
.
contiguous
()))
def
zerocopy_to_dgl_ndarray
(
data
):
if
data
.
dtype
==
th
.
bool
:
data
=
data
.
byte
()
return
nd
.
from_dlpack
(
dlpack
.
to_dlpack
(
data
.
contiguous
()))
else
:
def
zerocopy_to_dgl_ndarray
(
data
):
return
nd
.
from_dlpack
(
dlpack
.
to_dlpack
(
data
.
contiguous
()))
def
zerocopy_to_dgl_ndarray_for_write
(
input
):
def
zerocopy_to_dgl_ndarray_for_write
(
input
):
return
zerocopy_to_dgl_ndarray
(
input
)
return
zerocopy_to_dgl_ndarray
(
input
)
...
...
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