Skip to content

Commit

Permalink
Fix float16 min and max (apache#9149)
Browse files Browse the repository at this point in the history
* Add unittest for float16 min and max

* Add mshadow fix
  • Loading branch information
reminisce authored and piiswrong committed Dec 20, 2017
1 parent c71a2f3 commit 080d29c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mshadow
Submodule mshadow updated 1 files
+2 −2 mshadow/half.h
8 changes: 8 additions & 0 deletions tests/python/unittest/test_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 080d29c

Please sign in to comment.