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 2020/05/14 05:29:00 UTC
[GitHub] [incubator-mxnet] BenjaminCHEN2016 opened a new pull request #18313: [Fix][Numpy][WIP] fix mix numpy scalar and MXNet numpy ndarray
BenjaminCHEN2016 opened a new pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313
## Description ##
Attempt to resolve issue mentioned in #16743
However, the example code in the issue still can't run due to type issue.
`
import mxnet as mx
import numpy as np
mx.npx.set_np()
a = np.array(1) // the type in np is int64
a += mx.np.array(1) // the type in mx_np is float32
`
## Checklist ##
### Essentials ###
Please feel free to remove inapplicable items for your PR.
- [ ] The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant [JIRA issue](https://issues.apache.org/jira/projects/MXNET/issues) created (except PRs with tiny changes)
- [ ] Changes are complete (i.e. I finished coding on this PR)
- [ ] All changes have test coverage:
- Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
- Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
- Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
- [ ] Code is well-documented:
- For user-facing API changes, API doc string has been updated.
- For new C++ functions in header files, their functionalities and arguments are documented.
- For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
- Check the API doc at https://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
- [ ] To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
### Changes ###
- [ ] Feature1, tests, (and when applicable, API doc)
- [ ] Feature2, tests, (and when applicable, API doc)
## Comments ##
- If this change is a backward incompatible change, why must this change be made.
- Interesting edge cases to note here
----------------------------------------------------------------
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] sxjscience commented on a change in pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
sxjscience commented on a change in pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#discussion_r427068742
##########
File path: python/mxnet/numpy/multiarray.py
##########
@@ -282,6 +313,16 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): # pylint: disable=
_FALLBACK_ARRAY_UFUNC_WARNED_RECORD[onp_op] = True
out = onp_op(*new_inputs, **kwargs)
return _as_mx_np_array(out, ctx=inputs[0].ctx)
+ # ops with np mx_np
+ elif name in ufunc_list and isinstance(inputs[0], _np.ndarray):
+ # inplace
+ if 'out' in kwargs:
+ new_inputs = [arg.asnumpy() if isinstance(arg, ndarray) else arg for arg in inputs]
+ return onp_op(*new_inputs, **kwargs)
+ else:
+ new_inputs = [_as_mx_np_array(arg, ctx=inputs[1].ctx)
Review comment:
I'm not sure why should we use `inputs[1].ctx` instead of `inputs[0].ctx`.
----------------------------------------------------------------
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] BenjaminCHEN2016 commented on pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
BenjaminCHEN2016 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629739139
@mxnet-bot ci [miscellaneous, unix-cpu]
----------------------------------------------------------------
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 #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629923810
Jenkins CI successfully triggered : [centos-cpu, windows-gpu, windows-cpu]
----------------------------------------------------------------
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 #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-630108397
Jenkins CI successfully triggered : [unix-gpu]
----------------------------------------------------------------
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] hgt312 commented on pull request #18313: [Fix][Numpy][WIP] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
hgt312 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-628565299
Jax does not implement inplace op overload like `__iadd__`. It is not a real inplace operation.
In my opinion, inplace operation should keep its type, while the other should return a mx 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 #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629739118
Undefined action detected.
Permissible actions are : run ci [all], run ci [job1, job2]
Example : @mxnet-bot run ci [all]
Example : @mxnet-bot run ci [centos-cpu, clang]
----------------------------------------------------------------
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] hgt312 commented on pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
hgt312 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629925483
LGTM now. @yzhliu
----------------------------------------------------------------
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 removed a comment on pull request #18313: [Fix][Numpy][WIP] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
leezu removed a comment on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-628793435
We can also consider not exposing the "real" inplace operation
----------------------------------------------------------------
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] BenjaminCHEN2016 commented on pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
BenjaminCHEN2016 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629739171
@mxnet-bot run ci [miscellaneous, unix-cpu]
----------------------------------------------------------------
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] BenjaminCHEN2016 commented on pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
BenjaminCHEN2016 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629739113
@mxnet-bot ci [miscellaneous, unix-cpu],
----------------------------------------------------------------
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 commented on pull request #18313: [Fix][Numpy][WIP] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
leezu commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-628793435
We can also consider not exposing the "real" inplace operation
----------------------------------------------------------------
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] BenjaminCHEN2016 commented on pull request #18313: [Fix][Numpy][WIP] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
BenjaminCHEN2016 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629091482
Conversion rules:
| Expression | a type | b type | out type|
| --- | --- | --- | --- |
| `a += b` | onp | mx_np | onp |
| `a += b` | mx_np | onp | mx_np |
| `c = a + b` | onp | mx_np | mx_np |
| `c = a + b` | mx_np | onp | mx_np |
----------------------------------------------------------------
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] BenjaminCHEN2016 commented on pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
BenjaminCHEN2016 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-630028872
@mxnet-bot run ci [unix-gpu]
----------------------------------------------------------------
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 #18313: [Fix][Numpy][WIP] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-628395925
Hey @BenjaminCHEN2016 , 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**: [windows-gpu, centos-cpu, unix-cpu, website, windows-cpu, miscellaneous, centos-gpu, sanity, edge, clang, unix-gpu]
***
_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] mxnet-bot commented on pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-630028919
Jenkins CI successfully triggered : [unix-gpu]
----------------------------------------------------------------
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] sxjscience commented on pull request #18313: [Fix][Numpy][WIP] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
sxjscience commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-628486640
In Jax, if any ndarray is a Jax ndarray, the result will also be a Jax 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] hgt312 commented on pull request #18313: [Fix][Numpy][WIP] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
hgt312 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-628473298
@yzhliu @sxjscience Any thoughts on the conversion rules?
----------------------------------------------------------------
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] BenjaminCHEN2016 commented on pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
BenjaminCHEN2016 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629933202
@mxnet-bot run ci [centos-cpu]
----------------------------------------------------------------
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] sxjscience commented on pull request #18313: [Fix][Numpy][WIP] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
sxjscience commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-628721077
> Jax does not implement inplace op overload like `__iadd__`. It is not a real inplace operation.
> In my opinion, inplace operation should keep its type, while the other should return a mx ndarray.
I agree with that.
----------------------------------------------------------------
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 #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629739178
Jenkins CI successfully triggered : [miscellaneous, unix-cpu]
----------------------------------------------------------------
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] sxjscience merged pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
sxjscience merged pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313
----------------------------------------------------------------
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] BenjaminCHEN2016 commented on pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
BenjaminCHEN2016 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629923782
@mxnet-bot run ci [windows-cpu, windows-gpu, centos-cpu]
----------------------------------------------------------------
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] sxjscience commented on a change in pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
sxjscience commented on a change in pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#discussion_r427072560
##########
File path: python/mxnet/numpy/multiarray.py
##########
@@ -282,6 +313,16 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): # pylint: disable=
_FALLBACK_ARRAY_UFUNC_WARNED_RECORD[onp_op] = True
out = onp_op(*new_inputs, **kwargs)
return _as_mx_np_array(out, ctx=inputs[0].ctx)
+ # ops with np mx_np
+ elif name in ufunc_list and isinstance(inputs[0], _np.ndarray):
+ # inplace
+ if 'out' in kwargs:
+ new_inputs = [arg.asnumpy() if isinstance(arg, ndarray) else arg for arg in inputs]
+ return onp_op(*new_inputs, **kwargs)
+ else:
+ new_inputs = [_as_mx_np_array(arg, ctx=inputs[1].ctx)
Review comment:
Ignore my previous comment. I mean to choose one element in the inputs that has a valid `ctx`.
----------------------------------------------------------------
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] BenjaminCHEN2016 commented on pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
BenjaminCHEN2016 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-630108343
@mxnet-bot run ci [unix-gpu]
----------------------------------------------------------------
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] BenjaminCHEN2016 removed a comment on pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
BenjaminCHEN2016 removed a comment on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629739139
----------------------------------------------------------------
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] BenjaminCHEN2016 commented on pull request #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
BenjaminCHEN2016 commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-630571982
@sxjscience Any thoughts on this pr?
----------------------------------------------------------------
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 #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629933250
Jenkins CI successfully triggered : [centos-cpu]
----------------------------------------------------------------
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 #18313: [numpy] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-629739141
Undefined action detected.
Permissible actions are : run ci [all], run ci [job1, job2]
Example : @mxnet-bot run ci [all]
Example : @mxnet-bot run ci [centos-cpu, clang]
----------------------------------------------------------------
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] sxjscience commented on pull request #18313: [Fix][Numpy][WIP] fix mix numpy scalar and MXNet numpy ndarray
Posted by GitBox <gi...@apache.org>.
sxjscience commented on pull request #18313:
URL: https://github.com/apache/incubator-mxnet/pull/18313#issuecomment-628485821
```python
import jax.numpy as jnp
import numpy as onp
# jnp += onp
a = jnp.ones((10,))
b = onp.ones((10,))
a += b
print(type(a))
# onp += jnp
a = onp.ones((10,))
b = jnp.ones((10,))
a += b
print(type(a))
```
Output:
```
<class 'jax.interpreters.xla.DeviceArray'>
<class 'jax.interpreters.xla.DeviceArray'>
```
----------------------------------------------------------------
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