From 7ef46dfc667dad891664cd7a0c8fb9e83bb5a9bb Mon Sep 17 00:00:00 2001
From: Hendrik Borras <hendrikborras@web.de>
Date: Tue, 12 Oct 2021 18:18:49 +0100
Subject: [PATCH] Raised default for max_multithreshold_bit_width from 4 to 8,
 due to missing quantization for 8-bit input test networks (CNV and
 mobilenet).

---
 src/finn/builder/build_dataflow_config.py                    | 4 ++--
 src/finn/transformation/qonnx/convert_qonnx_to_finn.py       | 4 ++--
 src/finn/transformation/qonnx/quant_act_to_multithreshold.py | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/finn/builder/build_dataflow_config.py b/src/finn/builder/build_dataflow_config.py
index 4d9184545..98c9b0fe7 100644
--- a/src/finn/builder/build_dataflow_config.py
+++ b/src/finn/builder/build_dataflow_config.py
@@ -300,8 +300,8 @@ class DataflowBuildConfig:
     #: only affects Quant nodes in the activation path. Quant nodes, which define a
     #: bit width larger than `max_multithreshold_bit_width` are not converted to
     #: MultiThreshold nodes and a warning is raised instead.
-    #: If not given `max_multithreshold_bit_width` defaults to 4.
-    max_multithreshold_bit_width: Optional[int] = 4
+    #: If not given `max_multithreshold_bit_width` defaults to 8.
+    max_multithreshold_bit_width: Optional[int] = 8
 
     def _resolve_hls_clk_period(self):
         if self.hls_clk_period_ns is None:
diff --git a/src/finn/transformation/qonnx/convert_qonnx_to_finn.py b/src/finn/transformation/qonnx/convert_qonnx_to_finn.py
index d4eba367c..641e76d8f 100644
--- a/src/finn/transformation/qonnx/convert_qonnx_to_finn.py
+++ b/src/finn/transformation/qonnx/convert_qonnx_to_finn.py
@@ -54,7 +54,7 @@ class ConvertQONNXtoFINN(Transformation):
     :param max_multithreshold_bit_width: The value of max_multithreshold_bit_width is
     checked against the bit width of any given Quant node and the transformation to a
     MultiTrheshold node is rejected, when the bitwidth of the Quant node is larger
-    than value of max_multithreshold_bit_with. Defaults to: 4
+    than value of max_multithreshold_bit_with. Defaults to: 8
     :type max_multithreshold_bit_width: `int`, optional
     :param filter_lambda: Each candidate Quant and BinaryQant node is first evaluated
     by this lambda function. If the function returns False,
@@ -64,7 +64,7 @@ class ConvertQONNXtoFINN(Transformation):
     """
 
     def __init__(
-        self, max_multithreshold_bit_width=4, filter_lambda=lambda q_node: True
+        self, max_multithreshold_bit_width=8, filter_lambda=lambda q_node: True
     ):
         super().__init__()
         self.max_multithreshold_bit_width = max_multithreshold_bit_width
diff --git a/src/finn/transformation/qonnx/quant_act_to_multithreshold.py b/src/finn/transformation/qonnx/quant_act_to_multithreshold.py
index cd203e63f..24b185796 100644
--- a/src/finn/transformation/qonnx/quant_act_to_multithreshold.py
+++ b/src/finn/transformation/qonnx/quant_act_to_multithreshold.py
@@ -47,7 +47,7 @@ class ConvertQuantActToMultiThreshold(Transformation):
     :param max_multithreshold_bit_width: The value of max_multithreshold_bit_width is
     checked against the bit width of any given Quant node and the transformation to a
     MultiTrheshold node is rejected, when the bitwidth of the Quant node is larger
-    than value of max_multithreshold_bit_with. Defaults to: 4
+    than value of max_multithreshold_bit_with. Defaults to: 8
     :type max_multithreshold_bit_width: `int`, optional
     :param filter_lambda: Each candidate Quant and BinaryQant node is first evaluated
     by this lambda function. If the function returns False,
@@ -57,7 +57,7 @@ class ConvertQuantActToMultiThreshold(Transformation):
     """
 
     def __init__(
-        self, max_multithreshold_bit_width=4, filter_lambda=lambda q_node: True
+        self, max_multithreshold_bit_width=8, filter_lambda=lambda q_node: True
     ):
         super().__init__()
         self.max_multithreshold_bit_width = max_multithreshold_bit_width
-- 
GitLab