{"record":{"id":"4f80e587b5aa6366","repo":"tracel-ai/burn","slug":"torch-bindings-don-t-support-deform-conv2d","errorCode":null,"errorMessage":"Torch bindings don't support deform_conv2d","messagePattern":"Torch bindings don't support deform_conv2d","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/burn-tch/src/ops/module.rs","lineNumber":131,"sourceCode":"            bias.map(|t| t.tensor),\n            options.stride.map(|i| i as i64),\n            options.padding_begin().map(|i| i as i64),\n            options.dilation.map(|i| i as i64),\n            options.groups as i64,\n        );\n\n        TchTensor::new(tensor)\n    }\n\n    fn deform_conv2d(\n        _x: TchTensor,\n        _offset: TchTensor,\n        _weight: TchTensor,\n        _mask: Option<TchTensor>,\n        _bias: Option<TchTensor>,\n        _options: DeformConvOptions<2>,\n    ) -> TchTensor {\n        unimplemented!(\"Torch bindings don't support deform_conv2d\");\n    }\n\n    fn deform_conv2d_backward(\n        _x: TchTensor,\n        _offset: TchTensor,\n        _weight: TchTensor,\n        _mask: Option<TchTensor>,\n        _bias: Option<TchTensor>,\n        _out_grad: TchTensor,\n        _options: DeformConvOptions<2>,\n    ) -> DeformConv2dBackward<Self> {\n        unimplemented!(\"Torch bindings don't support deform_conv2d\");\n    }\n\n    fn conv_transpose1d(\n        x: TchTensor,\n        weight: TchTensor,\n        bias: Option<TchTensor>,","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-tch/src/ops/module.rs#L113-L149","documentation":"The LibTorch backend in burn-tch does not implement deformable convolution: deform_conv2d is a hard stub that panics with unimplemented!(), because the underlying tch (C++ LibTorch) bindings do not expose deform_conv2d. Calling it on a LibTorch tensor always panics regardless of inputs.","triggerScenarios":"Calling Tensor::deform_conv2d (or a model layer that uses it, e.g. DCN/DCNv2-style modules) on a tensor using the LibTorch (tch) backend.","commonSituations":"Running deformable-convolution vision models (DCN for detection/segmentation) on the burn-tch backend; switching a model from burn-candle/wgpu (where it may exist) to LibTorch; trying to leverage torch through burn for DCN ops that require custom extensions like torchvision's deform_conv2d.","solutions":["Use a backend that implements deform_conv2d (e.g. burn-cubecl/wgpu or NdArray as available) for this model","Replace deform_conv2d with a standard conv2d (losing deformability) or implement the op manually from primitive ops","Implement deform_conv2d via a custom op/torch extension (torchvision) and register it","File/vote on a burn issue to add deform_conv2d support to the tch backend"],"exampleFix":"// before\nlet out = x.deform_conv2d(offset, weight, mask, bias, options); // panics on LibTorch\n\n// after\n// run on a backend with support:\nlet out = x_cuda.deform_conv2d(offset, weight, mask, bias, options); // burn-cubecl backend","handlingStrategy":"fallback","validationCode":"// compile-time/backend check before building the model\nfn supports_deform_conv<B: Backend>() -> bool {\n    // LibTorch (tch) does not implement deform_conv2d\n    !(std::any::type_name::<B>().contains(\"LibTorch\") || std::any::type_name::<B>().contains(\"Tch\"))\n}","typeGuard":null,"tryCatchPattern":"let out = std::panic::catch_unwind(|| {\n    x.clone().deform_conv2d(offset.clone(), weight.clone(), mask.clone(), bias.clone(), options.clone())\n}).unwrap_or_else(|_| x.deform_conv2d_fallback(offset, weight, mask, bias, options));","preventionTips":["Avoid deform_conv2d models on the burn-tch backend; use wgpu/cubecl or another backend","Replace DCN layers with standard conv2d when porting to LibTorch","Check backend op support matrices before choosing a backend for exotic ops"],"tags":["rust","burn","libtorch","convolution","unimplemented-op"],"backgroundTag":"op-not-implemented-for-backend","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}