Torchscript support for Deformable Convolution v2

I heard PyTorch supports Deformable Convolution out of the box since 1.4 release, I just can not say by looking at code if it is version 1 or version 2 (
My question is does the support for Deformable Convolution mean I can jit it to torchscript?
And if I add the DCv2 layer to PyTroch from the aforementioned repository can I convert it to torchscript?

Thank you.

It looks like the custom kernels in the repo linked are bound using pybind ( So they will not work with TorchScript as is. However, it is possible to register the operator with TorchScript following, which would work with TorchScript.

1 Like

Thanks a lot!
I will try it out.

Any progress yet ? regarding dcnv2

It works fine.

Which libtorch version did u use to compile dcn_v2_cuda_forward_v2? I got error when compiling

candidate: constexpr torch::jit::RegisterOperators::RegisterOperators(torch::jit::RegisterOperators&&)
/usr/lib/libtorch_abi11_14/include/torch/csrc/jit/custom_operator.h:16:18: note:   candidate expects 1 argument, 2 provided
CMakeFiles/dcn_v2_cuda_forward_v2.dir/build.make:1509: recipe for target 'CMakeFiles/dcn_v2_cuda_forward_v2.dir/vision.cpp.o' faile

In newer versions operator registration api changed, you should type like this

static auto registry = torch::RegisterOperators(“my_ops::warp_perspective”, &warp_perspective);

Change your first line.

Now it works fine (pythorch 1.4), thanks, btw do you try using pytorch version 1.5 I got this error:
Could not export Python function call ‘_DCNv2’. Remove calls to Python functions before export

I try to trace model for CenterTrack model, but I got this error

TracerWarning: Output nr 1. of the traced function does not match the corresponding output of the Python function. Detailed error:
Not within tolerance rtol=1e-05 atol=1e-05 at input[26, 79, 149] (-1.9391770362854004 vs. -1.9395387172698975) and 669 other locations (0.00%)
check_tolerance, _force_outplace, True, _module_class)