From 080d29cb1a2daa903f99a6fa7c3f5f6dba2771dd Mon Sep 17 00:00:00 2001 From: reminisce Date: Wed, 20 Dec 2017 10:06:29 -0800 Subject: [PATCH] Fix float16 min and max (#9149) * Add unittest for float16 min and max * Add mshadow fix --- mshadow | 2 +- tests/python/unittest/test_operator.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mshadow b/mshadow index 984a3a7c253a..3d87ed2a4b47 160000 --- a/mshadow +++ b/mshadow @@ -1 +1 @@ -Subproject commit 984a3a7c253a9b590c17206f8d926bdaafdea997 +Subproject commit 3d87ed2a4b47ef749c616f208cee45d920fb6e6e diff --git a/tests/python/unittest/test_operator.py b/tests/python/unittest/test_operator.py index 19c4e65d3d80..ba1b99183f59 100644 --- a/tests/python/unittest/test_operator.py +++ b/tests/python/unittest/test_operator.py @@ -4668,6 +4668,14 @@ def test_slice_forward_backward(a, index): check_numeric_gradient(slice_sym, [in_data]) +def test_float16_min_max(): + """Test for issue: https://github.com/apache/incubator-mxnet/issues/9007""" + a = mx.nd.array([np.finfo('float16').min, np.finfo('float16').max], dtype='float16') + assert a.dtype == np.float16 + assert np.finfo('float16').min == mx.nd.min(a).asscalar() + assert np.finfo('float16').max == mx.nd.max(a).asscalar() + + if __name__ == '__main__': import nose nose.runmodule()