Skip to content

Commit

Permalink
Merge pull request PaddlePaddle#12 from qingqing01/framework_proto
Browse files Browse the repository at this point in the history
make unit test of backward_test pass.
  • Loading branch information
wangkuiyi authored Aug 11, 2017
2 parents f485815 + aad49da commit 5422776
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 216 deletions.
12 changes: 6 additions & 6 deletions paddle/framework/backward.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ template <typename Map, typename T>
static void ForEachVarName(Map& names, T callback) {
for (auto& name : names) {
for (auto& n : name.second) {
if (callback(n)) break;
if (callback(n)) return;
}
}
}

static bool AllInSet(
const std::unordered_map<std::string, std::vector<std::string>>& names,
const std::string& suffix, const std::unordered_set<std::string>& set) {
bool ret_val = true;
ForEachVarName(names, [&ret_val, &set, &suffix](const std::string& n) {
ret_val = set.find(n + suffix) == set.end();
return !ret_val;
bool all_in_set = true;
ForEachVarName(names, [&all_in_set, &set, &suffix](const std::string& n) {
all_in_set = set.find(n + suffix) != set.end();
return !all_in_set;
});
return ret_val;
return all_in_set;
}

static std::shared_ptr<OperatorBase> NOP() {
Expand Down
Loading

0 comments on commit 5422776

Please sign in to comment.