Skip to content

Commit 888a24b

Browse files
committed
Fixed issue in asarray_from_numpy for uint64 dtype. And changed call copy_to function
1 parent 2723947 commit 888a24b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

dpctl/tensor/_ctors.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ def _asarray_from_usm_ndarray(
186186
order=order,
187187
buffer_ctor_kwargs={"queue": copy_q},
188188
)
189-
# FIXME: call copy_to when implemented
190-
res[(slice(None, None, None),) * res.ndim] = usm_ndary
189+
hev, _ = ti._copy_usm_ndarray_into_usm_ndarray(
190+
src=usm_ndary, dst=res, sycl_queue=copy_q
191+
)
192+
hev.wait()
191193
return res
192194

193195

@@ -207,7 +209,7 @@ def _asarray_from_numpy_ndarray(
207209
if dtype is None:
208210
ary_dtype = ary.dtype
209211
dtype = _get_dtype(dtype, copy_q, ref_type=ary_dtype)
210-
if dtype.itemsize > ary_dtype.itemsize:
212+
if dtype.itemsize > ary_dtype.itemsize or ary_dtype == np.uint64:
211213
dtype = ary_dtype
212214
f_contig = ary.flags["F"]
213215
c_contig = ary.flags["C"]
@@ -244,8 +246,9 @@ def _asarray_from_numpy_ndarray(
244246
order=order,
245247
buffer_ctor_kwargs={"queue": copy_q},
246248
)
247-
# FIXME: call copy_to when implemented
248-
res[(slice(None, None, None),) * res.ndim] = ary
249+
ti._copy_numpy_ndarray_into_usm_ndarray(
250+
src=ary, dst=res, sycl_queue=copy_q
251+
)
249252
return res
250253

251254

dpctl/tests/test_usm_ndarray_ctor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,3 +1458,8 @@ def test_flags():
14581458
f.writable
14591459
# check comparison with generic types
14601460
f == Ellipsis
1461+
1462+
def test_asarray_uint64():
1463+
Xnp = np.ndarray(1, dtype=np.uint64)
1464+
X = dpt.asarray(Xnp)
1465+
assert X.dtype == Xnp.dtype

0 commit comments

Comments
 (0)