Skip to content

Commit

Permalink
Fix F.clip_grad_by_norm in the case of small norm
Browse files Browse the repository at this point in the history
  • Loading branch information
takuseno committed Jan 11, 2020
1 parent 6d25d9c commit fc83ec5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/nbla/cuda/function/generic/clip_grad_by_norm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ __global__ void kernel_clip_grad_by_norm_forward(const int num, T *y,
const T *x, const T *m,
const float clip_norm) {
NBLA_CUDA_KERNEL_LOOP(idx, num) {
y[idx] = (T)clip_norm * x[idx] / sqrtf(m[idx]);
y[idx] = (T)clip_norm * x[idx] / fmaxf(sqrtf(m[idx]), clip_norm);
}
}

Expand Down

0 comments on commit fc83ec5

Please sign in to comment.