From 28cd2b05fe2199dfa3fc6eb82a25a1e9551d84b8 Mon Sep 17 00:00:00 2001
From: Yaman Umuroglu <maltanar@gmail.com>
Date: Wed, 17 Jun 2020 16:46:04 +0100
Subject: [PATCH] [Transform] check MaxPool padding before skipping

---
 src/finn/transformation/streamline/reorder.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/finn/transformation/streamline/reorder.py b/src/finn/transformation/streamline/reorder.py
index 3fe1ef242..9348f917b 100644
--- a/src/finn/transformation/streamline/reorder.py
+++ b/src/finn/transformation/streamline/reorder.py
@@ -546,11 +546,18 @@ class MoveMaxPoolPastMultiThreshold(Transformation):
             node_ind += 1
             if n.op_type == "MaxPool" and not model.is_fork_node(n):
                 consumer = model.find_consumer(n.output[0])
+                pads = get_by_name(n.attribute, "pads")
+                has_padding = False
+                if pads is not None:
+                    pads = list(pads.ints)
+                    has_padding = np.prod(pads) != 0
                 if consumer is not None and consumer.op_type == "MultiThreshold":
                     mt_out = consumer.output[0]
                     mt_odt = model.get_tensor_datatype(mt_out)
-                    if mt_odt.signed():
-                        warnings.warn("Skipping signed-output MultiThreshold")
+                    if mt_odt.signed() and has_padding:
+                        warnings.warn(
+                            "Skipping padded MaxPool + signed-output MultiThreshold"
+                        )
                         continue
 
                     # remove old nodes
-- 
GitLab