Skip to content

Add BlockDesc and ProgramDesc to framework.proto#4276

Merged
JiayiFeng merged 5 commits intoPaddlePaddle:developfrom
JiayiFeng:add_program_proto
Sep 21, 2017
Merged

Add BlockDesc and ProgramDesc to framework.proto#4276
JiayiFeng merged 5 commits intoPaddlePaddle:developfrom
JiayiFeng:add_program_proto

Conversation

@JiayiFeng
Copy link
Collaborator

No description provided.

@JiayiFeng JiayiFeng requested a review from reyoung September 21, 2017 00:57
typedef boost::variant<boost::blank, int, float, std::string, std::vector<int>,
std::vector<float>, std::vector<std::string>,
std::vector<std::pair<int, int>>>
std::vector<std::pair<int, int>>, BlockDesc>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, this variant is BlockDesc* to avoid memcpy.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done


typedef std::unordered_map<std::string, Attribute> AttributeMap;

static ProgramDesc g_program_desc;
Copy link
Collaborator

Choose a reason for hiding this comment

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

In Google C++ style, a class instance cannot be a global variable.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It cannot be written in .h

Copy link
Collaborator

Choose a reason for hiding this comment

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

Variable definition usually should not be written in a header file, because it will define all variables in .cc which includes this header. Here should be a declaration.

  • To define an int value, we use int a;. To declare an int value, we use extern int a;. extern means somewhere is define that int value, but every .cc which includes this header can use that int value.

  • static means not to generate symbol name in .S or .o file. So this will actually create many ProgramDesc, each .cc has a new g_program_desc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Got it

return val;
}
case framework::AttrType::BLOCK: {
return g_program_desc.blocks(attr_desc.block_idx());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just return a pointer, to avoid memcpy.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

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 Job!

@JiayiFeng JiayiFeng merged commit 7d33447 into PaddlePaddle:develop Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants