From e025fc970693763c0e694c41e3339321b678937e Mon Sep 17 00:00:00 2001 From: seiriosPlus Date: Sun, 28 Oct 2018 13:50:36 +0800 Subject: [PATCH] fix unit test in cpu 1.1 --- python/paddle/fluid/op.py | 2 + .../tests/unittests/test_dist_transpiler.py | 48 ++++++++----------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/python/paddle/fluid/op.py b/python/paddle/fluid/op.py index 667db10d3e..4e1d1450de 100644 --- a/python/paddle/fluid/op.py +++ b/python/paddle/fluid/op.py @@ -120,6 +120,8 @@ class OpDescCreationMethod(object): new_attr.strings.extend(user_defined_attr) elif attr.type == framework_pb2.BOOLEANS: new_attr.bools.extend(user_defined_attr) + elif attr.type == framework_pb2.LONGS: + new_attr.longs.extend(user_defined_attr) elif attr.type == framework_pb2.INT_PAIRS: for p in user_defined_attr: pair = new_attr.int_pairs.add() diff --git a/python/paddle/fluid/tests/unittests/test_dist_transpiler.py b/python/paddle/fluid/tests/unittests/test_dist_transpiler.py index 2b7227a646..2ad3a974d1 100644 --- a/python/paddle/fluid/tests/unittests/test_dist_transpiler.py +++ b/python/paddle/fluid/tests/unittests/test_dist_transpiler.py @@ -480,7 +480,7 @@ class TestDistLookupTable(TestDistLookupTableBase): def transpiler_test_impl(self): pserver1, startup1 = self.get_pserver(self.pserver1_ep) - self.assertEqual(len(pserver1.blocks), 6) + self.assertEqual(len(pserver1.blocks), 5) # 0 listen_and_serv # 1 optimize for fc_w or fc_b adam self.assertEqual([op.type for op in pserver1.blocks[1].ops], @@ -491,23 +491,19 @@ class TestDistLookupTable(TestDistLookupTableBase): # 3 prefetch -> lookup_sparse_table for data0 self.assertEqual([op.type for op in pserver1.blocks[3].ops], ["lookup_sparse_table"]) - # 4 prefetch -> lookup_sparse_table for data1 - self.assertEqual([op.type for op in pserver1.blocks[4].ops], - ["lookup_sparse_table"]) - # 5 save table - self.assertEqual([op.type for op in pserver1.blocks[5].ops], ["save"]) + # 4 save table + self.assertEqual([op.type for op in pserver1.blocks[4].ops], ["save"]) trainer, trainer_startup = self.get_trainer() self.assertEqual(len(trainer.blocks), 1) ops = [ - 'split_ids', 'prefetch', 'merge_ids', 'sequence_pool', 'split_ids', - 'prefetch', 'merge_ids', 'sequence_pool', 'concat', 'mul', - 'elementwise_add', 'cross_entropy', 'mean', 'fill_constant', - 'mean_grad', 'cross_entropy_grad', 'elementwise_add_grad', 'send', - 'mul_grad', 'send', 'concat_grad', 'sequence_pool_grad', - 'lookup_table_grad', 'sequence_pool_grad', 'lookup_table_grad', - 'sum', 'split_ids', 'send', 'send_barrier', 'recv', 'recv', - 'fetch_barrier' + 'split_ids', 'prefetch', 'merge_ids', 'sequence_pool', + 'sequence_pool', 'concat', 'mul', 'elementwise_add', + 'cross_entropy', 'mean', 'fill_constant', 'mean_grad', + 'cross_entropy_grad', 'elementwise_add_grad', 'send', 'mul_grad', + 'send', 'concat_grad', 'sequence_pool_grad', 'lookup_table_grad', + 'sequence_pool_grad', 'lookup_table_grad', 'sum', 'split_ids', + 'send', 'send_barrier', 'recv', 'recv', 'fetch_barrier' ] self.assertEqual([op.type for op in trainer.blocks[0].ops], ops) @@ -563,7 +559,7 @@ class TestAsyncDistLookupTable(TestDistLookupTableBase): pserver1, startup1 = self.get_pserver(self.pserver1_ep, config, False) - self.assertEqual(len(pserver1.blocks), 6) + self.assertEqual(len(pserver1.blocks), 5) # 0 listen_and_serv # 1 optimize for fc_w or fc_b adam self.assertEqual([op.type for op in pserver1.blocks[1].ops], @@ -573,23 +569,21 @@ class TestAsyncDistLookupTable(TestDistLookupTableBase): # 3 prefetch -> lookup_sparse_table for data0 self.assertEqual([op.type for op in pserver1.blocks[3].ops], ["lookup_sparse_table"]) - # 4 prefetch -> lookup_sparse_table for data1 - self.assertEqual([op.type for op in pserver1.blocks[4].ops], - ["lookup_sparse_table"]) - # 5 save table - self.assertEqual([op.type for op in pserver1.blocks[5].ops], ["save"]) + # 4 save table + self.assertEqual([op.type for op in pserver1.blocks[4].ops], ["save"]) trainer, _ = self.get_trainer(config) self.assertEqual(len(trainer.blocks), 1) ops = [ - 'split_ids', 'prefetch', 'merge_ids', 'sequence_pool', 'split_ids', - 'prefetch', 'merge_ids', 'sequence_pool', 'concat', 'mul', - 'elementwise_add', 'cross_entropy', 'mean', 'fill_constant', - 'mean_grad', 'cross_entropy_grad', 'elementwise_add_grad', 'send', - 'mul_grad', 'send', 'concat_grad', 'sequence_pool_grad', - 'lookup_table_grad', 'sequence_pool_grad', 'lookup_table_grad', - 'sum', 'split_ids', 'send', 'recv', 'recv' + 'split_ids', 'prefetch', 'merge_ids', 'sequence_pool', + 'sequence_pool', 'concat', 'mul', 'elementwise_add', + 'cross_entropy', 'mean', 'fill_constant', 'mean_grad', + 'cross_entropy_grad', 'elementwise_add_grad', 'send', 'mul_grad', + 'send', 'concat_grad', 'sequence_pool_grad', 'lookup_table_grad', + 'sequence_pool_grad', 'lookup_table_grad', 'sum', 'split_ids', + 'send', 'recv', 'recv' ] + self.assertEqual([op.type for op in trainer.blocks[0].ops], ops) -- GitLab