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

Function context_of

python/dgl/utils/internal.py:1161–1168  ·  view source on GitHub ↗

Return the device of the data which can be either a tensor or a list/dict of tensors.

(data)

Source from the content-addressed store, hash-verified

1159
1160
1161def context_of(data):
1162 """Return the device of the data which can be either a tensor or a list/dict of tensors."""
1163 if isinstance(data, Mapping):
1164 return F.context(next(iter(data.values())))
1165 elif is_listlike(data):
1166 return F.context(next(iter(data)))
1167 else:
1168 return F.context(data)
1169
1170
1171def dtype_of(data):

Callers 7

node_subgraphFunction · 0.85
edge_subgraphFunction · 0.85
in_subgraphFunction · 0.85
out_subgraphFunction · 0.85
khop_in_subgraphFunction · 0.85
khop_out_subgraphFunction · 0.85
_build_neg_graphMethod · 0.85

Calls 3

contextMethod · 0.80
is_listlikeFunction · 0.70
valuesMethod · 0.45

Tested by

no test coverage detected