tracel-ai/burn · error
interpolate: unsupported mode {:?} / dtype {:?}
Error message
interpolate: unsupported mode {:?} / dtype {:?} What it means
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.
Source
Thrown at crates/burn-flex/src/ops/module.rs:603
(InterpolateMode::Bicubic, DType::F16) => {
interpolate::interpolate_bicubic_f16(x, output_size, options.align_corners)
}
(InterpolateMode::Bicubic, DType::BF16) => {
interpolate::interpolate_bicubic_bf16(x, output_size, options.align_corners)
}
(InterpolateMode::Lanczos3, DType::F32) => {
interpolate::interpolate_lanczos3_f32(x, output_size, options.align_corners)
}
(InterpolateMode::Lanczos3, DType::F64) => {
interpolate::interpolate_lanczos3_f64(x, output_size, options.align_corners)
}
(InterpolateMode::Lanczos3, DType::F16) => {
interpolate::interpolate_lanczos3_f16(x, output_size, options.align_corners)
}
(InterpolateMode::Lanczos3, DType::BF16) => {
interpolate::interpolate_lanczos3_bf16(x, output_size, options.align_corners)
}
(mode, dtype) => panic!(
"interpolate: unsupported mode {:?} / dtype {:?}",
mode, dtype
),
}
}
fn interpolate_backward(
x: FloatTensor<Flex>,
grad: FloatTensor<Flex>,
output_size: [usize; 2],
options: InterpolateOptions,
) -> FloatTensor<Flex> {
match (options.mode, x.dtype()) {
(InterpolateMode::Nearest, DType::F32) => {
interpolate::interpolate_nearest_backward_f32(
x,
grad,
output_size,View on GitHub (pinned to d16f7ba2ed)
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.
Example fix
// before let up = img_u8.interpolate(Bilinear, [256, 256]); // panics: (Bilinear, U8) // after let up = img_u8.cast(DType::F32).interpolate(Bilinear, [256, 256]);
Defensive patterns
Strategy: validation
Validate before calling
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); Type guard
fn is_float_dtype(d: burn::tensor::DType) -> bool {
matches!(d, burn::tensor::DType::F32 | burn::tensor::DType::F64 | burn::tensor::DType::F16 | burn::tensor::DType::BF16)
} Try / catch
// Convert u8/int images before interpolating:
let x = if is_float_dtype(x.dtype()) { x } else { x.cast(burn::tensor::DType::F32) };
let up = x.interpolate(burn::tensor::module::InterpolateMode::Bilinear, [256, 256]); Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- interpolate_backward: unsupported mode {:?} / dtype {:?}
- burn-flex does not support Bool(U32) storage (only Native an
- compare_int: unsupported dtype {:?}
- compare_int_elem: unsupported dtype {:?}
- any_float: unsupported dtype {:?}
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/90ef4f4a93faa763.
Report an issue: GitHub.