Skip to content

Commit f324c3f

Browse files
committed
Add CFD examples and update CFD check for dpnp.copy
1 parent 4ed70e2 commit f324c3f

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

dpnp/dpnp_iface_arraycreation.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,21 @@ def copy(
799799
>>> x[0] == z[0]
800800
array(False)
801801
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+
802817
"""
803818

804819
if subok is not False:
@@ -807,13 +822,14 @@ def copy(
807822
f"default value ``False``, but got {subok}"
808823
)
809824

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)
817833

818834
return array(
819835
a,

0 commit comments

Comments
 (0)