diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index c0bd122aea18..28b3ceac7acf 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -61,12 +61,8 @@ def __init__(self, "".format(shape, buffer.shape) ) self._array_obj = dpt.asarray(buffer, - dtype=buffer.dtype, copy=False, - order=order, - device=buffer.sycl_device, - usm_type=buffer.usm_type, - sycl_queue=buffer.sycl_queue) + order=order) else: sycl_queue_normalized = normalize_queue_device(sycl_queue=sycl_queue, device=device) self._array_obj = dpt.usm_ndarray(shape, diff --git a/dpnp/dpnp_container.py b/dpnp/dpnp_container.py index a983b1971615..efb5d67128cf 100644 --- a/dpnp/dpnp_container.py +++ b/dpnp/dpnp_container.py @@ -41,7 +41,7 @@ import numpy import dpctl.tensor as dpt - +from dpctl.tensor._device import normalize_queue_device if config.__DPNP_OUTPUT_DPCTL__: try: @@ -76,13 +76,13 @@ def asarray(x1, else: x1_obj = x1 + sycl_queue_normalized = normalize_queue_device(sycl_queue=sycl_queue, device=device) array_obj = dpt.asarray(x1_obj, dtype=dtype, copy=copy, order=order, - device=device, usm_type=usm_type, - sycl_queue=sycl_queue) + sycl_queue=sycl_queue_normalized) return dpnp_array(array_obj.shape, buffer=array_obj, order=order) @@ -94,11 +94,12 @@ def empty(shape, usm_type="device", sycl_queue=None): """Creates `dpnp_array` from uninitialized USM allocation.""" + sycl_queue_normalized = normalize_queue_device(sycl_queue=sycl_queue, device=device) + array_obj = dpt.empty(shape, dtype=dtype, order=order, - device=device, usm_type=usm_type, - sycl_queue=sycl_queue) + sycl_queue=sycl_queue_normalized) return dpnp_array(array_obj.shape, buffer=array_obj, order=order) diff --git a/dpnp/dpnp_utils/dpnp_algo_utils.pyx b/dpnp/dpnp_utils/dpnp_algo_utils.pyx index 2eba38cff59a..86a670c13601 100644 --- a/dpnp/dpnp_utils/dpnp_algo_utils.pyx +++ b/dpnp/dpnp_utils/dpnp_algo_utils.pyx @@ -399,6 +399,8 @@ cdef dpnp_descriptor create_output_descriptor(shape_type_c output_shape, if requested_out is None: result = None + if sycl_queue is not None: + device = None result_dtype = dpnp_DPNPFuncType_to_dtype(< size_t > c_type) result_obj = dpnp_container.empty(output_shape, dtype=result_dtype, @@ -541,6 +543,9 @@ cdef tuple get_common_usm_allocation(dpnp_descriptor x1, dpnp_descriptor x2): "".format(array1_obj.usm_type, array2_obj.usm_type)) common_sycl_queue = dpctl.utils.get_execution_queue((array1_obj.sycl_queue, array2_obj.sycl_queue)) + # TODO: refactor, remove when CFD is implemented in all array constructors + if common_sycl_queue is None and array1_obj.sycl_context == array2_obj.sycl_context: + common_sycl_queue = array1_obj.sycl_queue if common_sycl_queue is None: raise ValueError( "could not recognize common SYCL queue for inputs in SYCL queues {} and {}"