{"record":{"id":"90ef4f4a93faa763","repo":"tracel-ai/burn","slug":"interpolate-unsupported-mode-dtype","errorCode":null,"errorMessage":"interpolate: unsupported mode {:?} / dtype {:?}","messagePattern":"interpolate: unsupported mode (.+?) / dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/module.rs","lineNumber":603,"sourceCode":"            (InterpolateMode::Bicubic, DType::F16) => {\n                interpolate::interpolate_bicubic_f16(x, output_size, options.align_corners)\n            }\n            (InterpolateMode::Bicubic, DType::BF16) => {\n                interpolate::interpolate_bicubic_bf16(x, output_size, options.align_corners)\n            }\n            (InterpolateMode::Lanczos3, DType::F32) => {\n                interpolate::interpolate_lanczos3_f32(x, output_size, options.align_corners)\n            }\n            (InterpolateMode::Lanczos3, DType::F64) => {\n                interpolate::interpolate_lanczos3_f64(x, output_size, options.align_corners)\n            }\n            (InterpolateMode::Lanczos3, DType::F16) => {\n                interpolate::interpolate_lanczos3_f16(x, output_size, options.align_corners)\n            }\n            (InterpolateMode::Lanczos3, DType::BF16) => {\n                interpolate::interpolate_lanczos3_bf16(x, output_size, options.align_corners)\n            }\n            (mode, dtype) => panic!(\n                \"interpolate: unsupported mode {:?} / dtype {:?}\",\n                mode, dtype\n            ),\n        }\n    }\n\n    fn interpolate_backward(\n        x: FloatTensor<Flex>,\n        grad: FloatTensor<Flex>,\n        output_size: [usize; 2],\n        options: InterpolateOptions,\n    ) -> FloatTensor<Flex> {\n        match (options.mode, x.dtype()) {\n            (InterpolateMode::Nearest, DType::F32) => {\n                interpolate::interpolate_nearest_backward_f32(\n                    x,\n                    grad,\n                    output_size,","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/module.rs#L585-L621","documentation":"The Flex backend's interpolate op dispatches on the (InterpolateMode, dtype) pair. Every combination of Nearest/Bilinear/Bicubic/Lanczos3 with F32/F64/F16/BF16 is implemented; any other pair — meaning a non-float dtype, since all four InterpolateMode variants are covered — hits the catch-all arm and panics naming both the mode and dtype.","triggerScenarios":"Calling Tensor::interpolate (or Upsample layers) on the Flex backend with an input tensor whose dtype is not F32/F64/F16/BF16, regardless of mode; the message reports e.g. (Bilinear, U8) or (Bilinear, I32).","commonSituations":"Integer image tensors (u8 pixel data) passed to upsample without conversion; forgetting .float() after loading images; dtype drift from a quantized pipeline or checkpoint load.","solutions":["Cast the input to a supported float dtype before interpolating: x.cast(DType::F32).","Check the reported dtype in the panic message and fix the upstream tensor producer.","Add match arms for the missing (mode, dtype) combination calling interpolate::<mode>_<dtype> in crates/burn-flex/src/ops/module.rs."],"exampleFix":"// before\nlet up = img_u8.interpolate(Bilinear, [256, 256]); // panics: (Bilinear, U8)\n// after\nlet up = img_u8.cast(DType::F32).interpolate(Bilinear, [256, 256]);","handlingStrategy":"validation","validationCode":"assert!(matches!(x.dtype(), burn::tensor::DType::F32 | burn::tensor::DType::F64 | burn::tensor::DType::F16 | burn::tensor::DType::BF16), \"interpolate needs a float tensor, got {:?} (mode {:?})\", x.dtype(), options.mode);","typeGuard":"fn is_float_dtype(d: burn::tensor::DType) -> bool {\n    matches!(d, burn::tensor::DType::F32 | burn::tensor::DType::F64 | burn::tensor::DType::F16 | burn::tensor::DType::BF16)\n}","tryCatchPattern":"// Convert u8/int images before interpolating:\nlet x = if is_float_dtype(x.dtype()) { x } else { x.cast(burn::tensor::DType::F32) };\nlet up = x.interpolate(burn::tensor::module::InterpolateMode::Bilinear, [256, 256]);","preventionTips":["Always normalize input images to a float dtype (e.g. F32) before upsample/interpolate.","Validate the (mode, dtype) pair in tests for each InterpolateMode you use.","Check the panic message's reported dtype to locate the pipeline stage producing wrong tensors."],"tags":["rust","dtype","panic","interpolate","burn"],"backgroundTag":"unsupported-dtype","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"}