MCPcopy Create free account
hub / github.com/MAC-VO/MAC-VO / StructuralMove

Function StructuralMove

Utility/Utils.py:21–34  ·  view source on GitHub ↗
(obj, device)

Source from the content-addressed store, hash-verified

19
20
21def StructuralMove(obj, device) -> torch.Tensor | list | dict | None:
22 match obj:
23 case obj if torch.is_tensor(obj):
24 return obj.to(device)
25 case None:
26 return None
27 case dict():
28 return { k: StructuralMove(obj[k], device) for k in obj }
29 case list():
30 return [ StructuralMove(v, device) for v in obj ]
31 case np.ndarray():
32 return torch.tensor(obj).to(device)
33 case _:
34 raise ValueError(f"Unable to move type {type(obj)}")
35
36
37def cropToMultiple(x: torch.Tensor, factor: int | list[int], dim: int | list[int]):

Callers

nothing calls this directly

Calls 1

tensorMethod · 0.45

Tested by

no test coverage detected