|
|
|
@ -2,10 +2,22 @@ if (NOT WITH_ANAKIN)
|
|
|
|
|
return()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(ANAKIN_INSTALL_DIR "${THIRD_PARTY_PATH}/install/anakin" CACHE PATH
|
|
|
|
|
"Anakin install path." FORCE)
|
|
|
|
|
set(ANAKIN_INCLUDE "${ANAKIN_INSTALL_DIR}" CACHE STRING "root of Anakin header files")
|
|
|
|
|
set(ANAKIN_LIBRARY "${ANAKIN_INSTALL_DIR}" CACHE STRING "path of Anakin library")
|
|
|
|
|
INCLUDE(ExternalProject)
|
|
|
|
|
set(ANAKIN_SOURCE_DIR ${THIRD_PARTY_PATH}/anakin)
|
|
|
|
|
# the anakin install dir is only default one now
|
|
|
|
|
set(ANAKIN_INSTALL_DIR ${THIRD_PARTY_PATH}/anakin/src/extern_anakin/output)
|
|
|
|
|
set(ANAKIN_INCLUDE ${ANAKIN_INSTALL_DIR})
|
|
|
|
|
set(ANAKIN_LIBRARY ${ANAKIN_INSTALL_DIR})
|
|
|
|
|
set(ANAKIN_SHARED_LIB ${ANAKIN_LIBRARY}/libanakin.so)
|
|
|
|
|
set(ANAKIN_SABER_LIB ${ANAKIN_LIBRARY}/libanakin_saber_common.so)
|
|
|
|
|
|
|
|
|
|
# TODO(luotao): ANAKIN_MODLE_URL will move to demo ci later.
|
|
|
|
|
set(ANAKIN_MODLE_URL "http://paddle-inference-dist.bj.bcebos.com/mobilenet_v2.anakin.bin")
|
|
|
|
|
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_SOURCE_DIR}")
|
|
|
|
|
execute_process(COMMAND bash -c "cd ${ANAKIN_SOURCE_DIR}; wget -q --no-check-certificate ${ANAKIN_MODLE_URL}")
|
|
|
|
|
|
|
|
|
|
include_directories(${ANAKIN_INCLUDE})
|
|
|
|
|
include_directories(${ANAKIN_INCLUDE}/saber/)
|
|
|
|
|
|
|
|
|
|
set(ANAKIN_COMPILE_EXTRA_FLAGS
|
|
|
|
|
-Wno-error=unused-but-set-variable -Wno-unused-but-set-variable
|
|
|
|
@ -20,36 +32,33 @@ set(ANAKIN_COMPILE_EXTRA_FLAGS
|
|
|
|
|
-Wno-reorder
|
|
|
|
|
-Wno-error=cpp)
|
|
|
|
|
|
|
|
|
|
set(ANAKIN_LIBRARY_URL "https://github.com/pangge/Anakin/releases/download/Version0.1.0/anakin.tar.gz")
|
|
|
|
|
|
|
|
|
|
# A helper function used in Anakin, currently, to use it, one need to recursively include
|
|
|
|
|
# nearly all the header files.
|
|
|
|
|
function(fetch_include_recursively root_dir)
|
|
|
|
|
if (IS_DIRECTORY ${root_dir})
|
|
|
|
|
include_directories(${root_dir})
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
file(GLOB ALL_SUB RELATIVE ${root_dir} ${root_dir}/*)
|
|
|
|
|
foreach(sub ${ALL_SUB})
|
|
|
|
|
if (IS_DIRECTORY ${root_dir}/${sub})
|
|
|
|
|
fetch_include_recursively(${root_dir}/${sub})
|
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
if (NOT EXISTS "${ANAKIN_INSTALL_DIR}")
|
|
|
|
|
# download library
|
|
|
|
|
message(STATUS "Download Anakin library from ${ANAKIN_LIBRARY_URL}")
|
|
|
|
|
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
|
|
|
|
|
execute_process(COMMAND bash -c "rm -rf ${ANAKIN_INSTALL_DIR}/*")
|
|
|
|
|
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; wget --no-check-certificate -q ${ANAKIN_LIBRARY_URL}")
|
|
|
|
|
execute_process(COMMAND bash -c "mkdir -p ${ANAKIN_INSTALL_DIR}")
|
|
|
|
|
execute_process(COMMAND bash -c "cd ${ANAKIN_INSTALL_DIR}; tar xzf anakin.tar.gz")
|
|
|
|
|
endif()
|
|
|
|
|
ExternalProject_Add(
|
|
|
|
|
extern_anakin
|
|
|
|
|
${EXTERNAL_PROJECT_LOG_ARGS}
|
|
|
|
|
# TODO(luotao): use PaddlePaddle/Anakin later
|
|
|
|
|
GIT_REPOSITORY "https://github.com/luotao1/Anakin"
|
|
|
|
|
GIT_TAG "3957ae9263eaa0b1986758dac60a88852afb09be"
|
|
|
|
|
PREFIX ${ANAKIN_SOURCE_DIR}
|
|
|
|
|
UPDATE_COMMAND ""
|
|
|
|
|
CMAKE_ARGS -DUSE_GPU_PLACE=YES
|
|
|
|
|
-DUSE_X86_PLACE=YES
|
|
|
|
|
-DBUILD_WITH_UNIT_TEST=NO
|
|
|
|
|
-DPROTOBUF_ROOT=${THIRD_PARTY_PATH}/install/protobuf
|
|
|
|
|
-DMKLML_ROOT=${THIRD_PARTY_PATH}/install/mklml
|
|
|
|
|
-DCUDNN_ROOT=${CUDNN_ROOT}
|
|
|
|
|
${EXTERNAL_OPTIONAL_ARGS}
|
|
|
|
|
CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${ANAKIN_INSTALL_DIR}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (WITH_ANAKIN)
|
|
|
|
|
message(STATUS "Anakin for inference is enabled")
|
|
|
|
|
message(STATUS "Anakin is set INCLUDE:${ANAKIN_INCLUDE} LIBRARY:${ANAKIN_LIBRARY}")
|
|
|
|
|
fetch_include_recursively(${ANAKIN_INCLUDE})
|
|
|
|
|
link_directories(${ANAKIN_LIBRARY})
|
|
|
|
|
endif()
|
|
|
|
|
message(STATUS "Anakin for inference is enabled")
|
|
|
|
|
message(STATUS "Anakin is set INCLUDE:${ANAKIN_INCLUDE} LIBRARY:${ANAKIN_LIBRARY}")
|
|
|
|
|
|
|
|
|
|
add_library(anakin_shared SHARED IMPORTED GLOBAL)
|
|
|
|
|
set_property(TARGET anakin_shared PROPERTY IMPORTED_LOCATION ${ANAKIN_SHARED_LIB})
|
|
|
|
|
add_dependencies(anakin_shared extern_anakin protobuf mklml)
|
|
|
|
|
|
|
|
|
|
add_library(anakin_saber SHARED IMPORTED GLOBAL)
|
|
|
|
|
set_property(TARGET anakin_saber PROPERTY IMPORTED_LOCATION ${ANAKIN_SABER_LIB})
|
|
|
|
|
add_dependencies(anakin_saber extern_anakin protobuf mklml)
|
|
|
|
|
|
|
|
|
|
list(APPEND external_project_dependencies anakin_shared anakin_saber)
|
|
|
|
|