{"record":{"id":"77267e800011ff66","repo":"tracel-ai/burn","slug":"gather-nd-is-not-supported-for-bool-tensors","errorCode":null,"errorMessage":"gather_nd is not supported for bool tensors","messagePattern":"gather_nd is not supported for bool tensors","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-tensor/src/bridge/ops/bool.rs","lineNumber":167,"sourceCode":"                tensor.into(),\n                indices.into(),\n                values.into(),\n            )),\n            _ => unimplemented!(),\n        }\n    }\n\n    fn scatter_nd(\n        _data: BridgeTensor,\n        _indices: BridgeTensor,\n        _values: BridgeTensor,\n        _reduction: IndexingUpdateOp,\n    ) -> BridgeTensor {\n        panic!(\"scatter_nd is not supported for bool tensors\")\n    }\n\n    fn gather_nd(_data: BridgeTensor, _indices: BridgeTensor) -> BridgeTensor {\n        panic!(\"gather_nd is not supported for bool tensors\")\n    }\n\n    fn device(tensor: &BridgeTensor) -> Device {\n        Device::new(tensor.as_dispatch().device())\n    }\n\n    fn to_device(tensor: BridgeTensor, device: &Device) -> BridgeTensor {\n        BridgeTensor::bool(Dispatch::bool_to_device(\n            tensor.into(),\n            device.as_dispatch(),\n        ))\n    }\n\n    async fn into_data_async(tensor: BridgeTensor) -> Result<TensorData, ExecutionError> {\n        Dispatch::bool_into_data(tensor.into()).await\n    }\n\n    fn from_data(data: TensorData, device: &Device, dtype: DType) -> BridgeTensor {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-tensor/src/bridge/ops/bool.rs#L149-L185","documentation":"Capability guard on the bool tensor bridge: `gather_nd` (like `scatter_nd`) is deliberately unsupported for BoolKind bridge tensors — bool tensors cannot be gathered with an ND index op in this backend abstraction — so any call panics. The failing input is a bool tensor passed to gather_nd where a numeric dtype was expected.","triggerScenarios":"Calling tensor.gather(indices) / gather_nd on a Tensor::<B, D, Bool> — e.g. pulling selected boolean mask entries by index tensors.","commonSituations":"Reusing numeric gather code paths on boolean masks; model translation (ONNX GatherND on bool) into burn with the Bool element type.","solutions":["Cast the bool tensor to a numeric dtype (e.g. u8/f32) before gather_nd, then convert back.","Perform the gather manually with boolean masking or index_select, which are supported for bools.","Restructure the operation so indices are applied to the numeric source tensor before the bool conversion."],"exampleFix":"// before\nlet picked: Tensor<B, 2, Bool> = mask.gather(indices); // gather_nd on Bool\n// after\nlet picked = mask.int().gather(indices).bool_cast();","handlingStrategy":"fallback","validationCode":"fn gather_bool_mask<B: Backend, const D: usize>(mask: Tensor<B, D, Bool>, indices: Tensor<B, 2, Int>) -> Tensor<B, D, Bool> {\n    mask.int().gather(indices).bool_cast() // gather_nd path via Int fallback\n}","typeGuard":null,"tryCatchPattern":"std::panic::catch_unwind(|| mask.gather(indices))\n    .map_err(|_| \"gather_nd unsupported for Bool\")\n    .or_else(|_| Ok::<_, String>(mask.int().gather(indices).bool_cast()))?;","preventionTips":["Cast Bool tensors to Int before gather_nd-style operations and cast back afterwards","Prefer select/index along dims, which Bool supports, when gathering masks","Flag ONNX GatherND-on-bool nodes during model import and rewrite them to int gathers"],"tags":["rust","burn","unsupported-operation","bool","gather"],"backgroundTag":"unsupported-op-backend","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"}