未验证 提交 f2c59b88 编写于 作者: 姜永久 提交者: GitHub

rm unittests eager guard tests part23 where2zeros (#48895)

上级 ee4a20cc
......@@ -21,7 +21,6 @@ import paddle
import paddle.fluid as fluid
from paddle.fluid import Program, program_guard
from paddle.fluid.backward import append_backward
from paddle.fluid.framework import _test_eager_guard
class TestWhereOp(OpTest):
......@@ -356,18 +355,6 @@ class TestWhereDygraphAPI(unittest.TestCase):
expect_out = np.array([[0], [1]])
np.testing.assert_allclose(expect_out, np.array(res), rtol=1e-05)
def test_eager(self):
with _test_eager_guard():
self.test_api()
self.test_dygraph_api_broadcast_1()
self.test_dygraph_api_broadcast_2()
self.test_dygraph_api_broadcast_3()
self.test_dygraph_api_broadcast_4()
self.test_dygraph_api_broadcast_5()
self.test_dygraph_api_broadcast_6()
self.test_dygraph_api_broadcast_7()
self.test_dygraph_api_broadcast_8()
class TestWhereOpError(unittest.TestCase):
def test_errors(self):
......@@ -397,10 +384,6 @@ class TestWhereOpError(unittest.TestCase):
a = paddle.rand(cond_shape)
self.assertRaises(ValueError, paddle.where, cond, a)
def test_eager(self):
with _test_eager_guard():
self.test_value_error()
if __name__ == "__main__":
paddle.enable_static()
......
......@@ -18,7 +18,6 @@ import numpy as np
from op_test import OpTest
import paddle
from paddle.fluid.framework import _test_eager_guard
def sigmoid(x):
......@@ -235,10 +234,6 @@ class TestYoloBoxDygraph(unittest.TestCase):
)
paddle.enable_static()
def test_eager(self):
with _test_eager_guard():
self.test_dygraph()
class TestYoloBoxStatic(unittest.TestCase):
def test_static(self):
......
......@@ -16,7 +16,6 @@ import unittest
import numpy as np
import paddle
from paddle import to_tensor
from paddle.nn import ZeroPad2D
from paddle.nn.functional import zeropad2d
......@@ -34,7 +33,7 @@ class TestZeroPad2dAPIError(unittest.TestCase):
self.shape = [4, 3, 224, 224]
self.unsupport_dtypes = ['bool', 'int8']
def func_unsupport_dtypes(self):
def test_unsupport_dtypes(self):
"""
test unsupport dtypes.
"""
......@@ -44,11 +43,6 @@ class TestZeroPad2dAPIError(unittest.TestCase):
x_tensor = to_tensor(x).astype(dtype)
self.assertRaises(TypeError, zeropad2d, x=x_tensor, padding=pad)
def test_unsupport_dtypes(self):
with paddle.fluid.framework._test_eager_guard():
self.func_unsupport_dtypes()
self.func_unsupport_dtypes()
class TestZeroPad2dAPI(unittest.TestCase):
"""
......@@ -62,7 +56,7 @@ class TestZeroPad2dAPI(unittest.TestCase):
self.shape = [4, 3, 224, 224]
self.support_dtypes = ['float32', 'float64', 'int32', 'int64']
def func_support_dtypes(self):
def test_support_dtypes(self):
"""
test support types
"""
......@@ -75,12 +69,7 @@ class TestZeroPad2dAPI(unittest.TestCase):
ret_res = zeropad2d(x_tensor, [pad, pad, pad, pad]).numpy()
np.testing.assert_allclose(expect_res, ret_res, rtol=1e-05)
def test_support_dtypes(self):
with paddle.fluid.framework._test_eager_guard():
self.func_support_dtypes()
self.func_support_dtypes()
def func_support_pad2(self):
def test_support_pad2(self):
"""
test the type of 'pad' is list.
"""
......@@ -94,12 +83,7 @@ class TestZeroPad2dAPI(unittest.TestCase):
ret_res = zeropad2d(x_tensor, pad).numpy()
np.testing.assert_allclose(expect_res, ret_res, rtol=1e-05)
def test_support_pad2(self):
with paddle.fluid.framework._test_eager_guard():
self.func_support_pad2()
self.func_support_pad2()
def func_support_pad3(self):
def test_support_pad3(self):
"""
test the type of 'pad' is tuple.
"""
......@@ -113,12 +97,7 @@ class TestZeroPad2dAPI(unittest.TestCase):
ret_res = zeropad2d(x_tensor, pad).numpy()
np.testing.assert_allclose(expect_res, ret_res, rtol=1e-05)
def test_support_pad3(self):
with paddle.fluid.framework._test_eager_guard():
self.func_support_pad3()
self.func_support_pad3()
def func_support_pad4(self):
def test_support_pad4(self):
"""
test the type of 'pad' is paddle.Tensor.
"""
......@@ -133,11 +112,6 @@ class TestZeroPad2dAPI(unittest.TestCase):
ret_res = zeropad2d(x_tensor, pad_tensor).numpy()
np.testing.assert_allclose(expect_res, ret_res, rtol=1e-05)
def test_support_pad4(self):
with paddle.fluid.framework._test_eager_guard():
self.func_support_pad4()
self.func_support_pad4()
class TestZeroPad2DLayer(unittest.TestCase):
"""
......@@ -159,18 +133,13 @@ class TestZeroPad2DLayer(unittest.TestCase):
],
)
def func_layer(self):
def test_layer(self):
np.testing.assert_allclose(
zeropad2d(to_tensor(self.x), self.pad).numpy(),
self.padLayer(to_tensor(self.x)),
rtol=1e-05,
)
def test_layer(self):
with paddle.fluid.framework._test_eager_guard():
self.func_layer()
self.func_layer()
if __name__ == '__main__':
unittest.main()
......@@ -20,7 +20,7 @@ import paddle
import paddle.fluid as fluid
from paddle import _C_ops, zeros_like
from paddle.fluid import Program, core, program_guard
from paddle.fluid.framework import _test_eager_guard, convert_np_dtype_to_dtype_
from paddle.fluid.framework import convert_np_dtype_to_dtype_
class TestZerosLikeAPIError(unittest.TestCase):
......@@ -29,10 +29,6 @@ class TestZerosLikeAPIError(unittest.TestCase):
x = paddle.fluid.data('x', [3, 4])
self.assertRaises(TypeError, zeros_like, x, 'int8')
def test_eager(self):
with _test_eager_guard():
self.test_errors()
class TestZerosLikeAPI(unittest.TestCase):
def test_api(self):
......@@ -63,10 +59,6 @@ class TestZerosLikeAPI(unittest.TestCase):
self.assertEqual(outs[i].dtype, dtype)
self.assertEqual((outs[i] == np.zeros(shape, dtype)).all(), True)
def test_eager(self):
with _test_eager_guard():
self.test_api()
class TestZerosLikeImpeartive(unittest.TestCase):
def test_out(self):
......@@ -89,10 +81,6 @@ class TestZerosLikeImpeartive(unittest.TestCase):
self.assertEqual((out.numpy() == np.zeros(shape, dtype)).all(), True)
paddle.enable_static()
def test_eager(self):
with _test_eager_guard():
self.test_out()
class TestZerosAPI(unittest.TestCase):
def test_api(self):
......
......@@ -19,7 +19,6 @@ import numpy as np
import paddle
import paddle.fluid as fluid
from paddle.fluid import Program, program_guard
from paddle.fluid.framework import _test_eager_guard
class TestZerosOpError(unittest.TestCase):
......@@ -29,10 +28,6 @@ class TestZerosOpError(unittest.TestCase):
dtype = 'int8'
self.assertRaises(TypeError, fluid.layers.zeros, shape, dtype)
def test_eager(self):
with _test_eager_guard():
self.test_errors()
class ApiZerosTest(unittest.TestCase):
def test_out(self):
......@@ -74,11 +69,6 @@ class ApiZerosTest(unittest.TestCase):
expected_result = np.zeros(10, dtype='int64')
self.assertEqual((result == expected_result).all(), True)
def test_eager(self):
with _test_eager_guard():
self.test_out()
self.test_fluid_out()
class ApiZerosError(unittest.TestCase):
def test_errors(self):
......@@ -103,11 +93,6 @@ class ApiZerosError(unittest.TestCase):
error_msg = str(e)
assert error_msg.find("expected to be no less than 0") > 0
def test_eager(self):
with _test_eager_guard():
self.test_errors()
self.test_shape_errors()
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册