1 #include "cuda_runtime.h" 13 if(x < 0)
return .001f*x;
14 if(x > 1)
return .001f*(x-1.f) + 1.f;
19 if(x > 0 && x < 1)
return 1;
25 if (x < -1)
return -1;
34 __device__
float selu_activate_kernel(
float x){
return (x >= 0)*1.0507f*x + (x < 0)*1.0507f*1.6732f*(expf(x)-1);}
41 if(x < -4)
return .01f * (x + 4);
42 if(x > 4)
return .01f * (x - 4) + 1;
48 if (n%2 == 0)
return floorf(x/2);
49 else return (x - n) + floorf(x/2);
55 if (x > -1 && x < 1)
return 1;
75 if (floorf(x) == x)
return 0;
151 int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
154 float x1 = x[b*s + i];
155 float x2 = x[b*s + s/2 + i];
159 dx[b*s + s/2 + i] = x1*de;
166 check_error(cudaPeekAtLastError());
170 int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
173 float x1 = x[b*s + i];
174 float x2 = x[b*s + s/2 + i];
175 if(
id < n) y[id] = x1*x2;
181 check_error(cudaPeekAtLastError());
186 int i = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
192 int i = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
198 activate_array_kernel<<<cuda_gridsize(n), BLOCK>>>(x, n, a);
199 check_error(cudaPeekAtLastError());
204 gradient_array_kernel<<<cuda_gridsize(n), BLOCK>>>(x, n, a, delta);
205 check_error(cudaPeekAtLastError());
__device__ float relie_gradient_kernel(float x)
__device__ float gradient_kernel(float x, ACTIVATION a)
__global__ void activate_array_kernel(float *x, int n, ACTIVATION a)
__global__ void gradient_array_kernel(float *x, int n, ACTIVATION a, float *delta)
__device__ float plse_gradient_kernel(float x)
__device__ float plse_activate_kernel(float x)
__device__ float logistic_gradient_kernel(float x)
__device__ float ramp_activate_kernel(float x)
__device__ float tanh_gradient_kernel(float x)
__device__ float hardtan_gradient_kernel(float x)
__device__ float hardtan_activate_kernel(float x)
void binary_activate_array_gpu(float *x, int n, int size, BINARY_ACTIVATION a, float *y)
__device__ float leaky_activate_kernel(float x)
void binary_gradient_array_gpu(float *x, float *dx, int n, int size, BINARY_ACTIVATION a, float *y)
__device__ float relu_gradient_kernel(float x)
__global__ void binary_activate_array_kernel(float *x, int n, int s, BINARY_ACTIVATION a, float *y)
__device__ float stair_gradient_kernel(float x)
__device__ float loggy_activate_kernel(float x)
__device__ float lhtan_gradient_kernel(float x)
__device__ float lhtan_activate_kernel(float x)
__device__ float stair_activate_kernel(float x)
__global__ void binary_gradient_array_kernel(float *x, float *dy, int n, int s, BINARY_ACTIVATION a, float *dx)
__device__ float logistic_activate_kernel(float x)
__device__ float relie_activate_kernel(float x)
__device__ float ramp_gradient_kernel(float x)
__device__ float activate_kernel(float x, ACTIVATION a)
__device__ float loggy_gradient_kernel(float x)
__device__ float relu_activate_kernel(float x)
__device__ float linear_gradient_kernel(float x)
__device__ float selu_gradient_kernel(float x)
__device__ float elu_activate_kernel(float x)
__device__ float leaky_gradient_kernel(float x)
void activate_array_gpu(float *x, int n, ACTIVATION a)
__device__ float linear_activate_kernel(float x)
__device__ float tanh_activate_kernel(float x)
void gradient_array_gpu(float *x, int n, ACTIVATION a, float *delta)
__device__ float elu_gradient_kernel(float x)
__device__ float selu_activate_kernel(float x)