Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions of restoring ProgramDescBind from ProgramDesc #5109

Conversation

JiayiFeng
Copy link
Collaborator

@JiayiFeng JiayiFeng commented Oct 26, 2017

fixes #5110

int input_size = desc_.inputs_size();
for (int i = 0; i < input_size; ++i) {
const OpDesc::Var &var = desc_.inputs(i);
std::vector<std::string> &argus = inputs_[var.parameter()];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RepeatedToVector ?

BlockDescBind::BlockDescBind(ProgramDescBind *prog, BlockDesc *desc)
: prog_(prog), desc_(desc), need_update_(false) {
int var_size = desc_->vars_size();
for (int i = 0; i < var_size; ++i) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (auto& var_desc : desc_->vars()) {

}

}
int op_size = desc_->ops_size();
for (int i = 0; i < op_size; ++i) {
const OpDesc &op_desc = desc_->ops(i);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (auto& op_desc: desc_->ops()) {}

}
// restore attrs_
int attr_size = desc_.attrs_size();
for (int i = 0; i < attr_size; ++i) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (auto& attr: desc_.attrs())

PADDLE_ENFORCE(desc_.ParseFromString(binary_str),
"Fail to parse program_desc from binary string.");
int block_size = desc_.blocks_size();
for (int i = 0; i < block_size; ++i) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (auto block: *desc_.mutable_blocks())

Copy link
Collaborator

@reyoung reyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent

@JiayiFeng JiayiFeng merged commit aa379cc into PaddlePaddle:develop Oct 26, 2017
@JiayiFeng JiayiFeng deleted the dev_build_program_bind_from_program_desc branch October 26, 2017 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need functions to restore ProgramDescBind from ProgramDesc
2 participants