MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / module_to

Function module_to

python/oneflow/framework/check_point_v2.py:252–258  ·  view source on GitHub ↗
(obj: flow.nn.Module, dest: MAP_LOCATION)

Source from the content-addressed store, hash-verified

250
251
252def module_to(obj: flow.nn.Module, dest: MAP_LOCATION) -> "oneflow.nn.Module":
253 restore_location = _get_restore_location(dest)
254 # for nn.Module object, we will use a tensor to get the device
255 # to support dest with a Callable type
256 device = restore_location(flow.tensor([0])).device
257 obj.to(device)
258 return obj
259
260
261def _map_location(obj: Any, map_location: MAP_LOCATION):

Callers 1

_map_locationFunction · 0.85

Calls 3

_get_restore_locationFunction · 0.85
restore_locationFunction · 0.85
toMethod · 0.45

Tested by

no test coverage detected