From 4098dbc3cf0b36fb63e9761be47866ab8990555e Mon Sep 17 00:00:00 2001 From: RedContritio Date: Tue, 31 Jan 2023 14:41:18 +0000 Subject: [PATCH] add unittest --- .../paddle/fluid/tests/unittests/test_pool1d_api.py | 10 ++++++++++ .../paddle/fluid/tests/unittests/test_pool2d_api.py | 12 ++++++++++++ .../paddle/fluid/tests/unittests/test_pool3d_api.py | 10 ++++++++++ 3 files changed, 32 insertions(+) diff --git a/python/paddle/fluid/tests/unittests/test_pool1d_api.py b/python/paddle/fluid/tests/unittests/test_pool1d_api.py index 3816822e8f3ec..e671235869663 100644 --- a/python/paddle/fluid/tests/unittests/test_pool1d_api.py +++ b/python/paddle/fluid/tests/unittests/test_pool1d_api.py @@ -429,6 +429,16 @@ def run_zero_stride(): self.assertRaises(ValueError, run_zero_stride) + def run_zero_tuple_stride(): + with fluid.dygraph.guard(): + array = np.array([1], dtype=np.float32) + x = paddle.to_tensor( + np.reshape(array, [1, 1, 1]), dtype='float32' + ) + out = F.max_pool1d(x, 1, stride=(0)) + + self.assertRaises(ValueError, run_zero_tuple_stride) + if __name__ == '__main__': unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_pool2d_api.py b/python/paddle/fluid/tests/unittests/test_pool2d_api.py index c55ea337c41b7..fcdec610a480e 100644 --- a/python/paddle/fluid/tests/unittests/test_pool2d_api.py +++ b/python/paddle/fluid/tests/unittests/test_pool2d_api.py @@ -609,6 +609,18 @@ def run_zero_stride(): self.assertRaises(ValueError, run_zero_stride) + def run_zero_tuple_stride(): + with fluid.dygraph.guard(): + array = np.array([1], dtype=np.float32) + x = paddle.to_tensor( + np.reshape(array, [1, 1, 1, 1]), dtype='float32' + ) + out = max_pool2d( + x, 1, stride=(0, 0), return_mask=False, data_format='NHWC' + ) + + self.assertRaises(ValueError, run_zero_tuple_stride) + if __name__ == '__main__': unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_pool3d_api.py b/python/paddle/fluid/tests/unittests/test_pool3d_api.py index 30a03ab220bcc..e1d7543e7bce0 100644 --- a/python/paddle/fluid/tests/unittests/test_pool3d_api.py +++ b/python/paddle/fluid/tests/unittests/test_pool3d_api.py @@ -575,6 +575,16 @@ def run_zero_stride(): self.assertRaises(ValueError, run_zero_stride) + def run_zero_tuple_stride(): + with fluid.dygraph.guard(): + array = np.array([1], dtype=np.float32) + x = paddle.to_tensor( + np.reshape(array, [1, 1, 1, 1, 1]), dtype='float32' + ) + out = max_pool3d(x, 1, stride=(0, 0, 0), ceil_mode=False) + + self.assertRaises(ValueError, run_zero_tuple_stride) + if __name__ == '__main__': unittest.main()