Skip to content

Commit d96e14a

Browse files
Add version condition for IPEX prepare init (#1530)
* Update pytorch.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 4239d36 commit d96e14a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

neural_compressor/utils/pytorch.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,10 @@ def recover_model_from_json(model, json_file_path, example_inputs):
482482
ipex = LazyImport("intel_extension_for_pytorch")
483483
from torch.ao.quantization.observer import MinMaxObserver
484484

485-
qconfig = ipex.quantization.get_smooth_quant_qconfig_mapping(alpha=0.5, act_observer=MinMaxObserver())
485+
if ipex.__version__ >= "2.1.100":
486+
qconfig = ipex.quantization.get_smooth_quant_qconfig_mapping(alpha=0.5, act_observer=MinMaxObserver)
487+
else:
488+
qconfig = ipex.quantization.get_smooth_quant_qconfig_mapping(alpha=0.5, act_observer=MinMaxObserver())
486489
if isinstance(example_inputs, dict):
487490
model = ipex.quantization.prepare(model, qconfig, example_kwarg_inputs=example_inputs, inplace=True)
488491
else:

0 commit comments

Comments
 (0)