wkcn commented on a change in pull request #16234: [MXNET-1426] Fix the wrong
result of sum, mean, argmin, argmax when inputs contain inf or nan
URL: https://github.com/apache/incubator-mxnet/pull/16234#discussion_r327379713
##########
File path: 3rdparty/mshadow/mshadow/extension/reduce_with_axis.h
##########
@@ -112,7 +112,7 @@ struct Plan<ReduceWithAxisExp<Reducer, SrcExp, DType,
dimsrc, mask, dimdst>, DTy
index_t z = (x*size_+k)*trailing_+y;
DType tmp = res;
Reducer::Reduce(res, src_.Eval(z/last_, z%last_));
- if (tmp != res) {
+ if (tmp != res && !isnan_typed::IsNan(tmp)) {
Review comment:
It is necessary to check NaN. For example, argmin/argmax should return the
first index in the array [NaN, NaN], however (NaN != NaN) is true.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services