diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index 73d0f03b5349a0..592614b677ddf7 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -85,8 +85,9 @@ jobs: python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/wheel/requirements-dev.txt # For running Python API tests python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/src/requirements-dev.txt - # For running nGraph unit tests dependent on Python frameworks - python3 -m pip install -r $(REPO_DIR)/ngraph/test/requirements_test.txt + # For running PaddlePaddle frontend unit tests + python3 -m pip install -r $(REPO_DIR)/ngraph/test/frontend/paddlepaddle/requirements_dev.txt + # For running ONNX frontend unit tests python3 -m pip install -r $(REPO_DIR)/ngraph/test/requirements_test_onnx.txt # For MO unit tests python3 -m pip install -r $(REPO_DIR)/model-optimizer/requirements.txt @@ -171,13 +172,15 @@ jobs: displayName: 'Model Optimizer UT' continueOnError: false - - script: | - export FE_TEST_MODELS=$(INSTALL_DIR)/tests - . $(SETUPVARS) && $(INSTALL_TEST_DIR)/unit-test --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*IE_GPU* --gtest_output=xml:TEST-NGraphUT.xml + - script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/unit-test --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*IE_GPU* --gtest_output=xml:TEST-NGraphUT.xml workingDirectory: $(INSTALL_TEST_DIR) displayName: 'nGraph UT' continueOnError: false + - script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/paddlepaddle_tests --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*IE_GPU* --gtest_output=xml:TEST-PaddlePaddle.xml + displayName: 'PaddlePaddle Frontend UT' + continueOnError: false + # . $(SETUPVARS) && python3 $(WORK_DIR)/gtest-parallel/gtest_parallel.py $(INSTALL_TEST_DIR)/InferenceEngineUnitTests --workers=16 --dump_json_test_results=InferenceEngineUnitTests.json --gtest_filter=*smoke* -- --gtest_print_time=1 - script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/InferenceEngineUnitTests --gtest_print_time=1 --gtest_output=xml:TEST-InferenceEngineUnitTests.xml displayName: 'IE UT old' diff --git a/.ci/azure/windows.yml b/.ci/azure/windows.yml index 368797841c5505..e5ec0486f9bcd2 100644 --- a/.ci/azure/windows.yml +++ b/.ci/azure/windows.yml @@ -86,8 +86,9 @@ jobs: python -m pip install --upgrade pip rem For running Python API tests python -m pip install -r $(REPO_DIR)\inference-engine\ie_bridges\python\src\requirements-dev.txt - rem For running nGraph unit tests dependent on Python frameworks - python -m pip install -r $(REPO_DIR)\ngraph\test\requirements_test.txt + rem For running PaddlePaddle frontend unit tests + python -m pip install -r $(REPO_DIR)\ngraph\test\frontend\paddlepaddle\requirements_dev.txt + rem For running ONNX frontend unit tests python -m pip install -r $(REPO_DIR)\ngraph\test\requirements_test_onnx.txt rem For MO unit tests python -m pip install -r $(REPO_DIR)\model-optimizer\requirements.txt @@ -143,13 +144,15 @@ jobs: displayName: 'Clean build dir' continueOnError: false - - script: | - set FE_TEST_MODELS=$(INSTALL_DIR)\tests - call $(SETUPVARS) && $(INSTALL_TEST_DIR)\unit-test --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*IE_GPU* --gtest_output=xml:TEST-NGraphUT.xml + - script: call $(SETUPVARS) && $(INSTALL_TEST_DIR)\unit-test --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*IE_GPU* --gtest_output=xml:TEST-NGraphUT.xml workingDirectory: $(INSTALL_TEST_DIR) displayName: 'nGraph UT' continueOnError: false + - script: call $(SETUPVARS) && $(INSTALL_TEST_DIR)\paddlepaddle_tests --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*IE_GPU* --gtest_output=xml:TEST-PaddlePaddle.xml + displayName: 'PaddlePaddle Frontend UT' + continueOnError: false + - script: | set PATH=$(IB_DIR);%PATH% call $(SETUPVARS) && "$(IB_TESTCONSOLE)" $(INSTALL_TEST_DIR)\InferenceEngineUnitTests.exe --gtest_output=xml:TEST-InferenceEngineUnitTests-IB.xml diff --git a/cmake/test_model_zoo.cmake b/cmake/test_model_zoo.cmake index 06f14f2d1f5e82..c3f158626cdabe 100644 --- a/cmake/test_model_zoo.cmake +++ b/cmake/test_model_zoo.cmake @@ -120,6 +120,10 @@ if(ENABLE_TESTS) add_dependencies(test_model_zoo test_pip_prerequsites) endif() + if (NGRAPH_PDPD_FRONTEND_ENABLE) + add_dependencies(test_model_zoo paddlepaddle_test_models) + endif() + install(DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_model_zoo" DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL) diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index 956a224df1ceec..37ca03d1d7da7d 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -558,31 +558,10 @@ if (NGRAPH_ONNX_IMPORT_ENABLE) endif() # SOURCE FOR FRONTEND TESTING - file(GLOB FRONTEND_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/frontend/frontend_manager.cpp) set(SRC ${FRONTEND_TESTS_SRC} ${SRC}) -file(GLOB FRONTEND_SHARED_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/frontend/shared/src/*.cpp) -file(GLOB FRONTEND_SHARED_TESTS_HDR ${CMAKE_CURRENT_SOURCE_DIR}/frontend/shared/include/*.hpp) -set(SRC ${FRONTEND_SHARED_TESTS_SRC} ${SRC}) - -add_definitions("-DTEST_MODEL_BUILD_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\"") - -# ---- PaddlePaddle FrontEnd testing ------ -if (NGRAPH_PDPD_FRONTEND_ENABLE) - ie_check_pip_package(paddlepaddle WARNING) - - if(paddlepaddle_FOUND) - file(GLOB FRONTEND_PDPD_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/frontend/paddlepaddle/*.cpp) - set(SRC ${FRONTEND_PDPD_TESTS_SRC} ${SRC}) - set(PADDLE_TEST_MODELS_DIRNAME paddle_test_models) - set(TEST_PADDLE_MODELS ${CMAKE_CURRENT_BINARY_DIR}/${PADDLE_TEST_MODELS_DIRNAME}/) - add_definitions("-DTEST_PADDLE_MODELS_DIRNAME=\"${PADDLE_TEST_MODELS_DIRNAME}/\"") - endif() -endif() -# ---- End PaddlePaddle FrontEnd testing ------ - -add_clang_format_target(unit-test_clang FOR_SOURCES ${SRC} ${MULTI_TEST_SRC} ${FRONTEND_SHARED_TESTS_HDR}) +add_clang_format_target(unit-test_clang FOR_SOURCES ${SRC} ${MULTI_TEST_SRC}) foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST}) string(TOLOWER ${BACKEND_NAME} BACKEND_DIR) @@ -603,7 +582,6 @@ add_executable(unit-test ${SRC}) target_include_directories(unit-test PRIVATE ".") target_include_directories(unit-test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/runtime) -target_include_directories(unit-test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/frontend/shared/include) add_definitions("-DCURDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"") add_definitions("-DJSON_INCLUDES=\"${JSON_INCLUDE_DIR}\"") @@ -618,7 +596,8 @@ target_link_libraries(unit-test PRIVATE ngraph_test_util ie_backend interpreter_backend Threads::Threads - openvino::conditional_compilation) + openvino::conditional_compilation + frontend_manager) # Protobuf-lite does not support parsing files from prototxt format # Since most of the onnx models are stored in this format it have to be disabled @@ -655,39 +634,7 @@ install(TARGETS unit-test COMPONENT tests EXCLUDE_FROM_ALL) -############ FRONTEND ############ -target_include_directories(unit-test PRIVATE ${FRONTEND_INCLUDE_PATH} frontend/shared/include) -target_link_libraries(unit-test PRIVATE frontend_manager cnpy commonTestUtils) - add_subdirectory(frontend) -### END FRONTEND ### - -#PaddlePaddle - test models generator -if (NGRAPH_PDPD_FRONTEND_ENABLE AND paddlepaddle_FOUND) - file(GLOB_RECURSE PDPD_GEN_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/files/paddlepaddle/gen_scripts/generate_*.py) - set(OUT_FILES "") - foreach(GEN_SCRIPT ${PDPD_GEN_SCRIPTS}) - get_filename_component(FILE_WE ${GEN_SCRIPT} NAME_WE) - set(OUT_DONE_FILE ${TEST_PADDLE_MODELS}/${FILE_WE}_done.txt) - set(OUT_FILES ${OUT_DONE_FILE} ${OUT_FILES}) - add_custom_command(OUTPUT ${OUT_DONE_FILE} - COMMAND ${PYTHON_EXECUTABLE} - ${CMAKE_CURRENT_SOURCE_DIR}/files/paddlepaddle/gen_wrapper.py - ${GEN_SCRIPT} - ${TEST_PADDLE_MODELS} - ${OUT_DONE_FILE} - DEPENDS ${GEN_SCRIPT} ${CMAKE_CURRENT_SOURCE_DIR}/files/paddlepaddle/gen_wrapper.py - ) - endforeach() - add_custom_target(paddlepaddle_test_models DEPENDS ${OUT_FILES}) - add_dependencies(unit-test paddlepaddle_test_models) - add_dependencies(unit-test paddlepaddle_ngraph_frontend) - - install(DIRECTORY ${TEST_PADDLE_MODELS} - DESTINATION tests/${PADDLE_TEST_MODELS_DIRNAME} - COMPONENT tests - EXCLUDE_FROM_ALL) -endif() # process models add_dependencies(unit-test test_model_zoo) diff --git a/ngraph/test/frontend/CMakeLists.txt b/ngraph/test/frontend/CMakeLists.txt index ba20be7d338f2f..67ffb5a992ac1b 100644 --- a/ngraph/test/frontend/CMakeLists.txt +++ b/ngraph/test/frontend/CMakeLists.txt @@ -1,6 +1,11 @@ # Copyright (C) 2018-2021 Intel Corporation # SPDX-License-Identifier: Apache-2.0 # +add_subdirectory(shared) + +if (NGRAPH_PDPD_FRONTEND_ENABLE) + add_subdirectory(paddlepaddle) +endif() set(SRC ${CMAKE_CURRENT_SOURCE_DIR}/mock_frontend.cpp) add_library(mock1_ngraph_frontend SHARED ${SRC}) diff --git a/ngraph/test/frontend/paddlepaddle/CMakeLists.txt b/ngraph/test/frontend/paddlepaddle/CMakeLists.txt new file mode 100644 index 00000000000000..52b898192d0beb --- /dev/null +++ b/ngraph/test/frontend/paddlepaddle/CMakeLists.txt @@ -0,0 +1,70 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +set(TARGET_NAME "paddlepaddle_tests") + +file(GLOB_RECURSE SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) + +add_executable(${TARGET_NAME} ${SRC}) + +target_link_libraries(${TARGET_NAME} PRIVATE frontend_shared_test_classes) + +add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) + +install(TARGETS ${TARGET_NAME} + RUNTIME DESTINATION tests + COMPONENT tests + EXCLUDE_FROM_ALL) + +# Test model generating +ie_check_pip_package(paddlepaddle WARNING) + +set(TEST_PADDLE_MODELS_DIRNAME test_model_zoo/paddle_test_models) +target_compile_definitions(${TARGET_NAME} PRIVATE -D TEST_PADDLE_MODELS_DIRNAME=\"${TEST_PADDLE_MODELS_DIRNAME}/\") + +# If 'paddlepaddle' is not found, code will still be compiled +# but models will not be generated and tests will fail +# This is done this way for 'code style' and check cases - cmake shall pass, but CI machine doesn't need to have +# 'paddlepaddle' installed to check code style +if (paddlepaddle_FOUND) + set(TEST_PADDLE_MODELS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_PADDLE_MODELS_DIRNAME}/) + + file(GLOB_RECURSE PADDLE_GEN_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/test_models/gen_scripts/generate_*.py) + file(GLOB_RECURSE PADDLE_ALL_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/*.py) + set(OUT_FILES "") + foreach(GEN_SCRIPT ${PADDLE_GEN_SCRIPTS}) + get_filename_component(FILE_WE ${GEN_SCRIPT} NAME_WE) + set(OUT_DONE_FILE ${TEST_PADDLE_MODELS}/${FILE_WE}_done.txt) + set(OUT_FILES ${OUT_DONE_FILE} ${OUT_FILES}) + add_custom_command(OUTPUT ${OUT_DONE_FILE} + COMMAND ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/test_models/gen_wrapper.py + ${GEN_SCRIPT} + ${TEST_PADDLE_MODELS} + ${OUT_DONE_FILE} + DEPENDS ${PADDLE_ALL_SCRIPTS} + ) + endforeach() + add_custom_target(paddlepaddle_test_models DEPENDS ${OUT_FILES}) + + install(DIRECTORY ${TEST_PADDLE_MODELS} + DESTINATION tests/${TEST_PADDLE_MODELS_DIRNAME} + COMPONENT tests + EXCLUDE_FROM_ALL) +else() + # Produce warning message at build time as well + add_custom_command(OUTPUT unable_build_paddle_models.txt + COMMAND ${CMAKE_COMMAND} + -E cmake_echo_color --red "Warning: Unable to generate PaddlePaddle test models. Running '${TARGET_NAME}' will likely fail" + ) + add_custom_target(paddlepaddle_test_models DEPENDS unable_build_paddle_models.txt) +endif() + +add_dependencies(${TARGET_NAME} paddlepaddle_test_models) +add_dependencies(${TARGET_NAME} paddlepaddle_ngraph_frontend) + +# Fuzzy tests for PaddlePaddle use IE_CPU engine +if (ENABLE_MKL_DNN) + add_dependencies(${TARGET_NAME} MKLDNNPlugin) +endif() \ No newline at end of file diff --git a/ngraph/test/frontend/paddlepaddle/incorrect_cut_model.cpp b/ngraph/test/frontend/paddlepaddle/incorrect_cut_model.cpp index 0065dc2231f377..42cee6c6c70e25 100644 --- a/ngraph/test/frontend/paddlepaddle/incorrect_cut_model.cpp +++ b/ngraph/test/frontend/paddlepaddle/incorrect_cut_model.cpp @@ -21,8 +21,7 @@ TEST(FrontEndIncorrectCutModelTest, test_incorrect_cut) ASSERT_NO_THROW(frontEnd = fem.load_by_framework(PADDLE_FE)); ASSERT_NE(frontEnd, nullptr); auto model_filename = FrontEndTestUtils::make_model_path( - std::string(TEST_PADDLE_MODELS_DIRNAME) + - std::string("2in_2out/2in_2out.pdmodel")); + std::string(TEST_PADDLE_MODELS_DIRNAME) + std::string("2in_2out/2in_2out.pdmodel")); ASSERT_NO_THROW(inputModel = frontEnd->load(model_filename)); ASSERT_NE(inputModel, nullptr); diff --git a/ngraph/test/frontend/paddlepaddle/main.cpp b/ngraph/test/frontend/paddlepaddle/main.cpp new file mode 100644 index 00000000000000..f3c89e3ae80314 --- /dev/null +++ b/ngraph/test/frontend/paddlepaddle/main.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "utils.hpp" + +int main(int argc, char** argv) +{ + return FrontEndTestUtils::run_tests(argc, argv); +} diff --git a/ngraph/test/frontend/paddlepaddle/paddle_utils.hpp b/ngraph/test/frontend/paddlepaddle/paddle_utils.hpp index 78960af5a05598..270a56e2e9da7a 100644 --- a/ngraph/test/frontend/paddlepaddle/paddle_utils.hpp +++ b/ngraph/test/frontend/paddlepaddle/paddle_utils.hpp @@ -7,3 +7,4 @@ #include static const std::string PADDLE_FE = "paddle"; + diff --git a/ngraph/test/frontend/paddlepaddle/places.cpp b/ngraph/test/frontend/paddlepaddle/places.cpp index 2da7d59c93b37e..60800085950baa 100644 --- a/ngraph/test/frontend/paddlepaddle/places.cpp +++ b/ngraph/test/frontend/paddlepaddle/places.cpp @@ -56,9 +56,11 @@ std::vector tensor_names = { TEST(PDPD_Places, check_tensor_names) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); for (const auto& tensor_name : tensor_names) { @@ -70,9 +72,11 @@ TEST(PDPD_Places, check_tensor_names) TEST(PDPD_Places, check_input_outputs) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); auto inputs = input_model->get_inputs(); auto outputs = input_model->get_outputs(); @@ -105,9 +109,11 @@ TEST(PDPD_Places, check_input_outputs) TEST(PDPD_Places, check_out_port_of_all_ops) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); for (const auto& tensor_name : tensor_names) { @@ -128,9 +134,11 @@ TEST(PDPD_Places, check_out_port_of_all_ops) TEST(PDPD_Places, check_in_out_ports_of_model_outputs) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); auto outputs = input_model->get_outputs(); for (const auto& output : outputs) @@ -163,9 +171,11 @@ TEST(PDPD_Places, check_in_out_ports_of_model_outputs) TEST(PDPD_Places, check_source_target_tensors_of_model_outputs) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); auto outputs = input_model->get_outputs(); for (const auto& output : outputs) @@ -198,9 +208,11 @@ TEST(PDPD_Places, check_source_target_tensors_of_model_outputs) TEST(PDPD_Places, check_producing_consuming_ops_of_model_outputs) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); auto outputs = input_model->get_outputs(); for (const auto& output : outputs) @@ -234,9 +246,11 @@ TEST(PDPD_Places, check_producing_consuming_ops_of_model_outputs) TEST(PDPD_Places, check_data_flow) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); for (const auto& tensor_name : tensor_names) { @@ -275,9 +289,11 @@ TEST(PDPD_Places, check_data_flow) TEST(PDPD_Places, check_tensor_to_multiple_ports) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); for (const auto& tensor_name : tensor_names) { @@ -307,9 +323,11 @@ TEST(PDPD_Places, check_tensor_to_multiple_ports) TEST(PDPD_Places, check_consuming_ops) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); for (const auto& tensor_name : tensor_names) { @@ -352,9 +370,11 @@ TEST(PDPD_Places, check_consuming_ops) TEST(PDPD_Places, check_consuming_ops_2) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); auto it = find(tensor_names.begin(), tensor_names.end(), "lstm_0.tmp_2"); EXPECT_NE(it, tensor_names.end()); @@ -394,9 +414,11 @@ TEST(PDPD_Places, check_consuming_ops_2) TEST(PDPD_Places, check_producing_ops) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); for (const auto& tensor_name : tensor_names) { @@ -418,9 +440,11 @@ TEST(PDPD_Places, check_producing_ops) TEST(PDPD_Places, check_input_output_ports_dy_idx) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); std::vector output_names = {"save_infer_model/scale_0.tmp_1", "save_infer_model/scale_1.tmp_1", @@ -445,9 +469,11 @@ TEST(PDPD_Places, check_input_output_ports_dy_idx) TEST(PDPD_Places, check_ops_tensors_by_idx) { FrontEndTestUtils::setupTestEnv(); - auto m_fem = FrontEndManager(); - auto frontend = m_fem.load_by_framework(PADDLE_FE); - auto input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file)); + auto fem = FrontEndManager(); + FrontEnd::Ptr frontend; + ASSERT_NO_THROW(frontend = fem.load_by_framework(PADDLE_FE)); + InputModel::Ptr input_model; + ASSERT_NO_THROW(input_model = frontend->load(FrontEndTestUtils::make_model_path(model_file))); std::vector output_names = {"save_infer_model/scale_0.tmp_1", "save_infer_model/scale_1.tmp_1", diff --git a/ngraph/test/requirements_test.txt b/ngraph/test/frontend/paddlepaddle/requirements_dev.txt similarity index 63% rename from ngraph/test/requirements_test.txt rename to ngraph/test/frontend/paddlepaddle/requirements_dev.txt index 9615699d8bd920..f9f5ae3d96c92b 100644 --- a/ngraph/test/requirements_test.txt +++ b/ngraph/test/frontend/paddlepaddle/requirements_dev.txt @@ -3,6 +3,4 @@ paddlepaddle==2.1.0 gast==0.3.3 numpy~=1.19.2 six~=1.15.0 -# ONNX - generate test models -docopt~=0.6.2 -onnx~=1.9.0 \ No newline at end of file + diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_2in_2out.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_2in_2out.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_2in_2out.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_2in_2out.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_2in_2out_dynbatch.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_2in_2out_dynbatch.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_2in_2out_dynbatch.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_2in_2out_dynbatch.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_argmax.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_argmax.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_argmax.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_argmax.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_assign_value.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_assign_value.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_assign_value.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_assign_value.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_batch_norm.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_batch_norm.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_batch_norm.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_batch_norm.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_clip.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_clip.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_clip.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_clip.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_conv2d.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_conv2d.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_conv2d.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_conv2d.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_conv2d_relu.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_conv2d_relu.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_conv2d_relu.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_conv2d_relu.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_conv2d_s.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_conv2d_s.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_conv2d_s.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_conv2d_s.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_multi_tensor_split.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_multi_tensor_split.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_multi_tensor_split.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_multi_tensor_split.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_place_test_model.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_place_test_model.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_place_test_model.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_place_test_model.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_relu.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_relu.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_relu.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_relu.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/generate_unsupported_relu.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_unsupported_relu.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/generate_unsupported_relu.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/generate_unsupported_relu.py diff --git a/ngraph/test/files/paddlepaddle/gen_scripts/save_model.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/save_model.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_scripts/save_model.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_scripts/save_model.py diff --git a/ngraph/test/files/paddlepaddle/gen_wrapper.py b/ngraph/test/frontend/paddlepaddle/test_models/gen_wrapper.py similarity index 100% rename from ngraph/test/files/paddlepaddle/gen_wrapper.py rename to ngraph/test/frontend/paddlepaddle/test_models/gen_wrapper.py diff --git a/ngraph/test/frontend/shared/CMakeLists.txt b/ngraph/test/frontend/shared/CMakeLists.txt new file mode 100644 index 00000000000000..c4dda394fb1a05 --- /dev/null +++ b/ngraph/test/frontend/shared/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2018-2021 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# + +set(TARGET_NAME "frontend_shared_test_classes") + +file(GLOB_RECURSE LIBRARY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) +file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) + +add_library(${TARGET_NAME} STATIC ${LIBRARY_SRC} ${LIBRARY_HEADERS}) + +target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../..) +target_link_libraries(${TARGET_NAME} PUBLIC frontend_manager + ngraph::ngraph cnpy ie_backend ngraph_test_util commonTestUtils) + +add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME}) diff --git a/ngraph/test/frontend/shared/include/utils.hpp b/ngraph/test/frontend/shared/include/utils.hpp index 1b373d747d34fd..37828f1a09a919 100644 --- a/ngraph/test/frontend/shared/include/utils.hpp +++ b/ngraph/test/frontend/shared/include/utils.hpp @@ -4,15 +4,32 @@ #pragma once +#include #include #include #include "backend.hpp" +#include "common_test_utils/file_utils.hpp" #include "ngraph/env_util.hpp" #include "ngraph/file_util.hpp" // Helper functions namespace FrontEndTestUtils { + int run_tests(int argc, char** argv); + + std::string get_current_executable_path(); + + inline std::tuple + load_from_file(ngraph::frontend::FrontEndManager& fem, + const std::string& frontend_name, + const std::string& model_file) + { + auto frontend = fem.load_by_framework(frontend_name); + auto inputModel = frontend->load(model_file); + return std::tuple{ + frontend, inputModel}; + } + inline std::string fileToTestName(const std::string& fileName) { // TODO: GCC 4.8 has limited support of regex @@ -57,16 +74,6 @@ namespace FrontEndTestUtils inline std::string make_model_path(const std::string& modelsRelativePath) { - // First try build path - auto res = std::string(TEST_MODEL_BUILD_DIR) + "/" + modelsRelativePath; - if (exists(res)) - { - return res; - } - else - { - // Install case: if model file does not exist, use base path from env variable - return std::string(ngraph::getenv_string("FE_TEST_MODELS")) + "/" + modelsRelativePath; - } + return CommonTestUtils::getModelFromTestModelZoo(modelsRelativePath); } } // namespace FrontEndTestUtils \ No newline at end of file diff --git a/ngraph/test/frontend/shared/src/basic_api.cpp b/ngraph/test/frontend/shared/src/basic_api.cpp index 8fc3c57ab2d3f5..92a7254c76ec2f 100644 --- a/ngraph/test/frontend/shared/src/basic_api.cpp +++ b/ngraph/test/frontend/shared/src/basic_api.cpp @@ -30,12 +30,8 @@ void FrontEndBasicTest::initParamTest() void FrontEndBasicTest::doLoadFromFile() { - std::vector frontends; - ASSERT_NO_THROW(frontends = m_fem.get_available_front_ends()); - ASSERT_NO_THROW(m_frontEnd = m_fem.load_by_framework(m_feName)); - ASSERT_NE(m_frontEnd, nullptr); - ASSERT_NO_THROW(m_inputModel = m_frontEnd->load(m_modelFile)); - ASSERT_NE(m_inputModel, nullptr); + std::tie(m_frontEnd, m_inputModel) = + FrontEndTestUtils::load_from_file(m_fem, m_feName, m_modelFile); } TEST_P(FrontEndBasicTest, testLoadFromFile) diff --git a/ngraph/test/frontend/shared/src/cut_specific_model.cpp b/ngraph/test/frontend/shared/src/cut_specific_model.cpp index 5edf87fae6571f..cc9527bf8f95c0 100644 --- a/ngraph/test/frontend/shared/src/cut_specific_model.cpp +++ b/ngraph/test/frontend/shared/src/cut_specific_model.cpp @@ -40,13 +40,8 @@ void FrontEndCutModelTest::initParamTest() void FrontEndCutModelTest::doLoadFromFile() { - std::vector frontends; - FrontEnd::Ptr fe; - ASSERT_NO_THROW(frontends = m_fem.get_available_front_ends()); - ASSERT_NO_THROW(m_frontEnd = m_fem.load_by_framework(m_param.m_frontEndName)); - ASSERT_NE(m_frontEnd, nullptr); - ASSERT_NO_THROW(m_inputModel = m_frontEnd->load(m_param.m_modelName)); - ASSERT_NE(m_inputModel, nullptr); + std::tie(m_frontEnd, m_inputModel) = + FrontEndTestUtils::load_from_file(m_fem, m_param.m_frontEndName, m_param.m_modelName); } std::vector FrontEndCutModelTest::constructNewInputs() const diff --git a/ngraph/test/frontend/shared/src/main.cpp b/ngraph/test/frontend/shared/src/main.cpp new file mode 100644 index 00000000000000..3828e04f333aed --- /dev/null +++ b/ngraph/test/frontend/shared/src/main.cpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "gtest/gtest.h" + +using namespace std; + +namespace FrontEndTestUtils +{ + int run_tests(int argc, char** argv) + { + ::testing::InitGoogleTest(&argc, argv); + int rc = RUN_ALL_TESTS(); + return rc; + } +} // namespace FrontEndTestUtils \ No newline at end of file diff --git a/ngraph/test/frontend/shared/src/op_fuzzy.cpp b/ngraph/test/frontend/shared/src/op_fuzzy.cpp index 50a973cd9eee2d..a668de217fefb1 100644 --- a/ngraph/test/frontend/shared/src/op_fuzzy.cpp +++ b/ngraph/test/frontend/shared/src/op_fuzzy.cpp @@ -40,12 +40,8 @@ void FrontEndFuzzyOpTest::initParamTest() void FrontEndFuzzyOpTest::doLoadFromFile() { - std::vector frontends; - ASSERT_NO_THROW(frontends = m_fem.get_available_front_ends()); - ASSERT_NO_THROW(m_frontEnd = m_fem.load_by_framework(m_feName)); - ASSERT_NE(m_frontEnd, nullptr); - ASSERT_NO_THROW(m_inputModel = m_frontEnd->load(m_modelFile)); - ASSERT_NE(m_inputModel, nullptr); + std::tie(m_frontEnd, m_inputModel) = + FrontEndTestUtils::load_from_file(m_fem, m_feName, m_modelFile); } template diff --git a/ngraph/test/frontend/shared/src/partial_shape.cpp b/ngraph/test/frontend/shared/src/partial_shape.cpp index a35c54680e5294..2d74fc270975d8 100644 --- a/ngraph/test/frontend/shared/src/partial_shape.cpp +++ b/ngraph/test/frontend/shared/src/partial_shape.cpp @@ -38,13 +38,8 @@ void FrontEndPartialShapeTest::initParamTest() void FrontEndPartialShapeTest::doLoadFromFile() { - std::vector frontends; - FrontEnd::Ptr fe; - ASSERT_NO_THROW(frontends = m_fem.get_available_front_ends()); - ASSERT_NO_THROW(m_frontEnd = m_fem.load_by_framework(m_baseParam.m_frontEndName)); - ASSERT_NE(m_frontEnd, nullptr); - ASSERT_NO_THROW(m_inputModel = m_frontEnd->load(m_partShape.m_modelName)); - ASSERT_NE(m_inputModel, nullptr); + std::tie(m_frontEnd, m_inputModel) = FrontEndTestUtils::load_from_file( + m_fem, m_baseParam.m_frontEndName, m_partShape.m_modelName); } /////////////////////////////////////////////////////////////////// diff --git a/ngraph/test/frontend/shared/src/set_element_type.cpp b/ngraph/test/frontend/shared/src/set_element_type.cpp index 5cfbdce990b4d9..9b29a308298b63 100644 --- a/ngraph/test/frontend/shared/src/set_element_type.cpp +++ b/ngraph/test/frontend/shared/src/set_element_type.cpp @@ -31,13 +31,8 @@ void FrontEndElementTypeTest::initParamTest() void FrontEndElementTypeTest::doLoadFromFile() { - std::vector frontends; - FrontEnd::Ptr fe; - ASSERT_NO_THROW(frontends = m_fem.get_available_front_ends()); - ASSERT_NO_THROW(m_frontEnd = m_fem.load_by_framework(m_param.m_frontEndName)); - ASSERT_NE(m_frontEnd, nullptr); - ASSERT_NO_THROW(m_inputModel = m_frontEnd->load(m_param.m_modelName)); - ASSERT_NE(m_inputModel, nullptr); + std::tie(m_frontEnd, m_inputModel) = + FrontEndTestUtils::load_from_file(m_fem, m_param.m_frontEndName, m_param.m_modelName); } ///////////////////////////////////////////////////////////////////