From 6058ff13197f8c1f36b31e932038982ed2c01018 Mon Sep 17 00:00:00 2001
From: Yaman Umuroglu <maltanar@gmail.com>
Date: Thu, 3 Sep 2020 01:18:03 +0200
Subject: [PATCH] [Transform] don't run PrepareIP on nodes with output products

---
 src/finn/transformation/fpgadataflow/prepare_ip.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/finn/transformation/fpgadataflow/prepare_ip.py b/src/finn/transformation/fpgadataflow/prepare_ip.py
index 7d5da9400..21f8e0052 100644
--- a/src/finn/transformation/fpgadataflow/prepare_ip.py
+++ b/src/finn/transformation/fpgadataflow/prepare_ip.py
@@ -31,6 +31,7 @@ import finn.custom_op.registry as registry
 from finn.transformation import Transformation
 from finn.util.basic import make_build_dir
 from finn.util.fpgadataflow import is_fpgadataflow_node
+import warnings
 
 
 def _codegen_single_node(node, model, fpgapart, clk):
@@ -49,8 +50,10 @@ def _codegen_single_node(node, model, fpgapart, clk):
                 prefix="code_gen_ipgen_" + str(node.name) + "_"
             )
             inst.set_nodeattr("code_gen_dir_ipgen", code_gen_dir)
-        # ensure that there is generated code inside the dir
-        inst.code_generation_ipgen(model, fpgapart, clk)
+            # ensure that there is generated code inside the dir
+            inst.code_generation_ipgen(model, fpgapart, clk)
+        else:
+            warnings.warn("Using pre-existing code for %s" % node.name)
     except KeyError:
         # exception if op_type is not supported
         raise Exception("Custom op_type %s is currently not supported." % op_type)
@@ -66,6 +69,9 @@ class PrepareIP(Transformation):
 
     * clk in ns (int)
 
+    Any nodes that already have a code_gen_dir_ipgen attribute pointing to a valid path
+    will be skipped.
+
     Outcome if succesful: Node attribute "code_gen_dir_ipgen" contains path to folder
     that contains generated C++ code that can be used to generate a Vivado IP block.
     The subsequent transformation is HLSSynthIP"""
-- 
GitLab