Skip to content

Commit 42992c8

Browse files
committed
fix second case
1 parent 7ed547d commit 42992c8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

optimum/exporters/openvino/__main__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ class StoreAttr(object):
432432
for op in submodel.get_ops():
433433
if op.get_type_name() == "Constant" and op.get_element_type() in [Type.f16, Type.f32, Type.bf16]:
434434
num_parameters += reduce(operator.mul, op.shape, 1)
435+
del op
435436
if num_parameters >= _MAX_UNCOMPRESSED_SIZE:
436437
if is_nncf_available():
437438
quantization_config = {"bits": 8, "sym": False}
@@ -451,13 +452,14 @@ class StoreAttr(object):
451452

452453
if not is_nncf_available():
453454
raise ImportError("Quantization of the weights requires nncf, please install it with `pip install nncf`")
454-
455+
455456
from optimum.intel.openvino.quantization import _weight_only_quantization
456457

457-
_weight_only_quantization(submodel, quantization_config)
458+
compressed_submodel = _weight_only_quantization(submodel, quantization_config)
458459

459460
compressed_submodel_path = submodel_path.parent / f"{submodel_path.stem}_compressed.xml"
460-
save_model(submodel, compressed_submodel_path, compress_to_fp16=False)
461+
save_model(compressed_submodel, compressed_submodel_path, compress_to_fp16=False)
462+
del compressed_submodel
461463
del submodel
462464
gc.collect()
463465

optimum/intel/openvino/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import weakref
2222
from glob import glob
2323
from pathlib import Path
24-
from tempfile import TemporaryDirectory as OrigTemporaryDirectory, mkdtemp
24+
from tempfile import mkdtemp, TemporaryDirectory as OrigTemporaryDirectory
2525
from typing import Tuple, Type, Union
2626

2727
import numpy as np

0 commit comments

Comments
 (0)