diff --git a/neural_compressor/utils/pytorch.py b/neural_compressor/utils/pytorch.py index ad2d090b0a8..dfa9433fe8d 100644 --- a/neural_compressor/utils/pytorch.py +++ b/neural_compressor/utils/pytorch.py @@ -482,7 +482,10 @@ def recover_model_from_json(model, json_file_path, example_inputs): ipex = LazyImport("intel_extension_for_pytorch") from torch.ao.quantization.observer import MinMaxObserver - qconfig = ipex.quantization.get_smooth_quant_qconfig_mapping(alpha=0.5, act_observer=MinMaxObserver()) + if ipex.__version__ >= "2.1.100": + qconfig = ipex.quantization.get_smooth_quant_qconfig_mapping(alpha=0.5, act_observer=MinMaxObserver) + else: + qconfig = ipex.quantization.get_smooth_quant_qconfig_mapping(alpha=0.5, act_observer=MinMaxObserver()) if isinstance(example_inputs, dict): model = ipex.quantization.prepare(model, qconfig, example_kwarg_inputs=example_inputs, inplace=True) else: