Fix error in CUDA kernel of beam_search. (#15957)

test=develop
revert-15953-remove_default_stream_task_1
Yiqun Liu 6 years ago committed by GitHub
parent c494f64a0f
commit 87248281f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -119,6 +119,18 @@ __device__ __forceinline__ int SelectTopBeam(
__syncthreads();
}
if ((num_used_threads & 0x1) != 0) {
// If num_used_threads is a odd number, merge local top_beam of thread 0
// and num_used_threads - 1
if (tid_of_seq == 0) {
int index_in_sh = (num_used_threads - 1 + tid) * beam_size;
for (int i = 0; i < beam_size; i++) {
Insert(top_beam_local, top_beam[index_in_sh], beam_size);
index_in_sh++;
}
}
}
num_used_threads = num_used_threads >> 1;
if (tid_of_seq < num_used_threads) {
int index_in_sh = (num_used_threads + tid) * beam_size;

Loading…
Cancel
Save