-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Add functions of restoring ProgramDescBind from ProgramDesc #5109
Conversation
… dev_build_program_bind_from_program_desc
… dev_build_program_bind_from_program_desc
paddle/framework/op_desc.cc
Outdated
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()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RepeatedToVector
?
paddle/framework/block_desc.cc
Outdated
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) { |
There was a problem hiding this comment.
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()) {
}
paddle/framework/block_desc.cc
Outdated
} | ||
int op_size = desc_->ops_size(); | ||
for (int i = 0; i < op_size; ++i) { | ||
const OpDesc &op_desc = desc_->ops(i); |
There was a problem hiding this comment.
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()) {}
paddle/framework/op_desc.cc
Outdated
} | ||
// restore attrs_ | ||
int attr_size = desc_.attrs_size(); | ||
for (int i = 0; i < attr_size; ++i) { |
There was a problem hiding this comment.
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/framework/program_desc.cc
Outdated
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) { |
There was a problem hiding this comment.
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())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent
fixes #5110