tracel-ai/burn · error

lanczos3 interpolation backward is not supported for ndarray

Error message

lanczos3 interpolation backward is not supported for ndarray backend

What it means

Unimplemented-feature panic: the ndarray backend's `interpolate_backward` supports only the Nearest mode's gradient; NearestExact, Bilinear, and Lanczos3 modes have no backward implementation on CPU/ndarray, so requesting upsampling backward with those modes panics. The failing input is the InterpolateOptions mode on the backward pass.

Source

Thrown at crates/burn-ndarray/src/ops/module.rs:362

        grad: FloatTensor<Self>,
        output_size: [usize; 2],
        options: InterpolateOptions,
    ) -> FloatTensor<Self> {
        match options.mode {
            InterpolateMode::Nearest => module_op!(inp(x, grad), opt(), E, |x, grad| {
                nearest_interpolate_backward::<E>(x, grad, output_size).into()
            }),
            InterpolateMode::NearestExact => {
                panic!("nearest exact interpolation backward is not supported for ndarray backend")
            }
            InterpolateMode::Bilinear => {
                panic!("bilinear interpolation backward is not supported for ndarray backend")
            }
            InterpolateMode::Bicubic => {
                panic!("bicubic interpolation backward is not supported for ndarray backend")
            }
            InterpolateMode::Lanczos3 => {
                panic!("lanczos3 interpolation backward is not supported for ndarray backend")
            }
        }
    }

    fn conv3d(
        x: FloatTensor<Self>,
        weight: FloatTensor<Self>,
        bias: Option<FloatTensor<Self>>,
        options: ConvOptions<3>,
    ) -> FloatTensor<Self> {
        module_op!(inp(x, weight), opt(bias), E, |x, weight, bias| conv3d::<E>(
            x, weight, bias, options
        )
        .into())
    }

    fn conv_transpose3d(
        x: FloatTensor<Self>,

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Use InterpolateMode::Nearest for training on ndarray; keep Lanczos3 for inference-only preprocessing
  2. Move the Lanczos3 resize outside the model (preprocess data before the graph)
  3. Use a backend that supports Lanczos3 backward, if available
Defensive patterns

Strategy: validation

Validate before calling

assert!(matches!(mode, InterpolateMode::Nearest), "ndarray supports only nearest interpolate backward");

Type guard

fn is_ndarray_backward_safe(mode: &InterpolateMode) -> bool {
    matches!(mode, InterpolateMode::Nearest)
}

Prevention

When it happens

Trigger: Backpropagating through an interpolate node using InterpolateMode::Lanczos3 with the burn-ndarray backend.

Common situations: Training pipelines that use Lanczos3 resampling (high-quality image resize) inside the autodiff graph on CPU.

Related errors


AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05). Data as JSON: /api/errors/2ef0e9b6ee8efa45. Report an issue: GitHub.