Skip to content

Commit 91bda36

Browse files
authored
Separate executable for paddlepaddle unit tests (openvinotoolkit#6862)
* Separate executable for paddlepaddle unit tests * Fix CI * Move PaddlePaddle-specific python requirements to paddlepaddle test folder Also produce build time warning when paddle test models generation is disabled * Renamed back PADDLE_TEST_MODELS_DIRNAME to TEST_PADDLE_MODELS_DIRNAME * Add dependency on CPU plugin (PaddlePaddle fuzzy tests use CPU plugin for inference) * Fix code style * Fix review comments #2 * Code style fix * Add dependency of 'paddlepaddle_test_models' to 'test_model_zoo'
1 parent 8f5d9a8 commit 91bda36

34 files changed

+238
-154
lines changed

.ci/azure/linux.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ jobs:
8585
python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/wheel/requirements-dev.txt
8686
# For running Python API tests
8787
python3 -m pip install -r $(REPO_DIR)/inference-engine/ie_bridges/python/src/requirements-dev.txt
88-
# For running nGraph unit tests dependent on Python frameworks
89-
python3 -m pip install -r $(REPO_DIR)/ngraph/test/requirements_test.txt
88+
# For running PaddlePaddle frontend unit tests
89+
python3 -m pip install -r $(REPO_DIR)/ngraph/test/frontend/paddlepaddle/requirements_dev.txt
90+
# For running ONNX frontend unit tests
9091
python3 -m pip install -r $(REPO_DIR)/ngraph/test/requirements_test_onnx.txt
9192
# For MO unit tests
9293
python3 -m pip install -r $(REPO_DIR)/model-optimizer/requirements.txt
@@ -171,13 +172,15 @@ jobs:
171172
displayName: 'Model Optimizer UT'
172173
continueOnError: false
173174
174-
- script: |
175-
export FE_TEST_MODELS=$(INSTALL_DIR)/tests
176-
. $(SETUPVARS) && $(INSTALL_TEST_DIR)/unit-test --gtest_print_time=1 --gtest_filter=-backend_api.config_unsupported:*IE_GPU* --gtest_output=xml:TEST-NGraphUT.xml
175+
- 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
177176
workingDirectory: $(INSTALL_TEST_DIR)
178177
displayName: 'nGraph UT'
179178
continueOnError: false
180179

180+
- 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
181+
displayName: 'PaddlePaddle Frontend UT'
182+
continueOnError: false
183+
181184
# . $(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
182185
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/InferenceEngineUnitTests --gtest_print_time=1 --gtest_output=xml:TEST-InferenceEngineUnitTests.xml
183186
displayName: 'IE UT old'

.ci/azure/windows.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ jobs:
8686
python -m pip install --upgrade pip
8787
rem For running Python API tests
8888
python -m pip install -r $(REPO_DIR)\inference-engine\ie_bridges\python\src\requirements-dev.txt
89-
rem For running nGraph unit tests dependent on Python frameworks
90-
python -m pip install -r $(REPO_DIR)\ngraph\test\requirements_test.txt
89+
rem For running PaddlePaddle frontend unit tests
90+
python -m pip install -r $(REPO_DIR)\ngraph\test\frontend\paddlepaddle\requirements_dev.txt
91+
rem For running ONNX frontend unit tests
9192
python -m pip install -r $(REPO_DIR)\ngraph\test\requirements_test_onnx.txt
9293
rem For MO unit tests
9394
python -m pip install -r $(REPO_DIR)\model-optimizer\requirements.txt
@@ -143,13 +144,15 @@ jobs:
143144
displayName: 'Clean build dir'
144145
continueOnError: false
145146

146-
- script: |
147-
set FE_TEST_MODELS=$(INSTALL_DIR)\tests
148-
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
147+
- 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
149148
workingDirectory: $(INSTALL_TEST_DIR)
150149
displayName: 'nGraph UT'
151150
continueOnError: false
152151

152+
- 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
153+
displayName: 'PaddlePaddle Frontend UT'
154+
continueOnError: false
155+
153156
- script: |
154157
set PATH=$(IB_DIR);%PATH%
155158
call $(SETUPVARS) && "$(IB_TESTCONSOLE)" $(INSTALL_TEST_DIR)\InferenceEngineUnitTests.exe --gtest_output=xml:TEST-InferenceEngineUnitTests-IB.xml

cmake/test_model_zoo.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ if(ENABLE_TESTS)
120120
add_dependencies(test_model_zoo test_pip_prerequsites)
121121
endif()
122122

123+
if (NGRAPH_PDPD_FRONTEND_ENABLE)
124+
add_dependencies(test_model_zoo paddlepaddle_test_models)
125+
endif()
126+
123127
install(DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test_model_zoo"
124128
DESTINATION tests COMPONENT tests EXCLUDE_FROM_ALL)
125129

ngraph/test/CMakeLists.txt

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -558,31 +558,10 @@ if (NGRAPH_ONNX_IMPORT_ENABLE)
558558
endif()
559559

560560
# SOURCE FOR FRONTEND TESTING
561-
562561
file(GLOB FRONTEND_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/frontend/frontend_manager.cpp)
563562
set(SRC ${FRONTEND_TESTS_SRC} ${SRC})
564563

565-
file(GLOB FRONTEND_SHARED_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/frontend/shared/src/*.cpp)
566-
file(GLOB FRONTEND_SHARED_TESTS_HDR ${CMAKE_CURRENT_SOURCE_DIR}/frontend/shared/include/*.hpp)
567-
set(SRC ${FRONTEND_SHARED_TESTS_SRC} ${SRC})
568-
569-
add_definitions("-DTEST_MODEL_BUILD_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\"")
570-
571-
# ---- PaddlePaddle FrontEnd testing ------
572-
if (NGRAPH_PDPD_FRONTEND_ENABLE)
573-
ie_check_pip_package(paddlepaddle WARNING)
574-
575-
if(paddlepaddle_FOUND)
576-
file(GLOB FRONTEND_PDPD_TESTS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/frontend/paddlepaddle/*.cpp)
577-
set(SRC ${FRONTEND_PDPD_TESTS_SRC} ${SRC})
578-
set(PADDLE_TEST_MODELS_DIRNAME paddle_test_models)
579-
set(TEST_PADDLE_MODELS ${CMAKE_CURRENT_BINARY_DIR}/${PADDLE_TEST_MODELS_DIRNAME}/)
580-
add_definitions("-DTEST_PADDLE_MODELS_DIRNAME=\"${PADDLE_TEST_MODELS_DIRNAME}/\"")
581-
endif()
582-
endif()
583-
# ---- End PaddlePaddle FrontEnd testing ------
584-
585-
add_clang_format_target(unit-test_clang FOR_SOURCES ${SRC} ${MULTI_TEST_SRC} ${FRONTEND_SHARED_TESTS_HDR})
564+
add_clang_format_target(unit-test_clang FOR_SOURCES ${SRC} ${MULTI_TEST_SRC})
586565

587566
foreach(BACKEND_NAME ${ACTIVE_BACKEND_LIST})
588567
string(TOLOWER ${BACKEND_NAME} BACKEND_DIR)
@@ -603,7 +582,6 @@ add_executable(unit-test ${SRC})
603582

604583
target_include_directories(unit-test PRIVATE ".")
605584
target_include_directories(unit-test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/runtime)
606-
target_include_directories(unit-test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/frontend/shared/include)
607585

608586
add_definitions("-DCURDIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"")
609587
add_definitions("-DJSON_INCLUDES=\"${JSON_INCLUDE_DIR}\"")
@@ -618,7 +596,8 @@ target_link_libraries(unit-test PRIVATE ngraph_test_util
618596
ie_backend
619597
interpreter_backend
620598
Threads::Threads
621-
openvino::conditional_compilation)
599+
openvino::conditional_compilation
600+
frontend_manager)
622601

623602
# Protobuf-lite does not support parsing files from prototxt format
624603
# Since most of the onnx models are stored in this format it have to be disabled
@@ -655,39 +634,7 @@ install(TARGETS unit-test
655634
COMPONENT tests
656635
EXCLUDE_FROM_ALL)
657636

658-
############ FRONTEND ############
659-
target_include_directories(unit-test PRIVATE ${FRONTEND_INCLUDE_PATH} frontend/shared/include)
660-
target_link_libraries(unit-test PRIVATE frontend_manager cnpy commonTestUtils)
661-
662637
add_subdirectory(frontend)
663-
### END FRONTEND ###
664-
665-
#PaddlePaddle - test models generator
666-
if (NGRAPH_PDPD_FRONTEND_ENABLE AND paddlepaddle_FOUND)
667-
file(GLOB_RECURSE PDPD_GEN_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/files/paddlepaddle/gen_scripts/generate_*.py)
668-
set(OUT_FILES "")
669-
foreach(GEN_SCRIPT ${PDPD_GEN_SCRIPTS})
670-
get_filename_component(FILE_WE ${GEN_SCRIPT} NAME_WE)
671-
set(OUT_DONE_FILE ${TEST_PADDLE_MODELS}/${FILE_WE}_done.txt)
672-
set(OUT_FILES ${OUT_DONE_FILE} ${OUT_FILES})
673-
add_custom_command(OUTPUT ${OUT_DONE_FILE}
674-
COMMAND ${PYTHON_EXECUTABLE}
675-
${CMAKE_CURRENT_SOURCE_DIR}/files/paddlepaddle/gen_wrapper.py
676-
${GEN_SCRIPT}
677-
${TEST_PADDLE_MODELS}
678-
${OUT_DONE_FILE}
679-
DEPENDS ${GEN_SCRIPT} ${CMAKE_CURRENT_SOURCE_DIR}/files/paddlepaddle/gen_wrapper.py
680-
)
681-
endforeach()
682-
add_custom_target(paddlepaddle_test_models DEPENDS ${OUT_FILES})
683-
add_dependencies(unit-test paddlepaddle_test_models)
684-
add_dependencies(unit-test paddlepaddle_ngraph_frontend)
685-
686-
install(DIRECTORY ${TEST_PADDLE_MODELS}
687-
DESTINATION tests/${PADDLE_TEST_MODELS_DIRNAME}
688-
COMPONENT tests
689-
EXCLUDE_FROM_ALL)
690-
endif()
691638

692639
# process models
693640
add_dependencies(unit-test test_model_zoo)

ngraph/test/frontend/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Copyright (C) 2018-2021 Intel Corporation
22
# SPDX-License-Identifier: Apache-2.0
33
#
4+
add_subdirectory(shared)
5+
6+
if (NGRAPH_PDPD_FRONTEND_ENABLE)
7+
add_subdirectory(paddlepaddle)
8+
endif()
49

510
set(SRC ${CMAKE_CURRENT_SOURCE_DIR}/mock_frontend.cpp)
611
add_library(mock1_ngraph_frontend SHARED ${SRC})
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright (C) 2018-2021 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
5+
set(TARGET_NAME "paddlepaddle_tests")
6+
7+
file(GLOB_RECURSE SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
8+
9+
add_executable(${TARGET_NAME} ${SRC})
10+
11+
target_link_libraries(${TARGET_NAME} PRIVATE frontend_shared_test_classes)
12+
13+
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
14+
15+
install(TARGETS ${TARGET_NAME}
16+
RUNTIME DESTINATION tests
17+
COMPONENT tests
18+
EXCLUDE_FROM_ALL)
19+
20+
# Test model generating
21+
ie_check_pip_package(paddlepaddle WARNING)
22+
23+
set(TEST_PADDLE_MODELS_DIRNAME test_model_zoo/paddle_test_models)
24+
target_compile_definitions(${TARGET_NAME} PRIVATE -D TEST_PADDLE_MODELS_DIRNAME=\"${TEST_PADDLE_MODELS_DIRNAME}/\")
25+
26+
# If 'paddlepaddle' is not found, code will still be compiled
27+
# but models will not be generated and tests will fail
28+
# This is done this way for 'code style' and check cases - cmake shall pass, but CI machine doesn't need to have
29+
# 'paddlepaddle' installed to check code style
30+
if (paddlepaddle_FOUND)
31+
set(TEST_PADDLE_MODELS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_PADDLE_MODELS_DIRNAME}/)
32+
33+
file(GLOB_RECURSE PADDLE_GEN_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/test_models/gen_scripts/generate_*.py)
34+
file(GLOB_RECURSE PADDLE_ALL_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/*.py)
35+
set(OUT_FILES "")
36+
foreach(GEN_SCRIPT ${PADDLE_GEN_SCRIPTS})
37+
get_filename_component(FILE_WE ${GEN_SCRIPT} NAME_WE)
38+
set(OUT_DONE_FILE ${TEST_PADDLE_MODELS}/${FILE_WE}_done.txt)
39+
set(OUT_FILES ${OUT_DONE_FILE} ${OUT_FILES})
40+
add_custom_command(OUTPUT ${OUT_DONE_FILE}
41+
COMMAND ${PYTHON_EXECUTABLE}
42+
${CMAKE_CURRENT_SOURCE_DIR}/test_models/gen_wrapper.py
43+
${GEN_SCRIPT}
44+
${TEST_PADDLE_MODELS}
45+
${OUT_DONE_FILE}
46+
DEPENDS ${PADDLE_ALL_SCRIPTS}
47+
)
48+
endforeach()
49+
add_custom_target(paddlepaddle_test_models DEPENDS ${OUT_FILES})
50+
51+
install(DIRECTORY ${TEST_PADDLE_MODELS}
52+
DESTINATION tests/${TEST_PADDLE_MODELS_DIRNAME}
53+
COMPONENT tests
54+
EXCLUDE_FROM_ALL)
55+
else()
56+
# Produce warning message at build time as well
57+
add_custom_command(OUTPUT unable_build_paddle_models.txt
58+
COMMAND ${CMAKE_COMMAND}
59+
-E cmake_echo_color --red "Warning: Unable to generate PaddlePaddle test models. Running '${TARGET_NAME}' will likely fail"
60+
)
61+
add_custom_target(paddlepaddle_test_models DEPENDS unable_build_paddle_models.txt)
62+
endif()
63+
64+
add_dependencies(${TARGET_NAME} paddlepaddle_test_models)
65+
add_dependencies(${TARGET_NAME} paddlepaddle_ngraph_frontend)
66+
67+
# Fuzzy tests for PaddlePaddle use IE_CPU engine
68+
if (ENABLE_MKL_DNN)
69+
add_dependencies(${TARGET_NAME} MKLDNNPlugin)
70+
endif()

ngraph/test/frontend/paddlepaddle/incorrect_cut_model.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ TEST(FrontEndIncorrectCutModelTest, test_incorrect_cut)
2121
ASSERT_NO_THROW(frontEnd = fem.load_by_framework(PADDLE_FE));
2222
ASSERT_NE(frontEnd, nullptr);
2323
auto model_filename = FrontEndTestUtils::make_model_path(
24-
std::string(TEST_PADDLE_MODELS_DIRNAME) +
25-
std::string("2in_2out/2in_2out.pdmodel"));
24+
std::string(TEST_PADDLE_MODELS_DIRNAME) + std::string("2in_2out/2in_2out.pdmodel"));
2625
ASSERT_NO_THROW(inputModel = frontEnd->load(model_filename));
2726
ASSERT_NE(inputModel, nullptr);
2827

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (C) 2018-2021 Intel Corporation
2+
// SPDX-License-Identifier: Apache-2.0
3+
//
4+
5+
#include "utils.hpp"
6+
7+
int main(int argc, char** argv)
8+
{
9+
return FrontEndTestUtils::run_tests(argc, argv);
10+
}

ngraph/test/frontend/paddlepaddle/paddle_utils.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
#include <string>
88

99
static const std::string PADDLE_FE = "paddle";
10+

0 commit comments

Comments
 (0)