Skip to content

Commit b2367f3

Browse files
committed
update anakin.cmake
1 parent f4bcee1 commit b2367f3

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

cmake/external/anakin.cmake

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,17 @@ if (NOT WITH_ANAKIN)
22
return()
33
endif()
44

5+
INCLUDE(ExternalProject)
56
set(ANAKIN_SOURCE_DIR ${THIRD_PARTY_PATH}/anakin)
67
# the anakin install dir is only default one now
78
set(ANAKIN_INSTALL_DIR ${THIRD_PARTY_PATH}/anakin/src/extern_anakin/output)
89
set(ANAKIN_INCLUDE ${ANAKIN_INSTALL_DIR})
910
set(ANAKIN_LIBRARY ${ANAKIN_INSTALL_DIR})
10-
SET(ANAKIN_SHARED_LIB ${ANAKIN_LIBRARY}/libanakin.so)
11-
SET(ANAKIN_SABER_LIB ${ANAKIN_LIBRARY}/libanakin_saber_common.so)
11+
set(ANAKIN_SHARED_LIB ${ANAKIN_LIBRARY}/libanakin.so)
12+
set(ANAKIN_SABER_LIB ${ANAKIN_LIBRARY}/libanakin_saber_common.so)
1213

13-
# A helper function used in Anakin, currently, to use it, one need to recursively include
14-
# nearly all the header files.
15-
function(fetch_include_recursively root_dir)
16-
if (IS_DIRECTORY ${root_dir})
17-
include_directories(BEFORE ${root_dir})
18-
endif()
19-
20-
file(GLOB ALL_SUB RELATIVE ${root_dir} ${root_dir}/*)
21-
foreach(sub ${ALL_SUB})
22-
if (IS_DIRECTORY ${root_dir}/${sub})
23-
fetch_include_recursively(${root_dir}/${sub})
24-
endif()
25-
endforeach()
26-
endfunction()
27-
fetch_include_recursively(${ANAKIN_INCLUDE})
14+
include_directories(${ANAKIN_INCLUDE})
15+
include_directories(${ANAKIN_INCLUDE}/saber/)
2816

2917
set(ANAKIN_COMPILE_EXTRA_FLAGS
3018
-Wno-error=unused-but-set-variable -Wno-unused-but-set-variable
@@ -60,11 +48,9 @@ ExternalProject_Add(
6048
message(STATUS "Anakin for inference is enabled")
6149
message(STATUS "Anakin is set INCLUDE:${ANAKIN_INCLUDE} LIBRARY:${ANAKIN_LIBRARY}")
6250

63-
fetch_include_recursively(${ANAKIN_INCLUDE})
64-
add_dependencies(extern_anakin protobuf mklml)
6551
add_library(anakin SHARED IMPORTED GLOBAL)
6652
set_property(TARGET anakin PROPERTY IMPORTED_LOCATION ${ANAKIN_SHARED_LIB})
6753
set_property(TARGET anakin PROPERTY IMPORTED_LOCATION ${ANAKIN_SABER_LIB})
6854
set_property(TARGET anakin PROPERTY IMPORTED_LOCATION ${CUDNN_LIBRARY})
69-
add_dependencies(anakin extern_anakin)
55+
add_dependencies(anakin extern_anakin protobuf mklml)
7056
list(APPEND external_project_dependencies anakin)

paddle/fluid/inference/api/CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ endif()
6262

6363
if (WITH_ANAKIN) # only needed in CI
6464
# compile the libinference_anakin_api.a and anakin.so.
65-
fetch_include_recursively(${ANAKIN_INCLUDE})
6665
nv_library(inference_anakin_api SRCS api.cc api_anakin_engine.cc DEPS anakin)
6766
nv_library(inference_anakin_api_shared SHARED SRCS api.cc api_anakin_engine.cc DEPS anakin)
6867
set(ANAKIN_DEPS_LIB ${ANAKIN_SHARED_LIB} ${ANAKIN_SABER_LIB} ${CUDNN_LIBRARY})
@@ -73,12 +72,11 @@ if (WITH_ANAKIN) # only needed in CI
7372
anakin_target(inference_anakin_api)
7473
anakin_target(inference_anakin_api_shared)
7574
if (WITH_TESTING)
75+
# TODO(luotao): anakin_model will move to demo_ci later
7676
set(ANAKIN_MODLE_URL "http://paddle-inference-dist.bj.bcebos.com/mobilenet_v2.anakin.bin")
77-
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/.timestamp
78-
COMMAND cd ${CMAKE_CURRENT_BINARY_DIR} && wget --no-check-certificate ${ANAKIN_MODLE_URL}
79-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
77+
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; wget -q --no-check-certificate ${ANAKIN_MODLE_URL}")
8078
cc_test(inference_anakin_test SRCS api_anakin_engine_tester.cc
81-
ARGS --model=${CMAKE_CURRENT_BINARY_DIR}/mobilenet_v2.anakin.bin
79+
ARGS --model=${ANAKIN_INSTAL_DIR}/mobilenet_v2.anakin.bin
8280
DEPS inference_anakin_api_shared dynload_cuda SERIAL)
8381
target_compile_options(inference_anakin_test BEFORE PUBLIC ${ANAKIN_COMPILE_EXTRA_FLAGS})
8482
endif(WITH_TESTING)

0 commit comments

Comments
 (0)