tracel-ai/burn · error
int_gather: unsupported dtype {:?}
Error message
int_gather: unsupported dtype {:?} What it means
burn-flex's int_gather dispatches on the integer dtype and only implements gather for the standard signed/unsigned int widths (i64, i32, i16, i8, u64, u32, u16, u8). If the tensor's dtype falls outside that set (e.g. a bool or float tensor routed into an int-only op), the catch-all match arm panics. It is an intentional fail-fast guard against silently misinterpreting memory as a different element type.
Source
Thrown at crates/burn-flex/src/ops/int.rs:125
/// U8/U16/U32/U64 unsigned). The `indices` tensor may be any of those
/// widths too - it's normalised to `isize` by the shared `read_indices`
/// helper in `ops::gather_scatter` before the kernel runs, so callers are
/// not required to pre-convert to I64.
fn int_gather(
dim: usize,
tensor: IntTensor<Flex>,
indices: IntTensor<Flex>,
) -> IntTensor<Flex> {
match tensor.dtype() {
DType::I64 => crate::ops::gather_scatter::gather::<i64>(tensor, dim, indices),
DType::I32 => crate::ops::gather_scatter::gather::<i32>(tensor, dim, indices),
DType::I16 => crate::ops::gather_scatter::gather::<i16>(tensor, dim, indices),
DType::I8 => crate::ops::gather_scatter::gather::<i8>(tensor, dim, indices),
DType::U64 => crate::ops::gather_scatter::gather::<u64>(tensor, dim, indices),
DType::U32 => crate::ops::gather_scatter::gather::<u32>(tensor, dim, indices),
DType::U16 => crate::ops::gather_scatter::gather::<u16>(tensor, dim, indices),
DType::U8 => crate::ops::gather_scatter::gather::<u8>(tensor, dim, indices),
dt => panic!("int_gather: unsupported dtype {:?}", dt),
}
}
fn int_scatter(
dim: usize,
tensor: IntTensor<Flex>,
indices: IntTensor<Flex>,
value: IntTensor<Flex>,
update: burn_backend::tensor::IndexingUpdateOp,
) -> IntTensor<Flex> {
match update {
burn_backend::tensor::IndexingUpdateOp::Assign => {
debug_assert_eq!(tensor.dtype(), value.dtype(), "int_scatter: dtype mismatch");
match tensor.dtype() {
DType::I64 => crate::ops::gather_scatter::scatter_assign::<i64>(
tensor, dim, indices, value,
),
DType::I32 => crate::ops::gather_scatter::scatter_assign::<i32>(View on GitHub (pinned to d16f7ba2ed)
Solutions
- Check the tensor's dtype with tensor.dtype() before calling and convert to a supported int width with .cast(DType::I64) (or the appropriate width)
- Fix upstream logic so bool/float tensors are explicitly cast to an int dtype before indexing ops
- If a newly added DType variant triggers this, add the missing match arm dispatching to crate::ops::gather_scatter::gather::<T>
- File/report an issue against burn-flex if a legitimately supported dtype is rejected
Example fix
// before let picked = tensor.gather(dim, indices); // tensor is DType::Bool // after let picked = tensor.cast(DType::I64).gather(dim, indices);
Defensive patterns
Strategy: validation
Validate before calling
fn assert_supported_int_dtype(t: &burn::tensor::Tensor<burn::backend::Flex, 2>) {
match t.dtype() {
burn::tensor::DType::I64 | burn::tensor::DType::I32
| burn::tensor::DType::I16 | burn::tensor::DType::I8
| burn::tensor::DType::U64 | burn::tensor::DType::U32
| burn::tensor::DType::U16 | burn::tensor::DType::U8 => {}
other => panic!("gather needs an int dtype, got {:?}", other),
}
} Type guard
fn is_supported_int_dtype(dt: burn::tensor::DType) -> bool {
matches!(
dt,
burn::tensor::DType::I64 | burn::tensor::DType::I32
| burn::tensor::DType::I16 | burn::tensor::DType::I8
| burn::tensor::DType::U64 | burn::tensor::DType::U32
| burn::tensor::DType::U16 | burn::tensor::DType::U8
)
} Prevention
- Cast to an explicit int dtype (e.g. DType::I64) right after producing index-ish tensors
- Never feed bool tensors from comparison ops directly into gather/scatter ops
- Check tensor.dtype() in debug builds before indexing ops
- After burn version upgrades, review new DType variants against burn-flex match arms
When it happens
Trigger: Calling int_gather (directly or via TensorData/BackendExt gather ops) on an IntTensor whose dtype is not one of the eight implemented int widths - for example a bool-typed tensor produced by a comparison op being passed to gather, or a float tensor wrongly cast to the int handle.
Common situations: Mixing tensor types after comparison predicates (bool tensors fed into indexing ops), dtype-inference surprises in model code where a tensor stays in float/bool form, or a new DType variant added upstream in burn that burn-flex has not yet added match arms for.
Related errors
- int_scatter: unsupported dtype {:?}
- int_scatter_nd: unsupported dtype {:?}
- int_gather_nd: unsupported dtype {:?}
- int_select: unsupported dtype {:?}
- int_select_assign: unsupported dtype {:?}
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/600bbc9be2399940.
Report an issue: GitHub.