   // Free
   THCudaTensor_free(state, gradInput_n);
   THCudaTensor_free(state, gradOutput_n);
+  if (freeWeight)
+    THCudaTensor_free(state, weight);
 
   // Resize output
   if (batch == 0) {

  THCUNN_assertSameGPU(state, 5, input, gradOutput, weight,
                                 gradColumns, gradInput);
  THArgCheck(input->nDimension == 3 || input->nDimension == 4, 2, "3D or 4D (batch mode) tensor is expected");
  THArgCheck(weight->nDimension == 2, 4, "weight tensor must be 2D (nOutputPlane,nInputPlane*kH*kW)");
  THArgCheck(kW > 0 && kH > 0, 9, "kernel size should be greater than zero");
  THArgCheck(dW > 0 && dH > 0, 11, "stride should be greater than zero");

  // Params
  int nInputPlane = weight->size[1]/(kW*kH);
  int nOutputPlane = weight->size[0];

  int batch = 1;
  if (input->nDimension == 3) {

  // Free
  THCudaTensor_free(state, input_n);
  THCudaTensor_free(state, output_n);
  if (freeWeight)
    THCudaTensor_free(state, weight);

  // Resize output
  if (batch == 0) {
