tracel-ai/burn · error
nearest exact interpolation is not supported for ndarray bac
Error message
nearest exact interpolation is not supported for ndarray backend
What it means
The ndarray backend implements nearest, bilinear, and bicubic upsampling for interpolate(), but not the NearestExact mode (which matches ONNX/opencv nearest-exact semantics). Selecting that mode hits an explicit unimplemented panic.
Source
Thrown at crates/burn-ndarray/src/ops/module.rs:310
adaptive_avg_pool3d_backward::<E>(x, grad).into()
})
}
fn interpolate(
x: FloatTensor<Self>,
output_size: [usize; 2],
options: InterpolateOptions,
) -> FloatTensor<Self> {
match options.mode {
InterpolateMode::Nearest => {
module_op!(inp(x), opt(), E, |x| nearest_interpolate::<E>(
x,
output_size
)
.into())
}
InterpolateMode::NearestExact => {
panic!("nearest exact interpolation is not supported for ndarray backend")
}
InterpolateMode::Bilinear => {
let align_corners = options.align_corners;
module_op!(inp(x), opt(), E, |x| bilinear_interpolate::<E>(
x,
output_size,
align_corners
)
.into())
}
InterpolateMode::Bicubic => {
let align_corners = options.align_corners;
module_op!(inp(x), opt(), E, |x| bicubic_interpolate::<E>(
x,
output_size,
align_corners
)
.into())View on GitHub (pinned to d16f7ba2ed)
Solutions
- Switch to InterpolateMode::Nearest instead of NearestExact if exact half-pixel semantics are not critical.
- Switch backends for this op or the whole model (e.g. burn-tch/cubecl) which supports NearestExact.
- Implement nearest-exact manually (compute integer indices and gather) if semantics must match exactly.
- Check model export settings to emit plain nearest instead of nearest-exact.
Example fix
// before let up = x.interpolate([h*2, w*2], InterpolateOptions::new(InterpolateMode::NearestExact)); // panic // after let up = x.interpolate([h*2, w*2], InterpolateOptions::new(InterpolateMode::Nearest));
Defensive patterns
Strategy: fallback
Validate before calling
fn supported_interpolate_mode(mode: &InterpolateMode) -> Option<InterpolateMode> {
match mode {
InterpolateMode::NearestExact => None, // unsupported on ndarray
m => Some(m.clone()),
}
} Prevention
- Map NearestExact -> Nearest when targeting ndarray.
- Check backend feature matrices before importing ONNX resize ops.
- Prefer Nearest or Bilinear for portability across backends.
When it happens
Trigger: Calling tensor.interpolate(shape, InterpolateOptions::new(InterpolateMode::NearestExact)) on an NdArray backend tensor; loading/exported models (e.g. from ONNX) configured with nearest-exact upsampling.
Common situations: Importing models from ONNX where resize used nearest-exact; copying interpolate options from another backend without checking ndarray support.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- nearest exact interpolation backward is not supported for nd
- interpolate: unsupported mode {:?} / dtype {:?}
- interpolate_backward: unsupported mode {:?} / dtype {:?}
- Unsupported dtype: {other:?}
- Matrix multiplication requires an array with at least 2 dime
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/41b0dd4f9454582f.
Report an issue: GitHub.