{"record":{"id":"df480ae06a156d3b","repo":"tracel-ai/burn","slug":"float-scatter-nd-unsupported-dtype","errorCode":null,"errorMessage":"float_scatter_nd: unsupported dtype {:?}","messagePattern":"float_scatter_nd: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/float.rs","lineNumber":361,"sourceCode":"        data: FloatTensor<Flex>,\n        indices: IntTensor<Flex>,\n        values: FloatTensor<Flex>,\n        reduction: burn_backend::tensor::IndexingUpdateOp,\n    ) -> FloatTensor<Flex> {\n        match data.dtype() {\n            DType::F32 => {\n                crate::ops::gather_scatter::scatter_nd::<f32>(data, indices, values, reduction)\n            }\n            DType::F64 => {\n                crate::ops::gather_scatter::scatter_nd::<f64>(data, indices, values, reduction)\n            }\n            DType::F16 => {\n                crate::ops::gather_scatter::scatter_nd::<f16>(data, indices, values, reduction)\n            }\n            DType::BF16 => {\n                crate::ops::gather_scatter::scatter_nd::<bf16>(data, indices, values, reduction)\n            }\n            _ => panic!(\"float_scatter_nd: unsupported dtype {:?}\", data.dtype()),\n        }\n    }\n\n    fn float_gather_nd(data: FloatTensor<Flex>, indices: IntTensor<Flex>) -> FloatTensor<Flex> {\n        match data.dtype() {\n            DType::F32 => crate::ops::gather_scatter::gather_nd::<f32>(data, indices),\n            DType::F64 => crate::ops::gather_scatter::gather_nd::<f64>(data, indices),\n            DType::F16 => crate::ops::gather_scatter::gather_nd::<f16>(data, indices),\n            DType::BF16 => crate::ops::gather_scatter::gather_nd::<bf16>(data, indices),\n            _ => panic!(\"float_gather_nd: unsupported dtype {:?}\", data.dtype()),\n        }\n    }\n\n    fn float_select(\n        tensor: FloatTensor<Flex>,\n        dim: usize,\n        indices: IntTensor<Flex>,\n    ) -> FloatTensor<Flex> {","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/float.rs#L343-L379","documentation":"float_scatter_nd performs N-dimensional scatter updates and dispatches per dtype, supporting only F32, F64, F16, and BF16 for the data tensor. Any other dtype hits the catch-all panic. Like its siblings, it is a defensive dispatch guard in the flex backend.","triggerScenarios":"Calling float_scatter_nd (Tensor::scatter_nd) where the data tensor's dtype is not a float type (e.g. Int or Bool data with float-indexed updates).","commonSituations":"scatter_nd on an int parameter tensor (e.g. embedding indices data instead of weights); dtype changed by quantization or mixed-precision plumbing; new DType variant missing from the dispatch.","solutions":["Check data.dtype() is F32/F64/F16/BF16 before scatter_nd","Use the int/bool scatter_nd path for non-float data","Cast data to a float dtype before the operation","Add a match arm for any newly added DType"],"exampleFix":"// before: data is I64 -> panic\nlet out = data.scatter_nd(indices, values, reduction);\n// after\nlet out = data.cast(FloatDType::F32).scatter_nd(indices, values, reduction);","handlingStrategy":"type-guard","validationCode":"fn ensure_float_for_scatter_nd(dt: DType) -> Result<(), String> {\n    match dt {\n        DType::F32 | DType::F64 | DType::F16 | DType::BF16 => Ok(()),\n        other => Err(format!(\"float_scatter_nd requires a float data 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":["Confirm the data (not the indices) tensor is float before scatter_nd","Cast int data to float first if float output is expected","Keep indices int-typed and data float-typed in scatter_nd pipelines","Audit dtype dispatches when new DType variants are introduced"],"tags":["rust","tensor","dtype","scatter-nd","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"}