From a208b5cd2900eacae5aaf66d06e34fb30ed2ea43 Mon Sep 17 00:00:00 2001 From: Gaurav Jain Date: Mon, 15 Jun 2020 09:57:28 -0700 Subject: [PATCH] Allow ZeroDivisionTest to run eagerly PiperOrigin-RevId: 316486715 Change-Id: I5a705b27562c57760ed8efeae52c67a91539ee7c --- tensorflow/python/kernel_tests/zero_division_test.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tensorflow/python/kernel_tests/zero_division_test.py b/tensorflow/python/kernel_tests/zero_division_test.py index 7f2d100f1e3..f62ac9f7f26 100644 --- a/tensorflow/python/kernel_tests/zero_division_test.py +++ b/tensorflow/python/kernel_tests/zero_division_test.py @@ -20,26 +20,25 @@ from __future__ import print_function from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes -from tensorflow.python.framework import errors_impl +from tensorflow.python.framework import errors from tensorflow.python.framework import test_util from tensorflow.python.platform import test class ZeroDivisionTest(test.TestCase): - @test_util.run_deprecated_v1 def testZeros(self): with test_util.use_gpu(): for dtype in dtypes.uint8, dtypes.int16, dtypes.int32, dtypes.int64: zero = constant_op.constant(0, dtype=dtype) one = constant_op.constant(1, dtype=dtype) - bads = [one // zero] + bads = [lambda x, y: x // y] if dtype in (dtypes.int32, dtypes.int64): - bads.append(one % zero) + bads.append(lambda x, y: x % y) for bad in bads: try: - result = self.evaluate(bad) - except errors_impl.OpError as e: + result = self.evaluate(bad(one, zero)) + except (errors.OpError, errors.InvalidArgumentError) as e: # Ideally, we'd get a nice exception. In theory, this should only # happen on CPU, but 32 bit integer GPU division is actually on # CPU due to a placer bug.