MCPcopy
hub / github.com/zju3dv/4K4D / to_list

Function to_list

easyvolcap/utils/data_utils.py:938–949  ·  view source on GitHub ↗
(batch, non_blocking=False)

Source from the content-addressed store, hash-verified

936
937
938def to_list(batch, non_blocking=False) -> Union[List, Dict, np.ndarray]: # almost always exporting, should block
939 if isinstance(batch, (tuple, list)):
940 batch = [to_list(b, non_blocking) for b in batch]
941 elif isinstance(batch, dict):
942 batch = dotdict({k: to_list(v, non_blocking) for k, v in batch.items()})
943 elif isinstance(batch, torch.Tensor):
944 batch = batch.detach().to('cpu', non_blocking=non_blocking).numpy().tolist()
945 elif isinstance(batch, torch.Tensor):
946 batch = batch.tolist()
947 else: # others, keep as is
948 pass
949 return batch
950
951
952def to_cpu(batch, non_blocking=False, ignore_list: bool = False) -> torch.Tensor:

Callers 1

to_stringMethod · 0.90

Calls 2

dotdictClass · 0.90
numpyMethod · 0.80

Tested by

no test coverage detected