[XLA:TPU] Add F64 Cosine.
Now, F64 Stateless Random Normal should be supported on TPU. PiperOrigin-RevId: 306355714 Change-Id: Ib6dee1ddb66c92893887aa1ad2d5c37c17e945c9
This commit is contained in:
parent
162ce62eed
commit
258d16bc66
@ -151,20 +151,37 @@ class UnaryOpsTest(xla_test.XLATestCase):
|
||||
|
||||
def testSin(self):
|
||||
for dtype in self.float_types - {dtypes.bfloat16.as_numpy_dtype}:
|
||||
tol = 1e-3 if dtype == np.float32 else 1e-10
|
||||
tol = 1e-6 if dtype == np.float32 else 1e-12
|
||||
|
||||
x = np.linspace(-4 * np.pi, 4 * np.pi, num=1000, dtype=dtype)
|
||||
x = np.linspace(-4 * np.e, 4 * np.e, num=1000, dtype=dtype)
|
||||
self._assertOpOutputMatchesExpected(
|
||||
math_ops.sin, x, expected=np.sin(x), rtol=tol, atol=tol)
|
||||
|
||||
x = np.linspace(0., 2.71828e-30, num=1000, dtype=dtype)
|
||||
x = np.linspace(0., np.e * 1e-30, num=1000, dtype=dtype)
|
||||
self._assertOpOutputMatchesExpected(
|
||||
math_ops.sin, x, expected=np.sin(x), rtol=tol, atol=tol)
|
||||
|
||||
if dtype == np.float64:
|
||||
x = np.linspace(0., 3.141592e8, num=1000, dtype=dtype)
|
||||
x = np.linspace(0., np.e * 1e8, num=1000, dtype=dtype)
|
||||
self._assertOpOutputMatchesExpected(
|
||||
math_ops.sin, x, expected=np.sin(x), rtol=1e-5, atol=1e-5)
|
||||
math_ops.sin, x, expected=np.sin(x), rtol=tol, atol=1e-5)
|
||||
|
||||
def testCos(self):
|
||||
for dtype in self.float_types - {dtypes.bfloat16.as_numpy_dtype}:
|
||||
tol = 1e-6 if dtype == np.float32 else 1e-12
|
||||
|
||||
x = np.linspace(-4 * np.e, 4 * np.e, num=1000, dtype=dtype)
|
||||
self._assertOpOutputMatchesExpected(
|
||||
math_ops.cos, x, expected=np.cos(x), rtol=tol, atol=tol)
|
||||
|
||||
x = np.linspace(0., np.e * 1e-30, num=1000, dtype=dtype)
|
||||
self._assertOpOutputMatchesExpected(
|
||||
math_ops.cos, x, expected=np.cos(x), rtol=tol, atol=tol)
|
||||
|
||||
if dtype == np.float64:
|
||||
x = np.linspace(0., np.e * 1e8, num=1000, dtype=dtype)
|
||||
self._assertOpOutputMatchesExpected(
|
||||
math_ops.cos, x, expected=np.cos(x), rtol=tol, atol=1e-5)
|
||||
|
||||
def testFloatOps(self):
|
||||
for dtype in self.float_types:
|
||||
|
Loading…
x
Reference in New Issue
Block a user