I ran into the same problem. The bug is very likely that input tensor is on cpu rather than gpu.
In my case, I define my output tensor using torch::zeros() rather than torch::zeros_like(), then my output tensor is on cpu and will not be modified by GPU functions.
In fact, an illegal memory access exception is thrown, but we can’t see it unless we explicitly synchronize after the kernel launch.
Add synchronizing code after kernel launching is very useful for my debugging
cudaError_t cudaerr = cudaDeviceSynchronize();
if (cudaerr != cudaSuccess)
    printf("kernel launch failed with error \"%s\".\n", cudaGetErrorString(cudaerr));

It makes the error message much more meaningful.