Skip to content

Commit 4366943

Browse files
committed
Throw ValueError when types cannot be resolved
Previously, elementwise functions and clip would throw a TypeError in this case
1 parent f856624 commit 4366943

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

dpctl/tensor/_clip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def _clip_none(x, val, out, order, _binary_fn):
246246
_fp16 = sycl_dev.has_aspect_fp16
247247
_fp64 = sycl_dev.has_aspect_fp64
248248
if not _can_cast(val_dtype, res_dt, _fp16, _fp64):
249-
raise TypeError(
249+
raise ValueError(
250250
f"function 'clip' does not support input types "
251251
f"({x_dtype}, {val_dtype}), "
252252
"and the inputs could not be safely coerced to any "
@@ -527,7 +527,7 @@ def clip(x, min=None, max=None, out=None, order="K"):
527527
)
528528

529529
if res_dt is None:
530-
raise TypeError(
530+
raise ValueError(
531531
f"function '{clip}' does not support input types "
532532
f"({x_dtype}, {min_dtype}, {max_dtype}), "
533533
"and the inputs could not be safely coerced to any "

dpctl/tensor/_elementwise_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def __call__(self, o1, o2, out=None, order="K"):
481481
)
482482

483483
if res_dt is None:
484-
raise TypeError(
484+
raise ValueError(
485485
f"function '{self.name_}' does not support input types "
486486
f"({o1_dtype}, {o2_dtype}), "
487487
"and the inputs could not be safely coerced to any "

0 commit comments

Comments
 (0)