     imsize_w = input->size[3];
   }
 
+  input = THCudaTensor_newContiguous(state, input);
+
   int n_threads = batchSize * imsize_h * imsize_w;
   LRNFillScale<<<GET_BLOCKS(n_threads), CUDA_NUM_THREADS>>>(
       n_threads, THCudaTensor_data(state, input), batchSize, nInputPlane, imsize_h, imsize_w, local_size,

      local_size, -beta, float(2. * alpha * beta / local_size),
      THCudaTensor_data(state, gradInput));

}

    imsize_w = input->size[3];
  }

  input = THCudaTensor_newContiguous(state, input);
  gradOutput = THCudaTensor_newContiguous(state, gradOutput);

  int n_threads = batchSize * imsize_h * imsize_w;
  LRNComputeDiff<<<GET_BLOCKS(n_threads), CUDA_NUM_THREADS>>>(
      n_threads, THCudaTensor_data(state, input), THCudaTensor_data(state, output),
