提交 3c44556c 编写于 作者: A A. Unique TensorFlower 提交者: TensorFlower Gardener

Updates OSS Eigen version to get bug fix for negative arguments to sqrt.

Adds unit tests for handling negative arguments to tf.sqrt.
Followup to cl/135111959.
Change: 136665526
上级 465ce3dd
......@@ -1738,6 +1738,25 @@ class IsFiniteInfNanTest(tf.test.TestCase):
def testDouble(self):
self._testDtype(np.float64)
def testSqrt(self):
for dtype in [np.float16, np.float32, np.float64]:
fi = np.finfo(dtype)
for size in [1, 3, 4, 7, 8, 63, 64, 65]:
# For float32 Eigen uses Carmack's fast vectorized sqrt algorithm.
# It is not accurate for very large arguments, so we test for
# fi.max/100 instead of fi.max here.
for value in [fi.min, -2, -1, 0, fi.tiny, 1, 2, 1000, fi.max/100]:
x = np.full((size,), value, dtype=dtype)
np_y = np.sqrt(x)
np_nan = np.isnan(np_y)
with self.test_session(use_gpu=True):
tf_y = tf.sqrt(x)
tf_nan = tf.is_nan(tf_y)
if value < 0:
self.assertAllEqual(np_nan, tf_nan.eval())
else:
self.assertAllCloseAccordingToType(np_y, tf_y.eval())
class RoundingTest(tf.test.TestCase):
......
......@@ -14,8 +14,8 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
# These lines need to be changed when updating Eigen. They are parsed from
# this file by the cmake and make builds to determine the eigen version and
# hash.
eigen_version = "f6508f52a798"
eigen_sha256 = "9824d3beea839455e496ea472e4dcf05f7e25ec01dfb68e540fbfe522b609f72"
eigen_version = "1c7159a65db4"
eigen_sha256 = "b089a6eae493c32703c6beb5fdae9d64a7667c3a5440bae00ac8e517cc822e62"
native.new_http_archive(
name = "eigen_archive",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册