Check ONNX installation before usage (#13069)

This commit is contained in:
Ilya Lavrenov 2022-09-16 15:18:11 +04:00 committed by GitHub
parent 8f7c9a05f5
commit 99b450ef52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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")