Skip to content

Commit

Permalink
Strict gradient boundary check (apache#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen authored and sergei-mironov committed Aug 8, 2018
1 parent ecbc902 commit cddb5c1
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nnvm/src/pass/gradient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ Graph Gradient(Graph src) {
}
std::vector<NodeEntry> input_grads = grad_fun_map[ptr->op()]
(mirror_map.size() == 0 ? ptr : mirror_map.at(ptr.get()), out_agg_grads);
CHECK_EQ((*rit)->inputs.size(), input_grads.size())
<< "Gradient function not returning enough gradient";
auto git = input_grads.begin();
for (auto it = (*rit)->inputs.begin(); it != (*rit)->inputs.end(); ++it, ++git) {
output_grads[it->node.get()][it->index].grads.emplace_back(std::move(*git));
Expand Down

0 comments on commit cddb5c1

Please sign in to comment.