Skip to content

Commit

Permalink
fix bug on multiple calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffaljidhmah2 committed Mar 23, 2019
1 parent 1be3cf3 commit 56145e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ void Graph::eval(const Variable & z)
}
}
std::sort(cal_list.begin(), cal_list.end());

auto end=std::unique(cal_list.begin(), cal_list.end());
cal_list.resize(std::distance(cal_list.begin(),end));
for (auto it=cal_list.begin();it!= cal_list.end();++it)
op_stack[*it]->cal();
}
Expand Down Expand Up @@ -103,7 +104,8 @@ void Graph::backward(Variable & z)
}
}
std::sort(cal_list.begin(), cal_list.end());

auto end=std::unique(cal_list.begin(), cal_list.end());
cal_list.resize(std::distance(cal_list.begin(),end));
for (auto it=cal_list.rbegin();it!= cal_list.rend();++it)
op_stack[*it]->bp();

Expand Down

0 comments on commit 56145e3

Please sign in to comment.