From a51cb41f5653b71768beefa5a9d6283b298a11df Mon Sep 17 00:00:00 2001 From: jaesong Date: Tue, 17 Mar 2020 12:44:14 +0000 Subject: [PATCH] Fix illegal memory access of compute_grad_kernel If `mb == minibatch_size - 1 && u == U-1`, `labels[u]` is out-of-bounds memory access. --- include/detail/gpu_rnnt_kernel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/detail/gpu_rnnt_kernel.h b/include/detail/gpu_rnnt_kernel.h index 6d3cdae..738d7ef 100644 --- a/include/detail/gpu_rnnt_kernel.h +++ b/include/detail/gpu_rnnt_kernel.h @@ -168,7 +168,7 @@ __global__ void compute_grad_kernel(Tp* grads, const Tp* const acts, const Tp* c if (idx == blank_ && t < T-1) { grad -= exp(alphas[col] + logpk - logll[mb] + betas[col + maxU]); } - if (idx == labels[u] && u < U-1) { + if (u < U-1 && idx == labels[u]) { grad -= exp(alphas[col] + logpk - logll[mb] + betas[col+1]); } grads[col * alphabet_size + idx] = grad;