Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hgq/support for qonnx #123

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

makoeppel
Copy link
Contributor

@makoeppel makoeppel commented Jun 27, 2024

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 are FixedPointQuantizer. For qkeras the quantizers are replaced with the equivalent keras layers (e.g. q_conv2d --> conv2d). For now I added this option by replacing the FixedPointQuantizer with a custon Identity 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 layer FixedPoint after each FixedPointQuantizer layer using tf2onnx.convert.from_keras (in the HGQ style). However, this FixedPointQuantizer are not needed after this process so I used the cleanup_model() function to remove these FixedPointQuantizer and only keep the new FixedPoint nodes.

Tests:

  • tests/HGQ/test_hgq.py: the test converts from HGQ to a Proxy Model (flat keras model) to a QONNX.

ToDos:

  • The FINN backend needs to be figured out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant