git clone https://github.com/hls-fpga-machine-learning/hls4ml -b tutorial
cd hls4ml
pip install . --user
pip install enum --user
cd example-models
export FAVOURITEMODEL=1layer
hls4ml convert -c keras-config-${FAVOURITEMODEL}.yml
This will create a folder called my-hls-test-${FAVOURITEMODEL}
. If you want to change the projectory directory name edit the yml configuration file.
hls4ml build -p my-hls-test-${FAVOURITEMODEL} -c -s
or alternatively:
cd my-hls-test-${FAVOURITEMODEL}
vivado_hls -f build_prj.tcl "csim=1 synth=1 cosim=0 export=0"
./print-reports.sh -d ./
Extract and compare area under the ROC curve from keras (floating point calculations) and HLS (fixed point calculations)
pip install scikit-learn matplotlib==1.5.3 --user
python extract_roc.py -c keras-config-${FAVOURITEMODEL}.yml
Change precision of calculations and reuse factor in the keras configuration file and check effect on NN performance (AUC) and FPGA resource usage using the scripts above.
ReuseFactor: N # N = number of times a multiplier is used to do a computation
DefaultPrecision: ap_fixed<X,Y> # X = total number of bits, Y = number of integer bits, X-Y = number of decimal bits
NB: suggest to change the project output directory in the keras configuration for each test to avoid overwriting of previous projects.