Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions paddle/framework/scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,9 @@ void Scope::DropKids() {
kids_.clear();
}

std::vector<std::string> Scope::GetAllNames(bool recursive) const {
std::vector<std::string> known_vars(vars_.size());

if (recursive) {
for (auto& kid : kids_) {
auto kid_vars = kid->GetAllNames();
for (auto& p : kid_vars) {
known_vars.emplace_back(p);
}
}
}
std::vector<std::string> Scope::LocalVarNames() const {
std::vector<std::string> known_vars;
known_vars.reserve(this->vars_.size());
for (auto& p : vars_) {
known_vars.emplace_back(p.first);
}
Expand Down
2 changes: 1 addition & 1 deletion paddle/framework/scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Scope {
void DropKids();

// enumerate all the variables current contains.
std::vector<std::string> GetAllNames(bool recursive = false) const;
std::vector<std::string> LocalVarNames() const;

// Rename variable to a new name
void Rename(const std::string& origin_name,
Expand Down
2 changes: 1 addition & 1 deletion paddle/framework/scope_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ TEST(Scope, GetAllNames) {
Variable* v = s.Var("a");
EXPECT_EQ(&s, s.FindScope(v));

std::vector<std::string> ans = s.GetAllNames();
std::vector<std::string> ans = s.LocalVarNames();
std::string str;
for (auto& var : ans) {
str += var;
Expand Down
2 changes: 1 addition & 1 deletion paddle/operators/recurrent_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ class RecurrentGradOp : public RecurrentBase {

std::unordered_set<std::string> LocalVarNames(
const framework::Scope &scope) const {
return this->List2Set(scope.GetAllNames(false));
return this->List2Set(scope.LocalVarNames());
}
static std::vector<std::string> GradVarLists(
const std::vector<std::string> &var_names) {
Expand Down