Skip to content

Commit 70f5dfe

Browse files
committed
Pretty printing for unary elementwise functions
- Fixed type error message for binary elementwise functions
1 parent f611fdb commit 70f5dfe

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

dpctl/tensor/_elementwise_common.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ def __init__(self, name, result_type_resolver_fn, unary_dp_impl_fn, docs):
4747
self.unary_fn_ = unary_dp_impl_fn
4848
self.__doc__ = docs
4949

50+
def __str__(self):
51+
return f"<UnaryElementwiseFunc '{self.name_}'>"
52+
53+
def __repr__(self):
54+
return f"<UnaryElementwiseFunc '{self.name_}'>"
55+
5056
def __call__(self, x, out=None, order="K"):
5157
if not isinstance(x, dpt.usm_ndarray):
5258
raise TypeError(f"Expected dpctl.tensor.usm_ndarray, got {type(x)}")
@@ -389,7 +395,7 @@ def __call__(self, o1, o2, out=None, order="K"):
389395

390396
if res_dt is None:
391397
raise TypeError(
392-
"function 'add' does not support input types "
398+
f"function '{self.name_}' does not support input types "
393399
f"({o1_dtype}, {o2_dtype}), "
394400
"and the inputs could not be safely coerced to any "
395401
"supported types according to the casting rule ''safe''."

0 commit comments

Comments
 (0)