From ce7789fa6547ef9d0387d2a2b1c11402cfb9ff78 Mon Sep 17 00:00:00 2001 From: eaidova Date: Wed, 4 Dec 2024 09:08:42 +0400 Subject: [PATCH] fix code style --- optimum/exporters/openvino/model_patcher.py | 8 ++++---- optimum/exporters/openvino/utils.py | 10 +++++++++- optimum/intel/openvino/modeling_base.py | 12 ++++++------ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/optimum/exporters/openvino/model_patcher.py b/optimum/exporters/openvino/model_patcher.py index af830849eb..86985a5a4e 100644 --- a/optimum/exporters/openvino/model_patcher.py +++ b/optimum/exporters/openvino/model_patcher.py @@ -3386,8 +3386,8 @@ class Qwen2VLLanguageModelPatcher(DecoderModelPatcher): def __init__( self, config: OnnxConfig, - model: PreTrainedModel | TFPreTrainedModel, - model_kwargs: Dict[str, Any] | None = None, + model: Union[PreTrainedModel, TFPreTrainedModel], + model_kwargs: Dict[str, Any] = None, ): model.__orig_forward = model.forward @@ -3426,8 +3426,8 @@ class Qwen2VLVisionEmbMergerPatcher(ModelPatcher): def __init__( self, config: OnnxConfig, - model: PreTrainedModel | TFPreTrainedModel, - model_kwargs: Dict[str, Any] | None = None, + model: Union[PreTrainedModel, TFPreTrainedModel], + model_kwargs: Dict[str, Any] = None, ): model.__orig_forward = model.forward diff --git a/optimum/exporters/openvino/utils.py b/optimum/exporters/openvino/utils.py index 5242db1d1a..9891395a38 100644 --- a/optimum/exporters/openvino/utils.py +++ b/optimum/exporters/openvino/utils.py @@ -216,7 +216,15 @@ def get_submodels(model): return custom_export, fn_get_submodels -MULTI_MODAL_TEXT_GENERATION_MODELS = ["llava", "llava-next", "llava-qwen2", "internvl-chat", "minicpmv", "phi3-v", "qwen2-vl"] +MULTI_MODAL_TEXT_GENERATION_MODELS = [ + "llava", + "llava-next", + "llava-qwen2", + "internvl-chat", + "minicpmv", + "phi3-v", + "qwen2-vl", +] def save_config(config, save_dir): diff --git a/optimum/intel/openvino/modeling_base.py b/optimum/intel/openvino/modeling_base.py index d5d5666891..75c3f4b3c3 100644 --- a/optimum/intel/openvino/modeling_base.py +++ b/optimum/intel/openvino/modeling_base.py @@ -111,9 +111,9 @@ def __init__( for idx, key in enumerate(model.inputs): names = tuple(key.get_names()) input_names[next((name for name in names if "/" not in name), names[0])] = idx - input_dtypes[ - next((name for name in names if "/" not in name), names[0]) - ] = key.get_element_type().get_type_name() + input_dtypes[next((name for name in names if "/" not in name), names[0])] = ( + key.get_element_type().get_type_name() + ) self.input_names = input_names self.input_dtypes = input_dtypes @@ -122,9 +122,9 @@ def __init__( for idx, key in enumerate(model.outputs): names = tuple(key.get_names()) output_names[next((name for name in names if "/" not in name), names[0])] = idx - output_dtypes[ - next((name for name in names if "/" not in name), names[0]) - ] = key.get_element_type().get_type_name() + output_dtypes[next((name for name in names if "/" not in name), names[0])] = ( + key.get_element_type().get_type_name() + ) self.output_names = output_names self.output_dtypes = output_dtypes