Skip to content

Commit

Permalink
refine code
Browse files Browse the repository at this point in the history
  • Loading branch information
wgzintel committed Dec 18, 2023
1 parent c818d7b commit 277f568
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions optimum/intel/openvino/modeling_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from ...exporters.openvino import export, main_export
from ..utils.import_utils import is_nncf_available, is_transformers_version
from .utils import ONNX_WEIGHTS_NAME, OV_XML_FILE_NAME, print_compiled_model_properties
from .utils import ONNX_WEIGHTS_NAME, OV_XML_FILE_NAME, _print_compiled_model_properties


if is_transformers_version("<", "4.25.0"):
Expand Down Expand Up @@ -349,7 +349,7 @@ def compile(self):
# OPENVINO_LOG_LEVEL can be found in https://docs.openvino.ai/2023.2/openvino_docs_OV_UG_supported_plugins_AUTO_debugging.html
if "OPENVINO_LOG_LEVEL" in os.environ and int(os.environ["OPENVINO_LOG_LEVEL"]) > 2:
logger.info(f"{self._device} SUPPORTED_PROPERTIES:")
print_compiled_model_properties(self.request)
_print_compiled_model_properties(self.request)

def _reshape(
self,
Expand Down
4 changes: 2 additions & 2 deletions optimum/intel/openvino/modeling_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from ...exporters.openvino import main_export
from .loaders import OVTextualInversionLoaderMixin
from .modeling_base import OVBaseModel
from .utils import ONNX_WEIGHTS_NAME, OV_TO_NP_TYPE, OV_XML_FILE_NAME, print_compiled_model_properties
from .utils import ONNX_WEIGHTS_NAME, OV_TO_NP_TYPE, OV_XML_FILE_NAME, _print_compiled_model_properties


core = Core()
Expand Down Expand Up @@ -543,7 +543,7 @@ def _compile(self):
# OPENVINO_LOG_LEVEL can be found in https://docs.openvino.ai/2023.2/openvino_docs_OV_UG_supported_plugins_AUTO_debugging.html
if "OPENVINO_LOG_LEVEL" in os.environ and int(os.environ["OPENVINO_LOG_LEVEL"]) > 2:
logger.info(f"{self.device} SUPPORTED_PROPERTIES:")
print_compiled_model_properties(self.request)
_print_compiled_model_properties(self.request)

@property
def device(self):
Expand Down
6 changes: 3 additions & 3 deletions optimum/intel/openvino/modeling_seq2seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from ..utils.import_utils import is_transformers_version
from .modeling_base_seq2seq import OVBaseModelForSeq2SeqLM
from .utils import print_compiled_model_properties
from .utils import _print_compiled_model_properties


if is_transformers_version("<", "4.25.0"):
Expand Down Expand Up @@ -412,7 +412,7 @@ def _compile(self):
# OPENVINO_LOG_LEVEL can be found in https://docs.openvino.ai/2023.2/openvino_docs_OV_UG_supported_plugins_AUTO_debugging.html
if "OPENVINO_LOG_LEVEL" in os.environ and int(os.environ["OPENVINO_LOG_LEVEL"]) > 2:
logger.info(f"{self._device} SUPPORTED_PROPERTIES:")
print_compiled_model_properties(self.request)
_print_compiled_model_properties(self.request)


class OVDecoder:
Expand Down Expand Up @@ -516,7 +516,7 @@ def _compile(self):
# OPENVINO_LOG_LEVEL can be found in https://docs.openvino.ai/2023.2/openvino_docs_OV_UG_supported_plugins_AUTO_debugging.html
if "OPENVINO_LOG_LEVEL" in os.environ and int(os.environ["OPENVINO_LOG_LEVEL"]) > 2:
logger.info(f"{self._device} SUPPORTED_PROPERTIES:")
print_compiled_model_properties(compiled_model)
_print_compiled_model_properties(compiled_model)


@add_start_docstrings(
Expand Down
24 changes: 12 additions & 12 deletions optimum/intel/openvino/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@ def _is_timm_ov_dir(model_dir):


def _print_compiled_model_properties(compiled_model):
properties = properties.supported_properties()
skip_keys = {"SUPPORTED_METRICS", "SUPPORTED_CONFIG_KEYS", properties}
keys = set(compiled_model.get_property(properties)) - skip_keys
supported_properties = properties.supported_properties()
skip_keys = {"SUPPORTED_METRICS", "SUPPORTED_CONFIG_KEYS", supported_properties}
keys = set(compiled_model.get_property(supported_properties)) - skip_keys
for k in keys:
value = compiled_model.get_property(k)
if k == properties.device.properties():
for device_key in value.keys():
logger.info(f" {device_key}:")
for k2, value2 in value.get(device_key).items():
if k2 not in skip_keys:
logger.info(f" {k2}: {value2}")
else:
logger.info(f" {k}: {value}")
value = compiled_model.get_property(k)
if k == properties.device.properties():
for device_key in value.keys():
logger.info(f" {device_key}:")
for k2, value2 in value.get(device_key).items():
if k2 not in skip_keys:
logger.info(f" {k2}: {value2}")
else:
logger.info(f" {k}: {value}")

0 comments on commit 277f568

Please sign in to comment.