Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XLA] Split NextAfter test into a sepatate test instance #30081

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 28 additions & 24 deletions tensorflow/compiler/tests/binary_ops_test.py
Expand Up @@ -313,30 +313,6 @@ def testNumericOps(self):
dtype(7),
expected=np.array([[-6], [-5]], dtype=dtype))

if dtype in [np.float32, np.float64]:
x = np.array([
-0.0, 0.0, -0.0, +0.0, np.inf, np.inf, -np.inf, -np.inf, 2.0, 2.0,
1.0
],
dtype=dtype)
y = np.array(
[-0.0, 0.0, +0.0, -0.0, 1.0, -1.0, 1.0, -1.0, 2.0, 1.0, 2.0],
dtype=dtype)
expected = np.nextafter(x, y)

# We use assertAllEqual to expose any bugs hidden by relative or
# absolute error tolerances.
def NextAfterEqualityTest(result, expected, rtol):
del rtol
return self.assertAllEqual(result, expected)

self._testBinary(
math_ops.nextafter,
x,
y,
expected=expected,
equality_test=NextAfterEqualityTest)

# min/max not supported for complex
if dtype not in self.complex_types | {np.uint8, np.int8}:
self._testBinary(
Expand Down Expand Up @@ -424,6 +400,34 @@ def NextAfterEqualityTest(result, expected, rtol):
expected=np.array([1 << 32, 1 << 36, 1 << 32, 1 << 36],
dtype=np.int64))


def testNextAfter(self):
for dtype in self.numeric_types:
if dtype in [np.float32, np.float64]:
x = np.array([
-0.0, 0.0, -0.0, +0.0, np.inf, np.inf, -np.inf, -np.inf, 2.0, 2.0,
1.0
],
dtype=dtype)
y = np.array(
[-0.0, 0.0, +0.0, -0.0, 1.0, -1.0, 1.0, -1.0, 2.0, 1.0, 2.0],
dtype=dtype)
expected = np.nextafter(x, y)

# We use assertAllEqual to expose any bugs hidden by relative or
# absolute error tolerances.
def NextAfterEqualityTest(result, expected, rtol):
del rtol
return self.assertAllEqual(result, expected)

self._testBinary(
math_ops.nextafter,
x,
y,
expected=expected,
equality_test=NextAfterEqualityTest)


def testComplexOps(self):
for dtype in self.complex_types:
ctypes = {np.complex64: np.float32, np.complex128: np.float64}
Expand Down