Skip to content

Commit

Permalink
Merge pull request #91 from jmitrevs/cnn_fix
Browse files Browse the repository at this point in the history
fix some overlooked issues with cnn tutorial
  • Loading branch information
JanFSchulte authored Dec 17, 2024
2 parents 96dd631 + 23c97aa commit 29a7f7e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions part6_cnns.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import time\n",
Expand Down Expand Up @@ -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 ``<kernel height - 1>`` rows of input pixels, and maintains a shifting snapshot of the convolution kernel.\n",
Expand Down Expand Up @@ -678,10 +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'\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,\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()"
]
Expand Down Expand Up @@ -878,10 +881,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",
Expand Down Expand Up @@ -1320,7 +1319,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.16"
"version": "3.11.11"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 29a7f7e

Please sign in to comment.