{"record":{"id":"b70318b1be4a5a40","repo":"tracel-ai/burn","slug":"quantized-float-is-not-supported","errorCode":null,"errorMessage":"Quantized float is not supported","messagePattern":"Quantized float is not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-vision/src/color.rs","lineNumber":51,"sourceCode":"    /// # Returns\n    /// The same-shape image tensor in HSV color space.\n    fn rgb2hsv(self) -> Tensor<4>;\n    /// Converts a batch of images from the HSV color space to the RGB color space.\n    ///\n    /// # Arguments\n    /// * `self`: A batched image tensor of shape `[batch, channel, height, width]`.\n    ///   The first channel (hue) is in the `0.0..360.0` range.\n    ///   The other two (saturation and value) are in the `0.0..=1.0` range.\n    ///\n    /// # Returns\n    /// The same-shape image tensor in RGB color space.\n    fn hsv2rgb(self) -> Tensor<4>;\n}\n\n/// Quantized floats aren't supported, matching the other float vision ops.\nfn reject_quantized(images: &Tensor<4>) {\n    if matches!(images.dtype(), DType::QFloat(_)) {\n        unimplemented!(\"Quantized float is not supported\");\n    }\n}\n\nfn channel(img: &Tensor<4>, at: usize) -> Tensor<4> {\n    img.clone().narrow(1, at, 1)\n}\n\n/// One channel back out of a hue, its value and its chroma.\n/// `target` - target channel : `0` for red, `1` for green and `2` for blue.\nfn from_hue(sixths: &Tensor<4>, target: usize, value: &Tensor<4>, chroma: &Tensor<4>) -> Tensor<4> {\n    // Rotate the wheel depending on the target channel.\n    let rotated = sixths\n        .clone()\n        .add_scalar(5.0 - (target as f32) * 2.0)\n        .remainder_scalar(6.0);\n    let ramp = rotated.clone().min_pair(4.0 - rotated).clamp(0.0, 1.0);\n\n    value.clone() - chroma.clone() * ramp","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-vision/src/color.rs#L33-L69","documentation":"burn-vision's color conversion helpers call `reject_quantized`, which panics with \"Quantized float is not supported\" when the input image tensor has a QFloat dtype. Quantized (QFloat) tensors are not valid inputs for rgb2gray, gray2rgb, rgb2hsv, or hsv2rgb, matching the library's stance on float vision ops.","triggerScenarios":"Passing a quantized tensor (`matches!(img.dtype(), DType::QFloat(_))`) to TensorVision::rgb2gray, gray2rgb, rgb2hsv, or hsv2rgb with any backend.","commonSituations":"Running color conversion on frames coming out of an int8-quantized vision model or camera pipeline without dequantizing first; chaining vision ops after quantized inference and forgetting QFloat persists across ops.","solutions":["Dequantize the image tensor to a float dtype (F32/F16/BF16) before the color conversion","Keep color conversions before any quantization step in the pipeline","Check the input dtype with a guard and convert when it is QFloat","Use float inference for preprocessing/color ops and quantize only where needed"],"exampleFix":"// before\nlet gray = img.clone().rgb2gray(); // img.dtype() == DType::QFloat(_) -> panic\n// after\nlet float_img = img.dequantize();\nlet gray = float_img.rgb2gray();","handlingStrategy":"validation","validationCode":"assert!(!is_quantized_image(&img), \"dequantize before color conversion\");","typeGuard":"fn is_quantized_image<B: Backend>(img: &Tensor<B, 4>) -> bool {\n    matches!(img.dtype(), DType::QFloat(_))\n}","tryCatchPattern":null,"preventionTips":["Dequantize before any burn-vision op","Keep QFloat tensors confined to the quantized inference segment","Add dtype assertions at pipeline stage boundaries"],"tags":["rust","vision","quantization","color","panic"],"backgroundTag":"unimplemented-op-panic","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"}