Skip to content

Commit

Permalink
Add version condition for IPEX prepare init (#1530)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
changwangss and pre-commit-ci[bot] authored Jan 11, 2024
1 parent 4239d36 commit d96e14a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion neural_compressor/utils/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d96e14a

Please sign in to comment.