PyTorch 1.x gets its deformable convolution transplant
An unofficial port of the official Deformable-ConvNets DCNv2 operators into PyTorch 1.x with CPU and CUDA support.

What it does Implements Deformable Convolutional Networks v2 as custom PyTorch 1.x operators, adapted from the official Deformable-ConvNets repository. The project compiles native extensions via a build script and provides test scripts to verify gradients on both CPU and GPU.
The interesting bit The author debugged offset gradient failures until all checks passed in double precision, then openly documented a lingering backward reentrancy issue with numerical error small enough that the README literally asks whether it is even a serious problem.
Key highlights
- Adapted from the official
msracver/Deformable-ConvNetsDCNv2 operators - Master branch targets PyTorch 1.x; legacy
pytorch_0.4branch available - Includes separate CPU and CUDA test scripts for gradient verification
- All gradient checks pass with double precision
- Build process handled by a single
make.shscript
Caveats
- Backward pass is not reentrant; the README notes a
RuntimeErrorwith drift under1e-7for float and1e-15for double - Documentation is limited to build instructions and known issues
Verdict Useful if you need DCNv2 layers in a PyTorch 1.x pipeline and can tolerate an unofficial adaptation with a non-reentrant backward pass. Skip it if you require an officially maintained implementation.
Frequently asked
- What is CharlesShang/DCNv2?
- An unofficial port of the official Deformable-ConvNets DCNv2 operators into PyTorch 1.x with CPU and CUDA support.
- Is DCNv2 open source?
- Yes — CharlesShang/DCNv2 is open source, released under the BSD-3-Clause license.
- What language is DCNv2 written in?
- CharlesShang/DCNv2 is primarily written in C++.
- How popular is DCNv2?
- CharlesShang/DCNv2 has 1.3k stars on GitHub.
- Where can I find DCNv2?
- CharlesShang/DCNv2 is on GitHub at https://github.com/CharlesShang/DCNv2.