You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

protobuf_shared.cmake 2.9 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. if (HAVE_PROTOBUF)
  2. return()
  3. endif()
  4. include(ExternalProject)
  5. include(GNUInstallDirs)
  6. if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR
  7. (${CMAKE_INSTALL_PREFIX} STREQUAL "C:/Program Files (x86)/ascend"))
  8. set(CMAKE_INSTALL_PREFIX ${GE_CODE_DIR}/output CACHE STRING "path for install()" FORCE)
  9. message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.")
  10. endif()
  11. if (GE_PB_PKG)
  12. set(REQ_URL "${GE_PB_PKG}/libs/protobuf/v3.8.0.tar.gz")
  13. else()
  14. if (ENABLE_GITEE)
  15. set(REQ_URL "https://gitee.com/mirrors/protobuf_source/repository/archive/v3.8.0.tar.gz")
  16. set(MD5 "eba86ae9f07ba5cfbaf8af3bc4e84236")
  17. else()
  18. set(REQ_URL "https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz")
  19. set(MD5 "3d9e32700639618a4d2d342c99d4507a")
  20. endif ()
  21. endif()
  22. set(protobuf_CXXFLAGS "-Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2 -Dgoogle=ascend_private")
  23. set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
  24. ExternalProject_Add(protobuf_build
  25. URL ${REQ_URL}
  26. TLS_VERIFY OFF
  27. CONFIGURE_COMMAND ${CMAKE_COMMAND}
  28. -Dprotobuf_WITH_ZLIB=OFF
  29. -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
  30. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  31. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  32. -DCMAKE_LINKER=${CMAKE_LINKER}
  33. -DCMAKE_AR=${CMAKE_AR}
  34. -DCMAKE_RANLIB=${CMAKE_RANLIB}
  35. -DLIB_PREFIX=ascend_
  36. -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/protobuf <SOURCE_DIR>/cmake
  37. BUILD_COMMAND $(MAKE)
  38. INSTALL_COMMAND $(MAKE) install
  39. EXCLUDE_FROM_ALL TRUE
  40. )
  41. include(GNUInstallDirs)
  42. set(PROTOBUF_SHARED_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protobuf)
  43. add_library(ascend_protobuf SHARED IMPORTED)
  44. file(MAKE_DIRECTORY ${PROTOBUF_SHARED_PKG_DIR}/include)
  45. set_target_properties(ascend_protobuf PROPERTIES
  46. IMPORTED_LOCATION ${PROTOBUF_SHARED_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/libascend_protobuf.so
  47. )
  48. target_include_directories(ascend_protobuf INTERFACE ${PROTOBUF_SHARED_PKG_DIR}/include)
  49. set(INSTALL_BASE_DIR "")
  50. set(INSTALL_LIBRARY_DIR lib)
  51. install(FILES ${PROTOBUF_SHARED_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/ascend_protobuf.so.3.8.0.0 OPTIONAL
  52. DESTINATION ${INSTALL_LIBRARY_DIR})
  53. install(FILES ${PROTOBUF_SHARED_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/ascend_protobuf.so OPTIONAL
  54. DESTINATION ${INSTALL_LIBRARY_DIR})
  55. add_dependencies(ascend_protobuf protobuf_build)
  56. #set(HAVE_PROTOBUF TRUE CACHE BOOL "protobuf build add")
  57. set(HAVE_PROTOBUF TRUE)

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示