From ffbf71359a260031f4202dd4e6bab7efebaa90da Mon Sep 17 00:00:00 2001 From: Zhou Wei <52485244+zhouwei25@users.noreply.github.com> Date: Wed, 24 Feb 2021 23:18:57 +0800 Subject: [PATCH] modify custom op dependent from paddle_framework to paddle_custom_op (#31195) --- paddle/fluid/framework/CMakeLists.txt | 9 +++++---- paddle/scripts/paddle_build.bat | 18 +++++++++++++----- .../utils/cpp_extension/extension_utils.py | 2 +- python/setup.py.in | 10 ++++++---- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/paddle/fluid/framework/CMakeLists.txt b/paddle/fluid/framework/CMakeLists.txt index 482b5245b97..6e282a2e91c 100644 --- a/paddle/fluid/framework/CMakeLists.txt +++ b/paddle/fluid/framework/CMakeLists.txt @@ -328,9 +328,10 @@ cc_test(custom_tensor_test SRCS custom_tensor_test.cc DEPS custom_tensor glog) set(FLUID_FRAMEWORK_MODULES proto_desc memory lod_tensor executor data_feed_proto layer dynamic_loader custom_operator) cc_library(paddle_framework DEPS ${FLUID_FRAMEWORK_MODULES}) + +# Old custom op extension mechanism related, will be removed in 2.1.0 cc_library(paddle_framework_shared - SHARED SRCS executor.cc operator.cc custom_operator.cc ../extension/src/tensor.cc - ../extension/src/op_meta_info.cc + SHARED SRCS executor.cc operator.cc ${CMAKE_CURRENT_SOURCE_DIR}/c/c_api.cc ${CMAKE_SOURCE_DIR}/paddle/fluid/imperative/layer.cc DEPS ${FLUID_FRAMEWORK_MODULES}) @@ -382,9 +383,9 @@ if (LINUX) endif() if (WIN32) - set(PADDLE_CUSTOM_OP_SHARED_LIB + set(PADDLE_CUSTOM_OP_IMPORT_LIB ${PADDLE_BINARY_DIR}/paddle/fluid/framework/${CMAKE_BUILD_TYPE}/paddle_custom_op.lib - CACHE INTERNAL "Paddle custom op lib") + CACHE INTERNAL "Paddle custom op import lib") set(PADDLE_CUSTOM_OP_SHARED_LIB ${PADDLE_BINARY_DIR}/paddle/fluid/framework/${CMAKE_BUILD_TYPE}/paddle_custom_op.dll CACHE INTERNAL "Paddle custom op dll") diff --git a/paddle/scripts/paddle_build.bat b/paddle/scripts/paddle_build.bat index ff89af62ded..dc2e3ab593c 100644 --- a/paddle/scripts/paddle_build.bat +++ b/paddle/scripts/paddle_build.bat @@ -28,6 +28,7 @@ if not exist %cache_dir%\tools ( ) taskkill /f /im op_function_generator.exe wmic process where name="op_function_generator.exe" call terminate +taskkill /f /im python.exe 2>NUL rem ------initialize common variable------ if not defined GENERATOR set GENERATOR="Visual Studio 14 2015 Win64" @@ -55,6 +56,7 @@ rem -------set cache build directory----------- rmdir build\python /s/q rmdir build\paddle_install_dir /s/q rmdir build\paddle_inference_install_dir /s/q +rmdir build\paddle_inference_c_install_dir /s/q del build\CMakeCache.txt : set CI_SKIP_CPP_TEST if only *.py changed @@ -77,7 +79,10 @@ setlocal enabledelayedexpansion git show-ref --verify --quiet refs/heads/last_pr if %ERRORLEVEL% EQU 0 ( git diff HEAD last_pr --stat --name-only - git diff HEAD last_pr --stat --name-only | findstr "cmake/[a-zA-Z]*\.cmake CMakeLists.txt" + git diff HEAD last_pr --stat --name-only | findstr "setup.py.in" + if %ERRORLEVEL% EQU 0 ( + rmdir build /s/q + ) git branch -D last_pr git branch last_pr ) else ( @@ -246,11 +251,15 @@ set /p day_before=< %cache_dir%\day.txt if %day_now% NEQ %day_before% ( echo %day_now% > %cache_dir%\day.txt type %cache_dir%\day.txt - if %day_now% EQU 25 ( + if %day_now% EQU 21 ( rmdir %cache_dir%\third_party_GPU/ /s/q rmdir %cache_dir%\third_party/ /s/q ) - if %day_now% EQU 10 ( + if %day_now% EQU 11 ( + rmdir %cache_dir%\third_party_GPU/ /s/q + rmdir %cache_dir%\third_party/ /s/q + ) + if %day_now% EQU 01 ( rmdir %cache_dir%\third_party_GPU/ /s/q rmdir %cache_dir%\third_party/ /s/q ) @@ -604,8 +613,7 @@ python -c "import shutil;shutil.make_archive('paddle_inference', 'zip', root_dir set /p libsize=< lib_size.txt for /F %%i in ("%libsize%") do ( set /a libsize_m=%%i/1024 - echo "Windows Paddle_Inference Size: !libsize_m!M" - echo ipipe_log_param_Windows_Paddle_Inference_Size: !libsize_m!M + echo "Windows Paddle_Inference ZIP Size: !libsize_m!M" ) goto:eof diff --git a/python/paddle/utils/cpp_extension/extension_utils.py b/python/paddle/utils/cpp_extension/extension_utils.py index c3c8aa22121..ee8505623af 100644 --- a/python/paddle/utils/cpp_extension/extension_utils.py +++ b/python/paddle/utils/cpp_extension/extension_utils.py @@ -44,7 +44,7 @@ MSVC_COMPILE_FLAGS = [ '/DBOOST_HAS_STATIC_ASSERT', '/DNDEBUG', '/DPADDLE_USE_DSO' ] -MSVC_LINK_FLAGS = ['/MACHINE:X64', 'paddle_framework.lib'] +MSVC_LINK_FLAGS = ['/MACHINE:X64', 'paddle_custom_op.lib'] COMMON_NVCC_FLAGS = ['-DPADDLE_WITH_CUDA', '-DEIGEN_USE_GPU', '-O3'] diff --git a/python/setup.py.in b/python/setup.py.in index 8bfe307a202..0e214c5c65f 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -335,21 +335,23 @@ if '${WITH_XPU_BKCL}' == 'ON': shutil.copy('${XPU_BKCL_LIB}', libs_path) package_data['paddle.libs']+=['${XPU_BKCL_LIB_NAME}'] +### Old custom op extension mechanism related, will be removed in 2.1.0 ### # copy libpaddle_framework.so to libs on linux if sys.platform.startswith('linux'): shutil.copy('${FLUID_FRAMEWORK_SHARED_LIB}', libs_path) package_data['paddle.libs'] += ['libpaddle_framework.so'] +### New custom op extension mechanism related ### # copy libpaddle_custom_op.so to libs on linux if sys.platform.startswith('linux'): shutil.copy('${PADDLE_CUSTOM_OP_SHARED_LIB}', libs_path) package_data['paddle.libs'] += ['libpaddle_custom_op.so'] -# copy paddle_framework.lib/paddle_framework.dll to libs on windows +# copy paddle_custom_op.lib/paddle_custom_op.dll to libs on Windows if os.name == 'nt': - shutil.copy('${FLUID_FRAMEWORK_IMPORT_LIB}', libs_path) - shutil.copy('${FLUID_FRAMEWORK_SHARED_LIB}', libs_path) - package_data['paddle.libs'] += ['paddle_framework.lib', 'paddle_framework.dll'] + shutil.copy('${PADDLE_CUSTOM_OP_IMPORT_LIB}', libs_path) + shutil.copy('${PADDLE_CUSTOM_OP_SHARED_LIB}', libs_path) + package_data['paddle.libs'] += ['paddle_custom_op.lib', 'paddle_custom_op.dll'] # remove unused paddle/libs/__init__.py if os.path.isfile(libs_path+'/__init__.py'): -- GitLab