is the CuPy counterpart of NumPy
. It provides an intuitive interface for a fixed-size multidimensional array which resides in a CUDA device.
For the basic concept of ndarrays, please refer to the
.
(shape[, dtype, memptr, ...])
Multi-dimensional array on a CUDA device.
Conversion to/from NumPy arrays
and
are not implicitly convertible to each other. That means, NumPy functions cannot take
s as inputs, and vice versa.
To convert
to
, use
or
.
To convert
to
, use
or
.
Note that converting between
and
incurs data transfer between the host (CPU) device and the GPU device, which is costly in terms of performance.
(obj[, dtype, copy, order, subok, ...])
Creates an array on the current device.
(a[, dtype, order, copy, blocking])
Converts an object to array.
(a[, stream, order, out, blocking])
Returns an array on the host memory from an arbitrary source array.
Code compatibility features
is designed to be interchangeable with
in terms of code compatibility as much as possible. But occasionally, you will need to know whether the arrays you’re handling are
or
. One example is when invoking module-level functions such as
or
. In such situations,
can be used.