From b9f894ca75affdc2e60e75bb362a294c7acd8cd6 Mon Sep 17 00:00:00 2001 From: Francesco Gatti Date: Wed, 28 Jun 2017 15:16:38 +0000 Subject: [PATCH] better elu kernel --- src/kernels/activation_elu.cu | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/kernels/activation_elu.cu b/src/kernels/activation_elu.cu index 85df29f..b507b5a 100644 --- a/src/kernels/activation_elu.cu +++ b/src/kernels/activation_elu.cu @@ -10,11 +10,18 @@ __global__ void activation_elu(value_type *input, value_type *output, int size) { int i = threadIdx.x*(blockIdx.x +1); - - if(i0)*input[i] + (input[i]<0)*(expf(input[i]) -1); - - // the if x > or < is condensed in one operation for better threads flow + + if(i0) + k0 = 1.0f; + else + k0 = 0.0f; + k1 = 1.0f-k0; + + output[i] = k0*input[i] + k1*(expf(input[i]) -1.0f); + } }