thesps / conifer

Fast inference of Boosted Decision Trees in FPGAs
Apache License 2.0
48 stars 27 forks source link

Backend agreement #32

Closed thesps closed 2 years ago

thesps commented 2 years ago

The C++ and HLS backends agree well (checking the outputs from decision_function for the same input), relying on ap_fixed types to do the heavy lifting. The VHDL backend uses integer throughout and currently does not agree so well with the others. This PR goes part way to making the VHDL backend agree with the others by using the ap_fixed C++ to round/truncate/saturate as appropriate those values that are constant (thresholds, scores). A pybind11 adapter is written on the fly depending on the precision specified in configuration, called from the writer and decision function.

There are still cases where mismatches between C++ and VHDL can arise - e.g. when the output score saturates - that will be addressed in a later PR.