wkcn 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_r351558270
 
 

 ##########
 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:
   It will break the computational graph, and could not compute the gradient.

----------------------------------------------------------------
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