cupy.asarray#
- cupy.asarray(a, dtype=None, order=None, *, copy=None, blocking=False)[source]#
Converts an object to array.
This is equivalent to
array(a, dtype, copy=False, order=order).- Parameters:
a – The source object.
dtype – Data type specifier. It is inferred from the input by default.
order ({'C', 'F', 'A', 'K'}) – Whether to use row-major (C-style) or column-major (Fortran-style) memory representation. Defaults to
'K'.orderis ignored for objects that are notcupy.ndarray, but have the__cuda_array_interface__attribute.copy (bool, optional) – If
True,objis always copied. IfFalse, prohibits copy and raises ValueError on failure. IfNone(default),objis copied only when necessary.blocking (bool) – Default is
False, meaning if a H2D copy is needed it would run asynchronously on the current stream, and users are responsible for ensuring the stream order. For example, writing to the sourceawithout proper ordering while copying would result in a race condition. If set toTrue, the copy is synchronous (with respect to the host).
- Returns:
An array on the current device. If
ais already on the device, no copy is performed.- Return type:
Note
If
ais an numpy.ndarray instance that contains big-endian data, this function automatically swaps its byte order to little-endian, which is the NVIDIA and AMD GPU architecture’s native use.See also