Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
19914055
Unverified
Commit
19914055
authored
Sep 08, 2021
by
lin bin
Committed by
GitHub
Sep 08, 2021
Browse files
[Quantization] fix parameter assign problem of weight (#4138)
parent
681ccc59
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
nni/algorithms/compression/pytorch/quantization/quantizers.py
...algorithms/compression/pytorch/quantization/quantizers.py
+9
-1
No files found.
nni/algorithms/compression/pytorch/quantization/quantizers.py
View file @
19914055
...
...
@@ -253,7 +253,7 @@ class ObserverQuantizer(Quantizer):
module
.
weight_qmin
,
module
.
weight_qmax
)
delattr
(
module
,
'weight'
)
module
.
register_
paramet
er
(
'weight'
,
torch
.
nn
.
Parameter
(
quantized_weight
)
)
module
.
register_
buff
er
(
'weight'
,
quantized_weight
)
if
"input"
in
config
.
get
(
"quant_types"
,
[]):
scale
,
zero_point
=
self
.
calculate_qparams
(
layer
.
name
,
'input'
)
module
.
register_buffer
(
'input_scale'
,
scale
.
to
(
self
.
device
))
...
...
@@ -301,6 +301,14 @@ class ObserverQuantizer(Quantizer):
calibration_config
[
name
][
'tracked_min_weight'
]
=
-
val
calibration_config
[
name
][
'tracked_qmin_weight'
]
=
-
127
calibration_config
[
name
][
'tracked_qmax_weight'
]
=
127
weight
=
module
.
weight
quantized_weight
=
self
.
_quantize
(
weight
,
module
.
weight_scale
,
module
.
weight_zero_point
,
module
.
weight_qmin
,
module
.
weight_qmax
)
delattr
(
module
,
'weight'
)
module
.
register_parameter
(
'weight'
,
torch
.
nn
.
Parameter
(
quantized_weight
))
# refactor these magic numbers when customizations of dtype and qscheme are ready.
if
hasattr
(
module
,
'input_scale'
):
calibration_config
[
name
][
'input_bits'
]
=
8
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment