Skip to content

Commit d6495c4

Browse files
authored
Update _copy_utils.py
1 parent 16c8996 commit d6495c4

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

dpctl/tensor/_copy_utils.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,7 @@
4141
def _copy_to_numpy(ary):
4242
if not isinstance(ary, dpt.usm_ndarray):
4343
raise TypeError(f"Expected dpctl.tensor.usm_ndarray, got {type(ary)}")
44-
if ary.size == 0:
45-
# no data needs to be copied for zero sized array
46-
return np.ndarray(ary.shape, dtype=ary.dtype)
47-
nb = ary.usm_data.nbytes
48-
q = ary.sycl_queue
49-
hh = dpm.MemoryUSMHost(nb, queue=q)
50-
h = np.ndarray(nb, dtype="u1", buffer=hh).view(ary.dtype)
51-
itsz = ary.itemsize
52-
strides_bytes = tuple(si * itsz for si in ary.strides)
53-
offset = ary._element_offset * itsz
54-
# ensure that content of ary.usm_data is final
55-
q.wait()
56-
hh.copy_from_device(ary.usm_data)
57-
return np.ndarray(
58-
ary.shape,
59-
dtype=ary.dtype,
60-
buffer=h,
61-
strides=strides_bytes,
62-
offset=offset,
63-
)
44+
return ary.__array__()
6445

6546

6647
def _copy_from_numpy(np_ary, usm_type="device", sycl_queue=None):

0 commit comments

Comments
 (0)