Skip to content

Commit dcfcc2a

Browse files
committed
Merge remote-tracking branch 'origin/main' into stateful
2 parents a85960a + 17bf770 commit dcfcc2a

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed

optimum/intel/openvino/modeling_base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from ...exporters.openvino import export, main_export
3232
from ..utils.import_utils import is_nncf_available, is_transformers_version
33-
from .utils import ONNX_WEIGHTS_NAME, OV_XML_FILE_NAME
33+
from .utils import ONNX_WEIGHTS_NAME, OV_XML_FILE_NAME, _print_compiled_model_properties
3434

3535

3636
if is_transformers_version("<", "4.25.0"):
@@ -350,6 +350,10 @@ def compile(self):
350350
ov_config["CACHE_DIR"] = str(cache_dir)
351351
logger.info(f"Setting OpenVINO CACHE_DIR to {str(cache_dir)}")
352352
self.request = core.compile_model(self.model, self._device, ov_config)
353+
# OPENVINO_LOG_LEVEL can be found in https://docs.openvino.ai/2023.2/openvino_docs_OV_UG_supported_plugins_AUTO_debugging.html
354+
if "OPENVINO_LOG_LEVEL" in os.environ and int(os.environ["OPENVINO_LOG_LEVEL"]) > 2:
355+
logger.info(f"{self._device} SUPPORTED_PROPERTIES:")
356+
_print_compiled_model_properties(self.request)
353357

354358
def _reshape(
355359
self,

optimum/intel/openvino/modeling_diffusion.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
from ...exporters.openvino import main_export
5656
from .loaders import OVTextualInversionLoaderMixin
5757
from .modeling_base import OVBaseModel
58-
from .utils import ONNX_WEIGHTS_NAME, OV_TO_NP_TYPE, OV_XML_FILE_NAME
58+
from .utils import ONNX_WEIGHTS_NAME, OV_TO_NP_TYPE, OV_XML_FILE_NAME, _print_compiled_model_properties
5959

6060

6161
core = Core()
@@ -544,6 +544,10 @@ def _compile(self):
544544
if self.request is None:
545545
logger.info(f"Compiling the {self._model_name} to {self.device} ...")
546546
self.request = core.compile_model(self.model, self.device, self.ov_config)
547+
# OPENVINO_LOG_LEVEL can be found in https://docs.openvino.ai/2023.2/openvino_docs_OV_UG_supported_plugins_AUTO_debugging.html
548+
if "OPENVINO_LOG_LEVEL" in os.environ and int(os.environ["OPENVINO_LOG_LEVEL"]) > 2:
549+
logger.info(f"{self.device} SUPPORTED_PROPERTIES:")
550+
_print_compiled_model_properties(self.request)
547551

548552
@property
549553
def device(self):

optimum/intel/openvino/modeling_seq2seq.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import copy
1616
import logging
17+
import os
1718
from pathlib import Path
1819
from tempfile import gettempdir
1920
from typing import TYPE_CHECKING, Dict, Optional, Tuple, Union
@@ -37,6 +38,7 @@
3738

3839
from ..utils.import_utils import is_transformers_version
3940
from .modeling_base_seq2seq import OVBaseModelForSeq2SeqLM
41+
from .utils import _print_compiled_model_properties
4042

4143

4244
if is_transformers_version("<", "4.25.0"):
@@ -472,6 +474,10 @@ def _compile(self):
472474
if self.request is None:
473475
logger.info(f"Compiling the encoder to {self._device} ...")
474476
self.request = core.compile_model(self.model, self._device, self.ov_config)
477+
# OPENVINO_LOG_LEVEL can be found in https://docs.openvino.ai/2023.2/openvino_docs_OV_UG_supported_plugins_AUTO_debugging.html
478+
if "OPENVINO_LOG_LEVEL" in os.environ and int(os.environ["OPENVINO_LOG_LEVEL"]) > 2:
479+
logger.info(f"{self._device} SUPPORTED_PROPERTIES:")
480+
_print_compiled_model_properties(self.request)
475481

476482

477483
class OVDecoder:
@@ -570,7 +576,12 @@ def __call__(self, *args, **kwargs):
570576
def _compile(self):
571577
if self.request is None:
572578
logger.info(f"Compiling the decoder to {self._device} ...")
573-
self.request = core.compile_model(self.model, self._device, self.ov_config).create_infer_request()
579+
compiled_model = core.compile_model(self.model, self._device, self.ov_config)
580+
self.request = compiled_model.create_infer_request()
581+
# OPENVINO_LOG_LEVEL can be found in https://docs.openvino.ai/2023.2/openvino_docs_OV_UG_supported_plugins_AUTO_debugging.html
582+
if "OPENVINO_LOG_LEVEL" in os.environ and int(os.environ["OPENVINO_LOG_LEVEL"]) > 2:
583+
logger.info(f"{self._device} SUPPORTED_PROPERTIES:")
584+
_print_compiled_model_properties(compiled_model)
574585

575586

576587
@add_start_docstrings(

optimum/intel/openvino/utils.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@
1414

1515

1616
import json
17+
import logging
1718
import os
1819
from glob import glob
1920

2021
import numpy as np
2122
from huggingface_hub import model_info
22-
from openvino.runtime import Type
23+
from openvino.runtime import Type, properties
2324
from transformers.onnx.utils import ParameterFormat, compute_serialized_parameters_size
2425

2526

27+
logger = logging.getLogger(__name__)
28+
2629
OV_XML_FILE_NAME = "openvino_model.xml"
2730
OV_ENCODER_NAME = "openvino_encoder_model.xml"
2831
OV_DECODER_NAME = "openvino_decoder_model.xml"
@@ -123,3 +126,19 @@ def _is_timm_ov_dir(model_dir):
123126
if hf_hub_id and model_info(hf_hub_id).library_name == "timm":
124127
return True
125128
return False
129+
130+
131+
def _print_compiled_model_properties(compiled_model):
132+
supported_properties = properties.supported_properties()
133+
skip_keys = {"SUPPORTED_METRICS", "SUPPORTED_CONFIG_KEYS", supported_properties}
134+
keys = set(compiled_model.get_property(supported_properties)) - skip_keys
135+
for k in keys:
136+
value = compiled_model.get_property(k)
137+
if k == properties.device.properties():
138+
for device_key in value.keys():
139+
logger.info(f" {device_key}:")
140+
for k2, value2 in value.get(device_key).items():
141+
if k2 not in skip_keys:
142+
logger.info(f" {k2}: {value2}")
143+
else:
144+
logger.info(f" {k}: {value}")

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
"neural-compressor>=2.2.0",
4242
"onnx",
4343
"onnxruntime<1.15.0",
44-
"transformers>=4.33.0",
44+
"transformers>=4.34.0",
4545
],
46-
"openvino": ["openvino>=2023.2", "onnx", "onnxruntime", "transformers>=4.33.0"],
46+
"openvino": ["openvino>=2023.2", "onnx", "onnxruntime", "transformers>=4.34.0"],
4747
"nncf": ["nncf>=2.7.0"],
4848
"ipex": ["transformers<4.32.0", "intel-extension-for-pytorch", "onnx"],
4949
"diffusers": ["diffusers"],

0 commit comments

Comments
 (0)