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

QKeras updates #30

Merged
merged 18 commits into from
May 27, 2020
Merged

QKeras updates #30

merged 18 commits into from
May 27, 2020

Conversation

thesps
Copy link

@thesps thesps commented May 12, 2020

New specific things:

  • Add an Optimizer pass to set the rounding / saturation mode for the layer output. This is necessary to get decent with performance with the low precision quantized_relu layers. The pass is effectively disabled by default, since it may not be necessary for quantized_relu layers with higher precision.
  • New softmax implementation. The softmax implementation was quite error prone, and contained several hard-coded values, so I have rewritten it. The new version also has an extra configurability: each LUT precision can be set independently. Although even without this configurability, the new version is more reliable.

thesps added 10 commits May 4, 2020 17:38
…Splitting hls_model.py into hls_model.py and hls_layers.py was necessary to remove circular import dependency from optimizers importing Layers and utilities, while hls_model now needs to import optimizer
…quantized_bits(4,0).max() is 1.0, whereas it would be 0.5 with ap_fixed. So, add 1 bit to the integer for ap_fixed types
… modes (required qkeras converter split for circular import), and hooks for rounding mode to IntegerPrecisionType, FixedPrecisionType.
@thesps
Copy link
Author

thesps commented May 12, 2020

The new softmax implementation needs to be propagated to the other converters. Since it is represented by a new layer class, we need to make sure the converter instantiates the right layer (the new Softmax, rather than `Activation).

thesps added 5 commits May 12, 2020 15:11
…imizer pass to factorize out alpha scale and insert new 'ApplyAlpha' (BatchNormalization) layer to apply it back. Attach data_unquantized to WeightVariables to retain access to them later (used in QKerasFactorizeAlpha pass)
…m optimizer. Fix other passes to prevent multiple matches.
…rom Integer type. Fix match in rounding, saturation optimizer pass, add layer name to match API.
@thesps
Copy link
Author

thesps commented May 18, 2020

I added the new softmax layer (with its two tables) to the other converters. I tested the onnx and TF models (successfully) but couldn't try to Pytorch one yet due to (I think) some issue with that model being from a much older Pytorch version.

@vloncar vloncar merged commit 30ca8d8 into vloncar:csim_integration May 27, 2020
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.

2 participants