Skip to content

Commit 3ba1b21

Browse files
committed
handle unsupported dtype for given device in asarray
asarray now treats usm_ndarray the same as numpy arrays when the dtype of the array is not supported by targeted device
1 parent a26cac1 commit 3ba1b21

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

dpctl/tensor/_ctors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ def _asarray_from_usm_ndarray(
111111
raise TypeError(
112112
f"Expected dpctl.tensor.usm_ndarray, got {type(usm_ndary)}"
113113
)
114-
if dtype is None:
115-
dtype = usm_ndary.dtype
116114
if usm_type is None:
117115
usm_type = usm_ndary.usm_type
118116
if sycl_queue is not None:
@@ -122,6 +120,8 @@ def _asarray_from_usm_ndarray(
122120
copy_q = normalize_queue_device(sycl_queue=sycl_queue, device=exec_q)
123121
else:
124122
copy_q = usm_ndary.sycl_queue
123+
if dtype is None:
124+
dtype = _map_to_device_dtype(usm_ndary.dtype, copy_q)
125125
# Conditions for zero copy:
126126
can_zero_copy = copy is not True
127127
# dtype is unchanged

0 commit comments

Comments
 (0)