Skip to content

Commit

Permalink
Solve the NaN issue on the CPU
Browse files Browse the repository at this point in the history
This PR solves the NaN issue reported here : #63
The problem is that for newly allocated batches inside a Sequence, memory had to be reset to zeros, otherwise NaNs may flow in
  • Loading branch information
ASDen committed Feb 24, 2016
1 parent 509144d commit f1aebb2
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions batches.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,7 @@ struct Sequence {
}
void resize(int N, int n, int m) {
check();
if (N == size() && n == rows() && m == cols()) {
for (int t = 0; t < N; t++) {
steps[t].v.setZero();
steps[t].d.setZero();
}
} else {
if (N != size() || n != rows() || m != cols()) {
clear();
allocate(N, n, m);
steps.resize(N);
Expand All @@ -128,6 +123,8 @@ struct Sequence {
steps[t].d.displaceTo(data + (n * m) * (2 * t + 1), n, m, gpu);
}
}
//reset data, whether new or reused
memset(data,0,nbytes());
}
void like(const Sequence &other) {
resize(other.size(), other.rows(), other.cols());
Expand Down

0 comments on commit f1aebb2

Please sign in to comment.