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)
| 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. |
no test coverage detected