Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions python/paddle/fluid/tests/unittests/test_where_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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):
Expand Down Expand Up @@ -356,18 +355,6 @@ def test_where_condition(self):
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):
Expand Down Expand Up @@ -397,10 +384,6 @@ def test_value_error(self):
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()
Expand Down
5 changes: 0 additions & 5 deletions python/paddle/fluid/tests/unittests/test_yolo_box_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from op_test import OpTest

import paddle
from paddle.fluid.framework import _test_eager_guard


def sigmoid(x):
Expand Down Expand Up @@ -235,10 +234,6 @@ def test_dygraph(self):
)
paddle.enable_static()

def test_eager(self):
with _test_eager_guard():
self.test_dygraph()


class TestYoloBoxStatic(unittest.TestCase):
def test_static(self):
Expand Down
43 changes: 6 additions & 37 deletions python/paddle/fluid/tests/unittests/test_zeropad2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import numpy as np

import paddle
from paddle import to_tensor
from paddle.nn import ZeroPad2D
from paddle.nn.functional import zeropad2d
Expand All @@ -34,7 +33,7 @@ def setUp(self):
self.shape = [4, 3, 224, 224]
self.unsupport_dtypes = ['bool', 'int8']

def func_unsupport_dtypes(self):
def test_unsupport_dtypes(self):
"""
test unsupport dtypes.
"""
Expand All @@ -44,11 +43,6 @@ def func_unsupport_dtypes(self):
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):
"""
Expand All @@ -62,7 +56,7 @@ def setUp(self):
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
"""
Expand All @@ -75,12 +69,7 @@ def func_support_dtypes(self):
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.
"""
Expand All @@ -94,12 +83,7 @@ def func_support_pad2(self):
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.
"""
Expand All @@ -113,12 +97,7 @@ def func_support_pad3(self):
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.
"""
Expand All @@ -133,11 +112,6 @@ def func_support_pad4(self):
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):
"""
Expand All @@ -159,18 +133,13 @@ def setUp(self):
],
)

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()
14 changes: 1 addition & 13 deletions python/paddle/fluid/tests/unittests/test_zeros_like_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
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):
Expand All @@ -29,10 +29,6 @@ def test_errors(self):
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):
Expand Down Expand Up @@ -63,10 +59,6 @@ def test_api(self):
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):
Expand All @@ -89,10 +81,6 @@ def test_out(self):
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):
Expand Down
15 changes: 0 additions & 15 deletions python/paddle/fluid/tests/unittests/test_zeros_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
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):
Expand All @@ -29,10 +28,6 @@ def test_errors(self):
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):
Expand Down Expand Up @@ -74,11 +69,6 @@ def test_fluid_out(self):
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):
Expand All @@ -103,11 +93,6 @@ def test_shape_errors(self):
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()