|
|
@ -1,5 +1,7 @@
|
|
|
|
file(GLOB GENERAL_OPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*_op.cc")
|
|
|
|
file(GLOB GENERAL_OPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*_op.cc")
|
|
|
|
string(REPLACE ".cc" "" GENERAL_OPS "${GENERAL_OPS}")
|
|
|
|
string(REPLACE ".cc" "" GENERAL_OPS "${GENERAL_OPS}")
|
|
|
|
|
|
|
|
set(pybind_file ${PADDLE_SOURCE_DIR}/paddle/pybind/pybind.h)
|
|
|
|
|
|
|
|
file(WRITE ${pybind_file} "// Generated by the paddle/operator/CMakeLists.txt. DO NOT EDIT!\n\n")
|
|
|
|
function(op_library TARGET)
|
|
|
|
function(op_library TARGET)
|
|
|
|
# op_library is a function to create op library. The interface is same as
|
|
|
|
# op_library is a function to create op library. The interface is same as
|
|
|
|
# cc_library. But it handle split GPU/CPU code and link some common library
|
|
|
|
# cc_library. But it handle split GPU/CPU code and link some common library
|
|
|
@ -11,6 +13,7 @@ function(op_library TARGET)
|
|
|
|
set(options "")
|
|
|
|
set(options "")
|
|
|
|
set(oneValueArgs "")
|
|
|
|
set(oneValueArgs "")
|
|
|
|
set(multiValueArgs SRCS DEPS)
|
|
|
|
set(multiValueArgs SRCS DEPS)
|
|
|
|
|
|
|
|
set(pybind_flag 0)
|
|
|
|
cmake_parse_arguments(op_library "${options}" "${oneValueArgs}"
|
|
|
|
cmake_parse_arguments(op_library "${options}" "${oneValueArgs}"
|
|
|
|
"${multiValueArgs}" ${ARGN})
|
|
|
|
"${multiValueArgs}" ${ARGN})
|
|
|
|
|
|
|
|
|
|
|
@ -46,15 +49,40 @@ function(op_library TARGET)
|
|
|
|
cc_library(${TARGET} SRCS ${cc_srcs} DEPS ${op_library_DEPS}
|
|
|
|
cc_library(${TARGET} SRCS ${cc_srcs} DEPS ${op_library_DEPS}
|
|
|
|
${op_common_deps})
|
|
|
|
${op_common_deps})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# net_op doesn't need pybind
|
|
|
|
|
|
|
|
if ("${TARGET}" STREQUAL "net_op")
|
|
|
|
|
|
|
|
set(pybind_flag 1)
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# pybind USE_NO_KERNEL_OP
|
|
|
|
|
|
|
|
file(READ ${TARGET}.cc TARGET_CONTENT)
|
|
|
|
|
|
|
|
string(REGEX MATCH "OperatorWithKernel" regex_result "${TARGET_CONTENT}")
|
|
|
|
|
|
|
|
string(REPLACE "_op" "" TARGET "${TARGET}")
|
|
|
|
|
|
|
|
if (${pybind_flag} EQUAL 0 AND regex_result STREQUAL "")
|
|
|
|
|
|
|
|
file(APPEND ${pybind_file} "USE_NO_KERNEL_OP(${TARGET});\n")
|
|
|
|
|
|
|
|
set(pybind_flag 1)
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# pybind USE_CPU_ONLY_OP
|
|
|
|
|
|
|
|
list(LENGTH cu_srcs cu_srcs_len)
|
|
|
|
|
|
|
|
if (${pybind_flag} EQUAL 0 AND ${cu_srcs_len} EQUAL 0)
|
|
|
|
|
|
|
|
file(APPEND ${pybind_file} "USE_CPU_ONLY_OP(${TARGET});\n")
|
|
|
|
|
|
|
|
set(pybind_flag 1)
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# pybind USE_OP
|
|
|
|
|
|
|
|
if (${pybind_flag} EQUAL 0)
|
|
|
|
|
|
|
|
file(APPEND ${pybind_file} "USE_OP(${TARGET});\n")
|
|
|
|
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
|
|
add_subdirectory(math)
|
|
|
|
add_subdirectory(math)
|
|
|
|
|
|
|
|
|
|
|
|
set(DEPS_OPS
|
|
|
|
set(DEPS_OPS
|
|
|
|
recurrent_op)
|
|
|
|
recurrent_op)
|
|
|
|
|
|
|
|
|
|
|
|
op_library(recurrent_op SRCS recurrent_op.cc rnn/recurrent_op_utils.cc
|
|
|
|
op_library(recurrent_op SRCS recurrent_op.cc rnn/recurrent_op_utils.cc
|
|
|
|
DEPS framework_proto tensor operator net_op)
|
|
|
|
DEPS framework_proto tensor net_op)
|
|
|
|
|
|
|
|
|
|
|
|
list(REMOVE_ITEM GENERAL_OPS ${DEPS_OPS})
|
|
|
|
list(REMOVE_ITEM GENERAL_OPS ${DEPS_OPS})
|
|
|
|
foreach(src ${GENERAL_OPS})
|
|
|
|
foreach(src ${GENERAL_OPS})
|
|
|
|