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_r344987852
##########
File path: tests/python/unittest/test_ndarray.py
##########
@@ -601,16 +629,22 @@ def test_reduce_inner(numpy_reduce_func, nd_reduce_func,
multi_axes):
axes = np.random.randint(0, ndim)
numpy_ret = numpy_reduce_func(dat, axis=axes, keepdims=keepdims)
- ndarray_ret = nd_reduce_func(mx.nd.array(dat), axis=axes,
keepdims=keepdims)
+ mx_arr = mx.nd.array(dat, dtype=dtype)
+ ndarray_ret = nd_reduce_func(mx_arr, axis=axes, keepdims=keepdims)
if type(ndarray_ret) is mx.ndarray.NDArray:
ndarray_ret = ndarray_ret.asnumpy()
assert (ndarray_ret.shape == numpy_ret.shape) or \
(ndarray_ret.shape == (1,) and numpy_ret.shape == ()),
"nd:%s, numpy:%s" \
%(ndarray_ret.shape,
numpy_ret.shape)
- err = np.square(ndarray_ret - numpy_ret).mean()
- assert err < 1E-4
+ if check_dtype:
Review comment:
Hi @marcoabreu , here is the explanation.
1. So much branching
We need to test all reduce operators, like `min, max, argmin, argmax, sum,
mean` when the inputs contain `-inf, +inf, nan`.
2. Skipping the checks
I replace the old check with [a new
one](https://github.com/apache/incubator-mxnet/pull/16234/files#diff-69757562d07268150de8b369ff5b6b61R642).
----------------------------------------------------------------
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