-
Notifications
You must be signed in to change notification settings - Fork 478
Automatic type inference for param_t
in Parametrised Activations
#1139
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
Open
nghielme
wants to merge
16
commits into
main
Choose a base branch
from
leaky_relu_quant_alpha
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
11601cd
Added automatic inference of `param_t` constant for parametrised acti…
nghielme 72026fb
pre-commit fixes
nghielme 10ec7a2
Fix the case the param is a power of 2
nghielme 29f0831
Fix for a specific case related to no bits in the mantissa
nghielme ecf5c2c
Merge branch 'main' into leaky_relu_quant_alpha
nghielme 49e5a75
Merge branch 'main' into leaky_relu_quant_alpha
nghielme baba0f3
Merge branch 'main' into leaky_relu_quant_alpha
JanFSchulte 0808580
Merge branch 'main' into leaky_relu_quant_alpha
nghielme 79f7372
Update subproject commit reference in example-models
nghielme a4f5fa5
Merge branch 'main' into leaky_relu_quant_alpha
nghielme a39b3ef
Merge remote-tracking branch 'upstream/main' into leaky_relu_quant_alpha
jmitrevs 463acf7
first, untested version of constant precison
jmitrevs a8641d9
try using Fxp for precision setting
jmitrevs 8442c37
fix bug in max attribute of unsigned FixedPrecisionType
jmitrevs c7a6051
add unit test for precision from constant
jmitrevs 38e443c
Merge branch 'main' into leaky_relu_quant_alpha
JanFSchulte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Submodule example-models
updated
from c6bb3c to 6a82da
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this correctly, we are basically hard-coding the bit width of the parameter to be 8 (9 if signed) and assign the fractional and integer bits based on the value. Is that correct? Because trying to find a way to infer the needed total precision has been something that has stumped me forever when working on the brevitas stuff, but it seems that here as well the only solution is to hardcode some arbitrary value.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's mainly for those where the cases above don't apply. For 0 values we just use 1 bit. For power of 2 values we use a width of 1 or 2, depending on whether is negative or not. Then comes the attempt to use
Fxp
fromfxpmath
, which is logically likestruct
. It works well for values like1.25
of things that can be represented exactly. In those cases, the optimizer uses the width fromFxp
. But if that produces a width larger than 8 (not including the sign bit), then the size is capped at 8, with the appropriate range being set by the integer size. Note that Fxp would otherwise attempt to use 56 bits to store1.1
. These we cut off at 8 bits.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks. I think I will then implement something similar to the non-power-of-2 cases for brevitas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The optimizer can set negative integer bitwidths if it needs the precision for smaller values.