Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version info to OpenVINO models #690

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions optimum/exporters/openvino/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
from optimum.exporters.onnx.convert import export_pytorch as export_pytorch_to_onnx
from optimum.exporters.onnx.convert import export_tensorflow as export_tensorflow_onnx
from optimum.exporters.utils import _get_submodels_and_export_configs
from optimum.intel.utils.import_utils import (
_optimum_intel_version,
_optimum_version,
_torch_version,
_transformers_version,
)
from optimum.utils import DEFAULT_DUMMY_SHAPES, is_diffusers_available
from optimum.utils.save_utils import maybe_save_preprocessors

Expand Down Expand Up @@ -81,6 +87,10 @@ def _save_model(model, path: str, ov_config: Optional["OVConfig"] = None):

compress_to_fp16 = ov_config.dtype == "fp16"

model.set_rt_info(_transformers_version, ["optimum", "transformers_version"])
model.set_rt_info(_torch_version, ["optimum", "pytorch_version"])
model.set_rt_info(_optimum_intel_version, ["optimum", "optimum_intel_version"])
model.set_rt_info(_optimum_version, ["optimum", "optimum_version"])
Copy link
Collaborator

@eaidova eaidova Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need also add info about nncf here?
and as some other libs may be used as model source for conversion (diffusers for sd, timm for image classification and sentence_transformers), I think it can be useful to provide this libs info too (if they are available or based on source lib for conversion)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for including NNCF version

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added NNCF, diffusers, timm, sentence-transformers and onnx (for models converted from ONNX). I prefer not to add them just when the dependency is available, it's a bit strange to me to have timm_version in a BERT model for example. For timm and diffusers I now get the library name from the model path. Seems to work well, but let me know if there is a better way.

save_model(model, path, compress_to_fp16)


Expand Down
1 change: 1 addition & 0 deletions optimum/intel/utils/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
STR_OPERATION_TO_FUNC = {">": op.gt, ">=": op.ge, "==": op.eq, "!=": op.ne, "<=": op.le, "<": op.lt}

_optimum_version = importlib_metadata.version("optimum")
_optimum_intel_version = importlib_metadata.version("optimum-intel")
Copy link
Collaborator

@eaidova eaidova Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not from optimum.intel.version import __version__?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the consistency with _optimum_version :) But also the importlib_metadata version gives the commit ID:

>>> from optimum.intel.version import __version__
>>> from optimum.intel.utils.import_utils import _optimum_intel_version
>>> __version__
'1.17.0.dev0'
>>> _optimum_intel_version
'1.17.0.dev0+9d58b66'


_transformers_available = importlib.util.find_spec("transformers") is not None
_transformers_version = "N/A"
Expand Down
Loading