"No known conversion for arguments" in zeropad*d_cl functions
Created by: GiuseppeDiGuglielmo
I attach a package that shows a compilation problem that we are encountering.
tar xvfz my-hls-test-baseline.tgz
cd my-hls-test-baseline
vivado_hls -f build_prj.tcl
Functions like zeropad2d_cl "redirect" an hls::stream to another: https://github.com/fastmachinelearning/hls4ml/blob/master/hls4ml/templates/vivado/nnet_utils/nnet_padding_stream.h#L54
There are situations where the type of the input (data_T) and output (res_T) are different. https://github.com/fastmachinelearning/hls4ml/blob/master/hls4ml/templates/vivado/nnet_utils/nnet_padding_stream.h#L37-L41
For example,
- the input comes from an activation function whose type is
nnet::array<ap_fixed<8, 4, (ap_q_mode)0u, (ap_o_mode)0u>, 8u>
- the output that goes to a convolutional layer is
nnet::array<ap_fixed<8, 4>, 8u>
In this kind of situations, the compiler would complain
In file included from ../../../../firmware/parameters.h:19:0,
from ../../../../firmware/resnet_v1_eembc.cpp:22:
../../../../firmware/nnet_utils/nnet_padding_stream.h: In instantiation of ‘void nnet::zeropad2d_cl(hls::stream<srcType>&, hls::stream<dstType>&) [with data_T = nnet::array<ap_fixed<8, 4, (ap_q_mode)0u, (ap_o_mode)0u>, 16u>; res_T = nnet::array<ap_fixed<8, 4>, 16u>; CONFIG_T = config43]’:
../../../../firmware/resnet_v1_eembc.cpp:113:78: required from here
../../../../firmware/nnet_utils/nnet_padding_stream.h:54:13: error: no matching function for call to ‘hls::stream<nnet::array<ap_fixed<8, 4>, 16u> >::write(nnet::array<ap_fixed<8, 4, (ap_q_mode)0u, (ap_o_mode)0u>, 16u>)’
res.write(data.read());
^~~
In file included from ../../../../firmware/resnet_v1_eembc.h:25:0,
from ../../../../firmware/resnet_v1_eembc.cpp:21:
/tools/Xilinx/Vivado/2019.1/include/hls_stream.h:224:10: note: candidate: void hls::stream<__STREAM_T__>::write(const __STREAM_T__&) [with __STREAM_T__ = nnet::array<ap_fixed<8, 4>, 16u>]
void write(const __STREAM_T__& tail) {
^~~~~
/tools/Xilinx/Vivado/2019.1/include/hls_stream.h:224:10: note: no known conversion for argument 1 from ‘nnet::array<ap_fixed<8, 4, (ap_q_mode)0u, (ap_o_mode)0u>, 16u>’ to ‘const nnet::array<ap_fixed<8, 4>, 16u>&’
The problem may be associated with the nnet::array
type which may not handle the assignment between different types:
https://github.com/fastmachinelearning/hls4ml/blob/master/hls4ml/templates/vivado/nnet_utils/nnet_types.h#L24-L26