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
c08192cb
Unverified
Commit
c08192cb
authored
Jul 25, 2023
by
nv-dlasalle
Committed by
GitHub
Jul 25, 2023
Browse files
[Bugfix] Allow pinning of empty tensor (#6044)
parent
b400af48
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
python/dgl/backend/pytorch/tensor.py
python/dgl/backend/pytorch/tensor.py
+7
-5
tests/python/pytorch/utils/test_pin_memory.py
tests/python/pytorch/utils/test_pin_memory.py
+4
-0
No files found.
python/dgl/backend/pytorch/tensor.py
View file @
c08192cb
...
...
@@ -451,6 +451,8 @@ else:
def
zerocopy_to_dgl_ndarray_for_write
(
input
):
if
input
.
numel
()
>
0
:
# only check non-empty tensors
assert
input
.
is_contiguous
(),
(
"Cannot convert non-contiguous tensors "
"to dgl ndarray for write. Call .to_contiguous() first."
...
...
tests/python/pytorch/utils/test_pin_memory.py
View file @
c08192cb
...
...
@@ -31,6 +31,10 @@ def test_pin_view():
with
pytest
.
raises
(
dgl
.
DGLError
):
dgl
.
utils
.
pin_memory_inplace
(
v
)
# make sure an empty view does not generate an error
u
=
t
[
10
:
10
]
u
=
dgl
.
utils
.
pin_memory_inplace
(
u
)
@
pytest
.
mark
.
skipif
(
F
.
_default_context_str
==
"cpu"
,
reason
=
"Need gpu for this test."
...
...
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