diff --git a/tinynn/graph/quantization/quantizer.py b/tinynn/graph/quantization/quantizer.py index 55bfc6b7..09d6694b 100644 --- a/tinynn/graph/quantization/quantizer.py +++ b/tinynn/graph/quantization/quantizer.py @@ -3711,11 +3711,16 @@ def new_no_observer_set(): return new_no_observer_set - if LooseVersion(torch.__version__) >= LooseVersion("1.9.0"): + if LooseVersion(torch.__version__) >= LooseVersion("1.10.0"): orig_no_observer_set = sys.modules['torch.ao.quantization.quantize'].no_observer_set sys.modules['torch.ao.quantization.quantize'].no_observer_set = patch_observer_set( orig_no_observer_set ) + elif LooseVersion(torch.__version__) >= LooseVersion("1.9.0"): + orig_no_observer_set = torch.ao.quantization.quantization_mappings.no_observer_set + torch.ao.quantization.quantization_mappings.no_observer_set = patch_observer_set( + orig_no_observer_set + ) add_observer_func( graph.module,