Skip to content

Commit 09cd171

Browse files
Improve race condition check for unary functions
Of out array is logically the same as input array, there is no race condition, so avoid performing the temporary copy.
1 parent ea0579d commit 09cd171

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

dpctl/tensor/_elementwise_common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ def __call__(self, x, out=None, order="K"):
7979
f" got {out.dtype}"
8080
)
8181

82-
if buf_dt is None and ti._array_overlap(x, out):
82+
if (
83+
buf_dt is None
84+
and ti._array_overlap(x, out)
85+
and not ti._same_logical_tensors(x, out)
86+
):
8387
# Allocate a temporary buffer to avoid memory overlapping.
8488
# Note if `buf_dt` is not None, a temporary copy of `x` will be
8589
# created, so the array overlap check isn't needed.

0 commit comments

Comments
 (0)