Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first prototype of integrating HGQ into QONNX. I wanted to get this PR in to discuss how we will process especially with the FINN backend and to start a discussion.
How is it done & Questions:
The
from_keras()
function was changed to check for HGQ models (what about mixed models?). The Proxy Model from HGQ works a bit differently then just having the quantization information in each layer. It is more adding quantization information after the layer which will be quantized. This layers areFixedPointQuantizer
. For qkeras the quantizers are replaced with the equivalent keras layers (e.g. q_conv2d --> conv2d). For now I added this option by replacing theFixedPointQuantizer
with a custonIdentity
layer but it is not used since just taking the pure proxy model is enough. Here one should do some cleanup but I was unsure what option is the best. After this process the quantizers are used to add a new op type layerFixedPoint
after eachFixedPointQuantizer
layer usingtf2onnx.convert.from_keras
(in the HGQ style). However, thisFixedPointQuantizer
are not needed after this process so I used thecleanup_model()
function to remove theseFixedPointQuantizer
and only keep the newFixedPoint
nodes.Tests:
tests/HGQ/test_hgq.py
: the test converts from HGQ to a Proxy Model (flat keras model) to a QONNX.ToDos: