Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dpctl/tensor/_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ def clip(x, /, min=None, max=None, out=None, order="K"):
)
if order not in ["K", "C", "F", "A"]:
order = "K"
if x.dtype.kind in "iu":
if isinstance(min, int) and min <= dpt.iinfo(x.dtype).min:
min = None
if isinstance(max, int) and max >= dpt.iinfo(x.dtype).max:
max = None
if min is None and max is None:
exec_q = x.sycl_queue
orig_out = out
Expand Down
8 changes: 8 additions & 0 deletions dpctl/tests/test_tensor_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,3 +767,11 @@ def test_clip_readonly_out():

with pytest.raises(ValueError):
dpt.clip(x, out=r)


def test_clip_gh_1744():
get_queue_or_skip()
x = dpt.asarray([0, 255], dtype=dpt.uint8)
y = dpt.clip(x, -300, 300)

assert dpt.all(x == y)