You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2021/05/03 01:16:59 UTC

[GitHub] [incubator-mxnet] wkcn opened a new pull request #20233: [BUGFIX] fix numpy op fallback bug when ndarray in kwargs

wkcn opened a new pull request #20233:
URL: https://github.com/apache/incubator-mxnet/pull/20233


   ## Description ##
   
   This PR fixes the issue #20232 
   When a operator is not implemented in MXNet, it will be fallbacked to official numpy operator.
   However, it will trigger a bug when the NDArray only exist in `kwargs`.
    
   The reason is that the function `_as_onp_array` in [`multiarray.py#L380`](https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/numpy/multiarray.py#L380) could not discriminate the NDArray in `kwargs`.
   
   
   
   ## Checklist ##
   ### Essentials ###
   - [x] PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
   - [x] Changes are complete (i.e. I finished coding on this PR)
   - [ ] All changes have test coverage
   - [x] Code is well-documented
   
   ### Changes ###
   - [x] make the function  `_as_onp_array` in [`multiarray.py#L380`](https://github.com/apache/incubator-mxnet/blob/master/python/mxnet/numpy/multiarray.py#L380) support NDArray in `kwargs`.
   - [x] add a related unittest


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



[GitHub] [incubator-mxnet] wkcn commented on a change in pull request #20233: [BUGFIX] fix numpy op fallback bug when ndarray in kwargs

Posted by GitBox <gi...@apache.org>.
wkcn commented on a change in pull request #20233:
URL: https://github.com/apache/incubator-mxnet/pull/20233#discussion_r624841465



##########
File path: tests/python/unittest/test_numpy_op.py
##########
@@ -10349,3 +10349,17 @@ def test_broadcast_like_different_types():
     z = mx.npx.broadcast_like(x, y, 1, 1)
     assert_almost_equal(z.asnumpy(), np.array([[0,0],[0,0]]))
     assert x.dtype == z.dtype
+
+
+@use_np
+def test_np_apply_along_axis_fallback():
+    data = np.array([[1, 2, 3.], [4., 5., 6]])

Review comment:
       `data = np.array([[1., 2., 3.], [4., 5., 6.]])`




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



[GitHub] [incubator-mxnet] wkcn commented on a change in pull request #20233: [BUGFIX] fix numpy op fallback bug when ndarray in kwargs

Posted by GitBox <gi...@apache.org>.
wkcn commented on a change in pull request #20233:
URL: https://github.com/apache/incubator-mxnet/pull/20233#discussion_r624841338



##########
File path: python/mxnet/numpy/multiarray.py
##########
@@ -198,24 +198,32 @@ def _as_mx_np_array(object, ctx=None, zero_copy=False):
         raise TypeError('Does not support converting {} to mx.np.ndarray.'.format(str(type(object))))
 
 
-def _as_onp_array(object):
+def _as_onp_array(object, cur_ctx=None):

Review comment:
       The line 202nd should be """Convert object to numpy.ndarray."""




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



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20233: [BUGFIX] fix numpy op fallback bug when ndarray in kwargs

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20233:
URL: https://github.com/apache/incubator-mxnet/pull/20233#issuecomment-830978920


   Hey @wkcn , Thanks for submitting the PR 
   All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands: 
   - To trigger all jobs: @mxnet-bot run ci [all] 
   - To trigger specific jobs: @mxnet-bot run ci [job1, job2] 
   *** 
   **CI supported jobs**: [clang, unix-gpu, windows-cpu, centos-cpu, miscellaneous, unix-cpu, windows-gpu, website, edge, centos-gpu, sanity]
   *** 
   _Note_: 
    Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin. 
   All CI tests must pass before the PR can be merged. 
   


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



[GitHub] [incubator-mxnet] wkcn commented on a change in pull request #20233: [BUGFIX] fix numpy op fallback bug when ndarray in kwargs

Posted by GitBox <gi...@apache.org>.
wkcn commented on a change in pull request #20233:
URL: https://github.com/apache/incubator-mxnet/pull/20233#discussion_r624841338



##########
File path: python/mxnet/numpy/multiarray.py
##########
@@ -198,24 +198,32 @@ def _as_mx_np_array(object, ctx=None, zero_copy=False):
         raise TypeError('Does not support converting {} to mx.np.ndarray.'.format(str(type(object))))
 
 
-def _as_onp_array(object):
+def _as_onp_array(object, cur_ctx=None):

Review comment:
       It should be """Convert object to numpy.ndarray."""




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



[GitHub] [incubator-mxnet] leezu merged pull request #20233: [BUGFIX] fix numpy op fallback bug when ndarray in kwargs

Posted by GitBox <gi...@apache.org>.
leezu merged pull request #20233:
URL: https://github.com/apache/incubator-mxnet/pull/20233


   


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



[GitHub] [incubator-mxnet] wkcn commented on a change in pull request #20233: [BUGFIX] fix numpy op fallback bug when ndarray in kwargs

Posted by GitBox <gi...@apache.org>.
wkcn commented on a change in pull request #20233:
URL: https://github.com/apache/incubator-mxnet/pull/20233#discussion_r624841338



##########
File path: python/mxnet/numpy/multiarray.py
##########
@@ -198,24 +198,32 @@ def _as_mx_np_array(object, ctx=None, zero_copy=False):
         raise TypeError('Does not support converting {} to mx.np.ndarray.'.format(str(type(object))))
 
 
-def _as_onp_array(object):
+def _as_onp_array(object, cur_ctx=None):

Review comment:
       The line 202th should be """Convert object to numpy.ndarray."""




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