DreamIP / haddoc2

Caffe to VHDL
https://dream.ispr-ip.fr/
BSD 2-Clause "Simplified" License
66 stars 28 forks source link

KERNEL_VALUE is mismatch! #5

Closed tuanho27 closed 5 years ago

tuanho27 commented 5 years ago

Hi, I have generated successfully vhdl code and tried to synthesis in Xilinx Vivado, but I got below false message: [Synth 8-421] mismatched array sizes in rhs and lhs of assignment [params.vhd:65] [Synth 8-78] a value must be associated with generic KERNEL_VALUE [cnn_process.vhd:89] [Synth 8-318] illegal unconstrained array generic 'KERNEL_VALUE' [cnn_process.vhd:89] [Synth 8-285] failed synthesizing module 'cnn_process' [cnn_process.vhd:27]

I see the number of KERNEL VALUE of the conv layer 2 is reduced by half and this causes the error, but I did not figure out the reason behind this? It makes me a little confused. Is there any suggestion?

KamelAbdelouahab commented 5 years ago

Hello,

Please try to compile your design with VHDL 2008. Refer to page 178 in the following document: https://www.xilinx.com/support/documentation/sw_manuals/xilinx2015_3/ug901-vivado-synthesis.pdf

tuanho27 commented 5 years ago

Well, thanks for the reply @KamelAbdelouahab, I've tried re-compile with VHDL 2008 but it does not work. As I mentioned, I checked the number KERNEL_VALUE for the convolution layer 2, it is decreased the amount by half. For example: --conv2 constant conv2_IMAGE_WIDTH : integer := 28 ; constant conv2_IN_SIZE : integer := 32 ; constant conv2_OUT_SIZE : integer := 64 ; constant conv2_KERNEL_SIZE : integer := 5 ; constant conv2_BIAS_VALUE : pixel_array (0 to conv2_OUT_SIZE - 1 ) := (); constant conv2_KERNEL_VALUE : pixel_matrix (0 to conv2_OUT_SIZE - 1 , 0 to conv2_IN_SIZE conv2_KERNEL_SIZE conv2_KERNEL_SIZE - 1) := ();

As we can see, conv2_KERNEL_VALUE must be defined with (0 to 63, 0 to 32 5 5 - 1) = (0 to 63, 0 to 799) matrix. But when I checked its value data in params.vhd, it is just a matrix (0 t 63, 0 to 399 ), this issue is the same when I change the models. Have you tried with the different models besides Lenet?

KamelAbdelouahab commented 5 years ago

Hi again,

I just added the "caffe" version of Lenet5 in the example directory (see https://github.com/KamelAbdelouahab/haddoc2/commit/ff326085b258a90e88b3fe9e0008937f5529671a) and generated the corresponding VHDL.

I haven't been confronted to any size mismatch. the conv2 layer (50x20x5x5) is represented as a (50, 20x5x5) matrix in the params.vhd

Maybe you're working with an "old" version of Haddoc2 ?? Good luck

tuanho27 commented 5 years ago

Hi @KamelAbdelouahab,

Thank you for your reply and make me clear with the configuration of Lenet. I figured out what's the problem. Since my conv2 layer set the group parameter = 2, which I think your framework did not support yet. So it makes the output param for this layer lacks a half value. //--------------------------- layer { name: "conv2" type: "Convolution" bottom: "pool1" top: "conv2" convolution_param { num_output: 64 kernel_size: 5 group: 2 <------------- } } -----------// I didn't look carefully on your comment of Todo list: Support conv layers with sparse connections (such AlexNet's conv2 layer, where each neuron is connected to only half of conv1 outputs i.e n_outputs(layer-1) != n_inputs(layer) )) Now, I changed my model without using this parameter and it works. Again, thank you for your great work.

All the best,