Fixes: quantized_relu & unsigned profiling #405
Merged
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.
Note: bugfixes targeting release branch
quantized_relu
Since this change, we assign the wrong data type to
quantized_relu
activations. It sets the correct type forquantized_bits
, just notquantized_relu
. This is what causes the tests flagged in #377 to fail.Using the example of the hls4ml-tutorial Part3 QKeras model which uses
quantized_relu(6)
activations, on master branch we assignap_fixed<6,1>
. But appropriate choices would be insteadap_fixed<7,1>
(signed) orap_ufixed<6,0>
(unsigned). I've chosen to go for theap_ufixed
case for the fix since it uses fewer bits.You can see that the types we currently assign to the
relu
layers are wrong in the profiling:The model accuracy is:
ap_fixed<7,1>
was used instead)The synthesis results slightly prefer the
ap_ufixed
variation which has one fewer bit than the necessaryap_fixed
option.quantized_relu
precisionap_ufixed<6,0>
ap_fixed<7,1>
The
quantized_relu
tests now pass, so they are included again, resolving #377. I added a few more variations as well.unsigned
profiling
In fixing the above, I noticed that we don't display unsigned types correctly in the profiling, so I include the fix for that as well. (Separate commits in case they need to be taken separately).
Before (master):
After (this PR):