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

Method to_empty

python/oneflow/nn/modules/module.py:1408–1418  ·  view source on GitHub ↗

r"""Moves the parameters and buffers to the specified device without copying storage. Args: device (:class:`oneflow.device`): the desired device of the parameters and buffers in this module Returns: Module: self

(self: T, *, device: Union[str, flow.device])

Source from the content-addressed store, hash-verified

1406 return self
1407
1408 def to_empty(self: T, *, device: Union[str, flow.device]) -> T:
1409 r"""Moves the parameters and buffers to the specified device without copying storage.
1410
1411 Args:
1412 device (:class:`oneflow.device`): the desired device of the parameters
1413 and buffers in this module
1414
1415 Returns:
1416 Module: self
1417 """
1418 return self._apply(lambda t: flow.empty_like(t, device=device))
1419
1420 def _to_memory_format(self, memory_format):
1421 r"""Casts the parameters and buffers in this module to another memory format.

Callers 1

skip_initFunction · 0.80

Calls 1

_applyMethod · 0.95

Tested by

no test coverage detected