Skip to content

Commit

Permalink
Pretty printing for unary elementwise functions
Browse files Browse the repository at this point in the history
- Fixed type error message for binary elementwise functions
  • Loading branch information
ndgrigorian committed Jun 1, 2023
1 parent f611fdb commit 70f5dfe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dpctl/tensor/_elementwise_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def __init__(self, name, result_type_resolver_fn, unary_dp_impl_fn, docs):
self.unary_fn_ = unary_dp_impl_fn
self.__doc__ = docs

def __str__(self):
return f"<UnaryElementwiseFunc '{self.name_}'>"

def __repr__(self):
return f"<UnaryElementwiseFunc '{self.name_}'>"

def __call__(self, x, out=None, order="K"):
if not isinstance(x, dpt.usm_ndarray):
raise TypeError(f"Expected dpctl.tensor.usm_ndarray, got {type(x)}")
Expand Down Expand Up @@ -389,7 +395,7 @@ def __call__(self, o1, o2, out=None, order="K"):

if res_dt is None:
raise TypeError(
"function 'add' does not support input types "
f"function '{self.name_}' does not support input types "
f"({o1_dtype}, {o2_dtype}), "
"and the inputs could not be safely coerced to any "
"supported types according to the casting rule ''safe''."
Expand Down

0 comments on commit 70f5dfe

Please sign in to comment.