diff --git a/python/paddle/fluid/tests/unittests/test_cast_op.py b/python/paddle/fluid/tests/unittests/test_cast_op.py index 96ad3246f41b6d6a2fa481d9489e5997d90a855b..bb88d1cc5350576195d9b066842773fd2d22e75f 100644 --- a/python/paddle/fluid/tests/unittests/test_cast_op.py +++ b/python/paddle/fluid/tests/unittests/test_cast_op.py @@ -24,7 +24,6 @@ import paddle.fluid as fluid import paddle.fluid.core as core import paddle.fluid.layers as layers from paddle.fluid import Program, program_guard -from paddle.fluid.framework import _test_eager_guard class TestCastOpFp32ToFp64(OpTest): @@ -122,16 +121,15 @@ class TestCastOpError(unittest.TestCase): class TestCastOpEager(unittest.TestCase): def test_eager(self): with paddle.fluid.dygraph.base.guard(): - with _test_eager_guard(): - x = paddle.ones([2, 2], dtype="float16") - x.stop_gradient = False - out = paddle.cast(x, "float32") - np.testing.assert_array_equal( - out, np.ones([2, 2]).astype('float32') - ) - out.backward() - np.testing.assert_array_equal(x.gradient(), x.numpy()) - self.assertTrue(x.gradient().dtype == np.float16) + x = paddle.ones([2, 2], dtype="float16") + x.stop_gradient = False + out = paddle.cast(x, "float32") + np.testing.assert_array_equal( + out, np.ones([2, 2]).astype('float32') + ) + out.backward() + np.testing.assert_array_equal(x.gradient(), x.numpy()) + self.assertTrue(x.gradient().dtype == np.float16) class TestCastDoubleGradCheck(unittest.TestCase): diff --git a/python/paddle/fluid/tests/unittests/test_clip_op.py b/python/paddle/fluid/tests/unittests/test_clip_op.py index e6056c50124811f34e1cb1fe8fb4063e801f72e0..a25edccb97a4edca00c4f24e4cd020c11062c449 100644 --- a/python/paddle/fluid/tests/unittests/test_clip_op.py +++ b/python/paddle/fluid/tests/unittests/test_clip_op.py @@ -20,7 +20,6 @@ from op_test import OpTest import paddle import paddle.fluid as fluid from paddle.fluid import Program, program_guard -from paddle.fluid.framework import _test_eager_guard class TestClipOp(OpTest): @@ -231,7 +230,7 @@ class TestClipAPI(unittest.TestCase): ) paddle.disable_static() - def func_clip_dygraph(self): + def test_clip_dygraph(self): paddle.disable_static() place = ( fluid.CUDAPlace(0) @@ -279,20 +278,14 @@ class TestClipAPI(unittest.TestCase): out_6.numpy(), data.clip(0.2, 0.8), rtol=1e-05 ) - def test_clip_dygraph(self): - with _test_eager_guard(): - self.func_clip_dygraph() - self.func_clip_dygraph() - def test_clip_dygraph_default_max(self): paddle.disable_static() - with _test_eager_guard(): - x_int32 = paddle.to_tensor([1, 2, 3], dtype="int32") - x_int64 = paddle.to_tensor([1, 2, 3], dtype="int64") - x_f32 = paddle.to_tensor([1, 2, 3], dtype="float32") - egr_out1 = paddle.clip(x_int32, min=1) - egr_out2 = paddle.clip(x_int64, min=1) - egr_out3 = paddle.clip(x_f32, min=1) + x_int32 = paddle.to_tensor([1, 2, 3], dtype="int32") + x_int64 = paddle.to_tensor([1, 2, 3], dtype="int64") + x_f32 = paddle.to_tensor([1, 2, 3], dtype="float32") + egr_out1 = paddle.clip(x_int32, min=1) + egr_out2 = paddle.clip(x_int64, min=1) + egr_out3 = paddle.clip(x_f32, min=1) x_int32 = paddle.to_tensor([1, 2, 3], dtype="int32") x_int64 = paddle.to_tensor([1, 2, 3], dtype="int64") x_f32 = paddle.to_tensor([1, 2, 3], dtype="float32") diff --git a/python/paddle/fluid/tests/unittests/test_complex_abs.py b/python/paddle/fluid/tests/unittests/test_complex_abs.py index 8d21f76d64ff9671e1f9198378856d7551550f13..45b4ed74a67d7a6cd93829461afa7997db23aecd 100644 --- a/python/paddle/fluid/tests/unittests/test_complex_abs.py +++ b/python/paddle/fluid/tests/unittests/test_complex_abs.py @@ -19,7 +19,6 @@ from op_test import OpTest import paddle import paddle.fluid.dygraph as dg -from paddle.fluid.framework import _test_eager_guard class TestComplexAbsOp(OpTest): @@ -109,10 +108,6 @@ class TestAbs(unittest.TestCase): y = paddle.abs(paddle.to_tensor(x)) np.testing.assert_allclose(np.abs(x), y.numpy(), rtol=1e-05) - def test_eager(self): - with _test_eager_guard(): - self.test_all_positive() - class TestRealAbsOp(OpTest): def setUp(self): diff --git a/python/paddle/fluid/tests/unittests/test_complex_cast.py b/python/paddle/fluid/tests/unittests/test_complex_cast.py index 8302ba585856b01965b18800a49b07f43668bb6e..348bd8a332f5ef3d24aff0e5182559b13863be95 100644 --- a/python/paddle/fluid/tests/unittests/test_complex_cast.py +++ b/python/paddle/fluid/tests/unittests/test_complex_cast.py @@ -17,7 +17,6 @@ import unittest import numpy as np import paddle -from paddle.fluid.framework import _test_eager_guard class TestComplexCastOp(unittest.TestCase): @@ -80,12 +79,6 @@ class TestComplexCastOp(unittest.TestCase): c_128.cast('complex128').numpy(), c_64.numpy(), rtol=1e-05 ) - def test_eager(self): - with _test_eager_guard(): - self.test_complex64_complex128() - self.test_real_to_complex() - self.test_complex_to_real() - if __name__ == '__main__': unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_complex_elementwise_layers.py b/python/paddle/fluid/tests/unittests/test_complex_elementwise_layers.py index 98a95eb37a099bb46519cd93364239d0fcf3558f..8180d7a5c035eb260183a510f3c478bd1c854918 100644 --- a/python/paddle/fluid/tests/unittests/test_complex_elementwise_layers.py +++ b/python/paddle/fluid/tests/unittests/test_complex_elementwise_layers.py @@ -20,7 +20,6 @@ from numpy.random import random as rand import paddle import paddle.fluid as fluid import paddle.fluid.dygraph as dg -from paddle.fluid.framework import _test_eager_guard paddle_apis = { "add": paddle.add, @@ -112,12 +111,6 @@ class TestComplexElementwiseLayers(unittest.TestCase): self.compare_by_basic_api(x, y) self.compare_op_by_basic_api(x, y) - def test_eager(self): - with _test_eager_guard(): - self.test_real_x_complex_y() - self.test_complex_x_real_y() - self.test_complex_xy() - if __name__ == '__main__': unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_complex_getitem.py b/python/paddle/fluid/tests/unittests/test_complex_getitem.py index 09aca3b060f3077d5470fc037f8feec1d13ac20a..1bce833e78aedc58ab80357099f028dce345a40b 100644 --- a/python/paddle/fluid/tests/unittests/test_complex_getitem.py +++ b/python/paddle/fluid/tests/unittests/test_complex_getitem.py @@ -18,7 +18,6 @@ import numpy as np import paddle.fluid as fluid import paddle.fluid.dygraph as dg -from paddle.fluid.framework import _test_eager_guard class TestComplexGetitemLayer(unittest.TestCase): @@ -95,15 +94,6 @@ class TestComplexGetitemLayer(unittest.TestCase): np.testing.assert_allclose(x_var_slice.numpy(), x_np_slice) - def test_eager(self): - with _test_eager_guard(): - self.test_case1() - self.test_case2() - self.test_case3() - self.test_case4() - self.test_case5() - self.test_case6() - if __name__ == '__main__': unittest.main()