fastmachinelearning / hls4ml

Machine learning on FPGAs using HLS
https://fastmachinelearning.org/hls4ml
Apache License 2.0
1.24k stars 401 forks source link

Add support for parsing simple brevitas layers as part of pytorch models #1019

Open JanFSchulte opened 3 months ago

JanFSchulte commented 3 months ago

This PR adds support for the parsing of simple brevitas layers (QuantLinear, QuantActivation, QuantConv1D, QuantConv2D) to the pytorch parser. More complex models will still have to go through QONNX, but simple cases can be handled easily within the pytorch parser itself. To this end, this PR adds a new quantizer which only propagates the desired precision to the hsl4ml model, as brevitas already provides the quantized tensors which we pick up directly.

Type of change

For a new feature or function, please create an issue first to discuss it with us before submitting a pull request.

Note: Please delete options that are not relevant.

Tests

Tested locally with simple model and added pytests.

Checklist

JanFSchulte commented 3 months ago

pre-commit.ci autofix

jmitrevs commented 3 months ago

Do we need to add brevitas to our test environment docker image? Or can we just add brevitas as a testing dependency? I think that's why the test failed.

JanFSchulte commented 2 months ago

pre-commit.ci autofix