diff --git a/cmake/external/xpu.cmake b/cmake/external/xpu.cmake index 07fe7d245ef57814d704d11be6f6fe45cf514b2d..eb00b822209c53a55226a324440eb86e52ad7de7 100644 --- a/cmake/external/xpu.cmake +++ b/cmake/external/xpu.cmake @@ -4,30 +4,26 @@ endif() INCLUDE(ExternalProject) SET(XPU_PROJECT "extern_xpu") -SET(XPU_URL "https://baidu-kunlun-public.su.bcebos.com/paddle_depence/xpu.tar.gz" CACHE STRING "" FORCE) +SET(XPU_URL "https://baidu-kunlun-public.su.bcebos.com/paddle_depence/xpu_2020_09_22_api_2020_11_05.tar.gz" CACHE STRING "" FORCE) SET(XPU_SOURCE_DIR "${THIRD_PARTY_PATH}/xpu") SET(XPU_DOWNLOAD_DIR "${XPU_SOURCE_DIR}/src/${XPU_PROJECT}") SET(XPU_INSTALL_DIR "${THIRD_PARTY_PATH}/install/xpu") -SET(XPU_API_INC_DIR "${THIRD_PARTY_PATH}/install/xpu/api/include") -SET(XPU_RUNTIME_INC_DIR "${THIRD_PARTY_PATH}/install/xpu/runtime/include") +SET(XPU_API_INC_DIR "${THIRD_PARTY_PATH}/install/xpu/include") SET(XPU_LIB_DIR "${THIRD_PARTY_PATH}/install/xpu/lib") SET(XPU_API_LIB_NAME "libxpuapi.so") SET(XPU_RT_LIB_NAME "libxpurt.so") -SET(XPU_SIM_LIB_NAME "libxpusim.so") SET(XPU_API_LIB "${XPU_LIB_DIR}/${XPU_API_LIB_NAME}") SET(XPU_RT_LIB "${XPU_LIB_DIR}/${XPU_RT_LIB_NAME}") -SET(XPU_SIM_LIB "${XPU_LIB_DIR}/${XPU_SIM_LIB_NAME}") SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}" "${XPU_INSTALL_DIR}/lib") INCLUDE_DIRECTORIES(${XPU_API_INC_DIR}) -INCLUDE_DIRECTORIES(${XPU_RUNTIME_INC_DIR}) FILE(WRITE ${XPU_DOWNLOAD_DIR}/CMakeLists.txt "PROJECT(XPU)\n" "cmake_minimum_required(VERSION 3.0)\n" - "install(DIRECTORY xpu/api xpu/runtime xpu/lib \n" + "install(DIRECTORY xpu/include xpu/lib \n" " DESTINATION ${XPU_INSTALL_DIR})\n") ExternalProject_Add( @@ -50,5 +46,5 @@ set_property(TARGET shared_xpuapi PROPERTY IMPORTED_LOCATION "${XPU_API_LIB}") # for cc_library(xxx SRCS xxx.c DEPS xpulib) generate_dummy_static_lib(LIB_NAME "xpulib" GENERATOR "xpu.cmake") -TARGET_LINK_LIBRARIES(xpulib ${XPU_API_LIB} ${XPU_RT_LIB} ${XPU_SIM_LIB}) +TARGET_LINK_LIBRARIES(xpulib ${XPU_API_LIB} ${XPU_RT_LIB}) ADD_DEPENDENCIES(xpulib ${XPU_PROJECT}) diff --git a/paddle/fluid/operators/batch_norm_op_xpu.cc b/paddle/fluid/operators/batch_norm_op_xpu.cc index 624d5fe65ead74c4c920a3c3ea55fdc74aec1a67..c9208362bc8d259dc84075b7c48b5ee3b1cf6d9e 100644 --- a/paddle/fluid/operators/batch_norm_op_xpu.cc +++ b/paddle/fluid/operators/batch_norm_op_xpu.cc @@ -15,6 +15,7 @@ limitations under the License. */ #ifdef PADDLE_WITH_XPU #include "paddle/fluid/operators/batch_norm_op.h" +#include "xpu/refactor/nn.h" namespace paddle { namespace operators { @@ -72,10 +73,10 @@ class BatchNormXPUKernel : public framework::OpKernel { auto* variance_out_data = variance_out->data(); auto* saved_mean_data = saved_mean->data(); auto* saved_variance_data = saved_variance->data(); - int r = xpu::batch_norm_train_forward( - dev_ctx.x_context(), epsilon, momentum, N, C, H, W, x_data, y_data, - scale_data, bias_data, mean_out_data, variance_out_data, - saved_mean_data, saved_variance_data); + int r = xpu::batch_norm(dev_ctx.x_context(), x_data, y_data, N, C, H, + W, epsilon, momentum, scale_data, bias_data, + saved_mean_data, saved_variance_data, + mean_out_data, variance_out_data, true); PADDLE_ENFORCE_EQ( r, XPU_SUCCESS, platform::errors::External("XPU API(batch_norm_train_forward) return " diff --git a/python/setup.py.in b/python/setup.py.in index b7a6289d38f173f1a8f5a261f270712ac8d4b307..a4570c9d195636f4f8c96d2ceb8904e3a6eaae81 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -319,10 +319,8 @@ if '${WITH_XPU}' == 'ON': raise Exception("patch ${XPU_API_LIB} failed, command: %s" % command) shutil.copy('${XPU_API_LIB}', libs_path) shutil.copy('${XPU_RT_LIB}', libs_path) - shutil.copy('${XPU_SIM_LIB}', libs_path) package_data['paddle.libs']+=['${XPU_API_LIB_NAME}', - '${XPU_RT_LIB_NAME}', - '${XPU_SIM_LIB_NAME}'] + '${XPU_RT_LIB_NAME}'] # copy libfuild_framework.so to libs if os.name != 'nt' and sys.platform != 'darwin':