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
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. CONFIGURE_COMMAND ${CMAKE_COMMAND}
  27. -Dprotobuf_WITH_ZLIB=OFF
  28. -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
  29. -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
  30. -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
  31. -DCMAKE_LINKER=${CMAKE_LINKER}
  32. -DCMAKE_AR=${CMAKE_AR}
  33. -DCMAKE_RANLIB=${CMAKE_RANLIB}
  34. -DLIB_PREFIX=ascend_
  35. -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
  36. BUILD_COMMAND $(MAKE)
  37. INSTALL_COMMAND $(MAKE) install
  38. EXCLUDE_FROM_ALL TRUE
  39. )
  40. include(GNUInstallDirs)
  41. set(PROTOBUF_SHARED_PKG_DIR ${CMAKE_INSTALL_PREFIX}/protobuf)
  42. add_library(ascend_protobuf SHARED IMPORTED)
  43. file(MAKE_DIRECTORY ${PROTOBUF_SHARED_PKG_DIR}/include)
  44. set_target_properties(ascend_protobuf PROPERTIES
  45. IMPORTED_LOCATION ${PROTOBUF_SHARED_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/libascend_protobuf.so
  46. )
  47. target_include_directories(ascend_protobuf INTERFACE ${PROTOBUF_SHARED_PKG_DIR}/include)
  48. set(INSTALL_BASE_DIR "")
  49. set(INSTALL_LIBRARY_DIR lib)
  50. install(FILES ${PROTOBUF_SHARED_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/ascend_protobuf.so.3.8.0.0 OPTIONAL
  51. DESTINATION ${INSTALL_LIBRARY_DIR})
  52. install(FILES ${PROTOBUF_SHARED_PKG_DIR}/${CMAKE_INSTALL_LIBDIR}/ascend_protobuf.so OPTIONAL
  53. DESTINATION ${INSTALL_LIBRARY_DIR})
  54. add_dependencies(ascend_protobuf protobuf_build)
  55. #set(HAVE_PROTOBUF TRUE CACHE BOOL "protobuf build add")
  56. set(HAVE_PROTOBUF TRUE)

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