Skip to content

Commit

Permalink
[XPU] Add XPU plugin support (#55101)
Browse files Browse the repository at this point in the history
* Add XPU plugin to support the customized ops or improve the performance of the fusion ops based on hand-written xpu micro kernels.

* refine README.md
  • Loading branch information
hong19860320 authored Jul 4, 2023
1 parent 57cb1c9 commit 6d5d9f2
Show file tree
Hide file tree
Showing 15 changed files with 811 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ option(WITH_TENSORRT "Compile PaddlePaddle with NVIDIA TensorRT" OFF)
option(WITH_XPU "Compile PaddlePaddle with BAIDU KUNLUN XPU" OFF)
option(WITH_XPU_KP "Compile PaddlePaddle with BAIDU XPU compiler " OFF)
option(WITH_XPU_XFT "Compile PaddlePaddle with BAIDU XPU-XFT" OFF)
option(WITH_XPU_PLUGIN "Compile PaddlePaddle with BAIDU XPU plugin" OFF)
option(WITH_WIN_DUMP_DBG "Compile with windows core dump debug mode" OFF)
option(WITH_ROCM "Compile PaddlePaddle with ROCM platform" OFF)
option(WITH_IPU "Compile PaddlePaddle with Graphcore IPU" OFF)
Expand Down
6 changes: 6 additions & 0 deletions cmake/external/xpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ if(WITH_XPTI)
set(XPU_XPTI_LIB "${XPU_LIB_DIR}/${XPU_XPTI_LIB_NAME}")
endif()

if(WITH_XPU_PLUGIN)
message(STATUS "Compile with XPU PLUGIN!")
add_definitions(-DPADDLE_WITH_XPU_PLUGIN)
include_directories(${CMAKE_SOURCE_DIR}/paddle/phi/kernels/xpu/plugin/include)
endif()

if(WITH_XPU_BKCL AND WITH_XPU_XFT)
target_link_libraries(xpulib ${XPU_API_LIB} ${XPU_RT_LIB} ${XPU_BKCL_LIB}
${XPU_XFT_LIB})
Expand Down
4 changes: 4 additions & 0 deletions paddle/phi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ endif()

if(WITH_XPU)
list(APPEND PHI_DEPS xpulib)
if(WITH_XPU_PLUGIN)
add_subdirectory(kernels/xpu/plugin)
list(APPEND PHI_DEPS xpuplugin)
endif()
endif()

set(PHI_SRCS
Expand Down
3 changes: 3 additions & 0 deletions paddle/phi/backends/xpu/xpu_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ limitations under the License. */
#include "xpu/runtime.h"
#include "xpu/runtime_ex.h"
#include "xpu/xdnn.h"
#ifdef PADDLE_WITH_XPU_PLUGIN
#include "xpu/plugin.h"
#endif

namespace xpu = baidu::xpu::api;

Expand Down
Loading

0 comments on commit 6d5d9f2

Please sign in to comment.