Is it the first or second call to THCudaTensor_newContiguous that crashes? can you debug it?
input = THCudaTensor_newContiguous(state, input);

    THCudaTensor_resize4d(state, output, batchSize, nInputPlane, outputHeight, outputWidth);
    output = THCudaTensor_newContiguous(state, output);