Skip to content

Commit dd761ca

Browse files
Support NNCF 2.10
1 parent aca2b6c commit dd761ca

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

optimum/intel/openvino/configuration.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import nncf
2222
import torch
23+
from nncf.parameters import StrEnum
2324
from nncf.quantization.advanced_parameters import OverflowFix
2425
from transformers import PretrainedConfig
2526
from transformers.utils.quantization_config import QuantizationConfigMixin, QuantizationMethod
@@ -351,11 +352,12 @@ def __init__(
351352
"Please check your configuration."
352353
)
353354
super().__init__(ignored_scope, num_samples, False)
354-
# TODO: remove checks below once NNCF is updated to 2.10
355-
if isinstance(overflow_fix, str):
356-
overflow_fix = OverflowFix(overflow_fix)
357-
if isinstance(preset, str):
358-
preset = nncf.QuantizationPreset(preset)
355+
# TODO: remove code below once NNCF < 2.10 support is dropped
356+
if OverflowFix is not StrEnum:
357+
if isinstance(overflow_fix, str):
358+
overflow_fix = OverflowFix(overflow_fix)
359+
if isinstance(preset, str):
360+
preset = nncf.QuantizationPreset(preset)
359361

360362
self.preset = preset
361363
self.model_type = model_type
@@ -364,8 +366,8 @@ def __init__(
364366
self.post_init()
365367

366368
def to_dict(self) -> Dict[str, Any]:
367-
# TODO: remove code below once NNCF is updated to 2.10
368-
if isinstance(self.overflow_fix, Enum) or isinstance(self.preset, Enum):
369+
# TODO: remove code below once NNCF < 2.10 support is dropped
370+
if OverflowFix is not StrEnum:
369371
overflow_fix_value = (
370372
None
371373
if self.overflow_fix is None

0 commit comments

Comments
 (0)