{"record":{"id":"e4be166cef84343f","repo":"tracel-ai/burn","slug":"float-select-unsupported-dtype","errorCode":null,"errorMessage":"float_select: unsupported dtype {:?}","messagePattern":"float_select: unsupported dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-flex/src/ops/float.rs","lineNumber":385,"sourceCode":"            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> {\n        match tensor.dtype() {\n            DType::F32 => crate::ops::gather_scatter::select::<f32>(tensor, dim, indices),\n            DType::F64 => crate::ops::gather_scatter::select::<f64>(tensor, dim, indices),\n            DType::F16 => crate::ops::gather_scatter::select::<f16>(tensor, dim, indices),\n            DType::BF16 => crate::ops::gather_scatter::select::<bf16>(tensor, dim, indices),\n            _ => panic!(\"float_select: unsupported dtype {:?}\", tensor.dtype()),\n        }\n    }\n\n    fn float_select_assign(\n        tensor: FloatTensor<Flex>,\n        dim: usize,\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::select_assign::<f32>(tensor, dim, indices, value)\n                }\n                DType::F64 => {\n                    crate::ops::gather_scatter::select_assign::<f64>(tensor, dim, indices, value)\n                }","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-flex/src/ops/float.rs#L367-L403","documentation":"Dtype-dispatch exhaustiveness panic: `float_select` supports only float dtypes and panics otherwise; reaching it means a non-float tensor was dispatched into the float select (indexing) op in the Flex backend.","triggerScenarios":"Calling float_select (Tensor::select along a dim) where the tensor's dtype is Int or Bool rather than a float type.","commonSituations":"Selecting rows/slices from an int tensor (e.g. label tensor) via the float op; dtype changes upstream; new DType variant missing from the dispatch table.","solutions":["Confirm tensor.dtype() is a float type before select","Use the corresponding int/bool select op for non-float tensors","Cast the tensor to a float dtype before selecting","Add a match arm for any newly added DType"],"exampleFix":"// before: labels is I64 -> panic\nlet picked = labels.select(dim, indices);\n// after\nlet picked = labels.cast(FloatDType::F32).select(dim, indices);","handlingStrategy":"type-guard","validationCode":"fn ensure_float_for_select(dt: DType) -> Result<(), String> {\n    match dt {\n        DType::F32 | DType::F64 | DType::F16 | DType::BF16 => Ok(()),\n        other => Err(format!(\"float_select 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":["Check dtype before select/slice-gather ops","Route integer label tensors through int select ops or cast them first","Avoid silent dtype conversions between pipeline stages; log dtypes at stage boundaries","Update all dtype match arms when adding new variants"],"tags":["rust","tensor","dtype","select","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"}