Skip to content

Commit

Permalink
Support NNCF 2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-savelyevv committed Apr 17, 2024
1 parent aca2b6c commit e88811d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions optimum/intel/openvino/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import nncf
import torch
from nncf.parameters import StrEnum
from nncf.quantization.advanced_parameters import OverflowFix
from transformers import PretrainedConfig
from transformers.utils.quantization_config import QuantizationConfigMixin, QuantizationMethod
Expand Down Expand Up @@ -351,11 +352,12 @@ def __init__(
"Please check your configuration."
)
super().__init__(ignored_scope, num_samples, False)
# TODO: remove checks below once NNCF is updated to 2.10
if isinstance(overflow_fix, str):
overflow_fix = OverflowFix(overflow_fix)
if isinstance(preset, str):
preset = nncf.QuantizationPreset(preset)
# TODO: remove code below once NNCF < 2.10 support is dropped
if OverflowFix is not StrEnum:
if isinstance(overflow_fix, str):
overflow_fix = OverflowFix(overflow_fix)
if isinstance(preset, str):
preset = nncf.QuantizationPreset(preset)

self.preset = preset
self.model_type = model_type
Expand All @@ -364,8 +366,8 @@ def __init__(
self.post_init()

def to_dict(self) -> Dict[str, Any]:
# TODO: remove code below once NNCF is updated to 2.10
if isinstance(self.overflow_fix, Enum) or isinstance(self.preset, Enum):
# TODO: remove code below once NNCF < 2.10 support is dropped
if OverflowFix is not StrEnum and (isinstance(self.overflow_fix, Enum) or isinstance(self.preset, Enum)):
overflow_fix_value = (
None
if self.overflow_fix is None
Expand Down

0 comments on commit e88811d

Please sign in to comment.