From b4d66ed42bd258cda7b78ef5fa9eff2bc546081a Mon Sep 17 00:00:00 2001
From: icolbert <Ian.Colbert@amd.com>
Date: Tue, 17 Jan 2023 09:17:12 -0800
Subject: [PATCH] Fixing if-else logic to make more sense

---
 src/finn/custom_op/fpgadataflow/matrixvectoractivation.py | 3 +--
 src/finn/custom_op/fpgadataflow/vectorvectoractivation.py | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/finn/custom_op/fpgadataflow/matrixvectoractivation.py b/src/finn/custom_op/fpgadataflow/matrixvectoractivation.py
index a1dff7a0a..2ac9ad286 100644
--- a/src/finn/custom_op/fpgadataflow/matrixvectoractivation.py
+++ b/src/finn/custom_op/fpgadataflow/matrixvectoractivation.py
@@ -652,8 +652,7 @@ class MatrixVectorActivation(HLSCustomOp):
 
     def minimize_weight_bit_width(self, model):
         """Minimize the bit width based on the values of the weights"""
-        runtime_writable = self.get_nodeattr("runtime_writeable_weights") == 0
-        if runtime_writable:
+        if not self.get_nodeattr("runtime_writeable_weights"):
             weights = model.get_initializer(self.onnx_node.input[1])
             w_min = weights.min()
             w_max = weights.max()
diff --git a/src/finn/custom_op/fpgadataflow/vectorvectoractivation.py b/src/finn/custom_op/fpgadataflow/vectorvectoractivation.py
index 5d97244e5..fd74a7b0c 100644
--- a/src/finn/custom_op/fpgadataflow/vectorvectoractivation.py
+++ b/src/finn/custom_op/fpgadataflow/vectorvectoractivation.py
@@ -171,8 +171,7 @@ class VectorVectorActivation(HLSCustomOp):
 
     def minimize_weight_bit_width(self, model):
         """Minimize the bit width based on the values of the weights"""
-        runtime_writable = self.get_nodeattr("runtime_writeable_weights") == 0
-        if runtime_writable:
+        if not self.get_nodeattr("runtime_writeable_weights"):
             weights = model.get_initializer(self.onnx_node.input[1])
             w_min = weights.min()
             w_max = weights.max()
-- 
GitLab