{"record":{"id":"600bbc9be2399940","repo":"tracel-ai/burn","slug":"int-gather-unsupported-dtype","errorCode":null,"errorMessage":"int_gather: unsupported dtype {:?}","messagePattern":"int_gather: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/int.rs","lineNumber":125,"sourceCode":"    /// U8/U16/U32/U64 unsigned). The `indices` tensor may be any of those\n    /// widths too - it's normalised to `isize` by the shared `read_indices`\n    /// helper in `ops::gather_scatter` before the kernel runs, so callers are\n    /// not required to pre-convert to I64.\n    fn int_gather(\n        dim: usize,\n        tensor: IntTensor<Flex>,\n        indices: IntTensor<Flex>,\n    ) -> IntTensor<Flex> {\n        match tensor.dtype() {\n            DType::I64 => crate::ops::gather_scatter::gather::<i64>(tensor, dim, indices),\n            DType::I32 => crate::ops::gather_scatter::gather::<i32>(tensor, dim, indices),\n            DType::I16 => crate::ops::gather_scatter::gather::<i16>(tensor, dim, indices),\n            DType::I8 => crate::ops::gather_scatter::gather::<i8>(tensor, dim, indices),\n            DType::U64 => crate::ops::gather_scatter::gather::<u64>(tensor, dim, indices),\n            DType::U32 => crate::ops::gather_scatter::gather::<u32>(tensor, dim, indices),\n            DType::U16 => crate::ops::gather_scatter::gather::<u16>(tensor, dim, indices),\n            DType::U8 => crate::ops::gather_scatter::gather::<u8>(tensor, dim, indices),\n            dt => panic!(\"int_gather: unsupported dtype {:?}\", dt),\n        }\n    }\n\n    fn int_scatter(\n        dim: usize,\n        tensor: IntTensor<Flex>,\n        indices: IntTensor<Flex>,\n        value: IntTensor<Flex>,\n        update: burn_backend::tensor::IndexingUpdateOp,\n    ) -> IntTensor<Flex> {\n        match update {\n            burn_backend::tensor::IndexingUpdateOp::Assign => {\n                debug_assert_eq!(tensor.dtype(), value.dtype(), \"int_scatter: dtype mismatch\");\n                match tensor.dtype() {\n                    DType::I64 => crate::ops::gather_scatter::scatter_assign::<i64>(\n                        tensor, dim, indices, value,\n                    ),\n                    DType::I32 => crate::ops::gather_scatter::scatter_assign::<i32>(","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/int.rs#L107-L143","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nlet picked = tensor.gather(dim, indices); // tensor is DType::Bool\n// after\nlet picked = tensor.cast(DType::I64).gather(dim, indices);","handlingStrategy":"validation","validationCode":"fn assert_supported_int_dtype(t: &burn::tensor::Tensor<burn::backend::Flex, 2>) {\n    match t.dtype() {\n        burn::tensor::DType::I64 | burn::tensor::DType::I32\n        | burn::tensor::DType::I16 | burn::tensor::DType::I8\n        | burn::tensor::DType::U64 | burn::tensor::DType::U32\n        | burn::tensor::DType::U16 | burn::tensor::DType::U8 => {}\n        other => panic!(\"gather needs an int dtype, got {:?}\", other),\n    }\n}","typeGuard":"fn is_supported_int_dtype(dt: burn::tensor::DType) -> bool {\n    matches!(\n        dt,\n        burn::tensor::DType::I64 | burn::tensor::DType::I32\n            | burn::tensor::DType::I16 | burn::tensor::DType::I8\n            | burn::tensor::DType::U64 | burn::tensor::DType::U32\n            | burn::tensor::DType::U16 | burn::tensor::DType::U8\n    )\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","dtype","panic","burn-flex"],"backgroundTag":"unsupported-dtype","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}