Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GraphBolt] CPUCachedFeature.read_async body. [4] #7549

Merged
merged 3 commits into from
Jul 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions python/dgl/graphbolt/impl/cpu_cached_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(
policy=policy,
pin_memory=pin_memory,
)
self._is_pinned = pin_memory

def read(self, ids: torch.Tensor = None):
"""Read the feature by index.
Expand Down Expand Up @@ -103,7 +104,12 @@ def read_async(self, ids: torch.Tensor):
... future = next(async_handle)
>>> result = future.wait() # result contains the read values.
"""
raise NotImplementedError
if ids.is_cuda and self._is_pinned:
pass
elif ids.is_cuda:
pass
else:
pass

def read_async_num_stages(self, ids_device: torch.device):
"""The number of stages of the read_async operation. See read_async
Expand All @@ -117,7 +123,12 @@ def read_async_num_stages(self, ids_device: torch.device):
int
The number of stages of the read_async operation.
"""
raise NotImplementedError
if ids_device.type == "cuda":
return 4 + self._fallback_feature.read_async_num_stages(
torch.device("cpu")
)
else:
return 3 + self._fallback_feature.read_async_num_stages(ids_device)

def size(self):
"""Get the size of the feature.
Expand Down
Loading