未验证 提交 3f87464e 编写于 作者: Z Zeng Jinle 提交者: GitHub

refine executor_gc_helper codes, test=develop (#19814)

上级 6d72a86b
......@@ -44,7 +44,8 @@ struct ExecutorPrepareContext {
std::vector<std::unique_ptr<OperatorBase>> ops_;
std::unordered_map<OperatorBase*, std::vector<std::string>> unused_vars_;
std::unordered_map<const OperatorBase*, std::vector<std::string>>
unused_vars_;
bool force_disable_gc_{false};
};
......
......@@ -89,10 +89,10 @@ static bool VarCanBeDeleted(const std::string &name, const BlockDesc &block,
type == proto::VarType::LOD_TENSOR_ARRAY;
}
std::unordered_map<OperatorBase *, std::vector<std::string>> GetUnusedVars(
const BlockDesc &block,
const std::vector<std::unique_ptr<OperatorBase>> &ops,
const std::vector<std::string> &skip_var_list) {
std::unordered_map<const OperatorBase *, std::vector<std::string>>
GetUnusedVars(const BlockDesc &block,
const std::vector<std::unique_ptr<OperatorBase>> &ops,
const std::vector<std::string> &skip_var_list) {
std::unordered_set<std::string> skip_vars(skip_var_list.begin(),
skip_var_list.end());
......@@ -134,7 +134,7 @@ std::unordered_map<OperatorBase *, std::vector<std::string>> GetUnusedVars(
}
}
std::unordered_map<OperatorBase *, std::vector<std::string>> result;
std::unordered_map<const OperatorBase *, std::vector<std::string>> result;
for (auto &name_op_idx_pair : var_op_idx_map) {
auto &name = name_op_idx_pair.first;
size_t op_idx = name_op_idx_pair.second;
......@@ -144,8 +144,8 @@ std::unordered_map<OperatorBase *, std::vector<std::string>> GetUnusedVars(
}
void DeleteUnusedTensors(
const Scope &scope, OperatorBase *op,
const std::unordered_map<OperatorBase *, std::vector<std::string>>
const Scope &scope, const OperatorBase *op,
const std::unordered_map<const OperatorBase *, std::vector<std::string>>
&delete_vars_map,
GarbageCollector *gc) {
auto iter = delete_vars_map.find(op);
......
......@@ -26,15 +26,15 @@ namespace paddle {
namespace framework {
// Result map: op -> variable names that can be deleted after op runs
std::unordered_map<OperatorBase *, std::vector<std::string>> GetUnusedVars(
const BlockDesc &block,
const std::vector<std::unique_ptr<OperatorBase>> &ops,
const std::vector<std::string> &skip_vars);
std::unordered_map<const OperatorBase *, std::vector<std::string>>
GetUnusedVars(const BlockDesc &block,
const std::vector<std::unique_ptr<OperatorBase>> &ops,
const std::vector<std::string> &skip_vars);
// Collect unused tensors after op runs
void DeleteUnusedTensors(
const Scope &scope, OperatorBase *op,
const std::unordered_map<OperatorBase *, std::vector<std::string>>
const Scope &scope, const OperatorBase *op,
const std::unordered_map<const OperatorBase *, std::vector<std::string>>
&delete_vars_map,
GarbageCollector *gc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册