tracel-ai/burn · error
int_mask_fill: unsupported dtype {:?}
Error message
int_mask_fill: unsupported dtype {:?} What it means
int_mask_fill fills masked positions of an integer tensor with a scalar value, converting the scalar to the tensor's dtype. If the tensor's dtype is not one of the supported integer types, the function panics with 'unsupported dtype'. Note the scalar conversion itself uses value.to_i64()/to_u64().unwrap(), so the dtype dispatch is the guard implemented here.
Source
Thrown at crates/burn-flex/src/ops/int.rs:92
dt => panic!("int_mask_where: unsupported dtype {:?}", dt),
}
}
fn int_mask_fill(
tensor: IntTensor<Flex>,
mask: BoolTensor<Flex>,
value: Scalar,
) -> IntTensor<Flex> {
match tensor.dtype() {
DType::I64 => crate::ops::mask::mask_fill(tensor, mask, value.to_i64().unwrap()),
DType::I32 => crate::ops::mask::mask_fill(tensor, mask, value.to_i64().unwrap() as i32),
DType::I16 => crate::ops::mask::mask_fill(tensor, mask, value.to_i64().unwrap() as i16),
DType::I8 => crate::ops::mask::mask_fill(tensor, mask, value.to_i64().unwrap() as i8),
DType::U64 => crate::ops::mask::mask_fill(tensor, mask, value.to_u64().unwrap()),
DType::U32 => crate::ops::mask::mask_fill(tensor, mask, value.to_u64().unwrap() as u32),
DType::U16 => crate::ops::mask::mask_fill(tensor, mask, value.to_u64().unwrap() as u16),
DType::U8 => crate::ops::mask::mask_fill(tensor, mask, value.to_u64().unwrap() as u8),
dt => panic!("int_mask_fill: unsupported dtype {:?}", dt),
}
}
fn int_slice_assign(
tensor: IntTensor<Flex>,
slices: &[Slice],
value: IntTensor<Flex>,
) -> IntTensor<Flex> {
crate::ops::slice::slice_assign(tensor, slices, value)
}
/// Gather ints along `dim` at the given indices.
///
/// The `tensor` dispatches on its own int dtype (I8/I16/I32/I64 signed or
/// 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.View on GitHub (pinned to d16f7ba2ed)
Solutions
- Route float tensors to the float mask_fill op
- Cast the tensor to an integer dtype before calling int_mask_fill
- Assert tensor.dtype().is_int() (or equivalent) before the call
- Trace where the tensor's dtype changed if it was expected to be an int tensor
Example fix
// before let out = backend.int_mask_fill(f_tensor, mask, 3.0f32.into()); // panic: unsupported dtype F32 // after let out = backend.float_mask_fill(f_tensor, mask, 3.0f32.into());
Defensive patterns
Strategy: validation
Validate before calling
// before calling int_mask_fill
assert!(tensor.dtype().is_int(), "int_mask_fill requires an integer tensor, got {:?}", tensor.dtype()); Type guard
fn is_int_dtype(d: DType) -> bool {
matches!(d, DType::I64 | DType::I32 | DType::I16 | DType::I8 | DType::U64 | DType::U32 | DType::U16 | DType::U8)
} Prevention
- Route float tensors to the float mask_fill variant
- Track dtype through the pipeline; assert before int-specific ops
When it happens
Trigger: Calling int_mask_fill on a tensor whose dtype is not I64/I32/I16/I8/U64/U32/U16/U8 — i.e. a float or bool tensor reached the int ops entry point.
Common situations: Float tensors incorrectly passed to the int ops API, generic pipelines where the dtype parameter changed at runtime, or confusion between mask_fill variants for float vs int tensors.
Related errors
- int_mask_where: unsupported dtype {:?}
- Should be int, got float
- Should be int, got bool
- Should be int, got quantized
- Should be int, got autodiff
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/1efea90c57280309.
Report an issue: GitHub.