(tkDNN): Support Resnet-101-AP-GeM for CUDNN, TRT to be fixed

Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
Micaela Verucchi
2022-09-24 16:57:12 +02:00
parent d4f7b4ad8b
commit 56da10df64
9 changed files with 741 additions and 3 deletions
+41
View File
@@ -39,6 +39,47 @@ __global__ void forward_maxpool_layer_kernel(int n, int in_h, int in_w, int in_c
output[out_index] = max;
}
__global__ void forward_gen_avgpool_p_layer_kernel(int n, int w, int h, int c, float p, float *input, float *output)
{
int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x;
if(id >= n) return;
int k = id % c;
id /= c;
int b = id;
int i;
int out_index = (k + c*b);
output[out_index] = 0;
for(i = 0; i < w*h; ++i){
int in_index = i + h*w*(k + b*c);
float in = 1e-6f;
if (input[in_index] > 1e-6f)
in = input[in_index];
in = pow(in, p);
output[out_index] += in;
}
output[out_index] /= w*h;
output[out_index] = pow(output[out_index], 1. / p);
}
void GeneralizedMeanPoolingP(dnnType* srcData, dnnType* dstData, int n, int c, int h, int w, float p, cudaStream_t stream)
{
int tot_size = n*c*h*w;
int blocks = (tot_size+255)/256;
int threads = 256;
std::cerr<<"Calling forward_gen_avgpool_p_layer_kernel "<<n<< " "<< c<<" "<<h<< " "<< w<< "\n";
forward_gen_avgpool_p_layer_kernel<<<blocks, threads, 0, stream>>>(n*c, h, w, c, p, srcData, dstData);
}
void MaxPoolingForward(dnnType* srcData, dnnType* dstData, int n, int c, int h, int w, int stride_x, int stride_y, int size, int padding, cudaStream_t stream)
{