     	//long nOutputRows = (nInputRows - kH) / dH + 1;
 
     	input = THCudaTensor_newContiguous(state, input);
+    	gradoutput = THCudaTensor_newContiguous(state, gradoutput);
+    	
     	float* input_data = THCudaTensor_data(state, input);
+    	float* goutput_data = THCudaTensor_data(state, gradoutput);
 
     	THCudaTensor_resize3d(state, output, nInputPlane, nInputRows, nInputCols);
     	float* output_data = THCudaTensor_data(state, output);
     	
-    	float* goutput_data = THCudaTensor_data(state, gradoutput);
 
     	// cuda blocks & threads:
     	int yblocks = (int)(16L / nInputPlane);

	const int yy_step = blockDim.y*gridDim.y;

	// select input/output plane
	output = output + o*output_w*output_h;
	input = input + i*input_w*input_h;

	// For all output pixels...
	for(yy = yy_start; yy < yy_end; yy+=yy_step) {

    	  nInputPlane, nInputRows, nInputCols, kH, kW, dH, dW);
	
		THCudaTensor_free(state, input);
		THCudaTensor_free(state, gradoutput);
	}
	
	
