File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
tinynn/graph/quantization Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -3657,6 +3657,11 @@ def prepare_qat(
3657
3657
if hasattr (n .module , "qconfig" ):
3658
3658
delattr (n .module , "qconfig" )
3659
3659
3660
+ if hasattr (torch_q , 'add_observer_' ):
3661
+ add_observer_func = torch_q .add_observer_
3662
+ else :
3663
+ add_observer_func = sys .modules ['torch.ao.quantization.quantize' ]._add_observer_
3664
+
3660
3665
if LooseVersion (torch .__version__ ) >= LooseVersion ("1.8.0" ):
3661
3666
if LooseVersion (torch .__version__ ) >= LooseVersion ("1.13.0" ):
3662
3667
prepare_custom_config_dict = torch .ao .quantization .get_default_custom_config_dict ()
@@ -3667,13 +3672,13 @@ def prepare_qat(
3667
3672
"float_to_observed_custom_module_class" , {}
3668
3673
)
3669
3674
3670
- torch_q . add_observer_ (
3675
+ add_observer_func (
3671
3676
graph .module ,
3672
3677
qconfig_propagation_list = whitelist ,
3673
3678
custom_module_class_mapping = custom_module_class_mapping ,
3674
3679
)
3675
3680
else :
3676
- torch_q . add_observer_ (
3681
+ add_observer_func (
3677
3682
graph .module ,
3678
3683
qconfig_propagation_list = whitelist ,
3679
3684
)
You can’t perform that action at this time.
0 commit comments