提交 64a1cdf9 编写于 作者: Y Yu Yang

Merge branch 'scope' of https://github.com/jacquesqiao/Paddle into feature/scope_design

......@@ -8,15 +8,29 @@
1. Scope是Variable的Container
2. Scope可以共享
## Scope 是一个Variable的Container
## Scope is a Container of Variables.
解释下为啥Scope是Variable的container。解释下面几个小点的原因。
* Scope contains Variables as it's data member.
* Scope contains methods that are used to manage Variables, such as Create/Get/Delete.
* every variable only belong to one certain Scope.
* Scope should destruct all Variables within it when itself is destructed.
* Variable can only be created by Scope.
* Variable can only be got from Scope.
* Scope do not contains Operators and have no information to run them.
```cpp
class Scope {
public:
Variable* CreateVariable(const std::string& name);
const Variable* GetVariable(const std::string& name) const;
bool DeleteVariable(const std::string& name);
private:
std::unordered_map<std::string, std::shared_ptr<Vairable>> variable_map_;
};
```
* 他只包含variable
* 每一个variable也只属于一个Scope
* 每一个Scope析构的时候,会同时析构variable
* 只能通过Scope创建Vairable。
* 只能通过Scope获取Variable。
## Parent scope and local scope
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册