提交 921fa13e 编写于 作者: Y Yu Yang

Remove delete

上级 63a56b4a
...@@ -20,12 +20,11 @@ Scope is used to provide a running environment for Net. ...@@ -20,12 +20,11 @@ Scope is used to provide a running environment for Net.
All these data/state can be abstracted and create as variable in Paddle, so the only thing Scope need to care about is Variable. All these data/state can be abstracted and create as variable in Paddle, so the only thing Scope need to care about is Variable.
1. Variable can only be created by Scope. 1. Variable can only be created by Scope.
1. Variable can only be got from Scope. 1. Variable can only be got from Scope.
1. Scope contains methods that are used to manage Variables, such as Create/Get/Delete. 1. Scope contains methods that are used to manage Variables, such as Create/Get.
Because we only need to care about Variable, we only need method to manage the lifecycle of Variable. Because we only need to care about Variable, we only need method to manage the lifecycle of Variable.
- `Create` is used to create a Variable by its name and add the mapping relation. - `Create` is used to create a Variable by its name and add the mapping relation.
- `Get` is used to find a Variable by name. - `Get` is used to find a Variable by name.
- `Delete` is used to remove a Variable because sometimes we want to release memory or other resources.
1. Every variable only belongs to one certain Scope. 1. Every variable only belongs to one certain Scope.
...@@ -44,10 +43,9 @@ class Scope { ...@@ -44,10 +43,9 @@ class Scope {
public: public:
Variable* CreateVariable(const std::string& name); Variable* CreateVariable(const std::string& name);
const Variable* GetVariable(const std::string& name) const; const Variable* GetVariable(const std::string& name) const;
bool DeleteVariable(const std::string& name);
private: private:
std::unordered_map<std::string, std::shared_ptr<Vairable>> variable_map_; std::unordered_map<std::string, std::shared_ptr<Vairable>> vars_;
}; };
``` ```
...@@ -108,7 +106,7 @@ class Scope { ...@@ -108,7 +106,7 @@ class Scope {
private: private:
std::shared_ptr<Scope> parent_; std::shared_ptr<Scope> parent_;
std::unordered_map<std::string, std::unique_ptr<Attribute>> attrs_; std::unordered_map<std::string, std::unique_ptr<Attribute>> vars_;
}; };
``` ```
## Only scope can create a variable ## Only scope can create a variable
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册