dpctl.tensor.astype¶
- dpctl.tensor.astype(array, new_dtype, order='K', casting='unsafe', copy=True, device=None)[source]¶
Returns a copy of the
dpctl.tensor.usm_ndarray
, cast to a specified type.- Parameters:
array (usm_ndarray) – An input array.
new_dtype (dtype) – The data type of the resulting array. If None, gives default floating point type supported by device where the resulting array will be located.
order ({"C", "F", "A", "K"}, optional) – Controls memory layout of the resulting array if a copy is returned.
casting ({'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional) – Controls what kind of data casting may occur. Please see
numpy.ndarray.astype()
for description of casting modes.copy (bool, optional) – By default, astype always returns a newly allocated array. If this keyword is set to False, a view of the input array may be returned when possible.
device (object) – array API specification of device where the output array is created. Device can be specified by a a filter selector string, an instance of
dpctl.SyclDevice
, an instance ofdpctl.SyclQueue
, or an instance ofdpctl.tensor.Device
. If the value is None, returned array is created on the same device as array. Default: None.
- Returns:
An array with requested data type.
- Return type:
A view can be returned, if possible, when copy=False is used.