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
00c09b9f
Unverified
Commit
00c09b9f
authored
May 28, 2022
by
Quan (Andy) Gan
Committed by
GitHub
May 28, 2022
Browse files
Revert "[bugfix] Explicitly unpin tensoradapter allocated arrays (#3997)" (#4061)
This reverts commit
fdd1fe19
.
parent
c577dc9f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
33 deletions
+2
-33
include/dgl/runtime/ndarray.h
include/dgl/runtime/ndarray.h
+0
-2
src/runtime/ndarray.cc
src/runtime/ndarray.cc
+2
-11
tests/pytorch/test_unpin_tensoradapter.py
tests/pytorch/test_unpin_tensoradapter.py
+0
-20
No files found.
include/dgl/runtime/ndarray.h
View file @
00c09b9f
...
...
@@ -415,8 +415,6 @@ struct NDArray::Container {
std
::
vector
<
int64_t
>
stride_
;
/*! \brief The internal array object */
std
::
atomic
<
int
>
ref_counter_
{
0
};
bool
from_tensor_dispatcher_
{
false
};
};
// implementations of inline functions
...
...
src/runtime/ndarray.cc
View file @
00c09b9f
...
...
@@ -78,12 +78,6 @@ struct NDArray::Internal {
// This enables us to create NDArray from memory allocated by other
// frameworks that are DLPack compatible
static
void
DLPackDeleter
(
NDArray
::
Container
*
ptr
)
{
if
(
ptr
->
from_tensor_dispatcher_
)
{
if
(
IsDataPinned
(
&
(
ptr
->
dl_tensor
)))
{
UnpinData
(
&
(
ptr
->
dl_tensor
));
}
}
DLManagedTensor
*
tensor
=
static_cast
<
DLManagedTensor
*>
(
ptr
->
manager_ctx
);
if
(
tensor
->
deleter
!=
nullptr
)
{
(
*
tensor
->
deleter
)(
tensor
);
...
...
@@ -216,11 +210,8 @@ NDArray NDArray::Empty(std::vector<int64_t> shape,
DLDataType
dtype
,
DLContext
ctx
)
{
TensorDispatcher
*
td
=
TensorDispatcher
::
Global
();
if
(
td
->
IsAvailable
())
{
auto
nd
=
td
->
Empty
(
shape
,
dtype
,
ctx
);
nd
.
data_
->
from_tensor_dispatcher_
=
true
;
return
nd
;
}
if
(
td
->
IsAvailable
())
return
td
->
Empty
(
shape
,
dtype
,
ctx
);
NDArray
ret
=
Internal
::
Create
(
shape
,
dtype
,
ctx
);
// setup memory content
...
...
tests/pytorch/test_unpin_tensoradapter.py
deleted
100644 → 0
View file @
c577dc9f
import
backend
as
F
import
dgl
import
gc
import
unittest
import
torch
@
unittest
.
skipIf
(
F
.
ctx
().
type
==
'cpu'
,
reason
=
'Pinning memory tests require GPU.'
)
def
test_unpin_tensoradapater
():
# run a sufficient number of iterations such that the memory pool should be
# re-used
for
j
in
range
(
3
):
t
=
F
.
zerocopy_from_dlpack
(
dgl
.
ndarray
.
empty
(
[
10000
,
10
],
F
.
reverse_data_type_dict
[
F
.
float32
],
ctx
=
dgl
.
utils
.
to_dgl_context
(
torch
.
device
(
'cpu'
))).
to_dlpack
()).
zero_
()
assert
not
F
.
is_pinned
(
t
)
dgl
.
utils
.
pin_memory_inplace
(
t
)
assert
F
.
is_pinned
(
t
)
del
t
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