chainer.DeviceResident¶
-
class
chainer.
DeviceResident
[source]¶ A base class of objects with multi-device hierarchy.
Methods
-
device_resident_accept
(visitor)[source]¶ Applies the visitor to all the device objects in this instance.
- Parameters
visitor (DeviceResidentsVisitor) – Visitor.
This method should be overridden if the concrete class has custom sub-hierarchy of device resident objects.
-
from_chx
()[source]¶ Converts parameter variables and persistent values from ChainerX to NumPy/CuPy devices without any copy.
-
to_chx
()[source]¶ Converts parameter variables and persistent values to ChainerX without any copy.
This method does not handle non-registered attributes. If some of such attributes must be copied to ChainerX, the link implementation must override this method to do so.
Returns: self
-
to_cpu
() → chainer.device_resident.DeviceResident[source]¶ Copies parameter variables and persistent values to CPU.
Deprecated since version v7.0.0: Use
to_device()
instead.This method does not handle non-registered attributes. If some of such attributes must be copied to CPU, the link implementation should override
device_resident_accept()
to do so.Returns: self
-
to_device
(device: Union[backend.Device, chainerx.Device, cuda.Device, str, Tuple[str, int], ModuleType, Tuple[ModuleType, int]]) → DeviceResident[source]¶ Copies parameter variables and persistent values to the specified device.
This method does not handle non-registered attributes. If some of such attributes must be copied to the device, the link implementation must override this method to do so.
- Parameters
device – Target device specifier. See
get_device()
for available values.
Returns: self
-
to_gpu
(device: Union[cuda.Device, int, numpy.integer, None] = None) → chainer.device_resident.DeviceResident[source]¶ Copies parameter variables and persistent values to GPU.
Deprecated since version v7.0.0: Use
to_device()
instead.This method does not handle non-registered attributes. If some of such attributes must be copied to GPU, the link implementation must override
device_resident_accept()
to do so.Warning
This method does not transfer the parameters if they are already on GPU. Use
to_device
to perform inter-GPU transfer.- Parameters
device – Target device specifier. If omitted, the current device is used.
Returns: self
-
to_intel64
() → chainer.device_resident.DeviceResident[source]¶ Copies parameter variables and persistent values to CPU.
Deprecated since version v7.0.0: Use
to_device()
instead.
-
__eq__
()¶ Return self==value.
-
__ne__
()¶ Return self!=value.
-
__lt__
()¶ Return self<value.
-
__le__
()¶ Return self<=value.
-
__gt__
()¶ Return self>value.
-
__ge__
()¶ Return self>=value.
Attributes
-