MCPcopy
hub / github.com/dmlc/dgl / device

Method device

python/dgl/distributed/dist_graph.py:957–978  ·  view source on GitHub ↗

Get the device context of this graph. Examples -------- The following example uses PyTorch backend. >>> g = dgl.heterograph({ ... ('user', 'plays', 'game'): ([0, 1, 1, 2], [0, 0, 2, 1]) ... }) >>> print(g.device) device(type='cpu'

(self)

Source from the content-addressed store, hash-verified

955
956 @property
957 def device(self):
958 """Get the device context of this graph.
959
960 Examples
961 --------
962 The following example uses PyTorch backend.
963
964 >>> g = dgl.heterograph({
965 ... ('user', 'plays', 'game'): ([0, 1, 1, 2], [0, 0, 2, 1])
966 ... })
967 >>> print(g.device)
968 device(type='cpu')
969 >>> g = g.to('cuda:0')
970 >>> print(g.device)
971 device(type='cuda', index=0)
972
973 Returns
974 -------
975 Device context object
976 """
977 # TODO(da?): describe when self._g is None and device shouldn't be called.
978 return F.cpu()
979
980 def is_pinned(self):
981 """Check if the graph structure is pinned to the page-locked memory.

Callers 15

__call__Method · 0.45
_get_deviceFunction · 0.45
astypeFunction · 0.45
copy_toFunction · 0.45
zerosFunction · 0.45
onesFunction · 0.45
uniformFunction · 0.45
randintFunction · 0.45
full_1dFunction · 0.45
arangeFunction · 0.45
zerocopy_from_numpyFunction · 0.45
cpuFunction · 0.45

Calls 1

cpuMethod · 0.45

Tested by

no test coverage detected