tracel-ai/burn · error
float_select: unsupported dtype {:?}
Error message
float_select: unsupported dtype {:?} What it means
Dtype-dispatch exhaustiveness panic: `float_select` supports only float dtypes and panics otherwise; reaching it means a non-float tensor was dispatched into the float select (indexing) op in the Flex backend.
Source
Thrown at crates/burn-flex/src/ops/float.rs:385
DType::F32 => crate::ops::gather_scatter::gather_nd::<f32>(data, indices),
DType::F64 => crate::ops::gather_scatter::gather_nd::<f64>(data, indices),
DType::F16 => crate::ops::gather_scatter::gather_nd::<f16>(data, indices),
DType::BF16 => crate::ops::gather_scatter::gather_nd::<bf16>(data, indices),
_ => panic!("float_gather_nd: unsupported dtype {:?}", data.dtype()),
}
}
fn float_select(
tensor: FloatTensor<Flex>,
dim: usize,
indices: IntTensor<Flex>,
) -> FloatTensor<Flex> {
match tensor.dtype() {
DType::F32 => crate::ops::gather_scatter::select::<f32>(tensor, dim, indices),
DType::F64 => crate::ops::gather_scatter::select::<f64>(tensor, dim, indices),
DType::F16 => crate::ops::gather_scatter::select::<f16>(tensor, dim, indices),
DType::BF16 => crate::ops::gather_scatter::select::<bf16>(tensor, dim, indices),
_ => panic!("float_select: unsupported dtype {:?}", tensor.dtype()),
}
}
fn float_select_assign(
tensor: FloatTensor<Flex>,
dim: usize,
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)
}View on GitHub (pinned to d16f7ba2ed)
Solutions
- Confirm tensor.dtype() is a float type before select
- Use the corresponding int/bool select op for non-float tensors
- Cast the tensor to a float dtype before selecting
- Add a match arm for any newly added DType
Example fix
// before: labels is I64 -> panic let picked = labels.select(dim, indices); // after let picked = labels.cast(FloatDType::F32).select(dim, indices);
Defensive patterns
Strategy: type-guard
Validate before calling
fn ensure_float_for_select(dt: DType) -> Result<(), String> {
match dt {
DType::F32 | DType::F64 | DType::F16 | DType::BF16 => Ok(()),
other => Err(format!("float_select 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
- Check dtype before select/slice-gather ops
- Route integer label tensors through int select ops or cast them first
- Avoid silent dtype conversions between pipeline stages; log dtypes at stage boundaries
- Update all dtype match arms when adding new variants
When it happens
Trigger: Calling float_select (Tensor::select along a dim) where the tensor's dtype is Int or Bool rather than a float type.
Common situations: Selecting rows/slices from an int tensor (e.g. label tensor) via the float op; dtype changes upstream; new DType variant missing from the dispatch table.
Related errors
- Should be float, got int
- Should be float, got bool
- Should be float, got quantized
- Should be float, got autodiff
- float_into_int: unsupported source dtype {:?}
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/e4be166cef84343f.
Report an issue: GitHub.