MCPcopy
hub / github.com/yerfor/GeneFacePlusPlus / convert_like

Function convert_like

utils/commons/tensor_utils.py:83–92  ·  view source on GitHub ↗
(inp, target)

Source from the content-addressed store, hash-verified

81 return ret
82
83def convert_like(inp, target):
84 if isinstance(target, np.ndarray):
85 return convert_to_np(inp)
86 elif isinstance(target, torch.Tensor):
87 inp = convert_to_tensor(inp)
88 inp = inp.to()
89 if target.device == 'cpu':
90 return move_to_cpu(inp)
91 else:
92 return move_to_cuda(inp)
93
94def move_to_cpu(tensors):
95 ret = {}

Callers

nothing calls this directly

Calls 5

convert_to_npFunction · 0.85
convert_to_tensorFunction · 0.85
move_to_cpuFunction · 0.85
move_to_cudaFunction · 0.85
toMethod · 0.45

Tested by

no test coverage detected