Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading