     long nInputRows = input->size[2];
     long nInputPlane = input->size[1];
     long nbatch = input->size[0];
-    long nOutputCols = (nInputCols - kW) / dW + 1;
-    long nOutputRows = (nInputRows - kH) / dH + 1;
+    long nOutputCols = ceil(float(nInputCols - kW) / float(dW) + 1);
+    long nOutputRows = ceil(float(nInputRows - kH) / float(dH) + 1);
 
     //luaL_argcheck(L, nInputCols >= kW && nInputRows >= kH, 2, "input image smaller than kernel size");
 

  int xx, yy;

  // output size
  const int output_w = (input_w - kW) / dW + 1;
  const int output_h = (input_h - kH) / dH + 1;

  // compute offsets based on thread/block ID
  int o = blockIdx.x;

  int xx, yy;

  // output size
  int output_w = ceil(float(input_w - kW) / float(dW) + 1);
  int output_h = ceil(float(input_h - kH) / float(dH) + 1);

  // compute offsets based on thread/block ID
  int o = blockIdx.x;
