Skip to content

Using device or sycl_queue keyword, not both #1147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions dpnp/dpnp_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 6 additions & 5 deletions dpnp/dpnp_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand All @@ -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)
5 changes: 5 additions & 0 deletions dpnp/dpnp_utils/dpnp_algo_utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {}"
Expand Down