Skip to content

Commit

Permalink
Enable print properties of compiled model (#1046)
Browse files Browse the repository at this point in the history
* print properties of compile model

* Enable print properties

* Remove duplicate logging
  • Loading branch information
wgzintel authored Dec 3, 2024
1 parent ad8a4cb commit ba45714
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions optimum/intel/openvino/modeling_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ def _compile_model(

compiled_model = core.compile_model(model, device.upper() if device is not None else device, config=ov_config)
if "OPENVINO_LOG_LEVEL" in os.environ and int(os.environ["OPENVINO_LOG_LEVEL"]) > 2:
logger.info(f"{device if device is not None else 'AUTO'} SUPPORTED_PROPERTIES:")
_print_compiled_model_properties(compiled_model)
return compiled_model

Expand Down Expand Up @@ -802,7 +801,6 @@ def _compile(self):
self.request = core.compile_model(self.model, self._device, self.ov_config)
# 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)

@property
Expand Down
1 change: 0 additions & 1 deletion optimum/intel/openvino/modeling_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,6 @@ def _compile(self):
self.request = core.compile_model(self.model, self._device, self.ov_config)
# 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)

def to(self, *args, device: Optional[str] = None, dtype: Optional[torch.dtype] = None):
Expand Down
2 changes: 0 additions & 2 deletions optimum/intel/openvino/modeling_seq2seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ def _compile(self):
self.request = core.compile_model(self.model, self._device, ov_config)
# 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)


Expand Down Expand Up @@ -691,7 +690,6 @@ def _compile(self):
self.request = compiled_model.create_infer_request()
# 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)


Expand Down
3 changes: 3 additions & 0 deletions optimum/intel/openvino/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ def _is_timm_ov_dir(model_dir):


def _print_compiled_model_properties(compiled_model):
cur_log_level = logger.getEffectiveLevel()
logger.setLevel(logging.INFO)
supported_properties = properties.supported_properties()
skip_keys = {"SUPPORTED_METRICS", "SUPPORTED_CONFIG_KEYS", supported_properties}
keys = set(compiled_model.get_property(supported_properties)) - skip_keys
Expand All @@ -222,6 +224,7 @@ def _print_compiled_model_properties(compiled_model):
logger.info(f" {device}: {Core().get_property(device, 'FULL_DEVICE_NAME')}")
except Exception:
logger.error("[error] Get FULL_DEVICE_NAME failed")
logger.setLevel(cur_log_level)


def np_to_pt_generators(np_object, device):
Expand Down

0 comments on commit ba45714

Please sign in to comment.