{"record":{"id":"b32ca2b997e3a2d3","repo":"tracel-ai/burn","slug":"quantized-float-is-not-supported-b32ca2","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/tensor.rs","lineNumber":96,"sourceCode":"            settings.int_dtype,\n        );\n\n        let stats = ConnectedStats {\n            area: Tensor::from_dispatch(stats.area),\n            left: Tensor::from_dispatch(stats.left),\n            top: Tensor::from_dispatch(stats.top),\n            right: Tensor::from_dispatch(stats.right),\n            bottom: Tensor::from_dispatch(stats.bottom),\n            max_label: Tensor::from_dispatch(stats.max_label),\n        };\n        (Tensor::from_dispatch(labels), stats)\n    }\n}\n\nimpl Morphology for Tensor<3, Float> {\n    fn erode(self, kernel: Tensor<2, Bool>, opts: MorphOptions) -> Self {\n        if matches!(self.dtype(), DType::QFloat(_)) {\n            unimplemented!(\"Quantized float is not supported\");\n        }\n\n        let out = <Dispatch as FloatVisionOps>::float_erode(\n            self.into_dispatch(),\n            kernel.into_dispatch(),\n            opts,\n        );\n        Tensor::from_dispatch(out)\n    }\n\n    fn dilate(self, kernel: Tensor<2, Bool>, opts: MorphOptions) -> Self {\n        if matches!(self.dtype(), DType::QFloat(_)) {\n            unimplemented!(\"Quantized float is not supported\");\n        }\n\n        let out = <Dispatch as FloatVisionOps>::float_dilate(\n            self.into_dispatch(),\n            kernel.into_dispatch(),","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-vision/src/tensor.rs#L78-L114","documentation":"burn-vision's erode() for Float tensors rejects quantized (DType::QFloat) inputs with unimplemented!(). The morphological erode kernel (float_erode on the Dispatch backend) is only implemented for native float dtypes, so quantized tensors are explicitly refused instead of producing wrong results.","triggerScenarios":"Calling `tensor.erode(kernel, opts)` on a Tensor<3, Float> whose dtype is DType::QFloat(_), i.e. a tensor produced by quantization (e.g. loaded from a quantized model checkpoint or converted via calibration).","commonSituations":"Running vision preprocessing/postprocessing (OpenCV-style morphology) on tensors that come out of a quantized inference pipeline; passing a quantized activation tensor directly into erode instead of dequantizing first.","solutions":["Dequantize the tensor before calling erode: `tensor.dequantize()` (or convert to a native float dtype) and call erode on the resulting float tensor.","Call erode on an Int tensor instead — the `impl Morphology for Tensor<3, Int>` path has no quantization restriction.","Quantize/erode/dequantize around the op: perform morphology on the float model output before the quantized stage of the pipeline."],"exampleFix":"// before\nlet eroded = quantized_tensor.erode(&kernel, opts); // panics: unimplemented!\n// after\nlet float_tensor = quantized_tensor.dequantize();\nlet eroded = float_tensor.erode(&kernel, opts);","handlingStrategy":"validation","validationCode":"if matches!(tensor.dtype(), burn::tensor::DType::QFloat(_)) {\n    tensor = tensor.dequantize(); // convert to native float before erode\n}\nlet eroded = tensor.erode(kernel, opts);","typeGuard":"fn is_quantized(t: &Tensor<3>) -> bool {\n    matches!(t.dtype(), burn::tensor::DType::QFloat(_))\n}","tryCatchPattern":null,"preventionTips":["Check tensor.dtype() before any burn-vision morphological op when working with quantized models.","Dequantize at pipeline boundaries; keep morphology ops in the float section of the pipeline.","Prefer the Int Morphology impl for integer image processing workloads."],"tags":["rust","burn","quantization","unimplemented"],"backgroundTag":"quantized-dtype-unsupported","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"}