{"record":{"id":"a6d51cc3f1bac252","repo":"tracel-ai/burn","slug":"float-gather-unsupported-dtype","errorCode":null,"errorMessage":"float_gather: unsupported dtype {:?}","messagePattern":"float_gather: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/float.rs","lineNumber":281,"sourceCode":"    fn float_cat(tensors: Vec<FloatTensor<Flex>>, dim: usize) -> FloatTensor<Flex> {\n        crate::ops::cat::cat(tensors, dim)\n    }\n\n    fn float_reshape(tensor: FloatTensor<Flex>, shape: Shape) -> FloatTensor<Flex> {\n        tensor.reshape(shape)\n    }\n\n    fn float_gather(\n        dim: usize,\n        tensor: FloatTensor<Flex>,\n        indices: IntTensor<Flex>,\n    ) -> FloatTensor<Flex> {\n        match tensor.dtype() {\n            DType::F32 => crate::ops::gather_scatter::gather::<f32>(tensor, dim, indices),\n            DType::F64 => crate::ops::gather_scatter::gather::<f64>(tensor, dim, indices),\n            DType::F16 => crate::ops::gather_scatter::gather::<f16>(tensor, dim, indices),\n            DType::BF16 => crate::ops::gather_scatter::gather::<bf16>(tensor, dim, indices),\n            _ => panic!(\"float_gather: unsupported dtype {:?}\", tensor.dtype()),\n        }\n    }\n\n    fn float_scatter(\n        dim: usize,\n        tensor: FloatTensor<Flex>,\n        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                }","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/float.rs#L263-L299","documentation":"float_gather dispatches to a monomorphic gather implementation based on the tensor's dtype, supporting only F32, F64, F16, and BF16. Any other dtype (int or bool) reaching this float op hits the catch-all panic. It guards the dispatch table against non-float tensors.","triggerScenarios":"Calling float_gather (via Tensor::gather/select on a float tensor) where the data tensor's dtype is not one of the four float types, e.g. an Int or Bool tensor mis-dispatched into the float indexing path.","commonSituations":"Gathering on a tensor that upstream ops silently converted to int/bool; a misrouted dispatch in the backend; adding a new DType variant without updating this match.","solutions":["Verify the tensor being gathered is a float tensor (F32/F64/F16/BF16) with tensor.dtype()","If the data is int/bool, call the corresponding int/bool gather op instead","Insert an explicit cast to a float dtype before gathering if a float result is required","If a new DType variant exists, add a match arm dispatching to gather::<new_type>"],"exampleFix":"// before: x is I64 -> panic\nlet picked = x.gather(dim, indices);\n// after\nlet picked = x.cast(FloatDType::F32).gather(dim, indices);","handlingStrategy":"type-guard","validationCode":"fn ensure_float_for_gather(dt: DType) -> Result<(), String> {\n    match dt {\n        DType::F32 | DType::F64 | DType::F16 | DType::BF16 => Ok(()),\n        other => Err(format!(\"float_gather 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":["Assert the data tensor is float before gather/select-style ops","Cast non-float data explicitly with .cast(FloatDType::F32) when a float result is needed","Keep indices tensors int and data tensors float; never let them swap roles","Update dtype dispatch tables whenever a DType variant is added"],"tags":["rust","tensor","dtype","gather","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"}