diff --git a/python/paddle/base/executor.py b/python/paddle/base/executor.py index 7311991b021cd..a527abf7b5992 100755 --- a/python/paddle/base/executor.py +++ b/python/paddle/base/executor.py @@ -22,6 +22,8 @@ import numpy as np from paddle import pir +from paddle.base.framework import in_cinn_mode +from paddle.base.libpaddle.pir import apply_cinn_pass from ..pir import ( Program as PirProgram, @@ -1072,6 +1074,9 @@ def _get_program_and_executor(self, cached_data): pir_program, param_mapping, new_program._grad_var_to_var ) + if in_cinn_mode(): + apply_cinn_pass(pir_program) + type_to_program = {"default": pir_program} else: diff --git a/test/cpp/inference/test.cmake b/test/cpp/inference/test.cmake index 03839871580d7..460ab409fa672 100644 --- a/test/cpp/inference/test.cmake +++ b/test/cpp/inference/test.cmake @@ -58,19 +58,24 @@ function(inference_download_and_uncompress_without_verify INSTALL_DIR URL string(REGEX MATCH "[^/\\]+$" DOWNLOAD_NAME ${FILENAME}) set(EXTERNAL_PROJECT_NAME "extern_download_${FILENAME_EX}") set(UNPACK_DIR "${INSTALL_DIR}/src/${EXTERNAL_PROJECT_NAME}") - ExternalProject_Add( - ${EXTERNAL_PROJECT_NAME} - ${EXTERNAL_PROJECT_LOG_ARGS} - PREFIX ${INSTALL_DIR} - URL ${URL}/${FILENAME} - DOWNLOAD_DIR ${INSTALL_DIR} - DOWNLOAD_NO_EXTRACT 1 - DOWNLOAD_NO_PROGRESS 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND ${CMAKE_COMMAND} -E chdir ${INSTALL_DIR} ${CMAKE_COMMAND} -E - tar xzf ${DOWNLOAD_NAME} - UPDATE_COMMAND "" - INSTALL_COMMAND "") + + get_property(TARGET_EXIST GLOBAL PROPERTY ${EXTERNAL_PROJECT_NAME}) + if(NOT "${TARGET_EXIST}" STREQUAL EXIST) + ExternalProject_Add( + ${EXTERNAL_PROJECT_NAME} + ${EXTERNAL_PROJECT_LOG_ARGS} + PREFIX ${INSTALL_DIR} + URL ${URL}/${FILENAME} + DOWNLOAD_DIR ${INSTALL_DIR} + DOWNLOAD_NO_EXTRACT 1 + DOWNLOAD_NO_PROGRESS 1 + CONFIGURE_COMMAND "" + BUILD_COMMAND ${CMAKE_COMMAND} -E chdir ${INSTALL_DIR} ${CMAKE_COMMAND} -E + tar xzf ${DOWNLOAD_NAME} + UPDATE_COMMAND "" + INSTALL_COMMAND "") + set_property(GLOBAL PROPERTY ${EXTERNAL_PROJECT_NAME} "EXIST") + endif() endfunction() function(inference_base_test_build TARGET) diff --git a/test/deprecated/cpp/inference/api/CMakeLists.txt b/test/deprecated/cpp/inference/api/CMakeLists.txt index 86445c64c83bd..93cddd49a704b 100644 --- a/test/deprecated/cpp/inference/api/CMakeLists.txt +++ b/test/deprecated/cpp/inference/api/CMakeLists.txt @@ -470,6 +470,7 @@ if(WITH_TESTING AND WITH_INFERENCE_API_TEST) # resnet50 set(RESNET50_MODEL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/resnet50") + download_data_without_verify(${RESNET50_MODEL_DIR} "resnet50_model.tar.gz") inference_analysis_api_test_with_fake_data_run( test_analyzer_resnet50 ${IMG_CLASS_TEST_APP} ${RESNET50_MODEL_DIR} true) if(WIN32) diff --git a/test/deprecated/cpp/inference/test.cmake b/test/deprecated/cpp/inference/test.cmake index 5ceef8e85cb49..66644c418b64e 100644 --- a/test/deprecated/cpp/inference/test.cmake +++ b/test/deprecated/cpp/inference/test.cmake @@ -58,19 +58,23 @@ function(inference_download_and_uncompress_without_verify INSTALL_DIR URL string(REGEX MATCH "[^/\\]+$" DOWNLOAD_NAME ${FILENAME}) set(EXTERNAL_PROJECT_NAME "extern_download_${FILENAME_EX}") set(UNPACK_DIR "${INSTALL_DIR}/src/${EXTERNAL_PROJECT_NAME}") - ExternalProject_Add( - ${EXTERNAL_PROJECT_NAME} - ${EXTERNAL_PROJECT_LOG_ARGS} - PREFIX ${INSTALL_DIR} - URL ${URL}/${FILENAME} - DOWNLOAD_DIR ${INSTALL_DIR} - DOWNLOAD_NO_EXTRACT 1 - DOWNLOAD_NO_PROGRESS 1 - CONFIGURE_COMMAND "" - BUILD_COMMAND ${CMAKE_COMMAND} -E chdir ${INSTALL_DIR} ${CMAKE_COMMAND} -E - tar xzf ${DOWNLOAD_NAME} - UPDATE_COMMAND "" - INSTALL_COMMAND "") + get_property(TARGET_EXIST GLOBAL PROPERTY ${EXTERNAL_PROJECT_NAME}) + if(NOT "${TARGET_EXIST}" STREQUAL EXIST) + ExternalProject_Add( + ${EXTERNAL_PROJECT_NAME} + ${EXTERNAL_PROJECT_LOG_ARGS} + PREFIX ${INSTALL_DIR} + URL ${URL}/${FILENAME} + DOWNLOAD_DIR ${INSTALL_DIR} + DOWNLOAD_NO_EXTRACT 1 + DOWNLOAD_NO_PROGRESS 1 + CONFIGURE_COMMAND "" + BUILD_COMMAND ${CMAKE_COMMAND} -E chdir ${INSTALL_DIR} ${CMAKE_COMMAND} -E + tar xzf ${DOWNLOAD_NAME} + UPDATE_COMMAND "" + INSTALL_COMMAND "") + set_property(GLOBAL PROPERTY ${EXTERNAL_PROJECT_NAME} "EXIST") + endif() endfunction() function(inference_base_test_build TARGET) @@ -164,6 +168,11 @@ endfunction() set(WORD2VEC_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/word2vec") set(WORD2VEC_MODEL_DIR "${WORD2VEC_INSTALL_DIR}/word2vec.inference.model") +if(NOT EXISTS ${WORD2VEC_INSTALL_DIR}/word2vec.inference.model.tar.gz) + inference_download_and_uncompress_without_verify( + ${WORD2VEC_INSTALL_DIR} ${INFERENCE_URL} "word2vec.inference.model.tar.gz") +endif() + set(IMG_CLS_RESNET_INSTALL_DIR "${INFERENCE_DEMO_INSTALL_DIR}/image_classification_resnet") set(IMG_CLS_RESNET_MODEL_DIR