MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / maybe_to_cpu

Function maybe_to_cpu

PATH/core/memory.py:57–65  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

55 """
56
57 def maybe_to_cpu(x):
58 try:
59 like_gpu_tensor = x.device.type == "cuda" and hasattr(x, "to")
60 except AttributeError:
61 like_gpu_tensor = False
62 if like_gpu_tensor:
63 return x.to(device="cpu")
64 else:
65 return x
66
67 @wraps(func)
68 def wrapped(*args, **kwargs):

Callers 1

wrappedFunction · 0.85

Calls 1

toMethod · 0.45

Tested by

no test coverage detected