已合并
refactor(build): align build, test, and package pipelines with CANN 9.1.0 #69
LiuZonggu创建于 7月21日
refactor(build): align build, test, and package pipelines with CANN 9.1.0 #69
已合并
从已删除 :oat-correct合入到cann/ops-rasmaster
共 137 个文件变更+6242-20755
| @@ -10,10 +10,16 @@ | |||
| 10 | 10 | ||
| 11 | cmake_minimum_required(VERSION 3.16) | 11 | cmake_minimum_required(VERSION 3.16) |
| 12 | set(PKG_NAME ras) | 12 | set(PKG_NAME ras) |
| 13 | +set(CANN_3RD_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/third_party CACHE STRING "cann third party lib path") | ||
| 14 | +include(cmake/third_party/fetch_cann_cmake.cmake) | ||
| 15 | +set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${RULE_LAUNCH}) | ||
| 16 | +set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${RULE_LAUNCH}) | ||
| 17 | + | ||
| 13 | project(${PKG_NAME} VERSION 1.0.0) | 18 | project(${PKG_NAME} VERSION 1.0.0) |
| 14 | 19 | ||
| 15 | find_program(CCACHE_PROGRAM ccache) | 20 | find_program(CCACHE_PROGRAM ccache) |
| 16 | -if(CCACHE_PROGRAM) | 21 | +option(ENABLE_CCACHE "Enable ccache compilation acceleration" ON) |
| 22 | +if(ENABLE_CCACHE AND CCACHE_PROGRAM) | ||
| 17 | set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) | 23 | set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) |
| 18 | set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) | 24 | set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM}) |
| 19 | endif() | 25 | endif() |
| @@ -45,14 +51,16 @@ option(ENABLE_EXPERIMENTAL "Enable experimental module" OFF) | |||
| 45 | option(ENABLE_COVERAGE "Enable coverage" OFF) | 51 | option(ENABLE_COVERAGE "Enable coverage" OFF) |
| 46 | option(ENABLE_MSSANITIZER "Enable mssanitizer mode" OFF) | 52 | option(ENABLE_MSSANITIZER "Enable mssanitizer mode" OFF) |
| 47 | option(ENABLE_OOM "Enable oom mode" OFF) | 53 | option(ENABLE_OOM "Enable oom mode" OFF) |
| 54 | +option(ENABLE_DUMP_CCE "Enable dump_cce mode" OFF) | ||
| 55 | +option(NO_AICPU "Disable aicpu targets" OFF) | ||
| 56 | +option(NO_ACLNN "Disable ACLNN targets" OFF) | ||
| 48 | option(OP_HOST_UT "Enable ophost ut" OFF) | 57 | option(OP_HOST_UT "Enable ophost ut" OFF) |
| 49 | option(OP_API_UT "Enable opapi ut" OFF) | 58 | option(OP_API_UT "Enable opapi ut" OFF) |
| 50 | option(OP_GRAPH_UT "Enable graph ut" OFF) | 59 | option(OP_GRAPH_UT "Enable graph ut" OFF) |
| 51 | option(OP_KERNEL_UT "Enable kernel ut" OFF) | 60 | option(OP_KERNEL_UT "Enable kernel ut" OFF) |
| 52 | option(OP_KERNEL_AICPU_UT "Enable aicpu kernel ut" OFF) | 61 | option(OP_KERNEL_AICPU_UT "Enable aicpu kernel ut" OFF) |
| 53 | option(UT_TEST_ALL "Enable all ut" OFF) | 62 | option(UT_TEST_ALL "Enable all ut" OFF) |
| 54 | - | 63 | +option(DOWNLOAD_OPS_TEST_KIT "Download ops-test-kit repository" OFF) |
| 55 | -set(CANN_3RD_LIB_PATH ${PROJECT_SOURCE_DIR}/third_party CACHE STRING "cann third party lib path") | ||
| 56 | 64 | ||
| 57 | if(ENABLE_TEST) | 65 | if(ENABLE_TEST) |
| 58 | set(DEFAULT_BUILD_TYPE "Debug") | 66 | set(DEFAULT_BUILD_TYPE "Debug") |
| @@ -91,26 +99,37 @@ endif() | |||
| 91 | set(CMAKE_CXX_STANDARD | 99 | set(CMAKE_CXX_STANDARD |
| 92 | 17 | 100 | 17 |
| 93 | CACHE STRING "c++17 is needed for this project") | 101 | CACHE STRING "c++17 is needed for this project") |
| 102 | +include(cmake/third_party/opbase.cmake) # 放在dependencies.cmake前面 | ||
| 103 | +if(DOWNLOAD_OPS_TEST_KIT) | ||
| 104 | + include(cmake/third_party/ops_test_kit.cmake) | ||
| 105 | +endif() | ||
| 94 | include(cmake/dependencies.cmake) | 106 | include(cmake/dependencies.cmake) |
| 95 | -include(cmake/third_party/nlohmann_json.cmake) | 107 | +add_cann_third_party(json) |
| 96 | -include(cmake/third_party/abseil-cpp.cmake) | 108 | +add_cann_third_party(abseil-cpp) |
| 97 | -include(cmake/third_party/ascend_protobuf.cmake) | 109 | +add_cann_third_party(protobuf) |
| 98 | include(cmake/variables.cmake) | 110 | include(cmake/variables.cmake) |
| 99 | include(cmake/func.cmake) | 111 | include(cmake/func.cmake) |
| 100 | include(cmake/opbuild.cmake) | 112 | include(cmake/opbuild.cmake) |
| 101 | -include(cmake/third_party/eigen.cmake) | 113 | +add_cann_third_party(eigen) |
| 102 | include(cmake/intf_pub_linux.cmake) | 114 | include(cmake/intf_pub_linux.cmake) |
| 103 | include(cmake/modules/Finddlog.cmake) | 115 | include(cmake/modules/Finddlog.cmake) |
| 116 | +include(version.cmake) | ||
| 104 | 117 | ||
| 105 | if(ENABLE_CUSTOM AND ENABLE_ASC_BUILD) | 118 | if(ENABLE_CUSTOM AND ENABLE_ASC_BUILD) |
| 106 | include(cmake/custom_kernel.cmake) | 119 | include(cmake/custom_kernel.cmake) |
| 107 | endif() | 120 | endif() |
| 108 | 121 | ||
| 122 | +init_cann_project() | ||
| 123 | +if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) | ||
| 124 | + check_cann_pkg_build_deps("ops-ras") | ||
| 125 | +endif() | ||
| 126 | +add_cann_version_info_targets() | ||
| 127 | + | ||
| 109 | if(ENABLE_TEST) | 128 | if(ENABLE_TEST) |
| 110 | # ut common dependencies | 129 | # ut common dependencies |
| 130 | + add_cann_third_party(gtest) | ||
| 111 | include(cmake/intf_pub_llt_gccnative.cmake) | 131 | include(cmake/intf_pub_llt_gccnative.cmake) |
| 112 | include(cmake/ut.cmake) | 132 | include(cmake/ut.cmake) |
| 113 | - include(cmake/third_party/gtest.cmake) | ||
| 114 | 133 | ||
| 115 | # op host ut | 134 | # op host ut |
| 116 | if(UT_TEST_ALL OR OP_HOST_UT) | 135 | if(UT_TEST_ALL OR OP_HOST_UT) |
| @@ -122,11 +141,15 @@ if(ENABLE_TEST) | |||
| 122 | # op api ut | 141 | # op api ut |
| 123 | if(UT_TEST_ALL OR OP_API_UT) | 142 | if(UT_TEST_ALL OR OP_API_UT) |
| 124 | set(OP_API_MODULE_NAME ${PKG_NAME}_op_api_ut) | 143 | set(OP_API_MODULE_NAME ${PKG_NAME}_op_api_ut) |
| 144 | + set(OP_API_UT_COMMON_INC | ||
| 145 | + ${CMAKE_SOURCE_DIR}/tests/ut/op_api/op_api_ut_common/inc | ||
| 146 | + CACHE STRING "opapi ut common include path" FORCE) | ||
| 125 | endif() | 147 | endif() |
| 126 | 148 | ||
| 127 | # op graph ut | 149 | # op graph ut |
| 128 | if(UT_TEST_ALL OR OP_GRAPH_UT) | 150 | if(UT_TEST_ALL OR OP_GRAPH_UT) |
| 129 | - include(cmake/opbuild.cmake) | 151 | + include(cmake/gen_ops_info.cmake) |
| 152 | + include(cmake/symbol.cmake) | ||
| 130 | set(OP_GRAPH_MODULE_NAME ${PKG_NAME}_op_graph_ut) | 153 | set(OP_GRAPH_MODULE_NAME ${PKG_NAME}_op_graph_ut) |
| 131 | endif() | 154 | endif() |
| 132 | 155 | ||
| @@ -7,7 +7,7 @@ googletest: | |||
| 7 | version: v1.14.0 | 7 | version: v1.14.0 |
| 8 | type: test | 8 | type: test |
| 9 | eigen: | 9 | eigen: |
| 10 | - version: 3.4.0 | 10 | + version: 5.0.0 |
| 11 | type: run | 11 | type: run |
| 12 | makeself: | 12 | makeself: |
| 13 | version: 2.5.0-patch1.0 | 13 | version: 2.5.0-patch1.0 |
| @@ -221,7 +221,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||
| 221 | THE SOFTWARE. | 221 | THE SOFTWARE. |
| 222 | 222 | ||
| 223 | Copyright Notice and License Texts | 223 | Copyright Notice and License Texts |
| 224 | -Software: eigen 3.4.0 | 224 | +Software: eigen 5.0.0 |
| 225 | Copyright notice: | 225 | Copyright notice: |
| 226 | Copyright (c) 2020 Arm Ltd. and Contributors | 226 | Copyright (c) 2020 Arm Ltd. and Contributors |
| 227 | Copyright (c) 2011, Intel Corporation | 227 | Copyright (c) 2011, Intel Corporation |
| @@ -9,9 +9,9 @@ | |||
| 9 | # ============================================================================ | 9 | # ============================================================================ |
| 10 | 10 | ||
| 11 | set -e | 11 | set -e |
| 12 | -RELEASE_TARGETS=("ophost" "opapi" "onnxplugin" "opgraph") | 12 | +RELEASE_TARGETS=("ophost" "opapi" "onnxplugin" "opgraph" "tfplugin") |
| 13 | 13 | ||
| 14 | -SUPPORT_COMPUTE_UNIT_SHORT=("ascend031" "ascend035" "ascend310b" "ascend310p" "ascend910_93" "ascend950" "ascend910b" "ascend910" "kirinx90" "kirin9030" "mc62cm12a") | 14 | +SUPPORT_COMPUTE_UNIT_SHORT=("ascend031" "ascend035" "ascend310b" "ascend310p" "ascend910_93" "ascend950" "ascend350" "ascend910b" "ascend910" "kirinx90" "kirin9030" "mc62") |
| 15 | # 对SUPPORT_COMPUTE_UNIT_SHORT按字符串长度从长到短排序,避免前缀匹配时出错 | 15 | # 对SUPPORT_COMPUTE_UNIT_SHORT按字符串长度从长到短排序,避免前缀匹配时出错 |
| 16 | SUPPORT_COMPUTE_UNIT_SHORT=($(printf '%s\n' "${SUPPORT_COMPUTE_UNIT_SHORT[@]}" | awk '{print length($0) " " $0}' | sort -rn | cut -d ' ' -f2-)) | 16 | SUPPORT_COMPUTE_UNIT_SHORT=($(printf '%s\n' "${SUPPORT_COMPUTE_UNIT_SHORT[@]}" | awk '{print length($0) " " $0}' | sort -rn | cut -d ' ' -f2-)) |
| 17 | TRIGER_UTS=() | 17 | TRIGER_UTS=() |
| @@ -21,9 +21,10 @@ SUPPORTED_SHORT_OPTS="hj:vO:uf:-:" | |||
| 21 | 21 | ||
| 22 | # 所有支持的长选项 | 22 | # 所有支持的长选项 |
| 23 | SUPPORTED_LONG_OPTS=( | 23 | SUPPORTED_LONG_OPTS=( |
| 24 | - "help" "ops=" "soc=" "vendor_name=" "build-type=" "cov" "noexec" "opkernel" "opkernel_aicpu" "opkernel_aicpu_test" "static" | 24 | + "help" "ops=" "soc=" "vendor_name=" "build-type=" "cov" "noexec" "noaicpu" "opkernel" "opkernel_aicpu" "opkernel_aicpu_test" "static" |
| 25 | "jit" "pkg" "asan" "make_clean_all" "make_clean" "no_force" | 25 | "jit" "pkg" "asan" "make_clean_all" "make_clean" "no_force" |
| 26 | - "ophost" "opgraph" "opapi" "run_example" "example_name=" "genop=" "genop_aicpu=" "experimental" "cann_3rd_lib_path=" "oom" "onnxplugin" "dump_cce" | 26 | + "ophost" "opgraph" "opapi" "run_example" "example_name=" "genop=" "genop_aicpu=" "experimental" "cann_3rd_lib_path=" "oom" "onnxplugin" "tfplugin" "dump_cce" |
| 27 | + "module_extension=" "noaclnn" "mssanitizer" "rule_launch=" "ccache=" | ||
| 27 | ) | 28 | ) |
| 28 | 29 | ||
| 29 | in_array() { | 30 | in_array() { |
| @@ -241,6 +242,19 @@ usage() { | |||
| 241 | echo " bash build.sh --onnxplugin --debug" | 242 | echo " bash build.sh --onnxplugin --debug" |
| 242 | return | 243 | return |
| 243 | ;; | 244 | ;; |
| 245 | + tfplugin) | ||
| 246 | + echo "TensorFlow Plugin Build Options:" | ||
| 247 | + echo $dotted_line | ||
| 248 | + echo " --tfplugin Build TensorFlow plugin library" | ||
| 249 | + echo " -j[n] Compile thread nums, default is 8, eg: -j8" | ||
| 250 | + echo " -O[n] Compile optimization options, support [O0 O1 O2 O3], eg:-O3" | ||
| 251 | + echo " --debug Build with debug mode" | ||
| 252 | + echo $dotted_line | ||
| 253 | + echo "Examples:" | ||
| 254 | + echo " bash build.sh --tfplugin -j16 -O3" | ||
| 255 | + echo " bash build.sh --tfplugin --debug" | ||
| 256 | + return | ||
| 257 | + ;; | ||
| 244 | opgraph) | 258 | opgraph) |
| 245 | echo "Opgraph Build Options:" | 259 | echo "Opgraph Build Options:" |
| 246 | echo $dotted_line | 260 | echo $dotted_line |
| @@ -330,7 +344,8 @@ usage() { | |||
| 330 | echo " --ops Compile specified operator, use snake name, like: --ops=add,add_lora, use ',' to separate different operator" | 344 | echo " --ops Compile specified operator, use snake name, like: --ops=add,add_lora, use ',' to separate different operator" |
| 331 | echo " --soc Compile binary with specified Ascend SoC, like: --soc=ascend910b" | 345 | echo " --soc Compile binary with specified Ascend SoC, like: --soc=ascend910b" |
| 332 | echo " --vendor_name Specify the custom operator pkg vendor name, like: --vendor_name=customize, default to customize-ras" | 346 | echo " --vendor_name Specify the custom operator pkg vendor name, like: --vendor_name=customize, default to customize-ras" |
| 333 | - echo " --onnxplugin build op_ras_onnx_plugin.so" | 347 | + echo " --onnxplugin build oponnx_plugin_ras.so" |
| 348 | + echo " --tfplugin build optf_plugin_ras.so" | ||
| 334 | echo " --opapi build opapi_ras.so" | 349 | echo " --opapi build opapi_ras.so" |
| 335 | echo " --ophost build ophost_ras.so" | 350 | echo " --ophost build ophost_ras.so" |
| 336 | echo " --opkernel build binary kernel" | 351 | echo " --opkernel build binary kernel" |
| @@ -360,7 +375,7 @@ check_help_combinations() { | |||
| 360 | for arg in "${args[@]}"; do | 375 | for arg in "${args[@]}"; do |
| 361 | case "$arg" in | 376 | case "$arg" in |
| 362 | -u) has_u=true ;; | 377 | -u) has_u=true ;; |
| 363 | - --ophost | --opapi | --onnxplugin | --opgraph) | 378 | + --ophost | --opapi | --onnxplugin | --tfplugin | --opgraph) |
| 364 | has_test_command=true | 379 | has_test_command=true |
| 365 | has_build_command=true | 380 | has_build_command=true |
| 366 | ;; | 381 | ;; |
| @@ -466,7 +481,7 @@ set_create_libs() { | |||
| 466 | return | 481 | return |
| 467 | fi | 482 | fi |
| 468 | if [[ "$ENABLE_PACKAGE" == "TRUE" && "$ENABLE_CUSTOM" != "TRUE" ]]; then | 483 | if [[ "$ENABLE_PACKAGE" == "TRUE" && "$ENABLE_CUSTOM" != "TRUE" ]]; then |
| 469 | - BUILD_LIBS=("ophost_${REPOSITORY_NAME}" "opapi_${REPOSITORY_NAME}" "op_${REPOSITORY_NAME}_onnx_plugin" "opgraph_${REPOSITORY_NAME}") | 484 | + BUILD_LIBS=("ophost_${REPOSITORY_NAME}" "opapi_${REPOSITORY_NAME}" "oponnx_plugin_${REPOSITORY_NAME}" "optf_plugin_${REPOSITORY_NAME}" "opgraph_${REPOSITORY_NAME}") |
| 470 | ENABLE_CREATE_LIB=TRUE | 485 | ENABLE_CREATE_LIB=TRUE |
| 471 | else | 486 | else |
| 472 | if [[ "$OP_HOST" == "TRUE" ]]; then | 487 | if [[ "$OP_HOST" == "TRUE" ]]; then |
| @@ -478,7 +493,11 @@ set_create_libs() { | |||
| 478 | ENABLE_CREATE_LIB=TRUE | 493 | ENABLE_CREATE_LIB=TRUE |
| 479 | fi | 494 | fi |
| 480 | if [[ "$ONNX_PLUGIN" == "TRUE" ]]; then | 495 | if [[ "$ONNX_PLUGIN" == "TRUE" ]]; then |
| 481 | - BUILD_LIBS+=("op_${REPOSITORY_NAME}_onnx_plugin") | 496 | + BUILD_LIBS+=("oponnx_plugin_${REPOSITORY_NAME}") |
| 497 | + ENABLE_CREATE_LIB=TRUE | ||
| 498 | + fi | ||
| 499 | + if [[ "$TF_PLUGIN" == "TRUE" ]]; then | ||
| 500 | + BUILD_LIBS+=("optf_plugin_${REPOSITORY_NAME}") | ||
| 482 | ENABLE_CREATE_LIB=TRUE | 501 | ENABLE_CREATE_LIB=TRUE |
| 483 | fi | 502 | fi |
| 484 | if [[ "$OP_GRAPH" == "TRUE" ]]; then | 503 | if [[ "$OP_GRAPH" == "TRUE" ]]; then |
| @@ -597,6 +616,12 @@ checkopts() { | |||
| 597 | OP_HOST_UT=FALSE | 616 | OP_HOST_UT=FALSE |
| 598 | OP_GRAPH_UT=FALSE | 617 | OP_GRAPH_UT=FALSE |
| 599 | ONNX_PLUGIN=FALSE | 618 | ONNX_PLUGIN=FALSE |
| 619 | + TF_PLUGIN=FALSE | ||
| 620 | + NO_AICPU=FALSE | ||
| 621 | + NO_ACLNN=FALSE | ||
| 622 | + MODULE_EXT="" | ||
| 623 | + ENABLE_RULE_LAUNCH="" | ||
| 624 | + ENABLE_CCACHE=TRUE | ||
| 600 | OP_KERNEL_UT=FALSE | 625 | OP_KERNEL_UT=FALSE |
| 601 | OP_KERNEL_AICPU_UT=FALSE | 626 | OP_KERNEL_AICPU_UT=FALSE |
| 602 | OP_API=FALSE | 627 | OP_API=FALSE |
| @@ -653,6 +678,7 @@ checkopts() { | |||
| 653 | --opgraph) SHOW_HELP="opgraph" ;; | 678 | --opgraph) SHOW_HELP="opgraph" ;; |
| 654 | --opapi) SHOW_HELP="opapi" ;; | 679 | --opapi) SHOW_HELP="opapi" ;; |
| 655 | --onnxplugin) SHOW_HELP="onnxplugin" ;; | 680 | --onnxplugin) SHOW_HELP="onnxplugin" ;; |
| 681 | + --tfplugin) SHOW_HELP="tfplugin" ;; | ||
| 656 | --run_example) SHOW_HELP="run_example" ;; | 682 | --run_example) SHOW_HELP="run_example" ;; |
| 657 | --genop) SHOW_HELP="genop" ;; | 683 | --genop) SHOW_HELP="genop" ;; |
| 658 | --genop_aicpu) SHOW_HELP="genop_aicpu" ;; | 684 | --genop_aicpu) SHOW_HELP="genop_aicpu" ;; |
| @@ -742,7 +768,17 @@ checkopts() { | |||
| 742 | build-type=*) | 768 | build-type=*) |
| 743 | BUILD_TYPE=${OPTARG#*=} | 769 | BUILD_TYPE=${OPTARG#*=} |
| 744 | ;; | 770 | ;; |
| 745 | - mssanitizer) ENABLE_MSSANITIZER=FALSE ;; | 771 | + mssanitizer) ENABLE_MSSANITIZER=TRUE ;; |
| 772 | + noaicpu) NO_AICPU=TRUE ;; | ||
| 773 | + noaclnn) NO_ACLNN=TRUE ;; | ||
| 774 | + module_extension=*) MODULE_EXT=${OPTARG#*=} ;; | ||
| 775 | + rule_launch=*) ENABLE_RULE_LAUNCH=${OPTARG#*=} ;; | ||
| 776 | + ccache=*) | ||
| 777 | + ccache_value=${OPTARG#*=} | ||
| 778 | + if [[ "$ccache_value" == "off" || "$ccache_value" == "false" || "$ccache_value" == "disable" ]]; then | ||
| 779 | + ENABLE_CCACHE=FALSE | ||
| 780 | + fi | ||
| 781 | + ;; | ||
| 746 | oom) ENABLE_OOM=TRUE ;; | 782 | oom) ENABLE_OOM=TRUE ;; |
| 747 | dump_cce) ENABLE_DUMP_CCE=TRUE ;; | 783 | dump_cce) ENABLE_DUMP_CCE=TRUE ;; |
| 748 | noexec) ENABLE_UT_EXEC=FALSE ;; | 784 | noexec) ENABLE_UT_EXEC=FALSE ;; |
| @@ -801,6 +837,8 @@ checkopts() { | |||
| 801 | OP_KERNEL_AICPU=TRUE | 837 | OP_KERNEL_AICPU=TRUE |
| 802 | elif [[ "$OPTARG" == "onnxplugin" ]]; then | 838 | elif [[ "$OPTARG" == "onnxplugin" ]]; then |
| 803 | ONNX_PLUGIN=TRUE | 839 | ONNX_PLUGIN=TRUE |
| 840 | + elif [[ "$OPTARG" == "tfplugin" ]]; then | ||
| 841 | + TF_PLUGIN=TRUE | ||
| 804 | else | 842 | else |
| 805 | usage | 843 | usage |
| 806 | exit 1 | 844 | exit 1 |
| @@ -815,7 +853,8 @@ checkopts() { | |||
| 815 | esac | 853 | esac |
| 816 | done | 854 | done |
| 817 | 855 | ||
| 818 | - if [[ "$OP_KERNEL_AICPU_UT" != "TRUE" && "$ENABLE_TEST" == "TRUE" && "$OP_HOST" == "FALSE" && "$OP_GRAPH" == "FALSE" && "$OP_API" == "FALSE" && "$OP_KERNEL" == "FALSE" ]]; then | 856 | + if [[ "$OP_KERNEL_AICPU_UT" != "TRUE" && "$OP_KERNEL_AICPU" != "TRUE" && "$ENABLE_TEST" == "TRUE" && |
| 857 | + "$OP_HOST" == "FALSE" && "$OP_GRAPH" == "FALSE" && "$OP_API" == "FALSE" && "$OP_KERNEL" == "FALSE" ]]; then | ||
| 819 | OP_HOST=TRUE | 858 | OP_HOST=TRUE |
| 820 | OP_GRAPH=TRUE | 859 | OP_GRAPH=TRUE |
| 821 | OP_API=TRUE | 860 | OP_API=TRUE |
| @@ -871,6 +910,13 @@ assemble_cmake_args() { | |||
| 871 | CMAKE_ARGS="$CMAKE_ARGS -DENABLE_UT_EXEC=${ENABLE_UT_EXEC}" | 910 | CMAKE_ARGS="$CMAKE_ARGS -DENABLE_UT_EXEC=${ENABLE_UT_EXEC}" |
| 872 | CMAKE_ARGS="$CMAKE_ARGS -DENABLE_CUSTOM=${ENABLE_CUSTOM}" | 911 | CMAKE_ARGS="$CMAKE_ARGS -DENABLE_CUSTOM=${ENABLE_CUSTOM}" |
| 873 | CMAKE_ARGS="$CMAKE_ARGS -DENABLE_STATIC=${ENABLE_STATIC}" | 912 | CMAKE_ARGS="$CMAKE_ARGS -DENABLE_STATIC=${ENABLE_STATIC}" |
| 913 | + CMAKE_ARGS="$CMAKE_ARGS -DNO_AICPU=${NO_AICPU}" | ||
| 914 | + CMAKE_ARGS="$CMAKE_ARGS -DNO_ACLNN=${NO_ACLNN}" | ||
| 915 | + CMAKE_ARGS="$CMAKE_ARGS -DMODULE_EXT=${MODULE_EXT}" | ||
| 916 | + CMAKE_ARGS="$CMAKE_ARGS -DENABLE_CCACHE=${ENABLE_CCACHE}" | ||
| 917 | + if [[ -n "$ENABLE_RULE_LAUNCH" ]]; then | ||
| 918 | + CMAKE_ARGS="$CMAKE_ARGS -DRULE_LAUNCH=${ENABLE_RULE_LAUNCH}" | ||
| 919 | + fi | ||
| 874 | custom_cmake_args | 920 | custom_cmake_args |
| 875 | if [[ "$ENABLE_ASAN" == "TRUE" ]]; then | 921 | if [[ "$ENABLE_ASAN" == "TRUE" ]]; then |
| 876 | set +e | 922 | set +e |
| @@ -1113,6 +1159,7 @@ build_ut() { | |||
| 1113 | # 删除ai_core下的json文件,强制UT执行时重新生成json文件,避免多次执行之间的干扰 | 1159 | # 删除ai_core下的json文件,强制UT执行时重新生成json文件,避免多次执行之间的干扰 |
| 1114 | cd "${BUILD_PATH}" && rm -rf ${BUILD_PATH}/tbe/op_info_cfg/ai_core/* && cmake ${CMAKE_ARGS} .. | 1160 | cd "${BUILD_PATH}" && rm -rf ${BUILD_PATH}/tbe/op_info_cfg/ai_core/* && cmake ${CMAKE_ARGS} .. |
| 1115 | local enable_cov=FALSE | 1161 | local enable_cov=FALSE |
| 1162 | + local ut_build_failed=0 | ||
| 1116 | if [[ "$CI_MODE" == "TRUE" ]]; then | 1163 | if [[ "$CI_MODE" == "TRUE" ]]; then |
| 1117 | # ci 模式 | 1164 | # ci 模式 |
| 1118 | for trigger_option in "${TRIGGER_UTS[@]}"; do | 1165 | for trigger_option in "${TRIGGER_UTS[@]}"; do |
| @@ -1125,7 +1172,7 @@ build_ut() { | |||
| 1125 | else | 1172 | else |
| 1126 | cmake ${CMAKE_ARGS} -DASCEND_OP_NAME=${ut_args[1]} -DASCEND_COMPILE_OPS=${ut_args[2]} -DASCEND_COMPUTE_UNIT=${ut_args[3]} .. | 1173 | cmake ${CMAKE_ARGS} -DASCEND_OP_NAME=${ut_args[1]} -DASCEND_COMPILE_OPS=${ut_args[2]} -DASCEND_COMPUTE_UNIT=${ut_args[3]} .. |
| 1127 | fi | 1174 | fi |
| 1128 | - cmake --build . --target ${REPOSITORY_NAME}_${ut_args[0]} -- ${VERBOSE} -j $THREAD_NUM | 1175 | + cmake --build . --target ${REPOSITORY_NAME}_${ut_args[0]} -- ${VERBOSE} -j $THREAD_NUM || ut_build_failed=1 |
| 1129 | else | 1176 | else |
| 1130 | echo "Not need trigger Ut: ${ut_args[0]}" | 1177 | echo "Not need trigger Ut: ${ut_args[0]}" |
| 1131 | fi | 1178 | fi |
| @@ -1140,12 +1187,16 @@ build_ut() { | |||
| 1140 | cmake ${CMAKE_ARGS} .. | 1187 | cmake ${CMAKE_ARGS} .. |
| 1141 | fi | 1188 | fi |
| 1142 | fi | 1189 | fi |
| 1143 | - cmake --build . --target ${UT_TARGES[@]} -- ${VERBOSE} -j $THREAD_NUM | 1190 | + cmake --build . --target ${UT_TARGES[@]} -- ${VERBOSE} -j $THREAD_NUM || ut_build_failed=1 |
| 1144 | fi | 1191 | fi |
| 1145 | 1192 | ||
| 1146 | if [[ "$ENABLE_COVERAGE" =~ "TRUE" && "$enable_cov" == "TRUE" ]]; then | 1193 | if [[ "$ENABLE_COVERAGE" =~ "TRUE" && "$enable_cov" == "TRUE" ]]; then |
| 1147 | cmake --build . --target generate_ops_cpp_cov -- ${VERBOSE} -j $THREAD_NUM | 1194 | cmake --build . --target generate_ops_cpp_cov -- ${VERBOSE} -j $THREAD_NUM |
| 1148 | fi | 1195 | fi |
| 1196 | + if [[ "$ut_build_failed" == "1" ]]; then | ||
| 1197 | + print_error "UT build/test failed" | ||
| 1198 | + exit 1 | ||
| 1199 | + fi | ||
| 1149 | } | 1200 | } |
| 1150 | 1201 | ||
| 1151 | build_single_example() { | 1202 | build_single_example() { |
| @@ -1156,19 +1207,33 @@ build_single_example() { | |||
| 1156 | if [[ "${VENDOR_NAME}" == "" ]]; then | 1207 | if [[ "${VENDOR_NAME}" == "" ]]; then |
| 1157 | VENDOR_NAME="custom" | 1208 | VENDOR_NAME="custom" |
| 1158 | fi | 1209 | fi |
| 1159 | - export CUST_LIBRARY_PATH="${ASCEND_HOME_PATH}/opp/vendors/${VENDOR_NAME}_ras/op_api/lib" # 仅自定义算子需要 | 1210 | + local cust_include_flags="" |
| 1160 | - export CUST_INCLUDE_PATH="${ASCEND_HOME_PATH}/opp/vendors/${VENDOR_NAME}_ras/op_api/include" # 仅自定义算子需要 | 1211 | + local cust_library_flags="" |
| 1161 | - export LD_LIBRARY_PATH=${CUST_LIBRARY_PATH}:${LD_LIBRARY_PATH} | 1212 | + local cust_rpath_flags="" |
| 1162 | - if [ -f ${EAGER_LIBRARY_PATH}/libascendcl.so ]; then | 1213 | + if [[ -n "${ASCEND_CUSTOM_OPP_PATH}" ]]; then |
| 1163 | - g++ ${file} -I ${CUST_INCLUDE_PATH} -I ${INCLUDE_PATH} -I ${INCLUDE_PATH}/aclnnop -L ${CUST_LIBRARY_PATH} -L ${EAGER_LIBRARY_PATH} -lcust_opapi -lopapi_math -lascendcl -lnnopbase -o test_aclnn_${example} -Wl,-rpath=${CUST_LIBRARY_PATH} | 1214 | + IFS=':' read -ra PATH_ARRAY <<< "${ASCEND_CUSTOM_OPP_PATH}" |
| 1215 | + for path in "${PATH_ARRAY[@]}"; do | ||
| 1216 | + cust_include_flags="${cust_include_flags} -I ${path}/op_api/include" | ||
| 1217 | + cust_library_flags="${cust_library_flags} -L ${path}/op_api/lib" | ||
| 1218 | + cust_rpath_flags="${cust_rpath_flags}:${path}/op_api/lib" | ||
| 1219 | + done | ||
| 1220 | + cust_rpath_flags="${cust_rpath_flags#:}" | ||
| 1164 | else | 1221 | else |
| 1165 | - g++ ${file} -I ${CUST_INCLUDE_PATH} -I ${INCLUDE_PATH} -I ${INCLUDE_PATH}/aclnnop -L ${CUST_LIBRARY_PATH} -L ${EAGER_LIBRARY_PATH} -lcust_opapi -lopapi_math -lacl_rt -lnnopbase -o test_aclnn_${example} -Wl,-rpath=${CUST_LIBRARY_PATH} | 1222 | + cust_include_flags="-I ${ASCEND_HOME_PATH}/opp/vendors/${VENDOR_NAME}_ras/op_api/include" |
| 1223 | + cust_library_flags="-L ${ASCEND_HOME_PATH}/opp/vendors/${VENDOR_NAME}_ras/op_api/lib" | ||
| 1224 | + cust_rpath_flags="${ASCEND_HOME_PATH}/opp/vendors/${VENDOR_NAME}_ras/op_api/lib" | ||
| 1225 | + fi | ||
| 1226 | + export LD_LIBRARY_PATH=${cust_rpath_flags}:${LD_LIBRARY_PATH} | ||
| 1227 | + if [ -f ${EAGER_LIBRARY_PATH}/libascendcl.so ]; then | ||
| 1228 | + g++ ${file} ${cust_include_flags} -I ${INCLUDE_PATH} -I ${INCLUDE_PATH}/aclnnop ${cust_library_flags} -L ${EAGER_LIBRARY_PATH} -lcust_opapi -lopapi_math -lascendcl -lnnopbase -o test_aclnn_${example} -Wl,-rpath=${cust_rpath_flags} | ||
| 1229 | + else | ||
| 1230 | + g++ ${file} ${cust_include_flags} -I ${INCLUDE_PATH} -I ${INCLUDE_PATH}/aclnnop ${cust_library_flags} -L ${EAGER_LIBRARY_PATH} -lcust_opapi -lopapi_math -lacl_rt -lnnopbase -o test_aclnn_${example} -Wl,-rpath=${cust_rpath_flags} | ||
| 1166 | fi | 1231 | fi |
| 1167 | elif [[ "${PKG_MODE}" == "" ]]; then | 1232 | elif [[ "${PKG_MODE}" == "" ]]; then |
| 1168 | if [ -f ${EAGER_LIBRARY_PATH}/libascendcl.so ] || [ -f ${EAGER_LIBRARY_OPP_PATH}/libascendcl.so]; then | 1233 | if [ -f ${EAGER_LIBRARY_PATH}/libascendcl.so ] || [ -f ${EAGER_LIBRARY_OPP_PATH}/libascendcl.so]; then |
| 1169 | - g++ ${file} -I ${INCLUDE_PATH} -I ${INCLUDE_PATH}/aclnnop -I ${ACLNN_INCLUDE_PATH} -L ${EAGER_LIBRARY_OPP_PATH} -L ${EAGER_LIBRARY_PATH} -lopapi_nn -lopapi_math -lascendcl -lnnopbase -o test_aclnn_${example} | 1234 | + g++ ${file} -I ${INCLUDE_PATH} -I ${INCLUDE_PATH}/aclnnop -I ${ACLNN_INCLUDE_PATH} -L ${EAGER_LIBRARY_OPP_PATH} -L ${EAGER_LIBRARY_PATH} -lopapi_ras -lopapi_math -lascendcl -lnnopbase -o test_aclnn_${example} |
| 1170 | else | 1235 | else |
| 1171 | - g++ ${file} -I ${INCLUDE_PATH} -I ${INCLUDE_PATH}/aclnnop -I ${ACLNN_INCLUDE_PATH} -L ${EAGER_LIBRARY_OPP_PATH} -L ${EAGER_LIBRARY_PATH} -lopapi_nn -lopapi_math -lacl_rt -lnnopbase -o test_aclnn_${example} | 1236 | + g++ ${file} -I ${INCLUDE_PATH} -I ${INCLUDE_PATH}/aclnnop -I ${ACLNN_INCLUDE_PATH} -L ${EAGER_LIBRARY_OPP_PATH} -L ${EAGER_LIBRARY_PATH} -lopapi_ras -lopapi_math -lacl_rt -lnnopbase -o test_aclnn_${example} |
| 1172 | fi | 1237 | fi |
| 1173 | else | 1238 | else |
| 1174 | usage "run_example" | 1239 | usage "run_example" |
| @@ -1385,7 +1450,11 @@ main() { | |||
| 1385 | exit $? | 1450 | exit $? |
| 1386 | fi | 1451 | fi |
| 1387 | mkdir -p "${BUILD_PATH}" | 1452 | mkdir -p "${BUILD_PATH}" |
| 1388 | - cd "${BUILD_PATH}" && rm -f CMakeCache.txt && cmake -DENABLE_EXPERIMENTAL=${ENABLE_EXPERIMENTAL} -DPREPROCESS_ONLY=ON .. | 1453 | + cd "${BUILD_PATH}" && rm -f CMakeCache.txt && cmake \ |
| 1454 | + -DCANN_3RD_LIB_PATH="${CANN_3RD_LIB_PATH}" \ | ||
| 1455 | + -DENABLE_CCACHE="${ENABLE_CCACHE}" \ | ||
| 1456 | + -DENABLE_EXPERIMENTAL="${ENABLE_EXPERIMENTAL}" \ | ||
| 1457 | + -DPREPROCESS_ONLY=ON .. | ||
| 1389 | 1458 | ||
| 1390 | if [[ "$CI_MODE" == "TRUE" ]]; then | 1459 | if [[ "$CI_MODE" == "TRUE" ]]; then |
| 1391 | set_ci_mode | 1460 | set_ci_mode |
| @@ -1,10 +1,10 @@ | |||
| 1 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | -# This file is a part of the CANN Open Software. | 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). |
| 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 10 | #### custom to kernel build ##### | 10 | #### custom to kernel build ##### |
| @@ -23,6 +23,12 @@ function(add_custom_kernel_library ascendc_kernels) | |||
| 23 | get_op_type_from_binary_json(${binary_json} op_type) | 23 | get_op_type_from_binary_json(${binary_json} op_type) |
| 24 | if(EXISTS ${OP_DIR}/op_kernel/${op_name}.cpp) | 24 | if(EXISTS ${OP_DIR}/op_kernel/${op_name}.cpp) |
| 25 | list(APPEND op_def_list "${OP_DIR}/op_host/${op_name}_def.cpp") | 25 | list(APPEND op_def_list "${OP_DIR}/op_host/${op_name}_def.cpp") |
| 26 | + if(NOT ${MODULE_EXT} STREQUAL "") | ||
| 27 | + get_filename_component(PARENT_DIR ${OP_DIR} DIRECTORY) | ||
| 28 | + get_filename_component(op_category ${PARENT_DIR} NAME) | ||
| 29 | + file(GLOB op_def_ext_list ${MODULE_EXT}/${op_category}/${op_name}/op_host/${op_name}*_def*.cpp ) | ||
| 30 | + list(APPEND op_def_list ${op_def_ext_list}) | ||
| 31 | + endif() | ||
| 26 | list(APPEND op_name_list "${op_name}") | 32 | list(APPEND op_name_list "${op_name}") |
| 27 | list(APPEND op_type_list "${op_type}") | 33 | list(APPEND op_type_list "${op_type}") |
| 28 | endif() | 34 | endif() |
| @@ -67,4 +73,4 @@ function(add_custom_kernel_library ascendc_kernels) | |||
| 67 | add_dependencies(ascendc_kernels_lib_copy_kernel_srcs ascendc_kernel_src_copy) | 73 | add_dependencies(ascendc_kernels_lib_copy_kernel_srcs ascendc_kernel_src_copy) |
| 68 | endif() | 74 | endif() |
| 69 | set(${ascendc_kernels} ascendc_kernels_lib PARENT_SCOPE) | 75 | set(${ascendc_kernels} ascendc_kernels_lib PARENT_SCOPE) |
| 70 | -endfunction() | 76 | +endfunction() |
| @@ -60,6 +60,17 @@ message(STATUS "compile option:${CMAKE_CXX_FLAGS}") | |||
| 60 | if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) | 60 | if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) |
| 61 | if(EXISTS "${ASCEND_CANN_PACKAGE_PATH}/${SYSTEM_PREFIX}/tikcpp/ascendc_kernel_cmake") | 61 | if(EXISTS "${ASCEND_CANN_PACKAGE_PATH}/${SYSTEM_PREFIX}/tikcpp/ascendc_kernel_cmake") |
| 62 | find_package(ASC REQUIRED HINTS ${ASCEND_CANN_PACKAGE_PATH}/${SYSTEM_PREFIX}/tikcpp/ascendc_kernel_cmake) | 62 | find_package(ASC REQUIRED HINTS ${ASCEND_CANN_PACKAGE_PATH}/${SYSTEM_PREFIX}/tikcpp/ascendc_kernel_cmake) |
| 63 | + list(APPEND CMAKE_MODULE_PATH ${ASCEND_CANN_PACKAGE_PATH}/include/ge/cmake) | ||
| 64 | + find_package(GenerateEsPackage MODULE QUIET) | ||
| 65 | + if(NOT GenerateEsPackage_FOUND) | ||
| 66 | + message("") | ||
| 67 | + message("================================================================") | ||
| 68 | + message(" GenerateEsPackage package not found!") | ||
| 69 | + message("================================================================") | ||
| 70 | + message("Refer to the \"Operator Invocation\" chapter (environment preparation section) in the README and update the toolkit package to the latest version.") | ||
| 71 | + message("") | ||
| 72 | + message(FATAL_ERROR "Build terminated: Missing required dependency package GenerateEsPackage.") | ||
| 73 | + endif() | ||
| 63 | else() | 74 | else() |
| 64 | find_package(ASC REQUIRED HINTS ${ASCEND_CANN_PACKAGE_PATH}/compiler/tikcpp/ascendc_kernel_cmake) | 75 | find_package(ASC REQUIRED HINTS ${ASCEND_CANN_PACKAGE_PATH}/compiler/tikcpp/ascendc_kernel_cmake) |
| 65 | endif() | 76 | endif() |
| @@ -69,6 +80,7 @@ find_package(securec MODULE) | |||
| 69 | find_package(OPBASE MODULE REQUIRED) | 80 | find_package(OPBASE MODULE REQUIRED) |
| 70 | find_package(platform MODULE REQUIRED) | 81 | find_package(platform MODULE REQUIRED) |
| 71 | find_package(metadef MODULE REQUIRED) | 82 | find_package(metadef MODULE REQUIRED) |
| 83 | +find_package(mmpa MODULE REQUIRED) | ||
| 72 | find_package(runtime MODULE REQUIRED) | 84 | find_package(runtime MODULE REQUIRED) |
| 73 | find_package(nnopbase MODULE REQUIRED) | 85 | find_package(nnopbase MODULE REQUIRED) |
| 74 | find_package(tilingapi MODULE REQUIRED) | 86 | find_package(tilingapi MODULE REQUIRED) |
| @@ -76,4 +88,4 @@ find_package(aicpu MODULE REQUIRED) | |||
| 76 | if(ENABLE_TEST) | 88 | if(ENABLE_TEST) |
| 77 | list(APPEND CMAKE_PREFIX_PATH ${ASCEND_DIR}/tools/tikicpulib/lib/cmake) | 89 | list(APPEND CMAKE_PREFIX_PATH ${ASCEND_DIR}/tools/tikicpulib/lib/cmake) |
| 78 | find_package(tikicpulib REQUIRED) | 90 | find_package(tikicpulib REQUIRED) |
| 79 | -endif() | 91 | +endif() |
| @@ -25,6 +25,76 @@ function(add_modules) | |||
| 25 | endforeach() | 25 | endforeach() |
| 26 | endfunction() | 26 | endfunction() |
| 27 | 27 | ||
| 28 | +# 添加opbase object | ||
| 29 | +function(add_opbase_modules) | ||
| 30 | + if(TARGET opbase_infer_objs OR TARGET opbase_tiling_objs OR TARGET opbase_util_objs) | ||
| 31 | + return() | ||
| 32 | + endif() | ||
| 33 | + file(GLOB_RECURSE OPS_BASE_INFER_SRC | ||
| 34 | + ${OPBASE_SOURCE_PATH}/src/op_common/op_host/infershape_broadcast_util.cpp | ||
| 35 | + ${OPBASE_SOURCE_PATH}/src/op_common/op_host/infershape_elewise_util.cpp | ||
| 36 | + ${OPBASE_SOURCE_PATH}/src/op_common/op_host/infershape_reduce_util.cpp | ||
| 37 | + ) | ||
| 38 | + | ||
| 39 | + file(GLOB_RECURSE OPS_BASE_TILING_SRC | ||
| 40 | + ${OPBASE_SOURCE_PATH}/src/op_common/atvoss/elewise/*.cpp | ||
| 41 | + ${OPBASE_SOURCE_PATH}/src/op_common/atvoss/broadcast/*.cpp | ||
| 42 | + ${OPBASE_SOURCE_PATH}/src/op_common/atvoss/reduce/*.cpp | ||
| 43 | + ${OPBASE_SOURCE_PATH}/src/op_common/op_host/tiling_util.cpp | ||
| 44 | + ) | ||
| 45 | + | ||
| 46 | + file(GLOB_RECURSE OPS_BASE_UTIL_SRC | ||
| 47 | + ${OPBASE_SOURCE_PATH}/src/op_common/op_host/util/*.cpp | ||
| 48 | + ${OPBASE_SOURCE_PATH}/src/op_common/log/*.cpp | ||
| 49 | + ) | ||
| 50 | + | ||
| 51 | + if(OPS_BASE_INFER_SRC) | ||
| 52 | + add_library(opbase_infer_objs OBJECT ${OPS_BASE_INFER_SRC}) | ||
| 53 | + target_include_directories(opbase_infer_objs PRIVATE ${OP_PROTO_INCLUDE}) | ||
| 54 | + target_compile_options(opbase_infer_objs | ||
| 55 | + PRIVATE | ||
| 56 | + $<$<NOT:$<BOOL:${ENABLE_TEST}>>:-DDISABLE_COMPILE_V1> -Dgoogle=ascend_private | ||
| 57 | + -fvisibility=hidden | ||
| 58 | + ) | ||
| 59 | + target_link_libraries( | ||
| 60 | + opbase_infer_objs | ||
| 61 | + PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> | ||
| 62 | + $<BUILD_INTERFACE:dlog_headers> | ||
| 63 | + ) | ||
| 64 | + endif() | ||
| 65 | + | ||
| 66 | + if(OPS_BASE_TILING_SRC) | ||
| 67 | + add_library(opbase_tiling_objs OBJECT ${OPS_BASE_TILING_SRC}) | ||
| 68 | + target_include_directories(opbase_tiling_objs PRIVATE ${OP_TILING_INCLUDE}) | ||
| 69 | + target_compile_options(opbase_tiling_objs | ||
| 70 | + PRIVATE | ||
| 71 | + $<$<NOT:$<BOOL:${ENABLE_TEST}>>:-DDISABLE_COMPILE_V1> -Dgoogle=ascend_private | ||
| 72 | + -fvisibility=hidden -fno-strict-aliasing | ||
| 73 | + ) | ||
| 74 | + target_link_libraries( | ||
| 75 | + opbase_tiling_objs | ||
| 76 | + PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> | ||
| 77 | + $<BUILD_INTERFACE:dlog_headers> | ||
| 78 | + tiling_api | ||
| 79 | + ) | ||
| 80 | + endif() | ||
| 81 | + | ||
| 82 | + if(OPS_BASE_UTIL_SRC) | ||
| 83 | + add_library(opbase_util_objs OBJECT ${OPS_BASE_UTIL_SRC}) | ||
| 84 | + target_include_directories(opbase_util_objs PRIVATE ${OP_TILING_INCLUDE}) | ||
| 85 | + target_compile_options(opbase_util_objs | ||
| 86 | + PRIVATE | ||
| 87 | + $<$<NOT:$<BOOL:${ENABLE_TEST}>>:-DDISABLE_COMPILE_V1> -Dgoogle=ascend_private | ||
| 88 | + -fvisibility=hidden | ||
| 89 | + ) | ||
| 90 | + target_link_libraries( | ||
| 91 | + opbase_util_objs | ||
| 92 | + PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> | ||
| 93 | + $<BUILD_INTERFACE:dlog_headers> | ||
| 94 | + ) | ||
| 95 | + endif() | ||
| 96 | +endfunction() | ||
| 97 | + | ||
| 28 | # 添加infer object | 98 | # 添加infer object |
| 29 | function(add_infer_modules) | 99 | function(add_infer_modules) |
| 30 | if(NOT TARGET ${OPHOST_NAME}_infer_obj) | 100 | if(NOT TARGET ${OPHOST_NAME}_infer_obj) |
| @@ -46,8 +116,8 @@ function(add_infer_modules) | |||
| 46 | ${OPHOST_NAME}_infer_obj | 116 | ${OPHOST_NAME}_infer_obj |
| 47 | PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> | 117 | PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> |
| 48 | $<BUILD_INTERFACE:dlog_headers> | 118 | $<BUILD_INTERFACE:dlog_headers> |
| 49 | - $<$<TARGET_EXISTS:ops_base_util_objs>:$<TARGET_OBJECTS:ops_base_util_objs>> | 119 | + $<$<TARGET_EXISTS:opbase_util_objs>:$<TARGET_OBJECTS:opbase_util_objs>> |
| 50 | - $<$<TARGET_EXISTS:ops_base_infer_objs>:$<TARGET_OBJECTS:ops_base_infer_objs>> | 120 | + $<$<TARGET_EXISTS:opbase_infer_objs>:$<TARGET_OBJECTS:opbase_infer_objs>> |
| 51 | ) | 121 | ) |
| 52 | endif() | 122 | endif() |
| 53 | endfunction() | 123 | endfunction() |
| @@ -81,8 +151,8 @@ function(add_tiling_modules) | |||
| 81 | PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> | 151 | PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> |
| 82 | $<BUILD_INTERFACE:dlog_headers> | 152 | $<BUILD_INTERFACE:dlog_headers> |
| 83 | $<$<TARGET_EXISTS:${COMMON_NAME}_obj>:$<TARGET_OBJECTS:${COMMON_NAME}_obj>> | 153 | $<$<TARGET_EXISTS:${COMMON_NAME}_obj>:$<TARGET_OBJECTS:${COMMON_NAME}_obj>> |
| 84 | - $<$<TARGET_EXISTS:ops_base_util_objs>:$<TARGET_OBJECTS:ops_base_util_objs>> | 154 | + $<$<TARGET_EXISTS:opbase_util_objs>:$<TARGET_OBJECTS:opbase_util_objs>> |
| 85 | - $<$<TARGET_EXISTS:ops_base_tiling_objs>:$<TARGET_OBJECTS:ops_base_tiling_objs>> | 155 | + $<$<TARGET_EXISTS:opbase_tiling_objs>:$<TARGET_OBJECTS:opbase_tiling_objs>> |
| 86 | tiling_api | 156 | tiling_api |
| 87 | ) | 157 | ) |
| 88 | endif() | 158 | endif() |
| @@ -110,6 +180,7 @@ function(add_opapi_modules) | |||
| 110 | ${OPHOST_NAME}_opapi_obj | 180 | ${OPHOST_NAME}_opapi_obj |
| 111 | PUBLIC $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> | 181 | PUBLIC $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> |
| 112 | PRIVATE $<BUILD_INTERFACE:adump_headers> $<BUILD_INTERFACE:dlog_headers> | 182 | PRIVATE $<BUILD_INTERFACE:adump_headers> $<BUILD_INTERFACE:dlog_headers> |
| 183 | + $<$<TARGET_EXISTS:opbase_util_objs>:$<TARGET_OBJECTS:opbase_util_objs>> | ||
| 113 | ) | 184 | ) |
| 114 | endif() | 185 | endif() |
| 115 | endfunction() | 186 | endfunction() |
| @@ -157,7 +228,7 @@ function(add_aicpu_cust_kernel_modules target_name) | |||
| 157 | PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> | 228 | PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> |
| 158 | $<BUILD_INTERFACE:dlog_headers> | 229 | $<BUILD_INTERFACE:dlog_headers> |
| 159 | -Wl,--no-whole-archive | 230 | -Wl,--no-whole-archive |
| 160 | - Eigen3::EigenRas | 231 | + Eigen3::Eigen |
| 161 | ) | 232 | ) |
| 162 | if(NOT PREPROCESS_ONLY) | 233 | if(NOT PREPROCESS_ONLY) |
| 163 | if (NOT ${target_name} IN_LIST AICPU_CUST_OBJ_TARGETS) | 234 | if (NOT ${target_name} IN_LIST AICPU_CUST_OBJ_TARGETS) |
| @@ -190,8 +261,8 @@ function(add_graph_plugin_modules) | |||
| 190 | ${GRAPH_PLUGIN_NAME}_obj | 261 | ${GRAPH_PLUGIN_NAME}_obj |
| 191 | PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> | 262 | PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx17>> |
| 192 | $<BUILD_INTERFACE:dlog_headers> | 263 | $<BUILD_INTERFACE:dlog_headers> |
| 193 | - $<$<TARGET_EXISTS:ops_base_util_objs>:$<TARGET_OBJECTS:ops_base_util_objs>> | 264 | + $<$<TARGET_EXISTS:opbase_util_objs>:$<TARGET_OBJECTS:opbase_util_objs>> |
| 194 | - $<$<TARGET_EXISTS:ops_base_infer_objs>:$<TARGET_OBJECTS:ops_base_infer_objs>> | 265 | + $<$<TARGET_EXISTS:opbase_infer_objs>:$<TARGET_OBJECTS:opbase_infer_objs>> |
| 195 | ) | 266 | ) |
| 196 | endif() | 267 | endif() |
| 197 | endfunction() | 268 | endfunction() |
| @@ -380,6 +451,8 @@ function(add_modules_sources) | |||
| 380 | cmake_parse_arguments(MODULE "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | 451 | cmake_parse_arguments(MODULE "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) |
| 381 | set(SOURCE_DIR ${MODULE_DIR}) | 452 | set(SOURCE_DIR ${MODULE_DIR}) |
| 382 | 453 | ||
| 454 | + add_opbase_modules() | ||
| 455 | + | ||
| 383 | list(LENGTH MODULE_OPTYPE OpTypeLen) | 456 | list(LENGTH MODULE_OPTYPE OpTypeLen) |
| 384 | list(LENGTH MODULE_ACLNN_EXTRA_VERSION AclnnExtraVersionLen) | 457 | list(LENGTH MODULE_ACLNN_EXTRA_VERSION AclnnExtraVersionLen) |
| 385 | if((AclnnExtraVersionLen GREATER 1) AND (OpTypeLen GREATER 1)) | 458 | if((AclnnExtraVersionLen GREATER 1) AND (OpTypeLen GREATER 1)) |
| @@ -635,7 +708,7 @@ function(protobuf_generate_external comp c_var h_var) | |||
| 635 | COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" | 708 | COMMAND ${CMAKE_COMMAND} -E make_directory "${proto_output_path}" |
| 636 | COMMAND ${CMAKE_COMMAND} -E echo "generate proto cpp_out ${comp} by ${abs_file}" | 709 | COMMAND ${CMAKE_COMMAND} -E echo "generate proto cpp_out ${comp} by ${abs_file}" |
| 637 | COMMAND ${Protobuf_PROTOC_EXECUTABLE} -I${file_dir} ${extra_option} --cpp_out=${proto_output_path} ${abs_file} | 710 | COMMAND ${Protobuf_PROTOC_EXECUTABLE} -I${file_dir} ${extra_option} --cpp_out=${proto_output_path} ${abs_file} |
| 638 | - DEPENDS ${abs_file} ascend_protobuf_build_ras json | 711 | + DEPENDS ${abs_file} host_protoc json |
| 639 | COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM) | 712 | COMMENT "Running C++ protocol buffer compiler on ${file}" VERBATIM) |
| 640 | 713 | ||
| 641 | endforeach() | 714 | endforeach() |
| @@ -669,7 +742,7 @@ function(add_onnx_plugin_modules) | |||
| 669 | CXX_STANDARD_REQUIRED ON | 742 | CXX_STANDARD_REQUIRED ON |
| 670 | CXX_EXTENSIONS OFF | 743 | CXX_EXTENSIONS OFF |
| 671 | ) | 744 | ) |
| 672 | - target_include_directories(${ONNX_PLUGIN_NAME}_obj PRIVATE ${OP_PROTO_INCLUDE} ${Protobuf_INCLUDE} ${Protobuf_PATH} ${CMAKE_BINARY_DIR}/proto ${ONNX_PLUGIN_COMMON_INCLUDE} ${JSON_INCLUDE} ${ABSL_SOURCE_DIR}) | 745 | + target_include_directories(${ONNX_PLUGIN_NAME}_obj PRIVATE ${ONNX_PLUGIN_INCLUDE}) |
| 673 | target_compile_definitions(${ONNX_PLUGIN_NAME}_obj PRIVATE OPS_UTILS_LOG_SUB_MOD_NAME="ONNX_PLUGIN" LOG_CPP) | 746 | target_compile_definitions(${ONNX_PLUGIN_NAME}_obj PRIVATE OPS_UTILS_LOG_SUB_MOD_NAME="ONNX_PLUGIN" LOG_CPP) |
| 674 | 747 | ||
| 675 | if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) | 748 | if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) |
| @@ -687,8 +760,9 @@ function(add_onnx_plugin_modules) | |||
| 687 | ${ONNX_PLUGIN_NAME}_obj | 760 | ${ONNX_PLUGIN_NAME}_obj |
| 688 | PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx14>> | 761 | PRIVATE $<BUILD_INTERFACE:$<IF:$<BOOL:${ENABLE_TEST}>,intf_llt_pub_asan_cxx17,intf_pub_cxx14>> |
| 689 | $<BUILD_INTERFACE:dlog_headers> | 762 | $<BUILD_INTERFACE:dlog_headers> |
| 690 | - $<$<TARGET_EXISTS:ops_base_util_objs>:$<TARGET_OBJECTS:ops_base_util_objs>> | 763 | + $<$<TARGET_EXISTS:opbase_util_objs>:$<TARGET_OBJECTS:opbase_util_objs>> |
| 691 | - $<$<TARGET_EXISTS:ops_base_infer_objs>:$<TARGET_OBJECTS:ops_base_infer_objs>> | 764 | + $<$<TARGET_EXISTS:opbase_infer_objs>:$<TARGET_OBJECTS:opbase_infer_objs>> |
| 765 | + ascend_protobuf_static | ||
| 692 | ) | 766 | ) |
| 693 | endif() | 767 | endif() |
| 694 | endfunction() | 768 | endfunction() |
| @@ -1,10 +1,10 @@ | |||
| 1 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | -# This file is a part of the CANN Open Software. | 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). |
| 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 10 | 10 | ||
| @@ -41,32 +41,157 @@ function(kernel_src_copy) | |||
| 41 | DESTINATION ${IMPL_INSTALL_DIR}/${OP_NAME} | 41 | DESTINATION ${IMPL_INSTALL_DIR}/${OP_NAME} |
| 42 | ) | 42 | ) |
| 43 | endif() | 43 | endif() |
| 44 | + else() | ||
| 45 | + add_dependencies(${KNCPY_TARGET} ${OP_NAME}_src_copy) | ||
| 44 | endif() | 46 | endif() |
| 45 | endforeach() | 47 | endforeach() |
| 48 | + | ||
| 49 | + # common install | ||
| 50 | + if(NOT TARGET atvoss_src_copy) | ||
| 51 | + add_custom_target( | ||
| 52 | + atvoss_src_copy | ||
| 53 | + COMMAND | ||
| 54 | + ${CMAKE_COMMAND} -E make_directory ${KNCPY_DST_DIR}/common | ||
| 55 | + COMMAND | ||
| 56 | + bash -c "cp -r ${OPBASE_SOURCE_PATH}/pkg_inc/op_common/atvoss ${KNCPY_DST_DIR}/common" | ||
| 57 | + COMMAND | ||
| 58 | + bash -c "cp -r ${OPBASE_SOURCE_PATH}/include/op_common/op_kernel ${KNCPY_DST_DIR}/common" | ||
| 59 | + VERBATIM | ||
| 60 | + ) | ||
| 61 | + add_dependencies(${KNCPY_TARGET} atvoss_src_copy) | ||
| 62 | + endif() | ||
| 63 | + if(ENABLE_PACKAGE) | ||
| 64 | + install(DIRECTORY ${OPBASE_SOURCE_PATH}/pkg_inc/op_common/atvoss DESTINATION ${IMPL_INSTALL_DIR}/common) | ||
| 65 | + install(DIRECTORY ${OPBASE_SOURCE_PATH}/include/op_common/op_kernel DESTINATION ${IMPL_INSTALL_DIR}/common) | ||
| 66 | + endif() | ||
| 46 | endfunction() | 67 | endfunction() |
| 47 | 68 | ||
| 69 | +function(get_op_type_and_validate OP_DIR compute_unit op_name_var op_type_var is_valid_var) | ||
| 70 | + get_filename_component(op_name "${OP_DIR}" NAME) | ||
| 71 | + set(${op_name_var} "${op_name}" PARENT_SCOPE) | ||
| 72 | + set(cache_key "OP_CACHE_${op_name}_${compute_unit}") | ||
| 73 | + | ||
| 74 | + if(DEFINED ${cache_key}) | ||
| 75 | + set(cached_op_type "${${cache_key}}") | ||
| 76 | + if(cached_op_type) | ||
| 77 | + set(${op_type_var} "${cached_op_type}" PARENT_SCOPE) | ||
| 78 | + set(${is_valid_var} TRUE PARENT_SCOPE) | ||
| 79 | + return() | ||
| 80 | + else() | ||
| 81 | + set(${is_valid_var} FALSE PARENT_SCOPE) | ||
| 82 | + return() | ||
| 83 | + endif() | ||
| 84 | + endif() | ||
| 85 | + | ||
| 86 | + set(op_type "") | ||
| 87 | + set(binary_json ${OP_DIR}/op_host/config/${compute_unit}/${op_name}_binary.json) | ||
| 88 | + | ||
| 89 | + if(NOT EXISTS "${OP_DIR}/op_kernel") | ||
| 90 | + message(STATUS "[INFO] The op_kernel folder does not exist, [${op_name}] not need to compile.") | ||
| 91 | + set(${op_type_var} "" PARENT_SCOPE) | ||
| 92 | + set(${is_valid_var} FALSE PARENT_SCOPE) | ||
| 93 | + return() | ||
| 94 | + endif() | ||
| 95 | + | ||
| 96 | + if(EXISTS ${binary_json}) | ||
| 97 | + get_op_type_from_binary_json("${binary_json}" op_type) | ||
| 98 | + message(STATUS "[INFO] On [${compute_unit}], [${op_name}] compile binary with self config.") | ||
| 99 | + if(NOT op_type) | ||
| 100 | + set(${op_type_var} "" PARENT_SCOPE) | ||
| 101 | + set(${is_valid_var} FALSE PARENT_SCOPE) | ||
| 102 | + return() | ||
| 103 | + endif() | ||
| 104 | + else() | ||
| 105 | + get_op_type_from_op_name("${op_name}" op_type) | ||
| 106 | + if(NOT op_type) | ||
| 107 | + message(STATUS "[INFO] On [${compute_unit}], [${op_name}] not need to compile.") | ||
| 108 | + set(${op_type_var} "" PARENT_SCOPE) | ||
| 109 | + set(${is_valid_var} FALSE PARENT_SCOPE) | ||
| 110 | + return() | ||
| 111 | + endif() | ||
| 112 | + | ||
| 113 | + set(check_op_supported_result FALSE) | ||
| 114 | + check_op_supported("${op_name}" "${compute_unit}" check_op_supported_result) | ||
| 115 | + if(NOT check_op_supported_result) | ||
| 116 | + message(STATUS "[INFO] On [${compute_unit}], [${op_name}] not supported.") | ||
| 117 | + set(${op_type_var} ${op_type} PARENT_SCOPE) | ||
| 118 | + set(${is_valid_var} FALSE PARENT_SCOPE) | ||
| 119 | + return() | ||
| 120 | + endif() | ||
| 121 | + message(STATUS "[INFO] On [${compute_unit}], [${op_name}] compile binary with def config.") | ||
| 122 | + endif() | ||
| 123 | + | ||
| 124 | + set(${op_type_var} "${op_type}" PARENT_SCOPE) | ||
| 125 | + set(${is_valid_var} TRUE PARENT_SCOPE) | ||
| 126 | + set(${cache_key} "${op_type}" CACHE INTERNAL "Cached op_type for ${op_name} on ${compute_unit}") | ||
| 127 | +endfunction() | ||
| 128 | + | ||
| 129 | + | ||
| 48 | ################################################################################################### | 130 | ################################################################################################### |
| 49 | # generate operator dynamic python script for compile, generenate out path ${CMAKE_BINARY_DIR}/tbe, | 131 | # generate operator dynamic python script for compile, generenate out path ${CMAKE_BINARY_DIR}/tbe, |
| 50 | # and install to packages/vendors/${VENDOR_NAME}/op_impl/ai_core/tbe/${VENDOR_NAME}_impl/dynamic | 132 | # and install to packages/vendors/${VENDOR_NAME}/op_impl/ai_core/tbe/${VENDOR_NAME}_impl/dynamic |
| 51 | ################################################################################################### | 133 | ################################################################################################### |
| 52 | function(add_ops_impl_target) | 134 | function(add_ops_impl_target) |
| 53 | - set(oneValueArgs TARGET OPS_INFO_DIR IMPL_DIR OUT_DIR INSTALL_DIR) | 135 | + set(oneValueArgs TARGET OPS_INFO_DIR IMPL_DIR OUT_DIR INSTALL_DIR DEPENDS) |
| 54 | cmake_parse_arguments(OPIMPL "" "${oneValueArgs}" "OPS_BATCH;OPS_ITERATE" ${ARGN}) | 136 | cmake_parse_arguments(OPIMPL "" "${oneValueArgs}" "OPS_BATCH;OPS_ITERATE" ${ARGN}) |
| 55 | 137 | ||
| 138 | + #此处调用ascendc_impl_build.py目的是为了生成experimental算子的py文件 | ||
| 56 | add_custom_command(OUTPUT ${OPIMPL_OUT_DIR}/.impl_timestamp | 139 | add_custom_command(OUTPUT ${OPIMPL_OUT_DIR}/.impl_timestamp |
| 57 | COMMAND mkdir -m 700 -p ${OPIMPL_OUT_DIR}/dynamic | 140 | COMMAND mkdir -m 700 -p ${OPIMPL_OUT_DIR}/dynamic |
| 58 | COMMAND ${ASCEND_PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/util/ascendc_impl_build.py | 141 | COMMAND ${ASCEND_PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/util/ascendc_impl_build.py |
| 59 | - \"\" \"${OPIMPL_OPS_BATCH}\" \"${OPIMPL_OPS_ITERATE}\" | 142 | + \"\" \"${OPIMPL_OPS_BATCH}\" \"${OPIMPL_OPS_ITERATE}\" |
| 60 | - ${OPIMPL_IMPL_DIR} ${OPIMPL_OUT_DIR}/dynamic ${ASCEND_AUTOGEN_PATH} | 143 | + ${OPIMPL_IMPL_DIR} ${OPIMPL_OUT_DIR}/dynamic ${ASCEND_AUTOGEN_PATH} |
| 61 | - --opsinfo-dir ${OPIMPL_OPS_INFO_DIR} ${OPIMPL_OPS_INFO_DIR}/inner ${OPIMPL_OPS_INFO_DIR}/exc | 144 | + --opsinfo-dir ${OPIMPL_OPS_INFO_DIR} ${OPIMPL_OPS_INFO_DIR}/inner ${OPIMPL_OPS_INFO_DIR}/exc |
| 62 | COMMAND rm -rf ${OPIMPL_OUT_DIR}/.impl_timestamp | 145 | COMMAND rm -rf ${OPIMPL_OUT_DIR}/.impl_timestamp |
| 63 | COMMAND touch ${OPIMPL_OUT_DIR}/.impl_timestamp | 146 | COMMAND touch ${OPIMPL_OUT_DIR}/.impl_timestamp |
| 64 | DEPENDS ${CMAKE_SOURCE_DIR}/scripts/util/ascendc_impl_build.py | 147 | DEPENDS ${CMAKE_SOURCE_DIR}/scripts/util/ascendc_impl_build.py |
| 148 | + ${OPIMPL_DEPENDS} | ||
| 65 | ) | 149 | ) |
| 66 | add_custom_target(${OPIMPL_TARGET} ALL | 150 | add_custom_target(${OPIMPL_TARGET} ALL |
| 67 | DEPENDS ${OPIMPL_OUT_DIR}/.impl_timestamp | 151 | DEPENDS ${OPIMPL_OUT_DIR}/.impl_timestamp |
| 68 | ) | 152 | ) |
| 69 | 153 | ||
| 154 | + # 当编译单算子时,PREPROCESS_ONLY=FALSE情况下COMPILED_OP_DIRS是指定算子与被依赖的算子 | ||
| 155 | + if(NOT PREPROCESS_ONLY) | ||
| 156 | + foreach(compute_unit ${ASCEND_COMPUTE_UNIT}) | ||
| 157 | + set(compute_unit_op_cache "${compute_unit}_ALL_COMPUTE_PAIRS") | ||
| 158 | + if(NOT DEFINED ${compute_unit_op_cache}) | ||
| 159 | + set(all_op_pairs) | ||
| 160 | + foreach(OP_DIR ${COMPILED_OP_DIRS}) | ||
| 161 | + get_op_type_and_validate("${OP_DIR}" "${compute_unit}" op_name op_type is_valid) | ||
| 162 | + # 使用modext时会出现校验不支持,但实际上应该解析编译选项的情况,不能用is_valid校验 | ||
| 163 | + if(NOT op_type) | ||
| 164 | + continue() | ||
| 165 | + endif() | ||
| 166 | + | ||
| 167 | + list(APPEND all_op_pairs "${op_type}:${compute_unit}") | ||
| 168 | + endforeach() | ||
| 169 | + set(${compute_unit_op_cache} ${all_op_pairs} CACHE STRING "compute_unit:${compute_unit}") | ||
| 170 | + endif() | ||
| 171 | + | ||
| 172 | + set(cur_op_pairs ${${compute_unit_op_cache}}) | ||
| 173 | + if(ENABLE_EXPERIMENTAL) | ||
| 174 | + add_custom_command(OUTPUT ${OPIMPL_OUT_DIR}/${compute_unit}/.gen_timestamp | ||
| 175 | + COMMAND mkdir -m 700 -p ${OPIMPL_OUT_DIR}/${compute_unit} | ||
| 176 | + COMMAND rm -rf ${OPIMPL_OUT_DIR}/${compute_unit}/.gen_timestamp | ||
| 177 | + COMMAND touch ${OPIMPL_OUT_DIR}/${compute_unit}/.gen_timestamp | ||
| 178 | + DEPENDS merge_ini_${compute_unit} ${OPIMPL_OUT_DIR}/.impl_timestamp | ||
| 179 | + ) | ||
| 180 | + else() | ||
| 181 | + add_custom_command(OUTPUT ${OPIMPL_OUT_DIR}/${compute_unit}/.gen_timestamp | ||
| 182 | + COMMAND mkdir -m 700 -p ${OPIMPL_OUT_DIR}/${compute_unit} | ||
| 183 | + COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/util/gen_compile_option.sh ${cur_op_pairs} | ||
| 184 | + COMMAND rm -rf ${OPIMPL_OUT_DIR}/${compute_unit}/.gen_timestamp | ||
| 185 | + COMMAND touch ${OPIMPL_OUT_DIR}/${compute_unit}/.gen_timestamp | ||
| 186 | + DEPENDS merge_ini_${compute_unit} ${OPIMPL_OUT_DIR}/.impl_timestamp | ||
| 187 | + ) | ||
| 188 | + endif() | ||
| 189 | + add_custom_target(gen_compile_options_${compute_unit} ALL | ||
| 190 | + DEPENDS ${OPIMPL_OUT_DIR}/.impl_timestamp ${OPIMPL_OUT_DIR}/${compute_unit}/.gen_timestamp) | ||
| 191 | + add_dependencies(${OPIMPL_TARGET} gen_compile_options_${compute_unit}) | ||
| 192 | + endforeach() | ||
| 193 | + endif() | ||
| 194 | + | ||
| 70 | file(GLOB dynamic_impl ${OPIMPL_OUT_DIR}/dynamic/*.py) | 195 | file(GLOB dynamic_impl ${OPIMPL_OUT_DIR}/dynamic/*.py) |
| 71 | if(ENABLE_PACKAGE) | 196 | if(ENABLE_PACKAGE) |
| 72 | install( | 197 | install( |
| @@ -132,11 +257,22 @@ endfunction() | |||
| 132 | # srcpath: ${ASCEND_AUTOGEN_PATH} | 257 | # srcpath: ${ASCEND_AUTOGEN_PATH} |
| 133 | # generate outpath: ${CMAKE_BINARY_DIR}/tbe/graph | 258 | # generate outpath: ${CMAKE_BINARY_DIR}/tbe/graph |
| 134 | # ################################################################################################## | 259 | # ################################################################################################## |
| 260 | +function(has_graph_proto_sources OUT_VAR) | ||
| 261 | + get_target_property(proto_headers ${GRAPH_PLUGIN_NAME}_proto_headers INTERFACE_SOURCES) | ||
| 262 | + if(proto_headers AND NOT proto_headers MATCHES "-NOTFOUND$") | ||
| 263 | + set(${OUT_VAR} TRUE PARENT_SCOPE) | ||
| 264 | + else() | ||
| 265 | + set(${OUT_VAR} FALSE PARENT_SCOPE) | ||
| 266 | + endif() | ||
| 267 | +endfunction() | ||
| 268 | + | ||
| 135 | function(merge_graph_headers) | 269 | function(merge_graph_headers) |
| 136 | set(oneValueArgs TARGET OUT_DIR) | 270 | set(oneValueArgs TARGET OUT_DIR) |
| 137 | cmake_parse_arguments(MGPROTO "" "${oneValueArgs}" "" ${ARGN}) | 271 | cmake_parse_arguments(MGPROTO "" "${oneValueArgs}" "" ${ARGN}) |
| 138 | get_target_property(proto_headers ${GRAPH_PLUGIN_NAME}_proto_headers INTERFACE_SOURCES) | 272 | get_target_property(proto_headers ${GRAPH_PLUGIN_NAME}_proto_headers INTERFACE_SOURCES) |
| 139 | - set(proto_headers ${proto_headers} ${CMAKE_SOURCE_DIR}/common/inc/op_graph/op_ras_proto_extend.h) | 273 | + if(NOT proto_headers OR proto_headers MATCHES "-NOTFOUND$") |
| 274 | + message(FATAL_ERROR "merge_graph_headers requires at least one RAS op_graph proto header") | ||
| 275 | + endif() | ||
| 140 | add_custom_command(OUTPUT ${MGPROTO_OUT_DIR}/ops_proto_ras.h | 276 | add_custom_command(OUTPUT ${MGPROTO_OUT_DIR}/ops_proto_ras.h |
| 141 | COMMAND ${ASCEND_PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/util/merge_proto.py | 277 | COMMAND ${ASCEND_PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/util/merge_proto.py |
| 142 | ${proto_headers} | 278 | ${proto_headers} |
| @@ -148,7 +284,7 @@ function(merge_graph_headers) | |||
| 148 | ${MGPROTO_OUT_DIR}/ops_proto_ras.h | 284 | ${MGPROTO_OUT_DIR}/ops_proto_ras.h |
| 149 | ${MGPROTO_OUT_DIR}/ops_proto_ras.cpp | 285 | ${MGPROTO_OUT_DIR}/ops_proto_ras.cpp |
| 150 | DEPENDS ${MGPROTO_OUT_DIR}/ops_proto_ras.h | 286 | DEPENDS ${MGPROTO_OUT_DIR}/ops_proto_ras.h |
| 151 | - ) | 287 | + ) |
| 152 | add_custom_target(${MGPROTO_TARGET} ALL | 288 | add_custom_target(${MGPROTO_TARGET} ALL |
| 153 | DEPENDS ${MGPROTO_OUT_DIR}/ops_proto_ras.h ${MGPROTO_OUT_DIR}/ops_proto_ras.cpp | 289 | DEPENDS ${MGPROTO_OUT_DIR}/ops_proto_ras.h ${MGPROTO_OUT_DIR}/ops_proto_ras.cpp |
| 154 | ) | 290 | ) |
| @@ -255,7 +391,7 @@ function(prepare_compile_from_config) | |||
| 255 | COMMAND ${_ASCENDC_ENV_VAR} bash ${OPS_KERNEL_BINARY_SCRIPT}/build_binary_opc.sh | 391 | COMMAND ${_ASCENDC_ENV_VAR} bash ${OPS_KERNEL_BINARY_SCRIPT}/build_binary_opc.sh |
| 256 | ${CONFCMP_OP_TYPE} | 392 | ${CONFCMP_OP_TYPE} |
| 257 | ${CONFCMP_COMPUTE_UNIT} | 393 | ${CONFCMP_COMPUTE_UNIT} |
| 258 | - ${CONFCMP_OUT_DIR}/bin ${CMAKE_BUILD_TYPE} ${ENABLE_OOM} | 394 | + ${CONFCMP_OUT_DIR}/bin ${CMAKE_BUILD_TYPE} ${ENABLE_OOM} ${ENABLE_DUMP_CCE} ${ENABLE_MSSANITIZER} bisheng_flags=${BISHENG_FLAGS} "kernel_template_input=\"${KERNEL_TEMPLATE_INPUT}\"" |
| 259 | WORKING_DIRECTORY ${OPS_KERNEL_BINARY_SCRIPT} | 395 | WORKING_DIRECTORY ${OPS_KERNEL_BINARY_SCRIPT} |
| 260 | DEPENDS ${ASCEND_KERNEL_CONF_DST}/aic-${CONFCMP_COMPUTE_UNIT}-ops-info.ini | 396 | DEPENDS ${ASCEND_KERNEL_CONF_DST}/aic-${CONFCMP_COMPUTE_UNIT}-ops-info.ini |
| 261 | ascendc_kernel_src_copy | 397 | ascendc_kernel_src_copy |
| @@ -279,11 +415,11 @@ function(prepare_compile_from_config) | |||
| 279 | set(subDir "") | 415 | set(subDir "") |
| 280 | endif() | 416 | endif() |
| 281 | install(DIRECTORY ${CONFCMP_OUT_DIR}/bin/${CONFCMP_COMPUTE_UNIT}/${CONFCMP_OP_NAME} | 417 | install(DIRECTORY ${CONFCMP_OUT_DIR}/bin/${CONFCMP_COMPUTE_UNIT}/${CONFCMP_OP_NAME} |
| 282 | - DESTINATION ${BIN_KERNEL_INSTALL_DIR}/${CONFCMP_COMPUTE_UNIT}/${subDir} OPTIONAL | 418 | + DESTINATION ${BIN_KERNEL_INSTALL_DIR}/${CONFCMP_COMPUTE_UNIT}/${subDir} OPTIONAL FILE_PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE |
| 283 | ) | 419 | ) |
| 284 | file(GLOB CONFCMP_OP_NAME_JSON ${CONFCMP_OUT_DIR}/bin/config/${CONFCMP_COMPUTE_UNIT}/${CONFCMP_OP_NAME}*.json) | 420 | file(GLOB CONFCMP_OP_NAME_JSON ${CONFCMP_OUT_DIR}/bin/config/${CONFCMP_COMPUTE_UNIT}/${CONFCMP_OP_NAME}*.json) |
| 285 | install(FILES ${CONFCMP_OP_NAME_JSON} | 421 | install(FILES ${CONFCMP_OP_NAME_JSON} |
| 286 | - DESTINATION ${BIN_KERNEL_CONFIG_INSTALL_DIR}/${CONFCMP_COMPUTE_UNIT}/${subDir} OPTIONAL | 422 | + DESTINATION ${BIN_KERNEL_CONFIG_INSTALL_DIR}/${CONFCMP_COMPUTE_UNIT}/${subDir} OPTIONAL PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE |
| 287 | ) | 423 | ) |
| 288 | endif() | 424 | endif() |
| 289 | endfunction() | 425 | endfunction() |
| @@ -296,7 +432,6 @@ endfunction() | |||
| 296 | function(compile_from_config) | 432 | function(compile_from_config) |
| 297 | set(oneValueArgs TARGET OUT_DIR INSTALL_DIR COMPUTE_UNIT) | 433 | set(oneValueArgs TARGET OUT_DIR INSTALL_DIR COMPUTE_UNIT) |
| 298 | cmake_parse_arguments(CONFCMP "" "${oneValueArgs}" "" ${ARGN}) | 434 | cmake_parse_arguments(CONFCMP "" "${oneValueArgs}" "" ${ARGN}) |
| 299 | - message(STATUS "start to compile unit: ${CONFCMP_COMPUTE_UNIT}") | ||
| 300 | set(_ASCENDC_ENV_VAR) | 435 | set(_ASCENDC_ENV_VAR) |
| 301 | list(APPEND _ASCENDC_ENV_VAR export HI_PYTHON=${ASCEND_PYTHON_EXECUTABLE} &&) | 436 | list(APPEND _ASCENDC_ENV_VAR export HI_PYTHON=${ASCEND_PYTHON_EXECUTABLE} &&) |
| 302 | if(CCACHE_PROGRAM) | 437 | if(CCACHE_PROGRAM) |
| @@ -317,7 +452,8 @@ function(compile_from_config) | |||
| 317 | set(_BUILD_COMMAND) | 452 | set(_BUILD_COMMAND) |
| 318 | List(APPEND _BUILD_COMMAND export TILINGKEY_PAR_COMPILE=1 &&) | 453 | List(APPEND _BUILD_COMMAND export TILINGKEY_PAR_COMPILE=1 &&) |
| 319 | List(APPEND _BUILD_COMMAND export BIN_FILENAME_HASHED=1 &&) | 454 | List(APPEND _BUILD_COMMAND export BIN_FILENAME_HASHED=1 &&) |
| 320 | - List(APPEND _BUILD_COMMAND ${_ASCENDC_ENV_VAR} bash ${OPS_KERNEL_BINARY_SCRIPT}/build_binary_op_exe.sh ${CONFCMP_OUT_DIR}/bin ${idx}) | 455 | + List(APPEND _BUILD_COMMAND export ASCEND_SLOG_PRINT_TO_STDOUT=1 &&) |
| 456 | + List(APPEND _BUILD_COMMAND ${_ASCENDC_ENV_VAR} stdbuf -oL bash ${OPS_KERNEL_BINARY_SCRIPT}/build_binary_op_exe_task.sh ${CONFCMP_OUT_DIR}/bin ${idx}) | ||
| 321 | List(APPEND _BUILD_COMMAND && echo $(MAKE)) | 457 | List(APPEND _BUILD_COMMAND && echo $(MAKE)) |
| 322 | add_custom_target(exe_compile_${CONFCMP_COMPUTE_UNIT}_${idx} | 458 | add_custom_target(exe_compile_${CONFCMP_COMPUTE_UNIT}_${idx} |
| 323 | COMMAND ${_BUILD_COMMAND} | 459 | COMMAND ${_BUILD_COMMAND} |
| @@ -371,32 +507,11 @@ function(gen_binary_info_config_json) | |||
| 371 | endif() | 507 | endif() |
| 372 | endfunction() | 508 | endfunction() |
| 373 | 509 | ||
| 374 | -# ###################################################################################################################### | ||
| 375 | -# get op_type from *_def.cpp | ||
| 376 | -# ###################################################################################################################### | ||
| 377 | -function(get_op_type_from_op_name OP_NAME OP_TYPE) | ||
| 378 | - execute_process( | ||
| 379 | - COMMAND | ||
| 380 | - find ${CMAKE_CURRENT_SOURCE_DIR} -name ${OP_NAME}_def.cpp -exec grep OP_ADD {} \; | ||
| 381 | - OUTPUT_VARIABLE op_type | ||
| 382 | - ) | ||
| 383 | - if(NOT op_type) | ||
| 384 | - set(op_type "") | ||
| 385 | - else() | ||
| 386 | - string(REGEX REPLACE "[\t ]*OP_ADD\\([\t ]*" "" op_type ${op_type}) | ||
| 387 | - string(REGEX REPLACE "[\t ]*\\).*$" "" op_type ${op_type}) | ||
| 388 | - endif() | ||
| 389 | - set(${OP_TYPE} | ||
| 390 | - ${op_type} | ||
| 391 | - PARENT_SCOPE | ||
| 392 | - ) | ||
| 393 | -endfunction() | ||
| 394 | - | ||
| 395 | # ###################################################################################################################### | 510 | # ###################################################################################################################### |
| 396 | # check op_type is or not support in compute_unit | 511 | # check op_type is or not support in compute_unit |
| 397 | # ###################################################################################################################### | 512 | # ###################################################################################################################### |
| 398 | function(check_op_supported OP_NAME COMPUTE_UNIT OP_SUPPORTED_COMPUTE_UNIT) | 513 | function(check_op_supported OP_NAME COMPUTE_UNIT OP_SUPPORTED_COMPUTE_UNIT) |
| 399 | - set(cmd "find ${CMAKE_CURRENT_SOURCE_DIR} -name ${OP_NAME}_def.cpp -exec grep '\.AddConfig(\\s*\"${COMPUTE_UNIT}\"' {} \;") | 514 | + set(cmd "find ${OP_DIR} -name ${OP_NAME}_def.cpp -exec grep '\.AddConfig(\\s*\"${COMPUTE_UNIT}\"' {} \;") |
| 400 | execute_process( | 515 | execute_process( |
| 401 | COMMAND bash -c "${cmd}" | 516 | COMMAND bash -c "${cmd}" |
| 402 | OUTPUT_VARIABLE op_supported_compute_unit | 517 | OUTPUT_VARIABLE op_supported_compute_unit |
| @@ -415,10 +530,6 @@ endfunction() | |||
| 415 | # binary compile | 530 | # binary compile |
| 416 | function(gen_ops_info_and_python) | 531 | function(gen_ops_info_and_python) |
| 417 | gen_aclnn_with_opdef() | 532 | gen_aclnn_with_opdef() |
| 418 | - if(NOT TARGET opbuild_custom_gen_aclnn_all) | ||
| 419 | - message(STATUS "no need build binary, for all the ops donot have any operator def") | ||
| 420 | - return() | ||
| 421 | - endif() | ||
| 422 | 533 | ||
| 423 | kernel_src_copy( | 534 | kernel_src_copy( |
| 424 | TARGET ascendc_kernel_src_copy | 535 | TARGET ascendc_kernel_src_copy |
| @@ -432,39 +543,35 @@ function(gen_ops_info_and_python) | |||
| 432 | endif() | 543 | endif() |
| 433 | 544 | ||
| 434 | add_custom_target(common_copy | 545 | add_custom_target(common_copy |
| 435 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/tbe/ascendc/common/act | ||
| 436 | - COMMAND cp -r ${PROJECT_SOURCE_DIR}/common/act/* ${CMAKE_BINARY_DIR}/tbe/ascendc/common/act | ||
| 437 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/tbe/ascendc/common/cmct | ||
| 438 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/tbe/ascendc/inc | 546 | COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/tbe/ascendc/inc |
| 439 | COMMAND cp -r ${PROJECT_SOURCE_DIR}/common/inc/op_kernel/* ${CMAKE_BINARY_DIR}/tbe/ascendc/inc | 547 | COMMAND cp -r ${PROJECT_SOURCE_DIR}/common/inc/op_kernel/* ${CMAKE_BINARY_DIR}/tbe/ascendc/inc |
| 440 | ) | 548 | ) |
| 441 | 549 | ||
| 442 | if(ENABLE_PACKAGE) | 550 | if(ENABLE_PACKAGE) |
| 443 | - install( | ||
| 444 | - DIRECTORY ${CMAKE_BINARY_DIR}/tbe/ascendc/common/act/ | ||
| 445 | - DESTINATION ${IMPL_INSTALL_DIR}/common/act | ||
| 446 | - ) | ||
| 447 | - install( | ||
| 448 | - DIRECTORY ${CMAKE_BINARY_DIR}/tbe/ascendc/common/cmct/ | ||
| 449 | - DESTINATION ${IMPL_INSTALL_DIR}/common/cmct | ||
| 450 | - ) | ||
| 451 | install( | 551 | install( |
| 452 | DIRECTORY ${CMAKE_BINARY_DIR}/tbe/ascendc/inc/ | 552 | DIRECTORY ${CMAKE_BINARY_DIR}/tbe/ascendc/inc/ |
| 453 | DESTINATION ${IMPL_INSTALL_DIR}/inc | 553 | DESTINATION ${IMPL_INSTALL_DIR}/inc |
| 454 | ) | 554 | ) |
| 455 | endif() | 555 | endif() |
| 456 | 556 | ||
| 457 | - add_ops_impl_target( | 557 | + string(JOIN "/" simplified_key_str ${simplified_key_list}) |
| 458 | - TARGET ascendc_impl_gen | 558 | + string(JOIN "/" impl_mode_str ${impl_mode_list}) |
| 459 | - OPS_INFO_DIR ${ASCEND_AUTOGEN_PATH} | 559 | + string(JOIN "/" auto_sync_str ${auto_sync_list}) |
| 460 | - IMPL_DIR ${ASCEND_KERNEL_SRC_DST} | 560 | + string(JOIN "/" options_str ${option_list}) |
| 461 | - OUT_DIR ${CMAKE_BINARY_DIR}/tbe | 561 | + if(NOT auto_sync_str) |
| 462 | - INSTALL_DIR ${IMPL_DYNAMIC_INSTALL_DIR} | 562 | + set(auto_sync_str "auto_sync") |
| 563 | + endif() | ||
| 564 | + if(NOT options_str) | ||
| 565 | + set(options_str "options") | ||
| 566 | + endif() | ||
| 567 | + | ||
| 568 | + add_custom_target(gen_kernel_options | ||
| 569 | + COMMAND ${ASCEND_PYTHON_EXECUTABLE} ${OPS_KERNEL_BINARY_SCRIPT}/gen_ops_compile_ini.py ${CMAKE_BINARY_DIR}/tbe/config | ||
| 570 | + ${simplified_key_str} ${impl_mode_str} ${auto_sync_str} ${options_str} | ||
| 463 | ) | 571 | ) |
| 464 | 572 | ||
| 465 | - set(ascendc_impl_gen_depends ascendc_kernel_src_copy opbuild_custom_gen_aclnn_all common_copy) | 573 | + set(ascendc_impl_gen_depends ascendc_kernel_src_copy common_copy gen_kernel_options) |
| 466 | foreach(compute_unit ${ASCEND_ALL_COMPUTE_UNIT}) | 574 | foreach(compute_unit ${ASCEND_ALL_COMPUTE_UNIT}) |
| 467 | - message(STATUS "compute_unit=${compute_unit}") | ||
| 468 | # generate aic-${compute_unit}-ops-info.json, operator infos | 575 | # generate aic-${compute_unit}-ops-info.json, operator infos |
| 469 | if(ENABLE_CUSTOM) | 576 | if(ENABLE_CUSTOM) |
| 470 | set(ops_info_suffix "ops-info.json") | 577 | set(ops_info_suffix "ops-info.json") |
| @@ -486,31 +593,25 @@ function(gen_ops_info_and_python) | |||
| 486 | ) | 593 | ) |
| 487 | list(APPEND ascendc_impl_gen_depends ops_info_gen_${compute_unit}) | 594 | list(APPEND ascendc_impl_gen_depends ops_info_gen_${compute_unit}) |
| 488 | endforeach() | 595 | endforeach() |
| 596 | + | ||
| 597 | + add_ops_impl_target( | ||
| 598 | + TARGET ascendc_impl_gen | ||
| 599 | + OPS_INFO_DIR ${ASCEND_AUTOGEN_PATH} | ||
| 600 | + IMPL_DIR ${ASCEND_KERNEL_SRC_DST} | ||
| 601 | + OUT_DIR ${CMAKE_BINARY_DIR}/tbe | ||
| 602 | + INSTALL_DIR ${IMPL_DYNAMIC_INSTALL_DIR} | ||
| 603 | + DEPENDS ${ascendc_impl_gen_depends} | ||
| 604 | + ) | ||
| 489 | add_dependencies(ascendc_impl_gen ${ascendc_impl_gen_depends}) | 605 | add_dependencies(ascendc_impl_gen ${ascendc_impl_gen_depends}) |
| 490 | 606 | ||
| 491 | if(ENABLE_BINARY OR ENABLE_CUSTOM) | 607 | if(ENABLE_BINARY OR ENABLE_CUSTOM) |
| 492 | foreach(compute_unit ${ASCEND_COMPUTE_UNIT}) | 608 | foreach(compute_unit ${ASCEND_COMPUTE_UNIT}) |
| 493 | set(HAS_OP_COMPILE_OF_COMPUTE_UNIT FALSE) | 609 | set(HAS_OP_COMPILE_OF_COMPUTE_UNIT FALSE) |
| 494 | foreach(OP_DIR ${COMPILED_OP_DIRS}) | 610 | foreach(OP_DIR ${COMPILED_OP_DIRS}) |
| 495 | - get_filename_component(op_name ${OP_DIR} NAME) | 611 | + get_op_type_and_validate("${OP_DIR}" "${compute_unit}" op_name op_type is_valid) |
| 496 | - set(op_type) | ||
| 497 | set(binary_json ${OP_DIR}/op_host/config/${compute_unit}/${op_name}_binary.json) | 612 | set(binary_json ${OP_DIR}/op_host/config/${compute_unit}/${op_name}_binary.json) |
| 498 | - if(EXISTS ${binary_json}) | 613 | + if(NOT is_valid) |
| 499 | - get_op_type_from_binary_json("${binary_json}" op_type) | 614 | + continue() |
| 500 | - message(STATUS "[INFO] On [${compute_unit}], [${op_name}] compile binary with self config.") | ||
| 501 | - else() | ||
| 502 | - get_op_type_from_op_name("${op_name}" op_type) | ||
| 503 | - if(NOT op_type) | ||
| 504 | - message(STATUS "[INFO] On [${compute_unit}], [${op_name}] not need to compile.") | ||
| 505 | - continue() | ||
| 506 | - endif() | ||
| 507 | - | ||
| 508 | - set(check_op_supported_result) | ||
| 509 | - check_op_supported("${op_name}" "${compute_unit}" check_op_supported_result) | ||
| 510 | - if(NOT check_op_supported_result) | ||
| 511 | - message(STATUS "[INFO] On [${compute_unit}], [${op_name}] not supported.") | ||
| 512 | - continue() | ||
| 513 | - endif() | ||
| 514 | endif() | 615 | endif() |
| 515 | 616 | ||
| 516 | list(FIND ASCEND_OP_NAME ${op_name} INDEX) | 617 | list(FIND ASCEND_OP_NAME ${op_name} INDEX) |
| @@ -546,7 +647,7 @@ function(gen_ops_info_and_python) | |||
| 546 | COMPUTE_UNIT ${compute_unit} | 647 | COMPUTE_UNIT ${compute_unit} |
| 547 | ) | 648 | ) |
| 548 | 649 | ||
| 549 | - add_dependencies(ascendc_bin_${compute_unit}_${op_name} merge_ini_${compute_unit} ascendc_impl_gen gen_bin_scripts) | 650 | + add_dependencies(ascendc_bin_${compute_unit}_${op_name} gen_compile_options_${compute_unit} ascendc_impl_gen gen_bin_scripts) |
| 550 | endforeach() | 651 | endforeach() |
| 551 | 652 | ||
| 552 | # binary compile from binary json config | 653 | # binary compile from binary json config |
| @@ -574,4 +675,4 @@ function(gen_ops_info_and_python) | |||
| 574 | COMMENT "Executing cleanup: ${LOCK_CLEANUP_CMD}") | 675 | COMMENT "Executing cleanup: ${LOCK_CLEANUP_CMD}") |
| 575 | endforeach() | 676 | endforeach() |
| 576 | endif() | 677 | endif() |
| 577 | -endfunction() | 678 | +endfunction() |
| @@ -1,10 +1,10 @@ | |||
| 1 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | -# This file is a part of the CANN Open Software. | 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). |
| 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 10 | # intf_pub for c++11 | 10 | # intf_pub for c++11 |
| @@ -63,6 +63,7 @@ if(NOT TARGET intf_pub_cxx14) | |||
| 63 | -Wl,-z,relro | 63 | -Wl,-z,relro |
| 64 | -Wl,-z,now | 64 | -Wl,-z,now |
| 65 | -Wl,-z,noexecstack | 65 | -Wl,-z,noexecstack |
| 66 | + $<$<CONFIG:Release>:-s> | ||
| 66 | $<$<CONFIG:Release>:-Wl,--build-id=none> | 67 | $<$<CONFIG:Release>:-Wl,--build-id=none> |
| 67 | $<$<BOOL:${ENABLE_ASAN}>:-fsanitize=address -fsanitize=leak -fsanitize-recover=address> | 68 | $<$<BOOL:${ENABLE_ASAN}>:-fsanitize=address -fsanitize=leak -fsanitize-recover=address> |
| 68 | $<$<BOOL:${ENABLE_COVERAGE}>:-fprofile-arcs -ftest-coverage> | 69 | $<$<BOOL:${ENABLE_COVERAGE}>:-fprofile-arcs -ftest-coverage> |
| @@ -96,6 +97,7 @@ if(NOT TARGET intf_pub_cxx17) | |||
| 96 | -Wl,-z,relro | 97 | -Wl,-z,relro |
| 97 | -Wl,-z,now | 98 | -Wl,-z,now |
| 98 | -Wl,-z,noexecstack | 99 | -Wl,-z,noexecstack |
| 100 | + $<$<CONFIG:Release>:-s> | ||
| 99 | $<$<CONFIG:Release>:-Wl,--build-id=none> | 101 | $<$<CONFIG:Release>:-Wl,--build-id=none> |
| 100 | $<$<BOOL:${ENABLE_ASAN}>:-fsanitize=address -fsanitize=leak -fsanitize-recover=address> | 102 | $<$<BOOL:${ENABLE_ASAN}>:-fsanitize=address -fsanitize=leak -fsanitize-recover=address> |
| 101 | $<$<BOOL:${ENABLE_COVERAGE}>:-fprofile-arcs -ftest-coverage> | 103 | $<$<BOOL:${ENABLE_COVERAGE}>:-fprofile-arcs -ftest-coverage> |
| @@ -1,10 +1,10 @@ | |||
| 1 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | -# This file is a part of the CANN Open Software. | 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). |
| 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 10 | if(TARGET intf_llt_pub) | 10 | if(TARGET intf_llt_pub) |
| @@ -1,108 +0,0 @@ | |||
| 1 | -# ---------------------------------------------------------------------------- | ||
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | -# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 4 | -# This file is a part of the CANN Open Software. | ||
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | -# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | -# ---------------------------------------------------------------------------- | ||
| 10 | -# makeself.cmake - 自定义 makeself 打包脚本 | ||
| 11 | - | ||
| 12 | -# 设置 makeself 路径 | ||
| 13 | -set(MAKESELF_EXE ${CPACK_MAKESELF_PATH}/makeself.sh) | ||
| 14 | -set(MAKESELF_HEADER_EXE ${CPACK_MAKESELF_PATH}/makeself-header.sh) | ||
| 15 | -if(NOT MAKESELF_EXE) | ||
| 16 | - message(FATAL_ERROR "makeself not found!") | ||
| 17 | -endif() | ||
| 18 | - | ||
| 19 | -# 创建临时安装目录 | ||
| 20 | -set(STAGING_DIR "${CPACK_CMAKE_BINARY_DIR}/_CPack_Packages/makeself_staging") | ||
| 21 | -# 先删除再创建 | ||
| 22 | -file(REMOVE_RECURSE "${STAGING_DIR}") | ||
| 23 | -file(MAKE_DIRECTORY "${STAGING_DIR}") | ||
| 24 | - | ||
| 25 | -# 执行安装到临时目录 | ||
| 26 | -execute_process( | ||
| 27 | - COMMAND "${CMAKE_COMMAND}" --install "${CPACK_CMAKE_BINARY_DIR}" --prefix "${STAGING_DIR}" | ||
| 28 | - RESULT_VARIABLE INSTALL_RESULT | ||
| 29 | -) | ||
| 30 | - | ||
| 31 | -if(NOT INSTALL_RESULT EQUAL 0) | ||
| 32 | - message(FATAL_ERROR "Installation to staging directory failed: ${INSTALL_RESULT}") | ||
| 33 | -endif() | ||
| 34 | - | ||
| 35 | -# 生成安装配置文件 | ||
| 36 | -set(CSV_OUTPUT ${CPACK_CMAKE_BINARY_DIR}/filelist.csv) | ||
| 37 | -execute_process( | ||
| 38 | - COMMAND python3 ${CPACK_CMAKE_SOURCE_DIR}/scripts/package/package.py --pkg_name ops_ras --chip_name ${CPACK_SOC} --os_arch linux-${CPACK_ARCH} | ||
| 39 | - WORKING_DIRECTORY ${CPACK_CMAKE_BINARY_DIR} | ||
| 40 | - OUTPUT_VARIABLE result | ||
| 41 | - ERROR_VARIABLE error | ||
| 42 | - RESULT_VARIABLE code | ||
| 43 | - OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| 44 | -) | ||
| 45 | -message(STATUS "package.py result: ${code}") | ||
| 46 | -if (NOT code EQUAL 0) | ||
| 47 | - message(FATAL_ERROR "Filelist generation failed: ${result}") | ||
| 48 | -else () | ||
| 49 | - message(STATUS "Filelist generated successfully: ${result}") | ||
| 50 | - | ||
| 51 | - if (NOT EXISTS ${CSV_OUTPUT}) | ||
| 52 | - message(FATAL_ERROR "Output file not created: ${CSV_OUTPUT}") | ||
| 53 | - endif () | ||
| 54 | -endif () | ||
| 55 | -set(SCENE_OUT_PUT | ||
| 56 | - ${CPACK_CMAKE_BINARY_DIR}/scene.info | ||
| 57 | -) | ||
| 58 | -set(NN_VERSION_OUT_PUT | ||
| 59 | - ${CPACK_CMAKE_BINARY_DIR}/ops_ras_version.h | ||
| 60 | -) | ||
| 61 | - | ||
| 62 | -configure_file( | ||
| 63 | - ${SCENE_OUT_PUT} | ||
| 64 | - ${STAGING_DIR}/share/info/ops_ras/ | ||
| 65 | - COPYONLY | ||
| 66 | -) | ||
| 67 | -configure_file( | ||
| 68 | - ${CSV_OUTPUT} | ||
| 69 | - ${STAGING_DIR}/share/info/ops_ras/script/ | ||
| 70 | - COPYONLY | ||
| 71 | -) | ||
| 72 | -configure_file( | ||
| 73 | - ${NN_VERSION_OUT_PUT} | ||
| 74 | - ${STAGING_DIR}/share/info/ops_ras/ | ||
| 75 | - COPYONLY | ||
| 76 | -) | ||
| 77 | -# makeself打包 | ||
| 78 | -file(STRINGS ${CPACK_CMAKE_BINARY_DIR}/makeself.txt script_output) | ||
| 79 | -string(REPLACE " " ";" makeself_param_string "${script_output}") | ||
| 80 | -string(REGEX MATCH "cann.*\\.run" package_name "${makeself_param_string}") | ||
| 81 | - | ||
| 82 | -list(LENGTH makeself_param_string LIST_LENGTH) | ||
| 83 | -math(EXPR INSERT_INDEX "${LIST_LENGTH} - 2") | ||
| 84 | -list(INSERT makeself_param_string ${INSERT_INDEX} "${STAGING_DIR}") | ||
| 85 | - | ||
| 86 | -message(STATUS "script output: ${script_output}") | ||
| 87 | -message(STATUS "makeself: ${makeself_param_string}") | ||
| 88 | -message(STATUS "package: ${package_name}") | ||
| 89 | - | ||
| 90 | -execute_process(COMMAND bash ${MAKESELF_EXE} | ||
| 91 | - --header ${MAKESELF_HEADER_EXE} | ||
| 92 | - --help-header share/info/ops_ras/script/help.info | ||
| 93 | - ${makeself_param_string} share/info/ops_ras/script/install.sh | ||
| 94 | - WORKING_DIRECTORY ${STAGING_DIR} | ||
| 95 | - RESULT_VARIABLE EXEC_RESULT | ||
| 96 | - ERROR_VARIABLE EXEC_ERROR | ||
| 97 | -) | ||
| 98 | - | ||
| 99 | -if(NOT EXEC_RESULT EQUAL 0) | ||
| 100 | - message(FATAL_ERROR "makeself packaging failed: ${EXEC_ERROR}") | ||
| 101 | -endif() | ||
| 102 | - | ||
| 103 | -execute_process( | ||
| 104 | - COMMAND mkdir -p ${CPACK_PACKAGE_DIRECTORY} | ||
| 105 | - COMMAND mv ${STAGING_DIR}/${package_name} ${CPACK_PACKAGE_DIRECTORY}/ | ||
| 106 | - COMMAND echo "build pkg success: ${CPACK_PACKAGE_DIRECTORY}/${package_name}" | ||
| 107 | - WORKING_DIRECTORY ${STAGING_DIR} | ||
| 108 | -) | ||
| @@ -1,49 +0,0 @@ | |||
| 1 | -# ---------------------------------------------------------------------------- | ||
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | -# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 4 | -# This file is a part of the CANN Open Software. | ||
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | -# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | -# ---------------------------------------------------------------------------- | ||
| 10 | -# makeself.cmake - 自定义 makeself 打包脚本 | ||
| 11 | - | ||
| 12 | -# 设置 makeself 路径 | ||
| 13 | -set(MAKESELF_EXE ${CPACK_MAKESELF_PATH}/makeself.sh) | ||
| 14 | -set(MAKESELF_HEADER_EXE ${CPACK_MAKESELF_PATH}/makeself-header.sh) | ||
| 15 | -if(NOT MAKESELF_EXE) | ||
| 16 | - message(FATAL_ERROR "makeself not found!") | ||
| 17 | -endif() | ||
| 18 | - | ||
| 19 | -execute_process(COMMAND bash ${MAKESELF_EXE} | ||
| 20 | - --header ${MAKESELF_HEADER_EXE} | ||
| 21 | - --help-header ./help.info | ||
| 22 | - --gzip --complevel 4 --nomd5 --sha256 | ||
| 23 | - ./ ${CPACK_PACKAGE_FILE_NAME} "version:1.0" ./install.sh | ||
| 24 | - WORKING_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY} | ||
| 25 | - RESULT_VARIABLE EXEC_RESULT | ||
| 26 | - ERROR_VARIABLE EXEC_ERROR | ||
| 27 | -) | ||
| 28 | - | ||
| 29 | -if (NOT "${EXEC_RESULT}x" STREQUAL "0x") | ||
| 30 | - message(FATAL_ERROR "CPack Command error: ${EXEC_RESULT}\n${EXEC_ERROR}") | ||
| 31 | -endif() | ||
| 32 | - | ||
| 33 | -execute_process(COMMAND cp ${CPACK_EXTERNAL_BUILT_PACKAGES} ${CPACK_PACKAGE_DIRECTORY}/ | ||
| 34 | - COMMAND echo "Copy ${CPACK_EXTERNAL_BUILT_PACKAGES} to ${CPACK_PACKAGE_DIRECTORY}/" | ||
| 35 | - WORKING_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY} | ||
| 36 | -) | ||
| 37 | - | ||
| 38 | -if (NOT "${CPACK_PACKAGE_DIRECTORY}x" STREQUAL "${CPACK_INSTALL_PREFIX}x") | ||
| 39 | - execute_process( | ||
| 40 | - COMMAND ${CMAKE_COMMAND} -E make_directory ${CPACK_INSTALL_PREFIX} | ||
| 41 | - WORKING_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY} | ||
| 42 | - ) | ||
| 43 | - | ||
| 44 | - execute_process( | ||
| 45 | - COMMAND cp ${CPACK_EXTERNAL_BUILT_PACKAGES} ${CPACK_INSTALL_PREFIX}/ | ||
| 46 | - COMMAND echo "Copy ${CPACK_EXTERNAL_BUILT_PACKAGES} to ${CPACK_INSTALL_PREFIX}/" | ||
| 47 | - WORKING_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY} | ||
| 48 | - ) | ||
| 49 | -endif() | ||
| @@ -16,57 +16,37 @@ endif() | |||
| 16 | include(FindPackageHandleStandardArgs) | 16 | include(FindPackageHandleStandardArgs) |
| 17 | 17 | ||
| 18 | set(OPBASE_HEAD_SEARCH_PATHS | 18 | set(OPBASE_HEAD_SEARCH_PATHS |
| 19 | - ${ASCEND_DIR}/${SYSTEM_PREFIX}/include | 19 | + ${OPBASE_SOURCE_PATH}/include |
| 20 | - ${ASCEND_DIR}/${SYSTEM_PREFIX}/pkg_inc | 20 | + ${OPBASE_SOURCE_PATH}/pkg_inc |
| 21 | ${TOP_DIR}/ops-base/include | 21 | ${TOP_DIR}/ops-base/include |
| 22 | ${TOP_DIR}/ops-base/pkg_inc # compile with ci | 22 | ${TOP_DIR}/ops-base/pkg_inc # compile with ci |
| 23 | ) | 23 | ) |
| 24 | 24 | ||
| 25 | -set(OPBASE_LIB_SEARCH_PATHS ${ASCEND_DIR}/${SYSTEM_PREFIX}) | ||
| 26 | - | ||
| 27 | find_path(OPBASE_INC_DIR | 25 | find_path(OPBASE_INC_DIR |
| 28 | NAMES op_common/op_host/util/opbase_export.h | 26 | NAMES op_common/op_host/util/opbase_export.h |
| 29 | PATHS ${OPBASE_HEAD_SEARCH_PATHS} | 27 | PATHS ${OPBASE_HEAD_SEARCH_PATHS} |
| 30 | NO_CMAKE_SYSTEM_PATH | 28 | NO_CMAKE_SYSTEM_PATH |
| 31 | NO_CMAKE_FIND_ROOT_PATH | 29 | NO_CMAKE_FIND_ROOT_PATH |
| 32 | -) | 30 | + NO_DEFAULT_PATH |
| 33 | - | ||
| 34 | -find_library(OPBASE_LIB_DIR | ||
| 35 | - NAME ops_base | ||
| 36 | - PATHS ${OPBASE_LIB_SEARCH_PATHS} | ||
| 37 | - PATH_SUFFIXES lib64 | ||
| 38 | - NO_CMAKE_SYSTEM_PATH | ||
| 39 | - NO_CMAKE_FIND_ROOT_PATH | ||
| 40 | ) | 31 | ) |
| 41 | 32 | ||
| 42 | find_package_handle_standard_args(OPBASE | 33 | find_package_handle_standard_args(OPBASE |
| 43 | REQUIRED_VARS OPBASE_INC_DIR) | 34 | REQUIRED_VARS OPBASE_INC_DIR) |
| 44 | 35 | ||
| 45 | get_filename_component(OPBASE_INC_DIR ${OPBASE_INC_DIR} REALPATH) | 36 | get_filename_component(OPBASE_INC_DIR ${OPBASE_INC_DIR} REALPATH) |
| 46 | -if(OPBASE_LIB_DIR) | ||
| 47 | - get_filename_component(OPBASE_LIB_DIR ${OPBASE_LIB_DIR} REALPATH) | ||
| 48 | - add_library(opsbase SHARED IMPORTED) | ||
| 49 | - set_target_properties(opsbase PROPERTIES | ||
| 50 | - INTERFACE_INCLUDE_DIRECTORIES ${OPBASE_INC_DIR} | ||
| 51 | - IMPORTED_LOCATION ${OPBASE_LIB_DIR} | ||
| 52 | - ) | ||
| 53 | -else() | ||
| 54 | - if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) | ||
| 55 | - message(STATUS "Cannot find library ops_base") | ||
| 56 | - endif() | ||
| 57 | -endif() | ||
| 58 | 37 | ||
| 59 | if(OPBASE_FOUND) | 38 | if(OPBASE_FOUND) |
| 60 | if(NOT OPBASE_FIND_QUIETLY) | 39 | if(NOT OPBASE_FIND_QUIETLY) |
| 61 | message(STATUS "Found OPABSE include:${OPBASE_INC_DIR}") | 40 | message(STATUS "Found OPABSE include:${OPBASE_INC_DIR}") |
| 62 | - message(STATUS "Found OPABSE lib:${OPBASE_LIB_DIR}") | ||
| 63 | endif() | 41 | endif() |
| 64 | set(OPBASE_INC_DIRS | 42 | set(OPBASE_INC_DIRS |
| 65 | ${OPBASE_INC_DIR} | 43 | ${OPBASE_INC_DIR} |
| 66 | ${OPBASE_INC_DIR}/op_common | 44 | ${OPBASE_INC_DIR}/op_common |
| 67 | ${OPBASE_INC_DIR}/op_common/op_host | 45 | ${OPBASE_INC_DIR}/op_common/op_host |
| 46 | + ${OPBASE_INC_DIR}/op_common/op_graph | ||
| 68 | ${OPBASE_INC_DIR}/../pkg_inc | 47 | ${OPBASE_INC_DIR}/../pkg_inc |
| 69 | ${OPBASE_INC_DIR}/../pkg_inc/op_common | 48 | ${OPBASE_INC_DIR}/../pkg_inc/op_common |
| 70 | ${OPBASE_INC_DIR}/../pkg_inc/op_common/op_host | 49 | ${OPBASE_INC_DIR}/../pkg_inc/op_common/op_host |
| 50 | + ${OPBASE_INC_DIR}/../pkg_inc/op_common/op_graph | ||
| 71 | ) | 51 | ) |
| 72 | -endif() | 52 | +endif() |
| @@ -22,6 +22,10 @@ if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) | |||
| 22 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/pkg_inc/aicpu_common/context/common | 22 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/pkg_inc/aicpu_common/context/common |
| 23 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/pkg_inc/aicpu_common/context/cpu_proto | 23 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/pkg_inc/aicpu_common/context/cpu_proto |
| 24 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/pkg_inc/aicpu_common/context/utils | 24 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/pkg_inc/aicpu_common/context/utils |
| 25 | + ${ASCEND_DIR}/${SYSTEM_PREFIX}/include/aicpu_common/context | ||
| 26 | + ${ASCEND_DIR}/${SYSTEM_PREFIX}/include/aicpu_common/context/common | ||
| 27 | + ${ASCEND_DIR}/${SYSTEM_PREFIX}/include/aicpu_common/context/cpu_proto | ||
| 28 | + ${ASCEND_DIR}/${SYSTEM_PREFIX}/include/aicpu_common/context/utils | ||
| 25 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/include/experiment/datagw/aicpu/common | 29 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/include/experiment/datagw/aicpu/common |
| 26 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/pkg_inc | 30 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/pkg_inc |
| 27 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/pkg_inc/aicpu | 31 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/pkg_inc/aicpu |
| @@ -1,32 +1,41 @@ | |||
| 1 | -#!/bin/bash | ||
| 2 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 3 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | -# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 5 | # CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | # CANN Open Software License Agreement Version 2.0 (the "License"). |
| 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 8 | -# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 9 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 10 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 11 | 10 | ||
| 12 | -main() { | 11 | +if(mmpa_FOUND) |
| 13 | - echo "[INFO]excute file: $0" | 12 | + message(STATUS "mmpa has been found") |
| 14 | - if [ $# -lt 2 ]; then | 13 | + return() |
| 15 | - echo "[ERROR]input error" | 14 | +endif() |
| 16 | - echo "[ERROR]bash $0 {out_path} {task_id}" | ||
| 17 | - exit 1 | ||
| 18 | - fi | ||
| 19 | - local output_path="$1" | ||
| 20 | - local idx="$2" | ||
| 21 | 15 | ||
| 22 | - result=$(bash build_binary_op_exe_task.sh $output_path $idx) | 16 | +include(FindPackageHandleStandardArgs) |
| 23 | - local gen_res=$? | 17 | + |
| 24 | - if [ $gen_res -ne 0 ]; then | 18 | +set(MMPA_LIB_SEARCH_PATHS |
| 25 | - echo -e "[ERROR] build binary single op failed with ErrorCode[$gen_res]." | 19 | + ${ASCEND_DIR}/${SYSTEM_PREFIX} |
| 26 | - echo -e "Error output: \n $result" | 20 | +) |
| 27 | - return | 21 | + |
| 28 | - fi | 22 | +find_library(MMPA_LIB_DIR |
| 29 | - echo "$result" | 23 | + NAME mmpa |
| 30 | -} | 24 | + PATHS ${MMPA_LIB_SEARCH_PATHS} |
| 31 | -set -o pipefail | 25 | + PATH_SUFFIXES lib64 |
| 32 | -main "$@" | gawk '{print strftime("[%Y-%m-%d %H:%M:%S]"), $0}' | 26 | + NO_CMAKE_SYSTEM_PATH |
| 27 | + NO_CMAKE_FIND_ROOT_PATH | ||
| 28 | +) | ||
| 29 | + | ||
| 30 | +if(MMPA_LIB_DIR) | ||
| 31 | + get_filename_component(MMPA_LIB_DIR ${MMPA_LIB_DIR} REALPATH) | ||
| 32 | + add_library(mmpa SHARED IMPORTED) | ||
| 33 | + set_target_properties(mmpa PROPERTIES | ||
| 34 | + IMPORTED_LOCATION ${MMPA_LIB_DIR} | ||
| 35 | + ) | ||
| 36 | + message(STATUS "Found mmpa library:${MMPA_LIB_DIR}") | ||
| 37 | +else() | ||
| 38 | + if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) | ||
| 39 | + message(STATUS "Cannot find library mmpa") | ||
| 40 | + endif() | ||
| 41 | +endif() | ||
| @@ -18,12 +18,12 @@ include(FindPackageHandleStandardArgs) | |||
| 18 | 18 | ||
| 19 | set(NNOPBASE_ACLNN_HEAD_SEARCH_PATHS | 19 | set(NNOPBASE_ACLNN_HEAD_SEARCH_PATHS |
| 20 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/include | 20 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/include |
| 21 | - ${TOP_DIR}/ace/npuruntime/inc/external/ # compile with ci | 21 | + ${TOP_DIR}/ops-base/include/nnopbase/ # compile with ci |
| 22 | ) | 22 | ) |
| 23 | 23 | ||
| 24 | set(NNOPBASE_OPDEV_HEAD_SEARCH_PATHS | 24 | set(NNOPBASE_OPDEV_HEAD_SEARCH_PATHS |
| 25 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/include/aclnn | 25 | ${ASCEND_DIR}/${SYSTEM_PREFIX}/include/aclnn |
| 26 | - ${TOP_DIR}/ace/npuruntime/inc/nnopbase/ # compile with ci | 26 | + ${TOP_DIR}/ops-base/include/nnopbase/ # compile with ci |
| 27 | ) | 27 | ) |
| 28 | 28 | ||
| 29 | set(NNOPBASE_LIB_SEARCH_PATHS | 29 | set(NNOPBASE_LIB_SEARCH_PATHS |
| @@ -81,4 +81,4 @@ if(nnopbase_FOUND) | |||
| 81 | ) | 81 | ) |
| 82 | message(STATUS "Found aclnn include dir: ${NNOPBASE_ACLNN_INC_DIR}") | 82 | message(STATUS "Found aclnn include dir: ${NNOPBASE_ACLNN_INC_DIR}") |
| 83 | message(STATUS "Found opdev include dir: ${NNOPBASE_OPDEV_INC_DIR}") | 83 | message(STATUS "Found opdev include dir: ${NNOPBASE_OPDEV_INC_DIR}") |
| 84 | -endif() | 84 | +endif() |
| @@ -1,76 +1,26 @@ | |||
| 1 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | -# This file is a part of the CANN Open Software. | 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). |
| 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 10 | # ###################################################################################################################### | 10 | # ###################################################################################################################### |
| 11 | # 调用opbuild工具,生成aclnn/aclnnInner/.ini的算子信息库 等文件 generate outpath: ${ASCEND_AUTOGEN_PATH}/${sub_dir} | 11 | # 调用opbuild工具,生成aclnn/aclnnInner/.ini的算子信息库 等文件 generate outpath: ${ASCEND_AUTOGEN_PATH}/${sub_dir} |
| 12 | # ###################################################################################################################### | 12 | # ###################################################################################################################### |
| 13 | -function(gen_opbuild_target) | ||
| 14 | - set(oneValueArgs TARGET PREFIX GENACLNN OUT_DIR OUT_SUB_DIR) | ||
| 15 | - set(multiValueArgs IN_SRCS OUT_SRCS OUT_HEADERS) | ||
| 16 | - cmake_parse_arguments(OPBUILD "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
| 17 | - if(NOT OPBUILD_IN_SRCS) | ||
| 18 | - message(STATUS "No ${OPBUILD_PREFIX} srcs, skip ${OPBUILD_TARGET}") | ||
| 19 | - return() | ||
| 20 | - endif() | ||
| 21 | - | ||
| 22 | - if (NOT TARGET gen_op_host_${OPBUILD_PREFIX}) | ||
| 23 | - add_library(gen_op_host_${OPBUILD_PREFIX} SHARED ${OPBUILD_IN_SRCS}) | ||
| 24 | - endif() | ||
| 25 | - target_link_libraries(gen_op_host_${OPBUILD_PREFIX} PRIVATE $<BUILD_INTERFACE:intf_pub_cxx17> exe_graph register | ||
| 26 | - c_sec) | ||
| 27 | - target_compile_options(gen_op_host_${OPBUILD_PREFIX} PRIVATE -fno-common) | ||
| 28 | - string(REPLACE ";" "\;" OPS_PRODUCT_NAME "${ASCEND_COMPUTE_UNIT}") | ||
| 29 | - | ||
| 30 | - if(ENABLE_ASAN) | ||
| 31 | - execute_process( | ||
| 32 | - COMMAND ${CMAKE_C_COMPILER} -print-file-name=libasan.so | ||
| 33 | - OUTPUT_VARIABLE LIBASAN_PATH | ||
| 34 | - OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| 35 | - RESULT_VARIABLE result | ||
| 36 | - ) | ||
| 37 | - if(NOT result EQUAL 0) | ||
| 38 | - message(FATAL_ERROR "compiler not support asan, please disable asan") | ||
| 39 | - endif() | ||
| 40 | - endif() | ||
| 41 | - message("LIBASAN_PATH = ${LIBASAN_PATH}") | ||
| 42 | - add_custom_command( | ||
| 43 | - OUTPUT ${OPBUILD_OUT_SRCS} ${OPBUILD_OUT_HEADERS} | ||
| 44 | - COMMAND | ||
| 45 | - OPS_PROTO_SEPARATE=1 OPS_PROJECT_NAME=${OPBUILD_PREFIX} OPS_ACLNN_GEN=${OPBUILD_GENACLNN} | ||
| 46 | - OPS_PRODUCT_NAME=\"${OPS_PRODUCT_NAME}\" | ||
| 47 | - env LD_PRELOAD=${LIBASAN_PATH} | ||
| 48 | - env LD_LIBRARY_PATH=${ASCEND_DIR}/${SYSTEM_PREFIX}/lib64:$ENV{LD_LIBRARY_PATH} ${OP_BUILD_TOOL} | ||
| 49 | - $<TARGET_FILE:gen_op_host_${OPBUILD_PREFIX}> ${OPBUILD_OUT_DIR}/${OPBUILD_OUT_SUB_DIR}) | ||
| 50 | - | ||
| 51 | - if (NOT TARGET ${OPBUILD_TARGET}) | ||
| 52 | - add_custom_target(${OPBUILD_TARGET} DEPENDS ${OPBUILD_OUT_SRCS} ${OPBUILD_OUT_HEADERS}) | ||
| 53 | - endif() | ||
| 54 | - add_dependencies(${OPBUILD_TARGET} gen_op_host_${OPBUILD_PREFIX}) | ||
| 55 | - if(TARGET op_build) | ||
| 56 | - add_dependencies(${OPBUILD_TARGET} op_build) | ||
| 57 | - endif() | ||
| 58 | -endfunction() | ||
| 59 | - | ||
| 60 | function(gen_aclnn_classify host_obj prefix ori_out_srcs ori_out_headers opbuild_out_srcs opbuild_out_headers) | 13 | function(gen_aclnn_classify host_obj prefix ori_out_srcs ori_out_headers opbuild_out_srcs opbuild_out_headers) |
| 61 | get_target_property(module_sources ${host_obj} INTERFACE_SOURCES) | 14 | get_target_property(module_sources ${host_obj} INTERFACE_SOURCES) |
| 62 | set(sub_dir) | 15 | set(sub_dir) |
| 63 | # aclnn\aclnnExc以aclnn开头,aclnnInner以aclnnInner开头 | 16 | # aclnn\aclnnExc以aclnn开头,aclnnInner以aclnnInner开头 |
| 64 | if("${prefix}" STREQUAL "aclnn") | 17 | if("${prefix}" STREQUAL "aclnn") |
| 65 | - set(file_prefix "aclnn") | ||
| 66 | set(need_gen_aclnn 1) | 18 | set(need_gen_aclnn 1) |
| 67 | elseif("${prefix}" STREQUAL "aclnnInner") | 19 | elseif("${prefix}" STREQUAL "aclnnInner") |
| 68 | set(sub_dir inner) | 20 | set(sub_dir inner) |
| 69 | - set(file_prefix "aclnnInner") | ||
| 70 | set(need_gen_aclnn 1) | 21 | set(need_gen_aclnn 1) |
| 71 | elseif("${prefix}" STREQUAL "aclnnExc") | 22 | elseif("${prefix}" STREQUAL "aclnnExc") |
| 72 | set(sub_dir exc) | 23 | set(sub_dir exc) |
| 73 | - set(file_prefix "aclnn") | ||
| 74 | set(need_gen_aclnn 0) | 24 | set(need_gen_aclnn 0) |
| 75 | else() | 25 | else() |
| 76 | message(FATAL_ERROR "UnSupported aclnn prefix type, must be in aclnn/aclnnInner/aclnnExc") | 26 | message(FATAL_ERROR "UnSupported aclnn prefix type, must be in aclnn/aclnnInner/aclnnExc") |
| @@ -79,47 +29,44 @@ function(gen_aclnn_classify host_obj prefix ori_out_srcs ori_out_headers opbuild | |||
| 79 | set(out_src_path ${ASCEND_AUTOGEN_PATH}/${sub_dir}) | 29 | set(out_src_path ${ASCEND_AUTOGEN_PATH}/${sub_dir}) |
| 80 | file(MAKE_DIRECTORY ${out_src_path}) | 30 | file(MAKE_DIRECTORY ${out_src_path}) |
| 81 | get_filename_component(out_src_path ${out_src_path} REALPATH) | 31 | get_filename_component(out_src_path ${out_src_path} REALPATH) |
| 82 | - set(in_srcs) | ||
| 83 | - set(out_srcs) | ||
| 84 | - set(out_headers) | ||
| 85 | - if(module_sources) | ||
| 86 | - foreach(file ${module_sources}) | ||
| 87 | - get_filename_component(name_without_ext ${file} NAME_WE) | ||
| 88 | - string(REGEX REPLACE "_def$" "" _op_name ${name_without_ext}) | ||
| 89 | - list(APPEND in_srcs ${file}) | ||
| 90 | - file(GLOB out_src_with_ver ${out_src_path}/${file_prefix}_${_op_name}_v*.cpp) | ||
| 91 | - file(GLOB out_headers_with_ver ${out_src_path}/${file_prefix}_${_op_name}_v*.h) | ||
| 92 | - list(APPEND out_srcs ${out_src_path}/${file_prefix}_${_op_name}.cpp ${out_src_with_ver}) | ||
| 93 | - list(APPEND out_headers ${out_src_path}/${file_prefix}_${_op_name}.h ${out_headers_with_ver}) | ||
| 94 | - endforeach() | ||
| 95 | - endif() | ||
| 96 | # opbuild_gen_aclnn/opbuild_gen_aclnnInner/opbuild_gen_aclnnExc | 32 | # opbuild_gen_aclnn/opbuild_gen_aclnnInner/opbuild_gen_aclnnExc |
| 97 | - gen_opbuild_target( | 33 | + if(module_sources AND ENABLE_GEN_ACLNN) |
| 98 | - TARGET opbuild_gen_${prefix} PREFIX ${prefix} GENACLNN ${need_gen_aclnn} IN_SRCS "${in_srcs}" OUT_SRCS | 34 | + if (module_sources) |
| 99 | - "${out_srcs}" OUT_HEADERS "${out_headers}" OUT_DIR ${ASCEND_AUTOGEN_PATH} OUT_SUB_DIR ${sub_dir}) | 35 | + npu_op_code_gen( |
| 36 | + SRC ${module_sources} | ||
| 37 | + PACKAGE opbuild_gen_${prefix} | ||
| 38 | + OPTIONS OPS_PROTO_SEPARATE 1 OPS_PROJECT_NAME ${prefix} OPS_ACLNN_GEN ${need_gen_aclnn} | ||
| 39 | + OUT_DIR ${out_src_path} | ||
| 40 | + ) | ||
| 41 | + execute_process(COMMAND bash -c "rm -fr ${out_src_path}/*.ini" | ||
| 42 | + COMMAND | ||
| 43 | + ${CMAKE_COMMAND} -E env OPS_PROTO_SEPARATE=1 OPS_PROJECT_NAME=${prefix} OPS_ACLNN_GEN=${need_gen_aclnn} | ||
| 44 | + OPS_PRODUCT_NAME=${ASCEND_COMPUTE_UNIT} ${OP_BUILD_TOOL} ${out_src_path}/libascend_all_ops.so ${out_src_path} | ||
| 45 | + ) | ||
| 46 | + string(JOIN "," kernel_srcs ${kernel_src_list}) | ||
| 47 | + execute_process( | ||
| 48 | + COMMAND | ||
| 49 | + ${ASCEND_PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/util/insert_kernel_src.py | ||
| 50 | + ${kernel_srcs} ${out_src_path} ${ASCEND_COMPUTE_UNIT} | ||
| 51 | + ) | ||
| 52 | + endif() | ||
| 53 | + else() | ||
| 54 | + message(STATUS "No ${prefix} srcs, skip ${prefix}") | ||
| 55 | + endif() | ||
| 56 | + | ||
| 100 | if("${prefix}" STREQUAL "aclnnExc") | 57 | if("${prefix}" STREQUAL "aclnnExc") |
| 101 | get_target_property(exclude_headers ${OPHOST_NAME}_aclnn_exclude_headers INTERFACE_SOURCES) | 58 | get_target_property(exclude_headers ${OPHOST_NAME}_aclnn_exclude_headers INTERFACE_SOURCES) |
| 102 | if(exclude_headers) | 59 | if(exclude_headers) |
| 103 | set(${opbuild_out_headers} ${ori_out_headers} ${exclude_headers} PARENT_SCOPE) | 60 | set(${opbuild_out_headers} ${ori_out_headers} ${exclude_headers} PARENT_SCOPE) |
| 104 | endif() | 61 | endif() |
| 105 | else() | 62 | else() |
| 106 | - function(add_parent_path input_list output_list) | 63 | + file(GLOB out_srcs ${out_src_path}/${prefix}_*.cpp) |
| 107 | - set(path_list "") | 64 | + file(GLOB out_headers ${out_src_path}/${prefix}_*.h) |
| 108 | - foreach(item ${input_list}) | ||
| 109 | - list(APPEND path_list "${ASCEND_AUTOGEN_PATH}/${item}") | ||
| 110 | - endforeach() | ||
| 111 | - set(${output_list} "${path_list}" PARENT_SCOPE) | ||
| 112 | - endfunction() | ||
| 113 | 65 | ||
| 114 | - add_parent_path("${ACLNN_EXTRA_SRCS}" PARENT_ACLNN_EXTRA_SRCS) | 66 | + set(${opbuild_out_srcs} ${ori_out_srcs} ${out_srcs} PARENT_SCOPE) |
| 115 | - add_parent_path("${ACLNN_EXTRA_HEADERS}" PARENT_ACLNN_EXTRA_HEADERS) | ||
| 116 | - add_parent_path("${ACLNNINNER_EXTRA_SRCS}" PARENT_ACLNNINNER_EXTRA_SRCS) | ||
| 117 | - add_parent_path("${ACLNNINNER_EXTRA_HEADERS}" PARENT_ACLNNINNER_EXTRA_HEADERS) | ||
| 118 | - | ||
| 119 | - set(${opbuild_out_srcs} ${ori_out_srcs} ${out_srcs} ${PARENT_ACLNN_EXTRA_SRCS} ${PARENT_ACLNNINNER_EXTRA_SRCS} PARENT_SCOPE) | ||
| 120 | if("${prefix}" STREQUAL "aclnn") | 67 | if("${prefix}" STREQUAL "aclnn") |
| 121 | - set(${opbuild_out_headers} ${ori_out_headers} ${out_headers} ${PARENT_ACLNN_EXTRA_HEADERS} ${PARENT_ACLNNINNER_EXTRA_HEADERS} PARENT_SCOPE) | 68 | + set(${opbuild_out_headers} ${ori_out_headers} ${out_headers} PARENT_SCOPE) |
| 122 | - endif() | 69 | + endif() |
| 123 | endif() | 70 | endif() |
| 124 | endfunction() | 71 | endfunction() |
| 125 | 72 | ||
| @@ -164,7 +111,7 @@ function(gen_aclnn_with_opdef) | |||
| 164 | gen_aclnn_master_header(${aclnn_master_header_name} "${aclnn_master_header}" "${opbuild_out_headers}") | 111 | gen_aclnn_master_header(${aclnn_master_header_name} "${aclnn_master_header}" "${opbuild_out_headers}") |
| 165 | 112 | ||
| 166 | # 将头文件安装到packages/vendors/vendor_name/op_api/include | 113 | # 将头文件安装到packages/vendors/vendor_name/op_api/include |
| 167 | - if(ENABLE_PACKAGE) | 114 | + if(ENABLE_PACKAGE AND NOT NO_ACLNN) |
| 168 | install(FILES ${opbuild_out_headers} DESTINATION ${ACLNN_INC_INSTALL_DIR} OPTIONAL) | 115 | install(FILES ${opbuild_out_headers} DESTINATION ${ACLNN_INC_INSTALL_DIR} OPTIONAL) |
| 169 | install(FILES ${aclnn_master_header} DESTINATION ${ACLNN_INC_INSTALL_DIR} OPTIONAL) | 116 | install(FILES ${aclnn_master_header} DESTINATION ${ACLNN_INC_INSTALL_DIR} OPTIONAL) |
| 170 | install(FILES ${opbuild_out_headers} DESTINATION ${ACLNN_OP_INC_INSTALL_DIR} OPTIONAL) | 117 | install(FILES ${opbuild_out_headers} DESTINATION ${ACLNN_OP_INC_INSTALL_DIR} OPTIONAL) |
| @@ -174,39 +121,75 @@ function(gen_aclnn_with_opdef) | |||
| 174 | install(FILES ${opbuild_out_headers} DESTINATION ${CMAKE_BINARY_DIR}/static_library_files/include OPTIONAL) | 121 | install(FILES ${opbuild_out_headers} DESTINATION ${CMAKE_BINARY_DIR}/static_library_files/include OPTIONAL) |
| 175 | install(FILES ${opbuild_out_headers} DESTINATION ${CMAKE_BINARY_DIR}/static_library_files/include/aclnnop OPTIONAL) | 122 | install(FILES ${opbuild_out_headers} DESTINATION ${CMAKE_BINARY_DIR}/static_library_files/include/aclnnop OPTIONAL) |
| 176 | endif() | 123 | endif() |
| 177 | - foreach(aclnn_header_path ${opbuild_out_headers}) | ||
| 178 | - string(REGEX REPLACE "^.*/" "" filename "${aclnn_header_path}") | ||
| 179 | - list(APPEND aclnn_header_file "${filename}") | ||
| 180 | - endforeach() | ||
| 181 | endif() | 124 | endif() |
| 182 | 125 | ||
| 183 | - # ascendc_impl_gen depends opbuild_custom_gen_aclnn_all, for opbuild will generate .ini | ||
| 184 | - set(dependency_list) | ||
| 185 | - if(TARGET opbuild_gen_aclnn) | ||
| 186 | - list(APPEND dependency_list opbuild_gen_aclnn) | ||
| 187 | - endif() | ||
| 188 | - if(TARGET opbuild_gen_aclnnInner) | ||
| 189 | - list(APPEND dependency_list opbuild_gen_aclnnInner) | ||
| 190 | - endif() | ||
| 191 | - if(TARGET opbuild_gen_aclnnExc) | ||
| 192 | - list(APPEND dependency_list opbuild_gen_aclnnExc) | ||
| 193 | - endif() | ||
| 194 | - if(NOT dependency_list) | ||
| 195 | - message(STATUS "no operator info to generate") | ||
| 196 | - return() | ||
| 197 | - endif() | ||
| 198 | - | ||
| 199 | - if (NOT TARGET opbuild_custom_gen_aclnn_all) | ||
| 200 | - add_custom_target(opbuild_custom_gen_aclnn_all | ||
| 201 | - COMMAND python3 ${PROJECT_SOURCE_DIR}/scripts/util/modify_gen_aclnn_static.py ${CMAKE_BINARY_DIR}) | ||
| 202 | - endif() | ||
| 203 | - add_dependencies(opbuild_custom_gen_aclnn_all ${dependency_list}) | ||
| 204 | if(opbuild_out_srcs) | 126 | if(opbuild_out_srcs) |
| 205 | set_source_files_properties(${opbuild_out_srcs} PROPERTIES GENERATED TRUE) | 127 | set_source_files_properties(${opbuild_out_srcs} PROPERTIES GENERATED TRUE) |
| 206 | if (NOT TARGET opbuild_gen_aclnn_all) | 128 | if (NOT TARGET opbuild_gen_aclnn_all) |
| 207 | add_library(opbuild_gen_aclnn_all OBJECT ${opbuild_out_srcs}) | 129 | add_library(opbuild_gen_aclnn_all OBJECT ${opbuild_out_srcs}) |
| 208 | endif() | 130 | endif() |
| 209 | - add_dependencies(opbuild_gen_aclnn_all opbuild_custom_gen_aclnn_all) | 131 | + if (ENABLE_STATIC AND NOT TARGET opbuild_custom_gen_aclnn_all) |
| 132 | + add_custom_target(opbuild_custom_gen_aclnn_all | ||
| 133 | + COMMAND python3 ${PROJECT_SOURCE_DIR}/scripts/util/modify_gen_aclnn_static.py ${CMAKE_BINARY_DIR}) | ||
| 134 | + add_dependencies(opbuild_gen_aclnn_all opbuild_custom_gen_aclnn_all) | ||
| 135 | + endif() | ||
| 210 | target_include_directories(opbuild_gen_aclnn_all PRIVATE ${OPAPI_INCLUDE}) | 136 | target_include_directories(opbuild_gen_aclnn_all PRIVATE ${OPAPI_INCLUDE}) |
| 211 | endif() | 137 | endif() |
| 212 | endfunction() | 138 | endfunction() |
| 139 | + | ||
| 140 | +function(gen_aicpu_ini_from_opdef) | ||
| 141 | + message(STATUS "Opbuild generating AICPU ini/json from OpDef") | ||
| 142 | + cmake_parse_arguments(OPBUILD "" "OUT_DIR;PROJECT_NAME;ACCESS_PREFIX;ENABLE_SOURCE" "OPS_SRC" ${ARGN}) | ||
| 143 | + if(NOT OPBUILD_OPS_SRC) | ||
| 144 | + message(STATUS "No AICPU OpDef sources, skip.") | ||
| 145 | + return() | ||
| 146 | + endif() | ||
| 147 | + | ||
| 148 | + file(MAKE_DIRECTORY ${OPBUILD_OUT_DIR}) | ||
| 149 | + | ||
| 150 | + if(NOT TARGET intf_pub) | ||
| 151 | + message(FATAL_ERROR "intf_pub target is required for AICPU OpDef build") | ||
| 152 | + endif() | ||
| 153 | + | ||
| 154 | + set(aicpu_opdef_target opbuild_aicpu_ops) | ||
| 155 | + set(aicpu_opdef_so ${OPBUILD_OUT_DIR}/libaicpu_ops.so) | ||
| 156 | + set(aicpu_opdef_ini ${OPBUILD_OUT_DIR}/aicpu_kernel.ini) | ||
| 157 | + | ||
| 158 | + if(NOT TARGET ${aicpu_opdef_target}) | ||
| 159 | + add_library(${aicpu_opdef_target} SHARED ${OPBUILD_OPS_SRC}) | ||
| 160 | + target_include_directories(${aicpu_opdef_target} PRIVATE ${ASCEND_CANN_PACKAGE_PATH}/include) | ||
| 161 | + target_link_directories(${aicpu_opdef_target} PRIVATE ${ASCEND_CANN_PACKAGE_PATH}/lib64) | ||
| 162 | + target_link_libraries( | ||
| 163 | + ${aicpu_opdef_target} | ||
| 164 | + PRIVATE intf_pub | ||
| 165 | + exe_graph | ||
| 166 | + register | ||
| 167 | + tiling_api | ||
| 168 | + ) | ||
| 169 | + set_target_properties(${aicpu_opdef_target} PROPERTIES | ||
| 170 | + OUTPUT_NAME aicpu_ops | ||
| 171 | + LIBRARY_OUTPUT_DIRECTORY ${OPBUILD_OUT_DIR} | ||
| 172 | + ) | ||
| 173 | + endif() | ||
| 174 | + | ||
| 175 | + set(opbuild_env "") | ||
| 176 | + if(NOT "${OPBUILD_PROJECT_NAME}x" STREQUAL "x") | ||
| 177 | + list(APPEND opbuild_env "OPS_PROJECT_NAME=${OPBUILD_PROJECT_NAME}") | ||
| 178 | + endif() | ||
| 179 | + if(NOT "${OPBUILD_ACCESS_PREFIX}x" STREQUAL "x") | ||
| 180 | + list(APPEND opbuild_env "OPS_DIRECT_ACCESS_PREFIX=${OPBUILD_ACCESS_PREFIX}") | ||
| 181 | + endif() | ||
| 182 | + | ||
| 183 | + add_custom_command( | ||
| 184 | + OUTPUT ${aicpu_opdef_ini} | ||
| 185 | + COMMAND | ||
| 186 | + ${CMAKE_COMMAND} -E env ENABLE_SOURCE_PACKAGE=${OPBUILD_ENABLE_SOURCE} ${opbuild_env} | ||
| 187 | + ${OP_BUILD_TOOL} $<TARGET_FILE:${aicpu_opdef_target}> ${OPBUILD_OUT_DIR} --aicpu | ||
| 188 | + DEPENDS ${aicpu_opdef_target} | ||
| 189 | + COMMENT "Generating ${aicpu_opdef_ini} from ${aicpu_opdef_so}" | ||
| 190 | + VERBATIM | ||
| 191 | + ) | ||
| 192 | + | ||
| 193 | + message(STATUS "Opbuild generating AICPU ini/json from OpDef - done") | ||
| 194 | + set(OPBUILD_AICPU_INI ${aicpu_opdef_ini} PARENT_SCOPE) | ||
| 195 | +endfunction() | ||
| @@ -9,10 +9,8 @@ | |||
| 9 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 10 | #### CPACK to package run ##### | 10 | #### CPACK to package run ##### |
| 11 | 11 | ||
| 12 | -# download makeself package | ||
| 13 | -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/third_party/makeself-fetch.cmake) | ||
| 14 | - | ||
| 15 | function(pack_custom) | 12 | function(pack_custom) |
| 13 | + add_cann_third_party(makeself-fetch) | ||
| 16 | 14 | ||
| 17 | npu_op_package(${PACK_CUSTOM_NAME} | 15 | npu_op_package(${PACK_CUSTOM_NAME} |
| 18 | TYPE RUN | 16 | TYPE RUN |
| @@ -31,17 +29,27 @@ function(pack_custom) | |||
| 31 | if(TARGET ${OPHOST_NAME}_opapi_obj OR TARGET opbuild_gen_aclnn_all) | 29 | if(TARGET ${OPHOST_NAME}_opapi_obj OR TARGET opbuild_gen_aclnn_all) |
| 32 | list(APPEND op_package_list cust_opapi) | 30 | list(APPEND op_package_list cust_opapi) |
| 33 | endif() | 31 | endif() |
| 34 | - if(TARGET ${OPHOST_NAME}_infer_obj) | 32 | + if(TARGET cust_proto) |
| 35 | list(APPEND op_package_list cust_proto) | 33 | list(APPEND op_package_list cust_proto) |
| 36 | endif() | 34 | endif() |
| 37 | if(TARGET ${OPHOST_NAME}_tiling_obj) | 35 | if(TARGET ${OPHOST_NAME}_tiling_obj) |
| 38 | list(APPEND op_package_list cust_opmaster) | 36 | list(APPEND op_package_list cust_opmaster) |
| 39 | endif() | 37 | endif() |
| 40 | 38 | ||
| 41 | - npu_op_package_add(${PACK_CUSTOM_NAME} | 39 | + list(LENGTH op_package_list OP_PACKAGE_LENGTH) |
| 42 | - LIBRARY | 40 | + if(OP_PACKAGE_LENGTH GREATER 0) |
| 43 | - ${op_package_list} | 41 | + npu_op_package_add(${PACK_CUSTOM_NAME} |
| 44 | - ) | 42 | + LIBRARY |
| 43 | + ${op_package_list} | ||
| 44 | + ) | ||
| 45 | + endif() | ||
| 46 | + | ||
| 47 | + set(custom_proto_target "${PACK_CUSTOM_NAME}_ascendc_cust_op_proto") | ||
| 48 | + if(TARGET ${custom_proto_target}) | ||
| 49 | + set_target_properties(${custom_proto_target} PROPERTIES | ||
| 50 | + INSTALL_RPATH "\$ORIGIN/../../../es/lib/linux/${CMAKE_SYSTEM_PROCESSOR}" | ||
| 51 | + ) | ||
| 52 | + endif() | ||
| 45 | endfunction() | 53 | endfunction() |
| 46 | 54 | ||
| 47 | macro(INSTALL_SCRIPTS src_path) | 55 | macro(INSTALL_SCRIPTS src_path) |
| @@ -62,60 +70,49 @@ endmacro() | |||
| 62 | function(pack_built_in) | 70 | function(pack_built_in) |
| 63 | # 打印路径 | 71 | # 打印路径 |
| 64 | message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}") | 72 | message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}") |
| 65 | - message(STATUS "CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}") | 73 | + message(STATUS "CANN_CMAKE_DIR = ${CANN_CMAKE_DIR}") |
| 66 | message(STATUS "CMAKE_BINARY_DIR = ${CMAKE_BINARY_DIR}") | 74 | message(STATUS "CMAKE_BINARY_DIR = ${CMAKE_BINARY_DIR}") |
| 67 | 75 | ||
| 68 | set(script_prefix ${CMAKE_CURRENT_SOURCE_DIR}/scripts/package/ops_ras/scripts) | 76 | set(script_prefix ${CMAKE_CURRENT_SOURCE_DIR}/scripts/package/ops_ras/scripts) |
| 69 | INSTALL_SCRIPTS(${script_prefix}) | 77 | INSTALL_SCRIPTS(${script_prefix}) |
| 70 | 78 | ||
| 71 | set(SCRIPTS_FILES | 79 | set(SCRIPTS_FILES |
| 72 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/check_version_required.awk | 80 | + ${CANN_CMAKE_DIR}/scripts/install/check_version_required.awk |
| 73 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/common_func.inc | 81 | + ${CANN_CMAKE_DIR}/scripts/install/common_func.inc |
| 74 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/common_interface.sh | 82 | + ${CANN_CMAKE_DIR}/scripts/install/common_interface.sh |
| 75 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/common_interface.csh | 83 | + ${CANN_CMAKE_DIR}/scripts/install/common_interface.csh |
| 76 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/common_interface.fish | 84 | + ${CANN_CMAKE_DIR}/scripts/install/common_interface.fish |
| 77 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/version_compatiable.inc | 85 | + ${CANN_CMAKE_DIR}/scripts/install/version_compatiable.inc |
| 78 | ) | 86 | ) |
| 79 | 87 | ||
| 80 | install(FILES ${SCRIPTS_FILES} | 88 | install(FILES ${SCRIPTS_FILES} |
| 81 | DESTINATION share/info/ops_ras/script | 89 | DESTINATION share/info/ops_ras/script |
| 82 | ) | 90 | ) |
| 83 | set(COMMON_FILES | 91 | set(COMMON_FILES |
| 84 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/install_common_parser.sh | 92 | + ${CANN_CMAKE_DIR}/scripts/install/install_common_parser.sh |
| 85 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/common_func_v2.inc | 93 | + ${CANN_CMAKE_DIR}/scripts/install/common_func_v2.inc |
| 86 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/common_installer.inc | 94 | + ${CANN_CMAKE_DIR}/scripts/install/common_installer.inc |
| 87 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/script_operator.inc | 95 | + ${CANN_CMAKE_DIR}/scripts/install/script_operator.inc |
| 88 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/version_cfg.inc | 96 | + ${CANN_CMAKE_DIR}/scripts/install/version_cfg.inc |
| 89 | ) | 97 | ) |
| 90 | 98 | ||
| 91 | set(PACKAGE_FILES | 99 | set(PACKAGE_FILES |
| 92 | ${COMMON_FILES} | 100 | ${COMMON_FILES} |
| 93 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/multi_version.inc | 101 | + ${CANN_CMAKE_DIR}/scripts/install/multi_version.inc |
| 94 | - ) | ||
| 95 | - set(LATEST_MANGER_FILES | ||
| 96 | - ${COMMON_FILES} | ||
| 97 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/common_func.inc | ||
| 98 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/version_compatiable.inc | ||
| 99 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/sh/check_version_required.awk | ||
| 100 | ) | 102 | ) |
| 101 | set(CONF_FILES | 103 | set(CONF_FILES |
| 102 | - ${CMAKE_SOURCE_DIR}/scripts/package/common/cfg/path.cfg | 104 | + ${CANN_CMAKE_DIR}/scripts/package/cfg/path.cfg |
| 103 | ) | 105 | ) |
| 104 | - install(FILES ${CMAKE_SOURCE_DIR}/version.info | 106 | + install(FILES ${CMAKE_BINARY_DIR}/version.ops-ras.info |
| 105 | DESTINATION share/info/ops_ras | 107 | DESTINATION share/info/ops_ras |
| 108 | + RENAME version.info | ||
| 106 | ) | 109 | ) |
| 107 | install(FILES ${CONF_FILES} | 110 | install(FILES ${CONF_FILES} |
| 108 | - DESTINATION ops_ras/conf | 111 | + DESTINATION ${CMAKE_SYSTEM_PROCESSOR}-linux/conf |
| 109 | ) | 112 | ) |
| 110 | install(FILES ${PACKAGE_FILES} | 113 | install(FILES ${PACKAGE_FILES} |
| 111 | DESTINATION share/info/ops_ras/script | 114 | DESTINATION share/info/ops_ras/script |
| 112 | ) | 115 | ) |
| 113 | - install(FILES ${LATEST_MANGER_FILES} | ||
| 114 | - DESTINATION latest_manager | ||
| 115 | - ) | ||
| 116 | - install(DIRECTORY ${CMAKE_SOURCE_DIR}/scripts/package/latest_manager/scripts/ | ||
| 117 | - DESTINATION latest_manager | ||
| 118 | - ) | ||
| 119 | 116 | ||
| 120 | string(FIND "${ASCEND_COMPUTE_UNIT}" ";" SEMICOLON_INDEX) | 117 | string(FIND "${ASCEND_COMPUTE_UNIT}" ";" SEMICOLON_INDEX) |
| 121 | if (SEMICOLON_INDEX GREATER -1) | 118 | if (SEMICOLON_INDEX GREATER -1) |
| @@ -131,28 +128,19 @@ function(pack_built_in) | |||
| 131 | set(script_with_soc_prefix ${CMAKE_CURRENT_SOURCE_DIR}/scripts/package/ops_ras/scripts) | 128 | set(script_with_soc_prefix ${CMAKE_CURRENT_SOURCE_DIR}/scripts/package/ops_ras/scripts) |
| 132 | INSTALL_SCRIPTS(${script_with_soc_prefix}) | 129 | INSTALL_SCRIPTS(${script_with_soc_prefix}) |
| 133 | 130 | ||
| 131 | + # 打包可选的 cann_ops_ras whl;PR8 未落地时安全跳过。 | ||
| 132 | + set(WHL_SOURCE_DIR "${CMAKE_SOURCE_DIR}/torch_extension/dist") | ||
| 133 | + file(GLOB WHL_FILES "${WHL_SOURCE_DIR}/cann_ops_ras-*.whl") | ||
| 134 | + | ||
| 135 | + if(WHL_FILES) | ||
| 136 | + install(FILES ${WHL_FILES} | ||
| 137 | + DESTINATION python/site-packages | ||
| 138 | + ) | ||
| 139 | + message(STATUS "Including whl package: ${WHL_FILES}") | ||
| 140 | + else() | ||
| 141 | + message(STATUS "Optional cann_ops_ras whl not found in ${WHL_SOURCE_DIR}, skipping") | ||
| 142 | + endif() | ||
| 143 | + | ||
| 134 | include(${CMAKE_SOURCE_DIR}/cmake/runtimeKB.cmake) | 144 | include(${CMAKE_SOURCE_DIR}/cmake/runtimeKB.cmake) |
| 135 | - | 145 | + set_cann_cpack_config(ops-ras ENABLE_DEVICE ${ENABLE_DEVICE} COMPUTE_UNIT ${ASCEND_COMPUTE_UNIT} SHARE_INFO_NAME ops_ras) |
| 136 | - # ============= CPack ============= | 146 | +endfunction() |
| 137 | - set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") | ||
| 138 | - set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") | ||
| 139 | - set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}") | ||
| 140 | - | ||
| 141 | - set(CPACK_INSTALL_PREFIX "/") | ||
| 142 | - | ||
| 143 | - set(CPACK_CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}") | ||
| 144 | - set(CPACK_CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}") | ||
| 145 | - set(CPACK_CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") | ||
| 146 | - set(CPACK_CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") | ||
| 147 | - set(CPACK_MAKESELF_PATH "${MAKESELF_PATH}") | ||
| 148 | - set(CPACK_SOC "${compute_unit}") | ||
| 149 | - set(CPACK_ARCH "${ARCH}") | ||
| 150 | - set(CPACK_SET_DESTDIR ON) | ||
| 151 | - set(CPACK_GENERATOR External) | ||
| 152 | - set(CPACK_EXTERNAL_PACKAGE_SCRIPT "${CMAKE_SOURCE_DIR}/cmake/makeself_built_in.cmake") | ||
| 153 | - set(CPACK_EXTERNAL_ENABLE_STAGING true) | ||
| 154 | - set(CPACK_PACKAGE_DIRECTORY "${CMAKE_INSTALL_PREFIX}") | ||
| 155 | - | ||
| 156 | - message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}") | ||
| 157 | - include(CPack) | ||
| 158 | -endfunction() | ||
| @@ -1,10 +1,10 @@ | |||
| 1 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | -# This file is a part of the CANN Open Software. | 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). |
| 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 10 | #### CPACK runtime kb to package run ##### | 10 | #### CPACK runtime kb to package run ##### |
| @@ -36,4 +36,4 @@ foreach(RTKB_DATA_FILE ${RTKB_FILE_ALL}) | |||
| 36 | DESTINATION ${OPS_RTKB_DIR}/${fileSocPath}/unified_bank | 36 | DESTINATION ${OPS_RTKB_DIR}/${fileSocPath}/unified_bank |
| 37 | OPTIONAL | 37 | OPTIONAL |
| 38 | ) | 38 | ) |
| 39 | -endforeach() | 39 | +endforeach() |
| @@ -1,10 +1,10 @@ | |||
| 1 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | -# This file is a part of the CANN Open Software. | 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). |
| 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 10 | if (TARGET ${OPHOST_NAME}_infer_obj OR TARGET ${OPHOST_NAME}_tiling_obj OR TARGET ${OPHOST_NAME}_aicpu_objs) | 10 | if (TARGET ${OPHOST_NAME}_infer_obj OR TARGET ${OPHOST_NAME}_tiling_obj OR TARGET ${OPHOST_NAME}_aicpu_objs) |
| @@ -13,6 +13,9 @@ if (TARGET ${OPHOST_NAME}_infer_obj OR TARGET ${OPHOST_NAME}_tiling_obj OR TARGE | |||
| 13 | $<$<TARGET_EXISTS:${OPHOST_NAME}_infer_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_infer_obj>> | 13 | $<$<TARGET_EXISTS:${OPHOST_NAME}_infer_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_infer_obj>> |
| 14 | $<$<TARGET_EXISTS:${OPHOST_NAME}_tiling_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_tiling_obj>> | 14 | $<$<TARGET_EXISTS:${OPHOST_NAME}_tiling_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_tiling_obj>> |
| 15 | $<$<TARGET_EXISTS:${OPHOST_NAME}_aicpu_objs>:$<TARGET_OBJECTS:${OPHOST_NAME}_aicpu_objs>> | 15 | $<$<TARGET_EXISTS:${OPHOST_NAME}_aicpu_objs>:$<TARGET_OBJECTS:${OPHOST_NAME}_aicpu_objs>> |
| 16 | + $<$<TARGET_EXISTS:opbase_util_objs>:$<TARGET_OBJECTS:opbase_util_objs>> | ||
| 17 | + $<$<TARGET_EXISTS:opbase_infer_objs>:$<TARGET_OBJECTS:opbase_infer_objs>> | ||
| 18 | + $<$<TARGET_EXISTS:opbase_tiling_objs>:$<TARGET_OBJECTS:opbase_tiling_objs>> | ||
| 16 | ) | 19 | ) |
| 17 | add_custom_command(TARGET ${OPHOST_NAME}_static | 20 | add_custom_command(TARGET ${OPHOST_NAME}_static |
| 18 | POST_BUILD | 21 | POST_BUILD |
| @@ -26,12 +29,13 @@ if (TARGET ${OPHOST_NAME}_infer_obj OR TARGET ${OPHOST_NAME}_tiling_obj OR TARGE | |||
| 26 | c_sec | 29 | c_sec |
| 27 | -Wl,--no-as-needed | 30 | -Wl,--no-as-needed |
| 28 | register | 31 | register |
| 29 | - $<$<TARGET_EXISTS:opsbase>:opsbase> | ||
| 30 | -Wl,--as-needed | 32 | -Wl,--as-needed |
| 31 | -Wl,--whole-archive | 33 | -Wl,--whole-archive |
| 32 | rt2_registry_static | 34 | rt2_registry_static |
| 33 | tiling_api | 35 | tiling_api |
| 34 | -Wl,--no-whole-archive | 36 | -Wl,--no-whole-archive |
| 37 | + unified_dlog | ||
| 38 | + ascendalog | ||
| 35 | ) | 39 | ) |
| 36 | endif() | 40 | endif() |
| 37 | 41 | ||
| @@ -62,7 +66,7 @@ foreach(compute_unit ${ASCEND_COMPUTE_UNIT}) | |||
| 62 | set(RESOURCE_PATH ${CMAKE_BINARY_DIR}/autogen/${compute_unit}/aclnnop_resource) | 66 | set(RESOURCE_PATH ${CMAKE_BINARY_DIR}/autogen/${compute_unit}/aclnnop_resource) |
| 63 | file(GLOB RESOURCE_CPP ${RESOURCE_PATH}/*.cpp) | 67 | file(GLOB RESOURCE_CPP ${RESOURCE_PATH}/*.cpp) |
| 64 | set_source_files_properties(${RESOURCE_CPP} PROPERTIES GENERATED TRUE) | 68 | set_source_files_properties(${RESOURCE_CPP} PROPERTIES GENERATED TRUE) |
| 65 | - add_library(resource_${compute_unit}_static STATIC | 69 | + add_library(resource_${compute_unit}_static STATIC |
| 66 | $<$<TARGET_EXISTS:${OPHOST_NAME}_infer_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_infer_obj>> | 70 | $<$<TARGET_EXISTS:${OPHOST_NAME}_infer_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_infer_obj>> |
| 67 | $<$<TARGET_EXISTS:${OPHOST_NAME}_tiling_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_tiling_obj>> | 71 | $<$<TARGET_EXISTS:${OPHOST_NAME}_tiling_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_tiling_obj>> |
| 68 | $<$<TARGET_EXISTS:${OPHOST_NAME}_aicpu_objs>:$<TARGET_OBJECTS:${OPHOST_NAME}_aicpu_objs>> | 72 | $<$<TARGET_EXISTS:${OPHOST_NAME}_aicpu_objs>:$<TARGET_OBJECTS:${OPHOST_NAME}_aicpu_objs>> |
| @@ -1,36 +1,35 @@ | |||
| 1 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | -# This file is a part of the CANN Open Software. | 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). |
| 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 10 | # ophost shared | 10 | # ophost shared |
| 11 | function(gen_ophost_symbol) | 11 | function(gen_ophost_symbol) |
| 12 | if (NOT TARGET ${OPHOST_NAME}_infer_obj AND NOT TARGET ${OPHOST_NAME}_tiling_obj AND NOT TARGET ${OPHOST_NAME}_aicpu_objs) | 12 | if (NOT TARGET ${OPHOST_NAME}_infer_obj AND NOT TARGET ${OPHOST_NAME}_tiling_obj AND NOT TARGET ${OPHOST_NAME}_aicpu_objs) |
| 13 | + message(STATUS "No RAS infer/tiling/AICPU host sources found, skipping ${OPHOST_NAME}.") | ||
| 13 | return() | 14 | return() |
| 14 | endif() | 15 | endif() |
| 15 | - add_library( | 16 | + npu_op_library(${OPHOST_NAME}_obj TILING) |
| 16 | - ${OPHOST_NAME} SHARED | 17 | + target_sources(${OPHOST_NAME}_obj PUBLIC |
| 17 | $<$<TARGET_EXISTS:${OPHOST_NAME}_infer_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_infer_obj>> | 18 | $<$<TARGET_EXISTS:${OPHOST_NAME}_infer_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_infer_obj>> |
| 18 | $<$<TARGET_EXISTS:${OPHOST_NAME}_tiling_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_tiling_obj>> | 19 | $<$<TARGET_EXISTS:${OPHOST_NAME}_tiling_obj>:$<TARGET_OBJECTS:${OPHOST_NAME}_tiling_obj>> |
| 19 | $<$<TARGET_EXISTS:${OPHOST_NAME}_aicpu_objs>:$<TARGET_OBJECTS:${OPHOST_NAME}_aicpu_objs>> | 20 | $<$<TARGET_EXISTS:${OPHOST_NAME}_aicpu_objs>:$<TARGET_OBJECTS:${OPHOST_NAME}_aicpu_objs>> |
| 21 | + $<$<TARGET_EXISTS:opbase_util_objs>:$<TARGET_OBJECTS:opbase_util_objs>> | ||
| 22 | + $<$<TARGET_EXISTS:opbase_infer_objs>:$<TARGET_OBJECTS:opbase_infer_objs>> | ||
| 23 | + $<$<TARGET_EXISTS:opbase_tiling_objs>:$<TARGET_OBJECTS:opbase_tiling_objs>> | ||
| 20 | ) | 24 | ) |
| 21 | - | 25 | + add_library(${OPHOST_NAME} SHARED $<TARGET_OBJECTS:${OPHOST_NAME}_obj>) |
| 22 | target_link_libraries( | 26 | target_link_libraries( |
| 23 | ${OPHOST_NAME} | 27 | ${OPHOST_NAME} |
| 24 | PRIVATE $<BUILD_INTERFACE:intf_pub_cxx17> | 28 | PRIVATE $<BUILD_INTERFACE:intf_pub_cxx17> |
| 25 | - c_sec | 29 | + ${OPHOST_NAME}_obj |
| 26 | -Wl,--no-as-needed | 30 | -Wl,--no-as-needed |
| 27 | - register | 31 | + acl_rt |
| 28 | - $<$<TARGET_EXISTS:opsbase>:opsbase> | ||
| 29 | -Wl,--as-needed | 32 | -Wl,--as-needed |
| 30 | - -Wl,--whole-archive | ||
| 31 | - rt2_registry_static | ||
| 32 | - tiling_api | ||
| 33 | - -Wl,--no-whole-archive | ||
| 34 | -Wl,-Bsymbolic | 33 | -Wl,-Bsymbolic |
| 35 | $<$<CONFIG:RELEASE>:-s> | 34 | $<$<CONFIG:RELEASE>:-s> |
| 36 | ) | 35 | ) |
| @@ -1,59 +0,0 @@ | |||
| 1 | -# ---------------------------------------------------------------------------- | ||
| 2 | -# This program is free software, you can redistribute it and/or modify it. | ||
| 3 | -# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 4 | -# This file is a part of the CANN Open Software. | ||
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | -# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | -# ---------------------------------------------------------------------------- | ||
| 10 | - | ||
| 11 | -include(ExternalProject) | ||
| 12 | -set(ABSEIL_VERSION_PKG abseil-cpp-20230802.1.tar.gz) | ||
| 13 | - | ||
| 14 | -unset(abseil-cpp_FOUND CACHE) | ||
| 15 | -unset(ABSL_SOURCE_DIR CACHE) | ||
| 16 | - | ||
| 17 | -find_path(ABSL_SOURCE_DIR | ||
| 18 | - NAMES absl/log/absl_log.h | ||
| 19 | - NO_CMAKE_SYSTEM_PATH | ||
| 20 | - NO_CMAKE_FIND_ROOT_PATH | ||
| 21 | - PATHS ${PROJECT_SOURCE_DIR}/third_party/abseil-cpp) | ||
| 22 | - | ||
| 23 | -include(FindPackageHandleStandardArgs) | ||
| 24 | -find_package_handle_standard_args(abseil-cpp | ||
| 25 | - FOUND_VAR | ||
| 26 | - abseil-cpp_FOUND | ||
| 27 | - REQUIRED_VARS | ||
| 28 | - ABSL_SOURCE_DIR) | ||
| 29 | - | ||
| 30 | -set(ABSEIL_SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/abseil-cpp) | ||
| 31 | -if(abseil-cpp_FOUND) | ||
| 32 | - message(STATUS "Found abseil-cpp in ${CANN_3RD_LIB_PATH}/abseil-cpp") | ||
| 33 | -else() | ||
| 34 | - # 初始化可选参数列表 | ||
| 35 | - if(EXISTS "${CANN_3RD_LIB_PATH}/abseil-cpp/${ABSEIL_VERSION_PKG}") | ||
| 36 | - set(REQ_URL "file://${CANN_3RD_LIB_PATH}/abseil-cpp/${ABSEIL_VERSION_PKG}") | ||
| 37 | - message(STATUS "[ThirdPartyLib][abseil-cpp] found in ${REQ_URL}.") | ||
| 38 | - elseif(EXISTS "${CANN_3RD_LIB_PATH}/pkg/${ABSEIL_VERSION_PKG}") | ||
| 39 | - set(REQ_URL "file://${CANN_3RD_LIB_PATH}/pkg/${ABSEIL_VERSION_PKG}") | ||
| 40 | - message(STATUS "[ThirdPartyLib][abseil-cpp] found in ${REQ_URL}.") | ||
| 41 | - else() | ||
| 42 | - set(REQ_URL "https://gitcode.com/cann-src-third-party/abseil-cpp/releases/download/20230802.1/abseil-cpp-20230802.1.tar.gz") | ||
| 43 | - message(STATUS "[ThirdPartyLib][abseil-cpp] ${REQ_URL} not found, need download.") | ||
| 44 | - endif() | ||
| 45 | - | ||
| 46 | - ExternalProject_Add(abseil_build_ras | ||
| 47 | - URL ${REQ_URL} | ||
| 48 | - DOWNLOAD_DIR ${CANN_3RD_LIB_PATH}/pkg | ||
| 49 | - PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_LIST_DIR}/build/modules/patch/protobuf-hide_absl_symbols.patch | ||
| 50 | - SOURCE_DIR ${ABSEIL_SOURCE_DIR} | ||
| 51 | - CONFIGURE_COMMAND "" | ||
| 52 | - BUILD_COMMAND "" | ||
| 53 | - INSTALL_COMMAND "" | ||
| 54 | - EXCLUDE_FROM_ALL TRUE | ||
| 55 | - ) | ||
| 56 | - | ||
| 57 | - ExternalProject_Get_Property(abseil_build_ras SOURCE_DIR) | ||
| 58 | - set(ABSL_SOURCE_DIR ${SOURCE_DIR}) | ||
| 59 | -endif() | ||
| @@ -1,89 +0,0 @@ | |||
| 1 | -# ---------------------------------------------------------------------------------------------------------- | ||
| 2 | -# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | -# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | -# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | -# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | -# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | -# ---------------------------------------------------------------------------------------------------------- | ||
| 10 | -include(ExternalProject) | ||
| 11 | -set(PROTOBUF_VERSION_PKG protobuf-25.1.tar.gz) | ||
| 12 | -set(ASCEND_PROTOBUF_DIR ${CANN_3RD_LIB_PATH}/ascend_protobuf) | ||
| 13 | - | ||
| 14 | -include(FindPackageHandleStandardArgs) | ||
| 15 | -find_package_handle_standard_args(ascend_protobuf_build_ras | ||
| 16 | - FOUND_VAR | ||
| 17 | - ascend_protobuf_build_ras_FOUND | ||
| 18 | - REQUIRED_VARS | ||
| 19 | - ASCEND_PROTOBUF_SHARED_INCLUDE | ||
| 20 | -) | ||
| 21 | - | ||
| 22 | -set(ASCEND_PROTOBUF_SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/ascend_protobuf) | ||
| 23 | -if(ascend_protobuf_build_ras_FOUND AND NOT FORCE_REBUILD_CANN_3RD) | ||
| 24 | - message(STATUS "[ThirdPartyLib][ascend protobuf] ascend_protobuf_shared found, skip compile.") | ||
| 25 | - cmake_print_variables(ASCEND_PROTOBUF_SHARED_INCLUDE) | ||
| 26 | - cmake_print_variables(ASCEND_PROTOC) | ||
| 27 | - set(Protobuf_INCLUDE ${ASCEND_PROTOBUF_SHARED_INCLUDE}) | ||
| 28 | - set(Protobuf_PATH ${ASCEND_PROTOC}) | ||
| 29 | - set(Protobuf_PROTOC_EXECUTABLE ${Protobuf_PATH}/protoc) | ||
| 30 | - add_library(ascend_protobuf_build_ras INTERFACE) | ||
| 31 | -else() | ||
| 32 | - message(STATUS "[ThirdPartyLib][ascend protobuf] ascend protobuf shared not found, finding binary file.") | ||
| 33 | - if(EXISTS "${CANN_3RD_LIB_PATH}/protobuf/protobuf-all-25.1.tar.gz") | ||
| 34 | - set(REQ_URL "file://${CANN_3RD_LIB_PATH}/protobuf/protobuf-all-25.1.tar.gz") | ||
| 35 | - message(STATUS "[ThirdPartyLib][ascend protobuf] found in ${REQ_URL}.") | ||
| 36 | - elseif(EXISTS "${CANN_3RD_LIB_PATH}/pkg/${PROTOBUF_VERSION_PKG}") | ||
| 37 | - set(REQ_URL "file://${CANN_3RD_LIB_PATH}/pkg/${PROTOBUF_VERSION_PKG}") | ||
| 38 | - message(STATUS "[ThirdPartyLib][ascend protobuf] found in ${REQ_URL}.") | ||
| 39 | - else() | ||
| 40 | - set(REQ_URL "https://gitcode.com/cann-src-third-party/protobuf/releases/download/v25.1/protobuf-25.1.tar.gz") | ||
| 41 | - message(STATUS "[ThirdPartyLib][ascend protobuf] ${REQ_URL} not found, need download.") | ||
| 42 | - endif() | ||
| 43 | - | ||
| 44 | - 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") | ||
| 45 | - set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | ||
| 46 | - | ||
| 47 | - ExternalProject_Add(ascend_protobuf_build_ras | ||
| 48 | - URL ${REQ_URL} | ||
| 49 | - DOWNLOAD_DIR ${CANN_3RD_LIB_PATH}/pkg | ||
| 50 | - PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_LIST_DIR}/build/modules/patch/protobuf_25.1_change_version.patch | ||
| 51 | - CONFIGURE_COMMAND ${CMAKE_COMMAND} | ||
| 52 | - -DCMAKE_MESSAGE_LOG_LEVEL=ERROR | ||
| 53 | - -DCMAKE_INSTALL_LIBDIR=lib | ||
| 54 | - -Dprotobuf_WITH_ZLIB=OFF | ||
| 55 | - -DLIB_PREFIX=ascend_ | ||
| 56 | - -DCMAKE_SKIP_RPATH=TRUE | ||
| 57 | - -Dprotobuf_BUILD_TESTS=OFF | ||
| 58 | - -DBUILD_SHARED_LIBS=OFF | ||
| 59 | - -DCMAKE_CXX_STANDARD=14 | ||
| 60 | - -DCMAKE_CXX_FLAGS=${protobuf_CXXFLAGS} | ||
| 61 | - -DCMAKE_CXX_LDFLAGS=${protobuf_LDFLAGS} | ||
| 62 | - -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} | ||
| 63 | - -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} | ||
| 64 | - -DCMAKE_INSTALL_PREFIX=${ASCEND_PROTOBUF_DIR} | ||
| 65 | - -Dprotobuf_BUILD_PROTOC_BINARIES=ON | ||
| 66 | - -Dprotobuf_ABSL_PROVIDER=module | ||
| 67 | - -DABSL_ROOT_DIR=${ABSL_SOURCE_DIR} | ||
| 68 | - <SOURCE_DIR> | ||
| 69 | - SOURCE_DIR ${ASCEND_PROTOBUF_SOURCE_DIR} | ||
| 70 | - BUILD_COMMAND $(MAKE) | ||
| 71 | - INSTALL_COMMAND "" | ||
| 72 | - EXCLUDE_FROM_ALL TRUE | ||
| 73 | - ) | ||
| 74 | - if(TARGET abseil_build_ras) | ||
| 75 | - add_dependencies(ascend_protobuf_build_ras abseil_build_ras) | ||
| 76 | - endif() | ||
| 77 | - | ||
| 78 | - ExternalProject_Get_Property(ascend_protobuf_build_ras SOURCE_DIR) | ||
| 79 | - ExternalProject_Get_Property(ascend_protobuf_build_ras BINARY_DIR) | ||
| 80 | - | ||
| 81 | - set(Protobuf_INCLUDE ${SOURCE_DIR}/src) | ||
| 82 | - set(Protobuf_PATH ${BINARY_DIR}) | ||
| 83 | - set(Protobuf_PROTOC_EXECUTABLE ${Protobuf_PATH}/protoc) | ||
| 84 | - | ||
| 85 | - add_custom_command( | ||
| 86 | - OUTPUT ${Protobuf_PROTOC_EXECUTABLE} | ||
| 87 | - DEPENDS ascend_protobuf_build_ras | ||
| 88 | - ) | ||
| 89 | -endif() | ||
| @@ -1,61 +0,0 @@ | |||
| 1 | -diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
| 2 | -index eef6626..c054264 100644 | ||
| 3 | ---- a/CMakeLists.txt | ||
| 4 | -+++ b/CMakeLists.txt | ||
| 5 | -@@ -18,6 +18,9 @@ | ||
| 6 | - # As of 2022-09-06, CMake 3.10 is the minimum supported version. | ||
| 7 | - cmake_minimum_required(VERSION 3.10) | ||
| 8 | - | ||
| 9 | -+# NOTICE: force using static libraries | ||
| 10 | -+set(BUILD_SHARED_LIBS OFF) | ||
| 11 | -+ | ||
| 12 | - # Compiler id for Apple Clang is now AppleClang. | ||
| 13 | - if (POLICY CMP0025) | ||
| 14 | - cmake_policy(SET CMP0025 NEW) | ||
| 15 | -@@ -219,6 +222,7 @@ if(ABSL_ENABLE_INSTALL) | ||
| 16 | - PATTERN "*.h" | ||
| 17 | - PATTERN "copts" EXCLUDE | ||
| 18 | - PATTERN "testdata" EXCLUDE | ||
| 19 | -+ PATTERN "options.h" EXCLUDE | ||
| 20 | - ) | ||
| 21 | - | ||
| 22 | - file(READ "absl/base/options.h" ABSL_INTERNAL_OPTIONS_H_CONTENTS) | ||
| 23 | -diff --git a/absl/base/options.h b/absl/base/options.h | ||
| 24 | -index f308e1b..09617e0 100644 | ||
| 25 | ---- a/absl/base/options.h | ||
| 26 | -+++ b/absl/base/options.h | ||
| 27 | -@@ -200,7 +200,7 @@ | ||
| 28 | - // allowed. | ||
| 29 | - | ||
| 30 | - #define ABSL_OPTION_USE_INLINE_NAMESPACE 1 | ||
| 31 | --#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_20230802 | ||
| 32 | -+#define ABSL_OPTION_INLINE_NAMESPACE_NAME lts_ascend_private | ||
| 33 | - | ||
| 34 | - // ABSL_OPTION_HARDENED | ||
| 35 | - // | ||
| 36 | -diff --git a/absl/hash/internal/hash.cc b/absl/hash/internal/hash.cc | ||
| 37 | -index 11451e5..75886d3 100644 | ||
| 38 | ---- a/absl/hash/internal/hash.cc | ||
| 39 | -+++ b/absl/hash/internal/hash.cc | ||
| 40 | -@@ -44,7 +44,7 @@ uint64_t MixingHashState::CombineLargeContiguousImpl64( | ||
| 41 | - std::integral_constant<int, 8>{}); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | --ABSL_CONST_INIT const void* const MixingHashState::kSeed = &kSeed; | ||
| 45 | -+ABSL_CONST_INIT const void* const MixingHashState::kSeed = 0; | ||
| 46 | - | ||
| 47 | - // The salt array used by LowLevelHash. This array is NOT the mechanism used to | ||
| 48 | - // make absl::Hash non-deterministic between program invocations. See `Seed()` | ||
| 49 | -diff --git a/absl/hash/internal/hash.h b/absl/hash/internal/hash.h | ||
| 50 | -index ef3f366..7714cdb 100644 | ||
| 51 | ---- a/absl/hash/internal/hash.h | ||
| 52 | -+++ b/absl/hash/internal/hash.h | ||
| 53 | -@@ -1159,7 +1159,7 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> { | ||
| 54 | - #if (!defined(__clang__) || __clang_major__ > 11) && \ | ||
| 55 | - (!defined(__apple_build_version__) || \ | ||
| 56 | - __apple_build_version__ >= 19558921) // Xcode 12 | ||
| 57 | -- return static_cast<uint64_t>(reinterpret_cast<uintptr_t>(&kSeed)); | ||
| 58 | -+ return static_cast<uint64_t>(reinterpret_cast<uintptr_t>(kSeed)); | ||
| 59 | - #else | ||
| 60 | - // Workaround the absence of | ||
| 61 | - // https://github.com/llvm/llvm-project/commit/bc15bf66dcca76cc06fe71fca35b74dc4d521021. | ||
| @@ -1,357 +0,0 @@ | |||
| 1 | -diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
| 2 | -index 4137ce2..1d9e1ca 100644 | ||
| 3 | ---- a/CMakeLists.txt | ||
| 4 | -+++ b/CMakeLists.txt | ||
| 5 | -@@ -79,7 +79,7 @@ if (protobuf_BUILD_SHARED_LIBS) | ||
| 6 | - endif () | ||
| 7 | - | ||
| 8 | - # Version metadata | ||
| 9 | --set(protobuf_VERSION_STRING "4.25.1") | ||
| 10 | -+set(protobuf_VERSION_STRING "3.13.0") | ||
| 11 | - set(protobuf_DESCRIPTION "Protocol Buffers") | ||
| 12 | - set(protobuf_CONTACT "protobuf@googlegroups.com") | ||
| 13 | - | ||
| 14 | -@@ -105,7 +105,7 @@ message(STATUS "${protobuf_VERSION_PRERELEASE}") | ||
| 15 | - | ||
| 16 | - # Package version | ||
| 17 | - set(protobuf_VERSION | ||
| 18 | -- "${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}") | ||
| 19 | -+ "${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}") | ||
| 20 | - | ||
| 21 | - if(protobuf_VERSION_PRERELEASE) | ||
| 22 | - set(protobuf_VERSION "${protobuf_VERSION}.${protobuf_VERSION_PRERELEASE}") | ||
| 23 | -@@ -122,30 +122,6 @@ if(protobuf_VERBOSE) | ||
| 24 | - message(STATUS "]") | ||
| 25 | - endif() | ||
| 26 | - | ||
| 27 | --file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map | ||
| 28 | --"{ | ||
| 29 | -- global: | ||
| 30 | -- main; | ||
| 31 | -- local: | ||
| 32 | -- *; | ||
| 33 | --};") | ||
| 34 | --# CheckLinkerFlag module available in CMake >=3.18. | ||
| 35 | --if(${CMAKE_VERSION} VERSION_GREATER 3.18 OR ${CMAKE_VERSION} VERSION_EQUAL 3.18) | ||
| 36 | -- include(CheckLinkerFlag) | ||
| 37 | -- check_linker_flag(CXX -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map protobuf_HAVE_LD_VERSION_SCRIPT) | ||
| 38 | --else() | ||
| 39 | -- include(CheckCXXSourceCompiles) | ||
| 40 | -- set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) | ||
| 41 | -- set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map) | ||
| 42 | -- check_cxx_source_compiles(" | ||
| 43 | -- int main() { | ||
| 44 | -- return 0; | ||
| 45 | -- } | ||
| 46 | -- " protobuf_HAVE_LD_VERSION_SCRIPT) | ||
| 47 | -- set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS}) | ||
| 48 | --endif() | ||
| 49 | --file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map) | ||
| 50 | -- | ||
| 51 | - find_package(Threads REQUIRED) | ||
| 52 | - | ||
| 53 | - # We can install dependencies from submodules if we're running | ||
| 54 | -diff --git a/src/google/protobuf/arenastring.cc b/src/google/protobuf/arenastring.cc | ||
| 55 | -index bf9d0bb..0e4f450 100644 | ||
| 56 | ---- a/src/google/protobuf/arenastring.cc | ||
| 57 | -+++ b/src/google/protobuf/arenastring.cc | ||
| 58 | -@@ -11,6 +11,7 @@ | ||
| 59 | - | ||
| 60 | - #include "absl/log/absl_check.h" | ||
| 61 | - #include "absl/strings/string_view.h" | ||
| 62 | -+#include "absl/strings/escaping.h" | ||
| 63 | - #include "absl/synchronization/mutex.h" | ||
| 64 | - #include "google/protobuf/io/coded_stream.h" | ||
| 65 | - #include "google/protobuf/message_lite.h" | ||
| 66 | -@@ -116,7 +117,7 @@ void ArenaStringPtr::Set(absl::string_view value, Arena* arena) { | ||
| 67 | - old->assign("garbagedata"); | ||
| 68 | - } | ||
| 69 | - #else // PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 70 | -- UnsafeMutablePointer()->assign(value.data(), value.length()); | ||
| 71 | -+ UnsafeMutablePointer()->assign(std::string(value.data(), value.length())); | ||
| 72 | - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 73 | - } | ||
| 74 | - } | ||
| 75 | -@@ -263,6 +264,30 @@ void ArenaStringPtr::ClearToDefault(const LazyString& default_value, | ||
| 76 | - } | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | -+void ArenaStringPtr::Set(EmptyDefault, const std::string& value, Arena* arena) { | ||
| 80 | -+ Set(value, arena); | ||
| 81 | -+} | ||
| 82 | -+ | ||
| 83 | -+void ArenaStringPtr::Set(EmptyDefault, absl::string_view value, Arena* arena) { | ||
| 84 | -+ Set(value, arena); | ||
| 85 | -+} | ||
| 86 | -+ | ||
| 87 | -+void ArenaStringPtr::Set(EmptyDefault, std::string&& value, Arena* arena) { | ||
| 88 | -+ Set(value, arena); | ||
| 89 | -+} | ||
| 90 | -+ | ||
| 91 | -+void ArenaStringPtr::Set(EmptyDefault, const char* s, Arena* arena) { | ||
| 92 | -+ Set(s, arena); | ||
| 93 | -+} | ||
| 94 | -+ | ||
| 95 | -+void ArenaStringPtr::Set(EmptyDefault, const char* s, size_t n, Arena* arena) { | ||
| 96 | -+ Set(s, n, arena); | ||
| 97 | -+} | ||
| 98 | -+ | ||
| 99 | -+void ArenaStringPtr::Set(EmptyDefault, const void* p, size_t n, Arena* arena) { | ||
| 100 | -+ Set(absl::string_view{static_cast<const char*>(p), n}, arena); | ||
| 101 | -+} | ||
| 102 | -+ | ||
| 103 | - const char* EpsCopyInputStream::ReadArenaString(const char* ptr, | ||
| 104 | - ArenaStringPtr* s, | ||
| 105 | - Arena* arena) { | ||
| 106 | -@@ -277,8 +302,11 @@ const char* EpsCopyInputStream::ReadArenaString(const char* ptr, | ||
| 107 | - GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); | ||
| 108 | - return ptr; | ||
| 109 | - } | ||
| 110 | -- | ||
| 111 | - } // namespace internal | ||
| 112 | -+ | ||
| 113 | -+std::string CEscape(const std::string &src) { | ||
| 114 | -+ return absl::CEscape(absl::string_view(src)); | ||
| 115 | -+} | ||
| 116 | - } // namespace protobuf | ||
| 117 | - } // namespace google | ||
| 118 | - | ||
| 119 | -diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h | ||
| 120 | -index dea2aec..ffe2343 100644 | ||
| 121 | ---- a/src/google/protobuf/arenastring.h | ||
| 122 | -+++ b/src/google/protobuf/arenastring.h | ||
| 123 | -@@ -19,6 +19,8 @@ | ||
| 124 | - #include "google/protobuf/arena.h" | ||
| 125 | - #include "google/protobuf/explicitly_constructed.h" | ||
| 126 | - #include "google/protobuf/port.h" | ||
| 127 | -+#include "absl/strings/string_view.h" | ||
| 128 | -+#include "absl/strings/escaping.h" | ||
| 129 | - | ||
| 130 | - // must be last: | ||
| 131 | - #include "google/protobuf/port_def.inc" | ||
| 132 | -@@ -298,7 +300,15 @@ struct PROTOBUF_EXPORT ArenaStringPtr { | ||
| 133 | - void Set(const std::string& value, Arena* arena); | ||
| 134 | - void Set(const char* s, Arena* arena); | ||
| 135 | - void Set(const char* s, size_t n, Arena* arena); | ||
| 136 | -- | ||
| 137 | -+ // Compatibility with undefined symbol modifications in opp_kernel packages compiled based on protobuf 3.14 | ||
| 138 | -+ struct EmptyDefault {}; | ||
| 139 | -+ void Set(EmptyDefault, const std::string& value, Arena* arena); | ||
| 140 | -+ void Set(EmptyDefault, absl::string_view value, Arena* arena); | ||
| 141 | -+ void Set(EmptyDefault, std::string&& value, Arena* arena); | ||
| 142 | -+ void Set(EmptyDefault, const char* s, Arena* arena); | ||
| 143 | -+ void Set(EmptyDefault, const char* s, size_t n, Arena* arena); | ||
| 144 | -+ void Set(EmptyDefault, const void* p, size_t n, Arena* arena); | ||
| 145 | -+ | ||
| 146 | - void SetBytes(absl::string_view value, Arena* arena); | ||
| 147 | - void SetBytes(std::string&& value, Arena* arena); | ||
| 148 | - template <typename... OverloadDisambiguator> | ||
| 149 | -@@ -528,9 +538,9 @@ inline std::string* ArenaStringPtr::UnsafeMutablePointer() { | ||
| 150 | - ABSL_DCHECK(tagged_ptr_.Get() != nullptr); | ||
| 151 | - return tagged_ptr_.Get(); | ||
| 152 | - } | ||
| 153 | -- | ||
| 154 | -- | ||
| 155 | - } // namespace internal | ||
| 156 | -+ | ||
| 157 | -+PROTOBUF_EXPORT std::string CEscape(const std::string& src); | ||
| 158 | - } // namespace protobuf | ||
| 159 | - } // namespace google | ||
| 160 | - | ||
| 161 | -diff --git a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc b/src/google/protobuf/compiler/cpp/field_generators/string_field.cc | ||
| 162 | -index 748a8d6..1834c39 100644 | ||
| 163 | ---- a/src/google/protobuf/compiler/cpp/field_generators/string_field.cc | ||
| 164 | -+++ b/src/google/protobuf/compiler/cpp/field_generators/string_field.cc | ||
| 165 | -@@ -347,7 +347,7 @@ void SingularString::ReleaseImpl(io::Printer* p) const { | ||
| 166 | - p->Emit(R"cc( | ||
| 167 | - auto* released = $field_$.Release(); | ||
| 168 | - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 169 | -- $field_$.Set("", $set_args$); | ||
| 170 | -+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, "", $set_args$); | ||
| 171 | - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 172 | - return released; | ||
| 173 | - )cc"); | ||
| 174 | -@@ -393,7 +393,7 @@ void SingularString::SetAllocatedImpl(io::Printer* p) const { | ||
| 175 | - p->Emit(R"cc( | ||
| 176 | - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 177 | - if ($field_$.IsDefault()) { | ||
| 178 | -- $field_$.Set("", $set_args$); | ||
| 179 | -+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, "", $set_args$); | ||
| 180 | - } | ||
| 181 | - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 182 | - )cc"); | ||
| 183 | -@@ -442,7 +442,7 @@ void SingularString::GenerateInlineAccessorDefinitions(io::Printer* p) const { | ||
| 184 | - $TsanDetectConcurrentMutation$; | ||
| 185 | - $PrepareSplitMessageForWrite$; | ||
| 186 | - $update_hasbit$; | ||
| 187 | -- $field_$.$Set$(static_cast<Arg_&&>(arg), args..., $set_args$); | ||
| 188 | -+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, static_cast<Arg_&&>(arg), args..., $set_args$); | ||
| 189 | - $annotate_set$; | ||
| 190 | - // @@protoc_insertion_point(field_set:$pkg.Msg.field$) | ||
| 191 | - } | ||
| 192 | -@@ -463,7 +463,7 @@ void SingularString::GenerateInlineAccessorDefinitions(io::Printer* p) const { | ||
| 193 | - $update_hasbit$; | ||
| 194 | - //~ Don't use $Set$ here; we always want the std::string variant | ||
| 195 | - //~ regardless of whether this is a `bytes` field. | ||
| 196 | -- $field_$.Set(value, $set_args$); | ||
| 197 | -+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, value, $set_args$); | ||
| 198 | - } | ||
| 199 | - inline std::string* $Msg$::_internal_mutable_$name$() { | ||
| 200 | - $TsanDetectConcurrentMutation$; | ||
| 201 | -@@ -599,7 +599,7 @@ void SingularString::GenerateConstructorCode(io::Printer* p) const { | ||
| 202 | - if (IsString(field_, *opts_) && EmptyDefault()) { | ||
| 203 | - p->Emit(R"cc( | ||
| 204 | - #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 205 | -- $field_$.Set("", GetArena()); | ||
| 206 | -+ $field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, "", GetArena()); | ||
| 207 | - #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | ||
| 208 | - )cc"); | ||
| 209 | - } | ||
| 210 | -@@ -636,7 +636,7 @@ void SingularString::GenerateCopyConstructorCode(io::Printer* p) const { | ||
| 211 | - }}}, | ||
| 212 | - R"cc( | ||
| 213 | - if ($hazzer$) { | ||
| 214 | -- _this->$field_$.Set(from._internal_$name$(), $set_args$); | ||
| 215 | -+ _this->$field_$.Set(::google::protobuf::internal::ArenaStringPtr::EmptyDefault{}, from._internal_$name$(), $set_args$); | ||
| 216 | - } | ||
| 217 | - )cc"); | ||
| 218 | - } | ||
| 219 | -diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc | ||
| 220 | -index 2c8d275..d0abac8 100644 | ||
| 221 | ---- a/src/google/protobuf/compiler/cpp/helpers.cc | ||
| 222 | -+++ b/src/google/protobuf/compiler/cpp/helpers.cc | ||
| 223 | -@@ -1706,8 +1706,7 @@ bool IsFileDescriptorProto(const FileDescriptor* file, const Options& options) { | ||
| 224 | - } | ||
| 225 | - | ||
| 226 | - bool ShouldGenerateClass(const Descriptor* descriptor, const Options& options) { | ||
| 227 | -- return !IsMapEntryMessage(descriptor) || | ||
| 228 | -- HasDescriptorMethods(descriptor->file(), options); | ||
| 229 | -+ return true; | ||
| 230 | - } | ||
| 231 | - | ||
| 232 | - } // namespace cpp | ||
| 233 | -diff --git a/src/google/protobuf/compiler/cpp/helpers.h b/src/google/protobuf/compiler/cpp/helpers.h | ||
| 234 | -index 9b74835..a1b6f58 100644 | ||
| 235 | ---- a/src/google/protobuf/compiler/cpp/helpers.h | ||
| 236 | -+++ b/src/google/protobuf/compiler/cpp/helpers.h | ||
| 237 | -@@ -1002,7 +1002,7 @@ inline bool ShouldGenerateExternSpecializations(const Options& options) { | ||
| 238 | - // Some compilers can't handle that much input in a single translation unit. | ||
| 239 | - // These specializations are just a link size optimization and do not affect | ||
| 240 | - // correctness or performance, so it is ok to omit them. | ||
| 241 | -- return !options.opensource_runtime; | ||
| 242 | -+ return true; | ||
| 243 | - } | ||
| 244 | - | ||
| 245 | - struct OneOfRangeImpl { | ||
| 246 | -diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc | ||
| 247 | -index af5c0b2..254e77c 100644 | ||
| 248 | ---- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc | ||
| 249 | -+++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc | ||
| 250 | -@@ -254,7 +254,7 @@ std::string GetFieldConstantName(const FieldDescriptor* field) { | ||
| 251 | - | ||
| 252 | - std::string GetPropertyName(const FieldDescriptor* descriptor) { | ||
| 253 | - // Names of members declared or overridden in the message. | ||
| 254 | -- static const auto& reserved_member_names = *new absl::flat_hash_set<absl::string_view>({ | ||
| 255 | -+ static const auto& reserved_member_names = *new std::set<absl::string_view>({ | ||
| 256 | - "Types", | ||
| 257 | - "Descriptor", | ||
| 258 | - "Equals", | ||
| 259 | -diff --git a/src/google/protobuf/compiler/java/names.cc b/src/google/protobuf/compiler/java/names.cc | ||
| 260 | -index d934973..caa3c47 100644 | ||
| 261 | ---- a/src/google/protobuf/compiler/java/names.cc | ||
| 262 | -+++ b/src/google/protobuf/compiler/java/names.cc | ||
| 263 | -@@ -37,7 +37,7 @@ const char* DefaultPackage(Options options) { | ||
| 264 | - | ||
| 265 | - bool IsReservedName(absl::string_view name) { | ||
| 266 | - static const auto& kReservedNames = | ||
| 267 | -- *new absl::flat_hash_set<absl::string_view>({ | ||
| 268 | -+ *new std::set<absl::string_view>({ | ||
| 269 | - "abstract", "assert", "boolean", "break", "byte", | ||
| 270 | - "case", "catch", "char", "class", "const", | ||
| 271 | - "continue", "default", "do", "double", "else", | ||
| 272 | -@@ -49,7 +49,7 @@ bool IsReservedName(absl::string_view name) { | ||
| 273 | - "switch", "synchronized", "this", "throw", "throws", | ||
| 274 | - "transient", "try", "void", "volatile", "while", | ||
| 275 | - }); | ||
| 276 | -- return kReservedNames.contains(name); | ||
| 277 | -+ return kReservedNames.count(name) != 0U; | ||
| 278 | - } | ||
| 279 | - | ||
| 280 | - bool IsForbidden(absl::string_view field_name) { | ||
| 281 | -@@ -59,7 +59,7 @@ bool IsForbidden(absl::string_view field_name) { | ||
| 282 | - // Keep this list in sync with specialFieldNames in | ||
| 283 | - // java/core/src/main/java/com/google/protobuf/DescriptorMessageInfoFactory.java | ||
| 284 | - static const auto& kForbiddenNames = | ||
| 285 | -- *new absl::flat_hash_set<absl::string_view>({ | ||
| 286 | -+ *new std::set<absl::string_view>({ | ||
| 287 | - // java.lang.Object: | ||
| 288 | - "Class", | ||
| 289 | - // com.google.protobuf.MessageLiteOrBuilder: | ||
| 290 | -@@ -75,7 +75,7 @@ bool IsForbidden(absl::string_view field_name) { | ||
| 291 | - // obsolete. kept for backwards compatibility of generated code | ||
| 292 | - "CachedSize", | ||
| 293 | - }); | ||
| 294 | -- return kForbiddenNames.contains(UnderscoresToCamelCase(field_name, true)); | ||
| 295 | -+ return kForbiddenNames.count(UnderscoresToCamelCase(field_name, true)) != 0U; | ||
| 296 | - } | ||
| 297 | - | ||
| 298 | - std::string FieldName(const FieldDescriptor* field) { | ||
| 299 | -diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h | ||
| 300 | -index f45a1c8..e2191b7 100644 | ||
| 301 | ---- a/src/google/protobuf/extension_set.h | ||
| 302 | -+++ b/src/google/protobuf/extension_set.h | ||
| 303 | -@@ -166,7 +166,7 @@ class PROTOBUF_EXPORT GeneratedExtensionFinder { | ||
| 304 | - // off to the ExtensionSet for parsing. Etc. | ||
| 305 | - class PROTOBUF_EXPORT ExtensionSet { | ||
| 306 | - public: | ||
| 307 | -- constexpr ExtensionSet() : ExtensionSet(nullptr) {} | ||
| 308 | -+ constexpr ExtensionSet(); | ||
| 309 | - ExtensionSet(const ExtensionSet& rhs) = delete; | ||
| 310 | - | ||
| 311 | - // Arena enabled constructors: for internal use only. | ||
| 312 | -@@ -912,6 +912,9 @@ class PROTOBUF_EXPORT ExtensionSet { | ||
| 313 | - static void DeleteFlatMap(const KeyValue* flat, uint16_t flat_capacity); | ||
| 314 | - }; | ||
| 315 | - | ||
| 316 | -+constexpr ExtensionSet::ExtensionSet() | ||
| 317 | -+ : arena_(nullptr), flat_capacity_(0), flat_size_(0), map_{nullptr} {} | ||
| 318 | -+ | ||
| 319 | - constexpr ExtensionSet::ExtensionSet(Arena* arena) | ||
| 320 | - : arena_(arena), flat_capacity_(0), flat_size_(0), map_{nullptr} {} | ||
| 321 | - | ||
| 322 | -diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h | ||
| 323 | -index de8bd19..60bc923 100644 | ||
| 324 | ---- a/src/google/protobuf/message_lite.h | ||
| 325 | -+++ b/src/google/protobuf/message_lite.h | ||
| 326 | -@@ -505,12 +505,10 @@ class PROTOBUF_EXPORT MessageLite { | ||
| 327 | - return Arena::CreateMaybeMessage<T>(arena); | ||
| 328 | - } | ||
| 329 | - | ||
| 330 | --#ifdef PROTOBUF_EXPLICIT_CONSTRUCTORS | ||
| 331 | - template <typename T> | ||
| 332 | - static T* CreateMaybeMessage(Arena* arena, const T& from) { | ||
| 333 | - return Arena::CreateMaybeMessage<T>(arena, from); | ||
| 334 | - } | ||
| 335 | --#endif // PROTOBUF_EXPLICIT_CONSTRUCTORS | ||
| 336 | - | ||
| 337 | - inline explicit MessageLite(Arena* arena) : _internal_metadata_(arena) {} | ||
| 338 | - | ||
| 339 | -diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc | ||
| 340 | -index 25abc30..f17d861 100644 | ||
| 341 | ---- a/src/google/protobuf/port_def.inc | ||
| 342 | -+++ b/src/google/protobuf/port_def.inc | ||
| 343 | -@@ -572,14 +572,6 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3), | ||
| 344 | - #error PROTOBUF_FORCE_COPY_DEFAULT_STRING was previously defined | ||
| 345 | - #endif | ||
| 346 | - | ||
| 347 | --// Set (and leave set) PROTOBUF_EXPLICIT_CONSTRUCTORS | ||
| 348 | --// This flag changes the internal implementation class and its uses from using | ||
| 349 | --// aggregate initialization to using explicit constructor based initialization. | ||
| 350 | --// TODO: remove this flag and make the code permanent. | ||
| 351 | --#ifndef PROTOBUF_EXPLICIT_CONSTRUCTORS | ||
| 352 | --#define PROTOBUF_EXPLICIT_CONSTRUCTORS | ||
| 353 | --#endif | ||
| 354 | -- | ||
| 355 | - #ifdef PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION | ||
| 356 | - #error PROTOBUF_FORCE_ALLOCATION_ON_CONSTRUCTION was previously defined | ||
| 357 | - #endif | ||
| @@ -1,41 +1,38 @@ | |||
| 1 | # ---------------------------------------------------------------------------- | 1 | # ---------------------------------------------------------------------------- |
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. | 2 | # Copyright (c) 2026 Huawei Technologies Co., Ltd. |
| 4 | -# This file is a part of the CANN Open Software. | 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). |
| 6 | # Please refer to the License for details. You may not use this file except in compliance with the License. | 5 | # Please refer to the License for details. You may not use this file except in compliance with the License. |
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | # See LICENSE in the root of the software repository for the full text of the License. | 8 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ---------------------------------------------------------------------------- | 9 | # ---------------------------------------------------------------------------- |
| 10 | -if(POLICY CMP0135) | 10 | + |
| 11 | - cmake_policy(SET CMP0135 NEW) | 11 | +if(NOT PROJECT_SOURCE_DIR) |
| 12 | + if(CANN_3RD_LIB_PATH AND IS_DIRECTORY "${CANN_3RD_LIB_PATH}/cann-cmake") | ||
| 13 | + include("${CANN_3RD_LIB_PATH}/cann-cmake/function/prepare.cmake") | ||
| 14 | + else() | ||
| 15 | + include(FetchContent) | ||
| 16 | + | ||
| 17 | + set(CANN_CMAKE_TAG "master-015") | ||
| 18 | + if(CANN_3RD_LIB_PATH AND EXISTS "${CANN_3RD_LIB_PATH}/cmake-${CANN_CMAKE_TAG}.tar.gz") | ||
| 19 | + FetchContent_Declare( | ||
| 20 | + cann-cmake | ||
| 21 | + URL "${CANN_3RD_LIB_PATH}/cmake-${CANN_CMAKE_TAG}.tar.gz" | ||
| 22 | + ) | ||
| 23 | + else() | ||
| 24 | + FetchContent_Declare( | ||
| 25 | + cann-cmake | ||
| 26 | + GIT_REPOSITORY https://gitcode.com/cann/cmake.git | ||
| 27 | + GIT_TAG ${CANN_CMAKE_TAG} | ||
| 28 | + GIT_SHALLOW TRUE | ||
| 29 | + SOURCE_DIR ${CANN_3RD_LIB_PATH}/cann-cmake | ||
| 30 | + ) | ||
| 31 | + endif() | ||
| 32 | + FetchContent_GetProperties(cann-cmake) | ||
| 33 | + if(NOT cann-cmake_POPULATED) | ||
| 34 | + FetchContent_Populate(cann-cmake) | ||
| 35 | + endif() | ||
| 36 | + include("${cann-cmake_SOURCE_DIR}/function/prepare.cmake") | ||
| 37 | + endif() | ||
| 12 | endif() | 38 | endif() |
| 13 | - | ||
| 14 | -if (IS_DIRECTORY "${CANN_3RD_LIB_PATH}/eigen") | ||
| 15 | - set(REQ_URL "${CANN_3RD_LIB_PATH}/eigen") | ||
| 16 | -else() | ||
| 17 | - set(REQ_URL "https://gitcode.com/cann-src-third-party/eigen/releases/download/3.4.0/eigen-3.4.0.tar.gz") | ||
| 18 | -endif() | ||
| 19 | - | ||
| 20 | -include(ExternalProject) | ||
| 21 | -ExternalProject_Add(external_eigen_ras | ||
| 22 | - TLS_VERIFY OFF | ||
| 23 | - URL ${REQ_URL} | ||
| 24 | - DOWNLOAD_DIR download/eigen | ||
| 25 | - PREFIX third_party | ||
| 26 | - CONFIGURE_COMMAND "" | ||
| 27 | - BUILD_COMMAND "" | ||
| 28 | - INSTALL_COMMAND "" | ||
| 29 | -) | ||
| 30 | - | ||
| 31 | -ExternalProject_Get_Property(external_eigen_ras SOURCE_DIR) | ||
| 32 | - | ||
| 33 | -add_library(EigenRas INTERFACE) | ||
| 34 | -target_compile_options(EigenRas INTERFACE -w) | ||
| 35 | - | ||
| 36 | -set_target_properties(EigenRas PROPERTIES | ||
| 37 | - INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}" | ||
| 38 | -) | ||
| 39 | -add_dependencies(EigenRas external_eigen_ras) | ||
| 40 | - | ||
| 41 | -add_library(Eigen3::EigenRas ALIAS EigenRas) | ||
| @@ -1,116 +0,0 @@ | |||
| 1 | -# ---------------------------------------------------------------------------- | ||
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | -# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 4 | -# This file is a part of the CANN Open Software. | ||
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | -# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | -# ---------------------------------------------------------------------------- | ||
| 10 | -unset(gtest_FOUND CACHE) | ||
| 11 | -unset(GTEST_INCLUDE CACHE) | ||
| 12 | -unset(GTEST_STATIC_LIBRARY CACHE) | ||
| 13 | -unset(GTEST_MAIN_STATIC_LIBRARY CACHE) | ||
| 14 | -unset(GMOCK_STATIC_LIBRARY CACHE) | ||
| 15 | -unset(GMOCK_MAIN_STATIC_LIBRARY CACHE) | ||
| 16 | - | ||
| 17 | -set(GTEST_INSTALL_PATH ${CANN_3RD_LIB_PATH}/gtest) | ||
| 18 | -message("GTEST_INSTALL_PATH=${GTEST_INSTALL_PATH}") | ||
| 19 | -find_path(GTEST_INCLUDE | ||
| 20 | - NAMES gtest/gtest.h | ||
| 21 | - NO_CMAKE_SYSTEM_PATH | ||
| 22 | - NO_CMAKE_FIND_ROOT_PATH | ||
| 23 | - PATHS ${GTEST_INSTALL_PATH}/include) | ||
| 24 | -find_library(GTEST_STATIC_LIBRARY | ||
| 25 | - NAMES libgtest.a | ||
| 26 | - PATH_SUFFIXES lib lib64 | ||
| 27 | - NO_CMAKE_SYSTEM_PATH | ||
| 28 | - NO_CMAKE_FIND_ROOT_PATH | ||
| 29 | - PATHS ${GTEST_INSTALL_PATH}) | ||
| 30 | -find_library(GTEST_MAIN_STATIC_LIBRARY | ||
| 31 | - NAMES libgtest_main.a | ||
| 32 | - PATH_SUFFIXES lib lib64 | ||
| 33 | - NO_CMAKE_SYSTEM_PATH | ||
| 34 | - NO_CMAKE_FIND_ROOT_PATH | ||
| 35 | - PATHS ${GTEST_INSTALL_PATH}) | ||
| 36 | -find_library(GMOCK_STATIC_LIBRARY | ||
| 37 | - NAMES libgmock.a | ||
| 38 | - PATH_SUFFIXES lib lib64 | ||
| 39 | - NO_CMAKE_SYSTEM_PATH | ||
| 40 | - NO_CMAKE_FIND_ROOT_PATH | ||
| 41 | - PATHS ${GTEST_INSTALL_PATH}) | ||
| 42 | -find_library(GMOCK_MAIN_STATIC_LIBRARY | ||
| 43 | - NAMES libgmock_main.a | ||
| 44 | - PATH_SUFFIXES lib lib64 | ||
| 45 | - NO_CMAKE_SYSTEM_PATH | ||
| 46 | - NO_CMAKE_FIND_ROOT_PATH | ||
| 47 | - PATHS ${GTEST_INSTALL_PATH}) | ||
| 48 | - | ||
| 49 | -include(FindPackageHandleStandardArgs) | ||
| 50 | -find_package_handle_standard_args(gtest | ||
| 51 | - FOUND_VAR | ||
| 52 | - gtest_FOUND | ||
| 53 | - REQUIRED_VARS | ||
| 54 | - GTEST_INCLUDE | ||
| 55 | - GTEST_STATIC_LIBRARY | ||
| 56 | - GTEST_MAIN_STATIC_LIBRARY | ||
| 57 | - GMOCK_STATIC_LIBRARY | ||
| 58 | - GMOCK_MAIN_STATIC_LIBRARY | ||
| 59 | - ) | ||
| 60 | -message("gtest found:${gtest_FOUND}") | ||
| 61 | - | ||
| 62 | -if(gtest_FOUND AND NOT FORCE_REBUILD_CANN_3RD) | ||
| 63 | - message("gtest found in ${GTEST_INSTALL_PATH}, and not force rebuild cann third_party") | ||
| 64 | -else() | ||
| 65 | - message("not use cache, download the gtest code.") | ||
| 66 | - set(REQ_URL "https://gitcode.com/cann-src-third-party/googletest/releases/download/v1.14.0/googletest-1.14.0.tar.gz") | ||
| 67 | - set (gtest_CXXFLAGS "-D_GLIBCXX_USE_CXX11_ABI=0 -O2 -D_FORTIFY_SOURCE=2 -fPIC -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack") | ||
| 68 | - set (gtest_CFLAGS "-D_GLIBCXX_USE_CXX11_ABI=0 -O2 -D_FORTIFY_SOURCE=2 -fPIC -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack") | ||
| 69 | - | ||
| 70 | - include(ExternalProject) | ||
| 71 | - ExternalProject_Add(third_party_gtest | ||
| 72 | - URL ${REQ_URL} | ||
| 73 | - TLS_VERIFY OFF | ||
| 74 | - DOWNLOAD_DIR ${CANN_3RD_PKG_PATH} | ||
| 75 | - CONFIGURE_COMMAND ${CMAKE_COMMAND} | ||
| 76 | - -DCMAKE_CXX_FLAGS=${gtest_CXXFLAGS} | ||
| 77 | - -DCMAKE_C_FLAGS=${gtest_CFLAGS} | ||
| 78 | - -DCMAKE_INSTALL_PREFIX=${GTEST_INSTALL_PATH} | ||
| 79 | - -DCMAKE_INSTALL_LIBDIR=lib | ||
| 80 | - -DBUILD_TESTING=OFF | ||
| 81 | - -DBUILD_SHARED_LIBS=OFF | ||
| 82 | - -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER} | ||
| 83 | - -DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER} | ||
| 84 | - <SOURCE_DIR> | ||
| 85 | - BUILD_COMMAND $(MAKE) | ||
| 86 | - INSTALL_COMMAND $(MAKE) install | ||
| 87 | - EXCLUDE_FROM_ALL TRUE | ||
| 88 | - ) | ||
| 89 | -endif() | ||
| 90 | - | ||
| 91 | -set(GTEST_INCLUDE ${GTEST_INSTALL_PATH}/include) | ||
| 92 | - | ||
| 93 | -add_library(gtest STATIC IMPORTED) | ||
| 94 | -add_dependencies(gtest third_party_gtest) | ||
| 95 | - | ||
| 96 | -add_library(gmock STATIC IMPORTED) | ||
| 97 | -add_dependencies(gmock third_party_gtest) | ||
| 98 | - | ||
| 99 | -add_library(gtest_main STATIC IMPORTED) | ||
| 100 | -add_dependencies(gtest_main third_party_gtest) | ||
| 101 | - | ||
| 102 | -if (NOT EXISTS ${GTEST_INSTALL_PATH}/include) | ||
| 103 | - file(MAKE_DIRECTORY "${GTEST_INSTALL_PATH}/include") | ||
| 104 | -endif () | ||
| 105 | - | ||
| 106 | -set_target_properties(gtest PROPERTIES | ||
| 107 | - IMPORTED_LOCATION ${GTEST_INSTALL_PATH}/lib/libgtest.a | ||
| 108 | - INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INSTALL_PATH}/include) | ||
| 109 | - | ||
| 110 | -set_target_properties(gmock PROPERTIES | ||
| 111 | - IMPORTED_LOCATION ${GTEST_INSTALL_PATH}/lib/libgmock.a | ||
| 112 | - INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INSTALL_PATH}/include) | ||
| 113 | - | ||
| 114 | -set_target_properties(gtest_main PROPERTIES | ||
| 115 | - IMPORTED_LOCATION ${GTEST_INSTALL_PATH}/lib/libgtest_main.a | ||
| 116 | - INTERFACE_INCLUDE_DIRECTORIES ${GTEST_INSTALL_PATH}/include) | ||
| @@ -1,39 +0,0 @@ | |||
| 1 | -# ---------------------------------------------------------------------------- | ||
| 2 | -# This program is free software, you can redistribute it and/or modify. | ||
| 3 | -# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 4 | -# This file is a part of the CANN Open Software. | ||
| 5 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 6 | -# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 7 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | -# ---------------------------------------------------------------------------- | ||
| 10 | - | ||
| 11 | -set(MAKESELF_NAME "makeself") | ||
| 12 | -set(MAKESELF_PATH ${CANN_3RD_LIB_PATH}/makeself) | ||
| 13 | - | ||
| 14 | -if (POLICY CMP0135) | ||
| 15 | - cmake_policy(SET CMP0135 NEW) | ||
| 16 | -endif() | ||
| 17 | - | ||
| 18 | -# 默认配置的makeself还是不存在则下载 | ||
| 19 | -if (NOT EXISTS "${MAKESELF_PATH}/makeself-header.sh" OR NOT EXISTS "${MAKESELF_PATH}/makeself.sh") | ||
| 20 | - set(MAKESELF_URL "https://gitcode.com/cann-src-third-party/makeself/releases/download/release-2.5.0-patch1.0/makeself-release-2.5.0-patch1.tar.gz") | ||
| 21 | - message(STATUS "Downloading ${MAKESELF_NAME} from ${MAKESELF_URL}") | ||
| 22 | - | ||
| 23 | - include(FetchContent) | ||
| 24 | - FetchContent_Declare( | ||
| 25 | - ${MAKESELF_NAME} | ||
| 26 | - URL ${MAKESELF_URL} | ||
| 27 | - URL_HASH SHA256=bfa730a5763cdb267904a130e02b2e48e464986909c0733ff1c96495f620369a | ||
| 28 | - SOURCE_DIR "${MAKESELF_PATH}" # 直接解压到此目录 | ||
| 29 | - ) | ||
| 30 | - FetchContent_MakeAvailable(${MAKESELF_NAME}) | ||
| 31 | - execute_process( | ||
| 32 | - COMMAND chmod 700 "${CMAKE_BINARY_DIR}/makeself/makeself.sh" | ||
| 33 | - COMMAND chmod 700 "${CMAKE_BINARY_DIR}/makeself/makeself-header.sh" | ||
| 34 | - -E env | ||
| 35 | - CMAKE_TLS_VERIFY=0 | ||
| 36 | - RESULT_VARIABLE CHMOD_RESULT | ||
| 37 | - ERROR_VARIABLE CHMOD_ERROR | ||
| 38 | - ) | ||
| 39 | -endif() | ||
| @@ -1,66 +0,0 @@ | |||
| 1 | -# This program is free software, you can redistribute it and/or modify. | ||
| 2 | -# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | -# This file is a part of the CANN Open Software. | ||
| 4 | -# Licensed under CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | -# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 7 | -# See LICENSE in the root of the software repository for the full text of the License. | ||
| 8 | -# ============================================================================ | ||
| 9 | - | ||
| 10 | -include_guard(GLOBAL) | ||
| 11 | - | ||
| 12 | -if(json_FOUND) | ||
| 13 | - return() | ||
| 14 | -endif() | ||
| 15 | - | ||
| 16 | -unset(json_FOUND CACHE) | ||
| 17 | -unset(JSON_INCLUDE CACHE) | ||
| 18 | - | ||
| 19 | -if(NOT CANN_3RD_PKG_PATH) | ||
| 20 | - set(CANN_3RD_PKG_PATH ${PROJECT_SOURCE_DIR}/third_party/pkg) | ||
| 21 | -endif() | ||
| 22 | - | ||
| 23 | -set(JSON_DOWNLOAD_PATH ${CANN_3RD_LIB_PATH}/pkg) | ||
| 24 | -set(JSON_INSTALL_PATH ${CANN_3RD_LIB_PATH}/json) | ||
| 25 | -find_path(JSON_INCLUDE | ||
| 26 | - NAMES nlohmann/json.hpp | ||
| 27 | - NO_CMAKE_SYSTEM_PATH | ||
| 28 | - NO_CMAKE_FIND_ROOT_PATH | ||
| 29 | - PATHS ${JSON_INSTALL_PATH}/include) | ||
| 30 | - | ||
| 31 | -include(FindPackageHandleStandardArgs) | ||
| 32 | -find_package_handle_standard_args(json | ||
| 33 | - FOUND_VAR | ||
| 34 | - json_FOUND | ||
| 35 | - REQUIRED_VARS | ||
| 36 | - JSON_INCLUDE | ||
| 37 | - ) | ||
| 38 | - | ||
| 39 | -if(json_FOUND AND NOT FORCE_REBUILD_CANN_3RD) | ||
| 40 | - message("json found in ${JSON_INSTALL_PATH}, and not force rebuild cann third_party") | ||
| 41 | - set(JSON_INCLUDE ${JSON_INSTALL_PATH}/include) | ||
| 42 | - add_custom_target(nlohmann_json_ras) | ||
| 43 | -else() | ||
| 44 | - message("not use cache, download the json code") | ||
| 45 | - include(ExternalProject) | ||
| 46 | - ExternalProject_Add(nlohmann_json_ras | ||
| 47 | - URL https://gitcode.com/cann-src-third-party/json/releases/download/v3.11.3/include.zip | ||
| 48 | - URL_MD5 e2f46211f4cf5285412a63e8164d4ba6 | ||
| 49 | - DOWNLOAD_DIR download/nlohmann_json_ras | ||
| 50 | - PREFIX third_party | ||
| 51 | - TLS_VERIFY OFF | ||
| 52 | - DOWNLOAD_EXTRACT_TIMESTAMP OFF | ||
| 53 | - CONFIGURE_COMMAND "" | ||
| 54 | - BUILD_COMMAND "" | ||
| 55 | - INSTALL_COMMAND "" | ||
| 56 | - ) | ||
| 57 | - | ||
| 58 | - ExternalProject_Get_Property(nlohmann_json_ras SOURCE_DIR) | ||
| 59 | - set(JSON_INCLUDE ${SOURCE_DIR}/include) | ||
| 60 | -endif() | ||
| 61 | - | ||
| 62 | -add_library(json INTERFACE IMPORTED) | ||
| 63 | -set_target_properties(json PROPERTIES | ||
| 64 | - INTERFACE_INCLUDE_DIRECTORIES "${JSON_INCLUDE}") | ||
| 65 | -target_compile_definitions(json INTERFACE nlohmann=ascend_nlohmann) | ||
| 66 | -add_dependencies(json nlohmann_json_ras) | ||
| @@ -0,0 +1,59 @@ | |||
| 1 | +# ---------------------------------------------------------------------------- | ||
| 2 | +# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | +# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | +# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | +# ---------------------------------------------------------------------------- | ||
| 10 | +set(OPBASE_TAG_ID b92c2c8f3d999f315b0251cfb25edb111bb898d5) | ||
| 11 | + | ||
| 12 | +if(EXISTS "${PROJECT_SOURCE_DIR}/../../ops-base") | ||
| 13 | + get_filename_component(OPBASE_SOURCE_PATH | ||
| 14 | + ${PROJECT_SOURCE_DIR}/../../ops-base REALPATH) | ||
| 15 | + message(STATUS "Find opbase source dir: ${OPBASE_SOURCE_PATH}") | ||
| 16 | +elseif(EXISTS "${CANN_3RD_LIB_PATH}/opbase") | ||
| 17 | + get_filename_component(OPBASE_SOURCE_PATH | ||
| 18 | + ${CANN_3RD_LIB_PATH}/opbase REALPATH) | ||
| 19 | + message(STATUS "Find opbase source dir: ${OPBASE_SOURCE_PATH}") | ||
| 20 | + execute_process( | ||
| 21 | + COMMAND git checkout ${OPBASE_TAG_ID} | ||
| 22 | + WORKING_DIRECTORY ${OPBASE_SOURCE_PATH} | ||
| 23 | + RESULT_VARIABLE EXEC_RESULT | ||
| 24 | + OUTPUT_VARIABLE EXEC_INFO | ||
| 25 | + ERROR_VARIABLE EXEC_ERROR | ||
| 26 | + ) | ||
| 27 | + if(${EXEC_RESULT}) | ||
| 28 | + message(FATAL_ERROR "Git checkout failed! error: ${EXEC_ERROR}") | ||
| 29 | + endif() | ||
| 30 | +else() | ||
| 31 | + if(EXISTS "${PROJECT_SOURCE_DIR}/build/_deps/opbase-subbuild") | ||
| 32 | + file(REMOVE_RECURSE ${PROJECT_SOURCE_DIR}/build/_deps/opbase-subbuild) | ||
| 33 | + endif() | ||
| 34 | + include(FetchContent) | ||
| 35 | + | ||
| 36 | + FetchContent_Declare( | ||
| 37 | + opbase | ||
| 38 | + GIT_REPOSITORY https://gitcode.com/cann/opbase.git | ||
| 39 | + GIT_TAG ${OPBASE_TAG_ID} | ||
| 40 | + GIT_PROGRESS TRUE | ||
| 41 | + SOURCE_DIR ${CANN_3RD_LIB_PATH}/opbase) | ||
| 42 | + | ||
| 43 | + FetchContent_Populate(opbase) | ||
| 44 | + | ||
| 45 | + set(OPBASE_SOURCE_PATH ${CANN_3RD_LIB_PATH}/opbase) | ||
| 46 | + | ||
| 47 | + if(EXISTS ${OPBASE_SOURCE_PATH}/aicpu_common) | ||
| 48 | + file(REMOVE_RECURSE ${OPBASE_SOURCE_PATH}/aicpu_common) | ||
| 49 | + endif() | ||
| 50 | + if(EXISTS ${OPBASE_SOURCE_PATH}/pkg_inc/op_common/log) | ||
| 51 | + file(REMOVE_RECURSE ${OPBASE_SOURCE_PATH}/pkg_inc/op_common/log) | ||
| 52 | + endif() | ||
| 53 | + if(EXISTS ${OPBASE_SOURCE_PATH}/pkg_inc/op_common/op_host) | ||
| 54 | + file(REMOVE_RECURSE ${OPBASE_SOURCE_PATH}/pkg_inc/op_common/op_host) | ||
| 55 | + endif() | ||
| 56 | + if(EXISTS ${OPBASE_SOURCE_PATH}/pkg_inc/op_common/op_kernel) | ||
| 57 | + file(REMOVE_RECURSE ${OPBASE_SOURCE_PATH}/pkg_inc/op_common/op_kernel) | ||
| 58 | + endif() | ||
| 59 | +endif() | ||
| @@ -0,0 +1,57 @@ | |||
| 1 | +# ---------------------------------------------------------------------------- | ||
| 2 | +# Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 3 | +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of | ||
| 4 | +# CANN Open Software License Agreement Version 2.0 (the "License"). | ||
| 5 | +# Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 6 | +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 7 | +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| 8 | +# See LICENSE in the root of the software repository for the full text of the License. | ||
| 9 | +# ---------------------------------------------------------------------------- | ||
| 10 | +set(OPS_TEST_KIT_TAG_ID master) | ||
| 11 | +set(OPS_TEST_KIT_PKG ops-test-kit.tar.gz) | ||
| 12 | + | ||
| 13 | +if(EXISTS "${PROJECT_SOURCE_DIR}/build/third_party/ops-test-kit") | ||
| 14 | + get_filename_component(OPS_TEST_KIT_SOURCE_PATH | ||
| 15 | + ${PROJECT_SOURCE_DIR}/build/third_party/ops-test-kit REALPATH) | ||
| 16 | + message(STATUS "Find ops-test-kit source dir: ${OPS_TEST_KIT_SOURCE_PATH}") | ||
| 17 | +elseif(EXISTS "${CANN_3RD_LIB_PATH}/ops-test-kit") | ||
| 18 | + get_filename_component(OPS_TEST_KIT_SOURCE_PATH | ||
| 19 | + ${CANN_3RD_LIB_PATH}/ops-test-kit REALPATH) | ||
| 20 | + message(STATUS "Find ops-test-kit source dir: ${OPS_TEST_KIT_SOURCE_PATH}") | ||
| 21 | +else() | ||
| 22 | + if(EXISTS "${CANN_3RD_LIB_PATH}/pkg/${OPS_TEST_KIT_PKG}") | ||
| 23 | + set(OPS_TEST_KIT_URL "file://${CANN_3RD_LIB_PATH}/pkg/${OPS_TEST_KIT_PKG}") | ||
| 24 | + message(STATUS "[ThirdPartyLib][ops-test-kit] found in ${OPS_TEST_KIT_URL}.") | ||
| 25 | + include(FetchContent) | ||
| 26 | + FetchContent_Declare( | ||
| 27 | + ops_test_kit | ||
| 28 | + URL ${OPS_TEST_KIT_URL} | ||
| 29 | + SOURCE_DIR ${PROJECT_SOURCE_DIR}/build/third_party/ops-test-kit | ||
| 30 | + ) | ||
| 31 | + else() | ||
| 32 | + execute_process( | ||
| 33 | + COMMAND git remote get-url origin | ||
| 34 | + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
| 35 | + OUTPUT_VARIABLE GIT_REMOTE_URL | ||
| 36 | + OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| 37 | + ERROR_QUIET | ||
| 38 | + ) | ||
| 39 | + if(GIT_REMOTE_URL MATCHES "^git@|^ssh://") | ||
| 40 | + set(OPS_TEST_KIT_GIT_URL "git@gitcode.com:cann/ops-test-kit.git") | ||
| 41 | + message(STATUS "[ThirdPartyLib][ops-test-kit] using SSH protocol: ${OPS_TEST_KIT_GIT_URL}") | ||
| 42 | + else() | ||
| 43 | + set(OPS_TEST_KIT_GIT_URL "https://gitcode.com/cann/ops-test-kit.git") | ||
| 44 | + message(STATUS "[ThirdPartyLib][ops-test-kit] using HTTPS protocol: ${OPS_TEST_KIT_GIT_URL}") | ||
| 45 | + endif() | ||
| 46 | + include(FetchContent) | ||
| 47 | + FetchContent_Declare( | ||
| 48 | + ops_test_kit | ||
| 49 | + GIT_REPOSITORY ${OPS_TEST_KIT_GIT_URL} | ||
| 50 | + GIT_TAG ${OPS_TEST_KIT_TAG_ID} | ||
| 51 | + GIT_PROGRESS TRUE | ||
| 52 | + SOURCE_DIR ${PROJECT_SOURCE_DIR}/build/third_party/ops-test-kit | ||
| 53 | + ) | ||
| 54 | + endif() | ||
| 55 | + FetchContent_Populate(ops_test_kit) | ||
| 56 | + set(OPS_TEST_KIT_SOURCE_PATH ${PROJECT_SOURCE_DIR}/build/third_party/ops-test-kit) | ||
| 57 | +endif() | ||
| @@ -16,17 +16,12 @@ set(OPHOST_NAME ophost_${PKG_NAME}) | |||
| 16 | set(OPSTATIC_NAME cann_${PKG_NAME}_static) | 16 | set(OPSTATIC_NAME cann_${PKG_NAME}_static) |
| 17 | set(OPAPI_NAME opapi_${PKG_NAME}) | 17 | set(OPAPI_NAME opapi_${PKG_NAME}) |
| 18 | set(OPGRAPH_NAME opgraph_${PKG_NAME}) | 18 | set(OPGRAPH_NAME opgraph_${PKG_NAME}) |
| 19 | -set(ONNX_PLUGIN_NAME op_${PKG_NAME}_onnx_plugin) | 19 | +set(ONNX_PLUGIN_NAME oponnx_plugin_${PKG_NAME}) |
| 20 | +set(TF_PLUGIN_NAME optf_plugin_${PKG_NAME}) | ||
| 21 | +set(CUBE_UTILS_PLUGIN_NAME cube_utils_${PKG_NAME}_util) | ||
| 20 | set(GRAPH_PLUGIN_NAME graph_plugin_${PKG_NAME}) | 22 | set(GRAPH_PLUGIN_NAME graph_plugin_${PKG_NAME}) |
| 21 | set(VENDOR_PACKAGE_NAME ${VENDOR_NAME}_ras) | 23 | set(VENDOR_PACKAGE_NAME ${VENDOR_NAME}_ras) |
| 22 | 24 | ||
| 23 | -if(NOT CANN_3RD_LIB_PATH) | ||
| 24 | - set(CANN_3RD_LIB_PATH ${PROJECT_SOURCE_DIR}/build/third_party) | ||
| 25 | -endif() | ||
| 26 | -if(NOT CANN_3RD_PKG_PATH) | ||
| 27 | - set(CANN_3RD_PKG_PATH ${PROJECT_SOURCE_DIR}/build/third_party/pkg) | ||
| 28 | -endif() | ||
| 29 | - | ||
| 30 | message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}") | 25 | message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}") |
| 31 | if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") | 26 | if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") |
| 32 | set(ARCH x86_64) | 27 | set(ARCH x86_64) |
| @@ -82,13 +77,16 @@ if(ENABLE_CUSTOM) | |||
| 82 | set(AICPU_KERNEL_IMPL packages/vendors/${VENDOR_PACKAGE_NAME}/op_impl/cpu/aicpu_kernel/impl) | 77 | set(AICPU_KERNEL_IMPL packages/vendors/${VENDOR_PACKAGE_NAME}/op_impl/cpu/aicpu_kernel/impl) |
| 83 | set(AICPU_JSON_CONFIG packages/vendors/${VENDOR_PACKAGE_NAME}/op_impl/cpu/config) | 78 | set(AICPU_JSON_CONFIG packages/vendors/${VENDOR_PACKAGE_NAME}/op_impl/cpu/config) |
| 84 | set(CUST_AICPU_OP_PROTO packages/vendors/${VENDOR_PACKAGE_NAME}/op_proto) | 79 | set(CUST_AICPU_OP_PROTO packages/vendors/${VENDOR_PACKAGE_NAME}/op_proto) |
| 80 | + set(ES_INC_INSTALL_DIR packages/vendors/${VENDOR_PACKAGE_NAME}/op_proto/es/include) | ||
| 81 | + set(ES_LIB_INSTALL_DIR packages/vendors/${VENDOR_PACKAGE_NAME}/op_proto/es/lib/linux/${CMAKE_SYSTEM_PROCESSOR}) | ||
| 85 | set(VERSION_INFO_INSTALL_DIR packages/vendors/${VENDOR_PACKAGE_NAME}/) | 82 | set(VERSION_INFO_INSTALL_DIR packages/vendors/${VENDOR_PACKAGE_NAME}/) |
| 86 | - set(PACK_CUSTOM_NAME "cann-ops-ras-${VENDOR_NAME}-linux.${ARCH}") | 83 | + set(PACK_CUSTOM_NAME "cann-ops-ras-${VENDOR_NAME}_linux-${ARCH}") |
| 87 | else() | 84 | else() |
| 88 | # built-in package install path | 85 | # built-in package install path |
| 89 | - set(ACLNN_INC_INSTALL_DIR opp/include/aclnnop) | 86 | + set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME ops-ras) |
| 90 | - set(ACLNN_OP_INC_INSTALL_DIR opp/include/aclnnop/level2) | 87 | + set(ACLNN_INC_INSTALL_DIR ${CMAKE_SYSTEM_PROCESSOR}-linux/include/aclnnop) |
| 91 | - set(ACLNN_LIB_INSTALL_DIR opp/built-in/op_impl/ai_core/tbe/op_api/lib/linux/${CMAKE_SYSTEM_PROCESSOR}) | 88 | + set(ACLNN_OP_INC_INSTALL_DIR ${CMAKE_SYSTEM_PROCESSOR}-linux/include/aclnnop/level2) |
| 89 | + set(ACLNN_LIB_INSTALL_DIR ${CMAKE_SYSTEM_PROCESSOR}-linux/lib64) | ||
| 92 | set(OPS_INFO_INSTALL_DIR opp/built-in/op_impl/ai_core/tbe/config) | 90 | set(OPS_INFO_INSTALL_DIR opp/built-in/op_impl/ai_core/tbe/config) |
| 93 | set(IMPL_INSTALL_DIR opp/built-in/op_impl/ai_core/tbe/impl/ops_ras/ascendc) | 91 | set(IMPL_INSTALL_DIR opp/built-in/op_impl/ai_core/tbe/impl/ops_ras/ascendc) |
| 94 | set(IMPL_DYNAMIC_INSTALL_DIR opp/built-in/op_impl/ai_core/tbe/impl/ops_ras/dynamic) | 92 | set(IMPL_DYNAMIC_INSTALL_DIR opp/built-in/op_impl/ai_core/tbe/impl/ops_ras/dynamic) |
| @@ -96,12 +94,15 @@ else() | |||
| 96 | set(BIN_KERNEL_CONFIG_INSTALL_DIR opp/built-in/op_impl/ai_core/tbe/kernel/config) | 94 | set(BIN_KERNEL_CONFIG_INSTALL_DIR opp/built-in/op_impl/ai_core/tbe/kernel/config) |
| 97 | set(OPHOST_LIB_INSTALL_PATH opp/built-in/op_impl/ai_core/tbe/op_host/lib/linux/${CMAKE_SYSTEM_PROCESSOR}) | 95 | set(OPHOST_LIB_INSTALL_PATH opp/built-in/op_impl/ai_core/tbe/op_host/lib/linux/${CMAKE_SYSTEM_PROCESSOR}) |
| 98 | set(AICPU_KERNEL_IMPL opp/built-in/op_impl/aicpu/kernel) | 96 | set(AICPU_KERNEL_IMPL opp/built-in/op_impl/aicpu/kernel) |
| 97 | + set(AICPU_HOST_KERNEL_IMPL opp/built-in/op_impl/host_cpu) | ||
| 99 | set(AICPU_JSON_CONFIG opp/built-in/op_impl/aicpu/config) | 98 | set(AICPU_JSON_CONFIG opp/built-in/op_impl/aicpu/config) |
| 100 | set(OPTILING_LIB_INSTALL_DIR ${OPHOST_LIB_INSTALL_PATH}) | 99 | set(OPTILING_LIB_INSTALL_DIR ${OPHOST_LIB_INSTALL_PATH}) |
| 101 | set(OPGRAPH_INC_INSTALL_DIR opp/built-in/op_graph/inc) | 100 | set(OPGRAPH_INC_INSTALL_DIR opp/built-in/op_graph/inc) |
| 102 | set(OPGRAPH_LIB_INSTALL_DIR opp/built-in/op_graph/lib/linux/${CMAKE_SYSTEM_PROCESSOR}) | 101 | set(OPGRAPH_LIB_INSTALL_DIR opp/built-in/op_graph/lib/linux/${CMAKE_SYSTEM_PROCESSOR}) |
| 103 | set(ONNX_PLUGIN_LIB_INSTALL_DIR opp/built-in/framework/onnx) | 102 | set(ONNX_PLUGIN_LIB_INSTALL_DIR opp/built-in/framework/onnx) |
| 104 | - set(VERSION_INFO_INSTALL_DIR ops_ras) | 103 | + set(TF_PLUGIN_LIB_INSTALL_DIR opp/built-in/framework/tensorflow) |
| 104 | + set(VERSION_INFO_INSTALL_DIR ${CMAKE_SYSTEM_PROCESSOR}-linux) | ||
| 105 | + set(WHL_INSTALL_DIR ops_ras) | ||
| 105 | endif() | 106 | endif() |
| 106 | 107 | ||
| 107 | # util path | 108 | # util path |
| @@ -137,6 +138,15 @@ execute_process( | |||
| 137 | # pack path | 138 | # pack path |
| 138 | set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/build_out) | 139 | set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/build_out) |
| 139 | 140 | ||
| 141 | +if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG) | ||
| 142 | + set(JSON_INCLUDE ${JSON_SOURCE_PATH}/include) | ||
| 143 | + if(TARGET host_protoc) | ||
| 144 | + get_target_property(Protobuf_PROTOC_EXECUTABLE host_protoc IMPORTED_LOCATION) | ||
| 145 | + else() | ||
| 146 | + set(Protobuf_PROTOC_EXECUTABLE ${CMAKE_BINARY_DIR}/bin/protoc) | ||
| 147 | + endif() | ||
| 148 | +endif() | ||
| 149 | + | ||
| 140 | set(OPAPI_INCLUDE | 150 | set(OPAPI_INCLUDE |
| 141 | ${C_SEC_INCLUDE} | 151 | ${C_SEC_INCLUDE} |
| 142 | ${PLATFORM_INC_DIRS} | 152 | ${PLATFORM_INC_DIRS} |
| @@ -211,3 +221,15 @@ set(AICPU_DEFINITIONS | |||
| 211 | -fno-common | 221 | -fno-common |
| 212 | -fPIC | 222 | -fPIC |
| 213 | ) | 223 | ) |
| 224 | + | ||
| 225 | +set(ONNX_PLUGIN_INCLUDE | ||
| 226 | + ${OP_PROTO_INCLUDE} | ||
| 227 | + ${Protobuf_PATH} | ||
| 228 | + ${CMAKE_BINARY_DIR}/proto | ||
| 229 | + ${JSON_INCLUDE} | ||
| 230 | + ${ABS_INSTALL_DIR} | ||
| 231 | + ${OPS_RAS_DIR} | ||
| 232 | + ${OPS_RAS_DIR}/common/inc/framework | ||
| 233 | + ${OPS_RAS_DIR}/common/stub/inc/framework | ||
| 234 | + ${OPS_RAS_DIR}/common/inc/op_graph | ||
| 235 | +) | ||
| @@ -40,11 +40,14 @@ | |||
| 40 | } \ | 40 | } \ |
| 41 | } while (0) | 41 | } while (0) |
| 42 | 42 | ||
| 43 | -#define OPS_LOG_D(OPS_DESC, fmt, ...) dlog_debug(0, "[%s]" fmt, __func__, ##__VA_ARGS__) | 43 | +#define OPS_LOG_D(OPS_DESC, fmt, ...) \ |
| 44 | -#define OPS_LOG_I(OPS_DESC, fmt, ...) dlog_info(0, "[%s]" fmt, __func__, ##__VA_ARGS__) | 44 | + D_OP_LOGD(Ops::Base::GetSafeStr(Ops::Base::GetOpInfo(OPS_DESC)), fmt, ##__VA_ARGS__) |
| 45 | -#define OPS_LOG_W(OPS_DESC, fmt, ...) dlog_warn(0, "[%s]" fmt, __func__, ##__VA_ARGS__) | 45 | +#define OPS_LOG_I(OPS_DESC, fmt, ...) \ |
| 46 | -#define OPS_LOG_E(OPS_DESC, fmt, ...) dlog_error(0, "[%s]" fmt, __func__, ##__VA_ARGS__) | 46 | + D_OP_LOGI(Ops::Base::GetSafeStr(Ops::Base::GetOpInfo(OPS_DESC)), fmt, ##__VA_ARGS__) |
| 47 | -#define OPS_LOG_EVENT(OPS_DESC, fmt, ...) dlog_event(0, "[%s]" fmt, __func__, ##__VA_ARGS__) | 47 | +#define OPS_LOG_W(OPS_DESC, fmt, ...) \ |
| 48 | + D_OP_LOGW(Ops::Base::GetSafeStr(Ops::Base::GetOpInfo(OPS_DESC)), fmt, ##__VA_ARGS__) | ||
| 49 | +#define OPS_LOG_E(OPS_DESC, fmt, ...) \ | ||
| 50 | + D_OP_LOGE(Ops::Base::GetSafeStr(Ops::Base::GetOpInfo(OPS_DESC)), fmt, ##__VA_ARGS__) | ||
| 48 | 51 | ||
| 49 | #define OPS_ERR_IF(COND, LOG_FUNC, EXPR) \ | 52 | #define OPS_ERR_IF(COND, LOG_FUNC, EXPR) \ |
| 50 | if (__builtin_expect(COND, 0)) { \ | 53 | if (__builtin_expect(COND, 0)) { \ |
| @@ -17,4 +17,35 @@ | |||
| 17 | 17 | ||
| 18 | #define ACLNN_API __attribute__((visibility("default"))) | 18 | #define ACLNN_API __attribute__((visibility("default"))) |
| 19 | 19 | ||
| 20 | -#endif // COMMON_RAS_ACLNN_UTIL_H | 20 | +#include "opdev/platform.h" |
| 21 | +#include <set> | ||
| 22 | + | ||
| 23 | +namespace Ops { | ||
| 24 | +namespace Ras { | ||
| 25 | +namespace AclnnUtil { | ||
| 26 | + | ||
| 27 | +using namespace op; | ||
| 28 | + | ||
| 29 | +/** | ||
| 30 | + * 检查当前芯片架构是否为RegBase | ||
| 31 | + */ | ||
| 32 | +inline static bool IsRegbase() | ||
| 33 | +{ | ||
| 34 | + auto npuArch = GetCurrentPlatformInfo().GetCurNpuArch(); | ||
| 35 | + const static std::set<NpuArch> regbaseNpuArchs = { | ||
| 36 | + NpuArch::DAV_3510}; | ||
| 37 | + return regbaseNpuArchs.find(npuArch) != regbaseNpuArchs.end(); | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +inline static bool IsRegbase(NpuArch npuArch) | ||
| 41 | +{ | ||
| 42 | + const static std::set<NpuArch> regbaseNpuArchs = { | ||
| 43 | + NpuArch::DAV_3510}; | ||
| 44 | + return regbaseNpuArchs.find(npuArch) != regbaseNpuArchs.end(); | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +} // namespace AclnnUtil | ||
| 48 | +} // namespace Ras | ||
| 49 | +} // namespace Ops | ||
| 50 | + | ||
| 51 | +#endif // COMMON_RAS_ACLNN_UTIL_H | ||
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | #include <algorithm> | 14 | #include <algorithm> |
| 15 | #include "op_api/op_api_def.h" | 15 | #include "op_api/op_api_def.h" |
| 16 | +#include "op_api/aclnn_util.h" | ||
| 16 | #include "aclnn/aclnn_base.h" | 17 | #include "aclnn/aclnn_base.h" |
| 17 | #include "opdev/platform.h" | 18 | #include "opdev/platform.h" |
| 18 | #include "opdev/common_types.h" | 19 | #include "opdev/common_types.h" |
| @@ -201,14 +202,13 @@ static inline bool CheckDtypeValid1In1OutMatch( | |||
| 201 | } | 202 | } |
| 202 | 203 | ||
| 203 | /** | 204 | /** |
| 204 | - * l1: ASCEND910B 或者 ASCEND910_93芯片,该算子支持的数据类型列表 | 205 | + * l1: DAV_2201 芯片,该算子支持的数据类型列表 |
| 205 | * l2: 其他芯片,该算子支持的数据类型列表 | 206 | * l2: 其他芯片,该算子支持的数据类型列表 |
| 206 | */ | 207 | */ |
| 207 | inline static const std::initializer_list<DataType>& GetDtypeSupportListV1( | 208 | inline static const std::initializer_list<DataType>& GetDtypeSupportListV1( |
| 208 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) | 209 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) |
| 209 | { | 210 | { |
| 210 | - if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B || | 211 | + if (GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_2201) { |
| 211 | - GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93) { | ||
| 212 | return l1; | 212 | return l1; |
| 213 | } else { | 213 | } else { |
| 214 | return l2; | 214 | return l2; |
| @@ -216,14 +216,14 @@ inline static const std::initializer_list<DataType>& GetDtypeSupportListV1( | |||
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | /** | 218 | /** |
| 219 | - * l1: ASCEND910B ~ ASCEND910E芯片,该算子支持的数据类型列表 | 219 | + * l1: DAV_2201 和 DAV_3510芯片,该算子支持的数据类型列表 |
| 220 | * l2: 其他芯片,该算子支持的数据类型列表 | 220 | * l2: 其他芯片,该算子支持的数据类型列表 |
| 221 | */ | 221 | */ |
| 222 | inline static const std::initializer_list<DataType>& GetDtypeSupportListV2( | 222 | inline static const std::initializer_list<DataType>& GetDtypeSupportListV2( |
| 223 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) | 223 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) |
| 224 | { | 224 | { |
| 225 | - if (GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B && | 225 | + if (GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_2201 || |
| 226 | - GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E) { | 226 | + Ops::Ras::AclnnUtil::IsRegbase()) { |
| 227 | return l1; | 227 | return l1; |
| 228 | } else { | 228 | } else { |
| 229 | return l2; | 229 | return l2; |
| @@ -233,14 +233,13 @@ inline static const std::initializer_list<DataType>& GetDtypeSupportListV2( | |||
| 233 | inline static const std::initializer_list<op::DataType> GetDtypeSupportListV3( | 233 | inline static const std::initializer_list<op::DataType> GetDtypeSupportListV3( |
| 234 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) | 234 | const std::initializer_list<op::DataType>& l1, const std::initializer_list<op::DataType>& l2) |
| 235 | { | 235 | { |
| 236 | - auto socVersion = GetCurrentPlatformInfo().GetSocVersion(); | 236 | + auto npuArch = GetCurrentPlatformInfo().GetCurNpuArch(); |
| 237 | - switch (socVersion) { | 237 | + switch (npuArch) { |
| 238 | - case SocVersion::ASCEND910_93: | 238 | + case NpuArch::DAV_3510: |
| 239 | - case SocVersion::ASCEND910_95: | 239 | + case NpuArch::DAV_2201: { |
| 240 | - case SocVersion::ASCEND910B: { | ||
| 241 | return l1; | 240 | return l1; |
| 242 | } | 241 | } |
| 243 | - case SocVersion::ASCEND910: { | 242 | + case NpuArch::DAV_1001: { |
| 244 | return l2; | 243 | return l2; |
| 245 | } | 244 | } |
| 246 | default: { | 245 | default: { |
| @@ -363,8 +362,8 @@ static inline bool CheckPromoteTypeGeluBackward(const aclTensor* gradOutput, con | |||
| 363 | return false; | 362 | return false; |
| 364 | } | 363 | } |
| 365 | 364 | ||
| 366 | - if (!(GetCurrentPlatformInfo().GetSocVersion() >= SocVersion::ASCEND910B && | 365 | + if (!(GetCurrentPlatformInfo().GetCurNpuArch() == NpuArch::DAV_2201 || |
| 367 | - GetCurrentPlatformInfo().GetSocVersion() <= SocVersion::ASCEND910E) && (promoteType == op::DataType::DT_BF16)) { | 366 | + Ops::Ras::AclnnUtil::IsRegbase()) && (promoteType == op::DataType::DT_BF16)) { |
| 368 | OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Input dtype of gelu is not support bfloat16 in current socversion."); | 367 | OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Input dtype of gelu is not support bfloat16 in current socversion."); |
| 369 | return false; | 368 | return false; |
| 370 | } | 369 | } |
| @@ -19,8 +19,7 @@ namespace op { | |||
| 19 | constexpr int8_t ALLOW_FP32_DOWN_PRECISION = 1; | 19 | constexpr int8_t ALLOW_FP32_DOWN_PRECISION = 1; |
| 20 | constexpr int8_t USE_FP16 = 2; | 20 | constexpr int8_t USE_FP16 = 2; |
| 21 | constexpr int8_t USE_HF32 = 3; | 21 | constexpr int8_t USE_HF32 = 3; |
| 22 | - constexpr int8_t FORCE_GRP_ACC_FOR_FP32 = 4; | 22 | + constexpr int8_t USE_FP32_ADD = 4; |
| 23 | - constexpr int8_t USE_HIGH_PREC_MODE = 5; | ||
| 24 | constexpr size_t MAX_MASK_LEN64 = 64; | 23 | constexpr size_t MAX_MASK_LEN64 = 64; |
| 25 | } // namespace op | 24 | } // namespace op |
| 26 | #endif // OP_API_DEF_H_ | 25 | #endif // OP_API_DEF_H_ |
| @@ -15,7 +15,11 @@ | |||
| 15 | #ifndef OPS_BUILT_IN_OP_ASCENDC_PLATFORM_INFO_H_ | 15 | #ifndef OPS_BUILT_IN_OP_ASCENDC_PLATFORM_INFO_H_ |
| 16 | #define OPS_BUILT_IN_OP_ASCENDC_PLATFORM_INFO_H_ | 16 | #define OPS_BUILT_IN_OP_ASCENDC_PLATFORM_INFO_H_ |
| 17 | 17 | ||
| 18 | +#if ASC_DEVKIT_MAJOR >= 9 | ||
| 19 | +#include "kernel_basic_intf.h" | ||
| 20 | +#else | ||
| 18 | #include "kernel_operator.h" | 21 | #include "kernel_operator.h" |
| 22 | +#endif | ||
| 19 | #include "kernel_tiling/kernel_tiling.h" | 23 | #include "kernel_tiling/kernel_tiling.h" |
| 20 | #include "kernel_utils.h" | 24 | #include "kernel_utils.h" |
| 21 | 25 | ||
| @@ -80,10 +84,4 @@ __aicore__ inline constexpr bool IsDataCopyPadSupport() | |||
| 80 | 84 | ||
| 81 | } | 85 | } |
| 82 | 86 | ||
| 83 | -namespace AscendC { | 87 | +#endif // OPS_BUILT_IN_OP_ASCENDC_PLATFORM_INFO_H_ |
| 84 | -namespace MicroAPI { | ||
| 85 | - | ||
| 86 | -} | ||
| 87 | -} | ||
| 88 | - | ||
| 89 | -#endif // OPS_BUILT_IN_OP_ASCENDC_PLATFORM_INFO_H_ | ||