Skip to content

Commit

Permalink
move the is_pinned check insided CopyTo.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfbalin committed Jul 28, 2024
1 parent fb36668 commit 8f594c2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/dgl/graphbolt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ def apply_to(x, device, non_blocking=False):
return x
if not non_blocking:
return x.to(device)
# The copy is non blocking only if the objects are pinned.
assert x.is_pinned(), f"{x} should be pinned."
return x.to(device, non_blocking=True)


Expand Down Expand Up @@ -373,6 +371,9 @@ def __init__(self, datapipe, device, non_blocking=False):

def __iter__(self):
for data in self.datapipe:
if self.non_blocking:
# The copy is non blocking only if contents of data are pinned.
assert data.is_pinned(), f"{data} should be pinned."
yield recursive_apply(
data, apply_to, self.device, self.non_blocking
)
Expand Down

0 comments on commit 8f594c2

Please sign in to comment.