From 1f7c1d168b640ca5353b6d6203d42cbc9b91c614 Mon Sep 17 00:00:00 2001
From: Yaman Umuroglu <yamanu@xilinx.com>
Date: Fri, 26 Feb 2021 10:22:01 +0000
Subject: [PATCH] [Notebook] cybsec-3: minor deployment fixes

---
 .../3-build-accelerator-with-finn.ipynb       | 124 +++++++++++-------
 1 file changed, 75 insertions(+), 49 deletions(-)

diff --git a/notebooks/end2end_example/cybersecurity/3-build-accelerator-with-finn.ipynb b/notebooks/end2end_example/cybersecurity/3-build-accelerator-with-finn.ipynb
index 1a296654e..75b879cac 100644
--- a/notebooks/end2end_example/cybersecurity/3-build-accelerator-with-finn.ipynb
+++ b/notebooks/end2end_example/cybersecurity/3-build-accelerator-with-finn.ipynb
@@ -148,7 +148,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 16,
+   "execution_count": 3,
    "metadata": {},
    "outputs": [
     {
@@ -156,7 +156,7 @@
      "output_type": "stream",
      "text": [
       "Building dataflow accelerator from cybsec-mlp-ready.onnx\n",
-      "Intermediate outputs will be generated in /tmp/finn_dev_maltanar\n",
+      "Intermediate outputs will be generated in /tmp/finn_dev_ubuntu\n",
       "Final outputs will be generated in output_estimates_only\n",
       "Build log is at output_estimates_only/build_dataflow.log\n",
       "Running step: step_tidy_up [1/7]\n",
@@ -167,8 +167,8 @@
       "Running step: step_apply_folding_config [6/7]\n",
       "Running step: step_generate_estimate_reports [7/7]\n",
       "Completed successfully\n",
-      "CPU times: user 1.53 s, sys: 724 ms, total: 2.25 s\n",
-      "Wall time: 1.45 s\n"
+      "CPU times: user 1.84 s, sys: 599 ms, total: 2.44 s\n",
+      "Wall time: 1.77 s\n"
      ]
     },
     {
@@ -177,7 +177,7 @@
        "0"
       ]
      },
-     "execution_count": 16,
+     "execution_count": 3,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -196,14 +196,14 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 17,
+   "execution_count": 4,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "intermediate_models  report  time_per_step.json\r\n"
+      "build_dataflow.log  intermediate_models  report  time_per_step.json\r\n"
      ]
     }
    ],
@@ -213,7 +213,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 18,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [
     {
@@ -239,7 +239,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 19,
+   "execution_count": 6,
    "metadata": {},
    "outputs": [
     {
@@ -269,7 +269,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 20,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -282,7 +282,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 21,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
@@ -294,7 +294,7 @@
        " 'StreamingFCLayer_Batch_3': 64}"
       ]
      },
-     "execution_count": 21,
+     "execution_count": 8,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -314,7 +314,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 22,
+   "execution_count": 9,
    "metadata": {},
    "outputs": [
     {
@@ -347,7 +347,7 @@
        " 'total': {'BRAM_18K': 45.0, 'LUT': 10959.0, 'URAM': 0.0, 'DSP': 0.0}}"
       ]
      },
-     "execution_count": 22,
+     "execution_count": 9,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -373,7 +373,7 @@
     "\n",
     "Once we have a configuration that gives satisfactory estimates, we can move on to generating the accelerator. We can do this in different ways depending on how we want to integrate the accelerator into a larger system. For instance, if we have a larger streaming system built in Vivado or if we'd like to re-use this generated accelerator as an IP component in other projects, the `STITCHED_IP` output product is a good choice. We can also use the `OOC_SYNTH` output product to get post-synthesis resource and clock frequency numbers for our accelerator.\n",
     "\n",
-    "<font color=\"red\">**FPGA'21 tutorial:** These next builds will take about 10 minutes to complete since multiple calls to Vivado and a call to RTL simulation are involved. While this is running, you can examine the generated files with noVNC -- it is running on (your AWS URL):6080/vnc.html\n",
+    "<font color=\"red\">**FPGA'21 tutorial:** These next builds will take about 10 minutes to complete since multiple calls to Vivado and a call to RTL simulation are involved. While this is running, you can examine the generated files with noVNC -- it is running on **(your AWS URL):6080/vnc.html**\n",
     "\n",
     "* Once the `step_hls_codegen [8/16]` below is completed, you can view the generated HLS code under its own folder for each layer: `/tmp/finn_dev_ubuntu/code_gen_ipgen_StreamingFCLayer_Batch_XXXXXX`\n",
     "    \n",
@@ -383,9 +383,17 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 23,
+   "execution_count": 10,
    "metadata": {},
-   "outputs": [],
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Previous run results deleted!\n"
+     ]
+    }
+   ],
    "source": [
     "import finn.builder.build_dataflow as build\n",
     "import finn.builder.build_dataflow_config as build_cfg\n",
@@ -417,7 +425,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 24,
+   "execution_count": 11,
    "metadata": {},
    "outputs": [
     {
@@ -425,7 +433,7 @@
      "output_type": "stream",
      "text": [
       "Building dataflow accelerator from cybsec-mlp-ready.onnx\n",
-      "Intermediate outputs will be generated in /tmp/finn_dev_maltanar\n",
+      "Intermediate outputs will be generated in /tmp/finn_dev_ubuntu\n",
       "Final outputs will be generated in output_ipstitch_ooc_rtlsim\n",
       "Build log is at output_ipstitch_ooc_rtlsim/build_dataflow.log\n",
       "Running step: step_tidy_up [1/16]\n",
@@ -445,8 +453,8 @@
       "Running step: step_synthesize_bitfile [15/16]\n",
       "Running step: step_deployment_package [16/16]\n",
       "Completed successfully\n",
-      "CPU times: user 3.81 s, sys: 658 ms, total: 4.46 s\n",
-      "Wall time: 6min 23s\n"
+      "CPU times: user 4.76 s, sys: 710 ms, total: 5.47 s\n",
+      "Wall time: 8min 5s\n"
      ]
     },
     {
@@ -455,7 +463,7 @@
        "0"
       ]
      },
-     "execution_count": 24,
+     "execution_count": 11,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -481,19 +489,19 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 25,
+   "execution_count": 12,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "all_verilog_srcs.txt\t\t       ip\r\n",
-      "finn_vivado_stitch_proj.cache\t       make_project.sh\r\n",
-      "finn_vivado_stitch_proj.hw\t       make_project.tcl\r\n",
-      "finn_vivado_stitch_proj.ip_user_files  vivado.jou\r\n",
-      "finn_vivado_stitch_proj.srcs\t       vivado.log\r\n",
-      "finn_vivado_stitch_proj.xpr\r\n"
+      "all_verilog_srcs.txt\t\t       finn_vivado_stitch_proj.xpr\r\n",
+      "finn_vivado_stitch_proj.cache\t       ip\r\n",
+      "finn_vivado_stitch_proj.hw\t       make_project.sh\r\n",
+      "finn_vivado_stitch_proj.ip_user_files  make_project.tcl\r\n",
+      "finn_vivado_stitch_proj.sim\t       vivado.jou\r\n",
+      "finn_vivado_stitch_proj.srcs\t       vivado.log\r\n"
      ]
     }
    ],
@@ -510,7 +518,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 26,
+   "execution_count": 13,
    "metadata": {},
    "outputs": [
     {
@@ -535,7 +543,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 27,
+   "execution_count": 14,
    "metadata": {},
    "outputs": [
     {
@@ -543,7 +551,7 @@
      "output_type": "stream",
      "text": [
       "{\r\n",
-      "  \"vivado_proj_folder\": \"/tmp/finn_dev_maltanar/synth_out_of_context_g_urbes5/results_finn_design_wrapper\",\r\n",
+      "  \"vivado_proj_folder\": \"/tmp/finn_dev_ubuntu/synth_out_of_context_iut077er/results_finn_design_wrapper\",\r\n",
       "  \"LUT\": 8667.0,\r\n",
       "  \"FF\": 9063.0,\r\n",
       "  \"DSP\": 0.0,\r\n",
@@ -569,7 +577,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 28,
+   "execution_count": 15,
    "metadata": {},
    "outputs": [
     {
@@ -602,7 +610,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 29,
+   "execution_count": 16,
    "metadata": {},
    "outputs": [
     {
@@ -673,7 +681,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": 17,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -708,7 +716,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": 18,
    "metadata": {},
    "outputs": [
     {
@@ -716,7 +724,7 @@
      "output_type": "stream",
      "text": [
       "Building dataflow accelerator from cybsec-mlp-ready.onnx\n",
-      "Intermediate outputs will be generated in /tmp/finn_dev_maltanar\n",
+      "Intermediate outputs will be generated in /tmp/finn_dev_ubuntu\n",
       "Final outputs will be generated in output_final\n",
       "Build log is at output_final/build_dataflow.log\n",
       "Running step: step_tidy_up [1/16]\n",
@@ -736,8 +744,8 @@
       "Running step: step_synthesize_bitfile [15/16]\n",
       "Running step: step_deployment_package [16/16]\n",
       "Completed successfully\n",
-      "CPU times: user 3.66 s, sys: 892 ms, total: 4.56 s\n",
-      "Wall time: 17min 15s\n"
+      "CPU times: user 4.47 s, sys: 766 ms, total: 5.24 s\n",
+      "Wall time: 22min 13s\n"
      ]
     },
     {
@@ -746,7 +754,7 @@
        "0"
       ]
      },
-     "execution_count": 3,
+     "execution_count": 18,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -765,7 +773,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 19,
    "metadata": {},
    "outputs": [
     {
@@ -789,7 +797,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 20,
    "metadata": {},
    "outputs": [
     {
@@ -813,7 +821,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 21,
    "metadata": {},
    "outputs": [
     {
@@ -838,7 +846,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 22,
    "metadata": {},
    "outputs": [
     {
@@ -866,7 +874,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 23,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -875,7 +883,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 12,
+   "execution_count": 24,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -884,7 +892,25 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 13,
+   "execution_count": 25,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "driver.py\tfinn\t\t unsw_nb15_binarized.npz  validate.py\r\n",
+      "driver_base.py\truntime_weights  validate-unsw-nb15.py\r\n"
+     ]
+    }
+   ],
+   "source": [
+    "#! ls {final_output_dir}/deploy/driver"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 26,
    "metadata": {},
    "outputs": [
     {
@@ -893,7 +919,7 @@
        "'/workspace/finn/notebooks/end2end_example/cybersecurity/deploy-on-pynq.zip'"
       ]
      },
-     "execution_count": 13,
+     "execution_count": 26,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -907,7 +933,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "You can now download the created zipfile (File -> Open, mark the checkbox next to the `deploy-on-pynq.zip` and select Download from the toolbar), then copy it to your PYNQ board (for instance via `scp` or `rsync`). Then, run the following commands **on the PYNQ board** to extract the archive and run the validation:"
+    "You can now download the created zipfile (**File -> Open**, mark the checkbox next to the `deploy-on-pynq.zip` and select Download from the toolbar), then copy it to your PYNQ board (for instance via `scp` or `rsync`). Then, run the following commands **on the PYNQ board** to extract the archive and run the validation:"
    ]
   },
   {
-- 
GitLab