mxnet.npx.cpu

cpu(device_id=0)

Returns a CPU device.

This function is a short cut for Device('cpu', device_id). For most operations, when no device is specified, the default device is cpu().

Examples

>>> with mx.cpu():
...     cpu_array = mx.np.ones((2, 3))
>>> cpu_array.device
cpu(0)
>>> cpu_array = mx.np.ones((2, 3), ctx=mx.cpu())
>>> cpu_array.device
cpu(0)
Parameters

device_id (int, optional) – The device id of the device. device_id is not needed for CPU. This is included to make interface compatible with GPU.

Returns

device – The corresponding CPU device.

Return type

Device