Skip to content

Vivado template restructure

Created by: yiiyama

  • C++ template reorganization: I wanted parameters.h to include the weights for GarNet (so that the config structs can refer to the weight arrays). To make this happen, header inclusions in the C++ templates have been shuffled:
    • Added a new file defines.h that has the hls-fpga-machine-learning insert numbers and hls-fpga-machine-learning insert layer-precision lines (originally in parameters.h)
    • Line hls-fpga-machine-learning insert weights is now in parameters.h
    • myproject.h includes defines.h
    • myproject.cpp includes parameters.h
    • myproject_test.cpp does not include parameters.h any more (it only needed the number macros and typedefs, which are now in defines.h and are included through myproject.h)
  • "include list": Making the list of included nnet_utils files model-specific.
    • Added an attribute include_list to the class Layer in hls_model.py
    • The layer include list is set in templates/vivado_template.py (with functions defined in templates/templates.py)
    • Added a template line hls-fpga-machine-learning insert includes to templates/vivado/firmware/parameters.h
    • keras_writer.py collects the layer include lists, uniqify them, and inserts the list to this template line in parameters.h
  • Array partitioning and reshape: Allowing layers in hls_model.py to specify how they want to partition / reshape the input and output arrays.
    • I suppose we don't want the vivado-specific #pragma HLS ... lines in hls_model.py any more (lines 375-393).
    • Instead we should just set the pragma attribute of each ArrayVariable object to simple keywords of 'partition', 'reshape', or 'stream', or to a tuple ('partition/reshape', 'complete/cyclic/block'[, factor]) in case of incomplete partitioning or reshaping.
    • vivado_writer.py then should pick this config up and form the #pragma HLS ... lines (added a helper function _make_array_pragma).
  • hls_model.py made compatible with multiple input layers: lines 679-685. Type for _i_th input array (i != 1) is named input[i]_t
  • Cosmetics in myproject_test.cpp: Using std::copy and std::fill_n to set the input and output array values

Merge request reports

Loading