diff --git a/paddle/framework/block_desc.cc b/paddle/framework/block_desc.cc index ca3d03e55410c22fb31a8c11eb80e51e969524b0..3e344ea3790f57b0f53f36a40263dcdd326e67a9 100644 --- a/paddle/framework/block_desc.cc +++ b/paddle/framework/block_desc.cc @@ -155,8 +155,6 @@ BlockDesc::BlockDesc(ProgramDesc *prog, proto::BlockDesc *desc) for (const proto::OpDesc &op_desc : desc_->ops()) { ops_.emplace_back(new OpDesc(op_desc, prog, this)); } - std::cout << "Constructed block idx " << desc->idx() << " from protobuf str" - << std::endl; } BlockDesc::BlockDesc(const BlockDesc &other, proto::BlockDesc *desc, @@ -164,9 +162,8 @@ BlockDesc::BlockDesc(const BlockDesc &other, proto::BlockDesc *desc, : prog_(prog), desc_(desc) { need_update_ = true; for (auto &op : other.ops_) { - ops_.emplace_back(new OpDesc(*op, this)); + ops_.emplace_back(new OpDesc(*op->Proto(), prog, this)); } - for (auto &it : other.vars_) { auto *var = new VarDesc(*it.second); vars_[it.first].reset(var); diff --git a/paddle/framework/op_desc.cc b/paddle/framework/op_desc.cc index 7859c391fa370f1f2e60b8a94f2a370a99c2a765..46c50d9250f318b6afbe3c76c5c15cc5c51d1f2c 100644 --- a/paddle/framework/op_desc.cc +++ b/paddle/framework/op_desc.cc @@ -124,21 +124,10 @@ OpDesc::OpDesc(const proto::OpDesc &desc, ProgramDesc *prog, BlockDesc *block) // restore attrs_ for (const proto::OpDesc::Attr &attr : desc_.attrs()) { std::string attr_name = attr.name(); - // we use a trick to handle attr.type() is BLOCK here, because at this - // moment the sub_block hasn't beed added to ProgramDesc's vector - // so we cast the block_idx to a dummy BlockDesc pointer + // The sub_block referred to by the BLOCK attr hasn't be added + // to ProgramDesc class yet, we skip setting BLOCK attr here. if (attr.type() != proto::AttrType::BLOCK) { attrs_[attr_name] = GetAttrValue(attr); - } else { - size_t blk_idx = attr.block_idx(); - if (blk_idx < prog->Size()) { - attrs_[attr_name] = prog->MutableBlock(blk_idx); - std::cout << "In OpDesc: set up attr block idx " << blk_idx - << std::endl; - } else { - std::cout << "In OpDesc: We don't have this block idx " << blk_idx - << std::endl; - } } } this->block_ = block; diff --git a/paddle/framework/program_desc.cc b/paddle/framework/program_desc.cc index ba461b093390ff501caa7c0a39e720f39c66c4e8..0e937dda4e185590648962a6d4f827eea21eb620 100644 --- a/paddle/framework/program_desc.cc +++ b/paddle/framework/program_desc.cc @@ -43,7 +43,6 @@ ProgramDesc::ProgramDesc() { ProgramDesc::ProgramDesc(const ProgramDesc &o) { desc_ = o.desc_; - for (int i = 0; i < desc_.blocks_size(); ++i) { auto *block = desc_.mutable_blocks(i); blocks_.emplace_back(new BlockDesc(*o.blocks_[i], block, this)); @@ -54,8 +53,6 @@ ProgramDesc::ProgramDesc(const ProgramDesc &o) { if (attr.type() == proto::AttrType::BLOCK) { size_t blk_idx = attr.block_idx(); op->SetBlockAttr(attr.name(), *this->MutableBlock(blk_idx)); - std::cout << "In ProgramDesc 1: set block attr idx " << blk_idx - << std::endl; } } } @@ -64,11 +61,8 @@ ProgramDesc::ProgramDesc(const ProgramDesc &o) { ProgramDesc::ProgramDesc(const proto::ProgramDesc &desc) { desc_ = desc; - std::cout << std::endl << "starting in ProgDesc constructor" << std::endl; for (auto &block_desc : *desc_.mutable_blocks()) { blocks_.emplace_back(new BlockDesc(this, &block_desc)); - std::cout << "Done constructing block idx " << block_desc.idx() - << " parent idx " << block_desc.parent_idx() << std::endl; } for (auto &block : blocks_) { for (auto *op : block->AllOps()) { @@ -76,13 +70,10 @@ ProgramDesc::ProgramDesc(const proto::ProgramDesc &desc) { if (attr.type() == proto::AttrType::BLOCK) { size_t blk_idx = attr.block_idx(); op->SetBlockAttr(attr.name(), *this->MutableBlock(blk_idx)); - std::cout << "In ProgramDesc 2: set block attr idx " << blk_idx - << std::endl; } } } } - std::cout << "Done ProgDesc construction" << std::endl << std::endl; } ProgramDesc::ProgramDesc(const std::string &binary_str) { diff --git a/paddle/framework/prune.cc b/paddle/framework/prune.cc index 3c3ec87585124589d5ee4ef648d24cc7d10f5f60..00fe551e55e6be6d4e36a6953fa5b23054fca6e4 100644 --- a/paddle/framework/prune.cc +++ b/paddle/framework/prune.cc @@ -137,8 +137,6 @@ void prune_impl(const proto::ProgramDesc& input, proto::ProgramDesc* output, sub_block_dependent_vars.insert(argu); } } - std::cout << "pruning the next block, the current output_block_id is " - << output_block_id << std::endl; // GetSubBlockIndex(*op) is the idx of the sub_block in the input desc // output_block_id is the idx of the current block in the output desc prune_impl(input, output, GetSubBlockIndex(*op), output_block_id, @@ -147,8 +145,6 @@ void prune_impl(const proto::ProgramDesc& input, proto::ProgramDesc* output, } } - std::cout << "Starting to remove unreferenced variables" - << " for block idx " << output_block_id << std::endl; // remove the VarDescs in BlockDesc that are not referenced in // the pruned OpDescs std::unordered_map var_map; @@ -186,9 +182,7 @@ void prune_impl(const proto::ProgramDesc& input, proto::ProgramDesc* output, // TODO(fengjiayi): Prune() could be inplaced to avoid unnecessary copies void Prune(const proto::ProgramDesc& input, proto::ProgramDesc* output) { std::set dependent_vars; - std::cout << std::endl << "Start C++ framework::prune" << std::endl; prune_impl(input, output, 0, -1, dependent_vars); - std::cout << "Finished C++ framework::prune" << std::endl << std::endl; } void inference_optimize_impl(const proto::ProgramDesc& input, diff --git a/python/paddle/v2/fluid/io.py b/python/paddle/v2/fluid/io.py index e410549f8a5b3ba940b75416b9cdbdc4e75e79fe..613dc20b6ea5533d126a73b7ec47796b3f812db5 100644 --- a/python/paddle/v2/fluid/io.py +++ b/python/paddle/v2/fluid/io.py @@ -342,12 +342,6 @@ def save_inference_model(dirname, prepend_feed_ops(inference_program, feeded_var_names) append_fetch_ops(inference_program, fetch_var_names) - # save for checking - curstr = inference_program.to_string(True) - f = open("save_inf_prog_after_feed_fetch.txt", 'w') - f.write(curstr) - f.close() - model_file_name = dirname + "/__model__" with open(model_file_name, "wb") as f: f.write(inference_program.desc.serialize_to_string()) diff --git a/python/paddle/v2/fluid/tests/book/test_rnn_encoder_decoder.py b/python/paddle/v2/fluid/tests/book/test_rnn_encoder_decoder.py index 15f00f95d4020e1ea7f745136f0b250a97273d30..2211637b5b0eb263973f889bd66f18bd647e9fc2 100644 --- a/python/paddle/v2/fluid/tests/book/test_rnn_encoder_decoder.py +++ b/python/paddle/v2/fluid/tests/book/test_rnn_encoder_decoder.py @@ -225,18 +225,8 @@ def infer(save_dirname=None): # Construct feed as a dictionary of {feed_target_name: feed_target_data} # and results will contain a list of data corresponding to fetch_targets. - print("Print feed fetch target names as follows") - print(feed_target_names) assert feed_target_names[0] == 'source_sequence' assert feed_target_names[1] == 'target_sequence' - print([var.name for var in fetch_targets]) - - # save for checking - curstr = inference_program.to_string(True) - f = open("loaded_infer_prog.txt", 'w') - f.write(curstr) - f.close() - results = exe.run(inference_program, feed={ feed_target_names[0]: word_data,