From 1e74c0ae68a3516c9593b496787a73e0515c0fb0 Mon Sep 17 00:00:00 2001 From: peterjc123 Date: Fri, 31 May 2024 10:49:41 +0800 Subject: [PATCH] [CI] fix patch_observer_set for PT 1.9 (#321) --- tinynn/graph/quantization/quantizer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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,