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()[source]

Copies parameter variables and persistent values to CPU.

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)[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=None)[source]

Copies parameter variables and persistent values to GPU.

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.

Parameters

device – Target device specifier. If omitted, the current device is used.

Returns: self

to_intel64()[source]

Copies parameter variables and persistent values to CPU.

__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

device

Device instance.

xp

Array module corresponding to the device.

Depending on the device in which this object resides, this property returns numpy, cupy or chainerx.