Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

[BUGFIX] fix numpy op fallback bug when ndarray in kwargs#20233

Merged
leezu merged 2 commits intoapache:masterfrom
wkcn:fix_numpy_op_fallback_kwargs
May 3, 2021
Merged

[BUGFIX] fix numpy op fallback bug when ndarray in kwargs#20233
leezu merged 2 commits intoapache:masterfrom
wkcn:fix_numpy_op_fallback_kwargs

Conversation

@wkcn
Copy link
Copy Markdown
Member

@wkcn wkcn commented May 3, 2021

Description

Hi there,
This PR fixes the issue #20232
When a operator is not implemented in MXNet, it will be fallbacked to official numpy operator.
However, it triggers a bug when the NDArray only exist in kwargs.

Reproduce Example:

from mxnet import np, npx
npx.set_np()
data = np.array([[1,2,3.], [4.,5.,6]])
print(np.apply_along_axis(lambda x: x.mean(), axis=1, arr=data))

The reason is that the function _as_onp_array in multiarray.py#L380 could not discriminate the NDArray in kwargs.

Checklist

Essentials

  • PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented

Changes

  • make the function _as_onp_array in multiarray.py#L380 support NDArray in kwargs.
  • add a related unittest

@wkcn wkcn requested a review from szha as a code owner May 3, 2021 01:16
@mxnet-bot
Copy link
Copy Markdown

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.

@mseth10 mseth10 added the pr-awaiting-testing PR is reviewed and waiting CI build and test label May 3, 2021
@wkcn wkcn added the Numpy label May 3, 2021
Copy link
Copy Markdown
Member Author

@wkcn wkcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two positions may be made some change.

Copy link
Copy Markdown
Member

@szha szha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch and LGTM. Feel free to apply the suggested changes too.

@mseth10 mseth10 added pr-work-in-progress PR is still work in progress and removed pr-awaiting-testing PR is reviewed and waiting CI build and test labels May 3, 2021
@mseth10 mseth10 added pr-awaiting-testing PR is reviewed and waiting CI build and test pr-awaiting-review PR is waiting for code review and removed pr-work-in-progress PR is still work in progress pr-awaiting-testing PR is reviewed and waiting CI build and test labels May 3, 2021
@leezu leezu merged commit 00de7dd into apache:master May 3, 2021
josephevans pushed a commit to josephevans/mxnet that referenced this pull request Feb 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Numpy pr-awaiting-review PR is waiting for code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants