CMakeLists.txt 16.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
set(PYBIND_DEPS
    init
    pybind
    python
    proto_desc
    memory
    executor
    fleet_wrapper
    box_wrapper
    metrics
    prune
    feed_fetch_method
    pass
    generate_pass
    pass_builder
    parallel_executor
    profiler
    layer
    tracer
    engine
    scope_pool
    analysis_predictor
    imperative_profiler
    imperative_flag
    save_load_util
    dlpack_tensor
    device_context
    gloo_wrapper
    infer_io_utils
    heter_wrapper
    generator
    op_version_registry
    ps_gpu_wrapper
    custom_operator
    cost_model
    cuda_graph_with_memory_pool
    fleet_executor
    global_utils
    phi_utils
    tcp_store
    new_profiler)

if(WITH_PSCORE)
S
seemingwang 已提交
44 45
  set(PYBIND_DEPS ${PYBIND_DEPS} ps_service)
  set(PYBIND_DEPS ${PYBIND_DEPS} graph_py_service)
46
  if(WITH_HETERPS)
47 48
    set(PYBIND_DEPS ${PYBIND_DEPS} graph_gpu_wrapper)
  endif()
S
seemingwang 已提交
49
endif()
50
if(WITH_GPU OR WITH_ROCM)
51
  set(PYBIND_DEPS ${PYBIND_DEPS} dynload_cuda)
52
  set(PYBIND_DEPS ${PYBIND_DEPS} cuda_device_guard)
53 54
endif()

55
if(WITH_GPU)
56 57
  set(PYBIND_DEPS ${PYBIND_DEPS} cuda_profiler)
endif()
58
if(WITH_IPU)
J
jianghaicheng 已提交
59 60
  set(PYBIND_DEPS ${PYBIND_DEPS} ipu_info)
endif()
61

62
if(WITH_NCCL OR WITH_RCCL)
63
  set(PYBIND_DEPS ${PYBIND_DEPS} nccl_wrapper)
64
  set(PYBIND_DEPS ${PYBIND_DEPS} reducer)
65 66
endif()

67
if(WITH_XPU_BKCL)
68 69
  set(PYBIND_DEPS ${PYBIND_DEPS} reducer)
  set(PYBIND_DEPS ${PYBIND_DEPS} bkcl_context)
K
kuizhiqing 已提交
70 71 72
  set(PYBIND_DEPS ${PYBIND_DEPS} heter_ccl_context)
endif()

73
if(WITH_ASCEND_CL)
K
kuizhiqing 已提交
74 75 76
  set(PYBIND_DEPS ${PYBIND_DEPS} reducer)
  set(PYBIND_DEPS ${PYBIND_DEPS} hccl_context)
  set(PYBIND_DEPS ${PYBIND_DEPS} heter_ccl_context)
77 78
endif()

79
if(WITH_CNCL)
80
  set(PYBIND_DEPS ${PYBIND_DEPS} reducer)
81 82 83
  set(PYBIND_DEPS ${PYBIND_DEPS} cncl_context)
endif()

84
if(NOT WIN32)
85
  set(PYBIND_DEPS ${PYBIND_DEPS} data_loader)
86
  set(PYBIND_DEPS ${PYBIND_DEPS} mmap_allocator)
87
  if(WITH_GPU)
88 89
    set(PYBIND_DEPS ${PYBIND_DEPS} cuda_ipc_allocator)
  endif()
90
  if(WITH_NCCL OR WITH_RCCL)
91
    set(PYBIND_DEPS ${PYBIND_DEPS} nccl_context)
K
kuizhiqing 已提交
92
    set(PYBIND_DEPS ${PYBIND_DEPS} heter_ccl_context)
93
  endif()
94
endif()
F
flame 已提交
95

S
sneaxiy 已提交
96 97
if(WITH_PYTHON)
  list(APPEND PYBIND_DEPS py_func_op)
98
  list(APPEND PYBIND_DEPS py_layer_op)
S
sneaxiy 已提交
99
endif()
100 101

set(PYBIND_SRCS
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
    pybind.cc
    exception.cc
    protobuf.cc
    const_value.cc
    global_value_getter_setter.cc
    reader_py.cc
    fleet_wrapper_py.cc
    heter_wrapper_py.cc
    ps_gpu_wrapper_py.cc
    gloo_wrapper_py.cc
    box_helper_py.cc
    metrics_py.cc
    data_set_py.cc
    imperative.cc
    ir.cc
    bind_cost_model.cc
    bind_fleet_executor.cc
    inference_api.cc
    compatible.cc
    io.cc
    generator_py.cc
    communication.cc
    cuda_streams_py.cc)
125

126
if(NOT ON_INFER)
127 128 129 130 131
  set(PYBIND_DEPS ${PYBIND_DEPS} processgroup eager_reducer)
  if(WITH_NCCL)
    set(PYBIND_DEPS ${PYBIND_DEPS} processgroup_nccl)
    if(WITH_PSCORE)
      set(PYBIND_DEPS ${PYBIND_DEPS} processgroup_heter)
132
    endif()
133
  endif()
134 135
  if(WITH_GLOO)
    set(PYBIND_DEPS ${PYBIND_DEPS} processgroup_gloo)
136
  endif()
137
  if(WITH_ASCEND_CL)
138 139 140
    set(PYBIND_DEPS ${PYBIND_DEPS} processgroup_hccl)
    if(WITH_PSCORE)
      set(PYBIND_DEPS ${PYBIND_DEPS} processgroup_heter)
141
    endif()
142
  endif()
143 144 145
  set(PYBIND_SRCS ${PYBIND_SRCS} distributed_py.cc)
endif()

146
if(WITH_ASCEND)
147 148
  set(PYBIND_DEPS ${PYBIND_DEPS} ascend_wrapper)
  set(PYBIND_SRCS ${PYBIND_SRCS} ascend_wrapper_py.cc)
149
endif()
150

151 152 153
if(WITH_GLOO)
  set(PYBIND_DEPS ${PYBIND_DEPS} gloo_context)
  set(PYBIND_SRCS ${PYBIND_SRCS} gloo_context_py.cc)
154 155
  set(PYBIND_DEPS ${PYBIND_DEPS} imperative_gloo_context)
  set(PYBIND_DEPS ${PYBIND_DEPS} reducer)
156
endif()
157

158
if(WITH_CRYPTO)
Y
Yanghello 已提交
159 160
  set(PYBIND_DEPS ${PYBIND_DEPS} paddle_crypto)
  set(PYBIND_SRCS ${PYBIND_SRCS} crypto.cc)
161
endif()
162 163 164 165 166 167 168

if(WITH_PSLIB)
  set(DISTRIBUTE_COMPILE_FLAGS
      "-Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor -Wno-error=sign-compare -Wno-error=unused-variable -Wno-error=return-type -Wno-error=unused-but-set-variable -Wno-error=type-limits -Wno-error=unknown-pragmas -Wno-error=parentheses -Wno-error=unused-result"
  )
  if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
    set(DISTRIBUTE_COMPILE_FLAGS "${DISTRIBUTE_COMPILE_FLAGS} -faligned-new")
T
Thunderbrook 已提交
169
  endif()
170 171
  set_source_files_properties(
    heter_wrapper_py.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
172
endif()
173 174 175 176 177
if(WITH_PSCORE)
  if(WITH_ARM_BRPC)
    set(DISTRIBUTE_COMPILE_FLAGS
        "-faligned-new -Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor -Wno-error=sign-compare -Wno-error=unused-variable -Wno-error=return-type -Wno-error=unused-but-set-variable -Wno-error=unknown-pragmas -Wno-error=parentheses -Wno-error=unused-result"
    )
178
  else()
179 180 181
    set(DISTRIBUTE_COMPILE_FLAGS
        "-Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor -Wno-error=sign-compare -Wno-error=unused-variable -Wno-error=return-type -Wno-error=unused-but-set-variable -Wno-error=unknown-pragmas -Wno-error=parentheses -Wno-error=unused-result"
    )
182
  endif()
183 184
  set_source_files_properties(
    fleet_py.cc PROPERTIES COMPILE_FLAGS ${DISTRIBUTE_COMPILE_FLAGS})
1
123malin 已提交
185
  list(APPEND PYBIND_DEPS fleet communicator index_wrapper index_sampler)
T
tangwei12 已提交
186
  list(APPEND PYBIND_SRCS fleet_py.cc)
187
endif()
188

189
if(WITH_NCCL OR WITH_RCCL)
190 191 192
  list(APPEND PYBIND_SRCS nccl_wrapper_py.cc)
endif()

L
Leo Chen 已提交
193 194
if(WITH_PYTHON)
  # generate op pybind functions automatically for dygraph.
195 196 197 198 199 200 201 202 203 204 205
  if(WITH_ASCEND_CL)
    set(OP_FUNCTION_GENERETOR_DEPS
        pybind
        proto_desc
        executor
        layer
        tracer
        engine
        imperative_profiler
        imperative_flag
        ascend_wrapper)
206
  else()
207 208 209 210 211 212 213 214 215
    set(OP_FUNCTION_GENERETOR_DEPS
        pybind
        proto_desc
        executor
        layer
        tracer
        engine
        imperative_profiler
        imperative_flag)
216
  endif()
L
Leo Chen 已提交
217 218 219
  list(APPEND OP_FUNCTION_GENERETOR_DEPS ${GLOB_OP_LIB})
  list(APPEND OP_FUNCTION_GENERETOR_DEPS ${GLOB_OPERATOR_DEPS})

220
  if(WITH_NCCL OR WITH_RCCL)
L
Leo Chen 已提交
221
    list(APPEND OP_FUNCTION_GENERETOR_DEPS nccl_context)
222
  endif()
L
Leo Chen 已提交
223

224 225
  if(WITH_XPU_BKCL)
    list(APPEND OP_FUNCTION_GENERETOR_DEPS bkcl_context)
226
  endif()
227

228 229
  if(WITH_ASCEND_CL)
    list(APPEND OP_FUNCTION_GENERETOR_DEPS hccl_context)
230
  endif()
231

232 233
  if(WITH_CNCL)
    list(APPEND OP_FUNCTION_GENERETOR_DEPS cncl_context)
234
  endif()
235

L
Leo Chen 已提交
236
  add_executable(op_function_generator op_function_generator.cc)
237
  target_link_libraries(op_function_generator ${OP_FUNCTION_GENERETOR_DEPS})
238
  add_executable(eager_op_function_generator eager_op_function_generator.cc)
239 240
  target_link_libraries(eager_op_function_generator
                        ${OP_FUNCTION_GENERETOR_DEPS})
241 242
  if(NOT WIN32)
    add_executable(kernel_signature_generator kernel_signature_generator.cc)
243 244
    target_link_libraries(kernel_signature_generator
                          ${OP_FUNCTION_GENERETOR_DEPS})
245
  endif()
246

247
  get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES)
L
Leo Chen 已提交
248
  target_link_libraries(op_function_generator ${os_dependency_modules})
249
  target_link_libraries(eager_op_function_generator ${os_dependency_modules})
250 251
  if(WITH_ROCM)
    target_link_libraries(op_function_generator ${ROCM_HIPRTC_LIB})
252
    target_link_libraries(eager_op_function_generator ${ROCM_HIPRTC_LIB})
253
    target_link_libraries(kernel_signature_generator ${ROCM_HIPRTC_LIB})
254
  endif()
L
Leo Chen 已提交
255

256 257
  set(impl_file ${CMAKE_SOURCE_DIR}/paddle/fluid/pybind/op_function_impl.h)
  set(tmp_impl_file ${impl_file}.tmp)
258 259
  set(eager_impl_file
      ${CMAKE_SOURCE_DIR}/paddle/fluid/pybind/eager_op_function_impl.h)
260
  set(tmp_eager_impl_file ${eager_impl_file}.tmp)
261

262
  set(OP_IMPL_DEPS op_function_generator)
263 264
  set(EAGER_OP_IMPL_DEPS eager_op_function_generator
                         eager_final_state_python_c_codegen)
265

266
  if(WIN32)
267
    if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
268
      set(op_impl_path "${CMAKE_CURRENT_BINARY_DIR}")
269
    else()
270
      set(op_impl_path "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}")
271
    endif()
272

273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
    file(
      WRITE
      ${CMAKE_BINARY_DIR}/paddle/fluid/pybind/op_function_generator_retry.bat
      ""
      "set build_times=1\n"
      ":retry\n"
      "ECHO op_function_generator run %build_times% time\n"
      "taskkill /f /im op_function_generator.exe 2>NUL\n"
      "${op_impl_path}/op_function_generator.exe ${tmp_impl_file}\n"
      "if %ERRORLEVEL% NEQ 0 (\n"
      "    set /a build_times=%build_times%+1\n"
      "    if %build_times% GEQ 10 (\n"
      "        exit /b 1\n"
      "    ) else (\n"
      "        goto :retry\n"
      "    )\n"
      ")\n"
      "exit /b 0")

    file(
      WRITE
      ${CMAKE_BINARY_DIR}/paddle/fluid/pybind/eager_op_function_generator_retry.bat
      ""
      "set build_times=1\n"
      ":retry\n"
      "ECHO eager_op_function_generator run %build_times% time\n"
      "taskkill /f /im eager_op_function_generator.exe 2>NUL\n"
      "${op_impl_path}/eager_op_function_generator.exe ${tmp_eager_impl_file}\n"
      "if %ERRORLEVEL% NEQ 0 (\n"
      "    set /a build_times=%build_times%+1\n"
      "    if %build_times% GEQ 10 (\n"
      "        exit /b 1\n"
      "    ) else (\n"
      "        goto :retry\n"
      "    )\n"
      ")\n"
      "exit /b 0")
310

311
    if(${CBLAS_PROVIDER} STREQUAL MKLML)
312 313 314 315
      add_custom_command(
        OUTPUT ${op_impl_path}/libiomp5md.dll
        COMMAND ${CMAKE_COMMAND} -E copy ${MKLML_SHARED_IOMP_LIB}
                ${op_impl_path}
316 317
        DEPENDS mklml)
      list(APPEND OP_IMPL_DEPS ${op_impl_path}/libiomp5md.dll)
318
      list(APPEND EAGER_OP_IMPL_DEPS ${op_impl_path}/libiomp5md.dll)
319
    else()
320 321
      add_custom_command(
        OUTPUT ${op_impl_path}/openblas.dll
322 323 324
        COMMAND ${CMAKE_COMMAND} -E copy ${OPENBLAS_SHARED_LIB} ${op_impl_path}
        DEPENDS extern_openblas)
      list(APPEND OP_IMPL_DEPS ${op_impl_path}/openblas.dll)
325
      list(APPEND EAGER_OP_IMPL_DEPS ${op_impl_path}/openblas.dll)
326
    endif()
L
Leo Chen 已提交
327
    if(WITH_MKLDNN)
328 329
      add_custom_command(
        OUTPUT ${op_impl_path}/mkldnn.dll
330 331
        COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_SHARED_LIB} ${op_impl_path}
        DEPENDS mkldnn)
332 333
      list(APPEND OP_IMPL_DEPS ${op_impl_path}/mkldnn.dll)
      list(APPEND EAGER_OP_IMPL_DEPS ${op_impl_path}/mkldnn.dll)
334
    endif()
335
    if(WITH_ONNXRUNTIME)
336 337
      add_custom_command(
        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/paddle2onnx.dll
338
        COMMAND ${CMAKE_COMMAND} -E copy ${PADDLE2ONNX_LIB}
339
                ${CMAKE_CURRENT_BINARY_DIR}
340 341
        DEPENDS paddle2onnx)
      list(APPEND OP_IMPL_DEPS ${CMAKE_CURRENT_BINARY_DIR}/paddle2onnx.dll)
342 343
      list(APPEND EAGER_OP_IMPL_DEPS
           ${CMAKE_CURRENT_BINARY_DIR}/paddle2onnx.dll)
344

345 346 347 348
      add_custom_command(
        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/onnxruntime.dll
        COMMAND ${CMAKE_COMMAND} -E copy ${ONNXRUNTIME_SHARED_LIB}
                ${CMAKE_CURRENT_BINARY_DIR}
349 350
        DEPENDS onnxruntime)
      list(APPEND OP_IMPL_DEPS ${CMAKE_CURRENT_BINARY_DIR}/onnxruntime.dll)
351 352
      list(APPEND EAGER_OP_IMPL_DEPS
           ${CMAKE_CURRENT_BINARY_DIR}/onnxruntime.dll)
353
    endif()
354

355 356 357 358 359 360
    add_custom_command(
      OUTPUT ${impl_file}
      COMMAND
        ${CMAKE_BINARY_DIR}/paddle/fluid/pybind/op_function_generator_retry.bat
      COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_impl_file}
              ${impl_file}
361 362
      COMMENT "copy_if_different ${tmp_impl_file} to ${impl_file}"
      DEPENDS ${OP_IMPL_DEPS})
363
    if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
364 365 366 367 368 369
      add_custom_command(
        OUTPUT ${eager_impl_file}
        COMMAND
          ${CMAKE_BINARY_DIR}/paddle/fluid/pybind/eager_op_function_generator_retry.bat
        COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_eager_impl_file}
                ${eager_impl_file}
370 371 372
        COMMENT "copy_if_different ${tmp_eager_impl_file} to ${eager_impl_file}"
        DEPENDS ${EAGER_OP_IMPL_DEPS})
    endif()
373
  else()
374
    # If there are no *.so in /usr/lib or LD_LIBRARY_PATH,
L
Leo Chen 已提交
375
    # copy these *.so to current directory and append current directory to
376
    # LD_LIBRARY_PATH. This is different with Windows platformm, which search
L
Leo Chen 已提交
377
    # *.dll in current directory automatically.
378
    if(WITH_ONNXRUNTIME)
379 380 381 382 383
      if(APPLE)
        set(PADDLE2ONNX_PYBIND_OUT
            ${CMAKE_CURRENT_BINARY_DIR}/libpaddle2onnx.dylib)
        set(ONNXRUNTIME_PYBIND_OUT
            ${CMAKE_CURRENT_BINARY_DIR}/libonnxruntime.dylib)
384
      else()
385 386 387 388
        set(PADDLE2ONNX_PYBIND_OUT
            ${CMAKE_CURRENT_BINARY_DIR}/libpaddle2onnx.so)
        set(ONNXRUNTIME_PYBIND_OUT
            ${CMAKE_CURRENT_BINARY_DIR}/libonnxruntime.so)
389 390
      endif()

391 392 393 394
      add_custom_command(
        OUTPUT ${PADDLE2ONNX_PYBIND_OUT}
        COMMAND ${CMAKE_COMMAND} -E copy ${PADDLE2ONNX_LIB}
                ${CMAKE_CURRENT_BINARY_DIR}
395 396 397 398
        DEPENDS paddle2onnx)
      list(APPEND OP_IMPL_DEPS ${PADDLE2ONNX_PYBIND_OUT})
      list(APPEND EAGER_OP_IMPL_DEPS ${PADDLE2ONNX_PYBIND_OUT})

399 400 401 402
      add_custom_command(
        OUTPUT ${ONNXRUNTIME_PYBIND_OUT}
        COMMAND ${CMAKE_COMMAND} -E copy ${ONNXRUNTIME_LIB}
                ${CMAKE_CURRENT_BINARY_DIR}
403 404 405 406 407
        DEPENDS onnxruntime)
      list(APPEND OP_IMPL_DEPS ${ONNXRUNTIME_PYBIND_OUT})
      list(APPEND EAGER_OP_IMPL_DEPS ${ONNXRUNTIME_PYBIND_OUT})
    endif()

408
    if(WITH_MKLML)
409 410 411 412
      add_custom_command(
        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libiomp5.so
        COMMAND ${CMAKE_COMMAND} -E copy ${MKLML_SHARED_IOMP_LIB}
                ${CMAKE_CURRENT_BINARY_DIR}
413 414
        DEPENDS mklml)
      list(APPEND OP_IMPL_DEPS ${CMAKE_CURRENT_BINARY_DIR}/libiomp5.so)
415
      list(APPEND EAGER_OP_IMPL_DEPS ${CMAKE_CURRENT_BINARY_DIR}/libiomp5.so)
416 417
    endif()
    if(WITH_MKLDNN)
418 419 420 421
      add_custom_command(
        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/libdnnl.so.0
        COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_SHARED_LIB}
                ${CMAKE_CURRENT_BINARY_DIR}
422 423
        DEPENDS mkldnn)
      list(APPEND OP_IMPL_DEPS ${CMAKE_CURRENT_BINARY_DIR}/libdnnl.so.0)
424
      list(APPEND EAGER_OP_IMPL_DEPS ${CMAKE_CURRENT_BINARY_DIR}/libdnnl.so.0)
425
    endif()
426 427 428 429 430 431 432 433 434 435
    add_custom_command(
      OUTPUT ${impl_file}
      COMMAND
        ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:."
        "${CMAKE_CURRENT_BINARY_DIR}/op_function_generator" "${tmp_impl_file}"
      COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_impl_file}
              ${impl_file}
      COMMENT "copy_if_different ${tmp_impl_file} to ${impl_file}"
      DEPENDS ${OP_IMPL_DEPS}
      VERBATIM)
436
    if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
437 438 439 440 441 442 443 444 445 446 447 448
      add_custom_command(
        OUTPUT ${eager_impl_file}
        COMMAND
          ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:."
          "${CMAKE_CURRENT_BINARY_DIR}/eager_op_function_generator"
          "${tmp_eager_impl_file}"
        COMMAND ${CMAKE_COMMAND} -E copy_if_different ${tmp_eager_impl_file}
                ${eager_impl_file}
        COMMENT "copy_if_different ${tmp_eager_impl_file} to ${eager_impl_file}"
        DEPENDS ${EAGER_OP_IMPL_DEPS}
        VERBATIM)
    endif()
449
  endif()
450
  add_custom_target(op_function_generator_cmd ALL DEPENDS ${impl_file})
451
  if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
452 453
    add_custom_target(eager_op_function_generator_cmd ALL
                      DEPENDS ${eager_impl_file})
454
  endif()
L
Leo Chen 已提交
455

456 457 458 459 460 461
  list(APPEND PYBIND_DEPS interpretercore standalone_executor
       staticgraph_executor_statistics)
  cc_library(
    op_function_common
    SRCS op_function_common.cc
    DEPS ${PYBIND_DEPS})
462
  list(APPEND PYBIND_DEPS op_function_common)
463

464
  if(NOT ((NOT WITH_PYTHON) AND ON_INFER))
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
    cc_library(
      paddle_eager
      SRCS eager.cc eager_functions.cc eager_method.cc eager_properties.cc
           eager_utils.cc eager_py_layer.cc
      DEPS eager_api
           autograd_meta
           backward
           grad_node_info
           phi
           op_function_common
           final_dygraph_function
           final_dygraph_node
           dygraph_function
           dygraph_node
           accumulation_node
           py_layer_node
           global_utils
           utils
           python
           custom_operator
           custom_operator_node)
486 487 488 489
    add_dependencies(paddle_eager eager_codegen)
    add_dependencies(paddle_eager eager_op_function_generator_cmd)
    list(APPEND PYBIND_DEPS paddle_eager)
  endif()
490

491 492
  cc_library(
    paddle_pybind SHARED
493
    SRCS ${PYBIND_SRCS}
494
    DEPS ${PYBIND_DEPS} ${GLOB_OP_LIB} ${GLOB_OPERATOR_DEPS} ${GLOB_DEV_LIB})
495

496 497
  if(NOT APPLE AND NOT WIN32)
    target_link_libraries(paddle_pybind rt)
498
  endif()
499 500 501 502

  if(WITH_ROCM)
    target_link_libraries(paddle_pybind ${ROCM_HIPRTC_LIB})
  endif()
503

504
  get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES)
P
peizhilin 已提交
505
  target_link_libraries(paddle_pybind ${os_dependency_modules})
506
  add_dependencies(paddle_pybind op_function_generator_cmd)
507
endif()