Skip to content

Commit 1a0cf15

Browse files
Used ti._array_overlap instead of local implementation
1 parent bd9e465 commit 1a0cf15

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

dpctl/tensor/_copy_utils.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,6 @@
3131
)
3232

3333

34-
def _has_memory_overlap(x1, x2):
35-
if x1.size and x2.size:
36-
m1 = dpm.as_usm_memory(x1)
37-
m2 = dpm.as_usm_memory(x2)
38-
# can only overlap if bound to the same context
39-
if m1.sycl_context == m2.sycl_context:
40-
p1_beg = m1._pointer
41-
p1_end = p1_beg + m1.nbytes
42-
p2_beg = m2._pointer
43-
p2_end = p2_beg + m2.nbytes
44-
# may intersect if not ((p1_beg >= p2_end) or (p2_beg >= p2_end))
45-
return (p1_beg < p2_end) and (p2_beg < p1_end)
46-
return False
47-
# zero element array do not overlap anything
48-
return False
49-
50-
5134
def _copy_to_numpy(ary):
5235
if not isinstance(ary, dpt.usm_ndarray):
5336
raise TypeError
@@ -209,7 +192,7 @@ def _copy_overlapping(dst, src):
209192
def _copy_same_shape(dst, src):
210193
"""Assumes src and dst have the same shape."""
211194
# check that memory regions do not overlap
212-
if _has_memory_overlap(dst, src):
195+
if ti._array_overlap(dst, src):
213196
_copy_overlapping(src=src, dst=dst)
214197
return
215198

0 commit comments

Comments
 (0)