Files
openvino/src/plugins/intel_cpu/docs/selective_build.md
T
Ilya LavrenovandOleg Pipikin 8349849e1c Use FindPython3.cmake (#19847)
* Use FindPython3.cmake

* Fixed compilation on macOS 14 with new core development tools

* Try to use Python3_SOABI instead of PYTHON_MODULE_EXTENSION

* Use Development.Module

* Keep specifying only Python3_EXECUTABLE

* Print PYTHON_MODULE_EXTENSION

* Added check for minimal cmake version for python API

* Returned Python3_INCLUDE_DIR for cross-compilation case

* Try to allow cmake older than 3.18

* Use build python interpreter to check cython dependency

* revert changes in .ci/openvino-onnx/Dockerfile

* removed unused code

* Fixed issue with variables scope

* Experiment: remove include dirs

* Corrected docs

* Use pybind11 function to set extension

* Revert "Experiment: remove include dirs"

This reverts commit 6f7f90211c.

* Refactor ConvolutionBackpropDataLayerTest, ConvolutionLayerTest, DeformableConvolutionLayerTest (#19810)

* Refactor ConvolutionBackpropDataLayerTest

* Refactor ConvolutionLayerTest

* Refactor DeformableConvolutionLayerTest

* Apply comments

* Apply comments

* Fix

* Updated minimum cmake version for Windows

* Simplified check

* Removed useless message status

* Use puiblic option

---------

Co-authored-by: Oleg Pipikin <oleg.pipikin@intel.com>
2023-09-26 20:57:29 +02:00

3.0 KiB

Selective Build

Introduction

Selective build or conditional compilation can significantly reduce OpenVINO™ binaries size by excluding unnecessary components for particular model's inference.

Workflow

Onednn path in OpenVINO:

./src/plugins/intel_cpu/thirdparty/onednn/

The selective build carries on under the instruction of:

./src/common/conditional_compilation/CMakeLists.txt

First build

The first build collects the information and generate a CSV file indicating which components are going to be included and which are going to be excluded in the selected build.

  • For the first build, config cmake with option "-DENABLE_PROFILING_ITT=ON -DSELECTIVE_BUILD=COLLECT"
cd ./build

cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_CPU_DEBUG_CAPS=ON \
-DENABLE_PROFILING_ITT=ON \
-DSELECTIVE_BUILD=COLLECT \
-DCMAKE_INSTALL_PREFIX=`pwd`/install \
-DCMAKE_INSTALL_RPATH=`pwd`/install/runtime/3rdparty/tbb/lib:`pwd`/install/runtime/lib/intel64

cmake --build . --config Release -j 8

Generate statistics file (CSV):

  • Need to build manually to get libIntelSEAPI.so with the following step first.
# in ./build
cd ./thirdparty/itt_collector && make
  • Then generate statistics file (in .csv format).
cd ../../../bin/intel64/Release/

python ../../../thirdparty/itt_collector/runtool/sea_runtool.py \
--bindir ./lib -o models_statistics_dir ! \
./benchmark_app -niter 1 -nireq 1 \
-m <model_path>

Second build

The second build takes in the information in the statistics file and only build the components mentioned in the CSV file.

The generated CSV file could be found in folder:

openvino/bin/intel64/Release/

This time, config cmake with option "-DSELECTIVE_BUILD=ON"

cd ../../../build

cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_CPU_DEBUG_CAPS=ON \
-DENABLE_DEBUG_CAPS=ON \
-DSELECTIVE_BUILD=ON \
-DSELECTIVE_BUILD_STAT=<CSV_PATH> \
-DPython3_EXECUTABLE=/usr/bin/python3.7 \
-DCMAKE_INSTALL_PREFIX=`pwd`/install \
-DCMAKE_INSTALL_RPATH=`pwd`/install/runtime/3rdparty/tbb/lib:`pwd`/install/runtime/lib/intel64

cmake --build . --config Release -j 8

As shown in

./src/common/conditional_compilation/CMakeLists.txt

CSV file works as a SELECTIVE_BUILD_STAT and is first interpreted into a c++ head file:

./build/src/common/conditional_compilation/conditional_compilation_gen.h

It is generated by 'ccheader.py' and can indicate if selective build analyze process (first build) works correctly.

Test selective compile with benchmark

cd ./bin/intel64/Release

./benchmark_app -niter 1 -nireq 1 \
-m <model_path> -d CPU 

Reference

https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/conditional_compilation.md

https://github.com/openvinotoolkit/openvino/commit/ec48fcb29bef94cca480573110a598afc3515019#

https://github.com/openvinotoolkit/openvino/commit/1f96ddfbf9030e765aa0ca0a6aafb1ae2b8c3e98#diff-de6f7126342889fe9d0b505b0ac391db2275400488d5bab9194c2542a4f4d1fe