Skip to content

Commit a6d16f2

Browse files
Merge pull request #1284 from IntelPython/improve-overlap-check-in-copy
No need to call _copy_overlapping if src and dst address same memory
2 parents f032154 + 701c05b commit a6d16f2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

dpctl/tensor/_copy_utils.py

+5
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ def _copy_same_shape(dst, src):
213213
"""Assumes src and dst have the same shape."""
214214
# check that memory regions do not overlap
215215
if ti._array_overlap(dst, src):
216+
if src._pointer == dst._pointer and (
217+
src is dst
218+
or (src.strides == dst.strides and src.dtype == dst.dtype)
219+
):
220+
return
216221
_copy_overlapping(src=src, dst=dst)
217222
return
218223

0 commit comments

Comments
 (0)