From 5ae0c97faf78a02a3721298ccda9d6a0edbb7860 Mon Sep 17 00:00:00 2001 From: Yibing Liu Date: Wed, 17 Jan 2018 01:56:28 -0800 Subject: [PATCH] Add unit test case for no tokens to be erased --- .../v2/fluid/tests/test_sequence_erase_op.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/python/paddle/v2/fluid/tests/test_sequence_erase_op.py b/python/paddle/v2/fluid/tests/test_sequence_erase_op.py index 650984009..d8aa4f7e9 100644 --- a/python/paddle/v2/fluid/tests/test_sequence_erase_op.py +++ b/python/paddle/v2/fluid/tests/test_sequence_erase_op.py @@ -44,5 +44,20 @@ class TestSequenceEraseOp(OpTest): self.check_output() +class TestSequenceEraseOpEmpty(OpTest): + def setUp(self): + self.op_type = "sequence_erase" + in_seq = np.random.randint(0, 10, (30, 1)).astype("int32") + lod = [[0, 9, 13, 24, 30]] + tokens = [] + out_seq, new_lod0 = sequence_erase(in_seq, lod[0], tokens) + self.attrs = {'tokens': tokens} + self.inputs = {'X': (in_seq, lod)} + self.outputs = {'Out': (out_seq, [new_lod0])} + + def test_check_output(self): + self.check_output() + + if __name__ == '__main__': unittest.main() -- GitLab