   grids.z = nOutputs;
 
   size_t SHM_SIZE = getSuitableShmConfig(grids, threads, imgOut.m, imgOut.n);
+  // printf("grids = (%lu, %lu, %lu), threads = (%lu, %lu, %lu) \n", grids.x, grids.y, grids.z, threads.x, threads.y, threads.z);
 
   for (size_t i=0; i<nInputs; ++i)
     for (size_t b=0; b<batch_size; ++b) {


  // Copy data in global memory to shared memory
  float* D = K + kW * kH;
  int WIDTH_STEP = blockDim.x + kW - 1,
      HEIGHT_STEP = blockDim.y + kH - 1;

  int nTotal = WIDTH_STEP * HEIGHT_STEP;
  int avgToLoad  = nTotal / nThreads + 1;

  for (int i=0; i<avgToLoad; ++i) {
    int id = tid + i * nThreads;

    if (id >= nTotal) break;

    int xx = id / HEIGHT_STEP + x0 - (kW - 1),
	yy = id % HEIGHT_STEP + y0 - (kH - 1);

    if (xx < 0 || xx >= W || yy < 0 || yy >= H)
      D[id] = 0;
    else 
      D[id] = data[ xx * H + yy ];
  }
  __syncthreads();
  

    return;

  float sum = 0; 
  D += tx * HEIGHT_STEP + ty;
  for (int i = 0; i < kW; ++i)
    for(int j = 0; j < kH; ++j)
      sum += K[ i * kH + j ] * D[ i * HEIGHT_STEP + j]; 

  output[ x * fH + y ] = sum;
}
