dpnp.copy¶
- dpnp.copy(a, order='K', subok=False, device=None, usm_type=None, sycl_queue=None)[source]¶
Return an array copy of the given object.
For full documentation refer to
numpy.copy.- Parameters:
- aarray_like
Input data, in any form that can be converted to an array. This includes scalars, lists, lists of tuples, tuples, tuples of tuples, tuples of lists, and ndarrays.
- order{None, "C", "F", "A", "K"}, optional
Memory layout of the newly output array.
Default:
"K".- device{None, string, SyclDevice, SyclQueue, Device}, optional
An array API concept of device where the output array is created. device can be
None, a oneAPI filter selector string, an instance ofdpctl.SyclDevicecorresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue, or adpnp.tensor.Deviceobject returned bydpnp.ndarray.device.Default:
None.- usm_type{None, "device", "shared", "host"}, optional
The type of SYCL USM allocation for the output array.
Default:
None.- sycl_queue{None, SyclQueue}, optional
A SYCL queue to use for output array allocation and copying. The sycl_queue can be passed as
None(the default), which means to get the SYCL queue from device keyword if present or to use a default queue.Default:
None.
- Returns:
- outdpnp.ndarray
Array interpretation of a.
Limitations
Parameter subok is supported only with default value
False. Otherwise, the function raisesNotImplementedErrorexception.See also
dpnp.ndarray.copyPreferred method for creating an array copy
Notes
This is equivalent to:
>>> dpnp.array(a, copy=True)
Examples
Create an array x, with a reference y and a copy z:
>>> import dpnp as np >>> x = np.array([1, 2, 3]) >>> y = x >>> z = np.copy(x)
Note that, when we modify x, y will change, but not z:
>>> x[0] = 10 >>> x[0] == y[0] array(True) >>> x[0] == z[0] array(False)
Creating an array on a different device or with a specified usm_type
>>> x0 = np.array([1, 2, 3]) >>> x = np.copy(x0) # default case >>> x, x.device, x.usm_type (array([1, 2, 3]), Device(level_zero:gpu:0), 'device')
>>> y = np.copy(x0, device="cpu") >>> y, y.device, y.usm_type (array([1, 2, 3]), Device(opencl:cpu:0), 'device')
>>> z = np.copy(x0, usm_type="host") >>> z, z.device, z.usm_type (array([1, 2, 3]), Device(level_zero:gpu:0), 'host')