tracel-ai/burn · error
Unsupported dtype: {other:?}
Error message
Unsupported dtype: {other:?} What it means
int_abs must dispatch the abs computation to the concrete integer type stored in the tensor. If the tensor's dtype is not one of the supported signed integer types (i64/i32/i16/i8) and not an unsigned type (returned as-is), the dtype is unexpected and the backend panics with 'Unsupported dtype'.
Source
Thrown at crates/burn-ndarray/src/ops/int_tensor.rs:400
fn int_clamp(tensor: NdArrayTensor, min: Scalar, max: Scalar) -> NdArrayTensor {
execute_with_int_dtype!(tensor, |array| NdArrayMathOps::clamp(
array,
min.elem(),
max.elem()
))
}
fn int_abs(tensor: NdArrayTensor) -> NdArrayTensor {
match tensor.dtype() {
DType::I64 | DType::I32 | DType::I16 | DType::I8 => {
execute_with_dtype!(tensor, I, NdArrayMathOps::abs, [
I64 => i64, I32 => i32, I16 => i16, I8 => i8
])
}
// Already unsigned
DType::U64 | DType::U32 | DType::U16 | DType::U8 => tensor,
other => panic!("Unsupported dtype: {other:?}"),
}
}
fn int_into_float(tensor: NdArrayTensor, out_dtype: FloatDType) -> FloatTensor<Self> {
execute_with_float_out_dtype!(out_dtype, F, {
execute_with_int_dtype!(tensor, IntElem, |array: SharedArray<IntElem>| {
array.mapv(|a: IntElem| a.elem::<F>()).into_shared()
})
})
}
fn int_swap_dims(tensor: NdArrayTensor, dim1: usize, dim2: usize) -> NdArrayTensor {
execute_with_int_dtype!(tensor, |array| NdArrayOps::swap_dims(array, dim1, dim2))
}
fn int_random(
shape: Shape,
distribution: Distribution,View on GitHub (pinned to d16f7ba2ed)
Solutions
- Ensure the int tensor uses a supported dtype (I64/I32/I16/I8 or unsigned, which is returned unchanged).
- Cast the tensor to a supported int dtype (e.g. .int() / int cast to i32) before abs.
- Upgrade or downgrade burn so the backend and core DType enum versions match.
- Convert to float, take abs, and convert back as a workaround.
- Report the missing dtype case to the burn repository if a legit variant is unhandled.
Example fix
// before let t: Tensor<_, Int, NdArray> = ...; // dtype not in supported set let a = t.abs(); // after let t = t.cast(burn::tensor::DType::I32); // supported signed dtype let a = t.abs();
Defensive patterns
Strategy: type-guard
Validate before calling
assert!(matches!(t.dtype(), DType::I64 | DType::I32 | DType::I16 | DType::I8 | DType::U64 | DType::U32 | DType::U16 | DType::U8), "abs: unsupported int dtype");
Type guard
fn abs_supported(dt: DType) -> bool {
matches!(dt, DType::I64 | DType::I32 | DType::I16 | DType::I8
| DType::U64 | DType::U32 | DType::U16 | DType::U8)
} Prevention
- Cast tensors to a supported int dtype before abs
- Keep burn core and backend crate versions in sync
- Check tensor.dtype() when migrating between backends
When it happens
Trigger: Calling Tensor::abs on an Int tensor whose dtype falls outside the I64/I32/I16/I8/U64/U32/U16/U8 set — typically only possible with a mismatched/foreign dtype variant or an enum extended in a newer burn version without updating this match.
Common situations: Using a burn version where DType gained new variants while burn-ndarray's int_abs wasn't updated; dtype confusion after converting tensors across backends; bool tensors mis-typed as int.
Related errors
- burn-flex does not support Bool(U32) storage (only Native an
- compare_int: unsupported dtype {:?}
- compare_int_elem: unsupported dtype {:?}
- any_float: unsupported dtype {:?}
- all_float: unsupported dtype {:?}
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/56b74d53c0123f48.
Report an issue: GitHub.