src/frontends/onnx/docs/tests.md
pip install -r <OV_REPO_DIR>/src/frontends/onnx/tests/requirements.txt
After that CMake will produce test models from existin *.prototxt files
2. Build OpenVINO with the -DENABLE_TESTS=ON flag.
3. Run <OV_REPO_DIR>/bin/intel64/<OV_BUILD_TYPE>/ov_onnx_frontend_tests, where <OV_REPO_DIR> is your workspace folder, and OV_BUILD_TYPE can be Debug or Release, depending on the -DCMAKE_BUILD_TYPE CMake build option.
You can filter tests using the --gtest_filter flag like any other gtest-based tests.
For example:
<OV_REPO_DIR>/bin/intel64/<OV_BUILD_TYPE>/ov_onnx_frontend_tests --gtest_filter=*add*
-DENABLE_PYTHON=ON, preferably in a Python virtual environment. To avoid problems with too many Python interpreters installed on the host, you can also set the -DPython3_EXECUTABLE=<PYTHON_INTERPRETER_PATH> build option (requires cmake 3.16 and higher).NOTE: If you want to run the tests from the installation directory (like in the CI), add the
-P cmake_install.cmakeand-DCOMPONENT=testsCMake build options, and install OpenVINO viacmake --build . --target installas additional steps.
source <OV_INSTALL_DIR>/setupvars.sh for Linux, . <path-to-setupvars-folder>/setupvars.ps1 for Windows PowerShell, or sh <INSTALL_DIR>\setupvars.bat for Windows Command Prompt.pip install -r <OV_REPO_DIR>/src/bindings/python/requirements.txt
pip install -r <OV_REPO_DIR>/src/bindings/python/requirements_test.txt
You can run ONNX Frontend Python tests using the following commands:
pytest <OV_REPO_DIR>/src/bindings/python/tests/test_frontend/test_frontend_onnx*
pytest <OV_INSTALL_DIR>/tests/pyopenvino/tests/test_frontend/test_frontend_onnx*
You can run ONNX operators Python tests using the following commands:
pytest <OV_REPO_DIR>/src/bindings/python/tests/test_onnx \
--ignore=<OV_REPO_DIR>/src/bindings/python/tests/test_onnx/test_zoo_models.py \
--ignore=<OV_REPO_DIR>/src/bindings/python/tests/test_onnx/test_backend.py
pytest <OV_INSTALL_DIR>/tests/pyopenvino/tests/test_onnx \
--ignore=<OV_INSTALL_DIR>/tests/pyopenvino/tests/test_onnx/test_zoo_models.py \
--ignore=<OV_INSTALL_DIR>/tests/pyopenvino/tests/test_onnx/test_backend.py
pytest <OV_REPO_DIR>/src/bindings/python/tests/test_onnx/test_backend.py -sv -k 'not cuda'
pytest <OV_INSTALL_DIR>/tests/pyopenvino/tests/test_onnx/test_backend.py -sv -k 'not cuda'
Preparation: Download models. The current OpenVINO ONNX Frontend uses this version or the model_zoo_preprocess.sh script. The second approach is preferable, because some test data requires preprocessing.
model_zoo_preprocess.sh -d <ONNX_MODELS_DIR> -o
Note that the current CI also tests models from the MSFT package (the -m flag of the model_zoo_preprocess.sh script can enable the processing of it), but it is a deprecated pipeline. If you encounter problems with this package, contact openvino-onnx-frontend-maintainers.
Commands to run OpenModelZoo tests:
pytest --backend=CPU <OV_REPO_DIR>/src/bindings/python/tests/test_onnx/test_zoo_models.py -v -n 4 --forked -k 'not _cuda' --model_zoo_dir=<ONNX_MODELS_DIR>
Note that you can also run tests for a single model only, for example:
pytest --backend=CPU <OV_REPO_DIR>/src/bindings/python/tests/test_onnx/test_zoo_models.py -v -n 4 --forked -k 'not _cuda' --model_zoo_dir=<ONNX_MODELS_DIR> -k test_onnx_model_zoo_vision_classification_alexnet_model_bvlcalexnet_9_bvlc_alexnet_model_cpu
pytest --backend=CPU <OV_INSTALL_DIR>/tests/pyopenvino/tests/test_onnx/test_zoo_models.py -v -n 4 --forked -k 'not _cuda' --model_zoo_dir=<ONNX_MODELS_DIR>
Be aware that each model is tested in two stages: importing (OnnxBackendModelImportTest) and inference (OnnxBackendModelExecutionTest).
TIP: A useful
pytestflag during working with OpenModelZoo tests is--collect-only. It enables you to list all the possible tests (based on available models) without running them. An example output:
<TestCaseFunction test_onnx_model_zoo_vision_style_transfer_fast_neural_style_model_rain_princess_8_rain_princess_model_cpu>
<TestCaseFunction test_onnx_model_zoo_vision_style_transfer_fast_neural_style_model_rain_princess_9_rain_princess_rain_princess_cpu>
...
rel-1.8.1 version is used in the current CI configuration):git clone --branch rel-1.8.1 --single-branch --recursive https://github.com/microsoft/onnxruntime.git
rel-1.8.1 version:cd <OV_INSTALL_DIR>/deployment_tools/openvino && touch version.txt && echo "2021.4" > version.txt
source <OV_INSTALL_DIR>/setupvars.sh
<ONNX_RUNTIME_REPO_DIR>/build.sh --config RelWithDebInfo --use_openvino CPU_FP32 --build_shared_lib --parallel
After the building is finished, the tests will run automatically if the --skip_tests flag is not set.
Note that ONNX Runtime version from the master branch requires CMake version being greater than 3.25. You can parametrize the build.sh script with your custom CMake version by passing the path via the --cmake_path argument.