Skip to content

Commit

Permalink
Reference to benchmark_tool/openvino/tools/benchmark/main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wgzintel committed Dec 12, 2023
1 parent 457e563 commit 2560094
Show file tree
Hide file tree
Showing 2 changed files with 17 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_compile_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_compile_model_properties(self.request)
print_compiled_model_properties(self.request)


def _reshape(
Expand Down
32 changes: 15 additions & 17 deletions optimum/intel/openvino/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import numpy as np
from huggingface_hub import model_info
from openvino.runtime import Type
from openvino.runtime import Type,properties
from transformers.onnx.utils import ParameterFormat, compute_serialized_parameters_size


Expand Down Expand Up @@ -128,19 +128,17 @@ def _is_timm_ov_dir(model_dir):
return False


def param_to_string(parameters) -> str:
"""Convert a list / tuple of parameters returned from IE to a string."""
if isinstance(parameters, (list, tuple)):
return ', '.join([str(x) for x in parameters])
else:
return str(parameters)


def print_compile_model_properties(compile_model):
for property_key in compile_model.get_property('SUPPORTED_PROPERTIES'):
if property_key not in ('SUPPORTED_METRICS', 'SUPPORTED_CONFIG_KEYS', 'SUPPORTED_PROPERTIES'):
try:
property_val = compile_model.get_property(property_key)
except TypeError:
property_val = 'UNSUPPORTED TYPE'
logger.info(f'\t{property_key}: {param_to_string(property_val)}')
def print_compiled_model_properties(compiled_model):
keys = compiled_model.get_property(properties.supported_properties())
for k in keys:
skip_keys = ('SUPPORTED_METRICS', 'SUPPORTED_CONFIG_KEYS', properties.supported_properties())
if k not in skip_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}')

0 comments on commit 2560094

Please sign in to comment.