tracel-ai/burn · error

float_select_assign: unsupported dtype {:?}

Error message

float_select_assign: unsupported dtype {:?}

What it means

float_select_assign's IndexingUpdateOp::Set branch dispatches select_assign per dtype and only handles F32/F64/F16/BF16. A non-float tensor in this update path triggers the catch-all panic. This mirrors the float_scatter guards for the select_assign op.

Source

Thrown at crates/burn-flex/src/ops/float.rs:410

        indices: IntTensor<Flex>,
        value: FloatTensor<Flex>,
        update: burn_backend::tensor::IndexingUpdateOp,
    ) -> FloatTensor<Flex> {
        match update {
            burn_backend::tensor::IndexingUpdateOp::Assign => match tensor.dtype() {
                DType::F32 => {
                    crate::ops::gather_scatter::select_assign::<f32>(tensor, dim, indices, value)
                }
                DType::F64 => {
                    crate::ops::gather_scatter::select_assign::<f64>(tensor, dim, indices, value)
                }
                DType::F16 => {
                    crate::ops::gather_scatter::select_assign::<f16>(tensor, dim, indices, value)
                }
                DType::BF16 => {
                    crate::ops::gather_scatter::select_assign::<bf16>(tensor, dim, indices, value)
                }
                _ => panic!(
                    "float_select_assign: unsupported dtype {:?}",
                    tensor.dtype()
                ),
            },
            burn_backend::tensor::IndexingUpdateOp::Add => match tensor.dtype() {
                DType::F32 => {
                    crate::ops::gather_scatter::select_add::<f32>(tensor, dim, indices, value)
                }
                DType::F64 => {
                    crate::ops::gather_scatter::select_add::<f64>(tensor, dim, indices, value)
                }
                DType::F16 => {
                    crate::ops::gather_scatter::select_add::<f16>(tensor, dim, indices, value)
                }
                DType::BF16 => {
                    crate::ops::gather_scatter::select_add::<bf16>(tensor, dim, indices, value)
                }
                _ => panic!(

View on GitHub (pinned to d16f7ba2ed)

Solutions

  1. Verify the tensor dtype is F32/F64/F16/BF16 before select_assign
  2. Use the int/bool select_assign op for non-float tensors
  3. Cast the tensor to a float dtype before assignment
  4. Add the missing dispatch arm for a new DType

Example fix

// before: t is I32 -> panic on Set update
let t = t.select_assign(dim, indices, value, IndexingUpdateOp::Set);
// after
let t = t.cast(FloatDType::F32).select_assign(dim, indices, value, IndexingUpdateOp::Set);
Defensive patterns

Strategy: type-guard

Validate before calling

fn ensure_float_for_select_assign(dt: DType) -> Result<(), String> {
    match dt {
        DType::F32 | DType::F64 | DType::F16 | DType::BF16 => Ok(()),
        other => Err(format!("float_select_assign requires a float dtype, got {:?}", other)),
    }
}

Type guard

fn is_float_dtype(dt: DType) -> bool {
    matches!(dt, DType::F32 | DType::F64 | DType::F16 | DType::BF16)
}

Prevention

When it happens

Trigger: Calling float_select_assign (Tensor::select_assign with Set semantics) on a tensor whose dtype is not a float type.

Common situations: Assigning selected slices into an int tensor via the float path; dtype drift from upstream ops or mixed-precision configs; a new DType variant missing from the match.

Related errors


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