File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -432,6 +432,7 @@ class StoreAttr(object):
432
432
for op in submodel .get_ops ():
433
433
if op .get_type_name () == "Constant" and op .get_element_type () in [Type .f16 , Type .f32 , Type .bf16 ]:
434
434
num_parameters += reduce (operator .mul , op .shape , 1 )
435
+ del op
435
436
if num_parameters >= _MAX_UNCOMPRESSED_SIZE :
436
437
if is_nncf_available ():
437
438
quantization_config = {"bits" : 8 , "sym" : False }
@@ -451,13 +452,14 @@ class StoreAttr(object):
451
452
452
453
if not is_nncf_available ():
453
454
raise ImportError ("Quantization of the weights requires nncf, please install it with `pip install nncf`" )
454
-
455
+
455
456
from optimum .intel .openvino .quantization import _weight_only_quantization
456
457
457
- _weight_only_quantization (submodel , quantization_config )
458
+ compressed_submodel = _weight_only_quantization (submodel , quantization_config )
458
459
459
460
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
461
463
del submodel
462
464
gc .collect ()
463
465
Original file line number Diff line number Diff line change 21
21
import weakref
22
22
from glob import glob
23
23
from pathlib import Path
24
- from tempfile import TemporaryDirectory as OrigTemporaryDirectory , mkdtemp
24
+ from tempfile import mkdtemp , TemporaryDirectory as OrigTemporaryDirectory
25
25
from typing import Tuple , Type , Union
26
26
27
27
import numpy as np
You can’t perform that action at this time.
0 commit comments