Converting Old (pre-PyTorch1.0) C++/CUDA 8 extensions to PyTorch 1.0 C++/CUDA 9 extension

I want to convert the ShiftResNet PyTorch C++ layer (https://github.com/peterhj/shiftnet_cuda_v2) from its PyTorch 0.3 C++ form to the current PyTorch 1.0 form. I want to know what are the API changes that I should be wary about.
For instance in the code

  1. the author makes use of <THC/THC.h> header but in the tutorial Custom C++ and CUDA extension <ATen/ATen.h> has been used. How should I make the changes?

It would be great if I could get a migration guide similar to the one PyTorch developers wrote for migrating to PyTorch 0.3
P.S I am an old user of PyTorch Python API but I am starting with C++ part of this framework.

1 Like

Any updates on this?

Can you please write the error you’re getting?

I’ve migrated from PyTorch 0.4 to 1.0 without any problem, but my custom functions are pretty basic. The changes I made in my c++ code were:

  1. Using <torch/extension.h> instead of <torch/torch.h>.
  2. AT_ASSERT now gets one parameter instead of two.

the problem I face is that I am not sure what to do with THC/THC.h and the THCudaTensors it exposes. what are its PyTorch 1.0 counterparts?

example : https://github.com/peterhj/shiftnet_cuda_v2/blob/master/src/shiftnet_cuda.c

It seems like THC/THC.h is still there and you can still include it in your project.
Looking at “pytorch/aten/src/THC/generic/THCTensor.h”, it looks like all THCudaTensor_ should be changed to THCTensor_, but that’s just a guess.
I personally have only used at::Tensor from ATen throughout my code so I’m not sure I can help you in case changing THCudaTensor_ to THCTensor_ did not help, but it would be helpful if you could try to build your code and reply with the error messages you’re getting.