@@ -799,6 +799,21 @@ def copy(
799
799
>>> x[0] == z[0]
800
800
array(False)
801
801
802
+ Creating an array on a different device or with a specified usm_type
803
+
804
+ >>> x0 = np.array([1, 2, 3])
805
+ >>> x = np.copy(x0) # default case
806
+ >>> x, x.device, x.usm_type
807
+ (array([1, 2, 3]), Device(level_zero:gpu:0), 'device')
808
+
809
+ >>> y = np.copy(x0, device="cpu")
810
+ >>> y, y.device, y.usm_type
811
+ (array([1, 2, 3]), Device(opencl:cpu:0), 'device')
812
+
813
+ >>> z = np.copy(x0, usm_type="host")
814
+ >>> z, z.device, z.usm_type
815
+ (array([1, 2, 3]), Device(level_zero:gpu:0), 'host')
816
+
802
817
"""
803
818
804
819
if subok is not False :
@@ -807,13 +822,14 @@ def copy(
807
822
f"default value ``False``, but got { subok } "
808
823
)
809
824
810
- if (
811
- device is None
812
- and usm_type is None
813
- and sycl_queue is None
814
- and dpnp .is_supported_array_type (a )
815
- ):
816
- return dpnp_container .copy (a , order = order )
825
+ if dpnp .is_supported_array_type (a ):
826
+ sycl_queue_normalized = dpnp .get_normalized_queue_device (
827
+ a , device = device , sycl_queue = sycl_queue
828
+ )
829
+ if (
830
+ usm_type is None or usm_type == a .usm_type
831
+ ) and sycl_queue_normalized == a .sycl_queue :
832
+ return dpnp_container .copy (a , order = order )
817
833
818
834
return array (
819
835
a ,
0 commit comments