Converting torch.utils.ffi.create_extension to CppExtension

I am not knowledgeable about building extensions. I see that torch.utils.ffi has been deprecated. I am wondering how to convert this code: https://github.com/yhenon/pytorch-retinanet/blob/master/lib/nms/build.py which uses ffi to cpp extension.

Any directions would be helpful

3 Likes

By the time you have converted the .c files in src to C++ and ATen, it should be just a matter of replacing the entire file by one of the examples for torch.utils.cpp_extension.

Best regards

Thomas

2 Likes

Thank you for replying. I am sorry, but I am not following your suggestion.

The src folder has nms_cuda.c and nms_cuda.h. To my understanding I would need to build the extension from .c sources. Do you mean I have re-write the code in .c to .cpp and Aten? Is this an automatic process with some command?

I am sorry if I might be asking something very trivial.

I think that yes, to use a cpp extension, you need to move to .cpp and ATen. It’s a bit of work, but it certainly is a nicer interface once you get used to it (I think you can cut the size of the code by quite a bit and just keep a couple of files or three.)

Not that I know of.

Best regards

Thomas

@TheShadow29 any progress? I have also the same issue with pytorch 1.0.0 and I’d want to adapt it too, but not sure about the solution…

Bests,

I simply used pytorch 0.4.1. You could use nms, roipool and roialign from here for pytorch 1.0.0 though: https://github.com/facebookresearch/maskrcnn-benchmark/tree/master/maskrcnn_benchmark/csrc

1 Like

now torch.utils.ffi is deprecated in pytorch 1.0;

and you can see new API in https://pytorch.org/docs/0.4.1/cpp_extension.html?highlight=torch%20utils%20cpp_extension#torch-utils-cpp-extension