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/07/04 16:11:19 UTC
[GitHub] [incubator-mxnet] Yiyan66 opened a new pull request #18660: [numpy][do not review] fix flaky mixed precision binary error
Yiyan66 opened a new pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660
## Description ##
Delete the tests which may cause bug because of the following reasons:
1. There are differences about type inference between NumPy and Deep Numpy when there's a input with shape ():
If both inputs of np are of floating number types, the output is the more precise type, while onp will use the type of the matrix with higher dimension.
```python
from mxnet import np, npx
npx.set_np()
import numpy as _np
mx_test_x1 = np.random.uniform(-2, 2, (2,3)).astype(np.float32)
mx_test_x2 = np.random.uniform(-2, 2, ()).astype(np.float16)
np_out = _np.mod(mx_test_x1.asnumpy(), mx_test_x2.asnumpy()) # float16
mx_out = np.mod(mx_test_x1, mx_test_x2) # float32
```
2. As for logical ops, NumPy also has a weird behavior.
```python
from mxnet import np, npx
npx.set_np()
import numpy as _np
a = np.array([[1.441]], dtype = np.float16)
b = np.array(1.4413278, dtype = np.float32)
c = np.array([1.4413278], dtype = np.float32)
np.greater(a,b), np.greater(a,c) # True True
_np.greater(a.asnumpy(),b.asnumpy()), _np.greater(a.asnumpy(),c.asnumpy()) # False True
np.less_equal(a,b), np.less_equal(a,c) # False False
_np.less_equal(a.asnumpy(),b.asnumpy()), _np.less_equal(a.asnumpy(),c.asnumpy()) # True False
```
## 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] Yiyan66 commented on pull request #18660: [numpy] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
Yiyan66 commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-663325145
@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] Yiyan66 commented on pull request #18660: [numpy][do not review] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
Yiyan66 commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-654217844
@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] yzhliu merged pull request #18660: [numpy] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
yzhliu merged pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660
----------------------------------------------------------------
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] yzhliu commented on pull request #18660: [numpy] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
yzhliu commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-664821503
Thanks @Yiyan66
----------------------------------------------------------------
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] Yiyan66 commented on pull request #18660: [numpy] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
Yiyan66 commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-663083249
@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] mxnet-bot commented on pull request #18660: [numpy][do not review] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-654217914
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] yzhliu commented on a change in pull request #18660: [numpy] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
yzhliu commented on a change in pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#discussion_r453352397
##########
File path: tests/python/unittest/test_numpy_op.py
##########
@@ -3131,16 +3134,17 @@ def hybrid_forward(self, F, a, b, *args, **kwargs):
'mod': (1.0, 5.0, None, None),
'power': (1.0, 3.0, lambda y, x1, x2: _np.power(x1, x2 - 1.0) * x2,
lambda y, x1, x2: _np.power(x1, x2) * _np.log(x1)),
- 'equal': (0.0, 2.0, None, None),
- 'not_equal': (0.0, 2.0, None, None),
- 'greater': (0.0, 2.0, None, None),
- 'less': (0.0, 2.0, None, None),
- 'greater_equal': (0.0, 2.0, None, None),
- 'less_equal': (0.0, 2.0, None, None),
- 'logical_and': (0.0, 2.0, None, None),
- 'logical_or': (0.0, 2.0, None, None),
- 'logical_xor': (0.0, 2.0, None, None),
}
+ if not has_tvm_ops():
+ funcs['equal'] = (0.0, 2.0, None, None)
+ funcs['not_equal'] = (0.0, 2.0, None, None)
+ funcs['greater'] = (0.0, 2.0, None, None)
+ funcs['less'] = (0.0, 2.0, None, None)
+ funcs['greater_equal'] = (0.0, 2.0, None, None)
+ funcs['less_equal'] = (0.0, 2.0, None, None)
+ funcs['logical_and'] = (0.0, 2.0, None, None)
+ funcs['logical_or'] = (0.0, 2.0, None, None)
+ funcs['logical_xor'] = (0.0, 2.0, None, None)
Review comment:
I think there's a route to tvmop when it is enabled, can we disable such route for mixed-type operation? changing test does not seem to be a correct fix.
##########
File path: tests/python/unittest/test_numpy_op.py
##########
@@ -3075,6 +3074,10 @@ def __init__(self, func):
def hybrid_forward(self, F, a, b, *args, **kwargs):
return getattr(F.np, self._func)(a, b)
+ if (func in ['multiply', 'mod', 'equal', 'not_equal', 'greater',
+ 'greater_equal', 'less', 'less_equal']) and \
+ (lshape == () or rshape == ()) :
Review comment:
we need to document the different behavior in operators.
----------------------------------------------------------------
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 #18660: [numpy][do not review] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-653784158
Hey @Yiyan66 , 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**: [sanity, edge, website, miscellaneous, centos-cpu, windows-cpu, unix-gpu, centos-gpu, unix-cpu, clang, windows-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] yzhliu commented on a change in pull request #18660: [numpy] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
yzhliu commented on a change in pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#discussion_r461221499
##########
File path: tests/python/unittest/test_numpy_op.py
##########
@@ -3084,6 +3083,13 @@ def __init__(self, func):
def hybrid_forward(self, F, a, b, *args, **kwargs):
return getattr(F.np, self._func)(a, b)
+ if (func in ['multiply', 'mod', 'equal', 'not_equal', 'greater',
+ 'greater_equal', 'less', 'less_equal']) and \
+ (lshape == () or rshape == ()) :
+ # the behaviors of infer type in dealing with the input shape of '()' are different between np and onp
+ # logcial ops: when two numbers are only different in precision, NumPy also has a weird behavior
Review comment:
would be better to give some examples.
----------------------------------------------------------------
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 #18660: [numpy] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-662903709
Jenkins CI successfully triggered : [centos-cpu, centos-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] Yiyan66 commented on pull request #18660: [numpy][do not review] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
Yiyan66 commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-653914674
@mxnet-bot run ci [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 #18660: [numpy] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-663325158
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] Yiyan66 commented on pull request #18660: [numpy] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
Yiyan66 commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-662903653
@mxnet-bot run ci [centos-cpu, centos-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 #18660: [numpy][do not review] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-653914689
Jenkins CI successfully triggered : [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 #18660: [numpy] fix flaky mixed precision binary error
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #18660:
URL: https://github.com/apache/incubator-mxnet/pull/18660#issuecomment-663083306
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