tracel-ai/burn · error
int_scatter: unsupported dtype {:?}
Error message
int_scatter: unsupported dtype {:?} What it means
int_scatter dispatches on the tensor dtype for the IndexingUpdateOp::Set (assignment) path and panics when the dtype is not one of the eight implemented integer widths. The library refuses to reinterpret raw bytes of an unknown dtype during scatter-assign, so it fails fast with this panic instead of producing corrupt results.
Source
Thrown at crates/burn-flex/src/ops/int.rs:164
DType::I16 => crate::ops::gather_scatter::scatter_assign::<i16>(
tensor, dim, indices, value,
),
DType::I8 => crate::ops::gather_scatter::scatter_assign::<i8>(
tensor, dim, indices, value,
),
DType::U64 => crate::ops::gather_scatter::scatter_assign::<u64>(
tensor, dim, indices, value,
),
DType::U32 => crate::ops::gather_scatter::scatter_assign::<u32>(
tensor, dim, indices, value,
),
DType::U16 => crate::ops::gather_scatter::scatter_assign::<u16>(
tensor, dim, indices, value,
),
DType::U8 => crate::ops::gather_scatter::scatter_assign::<u8>(
tensor, dim, indices, value,
),
dt => panic!("int_scatter: unsupported dtype {:?}", dt),
}
}
burn_backend::tensor::IndexingUpdateOp::Add => {
debug_assert_eq!(tensor.dtype(), value.dtype(), "int_scatter: dtype mismatch");
match tensor.dtype() {
DType::I64 => {
crate::ops::gather_scatter::scatter_add::<i64>(tensor, dim, indices, value)
}
DType::I32 => {
crate::ops::gather_scatter::scatter_add::<i32>(tensor, dim, indices, value)
}
DType::I16 => {
crate::ops::gather_scatter::scatter_add::<i16>(tensor, dim, indices, value)
}
DType::I8 => {
crate::ops::gather_scatter::scatter_add::<i8>(tensor, dim, indices, value)
}
DType::U64 => {View on GitHub (pinned to d16f7ba2ed)
Solutions
- Cast both the target tensor and value to a supported int dtype (e.g. DType::I32) before calling int_scatter
- Ensure tensor.dtype() == value.dtype() before the call - the debug_assert signals this precondition
- Verify the update op you intended (Set vs Add/Mul); this panic is specific to the Set path
- If a new DType variant is missing, add a match arm calling crate::ops::gather_scatter::scatter_assign::<T>
Example fix
// before tensor.scatter(dim, indices, value, IndexingUpdateOp::Set); // tensor is DType::Bool // after let tensor = tensor.cast(DType::I32); let value = value.cast(DType::I32); tensor.scatter(dim, indices, value, IndexingUpdateOp::Set);
Defensive patterns
Strategy: validation
Validate before calling
assert_eq!(tensor.dtype(), value.dtype(), "int_scatter: dtype mismatch");
assert!(is_supported_int_dtype(tensor.dtype()), "unsupported dtype {:?}", tensor.dtype()); 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
- Always cast target and value to the same int dtype before scatter
- Use IndexingUpdateOp::Set only on genuinely integer tensors
- Run debug builds so the dtype-mismatch debug_assert fires early
- Keep dtype conversions at explicit boundaries rather than relying on inference
When it happens
Trigger: Calling int_scatter with IndexingUpdateOp::Set on a tensor whose dtype is outside i64/i32/i16/i8/u64/u32/u16/u8 (e.g. a bool tensor), or when tensor.dtype() and value.dtype() diverge so an unexpected arm is reached.
Common situations: Assigning into index results derived from bool masks, dtype drift between the target tensor and the update value after transformations, or a burn version that introduced a new DType not yet handled in burn-flex's match.
Related errors
- float_scatter: unsupported dtype {:?}
- int_gather: unsupported dtype {:?}
- int_scatter_nd: unsupported dtype {:?}
- int_gather_nd: unsupported dtype {:?}
- int_select: unsupported dtype {:?}
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/19c981f1ca9c57af.
Report an issue: GitHub.