Handle methods not having __module__
@@ -21,11 +21,24 @@ def _dispatch_notification(func):
dispatch_type = _ufunc_config.get_config_fallback_mode()
callback_func = _ufunc_config.get_fallback_mode_callback()
+ _module = hasattr(func, '__module__')
+ _name = hasattr(func, '__name__')
+
+ if _name and _module:
msg = "'{}' method not in cupy, falling back to '{}.{}'".format(
func.__name__, func.__module__, func.__name__)
-
- raise_msg = "'{}' method not found in cupy".format(
+ elif _name:
+ msg = "'{}' method not in cupy, ".format(func.__name__)
+ msg += "falling back to numpy implementation of '{}'".format(
func.__name__)
+ else:
+ msg = "This method is not available in cupy, "
+ msg += "falling back to numpy"
+
+ if _name:
+ raise_msg = "'{}' method not found in cupy".format(func.__name__)
+ else:
+ raise_msg = "This method is not available in cupy"
if dispatch_type == 'print':
print("Warning: {}".format(msg))
