Add BlockDesc and ProgramDesc to framework.proto#4276
Add BlockDesc and ProgramDesc to framework.proto#4276JiayiFeng merged 5 commits intoPaddlePaddle:developfrom
BlockDesc and ProgramDesc to framework.proto#4276Conversation
paddle/framework/attribute.h
Outdated
| 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> |
There was a problem hiding this comment.
Actually, this variant is BlockDesc* to avoid memcpy.
paddle/framework/attribute.h
Outdated
|
|
||
| typedef std::unordered_map<std::string, Attribute> AttributeMap; | ||
|
|
||
| static ProgramDesc g_program_desc; |
There was a problem hiding this comment.
In Google C++ style, a class instance cannot be a global variable.
There was a problem hiding this comment.
It cannot be written in .h
There was a problem hiding this comment.
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 useextern int a;.externmeans somewhere is define that int value, but every.ccwhich includes this header can use that int value. -
staticmeans not to generate symbol name in.Sor.ofile. So this will actually create manyProgramDesc, each.cchas a newg_program_desc.
paddle/framework/attribute.cc
Outdated
| return val; | ||
| } | ||
| case framework::AttrType::BLOCK: { | ||
| return g_program_desc.blocks(attr_desc.block_idx()); |
There was a problem hiding this comment.
Just return a pointer, to avoid memcpy.
No description provided.