From bdce7541619cd36049607424819ee0a4fec17372 Mon Sep 17 00:00:00 2001
From: Hendrik Borras <hendrikborras@web.de>
Date: Fri, 1 Oct 2021 10:32:42 +0100
Subject: [PATCH] Fixed a potential bug where removing the FINN datatype on a
 tensor would also remove other quantization information.

---
 src/finn/transformation/convert_qonnx_to_finn.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/finn/transformation/convert_qonnx_to_finn.py b/src/finn/transformation/convert_qonnx_to_finn.py
index 814c7f059..d522d9387 100644
--- a/src/finn/transformation/convert_qonnx_to_finn.py
+++ b/src/finn/transformation/convert_qonnx_to_finn.py
@@ -346,7 +346,12 @@ class QuantActBaseHandler(ABC):
         # Unset the FINN datatype
         qnt_annotations = model._model_proto.graph.quantization_annotation
         ret = get_by_name(qnt_annotations, n.output[0], "tensor_name")
-        ret.Clear()
+        if ret is not None:
+            ret_dt = get_by_name(
+                ret.quant_parameter_tensor_names, "finn_datatype", "key"
+            )
+            if ret_dt is not None:
+                ret_dt.Clear()
         # ToDo: This should be supported by finn-base, by calling the following:
         # model.set_tensor_datatype(n.output[0], None)
 
-- 
GitLab