From ffb58df2a66d57734efa81023956389109c5bb7f Mon Sep 17 00:00:00 2001
From: Yaman Umuroglu <maltanar@gmail.com>
Date: Tue, 18 Aug 2020 23:14:31 +0200
Subject: [PATCH] [PYNQ] use metadata_prop bitfile for both Vitis and Zynq

---
 notebooks/end2end_example/tfc_end2end_example.ipynb     | 4 ++--
 src/finn/transformation/fpgadataflow/make_zynq_proj.py  | 2 +-
 src/finn/transformation/fpgadataflow/synth_pynq_proj.py | 4 +---
 src/finn/transformation/fpgadataflow/vitis_build.py     | 4 ++--
 tests/fpgadataflow/test_fpgadataflow_ipstitch.py        | 4 ++--
 5 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/notebooks/end2end_example/tfc_end2end_example.ipynb b/notebooks/end2end_example/tfc_end2end_example.ipynb
index c388feca2..7c6c70f24 100644
--- a/notebooks/end2end_example/tfc_end2end_example.ipynb
+++ b/notebooks/end2end_example/tfc_end2end_example.ipynb
@@ -1379,7 +1379,7 @@
        "value: \"/tmp/finn_dev_jakobap/vivado_pynq_proj_ljn53hfs\"\n",
        ", key: \"vivado_synth_rpt\"\n",
        "value: \"/tmp/finn_dev_jakobap/vivado_pynq_proj_ljn53hfs/synth_report.xml\"\n",
-       ", key: \"vivado_pynq_bitfile\"\n",
+       ", key: \"bitfile\"\n",
        "value: \"/tmp/finn_dev_jakobap/vivado_pynq_proj_ljn53hfs/resizer.bit\"\n",
        "]"
       ]
@@ -1670,7 +1670,7 @@
        "value: \"/tmp/finn_dev_jakobap/vivado_pynq_proj_ljn53hfs\"\n",
        ", key: \"vivado_synth_rpt\"\n",
        "value: \"/tmp/finn_dev_jakobap/vivado_pynq_proj_ljn53hfs/synth_report.xml\"\n",
-       ", key: \"vivado_pynq_bitfile\"\n",
+       ", key: \"bitfile\"\n",
        "value: \"/tmp/finn_dev_jakobap/vivado_pynq_proj_ljn53hfs/resizer.bit\"\n",
        ", key: \"pynq_driver_dir\"\n",
        "value: \"/tmp/finn_dev_jakobap/pynq_driver_j_9suyqm\"\n",
diff --git a/src/finn/transformation/fpgadataflow/make_zynq_proj.py b/src/finn/transformation/fpgadataflow/make_zynq_proj.py
index 1558d7399..0aaf65f40 100644
--- a/src/finn/transformation/fpgadataflow/make_zynq_proj.py
+++ b/src/finn/transformation/fpgadataflow/make_zynq_proj.py
@@ -249,7 +249,7 @@ class MakeZYNQProject(Transformation):
         deploy_bitfile_name = vivado_pynq_proj_dir + "/resizer.bit"
         copy(bitfile_name, deploy_bitfile_name)
         # set bitfile attribute
-        model.set_metadata_prop("vivado_pynq_bitfile", deploy_bitfile_name)
+        model.set_metadata_prop("bitfile", deploy_bitfile_name)
         # set platform attribute for correct remote execution
         model.set_metadata_prop("platform", "zynq-iodma")
         hwh_name = (
diff --git a/src/finn/transformation/fpgadataflow/synth_pynq_proj.py b/src/finn/transformation/fpgadataflow/synth_pynq_proj.py
index d7f73a7fe..54c9c805c 100644
--- a/src/finn/transformation/fpgadataflow/synth_pynq_proj.py
+++ b/src/finn/transformation/fpgadataflow/synth_pynq_proj.py
@@ -50,8 +50,6 @@ class SynthPYNQProject(Transformation):
         process_compile = subprocess.Popen(bash_command, stdout=subprocess.PIPE)
         process_compile.communicate()
         # set bitfile attribute
-        model.set_metadata_prop(
-            "vivado_pynq_bitfile", vivado_pynq_proj_dir + "/resizer.bit"
-        )
+        model.set_metadata_prop("bitfile", vivado_pynq_proj_dir + "/resizer.bit")
         # TODO pull out synthesis statistics and put them in as attributes
         return (model, False)
diff --git a/src/finn/transformation/fpgadataflow/vitis_build.py b/src/finn/transformation/fpgadataflow/vitis_build.py
index 2df58c537..cb9182c23 100644
--- a/src/finn/transformation/fpgadataflow/vitis_build.py
+++ b/src/finn/transformation/fpgadataflow/vitis_build.py
@@ -160,7 +160,7 @@ class CreateVitisXO(Transformation):
 class VitisLink(Transformation):
     """Create an XCLBIN with Vitis.
 
-    Outcome if successful: sets the vitis_xclbin attribute in the ONNX
+    Outcome if successful: sets the bitfile attribute in the ONNX
     ModelProto's metadata_props field with the XCLBIN full path as value.
     """
 
@@ -259,7 +259,7 @@ class VitisLink(Transformation):
         assert os.path.isfile(xclbin), (
             "Vitis .xclbin file not created, check logs under %s" % link_dir
         )
-        model.set_metadata_prop("vitis_xclbin", xclbin)
+        model.set_metadata_prop("bitfile", xclbin)
         return (model, False)
 
 
diff --git a/tests/fpgadataflow/test_fpgadataflow_ipstitch.py b/tests/fpgadataflow/test_fpgadataflow_ipstitch.py
index 66b0ef921..75a67f350 100644
--- a/tests/fpgadataflow/test_fpgadataflow_ipstitch.py
+++ b/tests/fpgadataflow/test_fpgadataflow_ipstitch.py
@@ -333,7 +333,7 @@ def test_fpgadataflow_ipstitch_pynq_synth():
         ip_stitch_model_dir + "/test_fpgadataflow_pynq_projgen.onnx"
     )
     model = model.transform(SynthPYNQProject())
-    bitfile = model.get_metadata_prop("vivado_pynq_bitfile")
+    bitfile = model.get_metadata_prop("bitfile")
     assert bitfile is not None
     assert os.path.isfile(bitfile)
     model.save(ip_stitch_model_dir + "/test_fpgadataflow_ipstitch_pynq_synth.onnx")
@@ -463,7 +463,7 @@ def test_fpgadataflow_ipstitch_zynqbuild(board):
     model = model.transform(ZynqBuild(board, 10))
     model.save(ip_stitch_model_dir + "/test_fpgadataflow_ipstitch_customzynq.onnx")
 
-    bitfile_name = model.get_metadata_prop("vivado_pynq_bitfile")
+    bitfile_name = model.get_metadata_prop("bitfile")
     assert bitfile_name is not None
     assert os.path.isfile(bitfile_name)
     # deployment
-- 
GitLab