hls4ml icon indicating copy to clipboard operation
hls4ml copied to clipboard

Improve precision for non-power-of-2 scales in brevitas -> QONNX workflow and add pytests

Open JanFSchulte opened this issue 10 months ago • 0 comments

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-commit on the files I edited or added.
  • [x] I have added tests that prove my fix is effective or that my feature works.

JanFSchulte avatar Feb 24 '25 22:02 JanFSchulte