{"record":{"id":"19c981f1ca9c57af","repo":"tracel-ai/burn","slug":"int-scatter-unsupported-dtype","errorCode":null,"errorMessage":"int_scatter: unsupported dtype {:?}","messagePattern":"int_scatter: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/int.rs","lineNumber":164,"sourceCode":"                    DType::I16 => crate::ops::gather_scatter::scatter_assign::<i16>(\n                        tensor, dim, indices, value,\n                    ),\n                    DType::I8 => crate::ops::gather_scatter::scatter_assign::<i8>(\n                        tensor, dim, indices, value,\n                    ),\n                    DType::U64 => crate::ops::gather_scatter::scatter_assign::<u64>(\n                        tensor, dim, indices, value,\n                    ),\n                    DType::U32 => crate::ops::gather_scatter::scatter_assign::<u32>(\n                        tensor, dim, indices, value,\n                    ),\n                    DType::U16 => crate::ops::gather_scatter::scatter_assign::<u16>(\n                        tensor, dim, indices, value,\n                    ),\n                    DType::U8 => crate::ops::gather_scatter::scatter_assign::<u8>(\n                        tensor, dim, indices, value,\n                    ),\n                    dt => panic!(\"int_scatter: unsupported dtype {:?}\", dt),\n                }\n            }\n            burn_backend::tensor::IndexingUpdateOp::Add => {\n                debug_assert_eq!(tensor.dtype(), value.dtype(), \"int_scatter: dtype mismatch\");\n                match tensor.dtype() {\n                    DType::I64 => {\n                        crate::ops::gather_scatter::scatter_add::<i64>(tensor, dim, indices, value)\n                    }\n                    DType::I32 => {\n                        crate::ops::gather_scatter::scatter_add::<i32>(tensor, dim, indices, value)\n                    }\n                    DType::I16 => {\n                        crate::ops::gather_scatter::scatter_add::<i16>(tensor, dim, indices, value)\n                    }\n                    DType::I8 => {\n                        crate::ops::gather_scatter::scatter_add::<i8>(tensor, dim, indices, value)\n                    }\n                    DType::U64 => {","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/int.rs#L146-L182","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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>"],"exampleFix":"// before\ntensor.scatter(dim, indices, value, IndexingUpdateOp::Set); // tensor is DType::Bool\n// after\nlet tensor = tensor.cast(DType::I32);\nlet value = value.cast(DType::I32);\ntensor.scatter(dim, indices, value, IndexingUpdateOp::Set);","handlingStrategy":"validation","validationCode":"assert_eq!(tensor.dtype(), value.dtype(), \"int_scatter: dtype mismatch\");\nassert!(is_supported_int_dtype(tensor.dtype()), \"unsupported dtype {:?}\", tensor.dtype());","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":["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"],"tags":["rust","dtype","panic","scatter","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"}