提交 7924860b 编写于 作者: D DannyIsFunny

test=develop

上级 6ad97f6b
...@@ -152,7 +152,7 @@ std::vector<std::string> Predictor::GetOutputNames() { return output_names_; } ...@@ -152,7 +152,7 @@ std::vector<std::string> Predictor::GetOutputNames() { return output_names_; }
// get param names // get param names
std::vector<std::string> Predictor::GetParamNames() { std::vector<std::string> Predictor::GetParamNames() {
return exec_scope_->LocalVarNames(); return exec_scope_->VarNames();
} }
// append the names of inputs and outputs into input_names_ and output_names_ // append the names of inputs and outputs into input_names_ and output_names_
......
...@@ -60,6 +60,19 @@ Variable *Scope::FindLocalVar(const std::string &name) const { ...@@ -60,6 +60,19 @@ Variable *Scope::FindLocalVar(const std::string &name) const {
return nullptr; return nullptr;
} }
std::vector<std::string> Scope::VarNames() const {
std::vector<std::string> resulted_keys;
auto keys = LocalVarNames();
resulted_keys.insert(resulted_keys.end(), keys.begin(), keys.end());
const Scope *cur_scope = this;
while (cur_scope->parent()) {
cur_scope = cur_scope->parent();
keys = cur_scope->LocalVarNames();
resulted_keys.insert(resulted_keys.end(), keys.begin(), keys.end());
}
return resulted_keys;
}
std::vector<std::string> Scope::LocalVarNames() const { std::vector<std::string> Scope::LocalVarNames() const {
std::vector<std::string> keys; std::vector<std::string> keys;
for (const auto &item : vars_) { for (const auto &item : vars_) {
......
...@@ -45,6 +45,8 @@ class Scope final { ...@@ -45,6 +45,8 @@ class Scope final {
const Scope* parent() const { return parent_; } const Scope* parent() const { return parent_; }
// Get all params in each scope.
std::vector<std::string> VarNames() const;
// Following the legacy scope interface. // Following the legacy scope interface.
std::vector<std::string> LocalVarNames() const; std::vector<std::string> LocalVarNames() const;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册