Skip to content

Commit f6db04e

Browse files
Fix for copy of double precision NumPy array to device w/o HW support for DP
Routine to copy NumPy array to USM array casts double to single precision on host is sycl device does not support double precision
1 parent 290230a commit f6db04e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

dpctl/tensor/_copy_utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,15 @@ def _copy_from_numpy_into(dst, np_ary):
8181
if not isinstance(dst, dpt.usm_ndarray):
8282
raise TypeError("Expected usm_ndarray, got {}".format(type(dst)))
8383
src_ary = np.broadcast_to(np_ary, dst.shape)
84+
copy_q = dst.sycl_queue
85+
if copy_q.sycl_device.has_aspect_fp64 is False:
86+
src_ary_dt_c = src_ary.dtype.char
87+
if src_ary_dt_c == "d":
88+
src_ary = src_ary.astype(np.float32)
89+
elif src_ary_dt_c == "D":
90+
src_ary = src_ary.astype(np.complex64)
8491
ti._copy_numpy_ndarray_into_usm_ndarray(
85-
src=src_ary, dst=dst, sycl_queue=dst.sycl_queue
92+
src=src_ary, dst=dst, sycl_queue=copy_q
8693
)
8794

8895

0 commit comments

Comments
 (0)