diff --git a/src/cnn/backpropagation.c b/src/cnn/backpropagation.c index 2285de3..c321538 100644 --- a/src/cnn/backpropagation.c +++ b/src/cnn/backpropagation.c @@ -115,9 +115,9 @@ __global__ void backward_average_pooling_kernel(float*** input, float*** output, int max_move = kernel_size - padding; for (int a=-padding; a < max_move; a++) { - for (int b=-paddding; b < max_move; b++) { + for (int b=-padding; b < max_move; b++) { int idy_2 = stride*idy +a; - int idz_2 = stride*idz +b: + int idz_2 = stride*idz +b; if (not_outside(idy_2, idz_2, 0, input_width)) { int y = min(idy_2+1, min(kernel_size, input_width - idy_2)); int z = min(idz_2+1, min(kernel_size, input_width - idz_2)); @@ -214,7 +214,7 @@ __global__ void backward_max_pooling_kernel(float*** input, float*** output, int } } if (cpt==0) { - printf_error("Dimensions ou stride ou padding erroné dans 'backward_max_pooling_cpu'\n"); + printf(RED "[ERROR]" RESET " Dimensions ou stride ou padding erroné dans 'backward_max_pooling_cpu'\n"); } input[idx][stride*idy +a_max][stride*idz +b_max] = output[idx][idy][idz]/cpt; } @@ -262,7 +262,7 @@ void backward_max_pooling_cpu(float*** input, float*** output, int input_width, } } if (cpt==0) { - printf_error("Dimensions ou stride ou padding erroné dans 'backward_max_pooling_cpu'\n"); + printf_error((char*)"Dimensions ou stride ou padding erroné dans 'backward_max_pooling_cpu'\n"); } else { input[i][stride*j +a_max][stride*k +b_max] = output[i][j][k]/cpt; diff --git a/src/cnn/backpropagation.cu b/src/cnn/backpropagation.cu index 2285de3..c321538 100644 --- a/src/cnn/backpropagation.cu +++ b/src/cnn/backpropagation.cu @@ -115,9 +115,9 @@ __global__ void backward_average_pooling_kernel(float*** input, float*** output, int max_move = kernel_size - padding; for (int a=-padding; a < max_move; a++) { - for (int b=-paddding; b < max_move; b++) { + for (int b=-padding; b < max_move; b++) { int idy_2 = stride*idy +a; - int idz_2 = stride*idz +b: + int idz_2 = stride*idz +b; if (not_outside(idy_2, idz_2, 0, input_width)) { int y = min(idy_2+1, min(kernel_size, input_width - idy_2)); int z = min(idz_2+1, min(kernel_size, input_width - idz_2)); @@ -214,7 +214,7 @@ __global__ void backward_max_pooling_kernel(float*** input, float*** output, int } } if (cpt==0) { - printf_error("Dimensions ou stride ou padding erroné dans 'backward_max_pooling_cpu'\n"); + printf(RED "[ERROR]" RESET " Dimensions ou stride ou padding erroné dans 'backward_max_pooling_cpu'\n"); } input[idx][stride*idy +a_max][stride*idz +b_max] = output[idx][idy][idz]/cpt; } @@ -262,7 +262,7 @@ void backward_max_pooling_cpu(float*** input, float*** output, int input_width, } } if (cpt==0) { - printf_error("Dimensions ou stride ou padding erroné dans 'backward_max_pooling_cpu'\n"); + printf_error((char*)"Dimensions ou stride ou padding erroné dans 'backward_max_pooling_cpu'\n"); } else { input[i][stride*j +a_max][stride*k +b_max] = output[i][j][k]/cpt; diff --git a/src/cnn/convolution.c b/src/cnn/convolution.c index 9ad5450..0589462 100644 --- a/src/cnn/convolution.c +++ b/src/cnn/convolution.c @@ -7,9 +7,6 @@ #include "include/config.h" -#ifdef __CUDACC__ -__host__ __device__ -#endif void make_convolution_cpu(Kernel_cnn* kernel, float*** input, float*** output, int output_width, int stride, int padding) { // c'est le kernel de input diff --git a/src/cnn/convolution.cu b/src/cnn/convolution.cu index 9ad5450..0589462 100644 --- a/src/cnn/convolution.cu +++ b/src/cnn/convolution.cu @@ -7,9 +7,6 @@ #include "include/config.h" -#ifdef __CUDACC__ -__host__ __device__ -#endif void make_convolution_cpu(Kernel_cnn* kernel, float*** input, float*** output, int output_width, int stride, int padding) { // c'est le kernel de input diff --git a/src/cnn/include/convolution.h b/src/cnn/include/convolution.h index 0d555ed..6919f5c 100644 --- a/src/cnn/include/convolution.h +++ b/src/cnn/include/convolution.h @@ -1,8 +1,5 @@ #include "struct.h" -#ifdef __CUDACC__ -__host__ __device__ -#endif /* * Effectue la convolution naïvement sur le processeur diff --git a/src/cnn/include/make.h b/src/cnn/include/make.h index a115079..3e2a4ac 100644 --- a/src/cnn/include/make.h +++ b/src/cnn/include/make.h @@ -3,9 +3,6 @@ #ifndef DEF_MAKE_H #define DEF_MAKE_H -#ifdef __CUDACC__ -__host__ __device__ -#endif /* * Effectue la propagation d'une convolution avec stride et padding choisis sur le processeur diff --git a/src/cnn/make.c b/src/cnn/make.c index 3cdc8bd..a2a8dea 100644 --- a/src/cnn/make.c +++ b/src/cnn/make.c @@ -10,9 +10,6 @@ #include "include/config.h" -#ifdef __CUDACC__ -__host__ __device__ -#endif /* * Average Pooling diff --git a/src/cnn/make.cu b/src/cnn/make.cu index 3cdc8bd..a2a8dea 100644 --- a/src/cnn/make.cu +++ b/src/cnn/make.cu @@ -10,9 +10,6 @@ #include "include/config.h" -#ifdef __CUDACC__ -__host__ __device__ -#endif /* * Average Pooling diff --git a/src/common/include/utils.h b/src/common/include/utils.h index 6758feb..585e6c3 100644 --- a/src/common/include/utils.h +++ b/src/common/include/utils.h @@ -39,6 +39,9 @@ int max(int a, int b); #endif +#ifdef __CUDACC__ +__host__ __device__ +#endif /* * On renvoie true si et seulement si _ et _: * lower_bound <= x < upper_bound diff --git a/src/common/utils.c b/src/common/utils.c index 76e612e..da2c7f8 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -26,6 +26,10 @@ int max(int a, int b) { } #endif + +#ifdef __CUDACC__ +__host__ __device__ +#endif int not_outside(int x, int y, int lower_bound, int upper_bound) { return !(x < lower_bound || y < lower_bound || x >= upper_bound || y>= upper_bound); } diff --git a/src/common/utils.cu b/src/common/utils.cu index 03ee100..da2c7f8 100644 --- a/src/common/utils.cu +++ b/src/common/utils.cu @@ -27,6 +27,13 @@ int max(int a, int b) { #endif +#ifdef __CUDACC__ +__host__ __device__ +#endif +int not_outside(int x, int y, int lower_bound, int upper_bound) { + return !(x < lower_bound || y < lower_bound || x >= upper_bound || y>= upper_bound); +} + int i_div_up(int a, int b) { // Partie entière supérieure de a/b return ((a % b) != 0) ? (a / b + 1) : (a / b); }