reminisce commented on a change in pull request #16923: [WIP] Fallback 
mechanism for mx.np operators
URL: https://github.com/apache/incubator-mxnet/pull/16923#discussion_r351603076
 
 

 ##########
 File path: python/mxnet/numpy/multiarray.py
 ##########
 @@ -202,13 +220,13 @@ def __array_ufunc__(self, ufunc, method, *inputs, 
**kwargs):  # pylint: disable=
             name = ufunc.__name__
             mx_ufunc = _NUMPY_ARRAY_UFUNC_DICT.get(name, None)
             if mx_ufunc is None:
-                raise ValueError('mxnet.numpy operator `{}` has not been 
registered in '
-                                 'the _NUMPY_ARRAY_UFUNC_LIST. Please make 
sure you are '
-                                 'using NumPy >= 1.15.0 and the operator 
implementation '
-                                 'is compatible with NumPy. Then add the 
operator name '
-                                 'to the list.'
-                                 .format(name))
-            return mx_ufunc(*inputs, **kwargs)
+                # try to fallback to official NumPy op
+                onp_op = _get_np_op(name)
+                new_inputs = [arg.asnumpy() if isinstance(arg, ndarray) else 
arg for arg in inputs]
+                out = onp_op(*new_inputs, **kwargs)
 
 Review comment:
   We are aware of this. More sophisticated fallback mechanism is illustrated 
in https://github.com/apache/incubator-mxnet/pull/16698 by leveraging 
`CustomOp`. To reach 100% NumPy op coverage within a month, this the simplest 
and fastest pathway though. In the future, we will gradually replace those 
fallback ops with native implementation in backend.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to