{"record":{"id":"31fdcd634c7863f3","repo":"tracel-ai/burn","slug":"nearest-exact-interpolation-backward-is-not-suppor","errorCode":null,"errorMessage":"nearest exact interpolation backward is not supported for ndarray backend","messagePattern":"nearest exact interpolation backward is not supported for ndarray backend","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-ndarray/src/ops/module.rs","lineNumber":353,"sourceCode":"                    align_corners\n                )\n                .into())\n            }\n        }\n    }\n\n    fn interpolate_backward(\n        x: FloatTensor<Self>,\n        grad: FloatTensor<Self>,\n        output_size: [usize; 2],\n        options: InterpolateOptions,\n    ) -> FloatTensor<Self> {\n        match options.mode {\n            InterpolateMode::Nearest => module_op!(inp(x, grad), opt(), E, |x, grad| {\n                nearest_interpolate_backward::<E>(x, grad, output_size).into()\n            }),\n            InterpolateMode::NearestExact => {\n                panic!(\"nearest exact interpolation backward is not supported for ndarray backend\")\n            }\n            InterpolateMode::Bilinear => {\n                panic!(\"bilinear interpolation backward is not supported for ndarray backend\")\n            }\n            InterpolateMode::Bicubic => {\n                panic!(\"bicubic interpolation backward is not supported for ndarray backend\")\n            }\n            InterpolateMode::Lanczos3 => {\n                panic!(\"lanczos3 interpolation backward is not supported for ndarray backend\")\n            }\n        }\n    }\n\n    fn conv3d(\n        x: FloatTensor<Self>,\n        weight: FloatTensor<Self>,\n        bias: Option<FloatTensor<Self>>,\n        options: ConvOptions<3>,","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-ndarray/src/ops/module.rs#L335-L371","documentation":"interpolate_backward on the ndarray backend only implements the Nearest mode's backward pass; NearestExact, Bilinear, and Bicubic have no backward implementation and panic. Training (backward) with these upsample modes on ndarray is unsupported.","triggerScenarios":"Backward pass through an interpolate/upsample layer with InterpolateMode::NearestExact, Bilinear, or Bicubic on the NdArray backend (e.g. in a U-Net-style autoencoder during training).","commonSituations":"Training segmentation/super-resolution models with bilinear upsampling on ndarray; models exported with nearest-exact resize then fine-tuned.","solutions":["Use InterpolateMode::Nearest for upsampling during training on ndarray (only mode with backward support).","Train with a backend that implements the backward pass (burn-tch, burn-cubecl) for bilinear/bicubic.","Replace learned upsampling with unexpand/upsample via ConvTranspose2d (which has ndarray backward support).","Detach at the upsample layer (inference-only upsample) if gradients through it are acceptable to drop."],"exampleFix":"// before (training, ndarray backend)\nlet up = x.interpolate([h*2, w*2], InterpolateOptions::new(InterpolateMode::Bilinear));\n// backward panics\n// after\nlet up = x.interpolate([h*2, w*2], InterpolateOptions::new(InterpolateMode::Nearest));\n// or switch to BurnTch backend for bilinear training","handlingStrategy":"fallback","validationCode":"fn has_interpolate_backward(mode: &InterpolateMode) -> bool {\n    matches!(mode, InterpolateMode::Nearest) // ndarray backward support\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use Nearest upsampling when training on ndarray.","Use ConvTranspose2d (learned upsampling) instead of interpolate for trainable models.","Train bilinear/bicubic pipelines on tch/cubecl backends.","Consult the backend ops support table before choosing upsample modes for training."],"tags":["rust","burn-ndarray","interpolate","autodiff","unsupported"],"backgroundTag":"unsupported-operation","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"}