Skip to content

Conv1D support in hls_writer

Javier Duarte requested to merge jmgd/hls-writer-conv1d into master

First attempt at Conv1D layer support in hls_writer.py

There is still some issue with this though, where the CSIM fails for certain values of the hyperparameters of the first Conv1D layer. I committed two small example models to demonstrate this. One with the first Conv1D filter size of 4 (and 4 input channels) and the other with the first Conv1D filter size of 5 (and 4 input channels). The latter goes through CSIM without a problem, while the former fails CSIM. It seems to be related to the fact that the number of filters and the number of input channels is the same (it also fails for filter size of 5 with 5 input channels for example), but the issue is not so clear.

# filter size of 4
example-keras-model-files/KERAS_conv1d_small.json
example-keras-model-files/KERAS_conv1d_small_weights.h5
# filter size of 5
example-keras-model-files/KERAS_conv1d_small_nfilt5.json
example-keras-model-files/KERAS_conv1d_small_nfilt5_weights.h5

If you try to run it the default (filter size of 4):

python keras-to-hls.py -c keras-config.yml
cd my-hls-dir-test
vivado_hls -f build_prj.tcl 

you get this CSIM failure:

INFO: [SIM 211-2] *************** CSIM start ***************
INFO: [SIM 211-4] CSIM will launch GCC as the compiler.
   Compiling ../../../../myproject_test.cpp in debug mode
   Compiling ../../../../firmware/myproject.cpp in debug mode
In file included from ../../../../firmware/parameters.h:8:0,
                 from ../../../../firmware/myproject.cpp:21:
/home/jduarte1/hls-fpga-machine-learning/nnet_utils/nnet_conv.h: In function ‘void nnet::conv_1d(data_T (*)[CONFIG_T:: n_chan], res_T (*)[CONFIG_T:: n_filt], typename CONFIG_T::weight_t (*)[CONFIG_T:: n_chan][CONFIG_T:: n_filt], typename CONFIG_T::bias_t*) [with data_T = ap_fixed<18, 8>, res_T = ap_fixed<18, 8>, CONFIG_T = config1, typename CONFIG_T::weight_t = ap_fixed<18, 8>, typename CONFIG_T::bias_t = ap_fixed<18, 8>]’:
/home/jduarte1/hls-fpga-machine-learning/nnet_utils/nnet_conv.h:87:25: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make: *** [obj/myproject.o] Error 1
ERROR: [SIM 211-100] 'csim_design' failed: compilation error(s).
INFO: [SIM 211-3] *************** CSIM finish ***************
4
    while executing
"source [lindex $::argv 1] "
    ("uplevel" body line 1)
    invoked from within
"uplevel \#0 { source [lindex $::argv 1] } "

even though it compiles and runs outside of vivado_hls:

g++ -I/home/jduarte1/hls-fpga-machine-learning/nnet_utils -I/data/xilinx/Vivado_HLS/2016.4/include -I/data/xilinx/Vivado_HLS/2016.4/include/etc -I/data/xilinx/Vivado_HLS/2016.4/lnx64/tools/auto_cc/include -I/data/xilinx/Vivado_HLS/2016.4/include/ap_sysc -I/data/xilinx/Vivado_HLS/2016.4/lnx64/tools/systemc/include -I/home/jduarte1/hls-fpga-machine-learning/keras-to-hls/my-hls-dir-test -O0 -g3 -Wall -c -fmessage-length=0  myproject_test.cpp
g++ -I/home/jduarte1/hls-fpga-machine-learning/nnet_utils -I/data/xilinx/Vivado_HLS/2016.4/include -I/data/xilinx/Vivado_HLS/2016.4/include/etc -I/data/xilinx/Vivado_HLS/2016.4/lnx64/tools/auto_cc/include -I/data/xilinx/Vivado_HLS/2016.4/include/ap_sysc -I/data/xilinx/Vivado_HLS/2016.4/lnx64/tools/systemc/include -I/home/jduarte1/hls-fpga-machine-learning/keras-to-hls/my-hls-dir-test -O0 -g3 -Wall -c -fmessage-length=0  firmware/myproject.cpp 
g++ -o conv1d myproject_test.o myproject.o
./conv1d

If anyone @ejk43 @nhanvtran has a clue about what's going on let me and @benjaminkreis know!

Thanks!

Merge request reports

Loading