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)
| 44 | |
| 45 | |
| 46 | def 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 |