"git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "5f740d0f55adec63ee2453f83f1c0d7d984e01e4"
Unverified Commit c08f77bf authored by czkkkkkk's avatar czkkkkkk Committed by GitHub
Browse files

[BUGFIX] Fix the lazy device copy issue of DGL node/edge features. (#6564)

parent 5e78e070
...@@ -5661,6 +5661,9 @@ class DGLGraph(object): ...@@ -5661,6 +5661,9 @@ class DGLGraph(object):
If the graph is already on the specified device, the function directly returns it. If the graph is already on the specified device, the function directly returns it.
Otherwise, it returns a cloned graph on the specified device. Otherwise, it returns a cloned graph on the specified device.
Note that data of node and edge features are not moved to the specified
device before being accessed or `materialize_data()` is called.
Parameters Parameters
---------- ----------
device : Framework-specific device context object device : Framework-specific device context object
...@@ -5752,6 +5755,21 @@ class DGLGraph(object): ...@@ -5752,6 +5755,21 @@ class DGLGraph(object):
""" """
return self.to(F.cpu()) return self.to(F.cpu())
def materialize_data(self):
"""Materialize the graph data on the current device.
This method is a no-op if the graph data is already materialized.
Returns
-------
DGLGraph
The graph on the current device.
"""
for frame in itertools.chain(self._node_frames, self._edge_frames):
for col in frame._columns.values():
col.data # pylint: disable=pointless-statement
return self
def pin_memory_(self): def pin_memory_(self):
"""Pin the graph structure and node/edge data to the page-locked memory for """Pin the graph structure and node/edge data to the page-locked memory for
GPU zero-copy access. GPU zero-copy access.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment