Skip to content

Commit 871646b

Browse files
committed
_zero_like now allocates using the same sycl_queue
This prevents unexpected behavior when calling `imag` i.e., for x with a real-valued data type `dpctl.tensor.atan2(x.imag, x.real)` would not work prior to this change
1 parent 434015f commit 871646b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dpctl/tensor/_usmarray.pyx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,14 +1306,15 @@ cdef usm_ndarray _m_transpose(usm_ndarray ary):
13061306

13071307
cdef usm_ndarray _zero_like(usm_ndarray ary):
13081308
"""
1309-
Make C-contiguous array of zero elements with same shape
1310-
and type as ary.
1309+
Make C-contiguous array of zero elements with same shape,
1310+
type, device, and sycl_queue as ary.
13111311
"""
13121312
cdef dt = _make_typestr(ary.typenum_)
13131313
cdef usm_ndarray r = usm_ndarray(
13141314
_make_int_tuple(ary.nd_, ary.shape_) if ary.nd_ > 0 else tuple(),
13151315
dtype=dt,
1316-
buffer=ary.base_.get_usm_type()
1316+
buffer=ary.base_.get_usm_type(),
1317+
buffer_ctor_kwargs={"queue": ary.get_sycl_queue()},
13171318
)
13181319
r.base_.memset()
13191320
return r

0 commit comments

Comments
 (0)