From bb40bbc21fcca71c4db43181567fe3cac721e229 Mon Sep 17 00:00:00 2001 From: Jovan Mitrevski Date: Mon, 16 Dec 2024 15:24:43 -0600 Subject: [PATCH 1/2] fix some overlooked issues with cnn tutorial --- part6_cnns.ipynb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/part6_cnns.ipynb b/part6_cnns.ipynb index 7beb4bbb..582e3cfa 100644 --- a/part6_cnns.ipynb +++ b/part6_cnns.ipynb @@ -38,6 +38,7 @@ "metadata": {}, "outputs": [], "source": [ + "import os\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import time\n", @@ -645,10 +646,10 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now, we need to define the hls4ml and Vivado configurations. Two things will change with respect to what was done in the previous exercises. First, we will use ``IOType= 'io_stream'`` in the Vivado configuration.\n", + "Now, we need to define the hls4ml and Vivado configurations. Two things will change with respect to what was done in the previous exercises. First, we will use ``io_type='io_stream'`` in the Vitis_HLS configuration.\n", "\n", "---\n", - "****You must use ``IOType= 'io_stream'`` if attempting to synthesize a large convolutional neural network.****\n", + "****You must use ``io_type='io_stream'`` if attempting to synthesize a large convolutional neural network.****\n", "\n", "---\n", "The CNN implementation in hls4ml is based on streams, which are synthesized in hardware as first in, first out (FIFO) buffers. Shift registers are used to keep track of the last ```` rows of input pixels, and maintains a shifting snapshot of the convolution kernel.\n", @@ -678,10 +679,7 @@ "\n", "\n", "hls_model = hls4ml.converters.convert_from_keras_model(\n", - " model, hls_config=hls_config, backend='Vitis', output_dir='model_1/hls4ml_prj', part='xcu250-figd2104-2L-e'\n", - ")\n", - "hls_model = hls4ml.converters.keras_to_hls(\n", - " model, config=hls_config, output_dir='pruned_cnn', backend='Vitis', part='xcu250-figd2104-2L-e', io_type='io_stream'\n", + " model, hls_config=hls_config, backend='Vitis', output_dir='model_1/hls4ml_prj', part='xcu250-figd2104-2L-e', io_type='io_stream'\n", ")\n", "hls_model.compile()" ] @@ -878,10 +876,6 @@ "metadata": {}, "outputs": [], "source": [ - "import os\n", - "\n", - "os.environ['PATH'] = '/opt/Xilinx//Vitis_HLS/2024.1/bin:' + os.environ['PATH']\n", - "\n", "synth = False # Only if you want to synthesize the models yourself (>1h per model) rather than look at the provided reports.\n", "if synth:\n", " hls_model.build(csim=False, synth=True, vsynth=True)\n", @@ -1320,7 +1314,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.16" + "version": "3.11.11" } }, "nbformat": 4, From 23c97aa9258ae899e3282582dffa85a77cf77288 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:29:59 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit hooks --- part6_cnns.ipynb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/part6_cnns.ipynb b/part6_cnns.ipynb index 582e3cfa..4a8bda60 100644 --- a/part6_cnns.ipynb +++ b/part6_cnns.ipynb @@ -679,7 +679,12 @@ "\n", "\n", "hls_model = hls4ml.converters.convert_from_keras_model(\n", - " model, hls_config=hls_config, backend='Vitis', output_dir='model_1/hls4ml_prj', part='xcu250-figd2104-2L-e', io_type='io_stream'\n", + " model,\n", + " hls_config=hls_config,\n", + " backend='Vitis',\n", + " output_dir='model_1/hls4ml_prj',\n", + " part='xcu250-figd2104-2L-e',\n", + " io_type='io_stream',\n", ")\n", "hls_model.compile()" ]