From dd16e34cce3c9a376d928c3c408901969a39caad Mon Sep 17 00:00:00 2001 From: augustin64 Date: Thu, 30 Mar 2023 18:11:00 +0200 Subject: [PATCH] extern "C" get_activation_function_cuda --- src/cnn/function.c | 11 ++++------- src/cnn/function.cu | 11 ++++------- src/cnn/include/function.h | 3 +++ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/cnn/function.c b/src/cnn/function.c index 4ac6ecb..71af124 100644 --- a/src/cnn/function.c +++ b/src/cnn/function.c @@ -107,20 +107,16 @@ float leaky_relu_derivative(float x) { //* Tanh #ifdef __CUDACC__ -__device__ -#endif -float device_tanh_(float x) { +__device__ float device_tanh_(float x) { return tanh(x); } -#ifdef __CUDACC__ -__device__ -#endif -float device_tanh_derivative(float x) { +__device__ float device_tanh_derivative(float x) { float a = tanh(x); return 1 - a*a; } +#endif float tanh_(float x) { return tanh(x); } @@ -303,6 +299,7 @@ funcPtr get_activation_function(int activation) { #ifdef __CUDACC__ +extern "C" funcPtr get_activation_function_cuda(int activation) { funcPtr host_function; diff --git a/src/cnn/function.cu b/src/cnn/function.cu index 4ac6ecb..22bfae6 100644 --- a/src/cnn/function.cu +++ b/src/cnn/function.cu @@ -107,19 +107,15 @@ float leaky_relu_derivative(float x) { //* Tanh #ifdef __CUDACC__ -__device__ -#endif -float device_tanh_(float x) { +__device__ float device_tanh_(float x) { return tanh(x); } -#ifdef __CUDACC__ -__device__ -#endif -float device_tanh_derivative(float x) { +__device__ float device_tanh_derivative(float x) { float a = tanh(x); return 1 - a*a; } +#endif float tanh_(float x) { return tanh(x); @@ -303,6 +299,7 @@ funcPtr get_activation_function(int activation) { #ifdef __CUDACC__ +extern "C" funcPtr get_activation_function_cuda(int activation) { funcPtr host_function; diff --git a/src/cnn/include/function.h b/src/cnn/include/function.h index 4234009..6ff17b4 100644 --- a/src/cnn/include/function.h +++ b/src/cnn/include/function.h @@ -142,6 +142,9 @@ funcPtr get_activation_function(int activation); /* * Récupère un pointeur sur le device vers la fonction d'activation demandée puis le transforme en pointeur sur l'host */ +#ifdef __CUDACC__ +extern "C" funcPtr get_activation_function_cuda(int activation); +#endif #endif \ No newline at end of file