From 99b450ef5227ef8dbf5e3472cbb5601e007990a5 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Fri, 16 Sep 2022 15:18:11 +0400 Subject: [PATCH] Check ONNX installation before usage (#13069) --- cmake/test_model_zoo.cmake | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/cmake/test_model_zoo.cmake b/cmake/test_model_zoo.cmake index 7de2f56d9bf..ea0ebe0a843 100644 --- a/cmake/test_model_zoo.cmake +++ b/cmake/test_model_zoo.cmake @@ -4,26 +4,37 @@ set_property(GLOBAL PROPERTY JOB_POOLS four_jobs=4) +if(ENABLE_OV_ONNX_FRONTEND) + if(ENABLE_REQUIREMENTS_INSTALL) + # suppose that ONNX is found, because it's going to be installed during the build + set(onnx_FOUND ON) + else() + # if requirements are not installed automatically, we need to checks whether they are here + ov_check_pip_packages(REQUIREMENTS_FILE "${OpenVINO_SOURCE_DIR}/src/frontends/onnx/tests/requirements.txt" + RESULT_VAR onnx_FOUND + WARNING_MESSAGE "ONNX frontend tests will be skipped" + MESSAGE_MODE WARNING) + endif() +endif() + function(ov_model_convert SRC DST OUT) set(onnx_gen_script ${OpenVINO_SOURCE_DIR}/src/frontends/onnx/tests/onnx_prototxt_converter.py) - file(GLOB_RECURSE prototxt_models RELATIVE "${SRC}" "${SRC}/*.prototxt") file(GLOB_RECURSE xml_models RELATIVE "${SRC}" "${SRC}/*.xml") file(GLOB_RECURSE bin_models RELATIVE "${SRC}" "${SRC}/*.bin") file(GLOB_RECURSE onnx_models RELATIVE "${SRC}" "${SRC}/*.onnx") file(GLOB_RECURSE data_models RELATIVE "${SRC}" "${SRC}/*.data") + if(onnx_FOUND) + file(GLOB_RECURSE prototxt_models RELATIVE "${SRC}" "${SRC}/*.prototxt") + endif() + foreach(in_file IN LISTS prototxt_models xml_models bin_models onnx_models data_models) get_filename_component(ext "${in_file}" EXT) get_filename_component(rel_dir "${in_file}" DIRECTORY) get_filename_component(name_we "${in_file}" NAME_WE) set(model_source_dir "${SRC}/${rel_dir}") - if(NOT ENABLE_OV_ONNX_FRONTEND AND ext MATCHES "^\\.(onnx|prototxt)$") - # don't copy / process ONNX / prototxt files - continue() - endif() - if(ext STREQUAL ".prototxt") # convert model set(rel_out_name "${name_we}.onnx")