Skip to content

Commit 5872620

Browse files
authored
add neural_compressor version check (#1595)
* add neural_compressor version check * modify error message
1 parent b2983b4 commit 5872620

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

examples/cpu/features/int8_recipe_tuning/imagenet_autotune.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def eval_func(model):
126126
images = images.contiguous(memory_format=torch.channels_last)
127127
traced_model = torch.jit.trace(converted_model, images)
128128
traced_model = torch.jit.freeze(traced_model)
129+
traced_model(images)
130+
traced_model(images)
129131
break
130132

131133
eval_func(traced_model)
@@ -166,7 +168,7 @@ def main(args):
166168
' (default: resnet18)')
167169
parser.add_argument('-j', '--workers', default=4, type=int, metavar='N',
168170
help='number of data loading workers (default: 4)')
169-
parser.add_argument('-b', '--batch-size', default=56, type=int,
171+
parser.add_argument('-b', '--batch-size', default=256, type=int,
170172
metavar='N',
171173
help='mini-batch size (default: 256), this is the total '
172174
'batch size of all GPUs on the current node when '

intel_extension_for_pytorch/quantization/_autotune.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ def autotune(prepared_model, calib_dataloader, eval_func, sampling_sizes=[100],
2424
Returns:
2525
FP32 tuned model (torch.nn.Module)
2626
"""
27+
neural_compressor_version = '1.14.1'
2728
try:
2829
import neural_compressor
30+
if neural_compressor.__version__ != neural_compressor_version:
31+
raise RuntimeError("Please install Intel® Neural Compressor with version {} while the current version of Intel® Neural Compressor is {}.".format(neural_compressor_version, neural_compressor.__version__))
2932
except ImportError:
3033
try:
31-
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'neural_compressor==1.14.1'])
34+
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'neural_compressor=={}'.format(neural_compressor_version)])
3235
import neural_compressor
3336
except:
3437
assert False, "Unable to import neural_compressor from the local environment."

0 commit comments

Comments
 (0)