|
1 | 1 | add_subdirectory(dynload) |
2 | 2 |
|
3 | | -add_subdirectory(cpu) |
4 | | - |
5 | | -add_subdirectory(custom) |
| 3 | +set(BACKENDS_SRCS all_context.cc cpu/cpu_context.cc) |
| 4 | +set(BACKENDS_DEPS enforce place flags) |
6 | 5 |
|
7 | 6 | if(WITH_GPU OR WITH_ROCM) |
8 | | - add_subdirectory(gpu) |
| 7 | + list(APPEND BACKENDS_SRCS gpu/gpu_context.cc gpu/gpu_info.cc |
| 8 | + gpu/gpu_resources.cc) |
| 9 | + if(WITH_GPU) |
| 10 | + list(APPEND BACKENDS_SRCS gpu/cuda/cuda_info.cc) |
| 11 | + endif() |
| 12 | + if(WITH_ROCM) |
| 13 | + list(APPEND BACKENDS_SRCS gpu/rocm/rocm_info.cc) |
| 14 | + endif() |
| 15 | + list(APPEND BACKENDS_DEPS phi_dynload_cuda) |
9 | 16 | endif() |
10 | 17 |
|
11 | 18 | if(WITH_XPU) |
12 | | - add_subdirectory(xpu) |
| 19 | + list(APPEND BACKENDS_SRCS xpu/xpu_context.cc xpu/xpu_info.cc) |
13 | 20 | endif() |
14 | 21 |
|
15 | 22 | if(WITH_MKLDNN) |
16 | | - add_subdirectory(onednn) |
| 23 | + list(APPEND BACKENDS_SRCS onednn/onednn_context.cc) |
| 24 | + list(APPEND BACKENDS_DEPS mkldnn) |
17 | 25 | endif() |
18 | 26 |
|
19 | | -cc_library( |
20 | | - phi_context |
21 | | - SRCS all_context.cc |
22 | | - DEPS device_context cpu_context) |
23 | | - |
24 | | -if(WITH_XPU) |
25 | | - add_dependencies(phi_context xpu_context) |
| 27 | +if(WITH_CUSTOM_DEVICE) |
| 28 | + list( |
| 29 | + APPEND |
| 30 | + BACKENDS_SRCS |
| 31 | + callback_manager.cc |
| 32 | + device_guard.cc |
| 33 | + stream.cc |
| 34 | + event.cc |
| 35 | + device_base.cc |
| 36 | + device_manager.cc |
| 37 | + custom/custom_context.cc |
| 38 | + custom/custom_device.cc) |
26 | 39 | endif() |
27 | 40 |
|
28 | | -if(WITH_GPU) |
29 | | - add_dependencies(phi_context gpu_context) |
30 | | -endif() |
| 41 | +add_library(phi_backends "${BACKENDS_SRCS}") |
| 42 | +target_link_libraries(phi_backends ${BACKENDS_DEPS}) |
| 43 | + |
| 44 | +# for inference library |
| 45 | +get_property(phi_modules GLOBAL PROPERTY PHI_MODULES) |
| 46 | +set(phi_modules ${phi_modules} phi_backends) |
| 47 | +set_property(GLOBAL PROPERTY PHI_MODULES "${phi_modules}") |
31 | 48 |
|
32 | 49 | if(WITH_CUSTOM_DEVICE) |
33 | | - add_dependencies(phi_context custom_context) |
34 | | - cc_library( |
35 | | - callback_manager |
36 | | - SRCS callback_manager.cc |
37 | | - DEPS enforce place) |
38 | | - cc_library( |
39 | | - device_guard |
40 | | - SRCS device_guard.cc |
41 | | - DEPS enforce place) |
42 | | - cc_library( |
43 | | - stream |
44 | | - SRCS stream.cc |
45 | | - DEPS callback_manager) |
46 | | - cc_library( |
47 | | - event |
48 | | - SRCS event.cc |
49 | | - DEPS enforce place) |
50 | | - cc_library( |
51 | | - device_base |
52 | | - SRCS device_base.cc |
53 | | - DEPS stream event callback_manager device_guard device_context flags) |
54 | | - cc_library( |
55 | | - device_manager |
56 | | - SRCS device_manager.cc |
57 | | - DEPS custom_device) |
58 | | - set(GLOB_DEV_LIB |
59 | | - device_manager custom_device |
60 | | - CACHE INTERNAL "Global DEV library") |
| 50 | + cc_test( |
| 51 | + custom_device_test |
| 52 | + SRCS custom/custom_device_test.cc |
| 53 | + DEPS phi_backends phi_device_context) |
| 54 | + cc_test( |
| 55 | + capi_test |
| 56 | + SRCS custom/capi_test.cc |
| 57 | + DEPS phi_capi) |
61 | 58 | endif() |
0 commit comments