Skip to content

Commit

Permalink
modify custom op dependent from paddle_framework to paddle_custom_op (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwesky2010 committed Feb 24, 2021
1 parent 0f1fde5 commit ffbf713
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
9 changes: 5 additions & 4 deletions paddle/fluid/framework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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")
Expand Down
18 changes: 13 additions & 5 deletions paddle/scripts/paddle_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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 (
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion python/paddle/utils/cpp_extension/extension_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
'/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']

Expand Down
10 changes: 6 additions & 4 deletions python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down

0 comments on commit ffbf713

Please sign in to comment.