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.

CMakeLists.txt 5.0 kB

5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. set(PROTO_LIST
  2. "${METADEF_DIR}/proto/task.proto"
  3. )
  4. protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST})
  5. set(SRC_LIST
  6. "engine/host_cpu_engine.cc"
  7. "ops_kernel_store/host_cpu_ops_kernel_info.cc"
  8. "ops_kernel_store/op/op_factory.cc"
  9. "ops_kernel_store/op/host_op.cc"
  10. )
  11. set(CPU_OPS_KERNEL_LIST
  12. "ops_kernel_store/host_cpu_ops_kernel_builder.cc"
  13. )
  14. ############ libhost_cpu_engine.so ############
  15. add_library(host_cpu_engine SHARED ${SRC_LIST} ${PROTO_HDRS})
  16. target_compile_options(host_cpu_engine PRIVATE
  17. -Werror
  18. )
  19. target_include_directories(host_cpu_engine PRIVATE
  20. ${CMAKE_CURRENT_LIST_DIR}
  21. ${GE_CODE_DIR}/ge
  22. ${GE_CODE_DIR}/inc
  23. ${GE_CODE_DIR}/inc/external
  24. ${GE_CODE_DIR}/inc/framework
  25. ${METADEF_DIR}/inc
  26. ${METADEF_DIR}/inc/external
  27. ${METADEF_DIR}/inc/external/graph
  28. ${CMAKE_BINARY_DIR}
  29. ${CMAKE_BINARY_DIR}/proto/ge
  30. #### yellow zone ####
  31. ${GE_CODE_DIR}/../inc
  32. )
  33. target_link_libraries(host_cpu_engine PRIVATE
  34. $<BUILD_INTERFACE:intf_pub>
  35. -Wl,--no-as-needed
  36. protobuf
  37. c_sec
  38. graph
  39. register
  40. slog
  41. runtime
  42. -Wl,--as-needed
  43. )
  44. ############ atcstub/libhost_cpu_engine.so ############
  45. add_library(atc_host_cpu_engine SHARED ${SRC_LIST} ${PROTO_HDRS})
  46. target_compile_options(atc_host_cpu_engine PRIVATE
  47. -Werror
  48. )
  49. target_compile_definitions(atc_host_cpu_engine PRIVATE
  50. COMPILE_OMG_PACKAGE
  51. )
  52. target_include_directories(atc_host_cpu_engine PRIVATE
  53. ${CMAKE_CURRENT_LIST_DIR}
  54. ${GE_CODE_DIR}/ge
  55. ${GE_CODE_DIR}/inc
  56. ${GE_CODE_DIR}/inc/external
  57. ${GE_CODE_DIR}/inc/framework
  58. ${METADEF_DIR}/inc
  59. ${METADEF_DIR}/inc/external
  60. ${METADEF_DIR}/inc/external/graph
  61. ${CMAKE_BINARY_DIR}
  62. ${CMAKE_BINARY_DIR}/proto/ge
  63. #### yellow zone ####
  64. ${GE_CODE_DIR}/../inc
  65. )
  66. target_link_libraries(atc_host_cpu_engine PRIVATE
  67. $<BUILD_INTERFACE:intf_pub>
  68. -Wl,--no-as-needed
  69. protobuf
  70. c_sec
  71. graph
  72. register
  73. slog
  74. runtime_compile
  75. -Wl,--as-needed
  76. )
  77. set_target_properties(atc_host_cpu_engine PROPERTIES
  78. OUTPUT_NAME host_cpu_engine
  79. LIBRARY_OUTPUT_DIRECTORY atclib
  80. )
  81. ############ libhost_cpu_opskernel_builder.so ############
  82. add_library(host_cpu_opskernel_builder SHARED ${CPU_OPS_KERNEL_LIST})
  83. target_compile_options(host_cpu_opskernel_builder PRIVATE
  84. -Werror
  85. )
  86. target_include_directories(host_cpu_opskernel_builder PRIVATE
  87. ${CMAKE_CURRENT_LIST_DIR}
  88. ${GE_CODE_DIR}/ge
  89. ${GE_CODE_DIR}/inc
  90. ${GE_CODE_DIR}/inc/external
  91. ${GE_CODE_DIR}/inc/framework
  92. ${METADEF_DIR}/inc
  93. ${METADEF_DIR}/inc/external
  94. ${METADEF_DIR}/inc/external/graph
  95. ${CMAKE_BINARY_DIR}
  96. ${CMAKE_BINARY_DIR}/proto/ge
  97. #### yellow zone ####
  98. ${GE_CODE_DIR}/../inc
  99. )
  100. target_link_libraries(host_cpu_opskernel_builder PRIVATE
  101. $<BUILD_INTERFACE:intf_pub>
  102. -Wl,--no-as-needed
  103. protobuf
  104. c_sec
  105. slog
  106. graph
  107. register
  108. -Wl,--as-needed
  109. )
  110. ############ atclib/libhost_cpu_opskernel_builder.so ############
  111. add_library(atc_host_cpu_opskernel_builder SHARED ${CPU_OPS_KERNEL_LIST})
  112. target_compile_options(atc_host_cpu_opskernel_builder PRIVATE
  113. -Werror
  114. )
  115. target_include_directories(atc_host_cpu_opskernel_builder PRIVATE
  116. ${CMAKE_CURRENT_LIST_DIR}
  117. ${GE_CODE_DIR}/ge
  118. ${GE_CODE_DIR}/inc
  119. ${GE_CODE_DIR}/inc/external
  120. ${GE_CODE_DIR}/inc/framework
  121. ${METADEF_DIR}/inc
  122. ${METADEF_DIR}/inc/external
  123. ${METADEF_DIR}/inc/external/graph
  124. ${CMAKE_BINARY_DIR}
  125. ${CMAKE_BINARY_DIR}/proto/ge
  126. #### yellow zone ####
  127. ${GE_CODE_DIR}/../inc
  128. )
  129. target_link_libraries(atc_host_cpu_opskernel_builder PRIVATE
  130. $<BUILD_INTERFACE:intf_pub>
  131. -Wl,--no-as-needed
  132. protobuf
  133. c_sec
  134. slog
  135. graph
  136. register
  137. -Wl,--as-needed
  138. )
  139. set_target_properties(atc_host_cpu_opskernel_builder PROPERTIES
  140. OUTPUT_NAME host_cpu_opskernel_builder
  141. LIBRARY_OUTPUT_DIRECTORY atclib
  142. )
  143. ############ libhost_cpu_opskernel_builder.a ############
  144. add_library(host_cpu_opskernel_builder_static SHARED ${CPU_OPS_KERNEL_LIST})
  145. target_compile_options(host_cpu_opskernel_builder_static PRIVATE
  146. -Werror
  147. )
  148. target_include_directories(host_cpu_opskernel_builder_static PRIVATE
  149. ${CMAKE_CURRENT_LIST_DIR}
  150. ${GE_CODE_DIR}/ge
  151. ${GE_CODE_DIR}/inc
  152. ${GE_CODE_DIR}/inc/external
  153. ${GE_CODE_DIR}/inc/framework
  154. ${METADEF_DIR}/inc
  155. ${METADEF_DIR}/inc/external
  156. ${METADEF_DIR}/inc/external/graph
  157. ${CMAKE_BINARY_DIR}
  158. ${CMAKE_BINARY_DIR}/proto/ge
  159. #### yellow zone ####
  160. ${GE_CODE_DIR}/../inc
  161. )
  162. target_link_libraries(host_cpu_opskernel_builder_static PRIVATE
  163. $<BUILD_INTERFACE:intf_pub>
  164. protobuf
  165. c_sec
  166. )
  167. ############ install ############
  168. set(INSTALL_BASE_DIR "")
  169. set(INSTALL_LIBRARY_DIR lib)
  170. install(TARGETS host_cpu_engine host_cpu_opskernel_builder OPTIONAL
  171. LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}
  172. )
  173. install(TARGETS atc_host_cpu_engine atc_host_cpu_opskernel_builder OPTIONAL
  174. LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}/atclib
  175. )

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