Skip to content

Commit c228977

Browse files
authored
add anakin release (#11747)
1 parent f2459aa commit c228977

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

cmake/external/anakin.cmake

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ function(fetch_include_recursively root_dir)
2626
endforeach()
2727
endfunction()
2828

29-
# download library
30-
message(STATUS "Download Anakin library from ${ANAKIN_LIBRARY_URL}")
31-
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
32-
execute_process(COMMAND bash -c "rm -rf ${ANAKIN_INSTALL_DIR}/*")
33-
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; wget -q ${ANAKIN_LIBRARY_URL}")
34-
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
35-
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; tar xzf anakin_release_simple.tar.gz")
29+
if (NOT EXISTS "${ANAKIN_INSTALL_DIR}")
30+
# download library
31+
message(STATUS "Download Anakin library from ${ANAKIN_LIBRARY_URL}")
32+
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
33+
execute_process(COMMAND bash -c "rm -rf ${ANAKIN_INSTALL_DIR}/*")
34+
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; wget -q ${ANAKIN_LIBRARY_URL}")
35+
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
36+
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; tar xzf anakin_release_simple.tar.gz")
37+
endif()
3638

3739
if (WITH_ANAKIN)
3840
message(STATUS "Anakin for inference is enabled")

cmake/inference_lib.cmake

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,21 +149,33 @@ copy(memory_lib
149149
DSTS ${dst_dir}/${module} ${dst_dir}/${module}/detail
150150
)
151151

152-
set(module "inference")
153-
copy(inference_lib DEPS paddle_fluid_shared paddle_fluid
154-
SRCS ${src_dir}/${module}/*.h ${PADDLE_BINARY_DIR}/paddle/fluid/inference/libpaddle_fluid.*
155-
DSTS ${dst_dir}/${module} ${dst_dir}/${module}
156-
)
152+
set(inference_deps paddle_fluid_shared paddle_fluid)
157153

158154
if(WITH_CONTRIB)
159-
set(contrib_dst_dir "${FLUID_INSTALL_DIR}/contrib/inference")
160-
copy(contrib_inference_lib DEPS paddle_inference_api
155+
message(STATUS "installing contrib")
156+
set(contrib_dst_dir "${FLUID_INSTALL_DIR}/contrib/inference")
157+
if (WITH_ANAKIN)
158+
copy(contrib_anakin_inference_lib DEPS paddle_inference_api inference_anakin_api
159+
SRCS
160+
${PADDLE_BINARY_DIR}/paddle/contrib/inference/libinference_anakin_api* # compiled anakin api
161+
${PADDLE_BINARY_DIR}/third_party/install/anakin/*.tar.gz # anakin release
162+
DSTS ${contrib_dst_dir}/anakin ${contrib_dst_dir}/anakin)
163+
list(APPEND inference_deps contrib_anakin_inference_lib)
164+
endif()
165+
166+
copy(contrib_inference_lib DEPS paddle_inference_api
161167
SRCS ${PADDLE_SOURCE_DIR}/paddle/contrib/inference/paddle_inference_api.h
162168
${PADDLE_BINARY_DIR}/paddle/contrib/inference/libpaddle_inference_api.*
163-
DSTS ${contrib_dst_dir} ${contrib_dst_dir}
164-
)
169+
DSTS ${contrib_dst_dir} ${contrib_dst_dir})
170+
list(APPEND inference_deps contrib_inference_lib)
165171
endif()
166172

173+
set(module "inference")
174+
copy(inference_lib DEPS ${inference_deps}
175+
SRCS ${src_dir}/${module}/*.h ${PADDLE_BINARY_DIR}/paddle/fluid/inference/libpaddle_fluid.*
176+
DSTS ${dst_dir}/${module} ${dst_dir}/${module}
177+
)
178+
167179
set(module "platform")
168180
copy(platform_lib DEPS profiler_py_proto
169181
SRCS ${src_dir}/${module}/*.h ${src_dir}/${module}/dynload/*.h ${src_dir}/${module}/details/*.h

paddle/contrib/inference/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@ if (WITH_ANAKIN AND WITH_TESTING) # only needed in CI
5454
# Due to Anakin do not have official library releases and the versions of protobuf and cuda do not match Paddle's,
5555
# so anakin library will not be merged to our official inference library. To use anakin prediction API, one need to
5656
# compile the libinference_anakin_api.a and compile with anakin.so.
57-
nv_library(inference_anakin_api SHARED SRCS paddle_inference_api.cc paddle_inference_api_anakin_engine.cc)
57+
nv_library(inference_anakin_api SRCS paddle_inference_api.cc paddle_inference_api_anakin_engine.cc)
58+
nv_library(inference_anakin_api_shared SHARED SRCS paddle_inference_api.cc paddle_inference_api_anakin_engine.cc)
5859
target_compile_options(inference_anakin_api BEFORE PUBLIC ${ANAKIN_COMPILE_EXTRA_FLAGS})
60+
target_compile_options(inference_anakin_api_shared BEFORE PUBLIC ${ANAKIN_COMPILE_EXTRA_FLAGS})
5961
target_link_libraries(inference_anakin_api anakin anakin_saber_common)
62+
target_link_libraries(inference_anakin_api_shared anakin anakin_saber_common)
6063
cc_test(inference_anakin_test SRCS paddle_inference_api_anakin_engine_tester.cc
6164
ARGS --model=${ANAKIN_INSTALL_DIR}/mobilenet_v2.anakin.bin
6265
DEPS inference_anakin_api)

0 commit comments

Comments
 (0)