{"record":{"id":"1c984ccf82fb2516","repo":"tracel-ai/burn","slug":"float-scatter-unsupported-dtype","errorCode":null,"errorMessage":"float_scatter: unsupported dtype {:?}","messagePattern":"float_scatter: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/float.rs","lineNumber":306,"sourceCode":"        indices: IntTensor<Flex>,\n        value: FloatTensor<Flex>,\n        update: burn_backend::tensor::IndexingUpdateOp,\n    ) -> FloatTensor<Flex> {\n        match update {\n            burn_backend::tensor::IndexingUpdateOp::Assign => match tensor.dtype() {\n                DType::F32 => {\n                    crate::ops::gather_scatter::scatter_assign::<f32>(tensor, dim, indices, value)\n                }\n                DType::F64 => {\n                    crate::ops::gather_scatter::scatter_assign::<f64>(tensor, dim, indices, value)\n                }\n                DType::F16 => {\n                    crate::ops::gather_scatter::scatter_assign::<f16>(tensor, dim, indices, value)\n                }\n                DType::BF16 => {\n                    crate::ops::gather_scatter::scatter_assign::<bf16>(tensor, dim, indices, value)\n                }\n                _ => panic!(\"float_scatter: unsupported dtype {:?}\", tensor.dtype()),\n            },\n            burn_backend::tensor::IndexingUpdateOp::Add => match tensor.dtype() {\n                DType::F32 => {\n                    crate::ops::gather_scatter::scatter_add::<f32>(tensor, dim, indices, value)\n                }\n                DType::F64 => {\n                    crate::ops::gather_scatter::scatter_add::<f64>(tensor, dim, indices, value)\n                }\n                DType::F16 => {\n                    crate::ops::gather_scatter::scatter_add::<f16>(tensor, dim, indices, value)\n                }\n                DType::BF16 => {\n                    crate::ops::gather_scatter::scatter_add::<bf16>(tensor, dim, indices, value)\n                }\n                _ => panic!(\"float_scatter: unsupported dtype {:?}\", tensor.dtype()),\n            },\n            burn_backend::tensor::IndexingUpdateOp::Mul => match tensor.dtype() {\n                DType::F32 => {","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/float.rs#L288-L324","documentation":"In float_scatter, the IndexingUpdateOp::Set branch dispatches scatter_assign per dtype and only handles F32/F64/F16/BF16. A tensor with any other dtype in the Set-update path triggers this catch-all panic. It protects the monomorphic dispatch table from non-float tensors.","triggerScenarios":"Calling float_scatter (Tensor::scatter with IndexingUpdateOp::Set / scatter_assign) on a tensor whose dtype is not one of the four float types.","commonSituations":"Scattering into an int tensor routed through the float op; a wrong-dtype value tensor causing the backend to pick the float path; a newly added DType missing from the match.","solutions":["Confirm the target tensor is a float tensor before scattering","Use the int/bool scatter op for non-float tensors","Cast the tensor to a float dtype (e.g. F32) before scatter","Add the missing DType arm dispatching to scatter_assign if a new float/int variant exists"],"exampleFix":"// before: target is I32 -> panic on Set update\nlet t = t.scatter(dim, indices, value, IndexingUpdateOp::Set);\n// after\nlet t = t.cast(FloatDType::F32).scatter(dim, indices, value, IndexingUpdateOp::Set);","handlingStrategy":"type-guard","validationCode":"fn ensure_float_for_scatter(dt: DType) -> Result<(), String> {\n    match dt {\n        DType::F32 | DType::F64 | DType::F16 | DType::BF16 => Ok(()),\n        other => Err(format!(\"float_scatter requires a float dtype, got {:?}\", other)),\n    }\n}","typeGuard":"fn is_float_dtype(dt: DType) -> bool {\n    matches!(dt, DType::F32 | DType::F64 | DType::F16 | DType::BF16)\n}","tryCatchPattern":null,"preventionTips":["Verify the target tensor dtype before any scatter call","Ensure value tensors have the same dtype as the target so dispatch stays on one path","Use int-specific scatter ops for integer targets","Audit all IndexingUpdateOp branches when adding new dtypes"],"tags":["rust","tensor","dtype","scatter","panic"],"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"}