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

Function load_tensors

python/dgl/data/tensor_serialize.py:46–69  ·  view source on GitHub ↗

load dict of tensors from file Parameters ---------- filename : str File name to load dict of tensors. return_dgl_ndarray: bool Whether return dict of dgl NDArrays or backend tensors Returns --------- tensor_dict : dict dict of tensor or nda

(filename, return_dgl_ndarray=False)

Source from the content-addressed store, hash-verified

44
45
46def load_tensors(filename, return_dgl_ndarray=False):
47 """
48 load dict of tensors from file
49
50 Parameters
51 ----------
52 filename : str
53 File name to load dict of tensors.
54 return_dgl_ndarray: bool
55 Whether return dict of dgl NDArrays or backend tensors
56
57 Returns
58 ---------
59 tensor_dict : dict
60 dict of tensor or ndarray based on return_dgl_ndarray flag
61 """
62 nd_dict = _CAPI_LoadNDArrayDict(filename)
63 tensor_dict = {}
64 for key, value in nd_dict.items():
65 if return_dgl_ndarray:
66 tensor_dict[key] = value
67 else:
68 tensor_dict[key] = F.zerocopy_from_dgl_ndarray(value)
69 return tensor_dict

Callers 5

read_orig_idsFunction · 0.85
load_partition_featsFunction · 0.85
read_orig_idsFunction · 0.85
test_serialize_tensorsFunction · 0.85

Calls 1

itemsMethod · 0.45

Tested by 3

read_orig_idsFunction · 0.68
test_serialize_tensorsFunction · 0.68