Merged
fix(cmake): opkernel 单独构建跳过 GenerateEsPackage 与 add_es_library_and_whl #15126
gaoypAdd on 7 days ago
fix(cmake): opkernel 单独构建跳过 GenerateEsPackage 与 add_es_library_and_whl #15126
Merged
Merged fromDeleted :masterintocann/ops-transformermaster
Total: 9 files changed+35-6
| @@ -47,6 +47,7 @@ option(ENABLE_OOM "Enable kernel oom" OFF) | |||
| 47 | option(ENABLE_MSSANITIZER "Enable mssanitizer mode" OFF) | 47 | option(ENABLE_MSSANITIZER "Enable mssanitizer mode" OFF) |
| 48 | option(ENABLE_DUMP_CCE "Enable dump_cce mode" OFF) | 48 | option(ENABLE_DUMP_CCE "Enable dump_cce mode" OFF) |
| 49 | option(UT_INFERSHAPE_FLAG "Enable infershape ut" OFF) | 49 | option(UT_INFERSHAPE_FLAG "Enable infershape ut" OFF) |
| 50 | +option(ENABLE_OP_KERNEL "Enable op kernel only build (skip es package generation)" OFF) | ||
| 50 | 51 | ||
| 51 | set(ASCEND_COMPUTE_UNIT "ascend910b" CACHE STRING "soc that need to be compiled") | 52 | set(ASCEND_COMPUTE_UNIT "ascend910b" CACHE STRING "soc that need to be compiled") |
| 52 | set(ASCEND_OP_NAME "ALL" CACHE STRING "operators that need to be compiled") | 53 | set(ASCEND_OP_NAME "ALL" CACHE STRING "operators that need to be compiled") |
| @@ -67,6 +67,7 @@ OP_HOST=FALSE | |||
| 67 | OP_GRAPH=FALSE | 67 | OP_GRAPH=FALSE |
| 68 | ONNX_PLUGIN=FALSE | 68 | ONNX_PLUGIN=FALSE |
| 69 | OP_KERNEL=FALSE | 69 | OP_KERNEL=FALSE |
| 70 | +ENABLE_OP_KERNEL=FALSE | ||
| 70 | SOC_ARRAY=() | 71 | SOC_ARRAY=() |
| 71 | ENABLE_UT_EXEC=TRUE | 72 | ENABLE_UT_EXEC=TRUE |
| 72 | ENABLE_RULE_LAUNCH="" | 73 | ENABLE_RULE_LAUNCH="" |
| @@ -1659,6 +1660,8 @@ assemble_cmake_args() { | |||
| 1659 | CUSTOM_OPTION="${CUSTOM_OPTION} -DPACKAGE_TYPE=${cmake_pkg_type}" | 1660 | CUSTOM_OPTION="${CUSTOM_OPTION} -DPACKAGE_TYPE=${cmake_pkg_type}" |
| 1660 | fi | 1661 | fi |
| 1661 | 1662 | ||
| 1663 | + CUSTOM_OPTION="${CUSTOM_OPTION} -DENABLE_OP_KERNEL=${ENABLE_OP_KERNEL}" | ||
| 1664 | + | ||
| 1662 | if [[ "$ENABLE_AICPU" == "FALSE" ]]; then | 1665 | if [[ "$ENABLE_AICPU" == "FALSE" ]]; then |
| 1663 | CUSTOM_OPTION="${CUSTOM_OPTION} -DENABLE_AICPU=OFF -DENABLE_TILING_SINK=OFF " | 1666 | CUSTOM_OPTION="${CUSTOM_OPTION} -DENABLE_AICPU=OFF -DENABLE_TILING_SINK=OFF " |
| 1664 | fi | 1667 | fi |
| @@ -2190,6 +2193,13 @@ if [[ "${OPKERNEL_PKG_PR}" == "TRUE" ]]; then | |||
| 2190 | parse_changed_pr | 2193 | parse_changed_pr |
| 2191 | fi | 2194 | fi |
| 2192 | 2195 | ||
| 2196 | +if [[ "$OP_KERNEL" == "TRUE" && "$ENABLE_BUILD_PKG" != "TRUE" && "$ENABLE_TEST" != "TRUE" ]]; then | ||
| 2197 | + # --opkernel 单独构建二进制 kernel,不依赖 GenerateEsPackage / add_es_library_and_whl | ||
| 2198 | + ENABLE_OP_KERNEL=TRUE | ||
| 2199 | +else | ||
| 2200 | + ENABLE_OP_KERNEL=FALSE | ||
| 2201 | +fi | ||
| 2202 | + | ||
| 2193 | assemble_cmake_args | 2203 | assemble_cmake_args |
| 2194 | 2204 | ||
| 2195 | function get_cpu_num() { | 2205 | function get_cpu_num() { |
| @@ -232,6 +232,7 @@ if (BUILD_OPEN_PROJECT) | |||
| 232 | -p ${ASCEND_CANN_PACKAGE_PATH} | 232 | -p ${ASCEND_CANN_PACKAGE_PATH} |
| 233 | --autogen-dir ${ASCEND_AUTOGEN_DIR} | 233 | --autogen-dir ${ASCEND_AUTOGEN_DIR} |
| 234 | --build-open-project ${BUILD_OPEN_PROJECT} | 234 | --build-open-project ${BUILD_OPEN_PROJECT} |
| 235 | + --enable-op-kernel ${ENABLE_OP_KERNEL} | ||
| 235 | --binary-out-dir ${ASCEND_BINARY_OUT_DIR} | 236 | --binary-out-dir ${ASCEND_BINARY_OUT_DIR} |
| 236 | --impl-out-dir ${ASCEND_IMPL_OUT_DIR} | 237 | --impl-out-dir ${ASCEND_IMPL_OUT_DIR} |
| 237 | --op-build-tool ${OP_BUILD_TOOL} | 238 | --op-build-tool ${OP_BUILD_TOOL} |
| @@ -959,6 +959,7 @@ if(generate_proto_srcs AND TARGET cust_proto AND NOT ENABLE_BUILT_IN AND NOT ENA | |||
| 959 | target_link_directories(proto_transformer_cust PRIVATE ${ASCEND_DIR}/${SYSTEM_PREFIX}/lib64) | 959 | target_link_directories(proto_transformer_cust PRIVATE ${ASCEND_DIR}/${SYSTEM_PREFIX}/lib64) |
| 960 | target_include_directories(proto_transformer_cust PRIVATE ${OPS_TRANSFORMER_DIR}) | 960 | target_include_directories(proto_transformer_cust PRIVATE ${OPS_TRANSFORMER_DIR}) |
| 961 | 961 | ||
| 962 | + if(NOT ENABLE_OP_KERNEL) | ||
| 962 | add_es_library( | 963 | add_es_library( |
| 963 | ES_LINKABLE_AND_ALL_TARGET es_transformer_cust | 964 | ES_LINKABLE_AND_ALL_TARGET es_transformer_cust |
| 964 | OPP_PROTO_TARGET proto_transformer_cust | 965 | OPP_PROTO_TARGET proto_transformer_cust |
| @@ -1012,6 +1013,7 @@ if(generate_proto_srcs AND TARGET cust_proto AND NOT ENABLE_BUILT_IN AND NOT ENA | |||
| 1012 | ${CMAKE_BINARY_DIR}/es_packages/lib64 | 1013 | ${CMAKE_BINARY_DIR}/es_packages/lib64 |
| 1013 | ${ES_LIB_INSTALL_DIR} | 1014 | ${ES_LIB_INSTALL_DIR} |
| 1014 | ) | 1015 | ) |
| 1016 | + endif() | ||
| 1015 | endif() | 1017 | endif() |
| 1016 | 1018 | ||
| 1017 | # ------------------------------------------------ generate adapt py ------------------------------------------------ | 1019 | # ------------------------------------------------ generate adapt py ------------------------------------------------ |
| @@ -66,9 +66,11 @@ find_package(tilingapi MODULE REQUIRED) | |||
| 66 | find_package(aicpu MODULE REQUIRED) | 66 | find_package(aicpu MODULE REQUIRED) |
| 67 | 67 | ||
| 68 | if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) | 68 | if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) |
| 69 | - message(STATUS "Finding gen es pkg") | 69 | + if(NOT ENABLE_OP_KERNEL) |
| 70 | - find_package(GenerateEsPackage MODULE QUIET) | 70 | + message(STATUS "Finding gen es pkg") |
| 71 | - if(NOT GenerateEsPackage_FOUND) | 71 | + find_package(GenerateEsPackage MODULE QUIET) |
| 72 | - message(FATAL_ERROR "GenerateEsPackage not found") | 72 | + if(NOT GenerateEsPackage_FOUND) |
| 73 | - endif() | 73 | + message(FATAL_ERROR "GenerateEsPackage not found") |
| 74 | + endif() | ||
| 75 | + endif() | ||
| 74 | endif() | 76 | endif() |
| @@ -34,6 +34,10 @@ while [[ $# -gt 0 ]]; do | |||
| 34 | BUILD_OPEN_PROJECT="$2" | 34 | BUILD_OPEN_PROJECT="$2" |
| 35 | shift 2 | 35 | shift 2 |
| 36 | ;; | 36 | ;; |
| 37 | + --enable-op-kernel) | ||
| 38 | + ENABLE_OP_KERNEL="$2" | ||
| 39 | + shift 2 | ||
| 40 | + ;; | ||
| 37 | --binary-out-dir) | 41 | --binary-out-dir) |
| 38 | ASCEND_BINARY_OUT_DIR="$2" | 42 | ASCEND_BINARY_OUT_DIR="$2" |
| 39 | shift 2 | 43 | shift 2 |
| @@ -164,6 +168,7 @@ function build() { | |||
| 164 | cmake ${PATH_TO_SOURCE} \ | 168 | cmake ${PATH_TO_SOURCE} \ |
| 165 | -DBUILD_OPEN_PROJECT=${BUILD_OPEN_PROJECT} \ | 169 | -DBUILD_OPEN_PROJECT=${BUILD_OPEN_PROJECT} \ |
| 166 | -DPREPARE_BUILD=ON \ | 170 | -DPREPARE_BUILD=ON \ |
| 171 | + -DENABLE_OP_KERNEL=${ENABLE_OP_KERNEL:-OFF} \ | ||
| 167 | -DCUSTOM_ASCEND_CANN_PACKAGE_PATH=${ASCEND_CANN_PACKAGE_PATH} \ | 172 | -DCUSTOM_ASCEND_CANN_PACKAGE_PATH=${ASCEND_CANN_PACKAGE_PATH} \ |
| 168 | -DASCEND_AUTOGEN_DIR=${ASCEND_AUTOGEN_DIR} \ | 173 | -DASCEND_AUTOGEN_DIR=${ASCEND_AUTOGEN_DIR} \ |
| 169 | -DASCEND_BINARY_OUT_DIR=${ASCEND_BINARY_OUT_DIR} \ | 174 | -DASCEND_BINARY_OUT_DIR=${ASCEND_BINARY_OUT_DIR} \ |
| @@ -73,6 +73,7 @@ function(gen_es_transformer_lib_builtin) | |||
| 73 | PRIVATE | 73 | PRIVATE |
| 74 | ${OPS_TRANSFORMER_DIR}/common/include/op_host | 74 | ${OPS_TRANSFORMER_DIR}/common/include/op_host |
| 75 | ) | 75 | ) |
| 76 | + if(NOT ENABLE_OP_KERNEL) | ||
| 76 | add_es_library_and_whl( | 77 | add_es_library_and_whl( |
| 77 | ES_LINKABLE_AND_ALL_TARGET es_transformer | 78 | ES_LINKABLE_AND_ALL_TARGET es_transformer |
| 78 | OPP_PROTO_TARGET proto_temp_transformer | 79 | OPP_PROTO_TARGET proto_temp_transformer |
| @@ -93,6 +94,7 @@ function(gen_es_transformer_lib_builtin) | |||
| 93 | DESTINATION ${WHL_INSTALL_DIR}/es_packages/whl | 94 | DESTINATION ${WHL_INSTALL_DIR}/es_packages/whl |
| 94 | OPTIONAL | 95 | OPTIONAL |
| 95 | ) | 96 | ) |
| 97 | + endif() | ||
| 96 | endfunction() | 98 | endfunction() |
| 97 | 99 | ||
| 98 | # graph_plugin shared | 100 | # graph_plugin shared |
| @@ -139,6 +141,7 @@ function(gen_opgraph_symbol) | |||
| 139 | ${OPS_TRANSFORMER_DIR}/common/include/op_host | 141 | ${OPS_TRANSFORMER_DIR}/common/include/op_host |
| 140 | ) | 142 | ) |
| 141 | 143 | ||
| 144 | + if(NOT ENABLE_OP_KERNEL) | ||
| 142 | if(TARGET ${GRAPH_PLUGIN_NAME}_obj) | 145 | if(TARGET ${GRAPH_PLUGIN_NAME}_obj) |
| 143 | message(STATUS "Link es graph to graph plugin obj") | 146 | message(STATUS "Link es graph to graph plugin obj") |
| 144 | unset(GRAPH_SOURCE) | 147 | unset(GRAPH_SOURCE) |
| @@ -162,6 +165,7 @@ function(gen_opgraph_symbol) | |||
| 162 | -Wl,--as-needed | 165 | -Wl,--as-needed |
| 163 | ) | 166 | ) |
| 164 | endif() | 167 | endif() |
| 168 | + endif() | ||
| 165 | set_target_properties(${OPGRAPH_NAME} PROPERTIES OUTPUT_NAME "opgraph_transformer") | 169 | set_target_properties(${OPGRAPH_NAME} PROPERTIES OUTPUT_NAME "opgraph_transformer") |
| 166 | install(TARGETS ${OPGRAPH_NAME} | 170 | install(TARGETS ${OPGRAPH_NAME} |
| 167 | LIBRARY DESTINATION ${OPGRAPH_LIB_INSTALL_DIR} | 171 | LIBRARY DESTINATION ${OPGRAPH_LIB_INSTALL_DIR} |
| @@ -30,8 +30,10 @@ target_link_libraries(proto_math PRIVATE | |||
| 30 | ) | 30 | ) |
| 31 | 31 | ||
| 32 | # 生成es_math | 32 | # 生成es_math |
| 33 | +if(NOT ENABLE_OP_KERNEL) | ||
| 33 | add_es_library_and_whl( | 34 | add_es_library_and_whl( |
| 34 | ES_LINKABLE_AND_ALL_TARGET es_math | 35 | ES_LINKABLE_AND_ALL_TARGET es_math |
| 35 | OPP_PROTO_TARGET proto_math | 36 | OPP_PROTO_TARGET proto_math |
| 36 | OUTPUT_PATH ${CMAKE_BINARY_DIR}/es_packages_math | 37 | OUTPUT_PATH ${CMAKE_BINARY_DIR}/es_packages_math |
| 37 | ) | 38 | ) |
| 39 | +endif() | ||
| @@ -15,7 +15,9 @@ set_cann_build_dependencies(opbase ">=8.5") | |||
| 15 | set_cann_build_dependencies(hcomm ">=8.5") | 15 | set_cann_build_dependencies(hcomm ">=8.5") |
| 16 | set_cann_build_dependencies(ge-executor ">=8.5") | 16 | set_cann_build_dependencies(ge-executor ">=8.5") |
| 17 | set_cann_build_dependencies(metadef ">=8.5") | 17 | set_cann_build_dependencies(metadef ">=8.5") |
| 18 | -set_cann_build_dependencies(ge-compiler ">=8.5") | 18 | +if(NOT ENABLE_OP_KERNEL) |
| 19 | + set_cann_build_dependencies(ge-compiler ">=8.5") | ||
| 20 | +endif() | ||
| 19 | set_cann_build_dependencies(asc-devkit ">=8.5") | 21 | set_cann_build_dependencies(asc-devkit ">=8.5") |
| 20 | set_cann_build_dependencies(bisheng-compiler ">=8.5") | 22 | set_cann_build_dependencies(bisheng-compiler ">=8.5") |
| 21 | 23 | ||