-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Description
Paddle/paddle/framework/block_desc.cc
Lines 164 to 166 in b15c675
| for (auto &op : other.ops_) { | |
| ops_.emplace_back(new OpDesc(*op, this)); | |
| } |
The code above is how the OpDesc is constructed when we call program.clone() on the python side.
This construction will call the following function:
Paddle/paddle/framework/op_desc.h
Lines 39 to 42 in b15c675
| OpDesc(const OpDesc &other, BlockDesc *block) { | |
| *this = other; | |
| block_ = block; | |
| } |
Essentially, this calls a default assignment operator that copies the following data members:
Paddle/paddle/framework/op_desc.h
Lines 141 to 147 in b15c675
| proto::OpDesc desc_; | |
| BlockDesc *block_; // not_own | |
| // input arg name => input variable names | |
| VariableNameMap inputs_; | |
| // output arg name => output variable names | |
| VariableNameMap outputs_; | |
| AttributeMap attrs_; |
Because the attribute type in the AttributeMap could be a BlockDesc*, cloning program desc in this way, makes for example the BLOCK attribute of the while operator in the copied program desc points to a BlockDesc in the original program desc.
This will be fixed along with #8161