Added test for checking lib sizes, when using conditional compilation option (#4292)
This commit is contained in:
parent
38d16e24e9
commit
a382934a80
@ -58,6 +58,11 @@ def pytest_addoption(parser):
|
|||||||
type=Path,
|
type=Path,
|
||||||
help="Artifacts directory where tests write output or read input",
|
help="Artifacts directory where tests write output or read input",
|
||||||
)
|
)
|
||||||
|
parser.addoption(
|
||||||
|
"--openvino_ref",
|
||||||
|
type=Path,
|
||||||
|
help="Path to root directory with installed OpenVINO",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
@ -103,3 +108,9 @@ def collector_dir(request):
|
|||||||
def artifacts(request):
|
def artifacts(request):
|
||||||
"""Fixture function for command-line option."""
|
"""Fixture function for command-line option."""
|
||||||
return request.config.getoption("artifacts")
|
return request.config.getoption("artifacts")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def openvino_root_dir(request):
|
||||||
|
"""Fixture function for command-line option."""
|
||||||
|
return request.config.getoption("openvino_ref")
|
||||||
|
38
tests/conditional_compilation/test_size_tracking.py
Normal file
38
tests/conditional_compilation/test_size_tracking.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from path_utils import get_lib_path # pylint: disable=import-error
|
||||||
|
|
||||||
|
|
||||||
|
def get_lib_sizes(path, libraries):
|
||||||
|
"""Function for getting lib sizes by lib names"""
|
||||||
|
assert Path.exists(path), f'Directory {path} isn\'t created'
|
||||||
|
result = {}
|
||||||
|
error_lib = []
|
||||||
|
for lib in libraries:
|
||||||
|
try:
|
||||||
|
result[lib] = Path(path).joinpath(get_lib_path(lib)).stat().st_size
|
||||||
|
except FileNotFoundError as error:
|
||||||
|
error_lib.append(str(error))
|
||||||
|
assert len(error_lib) == 0, 'Following libraries couldn\'t be found: \n{}'.format('\n'.join(error_lib))
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def test_size_tracking_libs(openvino_root_dir, test_id, model, artifacts):
|
||||||
|
log = logging.getLogger('size_tracking')
|
||||||
|
libraries = ['inference_engine_transformations', 'MKLDNNPlugin', 'ngraph']
|
||||||
|
|
||||||
|
ref_libs_size = get_lib_sizes(openvino_root_dir, libraries)
|
||||||
|
install_prefix = artifacts / test_id / 'install_pkg'
|
||||||
|
lib_sizes = get_lib_sizes(install_prefix, libraries)
|
||||||
|
|
||||||
|
for lib in libraries:
|
||||||
|
lib_size_diff = ref_libs_size[lib] - lib_sizes[lib]
|
||||||
|
lib_size_diff_percent = lib_size_diff / ref_libs_size[lib] * 100
|
||||||
|
log.info('{}: old - {}kB; new - {}kB; diff = {}kB({:.2f}%)'.format(lib,
|
||||||
|
ref_libs_size[lib] / 1024,
|
||||||
|
lib_sizes[lib] / 1024,
|
||||||
|
lib_size_diff / 1024,
|
||||||
|
lib_size_diff_percent))
|
||||||
|
res = [lib for lib in libraries if lib_sizes[lib] > ref_libs_size[lib]]
|
||||||
|
assert len(res) == 0, f'These libraries: {res} have increased in size!'
|
@ -6,6 +6,8 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
def expand_env_vars(obj):
|
def expand_env_vars(obj):
|
||||||
@ -20,3 +22,29 @@ def expand_env_vars(obj):
|
|||||||
else:
|
else:
|
||||||
obj = os.path.expandvars(obj)
|
obj = os.path.expandvars(obj)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
def get_os_name():
|
||||||
|
"""Function for getting OS name"""
|
||||||
|
if sys.platform == "win32":
|
||||||
|
os_name = 'Windows'
|
||||||
|
else:
|
||||||
|
os_name = 'Linux'
|
||||||
|
return os_name
|
||||||
|
|
||||||
|
|
||||||
|
def get_lib_path(lib_name):
|
||||||
|
"""Function for getting absolute path in OpenVINO directory to specific lib"""
|
||||||
|
os_name = get_os_name()
|
||||||
|
all_libs = {
|
||||||
|
'inference_engine_transformations': {
|
||||||
|
'Windows': Path('deployment_tools/inference_engine/bin/intel64/Release/inference_engine_transformations.dll'),
|
||||||
|
'Linux': Path('deployment_tools/inference_engine/lib/intel64/libinference_engine_transformations.so')},
|
||||||
|
'MKLDNNPlugin': {
|
||||||
|
'Windows': Path('deployment_tools/inference_engine/bin/intel64/Release/MKLDNNPlugin.dll'),
|
||||||
|
'Linux': Path('deployment_tools/inference_engine/lib/intel64/libMKLDNNPlugin.so')},
|
||||||
|
'ngraph': {
|
||||||
|
'Windows': Path('deployment_tools/ngraph/lib/ngraph.dll'),
|
||||||
|
'Linux': Path('deployment_tools/ngraph/lib/libngraph.so')}
|
||||||
|
}
|
||||||
|
return all_libs[lib_name][os_name]
|
||||||
|
Loading…
Reference in New Issue
Block a user