Skip to content

Commit 01a11e4

Browse files
committed
sycl_queue check returned for dpnp.asarray() function.
1 parent 0568397 commit 01a11e4

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

dpnp/dpnp_container.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,34 @@ def asarray(x1,
8686
usm_type=None,
8787
sycl_queue=None):
8888
"""Converts `x1` to `dpnp_array`."""
89-
if isinstance(x1, dpnp_array):
90-
x1_obj = x1.get_array()
91-
else:
92-
x1_obj = x1
89+
dpu.validate_usm_type(usm_type, allow_none=True)
9390

9491
if order is None:
9592
order = 'C'
9693

9794
"""Converts incoming 'x1' object to 'dpnp_array'."""
98-
array_obj = dpt.asarray(x1_obj,
99-
dtype=dtype,
100-
copy=copy,
101-
order=order,
102-
device=device,
103-
usm_type=usm_type,
104-
sycl_queue=sycl_queue)
95+
if isinstance(x1, (list, tuple, range)):
96+
array_obj = dpt.asarray(x1,
97+
dtype=dtype,
98+
copy=copy,
99+
order=order,
100+
device=device,
101+
usm_type=usm_type,
102+
sycl_queue=sycl_queue)
103+
else:
104+
if isinstance(x1, dpnp_array):
105+
x1_obj = x1.get_array()
106+
else:
107+
x1_obj = x1
108+
109+
sycl_queue_normalized = dpnp.get_normalized_queue_device(x1_obj, device=device, sycl_queue=sycl_queue)
110+
111+
array_obj = dpt.asarray(x1_obj,
112+
dtype=dtype,
113+
copy=copy,
114+
order=order,
115+
usm_type=usm_type,
116+
sycl_queue=sycl_queue_normalized)
105117
return dpnp_array(array_obj.shape, buffer=array_obj, order=order)
106118

107119

0 commit comments

Comments
 (0)