cupy.astype#
- cupy.astype(x, dtype, /, *, copy=True)[source]#
Copies an array to a specified data type.
This function is an Array API compatible alternative to cupy.ndarray.astype.
- Parameters:
x (ndarray) – Input CuPy array to cast.
dtype (dtype) – Data type of the result.
copy (bool, optional) – Specifies whether to copy an array when the specified dtype matches the data type of the input array
x
. IfTrue
, a newly allocated array must always be returned. IfFalse
and the specified dtype matches the data type of the input array, the input array must be returned; otherwise, a newly allocated array must be returned. Defaults toTrue
.
- Returns:
out – An array having the specified data type.
- Return type:
See also