Skip to content

Commit

Permalink
add unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
RedContritio committed Feb 1, 2023
1 parent 48ab823 commit 4098dbc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/paddle/fluid/tests/unittests/test_pool1d_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
12 changes: 12 additions & 0 deletions python/paddle/fluid/tests/unittests/test_pool2d_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
10 changes: 10 additions & 0 deletions python/paddle/fluid/tests/unittests/test_pool3d_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 4098dbc

Please sign in to comment.