CMakeLists.txt 1.4 KB
Newer Older
W
Wu Yi 已提交
1
include(operators)
2 3 4 5
if(WITH_UNITY_BUILD)
    # Load Unity Build rules for operators in paddle/fluid/operators/reduce_ops.
    include(unity_build_rule.cmake)
endif()
P
peizhilin 已提交
6
if(WITH_GPU)
7 8 9 10 11
    if(${CMAKE_CUDA_COMPILER_VERSION} LESS 11.0)
        register_operators(DEPS cub)
    else()
        register_operators()
    endif()
P
peizhilin 已提交
12 13 14
else()
    register_operators()
endif()
W
Wu Yi 已提交
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

if(WITH_GPU)
    file(GLOB OPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.part.cu")
    string(REPLACE ".part.cu" "" OPS "${OPS}")

    foreach(src ${OPS})
        if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${src}.part.cu)
            set(CUDA_KERNEL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${src}.part.cu)
            file(READ ${CUDA_KERNEL_FILE} TARGET_CONTENT)
            string(REGEX MATCH "REGISTER_OP_CUDA_KERNEL\\(\\n?([^,]+),.*" MATCHED ${TARGET_CONTENT})
            if (MATCHED)
                string(STRIP ${CMAKE_MATCH_1} MATCHED)
                file(APPEND ${pybind_file} "USE_OP_DEVICE_KERNEL(${MATCHED}, CUDA);\n")
            endif()

        endif()
    endforeach()
endif()
33 34

if(WITH_GPU)
35 36 37 38 39
    if (${CMAKE_CUDA_COMPILER_VERSION} LESS 11.0)
	nv_test(check_reduce_rank_test SRCS check_reduce_rank_test.cu DEPS tensor cub)
    else()
	nv_test(check_reduce_rank_test SRCS check_reduce_rank_test.cu DEPS tensor)
    endif()
40
endif()
41 42 43 44

if(WITH_ASCEND_CL)
    cc_test(reduce_any_op_npu_test SRCS reduce_any_op_npu_test.cc DEPS op_registry reduce_any_op scope device_context enforce executor)
endif()