Convert C++/CUDA extension from pytorch 0.4.1 to pytorch 1.x.x

I have a file C++/CUDA written in torch 0.4.1 like this:


extern THCState *state;

__global__ void do_something(float *x, float *y) {
extern "C" void warping(THCudaTensor *tensor_x, THCudaTensor *tensor_x) {
    int a = 16;
    int step_h = THCudaTensor_size(state, tensor_x, 3);
    int step_w = THCudaTensor_size(state, tensor_x, 4);
    const dim3 block = dim3(1, a, a);
    const dim3 grid = dim3(1, step_h, step_w);
    float *x = THCudaTensor_data(state, tensor_x);
    float *y = THCudaTensor_data(state, tensor_y);

    cudaStream_t stream = THCState_getCurrentStream(state);
    do_something<<<grid, block, 0, stream>>>(x, y);


Now I want to use a higher pytorch version 1.x.x, so I have to change this file. I also read this tutorial from the official documentation here. I still got stuck when converting the code above.
Any suggestions would be appreciated.

Khang Truong.