Skip to content

Commit 4138cb4

Browse files
committed
full_like now validates and casts a Python scalar fill_value on order="K" path
1 parent 2282c5b commit 4138cb4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dpctl/tensor/_ctors.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,20 @@ def full_like(
14801480
_manager.add_event_pair(hev, copy_ev)
14811481
return res
14821482
else:
1483+
fill_value_type = type(fill_value)
1484+
dtype = _get_dtype(dtype, sycl_queue, ref_type=fill_value_type)
14831485
res = _empty_like_orderK(x, dtype, usm_type, sycl_queue)
1486+
if fill_value_type in [float, complex] and np.issubdtype(
1487+
dtype, np.integer
1488+
):
1489+
fill_value = int(fill_value.real)
1490+
elif fill_value_type is complex and np.issubdtype(
1491+
dtype, np.floating
1492+
):
1493+
fill_value = fill_value.real
1494+
elif fill_value_type is int and np.issubdtype(dtype, np.integer):
1495+
fill_value = _to_scalar(fill_value, dtype)
1496+
14841497
_manager = dpctl.utils.SequentialOrderManager[sycl_queue]
14851498
# populating new allocation, no dependent events
14861499
hev, full_ev = ti._full_usm_ndarray(fill_value, res, sycl_queue)

0 commit comments

Comments
 (0)