{"record":{"id":"8bc1c2b63025c310","repo":"tracel-ai/burn","slug":"unsupported-dtype-for-int-from-data","errorCode":null,"errorMessage":"Unsupported dtype for `int_from_data`","messagePattern":"Unsupported dtype for `int_from_data`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-cubecl/src/ops/int_tensor.rs","lineNumber":47,"sourceCode":"        let dtype = dtype.into();\n        super::empty(shape, device, dtype)\n    }\n\n    async fn int_into_data(tensor: IntTensor<Self>) -> Result<TensorData, ExecutionError> {\n        super::into_data(tensor).await\n    }\n\n    fn int_from_data(data: TensorData, device: &Device<Self>) -> IntTensor<Self> {\n        match data.dtype {\n            DType::I64\n            | DType::I32\n            | DType::I16\n            | DType::I8\n            | DType::U64\n            | DType::U32\n            | DType::U16\n            | DType::U8 => super::from_data(data, device),\n            _ => unimplemented!(\"Unsupported dtype for `int_from_data`\"),\n        }\n    }\n\n    fn int_to_device(tensor: IntTensor<Self>, device: &Device<Self>) -> IntTensor<Self> {\n        super::to_device(tensor, device)\n    }\n\n    fn int_reshape(tensor: IntTensor<Self>, shape: Shape) -> IntTensor<Self> {\n        super::reshape(tensor, shape)\n    }\n\n    fn int_slice(tensor: IntTensor<Self>, slices: &[Slice]) -> IntTensor<Self> {\n        // Check if all steps are 1\n        let all_steps_one = slices.iter().all(|info| info.step == 1);\n\n        if all_steps_one {\n            // Use optimized slice for step=1\n            let simple_ranges: Vec<Range<usize>> = slices","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-cubecl/src/ops/int_tensor.rs#L29-L65","documentation":"int_from_data converts host integer TensorData into a backend integer tensor. The supported set is I64/I32/I16/I8/U64/U32/U16/U8; any other dtype (floats, bool, quantized) cannot be loaded as an int tensor, so it panics with this unimplemented!.","triggerScenarios":"Calling int_from_data with TensorData whose dtype is not one of the eight integer dtypes — e.g. passing float data into an int tensor constructor, or bool/quantized dtype data.","commonSituations":"Type confusion when building TensorData manually; passing float tensors where index/int tensors are expected; data loaded from files with a mislabeled dtype.","solutions":["Cast the data to a supported integer dtype (e.g. i32/u32) before constructing the tensor","Convert floats explicitly: build the float tensor then .int() / cast to the int dtype","Verify TensorData.dtype matches the tensor type you construct (Tensor<.., Int>)","Fix data-loading code so integer arrays are stored with integer dtypes"],"exampleFix":"// before\nlet data = TensorData::from([1.0f32, 2.0]);\nlet idx = Tensor::<Backend, 1>::from_data(data, &device); // int tensor from float data -> panic\n// after\nlet idx = Tensor::<Backend, 1>::from_data(TensorData::from([1i32, 2]), &device);","handlingStrategy":"type-guard","validationCode":"fn int_data_supported(data: &TensorData) -> bool {\n    matches!(data.dtype,\n        DType::I64 | DType::I32 | DType::I16 | DType::I8 |\n        DType::U64 | DType::U32 | DType::U16 | DType::U8)\n}","typeGuard":"fn is_int_dtype(dtype: DType) -> bool {\n    matches!(dtype, DType::I64 | DType::I32 | DType::I16 | DType::I8 |\n                    DType::U64 | DType::U32 | DType::U16 | DType::U8)\n}","tryCatchPattern":"// Guard before creating int tensor:\nif int_data_supported(&data) { Tensor::<B, D, Int>::from_data(data, &device) } else { /* cast data or build float tensor then .int() */ }","preventionTips":["Match TensorData.dtype to the tensor kind (Int vs Float)","Cast floats to ints explicitly before building index tensors","Validate dtypes at data-loading boundaries"],"tags":["integer","dtype","tensor-data","unimplemented"],"backgroundTag":"unsupported-dtype-conversion","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"}