hls4ml
hls4ml copied to clipboard
Improve precision for non-power-of-2 scales in brevitas -> QONNX workflow and add pytests
Adds simple pytests for the brevitas -> QONNX -> hls4ml workflow.
Tested are models using both power-of-2 and non-power-of-2 scales. For the latter, the accuracy is generally poor, driven by insufficient precision for the scale variable in the rescaling operation. So far I have only come up with a stupid fix that chooses an arbitrary higher precision to improve things, and I would like to discuss better options to infer the required precision.
Type of change
- [x] Other (Specify)
Mostly adds tests
Tests
This PR adds the relevant pytests to test the brevitas -> QONNX -> hsl4ml workflow for a simple model with a linear layer and activation. More tests can be added, if desired.
Checklist
- [x] I have read the guidelines for contributing.
- [x] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have made corresponding changes to the documentation.
- [x] My changes generate no new warnings.
- [x] I have installed and run
pre-commiton the files I edited or added. - [x] I have added tests that prove my fix is effective or that my feature works.