Fix the inference operation of the deformable convolutional layer.

This commit removes the malloc operation in the inference
method and adds the sigmoid kernel.

Signed-off-by: Davide Sapienza <sapienza.dav@gmail.com>
This commit is contained in:
Davide Sapienza
2019-12-19 14:47:57 +01:00
parent df888a3457
commit e99b353d8b
5 changed files with 97 additions and 163 deletions
+31
View File
@@ -0,0 +1,31 @@
#include "kernels.h"
__device__
__forceinline__
double sigmoid (double a)
{
return 1.0 / (1.0 + exp (-a));
}
__global__
void activation_sigmoid(dnnType *input, dnnType *output, int size) {
int stride = gridDim.x * blockDim.x;
int tid = blockDim.x * blockIdx.x + threadIdx.x;
for (int i = tid; i < size; i += stride) {
output[i] = sigmoid (input[i]);
}
}
/**
ELU activation function
*/
void activationSIGMOIDForward(dnnType* srcData, dnnType* dstData, int size, cudaStream_t stream)
{
int blocks = (size+255)/256;
int threads = 256;
activation_sigmoid<<<blocks, threads, 0, stream>>>(srcData, dstData, size);
}