6 Star 0 Fork 481

胡晓霖/air

forked from CANN/air 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 11.24 KB
一键复制 编辑 原始数据 按行查看 历史
刘康 提交于 2022-02-08 11:08 . !2932 allinone
cmake_minimum_required(VERSION 3.14)
project (AIR[CXX])
set(AIR_CODE_DIR ${CMAKE_CURRENT_LIST_DIR})
GET_FILENAME_COMPONENT(GE_DEPEND_DIR ${CMAKE_CURRENT_LIST_DIR} DIRECTORY)
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
if (NOT BUILD_PATH)
set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build")
endif()
if (DEFINED ENV{D_PKG_SERVER})
set(GE_PB_PKG $ENV{D_PKG_SERVER})
set(AIR_PB_PKG $ENV{D_PKG_SERVER})
message("Download packages from DPKG server${AIR_PB_PKG}")
elseif (DEFINED ENV{MSLIBS_SERVER})
set(GE_PB_PKG "http://$ENV{MSLIBS_SERVER}:8081")
set(AIR_PB_PKG "http://$ENV{MSLIBS_SERVER}:8081")
message("Download packages from MSPKG server")
endif ()
if (DEFINED ENV{ASCEND_CUSTOM_PATH})
set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH})
message("Ascend custom path is ${ASCEND_DIR}")
else ()
set(ASCEND_DIR /usr/local/Ascend)
endif ()
set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64)
set(ASCEND_DRIVER_COMMON_DIR ${ASCEND_DIR}/driver/lib64/common)
set(ASCEND_DRIVER_SHARE_DIR ${ASCEND_DIR}/driver/lib64/share)
set(ASCEND_FWK_DIR ${ASCEND_DIR}/fwkacllib/lib64)
set(ASCEND_ATC_DIR ${ASCEND_DIR}/atc/lib64)
set(ASCEND_ACL_DIR ${ASCEND_DIR}/acllib/lib64)
set(STATIC_ACL_LIB ${ASCEND_ACL_DIR})
set(ASCEND_MS_RUNTIME_PATH ${ASCEND_FWK_DIR} ${ASCEND_ACL_DIR} ${ASCEND_ATC_DIR})
set(ASCEND_MS_DRIVER_PATH ${ASCEND_DRIVER_DIR} ${ASCEND_DRIVER_COMMON_DIR})
set(ATLAS_RUNTIME_DIR ${ASCEND_DIR}/ascend-toolkit/latest/fwkacllib/lib64)
set(ATLAS_ACL_DIR ${ASCEND_DIR}/ascend-toolkit/latest/acllib/lib64)
set(ATLAS_ATC_DIR ${ASCEND_DIR}/ascend-toolkit/latest/atc/lib64)
set(ATLAS_MS_RUNTIME_PATH ${ATLAS_RUNTIME_DIR} ${ATLAS_ACL_DIR} ${ATLAS_ATC_DIR})
option(BUILD_OPEN_PROJECT "Enable air compile in opensource." FALSE)
if (ENABLE_GE_COV OR ENABLE_GE_UT OR ENABLE_GE_ST)
set(HI_PYTHON python3)
SET(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/base/parser)
SET(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/base/metadef)
include(cmake/external_libs/protobuf_shared.cmake)
include(cmake/external_libs/protobuf_static.cmake)
include(cmake/external_libs/protoc.cmake)
include(cmake/external_libs/gflags.cmake)
include(cmake/external_libs/gtest.cmake)
include(cmake/external_libs/securec.cmake)
include(cmake/external_libs/json.cmake)
include(cmake/FindModule.cmake)
include(cmake/intf_pub_linux.cmake)
include(cmake/external_libs/openssl.cmake)
include(cmake/external_libs/re2.cmake)
include(cmake/external_libs/zlib.cmake)
include(cmake/external_libs/cares.cmake)
include(cmake/external_libs/abseil-cpp.cmake)
include(cmake/external_libs/grpc.cmake)
include(cmake/external_libs/protoc_grpc.cmake)
add_subdirectory(tests)
add_subdirectory(runtime)
elseif (BUILD_OPEN_PROJECT OR ENABLE_OPEN_SRC)
set(HI_PYTHON python3)
include(cmake/external_libs/protobuf_shared.cmake)
include(cmake/external_libs/protobuf_static.cmake)
include(cmake/external_libs/protoc.cmake)
include(cmake/external_libs/gflags.cmake)
include(cmake/external_libs/securec.cmake)
include(cmake/external_libs/json.cmake)
include(cmake/FindModule.cmake)
include(cmake/intf_pub_linux.cmake)
include(cmake/external_libs/protoc.cmake)
include(cmake/external_libs/openssl.cmake)
include(cmake/external_libs/re2.cmake)
include(cmake/external_libs/zlib.cmake)
include(cmake/external_libs/cares.cmake)
include(cmake/external_libs/abseil-cpp.cmake)
include(cmake/external_libs/grpc.cmake)
include(cmake/external_libs/protoc_grpc.cmake)
# if D_LINK_PATH is set in environment variables, search libraries in given path
if (DEFINED ENV{D_LINK_PATH})
# D_LINK_PATH is set
set(AIR_LIB_PATH $ENV{D_LINK_PATH})
message("Link path is ${AIR_LIB_PATH}")
set(AIR_SYS_ARCH "")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
# x86 ubuntu
set(AIR_SYS_ARCH "x86_64")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
# arm euleros
set(AIR_SYS_ARCH "aarch64")
else()
message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated")
endif()
set(AIR_LIB_PATH ${AIR_LIB_PATH}/${AIR_SYS_ARCH})
message("Air lib path is ${AIR_LIB_PATH}")
find_module(slog libalog.so ${AIR_LIB_PATH})
find_module(mmpa libmmpa.so ${AIR_LIB_PATH})
find_module(static_mmpa libmmpa.a ${AIR_LIB_PATH})
find_module(compress libcompress.so ${AIR_LIB_PATH})
find_module(platform libplatform.so ${AIR_LIB_PATH})
find_module(runtime libruntime.so ${AIR_LIB_PATH})
find_module(dgw_client_so libdgw_client_so.so ${AIR_LIB_PATH})
if (ENABLE_FWK_COMPILE)
find_module(msprofiler_fwk_share libmsprofiler.so ${AIR_LIB_PATH})
find_module(hccl libhccl.so ${AIR_LIB_PATH})
find_module(adump_server libadump_server.a ${AIR_LIB_PATH})
find_module(resource libresource.so ${AIR_LIB_PATH})
find_module(ascend_hal_stub libascend_hal.so ${AIR_LIB_PATH})
endif ()
else()
set(ASCEND_COMPILER_DIR ${ASCEND_DIR}/compiler/lib64)
set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/runtime/lib64)
if (NOT ENABLE_FWK_COMPILE)
find_module(slog libalog.so ${ASCEND_COMPILER_DIR})
find_module(compress libcompress.so ${ASCEND_COMPILER_DIR})
find_module(platform libplatform.so ${ASCEND_COMPILER_DIR})
find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR})
find_module(dgw_client_so libdgw_client_so.so ${ASCEND_RUNTIME_DIR})
find_module(graph libgraph.so ${ASCEND_COMPILER_DIR})
find_module(register libregister.so ${ASCEND_COMPILER_DIR})
find_module(error_manager liberror_manager.so ${ASCEND_COMPILER_DIR})
else ()
find_module(slog libalog.so ${ASCEND_RUNTIME_DIR})
find_module(opt_feature libopt_feature.so ${ASCEND_RUNTIME_DIR})
find_module(static_mmpa libmmpa.a ${ASCEND_COMPILER_DIR})
if (PLATFORM STREQUAL "train")
find_module(msprofiler_fwk_share libmsprofiler.so ${ASCEND_RUNTIME_DIR})
find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR})
find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR})
find_module(dgw_client_so libdgw_client_so.so ${ASCEND_RUNTIME_DIR})
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver)
if(PRODUCT STREQUAL "flr3")
message(FATAL_ERROR "This platform is not supported in train mode, build terminated")
endif()
elseif (PLATFORM STREQUAL "inference")
find_module(msprofiler_fwk_share libmsprofiler.so ${ASCEND_RUNTIME_DIR})
find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR})
find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR})
if (PRODUCT STREQUAL "flr1")
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver)
elseif (PRODUCT STREQUAL "flr2")
# flr2 ascend_hal_stub limsprof ?
elseif (PRODUCT STREQUAL "flr3")
#
else ()
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR})
endif ()
elseif (PLATFORM STREQUAL "all")
find_module(msprofiler_fwk_share libmsprofiler.so ${ASCEND_RUNTIME_DIR})
find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR})
find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR})
find_module(dgw_client_so libdgw_client_so.so ${ASCEND_RUNTIME_DIR})
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_RUNTIME_DIR}/stub)
else ()
message(STATUS "PLATFORM param is invalid, should be train or inference, you choose nothing!")
endif ()
endif ()
endif ()
if (ENABLE_FWK_COMPILE)
set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/base/metadef)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/base/metadef)
set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/base/parser)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/base/parser)
else ()
set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/third_party/metadef)
set(AIR_ROOT_INC_DIR ${CMAKE_CURRENT_LIST_DIR}/third_party/inc)
#add_subdirectory(third_party/metadef)
endif ()
if (ENABLE_AICPU_LLT OR ENABLE_FE_LLT OR ENABLE_FFTS_LLT)
include(cmake/external_libs/gtest.cmake)
add_subdirectory(test)
endif()
add_subdirectory(runtime)
elseif (ENABLE_D OR ENABLE_ACL)
# compiling with MindSpore
include(cmake/external_libs/protobuf_static.cmake)
include(cmake/external_libs/protobuf_shared.cmake)
include(cmake/external_libs/protoc.cmake)
include(cmake/external_libs/securec.cmake)
include(cmake/external_libs/json.cmake)
include(cmake/FindModule.cmake)
include(cmake/intf_pub_linux.cmake)
include(cmake/external_libs/openssl.cmake)
include(cmake/external_libs/re2.cmake)
include(cmake/external_libs/zlib.cmake)
include(cmake/external_libs/cares.cmake)
include(cmake/external_libs/abseil-cpp.cmake)
include(cmake/external_libs/grpc.cmake)
include(cmake/external_libs/protoc_grpc.cmake)
# common libraries
find_module(slog libalog.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
find_module(static_mmpa libmmpa.a ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
if (ENABLE_D)
# training
find_module(runtime libruntime.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
find_module(dgw_client_so libdgw_client_so.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
find_module(register libregister.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
endif ()
set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef)
add_subdirectory(metadef)
add_subdirectory(runtime)
elseif(ENABLE_MS_TESTCASES)
include(cmake/external_libs/protobuf_static.cmake)
include(cmake/external_libs/protobuf_shared.cmake)
include(cmake/external_libs/protoc.cmake)
include(cmake/external_libs/securec.cmake)
include(cmake/FindModule.cmake)
include(cmake/intf_pub_linux.cmake)
include(cmake/external_libs/openssl.cmake)
include(cmake/external_libs/re2.cmake)
include(cmake/external_libs/zlib.cmake)
include(cmake/external_libs/cares.cmake)
include(cmake/external_libs/abseil-cpp.cmake)
include(cmake/external_libs/grpc.cmake)
include(cmake/external_libs/protoc_grpc.cmake)
# common libraries
find_module(slog libalog.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
find_module(static_mmpa libmmpa.a ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef)
add_subdirectory(metadef)
add_subdirectory(runtime)
else()
set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/../parser)
set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/../metadef)
set(AIR_ROOT_INC_DIR ${CMAKE_CURRENT_LIST_DIR}/../inc)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
add_subdirectory(runtime)
endif ()
endif()
add_subdirectory(base)
add_subdirectory(compiler)
add_subdirectory(executor)
add_subdirectory(runner)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/shawn-hu/air.git
git@gitee.com:shawn-hu/air.git
shawn-hu
air
air
master

搜索帮助