tracel-ai/burn · error

conv3d: unsupported dtype {:?}

Error message

conv3d: unsupported dtype {:?}

What it means

conv3d in the burn-flex module ops dispatches on the input dtype to conv3d_f32/f64/f16/bf16 implementations; any other dtype reaches the catch-all panic. Like the other conv ops, it only accepts float tensors, but because Flex is dynamically typed the mismatch is only caught at runtime.

Source

Thrown at crates/burn-flex/src/ops/module.rs:259

                )
            }
            dtype => panic!("deform_conv2d_backward: unsupported dtype {:?}", dtype),
        };
        DeformConv2dBackward::new(x_grad, offset_grad, weight_grad, mask_grad, bias_grad)
    }

    fn conv3d(
        x: FloatTensor<Flex>,
        weight: FloatTensor<Flex>,
        bias: Option<FloatTensor<Flex>>,
        options: ConvOptions<3>,
    ) -> FloatTensor<Flex> {
        match x.dtype() {
            DType::F32 => conv::conv3d_f32(x, weight, bias, &options),
            DType::F64 => conv::conv3d_f64(x, weight, bias, &options),
            DType::F16 => conv::conv3d_f16(x, weight, bias, &options),
            DType::BF16 => conv::conv3d_bf16(x, weight, bias, &options),
            dtype => panic!("conv3d: unsupported dtype {:?}", dtype),
        }
    }

    fn conv_transpose1d(
        x: FloatTensor<Flex>,
        weight: FloatTensor<Flex>,
        bias: Option<FloatTensor<Flex>>,
        options: ConvTransposeOptions<1>,
    ) -> FloatTensor<Flex> {
        match x.dtype() {
            DType::F32 => conv_transpose::conv_transpose1d_f32(x, weight, bias, &options),
            DType::F64 => conv_transpose::conv_transpose1d_f64(x, weight, bias, &options),
            DType::F16 => conv_transpose::conv_transpose1d_f16(x, weight, bias, &options),
            DType::BF16 => conv_transpose::conv_transpose1d_bf16(x, weight, bias, &options),
            dtype => panic!("conv_transpose1d: unsupported dtype {:?}", dtype),
        }
    }

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Cast the input to float before conv3d: x.cast(DType::F32) (normalize u8 voxel data while casting).
  2. Print/inspect .dtype() on the input and weights just before the call to find the offending tensor.
  3. Fix the data loader to emit f32 (or bf16) tensors instead of raw integer volumes.
  4. If another dtype is legitimately required, add a matching arm (e.g. conv3d_i16 with cast) in crates/burn-flex/src/ops/module.rs.

Example fix

// before
let out = conv3d(ct_voxels_i16, weight, bias, options);
// panic: conv3d: unsupported dtype I16

// after
let x = ct_voxels_i16.cast(burn::tensor::DType::F32);
let out = conv3d(x, weight, bias, options);
Defensive patterns

Strategy: validation

Validate before calling

if !matches!(x.dtype(), DType::F32 | DType::F64 | DType::F16 | DType::BF16) {
    x = x.cast(DType::F32);
}
let out = conv3d(x, weight, bias, options);

Type guard

fn is_float(t: &Tensor<Flex>) -> bool {
    matches!(t.dtype(), DType::F32 | DType::F64 | DType::F16 | DType::BF16)
}

Try / catch

let out = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| conv3d(x.clone(), w.clone(), b.clone(), opts.clone())))
    .unwrap_or_else(|_| conv3d(x.cast(DType::F32), w, b, opts));

Prevention

When it happens

Trigger: Calling conv3d (or a Conv3d module forward) with a non-float input tensor: I8/I16/I32/I64/U8/Bool/etc.; passing volumetric video/medical data loaded as u8/int16 arrays without conversion.

Common situations: 3D medical imaging (CT/MRI) pipelines loading DICOM voxels as int16 and feeding them to a conv3d model; video models consuming uint8 frame volumes; quantized 3D networks missing a dequant step.

Related errors


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