Skip to content

Commit

Permalink
check embed index in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
twmht committed Mar 23, 2018
1 parent 7e97067 commit d09f157
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/caffe/layers/embed_layer.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ __global__ void EmbedForward(const int nthreads, const Dtype* bottom_data,
const int n = top_index / N;
const int d = top_index % N;
const int index = static_cast<int>(bottom_data[n]);
#ifdef DEBUG
assert(index >= 0);
assert(index < K);
assert(static_cast<Dtype>(index) == bottom_data[n]);
#endif
const int weight_index = index * N + d;
top_data[top_index] = weight[weight_index];
}
Expand Down

0 comments on commit d09f157

Please sign in to comment.