diff --git a/dpctl/tensor/_copy_utils.py b/dpctl/tensor/_copy_utils.py index 13866fc973..e34eb54c5d 100644 --- a/dpctl/tensor/_copy_utils.py +++ b/dpctl/tensor/_copy_utils.py @@ -117,6 +117,12 @@ def _copy_from_numpy_into(dst, np_ary): if not isinstance(np_ary, np.ndarray): raise TypeError("Expected numpy.ndarray, got {}".format(type(np_ary))) src_ary = np.broadcast_to(np.asarray(np_ary, dtype=dst.dtype), dst.shape) + if (dst.flags & 1) and src_ary.flags["C"]: + dst.usm_data.copy_from_host(src_ary.reshape((-1,)).view("u1")) + return + if (dst.flags & 2) and src_ary.flags["F"]: + dst.usm_data.copy_from_host(src_ary.reshape((-1,)).view("u1")) + return for i in range(dst.size): mi = np.unravel_index(i, dst.shape) host_buf = np.array(src_ary[mi], ndmin=1).view("u1")