         const int height, const int width, const int ksize, const int pad,
         const int stride, const int channels,
         const int height_col, const int width_col,
+        const int bidx, const int batch,
         float* data_col) {
     CUDA_KERNEL_LOOP(index, n) {
         int w_out = index % width_col;

        int channel_out = channel_in * ksize * ksize;
        int h_in = h_out * stride - pad;
        int w_in = w_out * stride - pad;
        data_col += (channel_out * height_col + h_out) * width_col + w_out;
        data_im += (h_in * width + w_in) * channels + channel_in;
        for (int i = 0; i < ksize; ++i) {
            for (int j = 0; j < ksize; ++j) {
                int h = h_in + i;
                int w = w_in + j;
                *data_col = (h >= 0 && w >= 0 && h < height && w < width) ?
                    data_im[(i * width + j) * channels] : 0;
                data_col += height_col * width_col;
            }
        }
    }

        luaL_argcheck(L, batchSize == 1 || batchSize % 4 == 0, 1, "batch size should be a multiple of 4 or equal to 1");
        luaL_argcheck(L, nOutputPlane % 8 == 0, 1, "nOutputPlane should be a multiple of 8");

        // Step batch (inner loop)
        // This variable defines how many samples are processed in //, in the inner loop
        int stepBatchSize = 1;
        if (batchSize % 4 == 0) {
            stepBatchSize = 4;
        }

        // Resize output
        THCudaTensor_resize4d(output, batchSize, outputHeight, outputWidth, nOutputPlane);

        // Resize temporary columns
        THCudaTensor_resize2d(columns, kH*kW*nInputPlane, stepBatchSize*outputHeight*outputWidth);

        // Add bias first
        // TODO: replace this by more efficient, custom kernel
        long k;
        THCudaTensor *outputPlane = THCudaTensor_new();
        for(k=0; k<nOutputPlane; k++) {
