Skip to content

Commit 1b5173d

Browse files
Using device or sycl_queue keyword, not both (#1147)
* Using device or sycl_queue keyword, not both
1 parent 395f051 commit 1b5173d

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

dpnp/dpnp_array.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,8 @@ def __init__(self,
6161
"".format(shape, buffer.shape)
6262
)
6363
self._array_obj = dpt.asarray(buffer,
64-
dtype=buffer.dtype,
6564
copy=False,
66-
order=order,
67-
device=buffer.sycl_device,
68-
usm_type=buffer.usm_type,
69-
sycl_queue=buffer.sycl_queue)
65+
order=order)
7066
else:
7167
sycl_queue_normalized = normalize_queue_device(sycl_queue=sycl_queue, device=device)
7268
self._array_obj = dpt.usm_ndarray(shape,

dpnp/dpnp_container.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import numpy
4242

4343
import dpctl.tensor as dpt
44-
44+
from dpctl.tensor._device import normalize_queue_device
4545

4646
if config.__DPNP_OUTPUT_DPCTL__:
4747
try:
@@ -76,13 +76,13 @@ def asarray(x1,
7676
else:
7777
x1_obj = x1
7878

79+
sycl_queue_normalized = normalize_queue_device(sycl_queue=sycl_queue, device=device)
7980
array_obj = dpt.asarray(x1_obj,
8081
dtype=dtype,
8182
copy=copy,
8283
order=order,
83-
device=device,
8484
usm_type=usm_type,
85-
sycl_queue=sycl_queue)
85+
sycl_queue=sycl_queue_normalized)
8686

8787
return dpnp_array(array_obj.shape, buffer=array_obj, order=order)
8888

@@ -94,11 +94,12 @@ def empty(shape,
9494
usm_type="device",
9595
sycl_queue=None):
9696
"""Creates `dpnp_array` from uninitialized USM allocation."""
97+
sycl_queue_normalized = normalize_queue_device(sycl_queue=sycl_queue, device=device)
98+
9799
array_obj = dpt.empty(shape,
98100
dtype=dtype,
99101
order=order,
100-
device=device,
101102
usm_type=usm_type,
102-
sycl_queue=sycl_queue)
103+
sycl_queue=sycl_queue_normalized)
103104

104105
return dpnp_array(array_obj.shape, buffer=array_obj, order=order)

dpnp/dpnp_utils/dpnp_algo_utils.pyx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ cdef dpnp_descriptor create_output_descriptor(shape_type_c output_shape,
399399

400400
if requested_out is None:
401401
result = None
402+
if sycl_queue is not None:
403+
device = None
402404
result_dtype = dpnp_DPNPFuncType_to_dtype(< size_t > c_type)
403405
result_obj = dpnp_container.empty(output_shape,
404406
dtype=result_dtype,
@@ -541,6 +543,9 @@ cdef tuple get_common_usm_allocation(dpnp_descriptor x1, dpnp_descriptor x2):
541543
"".format(array1_obj.usm_type, array2_obj.usm_type))
542544

543545
common_sycl_queue = dpctl.utils.get_execution_queue((array1_obj.sycl_queue, array2_obj.sycl_queue))
546+
# TODO: refactor, remove when CFD is implemented in all array constructors
547+
if common_sycl_queue is None and array1_obj.sycl_context == array2_obj.sycl_context:
548+
common_sycl_queue = array1_obj.sycl_queue
544549
if common_sycl_queue is None:
545550
raise ValueError(
546551
"could not recognize common SYCL queue for inputs in SYCL queues {} and {}"

0 commit comments

Comments
 (0)