cmake_minimum_required(VERSION 3.14) project (GraphEngine[CXX]) set(GE_CODE_DIR ${CMAKE_CURRENT_LIST_DIR}) set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE) if (NOT BUILD_PATH) set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build") endif() if(DEFINED ENV{ASCEND_CUSTOM_PATH}) set(ASCEND_DIR $ENV{ASCEND_CUSTOM_PATH}) 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_RUNTIME_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}) option(ENABLE_OPEN_SRC "Enable graphengine compile in opensource." FALSE) if (ENABLE_OPEN_SRC) set(HI_PYTHON python3.7) 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) # for CPU/GPU mode, find c_sec and slog from local prebuild #if(NOT ENABLE_D AND NOT GE_ONLY) # set(GE_PREBUILD_PATH ${GE_CODE_DIR}/third_party/prebuild/${CMAKE_HOST_SYSTEM_PROCESSOR}) # find_module(slog libslog.so ${GE_PREBUILD_PATH}) # 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(GE_LIB_PATH $ENV{D_LINK_PATH}) set(GE_SYS_ARCH "") if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64") # x86 ubuntu set(GE_SYS_ARCH "x86_64") elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64") # arm euleros set(GE_SYS_ARCH "aarch64") else() message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated") endif() set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH}) set(STATIC_ACL_LIB ${GE_LIB_PATH}) find_module(slog libslog.so ${GE_LIB_PATH}) find_module(static_mmpa libmmpa.a ${GE_LIB_PATH}) find_module(msprof libmsprof.so ${GE_LIB_PATH}) find_module(hccl libhccl.so ${GE_LIB_PATH}) find_module(adump_server libadump_server.a ${GE_LIB_PATH}) find_module(runtime libruntime.so ${GE_LIB_PATH}) find_module(runtime_compile libruntime_compile.so ${GE_LIB_PATH}) find_module(resource libresource.so ${GE_LIB_PATH}) find_module(error_manager liberror_manager.so ${GE_LIB_PATH}) find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) find_module(error_manager_static liberror_manager.a ${GE_LIB_PATH}) find_module(msprofiler libmsprofiler.a ${GE_LIB_PATH}) #find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) else() find_module(slog libslog.so ${ASCEND_ATC_DIR}) find_module(static_mmpa libmmpa.a ${ASCEND_ATC_DIR}) if(PLATFORM STREQUAL "train") find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) find_module(resource libresource.so ${ASCEND_RUNTIME_DIR}) find_module(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR}) find_module(msprofiler libmsprofiler.a ${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(adump_server libadump_server.a ${ASCEND_ACL_DIR}) find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) find_module(resource libresource.so ${ASCEND_ATC_DIR}) find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) #find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) if(PRODUCT STREQUAL "flr3") find_module(msprof libmsprof.so ${ASCEND_DRIVER_SHARE_DIR}) elseif(PRODUCT STREQUAL "flr1") find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) elseif(PRODUCT STREQUAL "flr2") # flr2 ascend_hal_stub limsprof ? else() find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) find_module(msprof libmsprof.so ${ASCEND_DRIVER_DIR}) endif() elseif(PLATFORM STREQUAL "all") find_module(msprof libmsprof.so ${ASCEND_DRIVER_COMMON_DIR}) find_module(hccl libhccl.so ${ASCEND_RUNTIME_DIR}) find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) find_module(resource libresource.so ${ASCEND_ATC_DIR}) find_module(error_manager liberror_manager.so ${ASCEND_ATC_DIR}) find_module(error_manager_static liberror_manager.a ${ASCEND_ACL_DIR}) find_module(msprofiler libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver) #find_module(ascendcl_static libascendcl.a ${ASCEND_ACL_DIR}) else() message(FATAL_ERROR "PLATFORM param is invalid, should be train or inference, build terminated") endif() endif() set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/parser) set(GE_DEPEND_DIR ${CMAKE_CURRENT_LIST_DIR}/..) add_subdirectory(metadef) add_subdirectory(parser) #add_subdirectory(metadef/graph) #add_subdirectory(metadef/register) elseif (ENABLE_D OR ENABLE_ACL) set(ASCEND_MS_RUNTIME_PATH ${ASCEND_RUNTIME_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}) # compiling with MindSpore include(cmake/external_libs/protobuf_static.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) # common libraries find_module(slog libslog.so ${ASCEND_MS_DRIVER_PATH}) find_module(error_manager liberror_manager.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(register libregister.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH}) endif () set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) add_subdirectory(metadef) elseif(ENABLE_MS_TESTCASE) include(cmake/external_libs/protobuf_static.cmake) include(cmake/external_libs/securec.cmake) include(cmake/intf_pub_linux.cmake) set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef) add_subdirectory(metadef) else() set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/../metadef) set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/../parser) set(GE_DEPEND_DIR ${CMAKE_CURRENT_LIST_DIR}/..) endif() add_subdirectory(ge)