Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
distiller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
distiller
Commits
0ae07549
Commit
0ae07549
authored
6 years ago
by
Guy Jacob
Browse files
Options
Downloads
Patches
Plain Diff
Post-train quant bugfix: squeeze scale factor shape when quantizing bias
parent
1210f412
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
distiller/quantization/range_linear.py
+2
-2
2 additions, 2 deletions
distiller/quantization/range_linear.py
with
2 additions
and
2 deletions
distiller/quantization/range_linear.py
+
2
−
2
View file @
0ae07549
...
@@ -359,7 +359,7 @@ class RangeLinearQuantParamLayerWrapper(RangeLinearQuantWrapper):
...
@@ -359,7 +359,7 @@ class RangeLinearQuantParamLayerWrapper(RangeLinearQuantWrapper):
self
.
has_bias
=
hasattr
(
wrapped_module
,
'
bias
'
)
and
wrapped_module
.
bias
is
not
None
self
.
has_bias
=
hasattr
(
wrapped_module
,
'
bias
'
)
and
wrapped_module
.
bias
is
not
None
if
self
.
has_bias
:
if
self
.
has_bias
:
if
self
.
preset_act_stats
:
if
self
.
preset_act_stats
:
linear_quantize_clamp
(
wrapped_module
.
bias
.
data
,
self
.
accum_scale
,
0
,
linear_quantize_clamp
(
wrapped_module
.
bias
.
data
,
self
.
accum_scale
.
squeeze
()
,
0
,
self
.
accum_min_q_val
,
self
.
accum_max_q_val
,
inplace
=
True
)
self
.
accum_min_q_val
,
self
.
accum_max_q_val
,
inplace
=
True
)
else
:
else
:
b_scale
,
b_zero_point
=
_get_quant_params_from_tensor
(
wrapped_module
.
bias
,
num_bits_params
,
self
.
mode
)
b_scale
,
b_zero_point
=
_get_quant_params_from_tensor
(
wrapped_module
.
bias
,
num_bits_params
,
self
.
mode
)
...
@@ -387,7 +387,7 @@ class RangeLinearQuantParamLayerWrapper(RangeLinearQuantWrapper):
...
@@ -387,7 +387,7 @@ class RangeLinearQuantParamLayerWrapper(RangeLinearQuantWrapper):
if
self
.
has_bias
:
if
self
.
has_bias
:
# Re-quantize bias to match x * w scale: b_q' = (in_scale * w_scale / b_scale) * (b_q + b_zero_point)
# Re-quantize bias to match x * w scale: b_q' = (in_scale * w_scale / b_scale) * (b_q + b_zero_point)
self
.
wrapped_module
.
bias
.
data
=
linear_quantize_clamp
(
self
.
base_b_q
+
self
.
b_zero_point
,
self
.
wrapped_module
.
bias
.
data
=
linear_quantize_clamp
(
self
.
base_b_q
+
self
.
b_zero_point
,
self
.
accum_scale
/
self
.
b_scale
,
0
,
self
.
accum_scale
.
squeeze
()
/
self
.
b_scale
,
0
,
self
.
accum_min_q_val
,
self
.
accum_max_q_val
)
self
.
accum_min_q_val
,
self
.
accum_max_q_val
)
# Note the main terms within the summation is:
# Note the main terms within the summation is:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment