diff --git a/inference-engine/thirdparty/mkl-dnn b/inference-engine/thirdparty/mkl-dnn index a5fffb52b012b3..2dd787262134c2 160000 --- a/inference-engine/thirdparty/mkl-dnn +++ b/inference-engine/thirdparty/mkl-dnn @@ -1 +1 @@ -Subproject commit a5fffb52b012b31c65ace894638ecfb8948de9ec +Subproject commit 2dd787262134c20f91f222bfa776225d2dddbc9a diff --git a/tests/conditional_compilation/conftest.py b/tests/conditional_compilation/conftest.py index e0f9b958dc3a93..e74f46ba3b9661 100644 --- a/tests/conditional_compilation/conftest.py +++ b/tests/conditional_compilation/conftest.py @@ -5,16 +5,7 @@ # pylint: disable=line-too-long -""" Pytest configuration for compilation tests. - -Sample usage: -python3 -m pytest test_cc.py \ - --sea_runtool=./thirdparty/itt_collector/runtool/sea_runtool.py \ - --collector_dir=./bin/intel64/Release \ - --artifacts= \ - --openvino_ref= \ - --openvino_root_dir= -""" +"""Pytest configuration for compilation tests.""" import logging import sys @@ -28,8 +19,7 @@ import pytest from path_utils import expand_env_vars # pylint: disable=import-error -from proc_utils import cmd_exec # pylint: disable=import-error -from test_utils import write_session_info, SESSION_INFO_FILE # pylint: disable=import-error +from test_utils import make_build, write_session_info, SESSION_INFO_FILE # pylint: disable=import-error log = logging.getLogger() @@ -117,7 +107,7 @@ def openvino_ref(request, openvino_root_dir, artifacts): """Fixture function for command-line option. Return path to root directory with installed OpenVINO. If --openvino_ref command-line option is not specified firstly build and install - instrumented binaries with OpenVINO repository specified in --openvino_root_dir option. + instrumented package with OpenVINO repository specified in --openvino_root_dir option. """ openvino_ref_path = request.config.getoption("openvino_ref") if openvino_ref_path: @@ -128,17 +118,13 @@ def openvino_ref(request, openvino_root_dir, artifacts): log.info("--openvino_ref is not specified. " "Building instrumented build at %s", build_dir) - cmd = ( - f"mkdir -p {build_dir} && " - f"cmake -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT " - f"-DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=`which python3` " - f"-S {openvino_root_dir} -B {build_dir} && " - f"make -C {build_dir} --jobs=$(nproc --all) && " - f"mkdir -p {openvino_ref_path} && " - f"cmake --install {build_dir} --prefix {openvino_ref_path}" + return_code, output = make_build( + openvino_root_dir, + build_dir, + openvino_ref_path, + cmake_additional_args=["-DSELECTIVE_BUILD=COLLECT"], + log=log ) - return_code, output = cmd_exec([cmd], log=log, shell=True) - assert return_code == 0, f"Command exited with non-zero status {return_code}:\n {output}" return openvino_ref_path diff --git a/tests/conditional_compilation/test_cc.py b/tests/conditional_compilation/test_cc.py index 4d21400513de86..e8c2731ff05cfc 100644 --- a/tests/conditional_compilation/test_cc.py +++ b/tests/conditional_compilation/test_cc.py @@ -14,7 +14,7 @@ import pytest from proc_utils import cmd_exec # pylint: disable=import-error -from test_utils import get_lib_sizes, infer_tool, run_infer # pylint: disable=import-error +from test_utils import get_lib_sizes, infer_tool, make_build, run_infer # pylint: disable=import-error log = logging.getLogger() @@ -61,46 +61,42 @@ def test_cc_collect(test_id, model, openvino_ref, test_info, @pytest.mark.dependency(depends=["cc_collect"]) -def test_minimized_build(test_id, model, openvino_root_dir, artifacts): # pylint: disable=unused-argument - """Install OpenVINO with collected conditional compilation statistics.""" +def test_minimized_pkg(test_id, model, openvino_root_dir, artifacts): # pylint: disable=unused-argument + """Build and install OpenVINO package with collected conditional compilation statistics.""" install_prefix = artifacts / test_id / "install_pkg" build_dir = openvino_root_dir / "build_minimized" log.info("Building minimized build at %s", build_dir) - cmd = ( - f"mkdir -p {build_dir} && " - f"cmake -DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD_STAT={artifacts / test_id}/*.csv " - "-DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=`which python3` " - f"-S {openvino_root_dir} -B {build_dir} &&" - f"make -C {build_dir} --jobs=$(nproc --all) && " - f"mkdir -p {install_prefix} && " - f"cmake --install {build_dir} --prefix {install_prefix}" + return_code, output = make_build( + openvino_root_dir, + build_dir, + install_prefix, + cmake_additional_args=[f"-DSELECTIVE_BUILD_STAT={artifacts / test_id}/*.csv"], + log=log, ) - return_code, output = cmd_exec([cmd], log=log, shell=True) - assert return_code == 0, f"Command exited with non-zero status {return_code}:\n {output}" -@pytest.mark.dependency(depends=["cc_collect", "minimized_build"]) +@pytest.mark.dependency(depends=["cc_collect", "minimized_pkg"]) def test_infer(test_id, model, artifacts): """Test inference with conditional compiled binaries.""" out = artifacts / test_id - minimized_build = out / "install_pkg" - return_code, output = run_infer(model, f"{out}_cc.npz", minimized_build) + minimized_pkg = out / "install_pkg" + return_code, output = run_infer(model, f"{out}_cc.npz", minimized_pkg) assert return_code == 0, f"Command exited with non-zero status {return_code}:\n {output}" -@pytest.mark.dependency(depends=["cc_collect", "minimized_build"]) +@pytest.mark.dependency(depends=["cc_collect", "minimized_pkg"]) def test_verify(test_id, model, openvino_ref, artifacts, tolerance=1e-6): # pylint: disable=too-many-arguments """Test verifying that inference results are equal.""" out = artifacts / test_id - minimized_build = out / "install_pkg" + minimized_pkg = out / "install_pkg" out_file = f"{out}.npz" out_file_cc = f"{out}_cc.npz" return_code, output = run_infer(model, out_file, openvino_ref) assert return_code == 0, f"Command exited with non-zero status {return_code}:\n {output}" - return_code, output = run_infer(model, out_file_cc, minimized_build) + return_code, output = run_infer(model, out_file_cc, minimized_pkg) assert return_code == 0, f"Command exited with non-zero status {return_code}:\n {output}" reference_results = dict(np.load(out_file)) inference_results = dict(np.load(out_file_cc)) @@ -113,13 +109,13 @@ def test_verify(test_id, model, openvino_ref, artifacts, tolerance=1e-6): # pyl ), "Reference and inference results differ" -@pytest.mark.dependency(depends=["cc_collect", "minimized_build"]) +@pytest.mark.dependency(depends=["cc_collect", "minimized_pkg"]) def test_libs_size(test_id, model, openvino_ref, artifacts): # pylint: disable=unused-argument """Test if libraries haven't increased in size after conditional compilation.""" libraries = ["inference_engine_transformations", "MKLDNNPlugin", "ngraph"] - minimized_build = artifacts / test_id / "install_pkg" + minimized_pkg = artifacts / test_id / "install_pkg" ref_libs_size = get_lib_sizes(openvino_ref, libraries) - lib_sizes = get_lib_sizes(minimized_build, libraries) + lib_sizes = get_lib_sizes(minimized_pkg, libraries) for lib in libraries: lib_size_diff = ref_libs_size[lib] - lib_sizes[lib] diff --git a/tests/conditional_compilation/test_utils.py b/tests/conditional_compilation/test_utils.py index 5ee0a09e0706c0..fa9cc2d2d381d4 100644 --- a/tests/conditional_compilation/test_utils.py +++ b/tests/conditional_compilation/test_utils.py @@ -6,12 +6,16 @@ """ import os import json +import multiprocessing +import shutil import sys from inspect import getsourcefile from pathlib import Path -from proc_utils import cmd_exec # pylint: disable=import-error + from install_pkg import get_openvino_environment # pylint: disable=import-error from path_utils import get_lib_path # pylint: disable=import-error +from proc_utils import cmd_exec # pylint: disable=import-error + SESSION_INFO_FILE = "cc_tests.json" infer_tool = str((Path(getsourcefile(lambda: 0)) / ".." / "tools" / "infer_tool.py").resolve()) @@ -58,3 +62,18 @@ def run_infer(model, out_file, install_dir): env=get_openvino_environment(install_dir), ) return returncode, output + + +def make_build(openvino_root_dir, build_dir, install_dir, cmake_additional_args=None, log=None): + """Parametrized build and install OpenVINO package.""" + python_executable = shutil.which("python3") + additional_args_line = " ".join(cmake_additional_args) + " " if cmake_additional_args else "" + nproc = multiprocessing.cpu_count() + cmd = ( + f"cmake -DENABLE_PROFILING_ITT=ON -DCMAKE_BUILD_TYPE=Release " + f"-DPYTHON_EXECUTABLE={python_executable} {additional_args_line}" + f"-S {openvino_root_dir} -B {build_dir} &&" + f"cmake --build {build_dir} -j{nproc} && " + f"cmake --install {build_dir} --prefix {install_dir}" + ) + return cmd_exec([cmd], shell=True, log=log)