 
      // compute the top left, top right, bottom left, bottom right corner for current grid
      // compute the nearest bottom right coordiate in source map of top left grid coordiate
-     getTopLeft(xs_tl, inputImages_width, xi_l, xWeight_l);
-     getTopLeft(ys_tl, inputImages_height, yi_t, yWeight_t);
+     getBottomRight(xs_tl, inputImages_width, xi_l, xWeight_l);
+     getBottomRight(ys_tl, inputImages_height, yi_t, yWeight_t);
      // compute the nearest top left coordiate in source map of bottom right grid coordiate
-     getBottomRight(xs_br, inputImages_width, xi_r, xWeight_r);
-     getBottomRight(ys_br, inputImages_height, yi_b, yWeight_b);
+     getTopLeft(xs_br, inputImages_width, xi_r, xWeight_r);
+     getTopLeft(ys_br, inputImages_height, yi_b, yWeight_b);
 
      bool topLeftIsIn = between(xi_l, 0, width-1) && between(yi_t, 0, height-1);
      bool topRightIsIn = between(xi_r, 0, width-1) && between(yi_t, 0, height-1);

           for (int x = xi_l; x <= xi_r; ++x) {
             if (!between(x, 0, width-1)) continue;
             int address = inputImages_strideBatch * b + inputImages_strideHeight * y + inputImages_strideWidth * x;
             grad_yf += 2 * gradOutValue_fg * inputImages_data[address + t]
                        * weights[id_point]
                        * (bias_y[id_point] - bias_y_weighted / weight_sum)
                        / weight_sum;
             grad_xf += 2 * gradOutValue_fg * inputImages_data[address + t]
                        * weights[id_point]
                        * (bias_x[id_point] - bias_x_weighted / weight_sum)
                        / weight_sum;
             ++id_point;
           }
         }

   float yf_s = (yf + 1) * (height - 1) / 2;
   // compute the top left, top right, bottom left, bottom right corner for current grid
   // compute the nearest bottom right coordiate in source map of top left grid coordiate
   getBottomRight(xs_tl, inputImages_width, xi_l, xWeight_l);
   getBottomRight(ys_tl, inputImages_height, yi_t, yWeight_t);
   // compute the nearest top left coordiate in source map of bottom right grid coordiate
   getTopLeft(xs_br, inputImages_width, xi_r, xWeight_r);
   getTopLeft(ys_br, inputImages_height, yi_b, yWeight_b);

/*
   #if __CUDA_ARCH__>=200
