reminisce commented on a change in pull request #17609: [numpy] add fallback ops
URL: https://github.com/apache/incubator-mxnet/pull/17609#discussion_r380000606
 
 

 ##########
 File path: python/mxnet/numpy/multiarray.py
 ##########
 @@ -244,14 +274,10 @@ def __array_function__(self, func, types, args, kwargs): 
 # pylint: disable=bad-
         mx_np_func = _NUMPY_ARRAY_FUNCTION_DICT.get(func, None)
         if mx_np_func is None:
             # try to fallback to official NumPy op
-            new_args = []
-            cur_ctx = None
-            for arg in args:
-                if isinstance(arg, ndarray):
-                    cur_ctx = arg.ctx
-                    new_args.append(arg.asnumpy())
-                else:
-                    new_args.append(arg)
+            new_args, cur_ctx = _as_onp_array(args)
 
 Review comment:
   Please add a check above this line to assert autograd is not on.
   ```python
   if autograd.is_recording():
       raise ValueError("Falling back to NumPy operator {} with autograd active 
is not supported. Please consider moving the operator to the outside of the 
autograd scope.").format(op_name)
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to