mxnet.npx.cpu_pinned

cpu_pinned(device_id=0)

Returns a CPU pinned memory device. Copying from CPU pinned memory to GPU is faster than from normal CPU memory.

This function is a short cut for Device('cpu_pinned', device_id).

Examples

>>> with mx.cpu_pinned():
...     cpu_array = mx.np.ones((2, 3))
>>> cpu_array.device
cpu_pinned(0)
>>> cpu_array = mx.np.ones((2, 3), ctx=mx.cpu_pinned())
>>> cpu_array.device
cpu_pinned(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 pinned memory device.

Return type

Device