From dc643a33523b48ace8e05dcfe0167b21d3687631 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Fri, 22 Sep 2017 15:42:14 -0700 Subject: [PATCH] Hot fix unittest --- paddle/pybind/protobuf.cc | 17 ++++------------- .../v2/framework/tests/test_protobuf_descs.py | 4 ---- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/paddle/pybind/protobuf.cc b/paddle/pybind/protobuf.cc index b4ed9c4335..0fb78bf7a2 100644 --- a/paddle/pybind/protobuf.cc +++ b/paddle/pybind/protobuf.cc @@ -59,14 +59,7 @@ public: BlockDescBind(ProgramDescBind *prog, BlockDesc *desc) : prog_(prog), desc_(desc), need_update_(false) {} - ~BlockDescBind() { - std::cerr << "dtor " << this << "," << desc_ << std::endl; - } - - int32_t id() const { - std::cerr << "desc ptr " << desc_ << std::endl; - return desc_->idx(); - } + int32_t id() const { return desc_->idx(); } int32_t Parent() const { return desc_->parent_idx(); } @@ -114,11 +107,9 @@ public: return *ptr; } - BlockDescBind *AppendBlock(BlockDescBind *parent) { + BlockDescBind *AppendBlock(const BlockDescBind &parent) { auto *b = prog_->add_blocks(); - std::cerr << "block ptr " << b << std::endl; - std::cerr << "pass ptr " << parent << std::endl; - b->set_parent_idx(parent->id()); + b->set_parent_idx(parent.id()); b->set_idx(prog_->blocks_size() - 1); blocks_.emplace_back(this, b); return &blocks_.back(); @@ -141,6 +132,7 @@ public: private: explicit ProgramDescBind(ProgramDesc *prog) : prog_(prog) { + blocks_.reserve(100); for (auto &block : *prog->mutable_blocks()) { blocks_.emplace_back(this, &block); } @@ -181,7 +173,6 @@ void BindProgramDesc(py::module &m) { } void BindBlockDesc(py::module &m) { - using namespace paddle::framework; // NOLINT py::class_(m, "BlockDesc", "") .def_property_readonly("id", &BlockDescBind::id) .def_property_readonly("parent", &BlockDescBind::Parent) diff --git a/python/paddle/v2/framework/tests/test_protobuf_descs.py b/python/paddle/v2/framework/tests/test_protobuf_descs.py index b5ff2d4c36..fbe1f7152b 100644 --- a/python/paddle/v2/framework/tests/test_protobuf_descs.py +++ b/python/paddle/v2/framework/tests/test_protobuf_descs.py @@ -17,16 +17,12 @@ class TestProgramDesc(unittest.TestCase): self.assertIsNotNone(prog_desc) block_root = prog_desc.block(0) self.assertIsNotNone(block_root) - print 'here' self.assertEqual(block_root.id, 0) block1 = prog_desc.append_block(block_root) block2 = prog_desc.append_block(block1) self.assertIsNotNone(block1) - print 'here' self.assertEqual(block1.id, block2.parent) - print 'here' self.assertEqual(block_root.id, block1.parent) - print 'here' block3 = prog_desc.append_block(block_root) self.assertEqual(block3.parent, block_root.id) self.assertEqual(prog_desc.block(1).id, 1) -- GitLab