已合并
【PR】:ge一月份需求合入(包含整改dflow ST、自定义算子执行Context等) #223
嵇锴创建于 1月27日
【PR】:ge一月份需求合入(包含整改dflow ST、自定义算子执行Context等) #223
已合并
共 1207 个文件变更+28706-18997
| @@ -14,6 +14,8 @@ project(CANN-GRAPH-ENGINE) | |||
| 14 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | 14 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 15 | set(BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) | 15 | set(BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 16 | 16 | ||
| 17 | +# 存在`.dev_env`文件说明是蓝区开发环境,并且调用了`prepare_dev_env.sh`完成了开发环境准备 | ||
| 18 | +# 除了设置好`.dev_env`中有的环境变量外,还会设置其他几个蓝区开发的必要变量 | ||
| 17 | if(EXISTS "${CMAKE_SOURCE_DIR}/.dev_env") | 19 | if(EXISTS "${CMAKE_SOURCE_DIR}/.dev_env") |
| 18 | set(ENABLE_OPEN_SRC True) | 20 | set(ENABLE_OPEN_SRC True) |
| 19 | set(ENABLE_GE_UT ON) | 21 | set(ENABLE_GE_UT ON) |
| @@ -91,6 +93,32 @@ if (NOT DEFINED CMAKE_PREFIX_PATH) | |||
| 91 | ) | 93 | ) |
| 92 | endif() | 94 | endif() |
| 93 | 95 | ||
| 96 | +include(CMakePrintHelpers) | ||
| 97 | +message(STATUS "Variables in air project:") | ||
| 98 | +cmake_print_variables(ASCEND_INSTALL_PATH) | ||
| 99 | +cmake_print_variables(ASCEND_3RD_LIB_PATH) | ||
| 100 | +cmake_print_variables(CMAKE_BUILD_TYPE) | ||
| 101 | +cmake_print_variables(CMAKE_INSTALL_PREFIX) | ||
| 102 | +cmake_print_variables(CMAKE_PREFIX_PATH) | ||
| 103 | +cmake_print_variables(CMAKE_MODULE_PATH) | ||
| 104 | +cmake_print_variables(BUILD_COMPONENT) | ||
| 105 | +cmake_print_variables(ENABLE_BUILD_DEVICE USE_CXX11_ABI CMAKE_TOOLCHAIN_FILE) | ||
| 106 | +if(ENABLE_BUILD_DEVICE) | ||
| 107 | + # 非MDC编译流程 | ||
| 108 | + set(USE_CXX11_ABI 0) | ||
| 109 | +else() | ||
| 110 | + if(CMAKE_TOOLCHAIN_FILE STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/cmake/llvm_toolchain.cmake") | ||
| 111 | + # MDC编译运行态 | ||
| 112 | + message("[MDC compile] MDC compile runtime state.") | ||
| 113 | + add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=${USE_CXX11_ABI}) | ||
| 114 | + set(MDC_COMPILE_RUNTIME ON) | ||
| 115 | + else() | ||
| 116 | + # MDC编译开发态 | ||
| 117 | + message("[MDC compile] MDC compile develop state.") | ||
| 118 | + set(USE_CXX11_ABI 0) | ||
| 119 | + endif() | ||
| 120 | +endif() | ||
| 121 | + | ||
| 94 | if (ENABLE_ACL_UT) | 122 | if (ENABLE_ACL_UT) |
| 95 | set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/base/metadef) | 123 | set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/base/metadef) |
| 96 | 124 | ||
| @@ -106,16 +134,6 @@ if (ENABLE_OPEN_SRC AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) | |||
| 106 | set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/output CACHE PATH "cmake default install path" FORCE) | 134 | set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/output CACHE PATH "cmake default install path" FORCE) |
| 107 | endif () | 135 | endif () |
| 108 | 136 | ||
| 109 | -include(CMakePrintHelpers) | ||
| 110 | -message(STATUS "Variables in air project:") | ||
| 111 | -cmake_print_variables(ASCEND_INSTALL_PATH) | ||
| 112 | -cmake_print_variables(ASCEND_3RD_LIB_PATH) | ||
| 113 | -cmake_print_variables(CMAKE_BUILD_TYPE) | ||
| 114 | -cmake_print_variables(CMAKE_INSTALL_PREFIX) | ||
| 115 | -cmake_print_variables(CMAKE_PREFIX_PATH) | ||
| 116 | -cmake_print_variables(CMAKE_MODULE_PATH) | ||
| 117 | -cmake_print_variables(BUILD_COMPONENT) | ||
| 118 | - | ||
| 119 | # 新开关适配,完成后删除原开关,从外部传入 | 137 | # 新开关适配,完成后删除原开关,从外部传入 |
| 120 | if (ENABLE_TEST) | 138 | if (ENABLE_TEST) |
| 121 | enable_testing() | 139 | enable_testing() |
| @@ -129,10 +147,30 @@ if (ENABLE_GE_C_LLT) | |||
| 129 | endif () | 147 | endif () |
| 130 | 148 | ||
| 131 | cmake_print_variables(ENABLE_OPEN_SRC ENABLE_TEST ENABLE_GE_BENCHMARK ENABLE_GE_ST ENABLE_GE_UT MINDSPORE_MODE PLATFORM | 149 | cmake_print_variables(ENABLE_OPEN_SRC ENABLE_TEST ENABLE_GE_BENCHMARK ENABLE_GE_ST ENABLE_GE_UT MINDSPORE_MODE PLATFORM |
| 132 | - BUILD_METADEF ENABLE_GE_DT ENABLE_RT2_UT ENABLE_PYTHON_UT ENABLE_PARSER_UT ENABLE_DFLOW_UT ENABLE_GE_C_LLT GE_C_DT ENABLE_TEST_C) | 150 | + BUILD_METADEF ENABLE_GE_DT ENABLE_RT2_UT ENABLE_PYTHON_UT ENABLE_PARSER_UT ENABLE_DFLOW_UT) |
| 133 | cmake_print_variables(BUILD_OPEN_PROJECT ENABLE_LLT_COV ENABLE_FE_LLT ENABLE_FFTS_LLT ENABLE_AICPU_LLT ENABLE_DVPP_LLT | 151 | cmake_print_variables(BUILD_OPEN_PROJECT ENABLE_LLT_COV ENABLE_FE_LLT ENABLE_FFTS_LLT ENABLE_AICPU_LLT ENABLE_DVPP_LLT |
| 134 | ENABLE_HCCE_LLT ENABLE_RTS_LLT ENABLE_UT ENABLE_ST, HI_PYTHON) | 152 | ENABLE_HCCE_LLT ENABLE_RTS_LLT ENABLE_UT ENABLE_ST, HI_PYTHON) |
| 135 | 153 | ||
| 154 | +# 针对 Clang 编译器,关闭特定警告(避免 -Werror 触发编译错误) | ||
| 155 | +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
| 156 | + message(STATUS "Add compile option for Clang.") | ||
| 157 | + | ||
| 158 | + add_compile_options(-Wno-error=unknown-warning-option) | ||
| 159 | + | ||
| 160 | + add_compile_options(-Wno-unused) | ||
| 161 | + add_compile_options(-Wno-unused-private-field) | ||
| 162 | + | ||
| 163 | + add_compile_options(-Wno-inconsistent-missing-override) | ||
| 164 | + add_compile_options(-Wno-vla) | ||
| 165 | + | ||
| 166 | + add_compile_options(-Wno-error=inconsistent-missing-override) | ||
| 167 | + add_compile_options(-Wno-error=vla) | ||
| 168 | + add_compile_options(-Wno-error=unused) | ||
| 169 | + add_compile_options(-Wno-error=unused-private-field) | ||
| 170 | + | ||
| 171 | + add_compile_options(-Wno-error) | ||
| 172 | +endif() | ||
| 173 | + | ||
| 136 | set(CMAKE_VERBOSE_MAKEFILE True) | 174 | set(CMAKE_VERBOSE_MAKEFILE True) |
| 137 | 175 | ||
| 138 | set(INSTALL_BASE_DIR "") | 176 | set(INSTALL_BASE_DIR "") |
| @@ -183,7 +221,6 @@ if (BUILD_OPEN_PROJECT OR ENABLE_OPEN_SRC) | |||
| 183 | set(TARGET_SYSTEM_NAME "Linux") | 221 | set(TARGET_SYSTEM_NAME "Linux") |
| 184 | set(OP_PROTO_DIR ${AIR_CODE_DIR}/tests/depends/op_stub/op_proto/inc) | 222 | set(OP_PROTO_DIR ${AIR_CODE_DIR}/tests/depends/op_stub/op_proto/inc) |
| 185 | set(METADEF_DIR ${AIR_CODE_DIR}/base/metadef) | 223 | set(METADEF_DIR ${AIR_CODE_DIR}/base/metadef) |
| 186 | - | ||
| 187 | set(GE_METADEF_DIR ${AIR_CODE_DIR}/graph_metadef) | 224 | set(GE_METADEF_DIR ${AIR_CODE_DIR}/graph_metadef) |
| 188 | set(GE_METADEF_INC_DIR ${AIR_CODE_DIR}/inc/graph_metadef) | 225 | set(GE_METADEF_INC_DIR ${AIR_CODE_DIR}/inc/graph_metadef) |
| 189 | 226 | ||
| @@ -197,7 +234,6 @@ else () | |||
| 197 | set(METADEF_DIR ${TOP_DIR}/metadef) | 234 | set(METADEF_DIR ${TOP_DIR}/metadef) |
| 198 | set(OP_PROTO_DIR ${TOP_DIR}/asl/ops/cann/ops/built-in/op_proto/inc) | 235 | set(OP_PROTO_DIR ${TOP_DIR}/asl/ops/cann/ops/built-in/op_proto/inc) |
| 199 | set(ASCGEN_DIR ${TOP_DIR}/air/compiler/graph/optimize/autofuse) | 236 | set(ASCGEN_DIR ${TOP_DIR}/air/compiler/graph/optimize/autofuse) |
| 200 | - | ||
| 201 | set(GE_METADEF_DIR ${AIR_CODE_DIR}/graph_metadef) | 237 | set(GE_METADEF_DIR ${AIR_CODE_DIR}/graph_metadef) |
| 202 | set(GE_METADEF_INC_DIR ${AIR_CODE_DIR}/inc/graph_metadef) | 238 | set(GE_METADEF_INC_DIR ${AIR_CODE_DIR}/inc/graph_metadef) |
| 203 | endif () | 239 | endif () |
| @@ -288,6 +324,7 @@ if ((CMAKE_BUILD_TYPE MATCHES GCOV) OR ENABLE_GE_DT) | |||
| 288 | 324 | ||
| 289 | if (ENABLE_GE_BENCHMARK) | 325 | if (ENABLE_GE_BENCHMARK) |
| 290 | add_dependencies(select_targets ge_runtime_benchmark) | 326 | add_dependencies(select_targets ge_runtime_benchmark) |
| 327 | + | ||
| 291 | elseif (ENABLE_GE_ST OR ENABLE_RT2_ST OR ENABLE_RT3_ST OR ENABLE_PYTHON_ST OR ENABLE_PARSER_ST OR ENABLE_DFLOW_ST) | 328 | elseif (ENABLE_GE_ST OR ENABLE_RT2_ST OR ENABLE_RT3_ST OR ENABLE_PYTHON_ST OR ENABLE_PARSER_ST OR ENABLE_DFLOW_ST) |
| 292 | if (ENABLE_RT2_ST) | 329 | if (ENABLE_RT2_ST) |
| 293 | add_dependencies(select_targets hybrid_model_async_exec_test | 330 | add_dependencies(select_targets hybrid_model_async_exec_test |
| @@ -341,7 +378,8 @@ if ((CMAKE_BUILD_TYPE MATCHES GCOV) OR ENABLE_GE_DT) | |||
| 341 | ut_jit_execution | 378 | ut_jit_execution |
| 342 | ut_eager_style_builder | 379 | ut_eager_style_builder |
| 343 | graphtuner_executor | 380 | graphtuner_executor |
| 344 | - ut_sc_check) | 381 | + ut_sc_check |
| 382 | + ge_manual_test) | ||
| 345 | endif () | 383 | endif () |
| 346 | 384 | ||
| 347 | if (ENABLE_RT2_UT) | 385 | if (ENABLE_RT2_UT) |
| @@ -406,6 +444,7 @@ if (NOT BUILD_OPEN_PROJECT) | |||
| 406 | install(TARGETS gert ge_common ge_common_base ge_executor_shared davinci_executor hybrid_executor ge_runner | 444 | install(TARGETS gert ge_common ge_common_base ge_executor_shared davinci_executor hybrid_executor ge_runner |
| 407 | ge_runner_v2 dflow_runner data_flow_base | 445 | ge_runner_v2 dflow_runner data_flow_base |
| 408 | ge_compiler aicore_utils slice air_headers | 446 | ge_compiler aicore_utils slice air_headers |
| 447 | + # 开发环境某些没有下载parser目录 | ||
| 409 | # _caffe_parser fmk_onnx_parser fmk_parser parser_common | 448 | # _caffe_parser fmk_onnx_parser fmk_parser parser_common |
| 410 | EXPORT air-targets | 449 | EXPORT air-targets |
| 411 | LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} OPTIONAL COMPONENT opensdk | 450 | LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} OPTIONAL COMPONENT opensdk |
| @@ -492,39 +531,43 @@ else ((BUILD_OPEN_PROJECT OR ENABLE_OPEN_SRC)) | |||
| 492 | ) | 531 | ) |
| 493 | 532 | ||
| 494 | if(BUILD_PKG_COMPONENT) | 533 | if(BUILD_PKG_COMPONENT) |
| 495 | - add_custom_target(ge-compiler) | 534 | + if (NOT MDC_COMPILE_RUNTIME) |
| 496 | - add_dependencies(ge-compiler parser_common aicore_utils fusion_pass op_compile_adapter aicpu_engine_common fmk_parser ge_compiler fmk_onnx_parser opskernel ge_runner | 535 | + add_custom_target(ge-compiler) |
| 497 | - slice aicpu_const_folding llm_engine jit_exe _caffe_parser flow_graph aihac_autofusion dflow_runner | 536 | + add_dependencies(ge-compiler parser_common aicore_utils fusion_pass op_compile_adapter aicpu_engine_common fmk_parser ge_compiler |
| 498 | - eager_style_graph_builder_base eager_style_graph_builder_base_static gen_esb aihac_ir | 537 | + fmk_onnx_parser opskernel ge_runner slice aicpu_const_folding llm_engine jit_exe _caffe_parser flow_graph aihac_autofusion |
| 499 | - aihac_ir_register aihac_symbolizer pyautofuse ge_python llm_datadist_python_v1 dataflow_python | 538 | + dflow_runner eager_style_graph_builder_base eager_style_graph_builder_base_static gen_esb aihac_ir aihac_ir_register |
| 500 | - hcom_gradient_split_tune hcom_graph_adaptor hcom_opskernel_builder hcom_gradtune_opskernel_builder) | 539 | + aihac_symbolizer pyautofuse ge_python llm_datadist_python_v1 dataflow_python) |
| 501 | - add_dependencies(ge-compiler fmk_parser ge_compiler fmk_onnx_parser ge_runner) | 540 | + add_dependencies(ge-compiler hcom_gradient_split_tune hcom_graph_adaptor hcom_opskernel_builder hcom_gradtune_opskernel_builder) |
| 502 | - add_dependencies(ge-compiler engine) | 541 | + add_dependencies(ge-compiler aicpu_ascend_engine aicpu_tf_engine dvpp_engine fe ffts ge_local_engine ge_local_opskernel_builder |
| 503 | - add_dependencies(ge-compiler aicpu_ascend_engine aicpu_tf_engine dvpp_engine fe ffts ge_local_engine ge_local_opskernel_builder | 542 | + host_cpu_opskernel_builder host_cpu_engine engine) |
| 504 | - host_cpu_opskernel_builder host_cpu_engine) | 543 | + add_dependencies(ge-compiler cpu_compiler udf_compiler) |
| 505 | - add_dependencies(ge-compiler cpu_compiler udf_compiler) | 544 | + add_dependencies(ge-compiler atc_atc.bin fwk_atc.bin) |
| 506 | - add_dependencies(ge-compiler atc_atc.bin) | 545 | + add_dependencies(ge-compiler compress compress_static compressweight compressweight_static rts_engine switch_by_index) |
| 507 | - add_dependencies(ge-compiler fwk_atc.bin) | 546 | + add_dependencies(ge-compiler acl_op_compiler) |
| 508 | - add_dependencies(ge-compiler compress compress_static compressweight compressweight_static rts_engine switch_by_index) | 547 | + add_dependencies(ge-compiler fmk_onnx_parser_stub fmk_parser_stub atc_stub_ge_compiler fwk_stub_ge_runner fwk_stub_ge_runner_v2 |
| 509 | - add_dependencies(ge-compiler acl_op_compiler) | 548 | + stub_acl_op_compiler) |
| 510 | - add_dependencies(ge-compiler fmk_onnx_parser_stub fmk_parser_stub atc_stub_ge_compiler fwk_stub_ge_runner fwk_stub_ge_runner_v2 | ||
| 511 | - stub_acl_op_compiler) | ||
| 512 | 549 | ||
| 513 | - add_custom_target(ge-executor) | 550 | + add_custom_target(ge-executor) |
| 514 | - add_dependencies(ge-executor ge_common ge_executor_shared ge_common_base davinci_executor hybrid_executor gert register | 551 | + add_dependencies(ge-executor ge_common ge_executor_shared ge_common_base davinci_executor hybrid_executor gert register |
| 515 | - graph npu_sched_model_loader lowering register_static graph_base model_deployer data_flow_base hcom_executor) | 552 | + graph npu_sched_model_loader lowering register_static graph_base model_deployer data_flow_base hcom_executor) |
| 516 | - add_dependencies(ge-executor ge_common gert graph register hybrid_executor lowering) | 553 | + add_dependencies(ge-executor acl_mdl acl_mdl_impl acl_op_executor acl_op_executor_impl acl_cblas) |
| 517 | - add_dependencies(ge-executor ge_common gert graph register hybrid_executor lowering register_static) | 554 | + add_dependencies(ge-executor runtime_update_model_param_dav_2201) |
| 518 | - add_dependencies(ge-executor graph register lowering) | 555 | + add_dependencies(ge-executor ge_common_stub stub_lowering atc_stub_graph gert_stub hybrid_executor_stub stub_register stub_acl_mdl |
| 519 | - add_dependencies(ge-executor acl_mdl acl_mdl_impl acl_op_executor acl_op_executor_impl acl_cblas) | 556 | + stub_acl_cblas stub_acl_op_executor) |
| 520 | - add_dependencies(ge-executor runtime_update_model_param_ascend910B runtime_update_model_param_ascend910_93) | 557 | + else() |
| 521 | - add_dependencies(ge-executor ge_common_stub stub_lowering atc_stub_graph gert_stub hybrid_executor_stub stub_register stub_acl_mdl | 558 | + # MDC 运行态编译 |
| 522 | - stub_acl_cblas stub_acl_op_executor) | 559 | + message("[MDC compile] MDC compile target set.") |
| 560 | + add_custom_target(ge-compiler) | ||
| 561 | + add_dependencies(ge-compiler flow_graph) | ||
| 523 | 562 | ||
| 524 | - add_custom_target(dflow-executor) | 563 | + add_custom_target(ge-executor) |
| 525 | - add_dependencies(dflow-executor deployer_daemon npu_executor_main host_cpu_executor_main udf_dump | 564 | + add_dependencies(ge-executor ge_common ge_common_base davinci_executor hybrid_executor gert register graph graph_base acl_cblas) |
| 526 | - reader_writer udf_profiling flow_func built_in_flowfunc udf_executor) | 565 | + endif () |
| 527 | - if (DEFINED ENV{TOOLCHAIN_DIR}) | 566 | + |
| 567 | + add_custom_target(dflow-executor) | ||
| 568 | + add_dependencies(dflow-executor deployer_daemon npu_executor_main host_cpu_executor_main udf_dump | ||
| 569 | + reader_writer udf_profiling flow_func built_in_flowfunc udf_executor) | ||
| 570 | + if (DEFINED ENV{TOOLCHAIN_DIR} AND ENABLE_BUILD_DEVICE) | ||
| 528 | message(STATUS $ENV{TOOLCHAIN_DIR}) | 571 | message(STATUS $ENV{TOOLCHAIN_DIR}) |
| 529 | set(TOOLCHAIN_DIR $ENV{TOOLCHAIN_DIR}) | 572 | set(TOOLCHAIN_DIR $ENV{TOOLCHAIN_DIR}) |
| 530 | set(CHILD_INSTALL_DIR ${CMAKE_BINARY_DIR}/device_install) | 573 | set(CHILD_INSTALL_DIR ${CMAKE_BINARY_DIR}/device_install) |
| @@ -557,7 +600,7 @@ else ((BUILD_OPEN_PROJECT OR ENABLE_OPEN_SRC)) | |||
| 557 | else () | 600 | else () |
| 558 | message(WARNING "ENV TOOLCHAIN_DIR is not defined, can't build udf device pkg!!!") | 601 | message(WARNING "ENV TOOLCHAIN_DIR is not defined, can't build udf device pkg!!!") |
| 559 | endif () | 602 | endif () |
| 560 | - | 603 | + |
| 561 | include(cmake/package.cmake) | 604 | include(cmake/package.cmake) |
| 562 | endif() | 605 | endif() |
| 563 | endif() | 606 | endif() |
| @@ -19,6 +19,8 @@ add_library(acl_cblas SHARED | |||
| 19 | target_include_directories(acl_cblas PRIVATE | 19 | target_include_directories(acl_cblas PRIVATE |
| 20 | ${CMAKE_CURRENT_LIST_DIR} | 20 | ${CMAKE_CURRENT_LIST_DIR} |
| 21 | ${CMAKE_CURRENT_LIST_DIR}/.. | 21 | ${CMAKE_CURRENT_LIST_DIR}/.. |
| 22 | + ${CMAKE_CURRENT_LIST_DIR}/../acl_model | ||
| 23 | + ${CMAKE_CURRENT_LIST_DIR}/../acl_op_executor | ||
| 22 | 24 | ||
| 23 | ${AIR_CODE_DIR}/inc | 25 | ${AIR_CODE_DIR}/inc |
| 24 | ${AIR_CODE_DIR}/inc/graph_metadef | 26 | ${AIR_CODE_DIR}/inc/graph_metadef |
| @@ -1,104 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * Copyright (c) 2025 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 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | -namespace acl { | ||
| 24 | - constexpr int64_t UNKNOW_DIM = -1; | ||
| 25 | - constexpr int64_t UNKNOW_RANK = -2; | ||
| 26 | - enum class AttrRangeType : std::uint8_t { | ||
| 27 | - RANGE_TYPE, | ||
| 28 | - VALUE_TYPE | ||
| 29 | - }; | ||
| 30 | - | ||
| 31 | - void ConvertSvecToVec(const ge::SmallVector<int64_t, static_cast<size_t>(ge::kDefaultMaxInputNum)> &svec, | ||
| 32 | - std::vector<int64_t> &vec); | ||
| 33 | - void ConvertVecToSvec(const std::vector<int64_t> &vec, ge::SmallVector<int64_t, | ||
| 34 | - static_cast<size_t>(ge::kDefaultMaxInputNum)> &svec); | ||
| 35 | -} | ||
| 36 | - | ||
| 37 | -struct ACL_FUNC_VISIBILITY aclTensorDesc { | ||
| 38 | - aclTensorDesc(const aclDataType aclTensorDataType, const std::initializer_list<int64_t> shape, | ||
| 39 | - const aclFormat aclTensorFormat); | ||
| 40 | - aclTensorDesc(const aclDataType aclTensorDataType, const size_t numDims, const int64_t *const aclTensorDims, | ||
| 41 | - const aclFormat aclTensorFormat); | ||
| 42 | - aclTensorDesc(const aclTensorDesc &tensorDesc); | ||
| 43 | - aclTensorDesc &operator=(const aclTensorDesc &tensorDesc); | ||
| 44 | - aclTensorDesc() = default; | ||
| 45 | - ~aclTensorDesc() = default; | ||
| 46 | - aclDataType dataType; | ||
| 47 | - aclFormat storageFormat = ACL_FORMAT_UNDEFINED; | ||
| 48 | - aclFormat format; | ||
| 49 | - ge::SmallVector<int64_t, static_cast<size_t>(ge::kDefaultMaxInputNum)> dims; | ||
| 50 | - ge::SmallVector<int64_t, static_cast<size_t>(ge::kDefaultMaxInputNum)> dimsBackup; | ||
| 51 | - ge::SmallVector<int64_t, static_cast<size_t>(ge::kDefaultMaxInputNum)> storageDims; | ||
| 52 | - ge::SmallVector<int64_t, static_cast<size_t>(ge::kDefaultMaxInputNum)> storageDimsBackup; | ||
| 53 | - std::string name; | ||
| 54 | - std::vector<std::pair<int64_t, int64_t>> shapeRange; | ||
| 55 | - std::vector<std::pair<int64_t, int64_t>> shapeRangeBackup; | ||
| 56 | - void *address = nullptr; | ||
| 57 | - std::string dynamicInputName; | ||
| 58 | - bool isConst = false; | ||
| 59 | - std::shared_ptr<void> constDataBuf; | ||
| 60 | - size_t constDataLen = 0U; | ||
| 61 | - bool isConstBackup = false; | ||
| 62 | - std::shared_ptr<void> constDataBufBackup; | ||
| 63 | - size_t constDataLenBackup = 0U; | ||
| 64 | - aclMemType memtype = ACL_MEMTYPE_DEVICE; | ||
| 65 | - // valRange is set from aclSetTensorValueRange | ||
| 66 | - std::vector<std::pair<int64_t, int64_t>> valRange; | ||
| 67 | - // for windows compile,use map ignore dvpp.so find the implementation GeAttrValue | ||
| 68 | - std::map<acl::AttrRangeType, ge::GeAttrValue> valueRange; | ||
| 69 | - std::string DebugString() const; | ||
| 70 | - bool IsSameTensor(const aclTensorDesc *const other) const; | ||
| 71 | - bool IsDynamicTensor() const; | ||
| 72 | - bool CheckShapeRange() const; | ||
| 73 | - bool IsConstTensor() const | ||
| 74 | - { | ||
| 75 | - return isConst; | ||
| 76 | - } | ||
| 77 | - bool IsHostMemTensor() const | ||
| 78 | - { | ||
| 79 | - return (memtype == ACL_MEMTYPE_HOST) || (memtype == ACL_MEMTYPE_HOST_COMPILE_INDEPENDENT); | ||
| 80 | - } | ||
| 81 | - inline bool IsOptinalTensor() const | ||
| 82 | - { | ||
| 83 | - return (dataType == ACL_DT_UNDEFINED) && (format == ACL_FORMAT_UNDEFINED) && (dims.empty()); | ||
| 84 | - } | ||
| 85 | - void Init(const aclTensorDesc &tensorDesc); | ||
| 86 | - void UpdateTensorShape(const std::vector<int64_t> &shape); | ||
| 87 | - void UpdateTensorShapeRange(const std::vector<std::pair<int64_t, int64_t>> &ranges); | ||
| 88 | - inline bool CheckConstTensor(const bool needCheckHostMem) const | ||
| 89 | - { | ||
| 90 | - return isConst || (needCheckHostMem && (memtype == ACL_MEMTYPE_HOST)); | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - bool operator==(const aclTensorDesc *const other) const; | ||
| 94 | - void BackupDimsAndShapeRanges(); | ||
| 95 | - void RecoverDimsAndShapeRanges(); | ||
| 96 | - void BackupConst(); | ||
| 97 | - void RecoverConst(); | ||
| 98 | - | ||
| 99 | -private: | ||
| 100 | - mutable std::string cachedKey; | ||
| 101 | - mutable std::string cachedShapeKey; | ||
| 102 | -}; | ||
| 103 | - | ||
| 104 | - | ||
| @@ -16,7 +16,7 @@ add_library(acl_mdl_impl SHARED | |||
| 16 | model/model_config.cpp | 16 | model/model_config.cpp |
| 17 | model/acl_resource_manager.cpp | 17 | model/acl_resource_manager.cpp |
| 18 | model/init_callback_register.cpp | 18 | model/init_callback_register.cpp |
| 19 | - types/acl_model_tensor_desc_internal.cpp | 19 | + types/tensor_desc_internal.cpp |
| 20 | ../common/json_parser.cpp | 20 | ../common/json_parser.cpp |
| 21 | ../common/log_inner.cpp | 21 | ../common/log_inner.cpp |
| 22 | ../utils/string_utils.cpp | 22 | ../utils/string_utils.cpp |
| @@ -28,6 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | + | ||
| 31 | 32 | ||
| 32 | namespace { | 33 | namespace { |
| 33 | constexpr int16_t FP16_MAX_EXP = 0x001F; | 34 | constexpr int16_t FP16_MAX_EXP = 0x001F; |
| @@ -63,14 +64,16 @@ constexpr float32_t MIN_CHN_MAX = 255.0F; | |||
| 63 | constexpr float32_t VR_CHN_MIN = -65504.0F; | 64 | constexpr float32_t VR_CHN_MIN = -65504.0F; |
| 64 | constexpr float32_t VR_CHN_MAX = 65504.0F; | 65 | constexpr float32_t VR_CHN_MAX = 65504.0F; |
| 65 | constexpr size_t STATIC_BATCH_INFO_SIZE = 1U; | 66 | constexpr size_t STATIC_BATCH_INFO_SIZE = 1U; |
| 67 | +constexpr uint32_t MAX_NPU_ARCH_LEN = 32U; | ||
| 66 | 68 | ||
| 67 | -static std::string GetSocName() | 69 | +static std::string GetNpuArch() |
| 68 | { | 70 | { |
| 69 | - const char *socName = aclrtGetSocName(); | 71 | + char npuArch[MAX_NPU_ARCH_LEN] = {0}; |
| 70 | - if (socName == nullptr) { | 72 | + const auto ret = rtGetSocSpec("version", "NpuArch", npuArch, sizeof(npuArch)); |
| 73 | + if (ret != RT_ERROR_NONE) { | ||
| 71 | return ""; | 74 | return ""; |
| 72 | } | 75 | } |
| 73 | - return std::string(socName); | 76 | + return std::string(npuArch); |
| 74 | } | 77 | } |
| 75 | 78 | ||
| 76 | static bool IsRoundOne(const uint64_t man, const uint16_t truncLen) | 79 | static bool IsRoundOne(const uint64_t man, const uint16_t truncLen) |
| @@ -427,7 +430,7 @@ static aclError GetAndCheckAippOutputShape(const uint32_t modelId, const aclmdlD | |||
| 427 | int64_t mdlOriH = 0; | 430 | int64_t mdlOriH = 0; |
| 428 | int64_t mdlOriW = 0; | 431 | int64_t mdlOriW = 0; |
| 429 | int64_t mdlOriN = 0; | 432 | int64_t mdlOriN = 0; |
| 430 | - const aclError result = acl::GetAippOutputHW(aippParmsSet, 0U, GetSocName(), aippOutputW, aippOutputH); | 433 | + const aclError result = acl::GetAippOutputHW(aippParmsSet, 0U, GetNpuArch(), aippOutputW, aippOutputH); |
| 431 | if (result != ACL_SUCCESS) { | 434 | if (result != ACL_SUCCESS) { |
| 432 | return result; | 435 | return result; |
| 433 | } | 436 | } |
| @@ -493,7 +496,7 @@ static aclError GetAndCheckAippParams(const uint32_t modelId, const aclmdlDesc & | |||
| 493 | } else { | 496 | } else { |
| 494 | ACL_LOG_INFO("current used model is old"); | 497 | ACL_LOG_INFO("current used model is old"); |
| 495 | } | 498 | } |
| 496 | - return acl::AippParamsCheck(aippParmsSet, GetSocName()); | 499 | + return acl::AippParamsCheck(aippParmsSet, GetNpuArch()); |
| 497 | } | 500 | } |
| 498 | 501 | ||
| 499 | static aclError VerifyIndex(const uint32_t modelId, const size_t idx, aclmdlDesc *const modelDesc) | 502 | static aclError VerifyIndex(const uint32_t modelId, const size_t idx, aclmdlDesc *const modelDesc) |
| @@ -812,13 +815,6 @@ aclmdlAIPP *aclmdlCreateAIPPImpl(uint64_t batchSize) | |||
| 812 | return nullptr; | 815 | return nullptr; |
| 813 | } | 816 | } |
| 814 | 817 | ||
| 815 | - const auto ret = memset_s(aippParmsSet, sizeof(aclmdlAIPP), 0, sizeof(aclmdlAIPP)); | ||
| 816 | - if (ret != EOK) { | ||
| 817 | - ACL_LOG_INNER_ERROR("[Set][Mem]memset failed, result[%d]", ret); | ||
| 818 | - ACL_DELETE(aippParmsSet); | ||
| 819 | - return nullptr; | ||
| 820 | - } | ||
| 821 | - | ||
| 822 | aippParmsSet->batchSize = batchSize; | 818 | aippParmsSet->batchSize = batchSize; |
| 823 | aippParmsSet->aippParms.batchNum = static_cast<int8_t>(batchSize); | 819 | aippParmsSet->aippParms.batchNum = static_cast<int8_t>(batchSize); |
| 824 | aippParmsSet->aippBatchPara.resize(batchSize); | 820 | aippParmsSet->aippBatchPara.resize(batchSize); |
| @@ -22,7 +22,6 @@ | |||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | - | ||
| 26 | 25 | ||
| 27 | 26 | ||
| 28 | 27 | ||
| @@ -35,19 +34,18 @@ class ExternalAllocatorDesc { | |||
| 35 | public: | 34 | public: |
| 36 | ExternalAllocatorDesc(): obj(nullptr), allocFunc(nullptr), freeFunc(nullptr), allocAdviseFunc(nullptr), getAddrFromBlockFunc(nullptr) {} | 35 | ExternalAllocatorDesc(): obj(nullptr), allocFunc(nullptr), freeFunc(nullptr), allocAdviseFunc(nullptr), getAddrFromBlockFunc(nullptr) {} |
| 37 | ExternalAllocatorDesc(aclrtAllocator allocator, | 36 | ExternalAllocatorDesc(aclrtAllocator allocator, |
| 38 | - aclrtAllocatorAllocFunc allocFunc, | 37 | + aclrtAllocatorAllocFunc allocFunction, |
| 39 | - aclrtAllocatorFreeFunc freeFunc, | 38 | + aclrtAllocatorFreeFunc freeFunction, |
| 40 | - aclrtAllocatorAllocAdviseFunc allocAdviseFunc, | 39 | + aclrtAllocatorAllocAdviseFunc allocAdviseFunction, |
| 41 | - aclrtAllocatorGetAddrFromBlockFunc getAddrFromBlockFunc) | 40 | + aclrtAllocatorGetAddrFromBlockFunc getAddrFromBlockFunction) : |
| 42 | - { | 41 | + obj(allocator), |
| 43 | - this->obj = allocator; | 42 | + allocFunc(allocFunction), |
| 44 | - this->allocFunc = allocFunc; | 43 | + freeFunc(freeFunction), |
| 45 | - this->freeFunc = freeFunc; | 44 | + allocAdviseFunc(allocAdviseFunction), |
| 46 | - this->allocAdviseFunc = allocAdviseFunc; | 45 | + getAddrFromBlockFunc(getAddrFromBlockFunction) {} |
| 47 | - this->getAddrFromBlockFunc = getAddrFromBlockFunc; | ||
| 48 | - } | ||
| 49 | ~ExternalAllocatorDesc() {} | 46 | ~ExternalAllocatorDesc() {} |
| 50 | - bool operator==(const ExternalAllocatorDesc &allocatorDesc) { | 47 | + bool operator==(const ExternalAllocatorDesc &allocatorDesc) const |
| 48 | + { | ||
| 51 | return obj == allocatorDesc.obj && | 49 | return obj == allocatorDesc.obj && |
| 52 | allocFunc == allocatorDesc.allocFunc && | 50 | allocFunc == allocatorDesc.allocFunc && |
| 53 | freeFunc == allocatorDesc.freeFunc && | 51 | freeFunc == allocatorDesc.freeFunc && |
| @@ -66,7 +64,7 @@ struct BundleModelInfo { | |||
| 66 | std::shared_ptr<gert::RtSession> rtSession; | 64 | std::shared_ptr<gert::RtSession> rtSession; |
| 67 | size_t varSize = 0U; | 65 | size_t varSize = 0U; |
| 68 | std::string fromFilePath; | 66 | std::string fromFilePath; |
| 69 | - std::shared_ptr<uint8_t> bundleModelData; | 67 | + std::shared_ptr<const uint8_t> bundleModelData; |
| 70 | size_t bundleModelSize = 0U; | 68 | size_t bundleModelSize = 0U; |
| 71 | std::vector<BundleSubModelInfo> subModelInfos; | 69 | std::vector<BundleSubModelInfo> subModelInfos; |
| 72 | std::vector<uint32_t> loadedSubModelId; // aclmdlBundleGetModelId use this when aclmdlBundleLoadFromxx is called | 70 | std::vector<uint32_t> loadedSubModelId; // aclmdlBundleGetModelId use this when aclmdlBundleLoadFromxx is called |
| @@ -9,22 +9,22 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | + | ||
| 12 | 13 | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ||
| 13 | 17 | ||
| 14 | namespace { | 18 | namespace { |
| 19 | + constexpr int32_t MIN_ALIGNMENT_YUV = 2; | ||
| 15 | constexpr uint32_t TWO_CHANNEL = 2U; | 20 | constexpr uint32_t TWO_CHANNEL = 2U; |
| 16 | constexpr uint32_t THREE_CHANNEL = 3U; | 21 | constexpr uint32_t THREE_CHANNEL = 3U; |
| 17 | constexpr uint32_t FOUR_CHANNEL = 4U; | 22 | constexpr uint32_t FOUR_CHANNEL = 4U; |
| 18 | constexpr uint32_t MULTIPLE = 16U; | 23 | constexpr uint32_t MULTIPLE = 16U; |
| 19 | - std::set<std::string> ascend310pSocVersionSet = {"Ascend310P1", "Ascend310P3", "Ascend310P5", "Ascend310P7"}; | ||
| 20 | - bool IsAscend310pSocVersion(const std::string &sovVersion) | ||
| 21 | - { | ||
| 22 | - return ascend310pSocVersionSet.count(sovVersion) > 0; | ||
| 23 | - } | ||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | namespace acl { | 26 | namespace acl { |
| 27 | -static aclError AippInputFormatCheck(const enum CceAippInputFormat inputFormat, const std::string &socVersion) | 27 | +static aclError AippInputFormatCheck(const enum CceAippInputFormat inputFormat, const std::string &npuArch) |
| 28 | { | 28 | { |
| 29 | bool flag = false; | 29 | bool flag = false; |
| 30 | if (inputFormat < CCE_YUV420SP_U8) { | 30 | if (inputFormat < CCE_YUV420SP_U8) { |
| @@ -33,25 +33,18 @@ static aclError AippInputFormatCheck(const enum CceAippInputFormat inputFormat, | |||
| 33 | return ACL_ERROR_INVALID_PARAM; | 33 | return ACL_ERROR_INVALID_PARAM; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | - if ((strncmp(socVersion.c_str(), "Ascend910", (sizeof("Ascend910") - 1UL)) == 0) || | 36 | + if (npuArch == NPUARCH_TO_STR(NpuArch::DAV_1001) || npuArch == NPUARCH_TO_STR(NpuArch::DAV_3002) || |
| 37 | - (strncmp(socVersion.c_str(), "Ascend310B", (sizeof("Ascend310B") - 1UL)) == 0)) { | 37 | + npuArch == NPUARCH_TO_STR(NpuArch::DAV_2002) || npuArch == NPUARCH_TO_STR(NpuArch::DAV_2201) || |
| 38 | + npuArch == NPUARCH_TO_STR(NpuArch::DAV_3510)) { | ||
| 38 | flag = ((inputFormat != CCE_YUV420SP_U8) && (inputFormat != CCE_XRGB8888_U8) && | 39 | flag = ((inputFormat != CCE_YUV420SP_U8) && (inputFormat != CCE_XRGB8888_U8) && |
| 39 | (inputFormat != CCE_RGB888_U8) && (inputFormat != CCE_YUV400_U8)); | 40 | (inputFormat != CCE_RGB888_U8) && (inputFormat != CCE_YUV400_U8)); |
| 40 | if (flag) { | 41 | if (flag) { |
| 41 | - ACL_LOG_INNER_ERROR("[Check][InputFormat]%s only support YUV420SP_U8, XRGB8888_U8, " | 42 | + ACL_LOG_INNER_ERROR("[Check][InputFormat]arch[%s] only support YUV420SP_U8, XRGB8888_U8, " |
| 42 | - "RGB888_U8, YUV400_U8, cceInputFormat = %d", socVersion.c_str(), static_cast<int32_t>(inputFormat)); | 43 | + "RGB888_U8, YUV400_U8, cceInputFormat = %d", npuArch.c_str(), static_cast<int32_t>(inputFormat)); |
| 43 | - return ACL_ERROR_INVALID_PARAM; | ||
| 44 | - } | ||
| 45 | - } else if (IsAscend310pSocVersion(socVersion)) { | ||
| 46 | - flag = ((inputFormat != CCE_YUV420SP_U8) && (inputFormat != CCE_XRGB8888_U8) && | ||
| 47 | - (inputFormat != CCE_RGB888_U8) && (inputFormat != CCE_YUV400_U8)); | ||
| 48 | - if (flag) { | ||
| 49 | - ACL_LOG_INNER_ERROR("[Check][InputFormat]%s only support YUV420SP_U8, XRGB8888_U8, RGB888_U8,YUV400_U8, " | ||
| 50 | - "cce_inputFormat = %d", socVersion.c_str(), static_cast<int32_t>(inputFormat)); | ||
| 51 | return ACL_ERROR_INVALID_PARAM; | 44 | return ACL_ERROR_INVALID_PARAM; |
| 52 | } | 45 | } |
| 53 | } else { | 46 | } else { |
| 54 | - ACL_LOG_INNER_ERROR("[Check][Aipp]dynamic aipp not support %s", socVersion.c_str()); | 47 | + ACL_LOG_INNER_ERROR("[Check][Aipp]dynamic aipp not support arch[%s]", npuArch.c_str()); |
| 55 | return ACL_ERROR_INVALID_PARAM; | 48 | return ACL_ERROR_INVALID_PARAM; |
| 56 | } | 49 | } |
| 57 | return ACL_SUCCESS; | 50 | return ACL_SUCCESS; |
| @@ -86,6 +79,7 @@ static aclError AippSrcImageSizeCheck(const enum CceAippInputFormat inputFormat, | |||
| 86 | return ACL_ERROR_INVALID_PARAM; | 79 | return ACL_ERROR_INVALID_PARAM; |
| 87 | } | 80 | } |
| 88 | } | 81 | } |
| 82 | + | ||
| 89 | return ACL_SUCCESS; | 83 | return ACL_SUCCESS; |
| 90 | } | 84 | } |
| 91 | 85 | ||
| @@ -200,7 +194,7 @@ static aclError AippCropSizeCheck(const aclmdlAIPP *const aippParmsSet, const si | |||
| 200 | static_cast<enum CceAippInputFormat>(aippParmsSet->aippParms.inputFormat); | 194 | static_cast<enum CceAippInputFormat>(aippParmsSet->aippParms.inputFormat); |
| 201 | if (inputFormat == CCE_YUV420SP_U8) { | 195 | if (inputFormat == CCE_YUV420SP_U8) { |
| 202 | // determine whether it is even | 196 | // determine whether it is even |
| 203 | - if (((cropStartPosW % 2) != 0) || ((cropStartPosH % 2) != 0)) { | 197 | + if (((cropStartPosW % MIN_ALIGNMENT_YUV) != 0) || ((cropStartPosH % MIN_ALIGNMENT_YUV) != 0)) { |
| 204 | ACL_LOG_INNER_ERROR("[Check][Params]cropStartPosW[%d], cropStartPosH[%d] must be even for YUV420SP_U8!", | 198 | ACL_LOG_INNER_ERROR("[Check][Params]cropStartPosW[%d], cropStartPosH[%d] must be even for YUV420SP_U8!", |
| 205 | cropStartPosW, cropStartPosH); | 199 | cropStartPosW, cropStartPosH); |
| 206 | return ACL_ERROR_INVALID_PARAM; | 200 | return ACL_ERROR_INVALID_PARAM; |
| @@ -208,7 +202,7 @@ static aclError AippCropSizeCheck(const aclmdlAIPP *const aippParmsSet, const si | |||
| 208 | } | 202 | } |
| 209 | if ((inputFormat == CCE_YUV422SP_U8) || (inputFormat == CCE_YUYV_U8)) { | 203 | if ((inputFormat == CCE_YUV422SP_U8) || (inputFormat == CCE_YUYV_U8)) { |
| 210 | // determine whether it is even | 204 | // determine whether it is even |
| 211 | - if ((cropStartPosW % 2) != 0) { | 205 | + if ((cropStartPosW % MIN_ALIGNMENT_YUV) != 0) { |
| 212 | ACL_LOG_INNER_ERROR("[Check][Params]cropStartPosW[%d] must be even for YUV422SP_U8 and YUYV_U8!", | 206 | ACL_LOG_INNER_ERROR("[Check][Params]cropStartPosW[%d] must be even for YUV422SP_U8 and YUYV_U8!", |
| 213 | cropStartPosW); | 207 | cropStartPosW); |
| 214 | return ACL_ERROR_INVALID_PARAM; | 208 | return ACL_ERROR_INVALID_PARAM; |
| @@ -219,7 +213,7 @@ static aclError AippCropSizeCheck(const aclmdlAIPP *const aippParmsSet, const si | |||
| 219 | } | 213 | } |
| 220 | 214 | ||
| 221 | 215 | ||
| 222 | -aclError GetAippOutputHW(const aclmdlAIPP *const aippParmsSet, const size_t batchIndex, const std::string &socVersion, | 216 | +aclError GetAippOutputHW(const aclmdlAIPP *const aippParmsSet, const size_t batchIndex, const std::string &npuArch, |
| 223 | int32_t &aippOutputW, int32_t &aippOutputH) | 217 | int32_t &aippOutputW, int32_t &aippOutputH) |
| 224 | { | 218 | { |
| 225 | if (aippParmsSet->aippBatchPara.empty()) { | 219 | if (aippParmsSet->aippBatchPara.empty()) { |
| @@ -251,12 +245,13 @@ aclError GetAippOutputHW(const aclmdlAIPP *const aippParmsSet, const size_t batc | |||
| 251 | + aippParmsSet->aippBatchPara[batchIndex].paddingSizeRight; | 245 | + aippParmsSet->aippBatchPara[batchIndex].paddingSizeRight; |
| 252 | aippOutputH += aippParmsSet->aippBatchPara[batchIndex].paddingSizeTop | 246 | aippOutputH += aippParmsSet->aippBatchPara[batchIndex].paddingSizeTop |
| 253 | + aippParmsSet->aippBatchPara[batchIndex].paddingSizeBottom; | 247 | + aippParmsSet->aippBatchPara[batchIndex].paddingSizeBottom; |
| 254 | - const bool flag = (IsAscend310pSocVersion(socVersion)) || | 248 | + const bool flag = |
| 255 | - (strncmp(socVersion.c_str(), "Ascend910", (sizeof("Ascend910") - 1UL)) == 0); | 249 | + (npuArch == NPUARCH_TO_STR(NpuArch::DAV_1001)) || (npuArch == NPUARCH_TO_STR(NpuArch::DAV_2002)) || |
| 250 | + (npuArch == NPUARCH_TO_STR(NpuArch::DAV_2201)) || (npuArch == NPUARCH_TO_STR(NpuArch::DAV_3510)); | ||
| 256 | if (flag) { | 251 | if (flag) { |
| 257 | ACL_CHECK_WITH_INNER_MESSAGE_AND_RETURN(aippOutputW <= 1080, ACL_ERROR_INVALID_PARAM, | 252 | ACL_CHECK_WITH_INNER_MESSAGE_AND_RETURN(aippOutputW <= 1080, ACL_ERROR_INVALID_PARAM, |
| 258 | - "[Check][Params]after padding, aipp output W[%d] should be less than or equal to 1080 for %s", | 253 | + "[Check][Params]after padding, aipp output W[%d] should be less than or equal to 1080 for arch[%s]", |
| 259 | - aippOutputW, socVersion.c_str()); | 254 | + aippOutputW, npuArch.c_str()); |
| 260 | } else { | 255 | } else { |
| 261 | ACL_LOG_INFO("no need to check aipp output width."); | 256 | ACL_LOG_INFO("no need to check aipp output width."); |
| 262 | } | 257 | } |
| @@ -265,7 +260,7 @@ aclError GetAippOutputHW(const aclmdlAIPP *const aippParmsSet, const size_t batc | |||
| 265 | return ACL_SUCCESS; | 260 | return ACL_SUCCESS; |
| 266 | } | 261 | } |
| 267 | 262 | ||
| 268 | -static aclError AippDynamicBatchParaCheck(const aclmdlAIPP *const aippParmsSet, const std::string &socVersion) | 263 | +static aclError AippDynamicBatchParaCheck(const aclmdlAIPP *const aippParmsSet, const std::string &npuArch) |
| 269 | { | 264 | { |
| 270 | int8_t scfSwitch = 0; | 265 | int8_t scfSwitch = 0; |
| 271 | int8_t cropSwitch = 0; | 266 | int8_t cropSwitch = 0; |
| @@ -274,7 +269,7 @@ static aclError AippDynamicBatchParaCheck(const aclmdlAIPP *const aippParmsSet, | |||
| 274 | int32_t aippFirstOutputW = 0; | 269 | int32_t aippFirstOutputW = 0; |
| 275 | int32_t aippFirstOutputH = 0; | 270 | int32_t aippFirstOutputH = 0; |
| 276 | 271 | ||
| 277 | - aclError result = GetAippOutputHW(aippParmsSet, 0UL, socVersion, aippFirstOutputW, aippFirstOutputH); | 272 | + aclError result = GetAippOutputHW(aippParmsSet, 0UL, npuArch, aippFirstOutputW, aippFirstOutputH); |
| 278 | if (result != ACL_SUCCESS) { | 273 | if (result != ACL_SUCCESS) { |
| 279 | return result; | 274 | return result; |
| 280 | } | 275 | } |
| @@ -297,7 +292,7 @@ static aclError AippDynamicBatchParaCheck(const aclmdlAIPP *const aippParmsSet, | |||
| 297 | } | 292 | } |
| 298 | } | 293 | } |
| 299 | 294 | ||
| 300 | - result = GetAippOutputHW(aippParmsSet, static_cast<size_t>(i), socVersion, aippBatchOutputW, aippBatchOutputH); | 295 | + result = GetAippOutputHW(aippParmsSet, static_cast<size_t>(i), npuArch, aippBatchOutputW, aippBatchOutputH); |
| 301 | if (result != ACL_SUCCESS) { | 296 | if (result != ACL_SUCCESS) { |
| 302 | return result; | 297 | return result; |
| 303 | } | 298 | } |
| @@ -315,14 +310,14 @@ static aclError AippDynamicBatchParaCheck(const aclmdlAIPP *const aippParmsSet, | |||
| 315 | return ACL_SUCCESS; | 310 | return ACL_SUCCESS; |
| 316 | } | 311 | } |
| 317 | 312 | ||
| 318 | -aclError AippParamsCheck(const aclmdlAIPP *const aippParmsSet, const std::string &socVersion) | 313 | +aclError AippParamsCheck(const aclmdlAIPP *const aippParmsSet, const std::string &npuArch) |
| 319 | { | 314 | { |
| 320 | ACL_LOG_INFO("start to execute aclAippParamsCheck"); | 315 | ACL_LOG_INFO("start to execute aclAippParamsCheck"); |
| 321 | ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(aippParmsSet); | 316 | ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(aippParmsSet); |
| 322 | 317 | ||
| 323 | const enum CceAippInputFormat inputFormat = | 318 | const enum CceAippInputFormat inputFormat = |
| 324 | static_cast<enum CceAippInputFormat>(aippParmsSet->aippParms.inputFormat); | 319 | static_cast<enum CceAippInputFormat>(aippParmsSet->aippParms.inputFormat); |
| 325 | - aclError result = AippInputFormatCheck(inputFormat, socVersion); | 320 | + aclError result = AippInputFormatCheck(inputFormat, npuArch); |
| 326 | if (result != ACL_SUCCESS) { | 321 | if (result != ACL_SUCCESS) { |
| 327 | return result; | 322 | return result; |
| 328 | } | 323 | } |
| @@ -346,7 +341,7 @@ aclError AippParamsCheck(const aclmdlAIPP *const aippParmsSet, const std::string | |||
| 346 | return result; | 341 | return result; |
| 347 | } | 342 | } |
| 348 | 343 | ||
| 349 | - result = AippDynamicBatchParaCheck(aippParmsSet, socVersion); | 344 | + result = AippDynamicBatchParaCheck(aippParmsSet, npuArch); |
| 350 | if (result != ACL_SUCCESS) { | 345 | if (result != ACL_SUCCESS) { |
| 351 | return result; | 346 | return result; |
| 352 | } | 347 | } |
| @@ -404,4 +399,4 @@ uint64_t GetSrcImageSize(const aclmdlAIPP *const aippParmsSet) | |||
| 404 | ACL_LOG_INFO("Input SrcImageSize = %lu, cce_InputFormat = %d", size, static_cast<int32_t>(inputFormat)); | 399 | ACL_LOG_INFO("Input SrcImageSize = %lu, cce_InputFormat = %d", size, static_cast<int32_t>(inputFormat)); |
| 405 | return size; | 400 | return size; |
| 406 | } | 401 | } |
| 407 | -} // namespace acl | 402 | +} // namespace acl |
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | + | ||
| 16 | 17 | ||
| 17 | namespace { | 18 | namespace { |
| 18 | void HandleReleaseSourceByDevice(int32_t deviceId, aclrtDeviceState state, void *args) | 19 | void HandleReleaseSourceByDevice(int32_t deviceId, aclrtDeviceState state, void *args) |
| @@ -130,4 +131,4 @@ __attribute__((destructor)) aclError UnRegResourceFinalizeCallback() | |||
| 130 | { | 131 | { |
| 131 | return aclFinalizeCallbackUnRegister(ACL_REG_TYPE_OTHER, ResourceFinalizeCallbackFunc); | 132 | return aclFinalizeCallbackUnRegister(ACL_REG_TYPE_OTHER, ResourceFinalizeCallbackFunc); |
| 132 | } | 133 | } |
| 133 | -} | 134 | +} |
| @@ -36,8 +36,8 @@ | |||
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | -#include "types/acl_model_tensor_desc_internal.h" | 39 | +#include "types/tensor_desc_internal.h" |
| 40 | -#include "types/acl_model_data_buffer_internal.h" | 40 | +#include "types/data_buffer_internal.h" |
| 41 | 41 | ||
| 42 | 42 | ||
| 43 | namespace { | 43 | namespace { |
| @@ -444,39 +444,39 @@ static aclError IsSupportRuntimeV2WithModelPath(const char *filePath, bool &isSu | |||
| 444 | static aclError GetBundleNumAndOffset(const void *const model, const size_t modelSize, | 444 | static aclError GetBundleNumAndOffset(const void *const model, const size_t modelSize, |
| 445 | size_t &varSize, std::vector<std::pair<size_t, size_t>> &subModelOffsetAndSize) | 445 | size_t &varSize, std::vector<std::pair<size_t, size_t>> &subModelOffsetAndSize) |
| 446 | { | 446 | { |
| 447 | - varSize = 0U; | 447 | + varSize = 0U; |
| 448 | - size_t currentOffset = 0U; | 448 | + size_t currentOffset = 0U; |
| 449 | - if (modelSize < (sizeof(ge::ModelFileHeader) + sizeof(ge::ModelPartitionTable))) { | 449 | + if (modelSize < (sizeof(ge::ModelFileHeader) + sizeof(ge::ModelPartitionTable))) { |
| 450 | - ACL_LOG_ERROR("[Check][Param] Invalid model size, Model data size %zu must be greater than or equal to %zu.", | 450 | + ACL_LOG_ERROR("[Check][Param] Invalid model size, Model data size %zu must be greater than or equal to %zu.", |
| 451 | - modelSize, sizeof(ge::ModelFileHeader)); | 451 | + modelSize, sizeof(ge::ModelFileHeader)); |
| 452 | - return ACL_ERROR_INVALID_PARAM; | 452 | + return ACL_ERROR_INVALID_PARAM; |
| 453 | + } | ||
| 454 | + const auto *fileHeader = ge::PtrToPtr<void, ge::ModelFileHeader>(model); | ||
| 455 | + if (fileHeader->modeltype != ge::MODEL_TYPE_BUNDLE_MODEL) { | ||
| 456 | + ACL_LOG_ERROR("this is not bundle om, please check"); | ||
| 457 | + return ACL_ERROR_INVALID_PARAM; | ||
| 458 | + } | ||
| 459 | + currentOffset += sizeof(ge::ModelFileHeader); | ||
| 460 | + const auto *partitionTable = | ||
| 461 | + ge::PtrToPtr<void, ge::ModelPartitionTable>(ge::ValueToPtr(ge::PtrToValue(model) + currentOffset)); | ||
| 462 | + const size_t partitionTableSize = ge::SizeOfModelPartitionTable(*partitionTable); | ||
| 463 | + ACL_LOG_INFO("get offset %zu, partitionTableSize %zu", currentOffset, partitionTableSize); | ||
| 464 | + ACL_REQUIRES_OK(acl::CheckSizeTAddOverflow(currentOffset, partitionTableSize, currentOffset)); | ||
| 465 | + ACL_REQUIRES_LE(currentOffset, modelSize); | ||
| 466 | + for (size_t i = 0; i < partitionTable->num; ++i) { | ||
| 467 | + ACL_LOG_INFO("get %zu om offset %zu, size %zu", i, currentOffset, partitionTable->partition[i].mem_size); | ||
| 468 | + if (partitionTable->partition[i].type == ge::BUNDLE_MODEL_VAR_INFO) { | ||
| 469 | + varSize = *ge::PtrToPtr<void, int64_t>(ge::ValueToPtr(ge::PtrToValue(model) + currentOffset)); | ||
| 470 | + ACL_LOG_INFO("get var size %zu", varSize); | ||
| 453 | } | 471 | } |
| 454 | - const auto *fileHeader = ge::PtrToPtr<void, ge::ModelFileHeader>(model); | 472 | + if (partitionTable->partition[i].type == ge::BUNDLE_MODEL_INFO) { |
| 455 | - if (fileHeader->modeltype != ge::MODEL_TYPE_BUNDLE_MODEL) { | 473 | + subModelOffsetAndSize.emplace_back(currentOffset, partitionTable->partition[i].mem_size); |
| 456 | - ACL_LOG_ERROR("this is not bundle om, please check"); | ||
| 457 | - return ACL_ERROR_INVALID_PARAM; | ||
| 458 | } | 474 | } |
| 459 | - currentOffset += sizeof(ge::ModelFileHeader); | 475 | + ACL_REQUIRES_OK(acl::CheckSizeTAddOverflow(currentOffset, |
| 460 | - const auto *partitionTable = | 476 | + partitionTable->partition[i].mem_size, currentOffset)); |
| 461 | - ge::PtrToPtr<void, ge::ModelPartitionTable>(ge::ValueToPtr(ge::PtrToValue(model) + currentOffset)); | ||
| 462 | - const size_t partitionTableSize = ge::SizeOfModelPartitionTable(*partitionTable); | ||
| 463 | - ACL_LOG_INFO("get offset %zu, partitionTableSize %zu", currentOffset, partitionTableSize); | ||
| 464 | - ACL_REQUIRES_OK(acl::CheckSizeTAddOverflow(currentOffset, partitionTableSize, currentOffset)); | ||
| 465 | ACL_REQUIRES_LE(currentOffset, modelSize); | 477 | ACL_REQUIRES_LE(currentOffset, modelSize); |
| 466 | - for (size_t i = 0; i < partitionTable->num; ++i) { | 478 | + } |
| 467 | - ACL_LOG_INFO("get %zu om offset %zu, size %zu", i, currentOffset, partitionTable->partition[i].mem_size); | 479 | + return ACL_SUCCESS; |
| 468 | - if (partitionTable->partition[i].type == ge::BUNDLE_MODEL_VAR_INFO) { | ||
| 469 | - varSize = *ge::PtrToPtr<void, int64_t>(ge::ValueToPtr(ge::PtrToValue(model) + currentOffset)); | ||
| 470 | - ACL_LOG_INFO("get var size %zu", varSize); | ||
| 471 | - } | ||
| 472 | - if (partitionTable->partition[i].type == ge::BUNDLE_MODEL_INFO) { | ||
| 473 | - subModelOffsetAndSize.emplace_back(currentOffset, partitionTable->partition[i].mem_size); | ||
| 474 | - } | ||
| 475 | - ACL_REQUIRES_OK(acl::CheckSizeTAddOverflow(currentOffset, | ||
| 476 | - partitionTable->partition[i].mem_size, currentOffset)); | ||
| 477 | - ACL_REQUIRES_LE(currentOffset, modelSize); | ||
| 478 | - } | ||
| 479 | - return ACL_SUCCESS; | ||
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | static aclError IsSupportRuntimeV2WithModelData(const void *const model, const size_t modelSize, | 482 | static aclError IsSupportRuntimeV2WithModelData(const void *const model, const size_t modelSize, |
| @@ -1891,7 +1891,7 @@ static aclError LoadBundleSubModelFromMem(const void *const currentModePtr, cons | |||
| 1891 | return ret; | 1891 | return ret; |
| 1892 | } | 1892 | } |
| 1893 | 1893 | ||
| 1894 | -static aclError BundleInitFromMem(std::shared_ptr<uint8_t> model, size_t modelSize, const std::string &modelPath, | 1894 | +static aclError BundleInitFromMem(std::shared_ptr<const uint8_t> model, size_t modelSize, const std::string &modelPath, |
| 1895 | void *varWeightPtr, size_t varWeightSize, uint32_t *bundleId) | 1895 | void *varWeightPtr, size_t varWeightSize, uint32_t *bundleId) |
| 1896 | { | 1896 | { |
| 1897 | // get bundle num from file header | 1897 | // get bundle num from file header |
| @@ -2202,9 +2202,9 @@ aclError aclmdlBundleInitFromMemImpl(const void* model, size_t modelSize, void * | |||
| 2202 | ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(bundleId); | 2202 | ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(bundleId); |
| 2203 | ACL_LOG_INFO("start to execute aclmdlBundleInitFromMem, model size %zu, varWeightSize %zu", | 2203 | ACL_LOG_INFO("start to execute aclmdlBundleInitFromMem, model size %zu, varWeightSize %zu", |
| 2204 | modelSize, varWeightSize); | 2204 | modelSize, varWeightSize); |
| 2205 | - std::shared_ptr<uint8_t> tmpData; | 2205 | + std::shared_ptr<const uint8_t> tmpData; |
| 2206 | // no delete func | 2206 | // no delete func |
| 2207 | - tmpData.reset(ge::PtrToPtr<void, uint8_t>(const_cast<void *>(model)), [](const uint8_t* const p) { (void) p; }); | 2207 | + tmpData.reset(ge::PtrToPtr<void, uint8_t>(model), [](const uint8_t* const p) { (void) p; }); |
| 2208 | ACL_REQUIRES_OK(BundleInitFromMem(tmpData, modelSize, "", varWeightPtr, varWeightSize, bundleId)); | 2208 | ACL_REQUIRES_OK(BundleInitFromMem(tmpData, modelSize, "", varWeightPtr, varWeightSize, bundleId)); |
| 2209 | ACL_LOG_INFO("end to execute aclmdlBundleInitFromMem, model size %zu, varWeightSize %zu, bundleId %u", | 2209 | ACL_LOG_INFO("end to execute aclmdlBundleInitFromMem, model size %zu, varWeightSize %zu, bundleId %u", |
| 2210 | modelSize, varWeightSize, *bundleId); | 2210 | modelSize, varWeightSize, *bundleId); |
| @@ -7,6 +7,7 @@ | |||
| 7 | * 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. |
| 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 | ||
| 11 | 12 | ||
| 12 | 13 | ||
| @@ -125,12 +125,9 @@ struct aclmdlDataset { | |||
| 125 | }; | 125 | }; |
| 126 | 126 | ||
| 127 | struct aclmdlAIPP { | 127 | struct aclmdlAIPP { |
| 128 | - aclmdlAIPP() | 128 | + uint64_t batchSize = 0U; |
| 129 | - : batchSize(0U) {} | ||
| 130 | - ~aclmdlAIPP() = default; | ||
| 131 | - uint64_t batchSize; | ||
| 132 | std::vector<kAippDynamicBatchPara> aippBatchPara; | 129 | std::vector<kAippDynamicBatchPara> aippBatchPara; |
| 133 | - kAippDynamicPara aippParms; | 130 | + kAippDynamicPara aippParms{}; |
| 134 | }; | 131 | }; |
| 135 | 132 | ||
| 136 | struct aclAippExtendInfo { | 133 | struct aclAippExtendInfo { |
Rapi/acl/acl_model/types/acl_model_tensor_desc_internal.cpp→api/acl/acl_model/types/tensor_desc_internal.cpp+8-7
| @@ -8,7 +8,7 @@ | |||
| 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 | -#include "acl_model_tensor_desc_internal.h" | 11 | +#include "tensor_desc_internal.h" |
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | 14 | ||
| @@ -39,20 +39,21 @@ namespace acl { | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | aclTensorDesc::aclTensorDesc(const aclDataType aclTensorDataType, | 41 | aclTensorDesc::aclTensorDesc(const aclDataType aclTensorDataType, |
| 42 | - const std::initializer_list<int64_t> shape, const aclFormat aclTensorFormat): dims(shape) | 42 | + const std::initializer_list<int64_t> shape, const aclFormat aclTensorFormat) : |
| 43 | + dataType(aclTensorDataType), | ||
| 44 | + format(aclTensorFormat), | ||
| 45 | + dims(shape) | ||
| 43 | { | 46 | { |
| 44 | - this->dataType = aclTensorDataType; | ||
| 45 | - this->format = aclTensorFormat; | ||
| 46 | if (acl::AclResourceManager::GetInstance().IsRuntimeV2Enable(false)) { // how to deal with it for model? | 47 | if (acl::AclResourceManager::GetInstance().IsRuntimeV2Enable(false)) { // how to deal with it for model? |
| 47 | this->storageDims = dims; | 48 | this->storageDims = dims; |
| 48 | } | 49 | } |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | aclTensorDesc::aclTensorDesc(const aclDataType aclTensorDataType, | 52 | aclTensorDesc::aclTensorDesc(const aclDataType aclTensorDataType, |
| 52 | - const size_t numDims, const int64_t *const aclTensorDims, const aclFormat aclTensorFormat) | 53 | + const size_t numDims, const int64_t *const aclTensorDims, const aclFormat aclTensorFormat) : |
| 54 | + dataType(aclTensorDataType), | ||
| 55 | + format(aclTensorFormat) | ||
| 53 | { | 56 | { |
| 54 | - this->dataType = aclTensorDataType; | ||
| 55 | - this->format = aclTensorFormat; | ||
| 56 | for (size_t i = 0U; i < numDims; ++i) { | 57 | for (size_t i = 0U; i < numDims; ++i) { |
| 57 | this->dims.push_back(*(aclTensorDims + i)); | 58 | this->dims.push_back(*(aclTensorDims + i)); |
| 58 | } | 59 | } |
Rapi/acl/acl_op_executor/types/tensor_desc_internal.h→api/acl/acl_model/types/tensor_desc_internal.h+1-0
| @@ -30,6 +30,7 @@ namespace acl { | |||
| 30 | 30 | ||
| 31 | void ACL_FUNC_VISIBILITY ConvertSvecToVec(const ge::SmallVector<int64_t, | 31 | void ACL_FUNC_VISIBILITY ConvertSvecToVec(const ge::SmallVector<int64_t, |
| 32 | static_cast<size_t>(ge::kDefaultMaxInputNum)> &svec, std::vector<int64_t> &vec); | 32 | static_cast<size_t>(ge::kDefaultMaxInputNum)> &svec, std::vector<int64_t> &vec); |
| 33 | + // use only for aclop | ||
| 33 | void ACL_FUNC_VISIBILITY ConvertVecToSvec(const std::vector<int64_t> &vec, ge::SmallVector<int64_t, | 34 | void ACL_FUNC_VISIBILITY ConvertVecToSvec(const std::vector<int64_t> &vec, ge::SmallVector<int64_t, |
| 34 | static_cast<size_t>(ge::kDefaultMaxInputNum)> &svec); | 35 | static_cast<size_t>(ge::kDefaultMaxInputNum)> &svec); |
| 35 | } | 36 | } |
| @@ -27,10 +27,13 @@ target_include_directories(acl_op_compiler PRIVATE | |||
| 27 | ${CMAKE_CURRENT_LIST_DIR}/.. | 27 | ${CMAKE_CURRENT_LIST_DIR}/.. |
| 28 | ${CMAKE_CURRENT_LIST_DIR}/../common | 28 | ${CMAKE_CURRENT_LIST_DIR}/../common |
| 29 | ${CMAKE_CURRENT_LIST_DIR}/../utils | 29 | ${CMAKE_CURRENT_LIST_DIR}/../utils |
| 30 | + ${CMAKE_CURRENT_LIST_DIR}/../acl_model | ||
| 31 | + ${CMAKE_CURRENT_LIST_DIR}/../acl_op_executor | ||
| 30 | ${CMAKE_CURRENT_LIST_DIR}/compile | 32 | ${CMAKE_CURRENT_LIST_DIR}/compile |
| 31 | ${CMAKE_CURRENT_LIST_DIR}/utils | 33 | ${CMAKE_CURRENT_LIST_DIR}/utils |
| 32 | ${CMAKE_CURRENT_LIST_DIR}/single_op | 34 | ${CMAKE_CURRENT_LIST_DIR}/single_op |
| 33 | ${CMAKE_CURRENT_LIST_DIR}/../acl_op_executor/single_op | 35 | ${CMAKE_CURRENT_LIST_DIR}/../acl_op_executor/single_op |
| 36 | + ${CMAKE_CURRENT_LIST_DIR}/../acl_op_executor/single_op/compile | ||
| 34 | 37 | ||
| 35 | ${AIR_CODE_DIR}/inc | 38 | ${AIR_CODE_DIR}/inc |
| 36 | ${AIR_CODE_DIR}/inc/external | 39 | ${AIR_CODE_DIR}/inc/external |
| @@ -91,6 +94,7 @@ target_link_libraries(acl_op_compiler PRIVATE | |||
| 91 | ge_runner | 94 | ge_runner |
| 92 | ge_common_base | 95 | ge_common_base |
| 93 | error_manager | 96 | error_manager |
| 97 | + platform | ||
| 94 | -Wl,--as-needed | 98 | -Wl,--as-needed |
| 95 | -ldl | 99 | -ldl |
| 96 | $<$<NOT:$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-lrt> | 100 | $<$<NOT:$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-lrt> |
| @@ -18,6 +18,11 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 21 | 26 | ||
| 22 | namespace { | 27 | namespace { |
| 23 | constexpr size_t COMPILE_OPT_SIZE = 256U; | 28 | constexpr size_t COMPILE_OPT_SIZE = 256U; |
| @@ -38,6 +43,13 @@ std::map<aclCompileOpt, std::string> compileOptMap = {{ACL_PRECISION_MODE, ge::P | |||
| 38 | {ACL_ALLOW_HF32, "ge.exec.allow_hf32"}, | 43 | {ACL_ALLOW_HF32, "ge.exec.allow_hf32"}, |
| 39 | {ACL_OP_DEBUG_OPTION, "op_debug_option"}}; | 44 | {ACL_OP_DEBUG_OPTION, "op_debug_option"}}; |
| 40 | 45 | ||
| 46 | +// A set of NPU architecture IDs for which JIT compilation is enabled by default. | ||
| 47 | +const std::set<std::string> kJitCompileEnabledByArch = { | ||
| 48 | + NPUARCH_TO_STR(NpuArch::DAV_1001), NPUARCH_TO_STR(NpuArch::DAV_2002), NPUARCH_TO_STR(NpuArch::DAV_2102), | ||
| 49 | + NPUARCH_TO_STR(NpuArch::DAV_3002), NPUARCH_TO_STR(NpuArch::DAV_3004), NPUARCH_TO_STR(NpuArch::DAV_3505), | ||
| 50 | + NPUARCH_TO_STR(NpuArch::DAV_3102), NPUARCH_TO_STR(NpuArch::DAV_5102), | ||
| 51 | +}; | ||
| 52 | + | ||
| 41 | aclError CheckInput(const char *opType, const int32_t numInputs, const aclTensorDesc *const inputDesc[], | 53 | aclError CheckInput(const char *opType, const int32_t numInputs, const aclTensorDesc *const inputDesc[], |
| 42 | const aclDataBuffer *const inputs[], const int32_t numOutputs, | 54 | const aclDataBuffer *const inputs[], const int32_t numOutputs, |
| 43 | const aclTensorDesc *const outputDesc[], aclDataBuffer *const outputs[], | 55 | const aclTensorDesc *const outputDesc[], aclDataBuffer *const outputs[], |
| @@ -105,20 +117,26 @@ aclError CopyOptValue(char *value, size_t length, const std::string &str) | |||
| 105 | ACL_LOG_INNER_ERROR("[Copy][Str]call strncpy_s failed, length: %zu, src size: %zu", length, str.size()); | 117 | ACL_LOG_INNER_ERROR("[Copy][Str]call strncpy_s failed, length: %zu, src size: %zu", length, str.size()); |
| 106 | return ACL_ERROR_FAILURE; | 118 | return ACL_ERROR_FAILURE; |
| 107 | } | 119 | } |
| 108 | - *(value + str.size()) = '\0'; | ||
| 109 | return ACL_SUCCESS; | 120 | return ACL_SUCCESS; |
| 110 | } | 121 | } |
| 111 | 122 | ||
| 112 | -std::string GetDefaultJitCompileValue(const std::string &version) | 123 | +std::string GetDefaultJitCompileValue() |
| 113 | { | 124 | { |
| 114 | - static const std::set<std::string> kDisabledVersion = {"Ascend910B1", "Ascend910B2", "Ascend910B3", | 125 | + std::string jit_compile_value = "disable"; |
| 115 | - "Ascend910B4", "Ascend910B4-1", "Ascend910B2C"}; | 126 | + constexpr uint32_t kMaxValueLen = 16U; |
| 116 | - static const std::string kDisabledShortVersion = "Ascend910_9"; | 127 | + char npuArch[kMaxValueLen] = {0}; |
| 117 | - std::string opt_value = "enable"; | 128 | + |
| 118 | - if ((kDisabledVersion.find(version) != kDisabledVersion.end()) || (version.find(kDisabledShortVersion) == 0UL)) { | 129 | + const auto ret = rtGetSocSpec("version", "NpuArch", npuArch, kMaxValueLen); |
| 119 | - opt_value = "disable"; | 130 | + if (ret != RT_ERROR_NONE) { |
| 131 | + ACL_LOG_WARN("Cannot get NpuArch, using jit_compile = [%s]", jit_compile_value.c_str()); | ||
| 132 | + return jit_compile_value; | ||
| 120 | } | 133 | } |
| 121 | - return opt_value; | 134 | + |
| 135 | + if (kJitCompileEnabledByArch.find(npuArch) != kJitCompileEnabledByArch.end()) { | ||
| 136 | + jit_compile_value = "enable"; | ||
| 137 | + } | ||
| 138 | + ACL_LOG_INFO("Current NpuArch is [%s], using default jit_compile = [%s]", npuArch, jit_compile_value.c_str()); | ||
| 139 | + return jit_compile_value; | ||
| 122 | } | 140 | } |
| 123 | } // namespace | 141 | } // namespace |
| 124 | 142 | ||
| @@ -302,12 +320,7 @@ aclError aclGetCompileopt(aclCompileOpt opt, char *value, size_t length) | |||
| 302 | return CopyOptValue(value, length, optValue); | 320 | return CopyOptValue(value, length, optValue); |
| 303 | } | 321 | } |
| 304 | if (opt == ACL_OP_JIT_COMPILE) { | 322 | if (opt == ACL_OP_JIT_COMPILE) { |
| 305 | - const char *socName = aclrtGetSocName(); | 323 | + return CopyOptValue(value, length, GetDefaultJitCompileValue()); |
| 306 | - std::string socVersion; | ||
| 307 | - if (socName != nullptr) { | ||
| 308 | - socVersion = std::string(socName); | ||
| 309 | - } | ||
| 310 | - return CopyOptValue(value, length, GetDefaultJitCompileValue(socVersion)); | ||
| 311 | } | 324 | } |
| 312 | return ACL_ERROR_API_NOT_SUPPORT; | 325 | return ACL_ERROR_API_NOT_SUPPORT; |
| 313 | } | 326 | } |
| @@ -1,71 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * Copyright (c) 2025 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 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | -namespace acl { | ||
| 21 | -constexpr uint64_t DEFAULT_MAX_OPQUEUE_NUM = 20000U; | ||
| 22 | - | ||
| 23 | -enum OpCompileType :int32_t { | ||
| 24 | - OP_COMPILE_SYS, | ||
| 25 | - OP_COMPILE_UNREGISTERED, | ||
| 26 | -}; | ||
| 27 | - | ||
| 28 | -enum OpExecuteType : int32_t { | ||
| 29 | - ACL_OP_EXECUTE, | ||
| 30 | - ACL_OP_EXECUTE_V2, | ||
| 31 | - | ||
| 32 | - // for aclopCompileAndExecuteV2 interface, To ensure compatibility with ACL_OP_EXECUTE_V2, | ||
| 33 | - // origin shape are update after executed. | ||
| 34 | - ACL_OP_EXECUTE_REFRESH_OUTPUT_ORI_SHAPE | ||
| 35 | -}; | ||
| 36 | - | ||
| 37 | -// AclOp does NOT own any of the fields | ||
| 38 | -class ACL_FUNC_VISIBILITY AclOp { | ||
| 39 | -public: | ||
| 40 | - AclOp() = default; | ||
| 41 | - ~AclOp(); | ||
| 42 | - AclOp(const AclOp& aclOp); | ||
| 43 | - AclOp &operator=(const AclOp &aclOp) &; | ||
| 44 | - | ||
| 45 | - std::string opType; | ||
| 46 | - int32_t numInputs = 0; | ||
| 47 | - int32_t numOutputs = 0; | ||
| 48 | - const aclTensorDesc * const *inputDesc = nullptr; | ||
| 49 | - const aclTensorDesc * const *outputDesc = nullptr; | ||
| 50 | - const aclDataBuffer *const *inputs = nullptr; | ||
| 51 | - aclDataBuffer *const *outputs = nullptr; | ||
| 52 | - const aclopAttr *opAttr = nullptr; | ||
| 53 | - aclopEngineType engineType = ACL_ENGINE_SYS; | ||
| 54 | - std::string opPath; | ||
| 55 | - OpCompileType compileType = OP_COMPILE_SYS; | ||
| 56 | - bool isCompile = false; | ||
| 57 | - OpExecuteType exeucteType = ACL_OP_EXECUTE; | ||
| 58 | - bool isCopyConstructor = false; | ||
| 59 | - bool isMatched = false; | ||
| 60 | - bool isDynamic = false; | ||
| 61 | - OpModel opModel; | ||
| 62 | - std::string DebugString() const; | ||
| 63 | - void Init(const AclOp& aclOp); | ||
| 64 | - void BackupConst() const; | ||
| 65 | - void RecoverConst() const; | ||
| 66 | - void BackupDimsAndShapeRanges() const; | ||
| 67 | - void RecoverDimsAndShapeRanges() const; | ||
| 68 | -}; | ||
| 69 | -} // namespace acl | ||
| 70 | - | ||
| 71 | - | ||
| @@ -1,90 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * Copyright (c) 2025 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 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | -struct ACL_FUNC_VISIBILITY aclopAttr { | ||
| 20 | - aclopAttr() = default; | ||
| 21 | - aclopAttr(const aclopAttr &opAttr); | ||
| 22 | - | ||
| 23 | - ~aclopAttr() = default; | ||
| 24 | - | ||
| 25 | - inline const std::map<std::string, ge::GeAttrValue> &Attrs() const | ||
| 26 | - { | ||
| 27 | - return attrs_; | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | - inline const std::map<std::string, ge::GeAttrValue> &EmplaceAttr(const std::string &str, ge::GeAttrValue val) | ||
| 31 | - { | ||
| 32 | - (void)attrs_.emplace(str, val); | ||
| 33 | - return attrs_; | ||
| 34 | - } | ||
| 35 | - | ||
| 36 | - inline void ClearConstBuf() | ||
| 37 | - { | ||
| 38 | - constDataBuf_.clear(); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - inline void EmplaceConstBuf(std::string &str) | ||
| 42 | - { | ||
| 43 | - constDataBuf_.emplace_back(str); | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - inline const std::vector<std::string> &GetConstBuf() const | ||
| 47 | - { | ||
| 48 | - return constDataBuf_; | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - template<typename T> | ||
| 52 | - aclError SetAttr(const char_t *const attrName, const T val) | ||
| 53 | - { | ||
| 54 | - ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(attrName); | ||
| 55 | - const auto attrVal = ge::GeAttrValue::CreateFrom<T>(val); | ||
| 56 | - attrs_[std::string(attrName)] = attrVal; | ||
| 57 | - return ACL_SUCCESS; | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - template<typename T> | ||
| 61 | - aclError SetAttr(const char_t *const attrName, const int32_t numValues, const T *const values) | ||
| 62 | - { | ||
| 63 | - ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(attrName); | ||
| 64 | - if (numValues > 0) { | ||
| 65 | - ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(values); | ||
| 66 | - } | ||
| 67 | - std::vector<T> valueVec; | ||
| 68 | - for (int32_t i = 0; i < numValues; ++i) { | ||
| 69 | - valueVec.push_back(values[i]); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - const auto attrValues = ge::GeAttrValue::CreateFrom<std::vector<T>>(valueVec); | ||
| 73 | - attrs_[std::string(attrName)] = attrValues; | ||
| 74 | - return ACL_SUCCESS; | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - void UpdateDigest(); | ||
| 78 | - | ||
| 79 | - size_t GetDigest() const; | ||
| 80 | - | ||
| 81 | - std::string DebugString() const; | ||
| 82 | - | ||
| 83 | - bool HasAttr(const char_t *const attrName) const; | ||
| 84 | - | ||
| 85 | -private: | ||
| 86 | - std::map<std::string, ge::GeAttrValue> attrs_; | ||
| 87 | - std::vector<std::string> constDataBuf_; | ||
| 88 | - mutable size_t digest_ = 0U; | ||
| 89 | -}; | ||
| 90 | - | ||
| @@ -1,68 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * Copyright (c) 2025 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 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | -namespace acl { | ||
| 27 | -struct OpModel { | ||
| 28 | - OpModel() = default; | ||
| 29 | - | ||
| 30 | - ~OpModel() = default; | ||
| 31 | - | ||
| 32 | - std::shared_ptr<void> data; | ||
| 33 | - int64_t profilingIndex = -1; | ||
| 34 | - uint32_t size = 0U; | ||
| 35 | - std::string name; | ||
| 36 | - uint64_t opModelId = 0U; | ||
| 37 | - size_t isStaticModelWithFuzzCompile = 0U; | ||
| 38 | - std::string cacheKey; | ||
| 39 | - std::shared_ptr<gert::StreamExecutor> executor = nullptr; | ||
| 40 | - std::shared_ptr<std::mutex> mtx; | ||
| 41 | -}; | ||
| 42 | - | ||
| 43 | -struct OpModelDef { | ||
| 44 | - std::string opType; | ||
| 45 | - uint64_t opModelId = 0U; | ||
| 46 | - std::vector<aclTensorDesc> inputDescArr; | ||
| 47 | - std::vector<aclTensorDesc> outputDescArr; | ||
| 48 | - aclopAttr opAttr; | ||
| 49 | - | ||
| 50 | - std::string modelPath; | ||
| 51 | - // 0: ACL_OP_COMPILE_DEFAULT mode | ||
| 52 | - // 1:ACL_OP_COMPILE_FUZZ mode but model is static | ||
| 53 | - // 2:ACL_OP_COMPILE_FUZZ mode and model is dynamic | ||
| 54 | - size_t isStaticModelWithFuzzCompile = 0U; | ||
| 55 | - | ||
| 56 | - // some single op input/output shape is static, but it should be dynamic as its tiling dependence | ||
| 57 | - bool isDynamicModel = false; | ||
| 58 | - | ||
| 59 | - std::string DebugString() const; | ||
| 60 | - | ||
| 61 | - uint64_t timestamp = static_cast<uint64_t>(ULLONG_MAX); | ||
| 62 | - uint64_t seq; | ||
| 63 | -}; | ||
| 64 | - | ||
| 65 | -ACL_FUNC_VISIBILITY aclError ReadOpModelFromFile(const std::string &path, OpModel &opModel); | ||
| 66 | -} // namespace acl | ||
| 67 | - | ||
| 68 | - | ||
| @@ -1,104 +0,0 @@ | |||
| 1 | -/** | ||
| 2 | - * Copyright (c) 2025 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 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | -namespace acl { | ||
| 24 | - constexpr int64_t UNKNOW_DIM = -1; | ||
| 25 | - constexpr int64_t UNKNOW_RANK = -2; | ||
| 26 | - enum class AttrRangeType : std::uint8_t { | ||
| 27 | - RANGE_TYPE, | ||
| 28 | - VALUE_TYPE | ||
| 29 | - }; | ||
| 30 | - | ||
| 31 | - void ConvertSvecToVec(const ge::SmallVector<int64_t, static_cast<size_t>(ge::kDefaultMaxInputNum)> &svec, | ||
| 32 | - std::vector<int64_t> &vec); | ||
| 33 | - void ConvertVecToSvec(const std::vector<int64_t> &vec, ge::SmallVector<int64_t, | ||
| 34 | - static_cast<size_t>(ge::kDefaultMaxInputNum)> &svec); | ||
| 35 | -} | ||
| 36 | - | ||
| 37 | -struct ACL_FUNC_VISIBILITY aclTensorDesc { | ||
| 38 | - aclTensorDesc(const aclDataType aclTensorDataType, const std::initializer_list<int64_t> shape, | ||
| 39 | - const aclFormat aclTensorFormat); | ||
| 40 | - aclTensorDesc(const aclDataType aclTensorDataType, const size_t numDims, const int64_t *const aclTensorDims, | ||
| 41 | - const aclFormat aclTensorFormat); | ||
| 42 | - aclTensorDesc(const aclTensorDesc &tensorDesc); | ||
| 43 | - aclTensorDesc &operator=(const aclTensorDesc &tensorDesc); | ||
| 44 | - aclTensorDesc() = default; | ||
| 45 | - ~aclTensorDesc() = default; | ||
| 46 | - aclDataType dataType; | ||
| 47 | - aclFormat storageFormat = ACL_FORMAT_UNDEFINED; | ||
| 48 | - aclFormat format; | ||
| 49 | - ge::SmallVector<int64_t, static_cast<size_t>(ge::kDefaultMaxInputNum)> dims; | ||
| 50 | - ge::SmallVector<int64_t, static_cast<size_t>(ge::kDefaultMaxInputNum)> dimsBackup; | ||
| 51 | - ge::SmallVector<int64_t, static_cast<size_t>(ge::kDefaultMaxInputNum)> storageDims; | ||
| 52 | - ge::SmallVector<int64_t, static_cast<size_t>(ge::kDefaultMaxInputNum)> storageDimsBackup; | ||
| 53 | - std::string name; | ||
| 54 | - std::vector<std::pair<int64_t, int64_t>> shapeRange; | ||
| 55 | - std::vector<std::pair<int64_t, int64_t>> shapeRangeBackup; | ||
| 56 | - void *address = nullptr; | ||
| 57 | - std::string dynamicInputName; | ||
| 58 | - bool isConst = false; | ||
| 59 | - std::shared_ptr<void> constDataBuf; | ||
| 60 | - size_t constDataLen = 0U; | ||
| 61 | - bool isConstBackup = false; | ||
| 62 | - std::shared_ptr<void> constDataBufBackup; | ||
| 63 | - size_t constDataLenBackup = 0U; | ||
| 64 | - aclMemType memtype = ACL_MEMTYPE_DEVICE; | ||
| 65 | - // valRange is set from aclSetTensorValueRange | ||
| 66 | - std::vector<std::pair<int64_t, int64_t>> valRange; | ||
| 67 | - // for windows compile,use map ignore dvpp.so find the implementation GeAttrValue | ||
| 68 | - std::map<acl::AttrRangeType, ge::GeAttrValue> valueRange; | ||
| 69 | - std::string DebugString() const; | ||
| 70 | - bool IsSameTensor(const aclTensorDesc *const other) const; | ||
| 71 | - bool IsDynamicTensor() const; | ||
| 72 | - bool CheckShapeRange() const; | ||
| 73 | - bool IsConstTensor() const | ||
| 74 | - { | ||
| 75 | - return isConst; | ||
| 76 | - } | ||
| 77 | - bool IsHostMemTensor() const | ||
| 78 | - { | ||
| 79 | - return (memtype == ACL_MEMTYPE_HOST) || (memtype == ACL_MEMTYPE_HOST_COMPILE_INDEPENDENT); | ||
| 80 | - } | ||
| 81 | - inline bool IsOptinalTensor() const | ||
| 82 | - { | ||
| 83 | - return (dataType == ACL_DT_UNDEFINED) && (format == ACL_FORMAT_UNDEFINED) && (dims.empty()); | ||
| 84 | - } | ||
| 85 | - void Init(const aclTensorDesc &tensorDesc); | ||
| 86 | - void UpdateTensorShape(const std::vector<int64_t> &shape); | ||
| 87 | - void UpdateTensorShapeRange(const std::vector<std::pair<int64_t, int64_t>> &ranges); | ||
| 88 | - inline bool CheckConstTensor(const bool needCheckHostMem) const | ||
| 89 | - { | ||
| 90 | - return isConst || (needCheckHostMem && (memtype == ACL_MEMTYPE_HOST)); | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | - bool operator==(const aclTensorDesc *const other) const; | ||
| 94 | - void BackupDimsAndShapeRanges(); | ||
| 95 | - void RecoverDimsAndShapeRanges(); | ||
| 96 | - void BackupConst(); | ||
| 97 | - void RecoverConst(); | ||
| 98 | - | ||
| 99 | -private: | ||
| 100 | - mutable std::string cachedKey; | ||
| 101 | - mutable std::string cachedShapeKey; | ||
| 102 | -}; | ||
| 103 | - | ||
| 104 | - | ||
| @@ -46,7 +46,6 @@ target_include_directories(acl_op_executor_impl PRIVATE | |||
| 46 | ${CMAKE_CURRENT_LIST_DIR}/../common | 46 | ${CMAKE_CURRENT_LIST_DIR}/../common |
| 47 | ${CMAKE_CURRENT_LIST_DIR}/../util | 47 | ${CMAKE_CURRENT_LIST_DIR}/../util |
| 48 | 48 | ||
| 49 | - #TODO from acl_mdl | ||
| 50 | ${CMAKE_CURRENT_LIST_DIR}/../acl_model | 49 | ${CMAKE_CURRENT_LIST_DIR}/../acl_model |
| 51 | 50 | ||
| 52 | ${AIR_CODE_DIR}/inc | 51 | ${AIR_CODE_DIR}/inc |
| @@ -211,7 +211,7 @@ aclError AclOpResourceManager::LoadModelFromMem(const void *const model, const s | |||
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | aclError AclOpResourceManager::LoadModelFromSharedMem(const std::shared_ptr<void> &model, const size_t modelSize, | 213 | aclError AclOpResourceManager::LoadModelFromSharedMem(const std::shared_ptr<void> &model, const size_t modelSize, |
| 214 | - const AclOp *const aclOp, const bool isStatic) | 214 | + AclOp *aclOp, const bool isStatic) |
| 215 | { | 215 | { |
| 216 | ACL_LOG_INFO("Load inner op model begin. modelSize = %zu", modelSize); | 216 | ACL_LOG_INFO("Load inner op model begin. modelSize = %zu", modelSize); |
| 217 | ACL_REQUIRES_NOT_NULL(model); | 217 | ACL_REQUIRES_NOT_NULL(model); |
| @@ -219,7 +219,7 @@ aclError AclOpResourceManager::LoadModelFromSharedMem(const std::shared_ptr<void | |||
| 219 | OpModel opModel; | 219 | OpModel opModel; |
| 220 | opModel.data = model; | 220 | opModel.data = model; |
| 221 | if (aclOp != nullptr) { | 221 | if (aclOp != nullptr) { |
| 222 | - const_cast<AclOp *>(aclOp)->opModel.profilingIndex = | 222 | + aclOp->opModel.profilingIndex = |
| 223 | static_cast<int64_t>(gert::GlobalProfilingWrapper::GetInstance()->RegisterString(aclOp->opType)); | 223 | static_cast<int64_t>(gert::GlobalProfilingWrapper::GetInstance()->RegisterString(aclOp->opType)); |
| 224 | opModel.profilingIndex = aclOp->opModel.profilingIndex; | 224 | opModel.profilingIndex = aclOp->opModel.profilingIndex; |
| 225 | } | 225 | } |
| @@ -317,7 +317,7 @@ aclError AclOpResourceManager::SetTensorConst(aclTensorDesc *const desc, const a | |||
| 317 | } | 317 | } |
| 318 | 318 | ||
| 319 | desc->isConst = true; | 319 | desc->isConst = true; |
| 320 | - desc->constDataBuf.reset(reinterpret_cast<char_t *>(hostMem), [](const char_t *const) {}); | 320 | + desc->constDataBuf.reset(static_cast<char_t *>(hostMem), [](const char_t *const) {}); |
| 321 | desc->constDataLen = length; | 321 | desc->constDataLen = length; |
| 322 | return ACL_SUCCESS; | 322 | return ACL_SUCCESS; |
| 323 | } | 323 | } |
| @@ -549,7 +549,7 @@ aclError AclOpResourceManager::ReadModelDefs(const std::string &configPath, | |||
| 549 | return ACL_SUCCESS; | 549 | return ACL_SUCCESS; |
| 550 | } | 550 | } |
| 551 | 551 | ||
| 552 | -aclError AclOpResourceManager::BuildOpModel(const AclOp &aclOp) | 552 | +aclError AclOpResourceManager::BuildOpModel(AclOp &aclOp) |
| 553 | { | 553 | { |
| 554 | RT2_PROFILING_SCOPE(gert::profiling::kUnknownName, gert::profiling::kAclBuildOpModel); | 554 | RT2_PROFILING_SCOPE(gert::profiling::kUnknownName, gert::profiling::kAclBuildOpModel); |
| 555 | std::shared_ptr<void> modelData; | 555 | std::shared_ptr<void> modelData; |
| @@ -60,7 +60,7 @@ public: | |||
| 60 | 60 | ||
| 61 | aclError LoadModelFromSharedMem(const std::shared_ptr<void> &model, | 61 | aclError LoadModelFromSharedMem(const std::shared_ptr<void> &model, |
| 62 | const size_t modelSize, | 62 | const size_t modelSize, |
| 63 | - const AclOp *const aclOp, | 63 | + AclOp *aclOp, |
| 64 | const bool isStatic = false); | 64 | const bool isStatic = false); |
| 65 | 65 | ||
| 66 | aclError GetOpModel(AclOp &aclOp); | 66 | aclError GetOpModel(AclOp &aclOp); |
| @@ -107,7 +107,7 @@ private: | |||
| 107 | aclError ReadModelDefs(const std::string &configPath, | 107 | aclError ReadModelDefs(const std::string &configPath, |
| 108 | std::vector<OpModelDef> &configList); | 108 | std::vector<OpModelDef> &configList); |
| 109 | 109 | ||
| 110 | - aclError BuildOpModel(const AclOp &aclOp); | 110 | + aclError BuildOpModel(AclOp &aclOp); |
| 111 | 111 | ||
| 112 | static bool OmFileFilterFn(const std::string &fileName); | 112 | static bool OmFileFilterFn(const std::string &fileName); |
| 113 | 113 | ||
| @@ -7,7 +7,7 @@ | |||
| 7 | * 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. |
| 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 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | ||
| @@ -366,7 +366,7 @@ aclError aclopSetKernelArgsImpl(aclopKernelDesc *kernelDesc, | |||
| 366 | blockDim, argSize); | 366 | blockDim, argSize); |
| 367 | kernelDesc->kernelId = std::string(kernelId); | 367 | kernelDesc->kernelId = std::string(kernelId); |
| 368 | kernelDesc->blockDim = blockDim; | 368 | kernelDesc->blockDim = blockDim; |
| 369 | - kernelDesc->extendArgs = std::string(reinterpret_cast<const char *>(args), static_cast<size_t>(argSize)); | 369 | + kernelDesc->extendArgs = std::string(static_cast<const char *>(args), static_cast<size_t>(argSize)); |
| 370 | 370 | ||
| 371 | return ACL_SUCCESS; | 371 | return ACL_SUCCESS; |
| 372 | } | 372 | } |
| @@ -88,7 +88,7 @@ aclError aclopSetAttrListDataTypeImpl(aclopAttr *attr, const char *attrName, int | |||
| 88 | aclError aclopSetAttrListBoolImpl(aclopAttr *attr, const char *attrName, int numValues, const uint8_t *values) | 88 | aclError aclopSetAttrListBoolImpl(aclopAttr *attr, const char *attrName, int numValues, const uint8_t *values) |
| 89 | { | 89 | { |
| 90 | ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(attr); | 90 | ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(attr); |
| 91 | - const auto *const boolValues = reinterpret_cast<const bool *>(values); | 91 | + const auto *const boolValues = static_cast<const bool *>(static_cast<const void *>(values)); |
| 92 | return attr->SetAttr(attrName, numValues, boolValues); | 92 | return attr->SetAttr(attrName, numValues, boolValues); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| @@ -12,13 +12,13 @@ | |||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | - | ||
| 16 | 15 | ||
| 17 | 16 | ||
| 18 | 17 | ||
| 19 | struct ACL_FUNC_VISIBILITY aclopAttr { | 18 | struct ACL_FUNC_VISIBILITY aclopAttr { |
| 20 | aclopAttr() = default; | 19 | aclopAttr() = default; |
| 21 | aclopAttr(const aclopAttr &opAttr); | 20 | aclopAttr(const aclopAttr &opAttr); |
| 21 | + aclopAttr& operator=(const aclopAttr &opAttr) = delete; | ||
| 22 | 22 | ||
| 23 | ~aclopAttr() = default; | 23 | ~aclopAttr() = default; |
| 24 | 24 | ||
| @@ -8,8 +8,8 @@ | |||
| 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 | -#ifndef ACL_OP_EXECUTOR_ACL_TYPES_OP_MODEL_H_ | 11 | +#ifndef ACL_TYPES_OP_MODEL_H_ |
| 12 | -#define ACL_OP_EXECUTOR_ACL_TYPES_OP_MODEL_H_ | 12 | +#define ACL_TYPES_OP_MODEL_H_ |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -65,4 +65,4 @@ struct OpModelDef { | |||
| 65 | ACL_FUNC_VISIBILITY aclError ReadOpModelFromFile(const std::string &path, OpModel &opModel); | 65 | ACL_FUNC_VISIBILITY aclError ReadOpModelFromFile(const std::string &path, OpModel &opModel); |
| 66 | } // namespace acl | 66 | } // namespace acl |
| 67 | 67 | ||
| 68 | -#endif // ACL_OP_EXECUTOR_ACL_TYPES_OP_MODEL_H_ | 68 | +#endif // ACL_TYPES_OP_MODEL_H_ |
| @@ -13,7 +13,6 @@ | |||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | - | ||
| 17 | 16 | ||
| 18 | 17 | ||
| 19 | namespace acl { | 18 | namespace acl { |
| @@ -16,6 +16,7 @@ add_custom_target( | |||
| 16 | ${CMAKE_CURRENT_BINARY_DIR}/op_executor_stub.cpp | 16 | ${CMAKE_CURRENT_BINARY_DIR}/op_executor_stub.cpp |
| 17 | ${CMAKE_CURRENT_BINARY_DIR}/mdl_stub.cpp | 17 | ${CMAKE_CURRENT_BINARY_DIR}/mdl_stub.cpp |
| 18 | ) | 18 | ) |
| 19 | + | ||
| 19 | add_custom_command( | 20 | add_custom_command( |
| 20 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cblas_stub.cpp | 21 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cblas_stub.cpp |
| 21 | ${CMAKE_CURRENT_BINARY_DIR}/op_compiler_stub.cpp | 22 | ${CMAKE_CURRENT_BINARY_DIR}/op_compiler_stub.cpp |
| @@ -39,6 +40,7 @@ add_custom_command( | |||
| 39 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external/acl | 40 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external/acl |
| 40 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external/acl | 41 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external/acl |
| 41 | ) | 42 | ) |
| 43 | + | ||
| 42 | #----------------------------------------------------------------------------------------------------------------# | 44 | #----------------------------------------------------------------------------------------------------------------# |
| 43 | ############ stub/libacl_cblas.so ############ | 45 | ############ stub/libacl_cblas.so ############ |
| 44 | add_library(stub_acl_cblas SHARED | 46 | add_library(stub_acl_cblas SHARED |
| @@ -73,12 +75,14 @@ target_link_libraries(stub_acl_cblas PRIVATE | |||
| 73 | add_library(stub_acl_op_compiler SHARED | 75 | add_library(stub_acl_op_compiler SHARED |
| 74 | ${CMAKE_CURRENT_BINARY_DIR}/op_compiler_stub.cpp | 76 | ${CMAKE_CURRENT_BINARY_DIR}/op_compiler_stub.cpp |
| 75 | ) | 77 | ) |
| 78 | + | ||
| 76 | target_include_directories(stub_acl_op_compiler PRIVATE | 79 | target_include_directories(stub_acl_op_compiler PRIVATE |
| 77 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external | 80 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external |
| 78 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external/acl | 81 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external/acl |
| 79 | ${ASCEND_INSTALL_PATH}/include | 82 | ${ASCEND_INSTALL_PATH}/include |
| 80 | ${ASCEND_INSTALL_PATH}/include/acl | 83 | ${ASCEND_INSTALL_PATH}/include/acl |
| 81 | ) | 84 | ) |
| 85 | + | ||
| 82 | target_compile_definitions(stub_acl_op_compiler PRIVATE | 86 | target_compile_definitions(stub_acl_op_compiler PRIVATE |
| 83 | _FORTIFY_SOURCE=2 | 87 | _FORTIFY_SOURCE=2 |
| 84 | ) | 88 | ) |
| @@ -100,12 +104,14 @@ target_link_libraries(stub_acl_op_compiler PRIVATE | |||
| 100 | add_library(stub_acl_op_executor SHARED | 104 | add_library(stub_acl_op_executor SHARED |
| 101 | ${CMAKE_CURRENT_BINARY_DIR}/op_executor_stub.cpp | 105 | ${CMAKE_CURRENT_BINARY_DIR}/op_executor_stub.cpp |
| 102 | ) | 106 | ) |
| 107 | + | ||
| 103 | target_include_directories(stub_acl_op_executor PRIVATE | 108 | target_include_directories(stub_acl_op_executor PRIVATE |
| 104 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external | 109 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external |
| 105 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external/acl | 110 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external/acl |
| 106 | ${ASCEND_INSTALL_PATH}/include | 111 | ${ASCEND_INSTALL_PATH}/include |
| 107 | ${ASCEND_INSTALL_PATH}/include/acl | 112 | ${ASCEND_INSTALL_PATH}/include/acl |
| 108 | ) | 113 | ) |
| 114 | + | ||
| 109 | target_compile_definitions(stub_acl_op_executor PRIVATE | 115 | target_compile_definitions(stub_acl_op_executor PRIVATE |
| 110 | _FORTIFY_SOURCE=2 | 116 | _FORTIFY_SOURCE=2 |
| 111 | ) | 117 | ) |
| @@ -127,12 +133,18 @@ target_link_libraries(stub_acl_op_executor PRIVATE | |||
| 127 | add_library(stub_acl_mdl SHARED | 133 | add_library(stub_acl_mdl SHARED |
| 128 | ${CMAKE_CURRENT_BINARY_DIR}/mdl_stub.cpp | 134 | ${CMAKE_CURRENT_BINARY_DIR}/mdl_stub.cpp |
| 129 | ) | 135 | ) |
| 136 | + | ||
| 130 | target_include_directories(stub_acl_mdl PRIVATE | 137 | target_include_directories(stub_acl_mdl PRIVATE |
| 131 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external | 138 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external |
| 132 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external/acl | 139 | ${CMAKE_CURRENT_LIST_DIR}/../../../inc/external/acl |
| 133 | ${ASCEND_INSTALL_PATH}/include | 140 | ${ASCEND_INSTALL_PATH}/include |
| 134 | ${ASCEND_INSTALL_PATH}/include/acl | 141 | ${ASCEND_INSTALL_PATH}/include/acl |
| 135 | ) | 142 | ) |
| 143 | + | ||
| 144 | +target_include_directories(stub_acl_mdl PRIVATE | ||
| 145 | + ${CMAKE_CURRENT_LIST_DIR}/../include/external | ||
| 146 | + ${CMAKE_CURRENT_LIST_DIR}/../include/external/acl | ||
| 147 | +) | ||
| 136 | target_compile_definitions(stub_acl_mdl PRIVATE | 148 | target_compile_definitions(stub_acl_mdl PRIVATE |
| 137 | _FORTIFY_SOURCE=2 | 149 | _FORTIFY_SOURCE=2 |
| 138 | ) | 150 | ) |
| @@ -1,6 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | -# -*- coding: UTF-8 -*- | 2 | +# -*- coding: utf-8 -*- |
| 3 | -# ---------------------------------------------------------------------------- | 3 | +# ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| 6 | # CANN Open Software License Agreement Version 2.0 (the "License"). | 6 | # CANN Open Software License Agreement Version 2.0 (the "License"). |
| @@ -8,7 +8,7 @@ | |||
| 8 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 8 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, |
| 9 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 9 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. |
| 10 | # See LICENSE in the root of the software repository for the full text of the License. | 10 | # See LICENSE in the root of the software repository for the full text of the License. |
| 11 | -# ---------------------------------------------------------------------------- | 11 | +# ----------------------------------------------------------------------------------------------------------- |
| 12 | 12 | ||
| 13 | import os | 13 | import os |
| 14 | import re | 14 | import re |
| @@ -484,7 +484,7 @@ static bool GetInputData(const aclDataBuffer *const dataBuffer, const aclDataTyp | |||
| 484 | case ACL_FLOAT16: | 484 | case ACL_FLOAT16: |
| 485 | for (size_t i = 0U; i < (dataBuffer->length / sizeof(aclFloat16)); ++i) { | 485 | for (size_t i = 0U; i < (dataBuffer->length / sizeof(aclFloat16)); ++i) { |
| 486 | inputFloatData.push_back( | 486 | inputFloatData.push_back( |
| 487 | - Fp16ToFloat(*(reinterpret_cast<const aclFloat16 *>(dataBuffer->data) + i))); | 487 | + Fp16ToFloat(*(static_cast<const aclFloat16 *>(dataBuffer->data) + i))); |
| 488 | } | 488 | } |
| 489 | break; | 489 | break; |
| 490 | case ACL_INT8: | 490 | case ACL_INT8: |
| @@ -611,13 +611,13 @@ static bool IsSameValue(const std::map<AttrRangeType, ge::GeAttrValue> &value1, | |||
| 611 | return true; | 611 | return true; |
| 612 | } | 612 | } |
| 613 | if ((it1 != value1.end()) && (it2 != value2.end())) { | 613 | if ((it1 != value1.end()) && (it2 != value2.end())) { |
| 614 | - const auto geTensor1 = const_cast<ge::GeAttrValue *>(&(it1->second))->MutableGet<ge::GeTensor>(); | 614 | + const auto geTensor1 = (&(it1->second))->Get<ge::GeTensor>(); |
| 615 | - const auto geTensor2 = const_cast<ge::GeAttrValue *>(&(it2->second))->MutableGet<ge::GeTensor>(); | 615 | + const auto geTensor2 = (&(it2->second))->Get<ge::GeTensor>(); |
| 616 | if ((geTensor1 != nullptr) && (geTensor2 != nullptr)) { | 616 | if ((geTensor1 != nullptr) && (geTensor2 != nullptr)) { |
| 617 | - void *const geDataPtr1 = reinterpret_cast<void *>(geTensor1->MutableData().data()); | 617 | + const void *const geDataPtr1 = static_cast<const void *>(geTensor1->GetData().data()); |
| 618 | - void *const geDataPtr2 = reinterpret_cast<void *>(geTensor2->MutableData().data()); | 618 | + const void *const geDataPtr2 = static_cast<const void *>(geTensor2->GetData().data()); |
| 619 | - const size_t dataSize1 = geTensor1->MutableData().size(); | 619 | + const size_t dataSize1 = geTensor1->GetData().size(); |
| 620 | - const size_t dataSize2 = geTensor2->MutableData().size(); | 620 | + const size_t dataSize2 = geTensor2->GetData().size(); |
| 621 | if ((dataSize1 == dataSize2) && (memcmp(geDataPtr1, geDataPtr2, dataSize1) == 0)) { | 621 | if ((dataSize1 == dataSize2) && (memcmp(geDataPtr1, geDataPtr2, dataSize1) == 0)) { |
| 622 | return true; | 622 | return true; |
| 623 | } | 623 | } |
| @@ -17,7 +17,6 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | - | ||
| 21 | 20 | ||
| 22 | 21 | ||
| 23 | 22 | ||
| @@ -51,6 +51,9 @@ if (${TARGET_SYSTEM_NAME} STREQUAL "Linux") | |||
| 51 | else() | 51 | else() |
| 52 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include> | 52 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include> |
| 53 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment> | 53 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment> |
| 54 | + $<$<BOOL:${ENABLE_OPEN_SRC}>:${CANN_GE_DIR}/inc> | ||
| 55 | + $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_OPENSDK_DIR}/include/runtime> | ||
| 56 | + $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_OPENSDK_DIR}/include/runtime/runtime> | ||
| 54 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment/msprof> | 57 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment/msprof> |
| 55 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment/slog> | 58 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment/slog> |
| 56 | endif() | 59 | endif() |
| @@ -103,10 +106,12 @@ elseif (${TARGET_SYSTEM_NAME} STREQUAL "LiteOS") | |||
| 103 | if(NOT ENABLE_OPEN_SRC) | 106 | if(NOT ENABLE_OPEN_SRC) |
| 104 | ${TOP_DIR}/inc/external | 107 | ${TOP_DIR}/inc/external |
| 105 | ${TOP_DIR}/runtime/src/acl/aclrt_c/common | 108 | ${TOP_DIR}/runtime/src/acl/aclrt_c/common |
| 106 | - ${TOP_DIR}/runtime/pkg_inc/base | ||
| 107 | else() | 109 | else() |
| 108 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include> | 110 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include> |
| 109 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment> | 111 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment> |
| 112 | + $<$<BOOL:${ENABLE_OPEN_SRC}>:${CANN_GE_DIR}/inc> | ||
| 113 | + $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_OPENSDK_DIR}/include/runtime> | ||
| 114 | + $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_OPENSDK_DIR}/include/runtime/runtime> | ||
| 110 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment/msprof> | 115 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment/msprof> |
| 111 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment/slog> | 116 | $<$<BOOL:${ENABLE_OPEN_SRC}>:${ASCEND_INSTALL_PATH}/include/experiment/slog> |
| 112 | endif() | 117 | endif() |
| @@ -6,7 +6,7 @@ | |||
| 6 | * 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, |
| 7 | * 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. |
| 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 | 11 | ||
| 12 | 12 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | -#------------------------------------------------------------------- | 2 | +# ----------------------------------------------------------------------------------------------------------- |
| 3 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 3 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 4 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 4 | # 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"). | 5 | # CANN Open Software License Agreement Version 2.0 (the "License"). |
| @@ -7,7 +7,7 @@ | |||
| 7 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 7 | # 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. | 8 | # 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. | 9 | # See LICENSE in the root of the software repository for the full text of the License. |
| 10 | -#------------------------------------------------------------------- | 10 | +# ----------------------------------------------------------------------------------------------------------- |
| 11 | 11 | ||
| 12 | real_path=$(realpath "$0") | 12 | real_path=$(realpath "$0") |
| 13 | LOCAL_PATH=$(cd $(dirname "$real_path"); pwd) | 13 | LOCAL_PATH=$(cd $(dirname "$real_path"); pwd) |
| @@ -33,7 +33,7 @@ const static std::map<std::string, std::set<std::string>> kStrValueRange = { | |||
| 33 | {"virtual_type", {"0", "1"}}, | 33 | {"virtual_type", {"0", "1"}}, |
| 34 | {"status_check", {"0", "1"}}, | 34 | {"status_check", {"0", "1"}}, |
| 35 | {"deterministic", {"0", "1"}}, | 35 | {"deterministic", {"0", "1"}}, |
| 36 | - {"external_weight", {"0", "1"}}, | 36 | + {"external_weight", {"0", "1", "2"}}, |
| 37 | {"display_model_info", {"0", "1"}}, | 37 | {"display_model_info", {"0", "1"}}, |
| 38 | {"atomic_clean_policy", {"0", "1"}}, | 38 | {"atomic_clean_policy", {"0", "1"}}, |
| 39 | {"disable_reuse_memory", {"0", "1"}}, | 39 | {"disable_reuse_memory", {"0", "1"}}, |
| @@ -148,7 +148,7 @@ CmdFlagInfo::CmdFlagInfo(int32_t has_arg, int32_t index, const std::string &flag | |||
| 148 | value_int32_(default_val) {} | 148 | value_int32_(default_val) {} |
| 149 | 149 | ||
| 150 | void CmdFlagInfo::PrintTypeError(const char *type) { | 150 | void CmdFlagInfo::PrintTypeError(const char *type) { |
| 151 | - std::string reason = "The value type must be [" + std::string(type) + "]"; | 151 | + std::string reason = "The value type must be [" + std::string(type) + "]."; |
| 152 | REPORT_PREDEFINED_ERR_MSG("E10003", std::vector<const char *>({"value", "parameter", "reason"}), | 152 | REPORT_PREDEFINED_ERR_MSG("E10003", std::vector<const char *>({"value", "parameter", "reason"}), |
| 153 | std::vector<const char *>({value_string_.c_str(), flag_name_.c_str(), reason.c_str()})); | 153 | std::vector<const char *>({value_string_.c_str(), flag_name_.c_str(), reason.c_str()})); |
| 154 | } | 154 | } |
| @@ -181,7 +181,8 @@ void CmdFlagInfo::PrintValueError() { | |||
| 181 | std::vector<const char *>({"framework", support.c_str()})); | 181 | std::vector<const char *>({"framework", support.c_str()})); |
| 182 | } else { | 182 | } else { |
| 183 | std::string parameter = "--" + flag_name_; | 183 | std::string parameter = "--" + flag_name_; |
| 184 | - const std::string reason = "The value is not within the range of values: " + PrintValueRange(); | 184 | + const std::string reason = |
| 185 | + "The value is not within the range of values. The valid range is " + PrintValueRange() + "."; | ||
| 185 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"value", "parameter", "reason"}), | 186 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"value", "parameter", "reason"}), |
| 186 | std::vector<const char *>({value_string_.c_str(), parameter.c_str(), reason.c_str()})); | 187 | std::vector<const char *>({value_string_.c_str(), parameter.c_str(), reason.c_str()})); |
| 187 | } | 188 | } |
| @@ -44,28 +44,19 @@ | |||
| 44 | namespace { | 44 | namespace { |
| 45 | using json = nlohmann::json; | 45 | using json = nlohmann::json; |
| 46 | using amctStatus = int32_t; | 46 | using amctStatus = int32_t; |
| 47 | -bool IsCaffeUnsupportedVersion(const std::string &version) { | ||
| 48 | - static const std::set<std::string> kUnsupportedVersion = {"Ascend910B1", "Ascend910B2", "Ascend910B3", | ||
| 49 | - "Ascend910B4", "Ascend910B4-1", "Ascend910B2C"}; | ||
| 50 | - static const std::string kUnsupportedShortVersion = "Ascend910_9"; | ||
| 51 | - if ((kUnsupportedVersion.find(version) != kUnsupportedVersion.end()) || | ||
| 52 | - (version.find(kUnsupportedShortVersion) == 0UL)) { | ||
| 53 | - return true; | ||
| 54 | - } | ||
| 55 | - return false; | ||
| 56 | -} | ||
| 57 | static bool is_dynamic_input = false; | 47 | static bool is_dynamic_input = false; |
| 58 | const char *const kAmctSo = "libamctacl.so"; | 48 | const char *const kAmctSo = "libamctacl.so"; |
| 59 | -const char *const kModeSupport = "only support 0(model to framework model), " | 49 | +const char *const kModeSupport = "The value must be selected from the following: 0(model to framework model), " |
| 60 | "1(framework model to json), 3(only pre-check), " | 50 | "1(framework model to json), 3(only pre-check), " |
| 61 | "5(pbtxt to json), 6(display model info)," | 51 | "5(pbtxt to json), 6(display model info)," |
| 62 | - "30(model to execute-om for nano)"; | 52 | + "30(model to execute-om for nano, an .om file for nano chips)."; |
| 63 | -const char *const kModelToJsonSupport = "only support 0(Caffe) 3(TensorFlow) 5(Onnx) when mode set 1"; | 53 | +const char *const kModelToJsonSupport = |
| 64 | -const char *const kCaffeFormatSupport = "only support NCHW, ND in Caffe model, you must choose one of them"; | 54 | + "The framework must be selected from {0(Caffe), 3(TensorFlow), 5(Onnx)} when model is set to 1(JSON)."; |
| 55 | +const char *const kCaffeFormatSupport = "The value must be NCHW or ND in Caffe model."; | ||
| 65 | const char *const kCaffeSupport = "Caffe is not supported in the current soc version"; | 56 | const char *const kCaffeSupport = "Caffe is not supported in the current soc version"; |
| 66 | const char *const kTFFormatSupport = | 57 | const char *const kTFFormatSupport = |
| 67 | - "only support NCHW, NHWC, ND, NCDHW, NDHWC in TF model, you must choose one of them"; | 58 | + "The value must be NCHW, NHWC, ND, NCDHW or NDHWC in TF model."; |
| 68 | -const char *const kONNXFormatSupport = "only support NCHW, ND, NCDHW in ONNX model, you must choose one of them"; | 59 | +const char *const kONNXFormatSupport = "The value must be NCHW, ND or NCDHW in ONNX model."; |
| 69 | // limit available mem size 2G | 60 | // limit available mem size 2G |
| 70 | const long kMinAvailableMem = 2097152; // 2 * 1024 * 1024 | 61 | const long kMinAvailableMem = 2097152; // 2 * 1024 * 1024 |
| 71 | 62 | ||
| @@ -357,6 +348,7 @@ DEFINE_string(external_weight, "0", | |||
| 357 | "For converting const to file constant, and saving weight to file. " | 348 | "For converting const to file constant, and saving weight to file. " |
| 358 | "0: save weight in om. " | 349 | "0: save weight in om. " |
| 359 | "1: save weight in file. " | 350 | "1: save weight in file. " |
| 351 | +"2: save all weights in one file. " | ||
| 360 | "Default is 0."); | 352 | "Default is 0."); |
| 361 | 353 | ||
| 362 | DEFINE_string(deterministic, "0", | 354 | DEFINE_string(deterministic, "0", |
| @@ -491,7 +483,7 @@ class GFlagUtils { | |||
| 491 | " --is_output_adjust_hw_layout Net output node datatype is fp16 and format is NC1HWC0, used with out_nodes. " | 483 | " --is_output_adjust_hw_layout Net output node datatype is fp16 and format is NC1HWC0, used with out_nodes. " |
| 492 | "true: enable; false(default): disable. E.g.: \"true,true,false,true\"\n" | 484 | "true: enable; false(default): disable. E.g.: \"true,true,false,true\"\n" |
| 493 | " --external_weight Convert const to file constant, and save weight in file.\n" | 485 | " --external_weight Convert const to file constant, and save weight in file.\n" |
| 494 | - " 0 (default): save weight in om. 1: save weight in file.\n" | 486 | + " 0 (default): save weight in om. 1: save weight in file. 2: save all weights in one file.\n" |
| 495 | + oo_help_info[static_cast<size_t>(OoCategory::kFeature)] + | 487 | + oo_help_info[static_cast<size_t>(OoCategory::kFeature)] + |
| 496 | "\n[Model Tuning]\n" | 488 | "\n[Model Tuning]\n" |
| 497 | " --disable_reuse_memory The switch of reuse memory. Default value is : 0. " | 489 | " --disable_reuse_memory The switch of reuse memory. Default value is : 0. " |
| @@ -658,13 +650,7 @@ class GFlagUtils { | |||
| 658 | support.c_str()); | 650 | support.c_str()); |
| 659 | return false; | 651 | return false; |
| 660 | } else if (FLAGS_framework == static_cast<int32_t>(domi::CAFFE)) { | 652 | } else if (FLAGS_framework == static_cast<int32_t>(domi::CAFFE)) { |
| 661 | - if (IsCaffeUnsupportedVersion(FLAGS_soc_version)) { | 653 | + // The Soc Version check for caffe model conversion has been removed, so errors may occur in later processes. |
| 662 | - REPORT_PREDEFINED_ERR_MSG( | ||
| 663 | - "E10001", std::vector<const char *>({"parameter", "value", "reason"}), | ||
| 664 | - std::vector<const char *>({"--framework", std::to_string(FLAGS_framework).c_str(), kCaffeSupport})); | ||
| 665 | - DOMI_LOGE("[Check][Parameter]%s.", kCaffeSupport); | ||
| 666 | - return false; | ||
| 667 | - } | ||
| 668 | if (FLAGS_weight.empty()) { | 654 | if (FLAGS_weight.empty()) { |
| 669 | REPORT_PREDEFINED_ERR_MSG( | 655 | REPORT_PREDEFINED_ERR_MSG( |
| 670 | "E10008", std::vector<const char *>({"parameter"}), | 656 | "E10008", std::vector<const char *>({"parameter"}), |
| @@ -729,7 +715,7 @@ class GFlagUtils { | |||
| 729 | REPORT_PREDEFINED_ERR_MSG( | 715 | REPORT_PREDEFINED_ERR_MSG( |
| 730 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 716 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 731 | std::vector<const char *>({"--op_precision_mode", FLAGS_op_precision_mode.c_str(), | 717 | std::vector<const char *>({"--op_precision_mode", FLAGS_op_precision_mode.c_str(), |
| 732 | - "path is not found"})); | 718 | + "Path defined by op precision mode is not found."})); |
| 733 | GELOGE(FAILED, "[Check][op_precision_mode] %s not found", FLAGS_op_precision_mode.c_str()); | 719 | GELOGE(FAILED, "[Check][op_precision_mode] %s not found", FLAGS_op_precision_mode.c_str()); |
| 734 | return FAILED; | 720 | return FAILED; |
| 735 | } | 721 | } |
| @@ -748,7 +734,8 @@ class GFlagUtils { | |||
| 748 | GELOGE(FAILED, "[Check][TransferShapeAndRange] Transfer shape to shape range failed!"); | 734 | GELOGE(FAILED, "[Check][TransferShapeAndRange] Transfer shape to shape range failed!"); |
| 749 | return FAILED; | 735 | return FAILED; |
| 750 | } | 736 | } |
| 751 | - | 737 | + GE_ASSERT_SUCCESS(CheckHintShapeConflictWithDynamicParam(FLAGS_input_hint_shape, FLAGS_dynamic_batch_size, |
| 738 | + FLAGS_dynamic_image_size, FLAGS_dynamic_dims), "[Check][input hint shape] failed!"); | ||
| 752 | if (CheckDynamicInputParamValid(FLAGS_dynamic_batch_size, FLAGS_dynamic_image_size, | 739 | if (CheckDynamicInputParamValid(FLAGS_dynamic_batch_size, FLAGS_dynamic_image_size, |
| 753 | FLAGS_dynamic_dims, FLAGS_input_shape, FLAGS_input_shape_range, | 740 | FLAGS_dynamic_dims, FLAGS_input_shape, FLAGS_input_shape_range, |
| 754 | FLAGS_input_format, is_dynamic_input) != SUCCESS) { | 741 | FLAGS_input_format, is_dynamic_input) != SUCCESS) { |
| @@ -761,7 +748,7 @@ class GFlagUtils { | |||
| 761 | REPORT_PREDEFINED_ERR_MSG( | 748 | REPORT_PREDEFINED_ERR_MSG( |
| 762 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 749 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 763 | std::vector<const char *>({"--insert_op_conf", FLAGS_insert_op_conf.c_str(), | 750 | std::vector<const char *>({"--insert_op_conf", FLAGS_insert_op_conf.c_str(), |
| 764 | - "dynamic dims function does not support aipp"})); | 751 | + "The dynamic dims function does not support AIPP."})); |
| 765 | GELOGE(FAILED, "[Check][Param]dynamic dims function does not support aipp"); | 752 | GELOGE(FAILED, "[Check][Param]dynamic dims function does not support aipp"); |
| 766 | return FAILED; | 753 | return FAILED; |
| 767 | } | 754 | } |
| @@ -825,7 +812,7 @@ class GFlagUtils { | |||
| 825 | if (is_invalid_input) { | 812 | if (is_invalid_input) { |
| 826 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char_t *>({"parameter", "value", "reason"}), | 813 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char_t *>({"parameter", "value", "reason"}), |
| 827 | std::vector<const char_t *>({"--display_model_info", FLAGS_display_model_info.c_str(), | 814 | std::vector<const char_t *>({"--display_model_info", FLAGS_display_model_info.c_str(), |
| 828 | - "display_model_info does not support execute-om for nano"})); | 815 | + "Parameter display_model_info does not support execute-om for nano."})); |
| 829 | GELOGE(FAILED, "[Check][Parameter]Input parameter[--display_model_info] does not support execute-om nano."); | 816 | GELOGE(FAILED, "[Check][Parameter]Input parameter[--display_model_info] does not support execute-om nano."); |
| 830 | return FAILED; | 817 | return FAILED; |
| 831 | } | 818 | } |
| @@ -892,7 +879,7 @@ class GFlagUtils { | |||
| 892 | } | 879 | } |
| 893 | target_soc += soc_str + " "; | 880 | target_soc += soc_str + " "; |
| 894 | } | 881 | } |
| 895 | - ss_err_msg << "option soc_version[" << target_soc << "] and mode[" << iter->first << "] must be set together"; | 882 | + ss_err_msg << "Option soc_version " << target_soc << " and mode " << iter->first << " must be set together"; |
| 896 | REPORT_PREDEFINED_ERR_MSG("E10055", std::vector<const char *>({"reason"}), | 883 | REPORT_PREDEFINED_ERR_MSG("E10055", std::vector<const char *>({"reason"}), |
| 897 | std::vector<const char *>({ss_err_msg.str().c_str()})); | 884 | std::vector<const char *>({ss_err_msg.str().c_str()})); |
| 898 | GELOGE(FAILED, "[Check][Option]mode[%d] should set soc_version[%s]", iter->first, target_soc.c_str()); | 885 | GELOGE(FAILED, "[Check][Option]mode[%d] should set soc_version[%s]", iter->first, target_soc.c_str()); |
| @@ -901,7 +888,7 @@ class GFlagUtils { | |||
| 901 | // soc version匹配成功,但mode参数不匹配 | 888 | // soc version匹配成功,但mode参数不匹配 |
| 902 | for (const std::string &soc_str : iter->second) { | 889 | for (const std::string &soc_str : iter->second) { |
| 903 | if (soc_str == FLAGS_soc_version) { | 890 | if (soc_str == FLAGS_soc_version) { |
| 904 | - ss_err_msg << "option soc_version[" << soc_str << "] and mode[" << iter->first << "] must be set together"; | 891 | + ss_err_msg << "Option soc_version " << soc_str << " and mode " << iter->first << " must be set together"; |
| 905 | REPORT_PREDEFINED_ERR_MSG("E10055", std::vector<const char *>({"reason"}), | 892 | REPORT_PREDEFINED_ERR_MSG("E10055", std::vector<const char *>({"reason"}), |
| 906 | std::vector<const char *>({ss_err_msg.str().c_str()})); | 893 | std::vector<const char *>({ss_err_msg.str().c_str()})); |
| 907 | GELOGE(FAILED, "[Check][Option]soc_version[%s] should set mode[%d]", soc_str.c_str(), iter->first); | 894 | GELOGE(FAILED, "[Check][Option]soc_version[%s] should set mode[%d]", soc_str.c_str(), iter->first); |
| @@ -1351,13 +1338,13 @@ namespace { | |||
| 1351 | static Status GenerateOfflineModel(GeGenerator &ge_generator, Graph graph, | 1338 | static Status GenerateOfflineModel(GeGenerator &ge_generator, Graph graph, |
| 1352 | std::string output, std::vector<GeTensor> inputs) { | 1339 | std::string output, std::vector<GeTensor> inputs) { |
| 1353 | std::map<int32_t, OfflineModelFormat> flags_mode_map = { | 1340 | std::map<int32_t, OfflineModelFormat> flags_mode_map = { |
| 1354 | - {GEN_EXE_OM_FOR_NANO, OM_FORMAT_NANO} | 1341 | + {GEN_EXE_OM_FOR_NANO, OfflineModelFormat::OM_FORMAT_NANO} |
| 1355 | }; | 1342 | }; |
| 1356 | 1343 | ||
| 1357 | if (flags_mode_map.find(FLAGS_mode) != flags_mode_map.end()) { | 1344 | if (flags_mode_map.find(FLAGS_mode) != flags_mode_map.end()) { |
| 1358 | return ge_generator.GenerateOfflineModel(graph, output, inputs, flags_mode_map[FLAGS_mode]); | 1345 | return ge_generator.GenerateOfflineModel(graph, output, inputs, flags_mode_map[FLAGS_mode]); |
| 1359 | } | 1346 | } |
| 1360 | - return ge_generator.GenerateOfflineModel(graph, output, inputs, OM_FORMAT_DEFAULT); | 1347 | + return ge_generator.GenerateOfflineModel(graph, output, inputs, OfflineModelFormat::OM_FORMAT_DEFAULT); |
| 1361 | } | 1348 | } |
| 1362 | 1349 | ||
| 1363 | void SetAtcParams(std::map<std::string, std::string> &atc_params, const std::string &output) { | 1350 | void SetAtcParams(std::map<std::string, std::string> &atc_params, const std::string &output) { |
| @@ -1442,7 +1429,7 @@ Status GenerateModelBySingleGraph(GeGenerator &ge_generator, const std::string & | |||
| 1442 | return FAILED); | 1429 | return FAILED); |
| 1443 | ret = GenerateOfflineModel(ge_generator, graph, output, inputs); | 1430 | ret = GenerateOfflineModel(ge_generator, graph, output, inputs); |
| 1444 | if (ret != SUCCESS) { | 1431 | if (ret != SUCCESS) { |
| 1445 | - REPORT_PREDEFINED_ERR_MSG("E10042", std::vector<const char *>({}), std::vector<const char *>({})); | 1432 | + REPORT_INNER_ERR_MSG("E19999", "GE GenerateOfflineModel execute failed"); |
| 1446 | DOMI_LOGE("GE GenerateOfflineModel execute failed"); | 1433 | DOMI_LOGE("GE GenerateOfflineModel execute failed"); |
| 1447 | return FAILED; | 1434 | return FAILED; |
| 1448 | } | 1435 | } |
| @@ -1473,7 +1460,6 @@ Status GenerateModel(std::map<std::string, std::string> &options, const std::str | |||
| 1473 | GE_MAKE_GUARD(release, callback); | 1460 | GE_MAKE_GUARD(release, callback); |
| 1474 | GELOGD("Current input is single graph to generate model."); | 1461 | GELOGD("Current input is single graph to generate model."); |
| 1475 | return GenerateModelBySingleGraph(ge_generator, output, options); | 1462 | return GenerateModelBySingleGraph(ge_generator, output, options); |
| 1476 | - return SUCCESS; | ||
| 1477 | } | 1463 | } |
| 1478 | 1464 | ||
| 1479 | static void SetEnvForSingleOp(std::map<std::string, std::string> &options) { | 1465 | static void SetEnvForSingleOp(std::map<std::string, std::string> &options) { |
| @@ -1532,9 +1518,9 @@ Status GenerateSingleOp(const std::string& json_file_path) { | |||
| 1532 | } | 1518 | } |
| 1533 | 1519 | ||
| 1534 | if (!FLAGS_op_precision_mode.empty() && !CheckInputPathValid(FLAGS_op_precision_mode, "--op_precision_mode")) { | 1520 | if (!FLAGS_op_precision_mode.empty() && !CheckInputPathValid(FLAGS_op_precision_mode, "--op_precision_mode")) { |
| 1535 | - REPORT_PREDEFINED_ERR_MSG( | 1521 | + REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 1536 | - "E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 1522 | + std::vector<const char *>({"--op_precision_mode", FLAGS_op_precision_mode.c_str(), |
| 1537 | - std::vector<const char *>({"--op_precision_mode", FLAGS_op_precision_mode.c_str(), "path is not found"})); | 1523 | + "Path defined by op_precision_mode is not found."})); |
| 1538 | GELOGE(FAILED, "[Check][op_precision_mode] %s not found", FLAGS_op_precision_mode.c_str()); | 1524 | GELOGE(FAILED, "[Check][op_precision_mode] %s not found", FLAGS_op_precision_mode.c_str()); |
| 1539 | return FAILED; | 1525 | return FAILED; |
| 1540 | } | 1526 | } |
| @@ -1826,7 +1812,6 @@ Status DisplayModelInfo() { | |||
| 1826 | Status ConvertPbtxtToJson(); | 1812 | Status ConvertPbtxtToJson(); |
| 1827 | 1813 | ||
| 1828 | Status ConvertPbtxtToJson() { | 1814 | Status ConvertPbtxtToJson() { |
| 1829 | - | ||
| 1830 | if (FLAGS_om.empty()) { | 1815 | if (FLAGS_om.empty()) { |
| 1831 | REPORT_PREDEFINED_ERR_MSG("E10004", std::vector<const char *>({"parameter"}), std::vector<const char *>({"om"})); | 1816 | REPORT_PREDEFINED_ERR_MSG("E10004", std::vector<const char *>({"parameter"}), std::vector<const char *>({"om"})); |
| 1832 | GELOGE(FAILED, "[Check][Parameter]Input parameter[--om]'s value is empty!"); | 1817 | GELOGE(FAILED, "[Check][Parameter]Input parameter[--om]'s value is empty!"); |
| @@ -1835,9 +1820,9 @@ Status ConvertPbtxtToJson() { | |||
| 1835 | 1820 | ||
| 1836 | const std::string &suffix = FLAGS_om.substr(FLAGS_om.find_last_of('.') + 1); | 1821 | const std::string &suffix = FLAGS_om.substr(FLAGS_om.find_last_of('.') + 1); |
| 1837 | if (suffix != "txt") { | 1822 | if (suffix != "txt") { |
| 1838 | - static const std::string reason = "if the value of [--model] is " + | 1823 | + static const std::string reason = "If the value of --model is " + |
| 1839 | - std::to_string(static_cast<uint32_t>(RunMode::PBTXT_TO_JSON)) + | 1824 | + std::to_string(static_cast<uint32_t>(RunMode::PBTXT_TO_JSON)) + |
| 1840 | - ", [--om] parameter only support *.txt format."; | 1825 | + ", --om only supports *.txt format."; |
| 1841 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 1826 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 1842 | std::vector<const char *>({"--om", FLAGS_om.c_str(), reason.c_str()})); | 1827 | std::vector<const char *>({"--om", FLAGS_om.c_str(), reason.c_str()})); |
| 1843 | GELOGE(FAILED, "[Check][Parameter] Invalid value for --om[%s], %s", FLAGS_om.c_str(), reason.c_str()); | 1828 | GELOGE(FAILED, "[Check][Parameter] Invalid value for --om[%s], %s", FLAGS_om.c_str(), reason.c_str()); |
| @@ -1908,8 +1893,8 @@ Status CheckAndRunSingleOp() { | |||
| 1908 | if ((FLAGS_display_model_info == "1") || (FLAGS_framework != -1) || (!FLAGS_insert_op_conf.empty()) || | 1893 | if ((FLAGS_display_model_info == "1") || (FLAGS_framework != -1) || (!FLAGS_insert_op_conf.empty()) || |
| 1909 | (FLAGS_mode != static_cast<int32_t>(RunMode::GEN_OM_MODEL))) { | 1894 | (FLAGS_mode != static_cast<int32_t>(RunMode::GEN_OM_MODEL))) { |
| 1910 | std::string reason( | 1895 | std::string reason( |
| 1911 | - "After the parameter[--singleop] is specified, these parameters can cause conflicts: " | 1896 | + "When --singleop is specified, only one of the following parameters can be used: {--display_model_info, " |
| 1912 | - "[--display_model_info,--mode,--framework,--insert_op_conf]."); | 1897 | + "--mode, --framework, --insert_op_conf}."); |
| 1913 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 1898 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 1914 | std::vector<const char *>({"--singleop", FLAGS_singleop.c_str(), reason.c_str()})); | 1899 | std::vector<const char *>({"--singleop", FLAGS_singleop.c_str(), reason.c_str()})); |
| 1915 | GELOGE(FAILED, "[Check][Parameter]%s", reason.c_str()); | 1900 | GELOGE(FAILED, "[Check][Parameter]%s", reason.c_str()); |
| @@ -1991,7 +1976,7 @@ int32_t main_impl(int32_t argc, char* argv[]) { | |||
| 1991 | } | 1976 | } |
| 1992 | do { | 1977 | do { |
| 1993 | if (!FLAGS_auto_tune_mode.empty()) { | 1978 | if (!FLAGS_auto_tune_mode.empty()) { |
| 1994 | - std::string reason("The Auto Tune function has been discarded. Please use the AOE tool for tuning."); | 1979 | + std::string reason("The Auto Tune function has been deprecated. Please use the AOE tool for tuning."); |
| 1995 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 1980 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 1996 | std::vector<const char *>({"--auto_tune_mode", FLAGS_auto_tune_mode.c_str(), reason.c_str()})); | 1981 | std::vector<const char *>({"--auto_tune_mode", FLAGS_auto_tune_mode.c_str(), reason.c_str()})); |
| 1997 | GELOGE(FAILED, "[Check][Parameter]%s", reason.c_str()); | 1982 | GELOGE(FAILED, "[Check][Parameter]%s", reason.c_str()); |
| @@ -33,6 +33,7 @@ | |||
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | + | ||
| 36 | 37 | ||
| 37 | using std::ostringstream; | 38 | using std::ostringstream; |
| 38 | 39 | ||
| @@ -40,11 +41,11 @@ namespace ge { | |||
| 40 | namespace { | 41 | namespace { |
| 41 | const std::string kGraphDefaultName = "domi_default"; | 42 | const std::string kGraphDefaultName = "domi_default"; |
| 42 | const std::string kScopeIdAttr = "fusion_scope"; | 43 | const std::string kScopeIdAttr = "fusion_scope"; |
| 43 | -const char *const kOutputTypeSample = "correct sample is \"opname:index:dtype\""; | 44 | +const char *const kOutputTypeSample = "The parameter is invalid. Valid format \"opname:index:dtype\"."; |
| 44 | -const char *const kOutputTypeSupport = "only support FP32, FP16, UINT8, INT8, a node can only have one type, " | 45 | +const char *const kOutputTypeSupport = "The value must be FP32, FP16, UINT8, INT8. A node can only have one type. " |
| 45 | - "The correct example is: --output_type=FP32"; | 46 | + "The correct example is: --output_type=FP32."; |
| 46 | const char *const kOutputTypeError = "In the mode of specified node, the correct example is: node1:0:FP16;node2:0:FP32." | 47 | const char *const kOutputTypeError = "In the mode of specified node, the correct example is: node1:0:FP16;node2:0:FP32." |
| 47 | - "The nodes set in --output_type must be found in --out_nodes"; | 48 | + "The nodes set in --output_type must be found in --out_nodes."; |
| 48 | const size_t kNodeNameIndex = 0; | 49 | const size_t kNodeNameIndex = 0; |
| 49 | const size_t kIndexStrIndex = 1; | 50 | const size_t kIndexStrIndex = 1; |
| 50 | const size_t kDTValueIndex = 2; | 51 | const size_t kDTValueIndex = 2; |
| @@ -122,7 +123,7 @@ static domi::Status CheckInputShapeNode(const ComputeGraphPtr &graph, bool is_dy | |||
| 122 | GELOGE(PARAM_INVALID, "[Check][Param]Input op [%s] shape %ld is negative, " | 123 | GELOGE(PARAM_INVALID, "[Check][Param]Input op [%s] shape %ld is negative, " |
| 123 | "maybe you should set input_shape to specify its shape", node->GetName().c_str(), dim); | 124 | "maybe you should set input_shape to specify its shape", node->GetName().c_str(), dim); |
| 124 | const std::string reason = | 125 | const std::string reason = |
| 125 | - "The shapes of Inputs contain -1 in model, maybe you should set input_shape to specify its shape"; | 126 | + "The shapes of inputs contain -1 in the model. You may need to set input shape to specify its shape."; |
| 126 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 127 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 127 | std::vector<const char *>({"--input_shape", "NULL", reason.c_str()})); | 128 | std::vector<const char *>({"--input_shape", "NULL", reason.c_str()})); |
| 128 | return PARAM_INVALID; | 129 | return PARAM_INVALID; |
| @@ -275,7 +276,7 @@ domi::Status StringToInt(std::string &str, int32_t &value) { | |||
| 275 | if (!CheckDigitStr(str)) { | 276 | if (!CheckDigitStr(str)) { |
| 276 | GELOGE(PARAM_INVALID, "[Check][Param]Invalid of digit std::string: %s ", str.c_str()); | 277 | GELOGE(PARAM_INVALID, "[Check][Param]Invalid of digit std::string: %s ", str.c_str()); |
| 277 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 278 | REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 278 | - std::vector<const char *>({"--output_type", str.c_str(), "is not positive integer"})); | 279 | + std::vector<const char *>({"--output_type", str.c_str(), "The value is not a positive integer."})); |
| 279 | return PARAM_INVALID; | 280 | return PARAM_INVALID; |
| 280 | } | 281 | } |
| 281 | value = stoi(str); | 282 | value = stoi(str); |
| @@ -382,8 +383,8 @@ domi::Status CheckOutNode(ge::OpDescPtr op_desc, int32_t index) { | |||
| 382 | "[Check][Param]out_node [%s] output index:%d must be smaller " | 383 | "[Check][Param]out_node [%s] output index:%d must be smaller " |
| 383 | "than node output size:%d and can not be negative", | 384 | "than node output size:%d and can not be negative", |
| 384 | op_desc->GetName().c_str(), index, out_size); | 385 | op_desc->GetName().c_str(), index, out_size); |
| 385 | - std::string fail_reason = "output index:" + to_string(index) + " must be smaller than output size:" + | 386 | + std::string fail_reason = "Output index:\"" + to_string(index) + "\" must be smaller than output size:" + |
| 386 | - to_string(out_size) + " and can not be negative"; | 387 | + to_string(out_size) + " and cannot be negative."; |
| 387 | REPORT_PREDEFINED_ERR_MSG("E10003", std::vector<const char *>({"parameter", "value", "reason"}), | 388 | REPORT_PREDEFINED_ERR_MSG("E10003", std::vector<const char *>({"parameter", "value", "reason"}), |
| 388 | std::vector<const char *>({"out_nodes", op_desc->GetName().c_str(), fail_reason.c_str()})); | 389 | std::vector<const char *>({"out_nodes", op_desc->GetName().c_str(), fail_reason.c_str()})); |
| 389 | return FAILED; | 390 | return FAILED; |
| @@ -620,7 +621,8 @@ domi::Status ParseOutNodes(const std::string &out_nodes) { | |||
| 620 | REPORT_PREDEFINED_ERR_MSG( | 621 | REPORT_PREDEFINED_ERR_MSG( |
| 621 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 622 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 622 | std::vector<const char *>( | 623 | std::vector<const char *>( |
| 623 | - {"--out_nodes", node.c_str(), "the correct format is \"node_name1:0;node_name1:1;node_name2:0\""})); | 624 | + {"--out_nodes", node.c_str(), |
| 625 | + "The parameter format is invalid. Valid format: \"node_name1:0;node_name1:1;node_name2:0\"."})); | ||
| 624 | GELOGE(PARAM_INVALID, | 626 | GELOGE(PARAM_INVALID, |
| 625 | "[Parse][Param]The input format of --out_nodes is invalid, the correct format is " | 627 | "[Parse][Param]The input format of --out_nodes is invalid, the correct format is " |
| 626 | "\"node_name1:0;node_name1:1;node_name2:0\", while the actual input is %s.", | 628 | "\"node_name1:0;node_name1:1;node_name2:0\", while the actual input is %s.", |
| @@ -635,7 +637,7 @@ domi::Status ParseOutNodes(const std::string &out_nodes) { | |||
| 635 | if (!CheckDigitStr(key_value_v[1])) { | 637 | if (!CheckDigitStr(key_value_v[1])) { |
| 636 | REPORT_PREDEFINED_ERR_MSG( | 638 | REPORT_PREDEFINED_ERR_MSG( |
| 637 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 639 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 638 | - std::vector<const char *>({"--out_nodes", out_nodes.c_str(), "index is not positive integer"})); | 640 | + std::vector<const char *>({"--out_nodes", out_nodes.c_str(), "The index is not a positive integer."})); |
| 639 | GELOGE(PARAM_INVALID, "[Parse][Param]This str must be digit string, while the actual input is %s", | 641 | GELOGE(PARAM_INVALID, "[Parse][Param]This str must be digit string, while the actual input is %s", |
| 640 | out_nodes.c_str()); | 642 | out_nodes.c_str()); |
| 641 | return PARAM_INVALID; | 643 | return PARAM_INVALID; |
| @@ -656,7 +658,8 @@ domi::Status ParseOutNodes(const std::string &out_nodes) { | |||
| 656 | if (set_output_mode == kSetOutputModeMixed) { | 658 | if (set_output_mode == kSetOutputModeMixed) { |
| 657 | REPORT_PREDEFINED_ERR_MSG( | 659 | REPORT_PREDEFINED_ERR_MSG( |
| 658 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 660 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 659 | - std::vector<const char *>({"--out_nodes", out_nodes.c_str(), "is not all index or top_name"})); | 661 | + std::vector<const char *>( |
| 662 | + {"--out_nodes", out_nodes.c_str(), "Only one of index, top_name and output_name can be used."})); | ||
| 660 | GELOGE(PARAM_INVALID, "[Parse][Param]This out_nodes str must be all index or tensor_name, " | 663 | GELOGE(PARAM_INVALID, "[Parse][Param]This out_nodes str must be all index or tensor_name, " |
| 661 | "while the actual input is %s", out_nodes.c_str()); | 664 | "while the actual input is %s", out_nodes.c_str()); |
| 662 | return PARAM_INVALID; | 665 | return PARAM_INVALID; |
| @@ -699,7 +702,7 @@ static domi::Status CheckOpNameMap(const ComputeGraphPtr &graph, const std::stri | |||
| 699 | if (propertiesMap.empty()) { | 702 | if (propertiesMap.empty()) { |
| 700 | REPORT_PREDEFINED_ERR_MSG( | 703 | REPORT_PREDEFINED_ERR_MSG( |
| 701 | "E10003", std::vector<const char *>({"parameter", "value", "reason"}), | 704 | "E10003", std::vector<const char *>({"parameter", "value", "reason"}), |
| 702 | - std::vector<const char *>({"op_name_map", op_conf.c_str(), "the file content is empty"})); | 705 | + std::vector<const char *>({"op_name_map", op_conf.c_str(), "The file content is empty."})); |
| 703 | GELOGE(PARAM_INVALID, "[Check][Param]op_name_map file content is empty, please check file!"); | 706 | GELOGE(PARAM_INVALID, "[Check][Param]op_name_map file content is empty, please check file!"); |
| 704 | return PARAM_INVALID; | 707 | return PARAM_INVALID; |
| 705 | } | 708 | } |
| @@ -707,9 +710,9 @@ static domi::Status CheckOpNameMap(const ComputeGraphPtr &graph, const std::stri | |||
| 707 | GE_IF_BOOL_EXEC(graphNodeTypes.find(iter->second) == graphNodeTypes.end(), | 710 | GE_IF_BOOL_EXEC(graphNodeTypes.find(iter->second) == graphNodeTypes.end(), |
| 708 | REPORT_PREDEFINED_ERR_MSG( | 711 | REPORT_PREDEFINED_ERR_MSG( |
| 709 | "E10003", std::vector<const char *>({"parameter", "value", "reason"}), | 712 | "E10003", std::vector<const char *>({"parameter", "value", "reason"}), |
| 710 | - std::vector<const char *>({"op_name_map", op_conf.c_str(), ("type[" + iter->second + "] is not found in model").c_str()})); | 713 | + std::vector<const char *>({"op_name_map", op_conf.c_str(), |
| 711 | - GELOGE(PARAM_INVALID, "[Find][NodeType]Invalid parameter for op_name_map."); | 714 | + ("Type[" + iter->second + "] is not found in the model.").c_str()})); |
| 712 | - return PARAM_INVALID;); | 715 | + GELOGE(PARAM_INVALID, "[Find][NodeType]Invalid parameter for op_name_map."); return PARAM_INVALID;); |
| 713 | } | 716 | } |
| 714 | return SUCCESS; | 717 | return SUCCESS; |
| 715 | } | 718 | } |
| @@ -774,7 +777,7 @@ FMK_FUNC_HOST_VISIBILITY domi::Status ParseGraph(ge::Graph &graph, const std::ma | |||
| 774 | GE_IF_BOOL_EXEC(!PropertiesManager::Instance().Init(op_conf), | 777 | GE_IF_BOOL_EXEC(!PropertiesManager::Instance().Init(op_conf), |
| 775 | REPORT_PREDEFINED_ERR_MSG( | 778 | REPORT_PREDEFINED_ERR_MSG( |
| 776 | "E10003", std::vector<const char *>({"parameter", "value", "reason"}), | 779 | "E10003", std::vector<const char *>({"parameter", "value", "reason"}), |
| 777 | - std::vector<const char *>({"op_name_map", op_conf, "file content error"})); | 780 | + std::vector<const char *>({"op_name_map", op_conf, "File content error."})); |
| 778 | GELOGE(FAILED, "[Invoke][Init]op_name_map init failed!"); | 781 | GELOGE(FAILED, "[Invoke][Init]op_name_map init failed!"); |
| 779 | return FAILED); | 782 | return FAILED); |
| 780 | // Return map and put it into ATC global variable | 783 | // Return map and put it into ATC global variable |
| @@ -1077,8 +1080,9 @@ FMK_FUNC_HOST_VISIBILITY domi::Status ConvertFwkModelToJson(const domi::Framewor | |||
| 1077 | 1080 | ||
| 1078 | REPORT_PREDEFINED_ERR_MSG( | 1081 | REPORT_PREDEFINED_ERR_MSG( |
| 1079 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), | 1082 | "E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 1080 | - std::vector<const char *>({"--framework", std::to_string(framework).c_str(), | 1083 | + std::vector<const char *>( |
| 1081 | - "only support 0(Caffe) 3(TensorFlow) 5(Onnx) when model set 1"})); | 1084 | + {"--framework", std::to_string(framework).c_str(), |
| 1085 | + "The ramework must be selected from {0(Caffe), 3(TensorFlow), 5(Onnx)} when model is set to 1(JSON)."})); | ||
| 1082 | GELOGE(PARAM_INVALID, "[Check][Param]Input parameter[--framework] is mandatory " | 1086 | GELOGE(PARAM_INVALID, "[Check][Param]Input parameter[--framework] is mandatory " |
| 1083 | "and it's value must be: 0(Caffe) 3(TensorFlow) or 5(Onnx)."); | 1087 | "and it's value must be: 0(Caffe) 3(TensorFlow) or 5(Onnx)."); |
| 1084 | return PARAM_INVALID; | 1088 | return PARAM_INVALID; |
| @@ -0,0 +1,12 @@ | |||
| 1 | +approvers: | ||
| 2 | +- wqtshg | ||
| 3 | +- zhangfan_hq | ||
| 4 | +- lipeiyang3699 | ||
| 5 | +- zhangdepeng2 | ||
| 6 | +reviewers: | ||
| 7 | +- sheng-nan | ||
| 8 | +- chengyuan14 | ||
| 9 | +- songmingyang001 | ||
| 10 | + | ||
| 11 | +options: | ||
| 12 | + no_parent_owners: true | ||
| @@ -1,4 +1,6 @@ | |||
| 1 | -# ---------------------------------------------------------------------------- | 1 | +#!/usr/bin/env python3 |
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 2 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 3 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 5 | # 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"). | 6 | # CANN Open Software License Agreement Version 2.0 (the "License"). |
| @@ -6,5 +8,5 @@ | |||
| 6 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 8 | # 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. | 9 | # 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. | 10 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -# ---------------------------------------------------------------------------- | 11 | +# ----------------------------------------------------------------------------------------------------------- |
| 10 | 12 | ||
| @@ -1,4 +1,6 @@ | |||
| 1 | -# ---------------------------------------------------------------------------- | 1 | +#!/usr/bin/env python3 |
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 2 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 3 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 5 | # 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"). | 6 | # CANN Open Software License Agreement Version 2.0 (the "License"). |
| @@ -6,5 +8,5 @@ | |||
| 6 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 8 | # 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. | 9 | # 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. | 10 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -# ---------------------------------------------------------------------------- | 11 | +# ----------------------------------------------------------------------------------------------------------- |
| 10 | 12 | ||
| @@ -1,4 +1,6 @@ | |||
| 1 | -# ---------------------------------------------------------------------------- | 1 | +#!/usr/bin/env python3 |
| 2 | +# -*- coding: utf-8 -*- | ||
| 3 | +# ----------------------------------------------------------------------------------------------------------- | ||
| 2 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 3 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 5 | # 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"). | 6 | # CANN Open Software License Agreement Version 2.0 (the "License"). |
| @@ -6,5 +8,5 @@ | |||
| 6 | # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | 8 | # 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. | 9 | # 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. | 10 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | -# ---------------------------------------------------------------------------- | 11 | +# ----------------------------------------------------------------------------------------------------------- |
| 10 | 12 | ||
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -97,7 +98,6 @@ try: | |||
| 97 | _default_lib_available = True | 98 | _default_lib_available = True |
| 98 | except OSError as e: | 99 | except OSError as e: |
| 99 | _default_lib = None | 100 | _default_lib = None |
| 100 | - print(f"Warning: Failed to load {DEFAULT_GENERATED_LIB_NAME}: {e}") | ||
| 101 | 101 | ||
| 102 | 102 | ||
| 103 | def is_generated_lib_available(): | 103 | def is_generated_lib_available(): |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -71,4 +72,4 @@ def is_session_lib_loaded(): | |||
| 71 | Returns: | 72 | Returns: |
| 72 | bool: True if library is loaded successfully. | 73 | bool: True if library is loaded successfully. |
| 73 | """ | 74 | """ |
| 74 | - return session_lib is not None | 75 | + return session_lib is not None |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -13,19 +14,35 @@ | |||
| 13 | """Runtime utilities for dynamically discovering and loading ES plugins.""" | 14 | """Runtime utilities for dynamically discovering and loading ES plugins.""" |
| 14 | 15 | ||
| 15 | import importlib | 16 | import importlib |
| 16 | -import logging | ||
| 17 | import sys | 17 | import sys |
| 18 | from types import ModuleType | 18 | from types import ModuleType |
| 19 | -from typing import Dict, Any, Union, List | 19 | +from typing import Dict, Any, List |
| 20 | 20 | ||
| 21 | try: | 21 | try: |
| 22 | from importlib.metadata import entry_points | 22 | from importlib.metadata import entry_points |
| 23 | except ImportError: | 23 | except ImportError: |
| 24 | from importlib_metadata import entry_points # type: ignore | 24 | from importlib_metadata import entry_points # type: ignore |
| 25 | 25 | ||
| 26 | -LOG = logging.getLogger(__name__) | ||
| 27 | _ENTRY_POINT_GROUP = "ge.es.plugins" | 26 | _ENTRY_POINT_GROUP = "ge.es.plugins" |
| 28 | 27 | ||
| 28 | +# Log level keywords | ||
| 29 | +LOG_LEVEL_INFO = "INFO" | ||
| 30 | +LOG_LEVEL_WARNING = "WARNING" | ||
| 31 | +LOG_LEVEL_ERROR = "ERROR" | ||
| 32 | + | ||
| 33 | + | ||
| 34 | +def debug_print(level: str, message: str, *args): | ||
| 35 | + """Print debug message with formatted output. | ||
| 36 | + | ||
| 37 | + Args: | ||
| 38 | + level: Log level (INFO, WARNING, ERROR) | ||
| 39 | + message: Message format string | ||
| 40 | + *args: Arguments for message formatting | ||
| 41 | + """ | ||
| 42 | + module_name = __name__ | ||
| 43 | + formatted_message = message % args if args else message | ||
| 44 | + print(f"[{level}] [{module_name}] {formatted_message}") | ||
| 45 | + | ||
| 29 | 46 | ||
| 30 | def _iter_plugin_entry_points() -> List[Any]: | 47 | def _iter_plugin_entry_points() -> List[Any]: |
| 31 | """Compatible with entry_points API changes across different Python versions.""" | 48 | """Compatible with entry_points API changes across different Python versions.""" |
| @@ -80,7 +97,7 @@ def load_all_plugins() -> Dict[str, ModuleType]: | |||
| 80 | for entry_point in _iter_plugin_entry_points(): | 97 | for entry_point in _iter_plugin_entry_points(): |
| 81 | name = getattr(entry_point, "name", None) | 98 | name = getattr(entry_point, "name", None) |
| 82 | if not name: | 99 | if not name: |
| 83 | - LOG.warning("Ignoring ES plugin entry point without name: %s", entry_point) | 100 | + debug_print(LOG_LEVEL_WARNING, "Ignoring ES plugin entry point without name: %s", entry_point) |
| 84 | continue | 101 | continue |
| 85 | 102 | ||
| 86 | try: | 103 | try: |
| @@ -97,28 +114,25 @@ def load_all_plugins() -> Dict[str, ModuleType]: | |||
| 97 | # Add to plugin dictionary | 114 | # Add to plugin dictionary |
| 98 | plugins[name] = module | 115 | plugins[name] = module |
| 99 | 116 | ||
| 100 | - # Check plugin status (if plugin provides status function) | 117 | + debug_print(LOG_LEVEL_INFO, "ES plugin '%s' loaded: %s", name, module.__name__) |
| 101 | - status = "loaded" | ||
| 102 | - if hasattr(module, "is_ops_loaded"): | ||
| 103 | - ops_loaded = module.is_ops_loaded() | ||
| 104 | - status = "fully loaded" if ops_loaded else "partially loaded" | ||
| 105 | - | ||
| 106 | - LOG.info("ES plugin '%s' %s: %s", name, status, module.__name__) | ||
| 107 | 118 | ||
| 108 | except AttributeError as err: | 119 | except AttributeError as err: |
| 109 | - LOG.error( | 120 | + debug_print( |
| 121 | + LOG_LEVEL_ERROR, | ||
| 110 | "Failed to load ES plugin '%s': entry point '%s' missing required attribute. " | 122 | "Failed to load ES plugin '%s': entry point '%s' missing required attribute. " |
| 111 | "Ensure the plugin's __init__.py defines get_module(). Error: %s", | 123 | "Ensure the plugin's __init__.py defines get_module(). Error: %s", |
| 112 | name, getattr(entry_point, "value", "unknown"), err | 124 | name, getattr(entry_point, "value", "unknown"), err |
| 113 | ) | 125 | ) |
| 114 | except ImportError as err: | 126 | except ImportError as err: |
| 115 | - LOG.error( | 127 | + debug_print( |
| 128 | + LOG_LEVEL_ERROR, | ||
| 116 | "Failed to import ES plugin '%s': %s. " | 129 | "Failed to import ES plugin '%s': %s. " |
| 117 | "Check if all dependencies are installed.", | 130 | "Check if all dependencies are installed.", |
| 118 | name, err | 131 | name, err |
| 119 | ) | 132 | ) |
| 120 | except Exception as err: | 133 | except Exception as err: |
| 121 | - LOG.error( | 134 | + debug_print( |
| 135 | + LOG_LEVEL_ERROR, | ||
| 122 | "Unexpected error loading ES plugin '%s' (entry point: %s): %s", | 136 | "Unexpected error loading ES plugin '%s' (entry point: %s): %s", |
| 123 | name, getattr(entry_point, "value", "unknown"), err | 137 | name, getattr(entry_point, "value", "unknown"), err |
| 124 | ) | 138 | ) |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,3 +1,5 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 1 | # ---------------------------------------------------------------------------- | 3 | # ---------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 3 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,3 +1,5 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +# -*- coding: utf-8 -*- | ||
| 1 | # ---------------------------------------------------------------------------- | 3 | # ---------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 3 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -7,7 +9,6 @@ | |||
| 7 | # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | 9 | # 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. | 10 | # See LICENSE in the root of the software repository for the full text of the License. |
| 9 | # ---------------------------------------------------------------------------- | 11 | # ---------------------------------------------------------------------------- |
| 10 | - | ||
| 11 | from enum import IntEnum | 12 | from enum import IntEnum |
| 12 | 13 | ||
| 13 | 14 | ||
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -1,5 +1,6 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | +# ------------------------------------------------------------------- | ||
| 3 | # ----------------------------------------------------------------------------------------------------------- | 4 | # ----------------------------------------------------------------------------------------------------------- |
| 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -9,7 +9,6 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | - | ||
| 13 | 12 | ||
| 14 | 13 | ||
| 15 | 14 | ||
| @@ -76,14 +76,14 @@ graphStatus GeApiWrapper_Graph_Dump_To_Onnx(Graph *graph, const char *path, cons | |||
| 76 | return ge::GRAPH_SUCCESS; | 76 | return ge::GRAPH_SUCCESS; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | -graphStatus GeApiWrapper_Graph_Dump_To_File(Graph *graph, int32_t format, const char *suffix) { | 79 | +graphStatus GeApiWrapper_Graph_Dump_To_File(const Graph *graph, int32_t format, const char *suffix) { |
| 80 | GE_ASSERT_NOTNULL(graph); | 80 | GE_ASSERT_NOTNULL(graph); |
| 81 | GE_ASSERT_NOTNULL(suffix); | 81 | GE_ASSERT_NOTNULL(suffix); |
| 82 | AscendString suffix_str(suffix); | 82 | AscendString suffix_str(suffix); |
| 83 | return graph->DumpToFile(static_cast<ge::Graph::DumpFormat>(format), suffix_str); | 83 | return graph->DumpToFile(static_cast<ge::Graph::DumpFormat>(format), suffix_str); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | -const char *GeApiWrapper_Graph_Dump_To_Stream(Graph *graph, int32_t format) { | 86 | +const char *GeApiWrapper_Graph_Dump_To_Stream(const Graph *graph, int32_t format) { |
| 87 | GE_ASSERT_NOTNULL(graph); | 87 | GE_ASSERT_NOTNULL(graph); |
| 88 | std::ostringstream oss; | 88 | std::ostringstream oss; |
| 89 | GE_ASSERT_GRAPH_SUCCESS(graph->Dump(static_cast<ge::Graph::DumpFormat>(format), oss)); | 89 | GE_ASSERT_GRAPH_SUCCESS(graph->Dump(static_cast<ge::Graph::DumpFormat>(format), oss)); |
| @@ -91,7 +91,7 @@ const char *GeApiWrapper_Graph_Dump_To_Stream(Graph *graph, int32_t format) { | |||
| 91 | return ge::c_wrapper::MallocCopyString(dump_result.c_str()); | 91 | return ge::c_wrapper::MallocCopyString(dump_result.c_str()); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | -graphStatus GeApiWrapper_Graph_SaveToAir(Graph *graph, const char_t *file_name) { | 94 | +graphStatus GeApiWrapper_Graph_SaveToAir(const Graph *graph, const char_t *file_name) { |
| 95 | GE_ASSERT_NOTNULL(graph); | 95 | GE_ASSERT_NOTNULL(graph); |
| 96 | GE_ASSERT_NOTNULL(file_name); | 96 | GE_ASSERT_NOTNULL(file_name); |
| 97 | return graph->SaveToFile(file_name); | 97 | return graph->SaveToFile(file_name); |
| @@ -103,7 +103,7 @@ graphStatus GeApiWrapper_Graph_LoadFromAir(Graph *graph, const char_t *file_name | |||
| 103 | return graph->LoadFromFile(file_name); | 103 | return graph->LoadFromFile(file_name); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | -GNode **GeApiWrapper_Graph_GetDirectNode(Graph *graph, size_t *node_num) { | 106 | +GNode **GeApiWrapper_Graph_GetDirectNode(const Graph *graph, size_t *node_num) { |
| 107 | GE_ASSERT_NOTNULL(graph); | 107 | GE_ASSERT_NOTNULL(graph); |
| 108 | GE_ASSERT_NOTNULL(node_num); | 108 | GE_ASSERT_NOTNULL(node_num); |
| 109 | return VecGNodesToArray(graph->GetDirectNode(), node_num); | 109 | return VecGNodesToArray(graph->GetDirectNode(), node_num); |
| @@ -131,7 +131,7 @@ graphStatus GeApiWrapper_Graph_RemoveNode(Graph *graph, GNode &node) { | |||
| 131 | return graph->RemoveNode(node); | 131 | return graph->RemoveNode(node); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | -graphStatus GeApiWrapper_Graph_FindNodeByName(Graph *graph, const char *name, GNode **node) { | 134 | +graphStatus GeApiWrapper_Graph_FindNodeByName(const Graph *graph, const char *name, GNode **node) { |
| 135 | GE_ASSERT_NOTNULL(graph); | 135 | GE_ASSERT_NOTNULL(graph); |
| 136 | GE_ASSERT_NOTNULL(name); | 136 | GE_ASSERT_NOTNULL(name); |
| 137 | AscendString node_name(name); | 137 | AscendString node_name(name); |
| @@ -17,6 +17,8 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | + | ||
| 21 | + | ||
| 20 | 22 | ||
| 21 | namespace ge { | 23 | namespace ge { |
| 22 | namespace c_wrapper { | 24 | namespace c_wrapper { |
| @@ -147,6 +149,9 @@ inline const char *AscendStringToChar(const AscendString &s) { | |||
| 147 | } // namespace ge | 149 | } // namespace ge |
| 148 | 150 | ||
| 149 | 151 | ||
| 152 | + | ||
| 153 | +using char_t = char; | ||
| 154 | + | ||
| 150 | extern "C" { | 155 | extern "C" { |
| 151 | 156 | ||
| 152 | ge::graphStatus GeApiWrapper_AttrValue_SetBool(void *av, bool value); | 157 | ge::graphStatus GeApiWrapper_AttrValue_SetBool(void *av, bool value); |
| @@ -202,12 +207,42 @@ ge::graphStatus GeApiWrapper_GNode_GetAttr(const ge::GNode *node, const char *ke | |||
| 202 | ge::graphStatus GeApiWrapper_GNode_SetOutputAttr(ge::GNode *node, const char *attr_name, uint32_t output_index, | 207 | ge::graphStatus GeApiWrapper_GNode_SetOutputAttr(ge::GNode *node, const char *attr_name, uint32_t output_index, |
| 203 | const void *attr_value); | 208 | const void *attr_value); |
| 204 | void GeApiWrapper_GNode_FreeIntArray(int32_t *arrs); | 209 | void GeApiWrapper_GNode_FreeIntArray(int32_t *arrs); |
| 210 | +ge::Status GeApiWrapper_GEFinalize(); | ||
| 211 | +ge::Status GeApiWrapper_GEInitialize(char **keys, char **values, int size); | ||
| 212 | +ge::graphStatus GeApiWrapper_Graph_LoadFromAir(ge::Graph *graph, const char_t *file_name); | ||
| 213 | +ge::graphStatus GeApiWrapper_Graph_AddControlEdge(ge::Graph *graph, ge::GNode &src_node, ge::GNode &dst_node); | ||
| 214 | +ge::graphStatus GeApiWrapper_Graph_SetAttr(ge::Graph *graph, const char *key, const void *attr_value); | ||
| 215 | +ge::graphStatus GeApiWrapper_Graph_RemoveNode(ge::Graph *graph, ge::GNode &node); | ||
| 216 | +ge::graphStatus GeApiWrapper_Graph_Dump_To_File(const ge::Graph *graph, int32_t format, const char *suffix); | ||
| 217 | +const char *GeApiWrapper_Graph_Dump_To_Stream(const ge::Graph *graph, int32_t format); | ||
| 218 | +ge::graphStatus GeApiWrapper_Graph_FindNodeByName(const ge::Graph *graph, const char *name, ge::GNode **node); | ||
| 219 | +const char *GeApiWrapper_Graph_GetName(const ge::Graph *graph); | ||
| 220 | +ge::Graph *GeApiWrapper_Graph_CreateGraph(const char *name); | ||
| 221 | +ge::graphStatus GeApiWrapper_Graph_SaveToAir(const ge::Graph *graph, const char_t *file_name); | ||
| 222 | +ge::graphStatus GeApiWrapper_Graph_RemoveEdge(ge::Graph *graph, ge::GNode &src_node, const int32_t src_port_index, | ||
| 223 | + ge::GNode &dst_node, const int32_t dst_port_index); | ||
| 224 | +ge::graphStatus GeApiWrapper_Graph_GetAttr(const ge::Graph *graph, const char *key, void *attr_value); | ||
| 225 | +void GeApiWrapper_Graph_DestroyGraph(const ge::Graph *graph); | ||
| 205 | void GeApiWrapper_Graph_FreeGraphArray(ge::Graph **graphs); | 226 | void GeApiWrapper_Graph_FreeGraphArray(ge::Graph **graphs); |
| 227 | +ge::graphStatus GeApiWrapper_Graph_AddDataEdge(ge::Graph *graph, ge::GNode &src_node, const int32_t src_port_index, | ||
| 228 | + ge::GNode &dst_node, const int32_t dst_port_index); | ||
| 229 | +ge::GNode **GeApiWrapper_Graph_GetAllNodes(const ge::Graph *graph, size_t *node_num); | ||
| 230 | +ge::GNode **GeApiWrapper_Graph_GetDirectNode(const ge::Graph *graph, size_t *node_num); | ||
| 231 | +ge::graphStatus GeApiWrapper_Graph_Dump_To_Onnx(ge::Graph *graph, const char *path, const char *suffix); | ||
| 206 | ge::Graph **GeApiWrapper_Graph_GetAllSubgraphs(const ge::Graph *graph, size_t *subgraph_num); | 232 | ge::Graph **GeApiWrapper_Graph_GetAllSubgraphs(const ge::Graph *graph, size_t *subgraph_num); |
| 207 | ge::Graph *GeApiWrapper_Graph_GetSubGraph(const ge::Graph *graph, const char *name); | 233 | ge::Graph *GeApiWrapper_Graph_GetSubGraph(const ge::Graph *graph, const char *name); |
| 208 | ge::graphStatus GeApiWrapper_Graph_AddSubGraph(ge::Graph *graph, const ge::Graph *subgraph); | 234 | ge::graphStatus GeApiWrapper_Graph_AddSubGraph(ge::Graph *graph, const ge::Graph *subgraph); |
| 209 | ge::graphStatus GeApiWrapper_Graph_RemoveSubgraph(ge::Graph *graph, const char *name); | 235 | ge::graphStatus GeApiWrapper_Graph_RemoveSubgraph(ge::Graph *graph, const char *name); |
| 210 | - | 236 | +ge::Session *GeApiWrapper_Session_CreateSession(); |
| 237 | +ge::Tensor** GeApiWrapper_Session_RunGraph(ge::Session *session, uint32_t graph_id, void **inputs, int input_count, size_t *tensor_num); | ||
| 238 | +ge::Status GeApiWrapper_Session_AddGraph(ge::Session *session, uint32_t graph_id, ge::Graph *graph); | ||
| 239 | +void GeApiWrapper_Session_DestroySession(const ge::Session *session); | ||
| 240 | +ge::Format GeApiWrapper_Tensor_GetFormat(EsCTensor *tensor); | ||
| 241 | +EsCTensor *GeApiWrapper_Tensor_CreateTensor(); | ||
| 242 | +void GeApiWrapper_Tensor_DestroyEsCTensor(EsCTensor *tensor); | ||
| 243 | +ge::graphStatus GeApiWrapper_Tensor_SetFormat(EsCTensor *tensor, const ge::Format &format); | ||
| 244 | +ge::DataType GeApiWrapper_Tensor_GetDataType(EsCTensor *tensor); | ||
| 245 | +ge::graphStatus GeApiWrapper_Tensor_SetDataType(EsCTensor *tensor, const ge::DataType &dtype); | ||
| 211 | 246 | ||
| 212 | } | 247 | } |
| 213 | 248 | ||
| @@ -1,6 +1,5 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | -#------------------------------------------------------------------- | ||
| 4 | # ----------------------------------------------------------------------------------------------------------- | 3 | # ----------------------------------------------------------------------------------------------------------- |
| 5 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. | 4 | # Copyright (c) 2025 Huawei Technologies Co., Ltd. |
| 6 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of | 5 | # This program is free software, you can redistribute it and/or modify it under the terms and conditions of |
| @@ -14,9 +14,7 @@ if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) | |||
| 14 | 14 | ||
| 15 | set(RUNNER_SRC_LIST_V2 | 15 | set(RUNNER_SRC_LIST_V2 |
| 16 | "client/ge_api_v2.cc" | 16 | "client/ge_api_v2.cc" |
| 17 | - "session_v2/inner_ge_session.cc" | 17 | + "session/ge_session_impl.cc" |
| 18 | - "session_v2/ge_session_manager.cc" | ||
| 19 | - "session_v2/ge_session_impl.cc" | ||
| 20 | "common/plugin/tbe_plugin_manager.cc" | 18 | "common/plugin/tbe_plugin_manager.cc" |
| 21 | ) | 19 | ) |
| 22 | 20 | ||
| @@ -46,12 +46,12 @@ | |||
| 46 | 46 | ||
| 47 | 47 | ||
| 48 | 48 | ||
| 49 | - | ||
| 50 | 49 | ||
| 51 | 50 | ||
| 52 | 51 | ||
| 53 | 52 | ||
| 54 | 53 | ||
| 54 | + | ||
| 55 | 55 | ||
| 56 | namespace { | 56 | namespace { |
| 57 | constexpr int32_t kMaxStrLen = 128; | 57 | constexpr int32_t kMaxStrLen = 128; |
| @@ -81,15 +81,17 @@ std::map<ge::DataType, size_t> CONST_OPDATA_TYPE_SIZE_MAP = { | |||
| 81 | }; | 81 | }; |
| 82 | 82 | ||
| 83 | // dfx for RunGraphAsync, log error on error return | 83 | // dfx for RunGraphAsync, log error on error return |
| 84 | -void RunGraphAsyncCallback(ge::Status ret, uint64_t session_id, uint32_t graph_id, std::vector<ge::Tensor> &outputs, | 84 | +void RunGraphAsyncCallback(ge::Status ret, uint64_t session_id, uint32_t graph_id, std::vector<gert::Tensor> &outputs, |
| 85 | - ge::RunAsyncCallback callback) { | 85 | + const ge::RunAsyncCallback &callback) { |
| 86 | if ((ret != ge::SUCCESS) && (ret != ge::END_OF_SEQUENCE)) { | 86 | if ((ret != ge::SUCCESS) && (ret != ge::END_OF_SEQUENCE)) { |
| 87 | GELOGE(ret, "Run graph async failed, error code:%u, session_id:%lu, graph_id:%u", ret, session_id, graph_id); | 87 | GELOGE(ret, "Run graph async failed, error code:%u, session_id:%lu, graph_id:%u", ret, session_id, graph_id); |
| 88 | REPORT_INNER_ERR_MSG("E19999", "Run graph async failed, error code:%u, session_id:%lu, graph_id:%u", ret, session_id, | 88 | REPORT_INNER_ERR_MSG("E19999", "Run graph async failed, error code:%u, session_id:%lu, graph_id:%u", ret, session_id, |
| 89 | graph_id); | 89 | graph_id); |
| 90 | } | 90 | } |
| 91 | if (callback != nullptr) { | 91 | if (callback != nullptr) { |
| 92 | - callback(ret, outputs); | 92 | + std::vector<ge::Tensor> ge_tensors; |
| 93 | + (void) ge::TensorTransUtils::GertTensors2Tensors(outputs, ge_tensors); | ||
| 94 | + callback(ret, ge_tensors); | ||
| 93 | } | 95 | } |
| 94 | GELOGI("run graph async finished, session_id: %lu, graph_id: %u, result=%u", session_id, graph_id, ret); | 96 | GELOGI("run graph async finished, session_id: %lu, graph_id: %u, result=%u", session_id, graph_id, ret); |
| 95 | } | 97 | } |
| @@ -104,37 +106,62 @@ ge::SessionManager *GetSessionManager() { | |||
| 104 | 106 | ||
| 105 | namespace ge { | 107 | namespace ge { |
| 106 | namespace { | 108 | namespace { |
| 107 | - void ConstructSession(const std::map<std::string, std::string> &options, SessionId &session_id) { | 109 | +void ConstructSession(const std::map<std::string, std::string> &options, SessionId &session_id) { |
| 108 | - GELOGT(TRACE_INIT, "Session Constructor start"); | 110 | + GELOGT(TRACE_INIT, "Session Constructor start"); |
| 109 | - // check init status | 111 | + // check init status |
| 110 | - session_id = 0U; | 112 | + session_id = 0U; |
| 111 | - if (!IsGEInitialize()) { | 113 | + if (!IsGEInitialize()) { |
| 112 | - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Construct session failed because lack GEInitialize call before."); | 114 | + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Construct session failed because lack GEInitialize call before."); |
| 113 | - REPORT_INNER_ERR_MSG("E19999", "Construct session failed because lack GEInitialize call before."); | 115 | + REPORT_INNER_ERR_MSG("E19999", "Construct session failed because lack GEInitialize call before."); |
| 114 | - return; | 116 | + return; |
| 115 | - } | ||
| 116 | - // call Initialize | ||
| 117 | - if (GEAPICheckSupportedSessionOptions(options) != SUCCESS) { | ||
| 118 | - GELOGW("[Check][Param] Check supported options failed."); | ||
| 119 | - } | ||
| 120 | - if (CheckAllowParallelCompile(options) != SUCCESS) { | ||
| 121 | - return; | ||
| 122 | - } | ||
| 123 | - uint64_t tmp_session_id = 0UL; | ||
| 124 | - const Status ret = g_session_manager->CreateSession(options, tmp_session_id); | ||
| 125 | - // failed guarder, should call GE_DISMISS_GUARD if success | ||
| 126 | - GE_DISMISSABLE_GUARD(create_failed, | ||
| 127 | - ([tmp_session_id]() {g_session_manager->DestroySession(tmp_session_id);})); | ||
| 128 | - if (ret != SUCCESS) { | ||
| 129 | - GELOGE(ret, "Construct session failed, error code:%u.", ret); | ||
| 130 | - REPORT_INNER_ERR_MSG("E19999", "Construct session failed, error code:%u.", ret); | ||
| 131 | - return; | ||
| 132 | - } | ||
| 133 | - | ||
| 134 | - session_id = tmp_session_id; | ||
| 135 | - GE_DISMISS_GUARD(create_failed); | ||
| 136 | - GELOGT(TRACE_STOP, "Session construct finished, session id is %lu", session_id); | ||
| 137 | } | 117 | } |
| 118 | + // call Initialize | ||
| 119 | + if (GEAPICheckSupportedSessionOptions(options) != SUCCESS) { | ||
| 120 | + GELOGW("[Check][Param] Check supported options failed."); | ||
| 121 | + } | ||
| 122 | + if (CheckAllowParallelCompile(options) != SUCCESS) { | ||
| 123 | + return; | ||
| 124 | + } | ||
| 125 | + uint64_t tmp_session_id = 0UL; | ||
| 126 | + Status ret = g_session_manager->CreateSession(options, tmp_session_id); | ||
| 127 | + // failed guarder, should call GE_DISMISS_GUARD if success | ||
| 128 | + GE_DISMISSABLE_GUARD(create_failed, | ||
| 129 | + ([tmp_session_id]() {g_session_manager->DestroySession(tmp_session_id);})); | ||
| 130 | + if (ret != SUCCESS) { | ||
| 131 | + GELOGE(ret, "Construct session failed, error code:%u.", ret); | ||
| 132 | + REPORT_INNER_ERR_MSG("E19999", "Construct session failed, error code:%u.", ret); | ||
| 133 | + return; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + session_id = tmp_session_id; | ||
| 137 | + | ||
| 138 | + auto inner_session = g_session_manager->GetSession(session_id); | ||
| 139 | + ret = inner_session->CreateDFlowSessionIfNeed(); | ||
| 140 | + if (ret != SUCCESS) { | ||
| 141 | + GELOGE(ret, "Construct session failed, error code:%u.", ret); | ||
| 142 | + REPORT_INNER_ERR_MSG("E19999", "Construct session failed, error code:%u.", ret); | ||
| 143 | + return; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + GE_DISMISS_GUARD(create_failed); | ||
| 147 | + GELOGT(TRACE_STOP, "Session construct finished, session id is %lu", session_id); | ||
| 148 | +} | ||
| 149 | + | ||
| 150 | +Status CheckCompiledFlag(const SessionPtr &inner_session, uint32_t graph_id, bool expect_flag) { | ||
| 151 | + bool flag = false; | ||
| 152 | + GE_ASSERT_SUCCESS(inner_session->GetCompiledFlag(graph_id, flag), | ||
| 153 | + "get compiled flag failed. session_id:%llu, graph_id:%u", inner_session->GetSessionId(), graph_id); | ||
| 154 | + if (flag != expect_flag) { | ||
| 155 | + const auto error_code = expect_flag ? GE_GRAPH_NOT_BUILT : UNSUPPORTED; | ||
| 156 | + const auto error_msg = expect_flag ? | ||
| 157 | + "Graph needs to be compiled first, graph_id=" + std::to_string(graph_id) : | ||
| 158 | + "Incompatible with API CompileGraph, graph_id=" + std::to_string(graph_id); | ||
| 159 | + GELOGE(error_code, "%s", error_msg.c_str()); | ||
| 160 | + REPORT_INNER_ERR_MSG("E19999", "%s", error_msg.c_str()); | ||
| 161 | + return error_code; | ||
| 162 | + } | ||
| 163 | + return SUCCESS; | ||
| 164 | +} | ||
| 138 | } // namespace | 165 | } // namespace |
| 139 | size_t SessionUtils::NumSessions() { | 166 | size_t SessionUtils::NumSessions() { |
| 140 | std::lock_guard<std::mutex> lock(g_ge_release_mutex); | 167 | std::lock_guard<std::mutex> lock(g_ge_release_mutex); |
| @@ -295,15 +322,25 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map<s | |||
| 295 | 322 | ||
| 296 | GELOGD("Adding graph to session, graph_id: %u", graph_id); | 323 | GELOGD("Adding graph to session, graph_id: %u", graph_id); |
| 297 | 324 | ||
| 298 | - Status ret = FAILED; | 325 | + auto inner_session = g_session_manager->GetSession(sessionId_); |
| 299 | - const UserHybridGraphManagerPtr user_hybrid_graph_manager = g_session_manager->GetUserHybridGraphManager(sessionId_); | 326 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Add graph failed, session_id:%lu.", sessionId_); |
| 300 | - GE_CHK_BOOL_RET_STATUS(user_hybrid_graph_manager != nullptr, FAILED, "Add graph failed, session_id:%lu.", sessionId_); | 327 | + |
| 301 | - const bool is_enable_slice_schedule = EnableSliceSchedule(); | 328 | + // Check if dflow session is enabled |
| 302 | - ret = user_hybrid_graph_manager->AddGraph(graph_id, graph, options); | 329 | + const auto dflow_session = inner_session->GetDFlowSession(); |
| 330 | + Status ret; | ||
| 331 | + if (dflow_session != nullptr) { | ||
| 332 | + GE_ASSERT_SUCCESS(InnerSession::SetSessionGraphId(graph, sessionId_, graph_id), | ||
| 333 | + "Set session graph id failed."); | ||
| 334 | + inner_session->UpdateGlobalSessionContext(); | ||
| 335 | + ret = dflow_session->AddGraph(graph_id, graph, options); | ||
| 336 | + GELOGI("Add graph to dflow session success, graph_id=%u", graph_id); | ||
| 337 | + } else { | ||
| 338 | + ret = inner_session->AddGraph(graph_id, graph, options); | ||
| 339 | + } | ||
| 303 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Add graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, | 340 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Add graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, |
| 304 | sessionId_, graph_id); | 341 | sessionId_, graph_id); |
| 305 | 342 | ||
| 306 | - GELOGD("AddGraph finished in Session, graph_id: %u, is_enable_slice_schedule:%u", graph_id, is_enable_slice_schedule); | 343 | + GELOGD("AddGraph finished in Session, graph_id: %u", graph_id); |
| 307 | return ret; | 344 | return ret; |
| 308 | } | 345 | } |
| 309 | 346 | ||
| @@ -336,15 +373,24 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map<A | |||
| 336 | GELOGW("[Check][Param] Check supported options failed."); | 373 | GELOGW("[Check][Param] Check supported options failed."); |
| 337 | } | 374 | } |
| 338 | GELOGD("Adding graph to session"); | 375 | GELOGD("Adding graph to session"); |
| 339 | - Status ret = FAILED; | 376 | + auto inner_session = g_session_manager->GetSession(sessionId_); |
| 340 | - auto isEnableSliceSchedule = EnableSliceSchedule(); | 377 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Add graph failed, session_id:%lu.", sessionId_); |
| 341 | - const UserHybridGraphManagerPtr user_hybrid_graph_manager = g_session_manager->GetUserHybridGraphManager(sessionId_); | 378 | + // Check if dflow session is enabled |
| 342 | - GE_CHK_BOOL_RET_STATUS(user_hybrid_graph_manager != nullptr, FAILED, "Add graph failed, session_id:%lu.", sessionId_); | 379 | + const auto dflow_session = inner_session->GetDFlowSession(); |
| 343 | - ret = user_hybrid_graph_manager->AddGraph(graph_id, graph, str_options); | 380 | + Status ret; |
| 381 | + if (dflow_session != nullptr) { | ||
| 382 | + GE_ASSERT_SUCCESS(InnerSession::SetSessionGraphId(graph, sessionId_, graph_id), | ||
| 383 | + "Set session graph id failed."); | ||
| 384 | + inner_session->UpdateGlobalSessionContext(); | ||
| 385 | + ret = dflow_session->AddGraph(graph_id, graph, str_options); | ||
| 386 | + GELOGI("Add graph to dflow session success, graph_id=%u", graph_id); | ||
| 387 | + } else { | ||
| 388 | + ret = inner_session->AddGraph(graph_id, graph, str_options); | ||
| 389 | + } | ||
| 344 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Add graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, | 390 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Add graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, |
| 345 | sessionId_, graph_id); | 391 | sessionId_, graph_id); |
| 346 | 392 | ||
| 347 | - GELOGD("AddGraph finished in Session, graph_id: %u, isEnableSliceSchedule:%u", graph_id, isEnableSliceSchedule); | 393 | + GELOGD("AddGraph finished in Session, graph_id: %u", graph_id); |
| 348 | return SUCCESS; | 394 | return SUCCESS; |
| 349 | } | 395 | } |
| 350 | 396 | ||
| @@ -379,6 +425,11 @@ Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph, | |||
| 379 | GELOGW("[Check][Param] Check supported options failed."); | 425 | GELOGW("[Check][Param] Check supported options failed."); |
| 380 | } | 426 | } |
| 381 | 427 | ||
| 428 | + // Check if dflow session is enabled (not supported for AddGraphWithCopy) | ||
| 429 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 430 | + GE_CHK_BOOL_RET_STATUS(dflow_session == nullptr, UNSUPPORTED, | ||
| 431 | + "Dflow session does not support current function, pls check."); | ||
| 432 | + | ||
| 382 | GELOGD("Adding graph to session"); | 433 | GELOGD("Adding graph to session"); |
| 383 | const Status ret = inner_session->AddGraphWithCopy(graph_id, graph, str_options); | 434 | const Status ret = inner_session->AddGraphWithCopy(graph_id, graph, str_options); |
| 384 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Add graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, | 435 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Add graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, |
| @@ -395,20 +446,27 @@ Status Session::RemoveGraph(uint32_t graph_id) { | |||
| 395 | REPORT_INNER_ERR_MSG("E19999", "Creating session failed because lack GEInitialize call before."); | 446 | REPORT_INNER_ERR_MSG("E19999", "Creating session failed because lack GEInitialize call before."); |
| 396 | return FAILED; | 447 | return FAILED; |
| 397 | } | 448 | } |
| 398 | - | 449 | + |
| 399 | GRAPH_PROFILING_REG(gert::GeProfInfoType::kRemoveGraph); | 450 | GRAPH_PROFILING_REG(gert::GeProfInfoType::kRemoveGraph); |
| 400 | GELOGT(TRACE_INIT, "Session RemoveGraph start, graph_id: %u", graph_id); | 451 | GELOGT(TRACE_INIT, "Session RemoveGraph start, graph_id: %u", graph_id); |
| 401 | 452 | ||
| 402 | // call RemoveGraph | 453 | // call RemoveGraph |
| 403 | - Status ret = FAILED; | 454 | + auto inner_session = g_session_manager->GetSession(sessionId_); |
| 404 | - auto isEnableSliceSchedule = EnableSliceSchedule(); | 455 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Remove graph failed, session_id:%lu.", sessionId_); |
| 405 | - const UserHybridGraphManagerPtr user_hybrid_graph_manager = g_session_manager->GetUserHybridGraphManager(sessionId_); | 456 | + |
| 406 | - GE_CHK_BOOL_RET_STATUS(user_hybrid_graph_manager != nullptr, FAILED, "Remove graph failed, session_id:%lu.", sessionId_); | 457 | + // Check if dflow session is enabled |
| 407 | - ret = user_hybrid_graph_manager->RemoveGraph(graph_id); | 458 | + const auto dflow_session = inner_session->GetDFlowSession(); |
| 459 | + Status ret; | ||
| 460 | + if (dflow_session != nullptr) { | ||
| 461 | + inner_session->UpdateGlobalSessionContext(); | ||
| 462 | + ret = dflow_session->RemoveGraph(graph_id); | ||
| 463 | + } else { | ||
| 464 | + ret = inner_session->RemoveGraph(graph_id); | ||
| 465 | + } | ||
| 408 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Remove graph failed, error code:%u, session_id:%lu, graph_id:%u.", | 466 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Remove graph failed, error code:%u, session_id:%lu, graph_id:%u.", |
| 409 | ret, sessionId_, graph_id); | 467 | ret, sessionId_, graph_id); |
| 410 | 468 | ||
| 411 | - GELOGT(TRACE_STOP, "Session RemoveGraph finished, graph_id: %u, isEnableSliceSchedule:%u", graph_id, isEnableSliceSchedule); | 469 | + GELOGT(TRACE_STOP, "Session RemoveGraph finished, graph_id: %u", graph_id); |
| 412 | return ret; | 470 | return ret; |
| 413 | } | 471 | } |
| 414 | 472 | ||
| @@ -470,13 +528,21 @@ Status Session::RunGraph(uint32_t graph_id, const std::vector<Tensor> &inputs, s | |||
| 470 | 528 | ||
| 471 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); | 529 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); |
| 472 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Run graph failed, session_id:%lu.", sessionId_); | 530 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Run graph failed, session_id:%lu.", sessionId_); |
| 473 | - | ||
| 474 | GELOGI("Session RunGraph start, session_id: %lu, graph_id: %u, input size %zu, output size %zu", | 531 | GELOGI("Session RunGraph start, session_id: %lu, graph_id: %u, input size %zu, output size %zu", |
| 475 | sessionId_, graph_id, inputs.size(), outputs.size()); | 532 | sessionId_, graph_id, inputs.size(), outputs.size()); |
| 476 | 533 | ||
| 477 | - | 534 | + // Check if dflow session is enabled |
| 478 | - // call RunGraph | 535 | + const auto dflow_session = inner_session->GetDFlowSession(); |
| 479 | - Status ret = inner_session->RunGraph(graph_id, inputs, outputs); | 536 | + Status ret; |
| 537 | + if (dflow_session != nullptr) { | ||
| 538 | + inner_session->UpdateGlobalSessionContext(); | ||
| 539 | + ret = dflow_session->RunGraph(graph_id, inputs, outputs); | ||
| 540 | + } else { | ||
| 541 | + const auto check_ret = CheckCompiledFlag(inner_session, graph_id, false); | ||
| 542 | + GE_CHK_BOOL_RET_STATUS(check_ret == SUCCESS, check_ret, | ||
| 543 | + "Run graph failed, incompatible with API CompileGraph, graph_id=%u", graph_id); | ||
| 544 | + ret = inner_session->RunGraph(graph_id, inputs, outputs); | ||
| 545 | + } | ||
| 480 | // check return status | 546 | // check return status |
| 481 | const bool need_convert_error_code = (ret == RT_ERROR_TO_GE_STATUS(ACL_ERROR_RT_QUEUE_EMPTY)); | 547 | const bool need_convert_error_code = (ret == RT_ERROR_TO_GE_STATUS(ACL_ERROR_RT_QUEUE_EMPTY)); |
| 482 | ret = need_convert_error_code ? ACL_ERROR_GE_MODEL_EXECUTE_TIMEOUT : ret; | 548 | ret = need_convert_error_code ? ACL_ERROR_GE_MODEL_EXECUTE_TIMEOUT : ret; |
| @@ -507,12 +573,14 @@ Status Session::RunGraphWithStreamAsync(uint32_t graph_id, void *stream, const s | |||
| 507 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Run graph with stream async failed, session_id:%lu.", | 573 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Run graph with stream async failed, session_id:%lu.", |
| 508 | sessionId_); | 574 | sessionId_); |
| 509 | 575 | ||
| 510 | - | 576 | + // Check if dflow session is enabled (not supported for RunGraphWithStreamAsync) |
| 577 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 578 | + GE_CHK_BOOL_RET_STATUS(dflow_session == nullptr, UNSUPPORTED, | ||
| 579 | + "Dflow session does not support current function, pls check."); | ||
| 511 | const Status ret = inner_session->RunGraphWithStreamAsync(graph_id, stream, inputs, outputs); | 580 | const Status ret = inner_session->RunGraphWithStreamAsync(graph_id, stream, inputs, outputs); |
| 512 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, | 581 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, |
| 513 | "Run graph with stream async failed, error code:%u, session_id:%lu, graph_id:%u, stream:%p.", | 582 | "Run graph with stream async failed, error code:%u, session_id:%lu, graph_id:%u, stream:%p.", |
| 514 | ret, sessionId_, graph_id, stream); | 583 | ret, sessionId_, graph_id, stream); |
| 515 | - | ||
| 516 | GELOGI("Session run graph with stream async finished."); | 584 | GELOGI("Session run graph with stream async finished."); |
| 517 | return SUCCESS; | 585 | return SUCCESS; |
| 518 | } | 586 | } |
| @@ -526,16 +594,19 @@ Status Session::ExecuteGraphWithStreamAsync(uint32_t graph_id, void *stream, con | |||
| 526 | return FAILED; | 594 | return FAILED; |
| 527 | } | 595 | } |
| 528 | 596 | ||
| 529 | - Status ret = FAILED; | 597 | + const auto inner_session = g_session_manager->GetSession(sessionId_); |
| 530 | - auto is_enable_slice_schedule = EnableSliceSchedule(); | 598 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Execute graph with stream async failed, session_id:%lu.", |
| 531 | - const UserGraphsManagerPtr user_graphs_manager = g_session_manager->GetUserGraphsManager(sessionId_); | ||
| 532 | - GE_CHK_BOOL_RET_STATUS(user_graphs_manager != nullptr, FAILED, "Execute graph with stream async failed, session_id:%lu.", | ||
| 533 | sessionId_); | 599 | sessionId_); |
| 534 | - ret = user_graphs_manager->ExecuteGraphWithStreamAsync(graph_id, stream, inputs, outputs); | 600 | + |
| 601 | + // Check if dflow session is enabled (not supported for ExecuteGraphWithStreamAsync) | ||
| 602 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 603 | + GE_CHK_BOOL_RET_STATUS(dflow_session == nullptr, UNSUPPORTED, | ||
| 604 | + "Dflow session does not support current function, pls check."); | ||
| 605 | + | ||
| 606 | + const auto ret = inner_session->ExecuteGraphWithStreamAsync(graph_id, stream, inputs, outputs); | ||
| 535 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, | 607 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, |
| 536 | "Execute graph with stream async failed, error code:%u, session_id:%lu, graph_id:%u, " | 608 | "Execute graph with stream async failed, error code:%u, session_id:%lu, graph_id:%u, " |
| 537 | - "stream:%p, is_enable_slice_schedule:%d", | 609 | + "stream:%p", ret, sessionId_, graph_id, stream); |
| 538 | - ret, sessionId_, graph_id, stream, is_enable_slice_schedule); | ||
| 539 | return SUCCESS; | 610 | return SUCCESS; |
| 540 | } | 611 | } |
| 541 | 612 | ||
| @@ -550,6 +621,11 @@ Status Session::RegisterCallBackFunc(const std::string &key, const pCallBackFunc | |||
| 550 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); | 621 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); |
| 551 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); | 622 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 552 | 623 | ||
| 624 | + // Check if dflow session is enabled (not supported for RegisterCallBackFunc) | ||
| 625 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 626 | + GE_CHK_BOOL_RET_STATUS(dflow_session == nullptr, UNSUPPORTED, | ||
| 627 | + "Dflow session does not support current function, pls check."); | ||
| 628 | + | ||
| 553 | return inner_session->RegisterCallBackFunc(key, callback); | 629 | return inner_session->RegisterCallBackFunc(key, callback); |
| 554 | } | 630 | } |
| 555 | 631 | ||
| @@ -568,6 +644,11 @@ Status Session::RegisterCallBackFunc(const char *key, const session::pCallBackFu | |||
| 568 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); | 644 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); |
| 569 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); | 645 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 570 | 646 | ||
| 647 | + // Check if dflow session is enabled (not supported for RegisterCallBackFunc) | ||
| 648 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 649 | + GE_CHK_BOOL_RET_STATUS(dflow_session == nullptr, UNSUPPORTED, | ||
| 650 | + "Dflow session does not support current function, pls check."); | ||
| 651 | + | ||
| 571 | return inner_session->RegisterCallBackFunc(str_key, callback); | 652 | return inner_session->RegisterCallBackFunc(str_key, callback); |
| 572 | } | 653 | } |
| 573 | 654 | ||
| @@ -581,11 +662,33 @@ Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo> | |||
| 581 | 662 | ||
| 582 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); | 663 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); |
| 583 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Build graph failed, session_id:%lu.", sessionId_); | 664 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Build graph failed, session_id:%lu.", sessionId_); |
| 584 | - | ||
| 585 | GELOGT(TRACE_INIT, "start to build graph, session_id: %lu, graph_id: %u, input size %zu", | 665 | GELOGT(TRACE_INIT, "start to build graph, session_id: %lu, graph_id: %u, input size %zu", |
| 586 | sessionId_, graph_id, inputs.size()); | 666 | sessionId_, graph_id, inputs.size()); |
| 587 | 667 | ||
| 588 | - const Status ret = inner_session->BuildGraph(graph_id, inputs); | 668 | + // Check if dflow session is enabled |
| 669 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 670 | + Status ret; | ||
| 671 | + if (dflow_session != nullptr) { | ||
| 672 | + inner_session->UpdateGlobalSessionContext(); | ||
| 673 | + GELOGI("Build graph in dflow session."); | ||
| 674 | + std::vector<ge::GeTensor> ge_inputs; | ||
| 675 | + for (auto const &input : inputs) { | ||
| 676 | + std::vector<int64_t> input_dims; | ||
| 677 | + (void)std::transform(input.dims.begin(), input.dims.end(), std::back_inserter(input_dims), | ||
| 678 | + [](int64_t x) -> int64_t { return x; }); | ||
| 679 | + GeShape input_shape(input_dims); | ||
| 680 | + GeTensorDesc input_tensor_desc; | ||
| 681 | + input_tensor_desc.SetShape(input_shape); | ||
| 682 | + input_tensor_desc.SetDataType(static_cast<ge::DataType>(input.data_type)); | ||
| 683 | + ge_inputs.emplace_back(input_tensor_desc); | ||
| 684 | + } | ||
| 685 | + ret = dflow_session->BuildGraph(graph_id, ge_inputs); | ||
| 686 | + } else { | ||
| 687 | + const auto check_ret = CheckCompiledFlag(inner_session, graph_id, false); | ||
| 688 | + GE_CHK_BOOL_RET_STATUS(check_ret == SUCCESS, check_ret, | ||
| 689 | + "Build graph failed, incompatible with API CompileGraph, graph_id=%u", graph_id); | ||
| 690 | + ret = inner_session->BuildGraph(graph_id, inputs); | ||
| 691 | + } | ||
| 589 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Build graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, | 692 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Build graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, |
| 590 | sessionId_, graph_id); | 693 | sessionId_, graph_id); |
| 591 | return SUCCESS; | 694 | return SUCCESS; |
| @@ -601,16 +704,14 @@ Status Session::LoadGraph(const uint32_t graph_id, const std::map<AscendString, | |||
| 601 | return FAILED; | 704 | return FAILED; |
| 602 | } | 705 | } |
| 603 | 706 | ||
| 604 | - Status ret = FAILED; | 707 | + const auto inner_session = g_session_manager->GetSession(sessionId_); |
| 605 | - const UserGraphsManagerPtr user_graphs_manager = g_session_manager->GetUserGraphsManager(sessionId_); | 708 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Load graph failed, session_id:%lu.", sessionId_); |
| 606 | - GE_CHK_BOOL_RET_STATUS(user_graphs_manager != nullptr, FAILED, "Load graph failed, session_id:%lu.", sessionId_); | 709 | + const auto check_ret = CheckCompiledFlag(inner_session, graph_id, true); |
| 607 | - auto is_enable_slice_schedule = EnableSliceSchedule(); | 710 | + GE_ASSERT_SUCCESS(check_ret, "Load graph failed, graph needs to be compiled first, graph_id=%u", graph_id); |
| 608 | - ret = user_graphs_manager->LoadGraph(graph_id, options, stream); | ||
| 609 | - | ||
| 610 | - GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, | ||
| 611 | - "Load graph failed, error code:%u, session_id:%lu, graph_id:%u, is_enable_slice_schedule:%d", | ||
| 612 | - ret, sessionId_, graph_id, is_enable_slice_schedule); | ||
| 613 | 711 | ||
| 712 | + const auto ret = inner_session->LoadGraph(graph_id, options, stream); | ||
| 713 | + GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Load graph failed, error code:%u, session_id:%lu, graph_id:%u", | ||
| 714 | + ret, sessionId_, graph_id); | ||
| 614 | return ret; | 715 | return ret; |
| 615 | } | 716 | } |
| 616 | 717 | ||
| @@ -626,14 +727,29 @@ Status Session::BuildGraph(uint32_t graph_id, const std::vector<ge::Tensor> &inp | |||
| 626 | GELOGT(TRACE_INIT, "start to build graph, session_id: %lu, graph_id: %u, input size %zu", | 727 | GELOGT(TRACE_INIT, "start to build graph, session_id: %lu, graph_id: %u, input size %zu", |
| 627 | sessionId_, graph_id, inputs.size()); | 728 | sessionId_, graph_id, inputs.size()); |
| 628 | 729 | ||
| 629 | - Status ret = FAILED; | 730 | + auto inner_session = g_session_manager->GetSession(sessionId_); |
| 630 | - auto isEnableSliceSchedule = EnableSliceSchedule(); | 731 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Build graph failed, session_id:%lu.", sessionId_); |
| 631 | - const UserHybridGraphManagerPtr user_hybrid_graph_manager = g_session_manager->GetUserHybridGraphManager(sessionId_); | 732 | + |
| 632 | - GE_CHK_BOOL_RET_STATUS(user_hybrid_graph_manager != nullptr, FAILED, "Build graph failed, session_id:%lu.", sessionId_); | 733 | + // Check if dflow session is enabled |
| 633 | - ret = user_hybrid_graph_manager->BuildGraph(graph_id, inputs); | 734 | + const auto dflow_session = inner_session->GetDFlowSession(); |
| 735 | + Status ret; | ||
| 736 | + if (dflow_session != nullptr) { | ||
| 737 | + inner_session->UpdateGlobalSessionContext(); | ||
| 738 | + GELOGI("Build graph in dflow session."); | ||
| 739 | + std::vector<ge::GeTensor> ge_inputs; | ||
| 740 | + for (const auto &input : inputs) { | ||
| 741 | + ge_inputs.emplace_back(TensorAdapter::AsGeTensor(input)); | ||
| 742 | + } | ||
| 743 | + ret = dflow_session->BuildGraph(graph_id, ge_inputs); | ||
| 744 | + } else { | ||
| 745 | + const auto check_ret = CheckCompiledFlag(inner_session, graph_id, false); | ||
| 746 | + GE_CHK_BOOL_RET_STATUS(check_ret == SUCCESS, check_ret, | ||
| 747 | + "Build graph failed, check compiled flag failed, graph_id=%u", graph_id); | ||
| 748 | + ret = inner_session->BuildGraph(graph_id, inputs); | ||
| 749 | + } | ||
| 634 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Build graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, | 750 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Build graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, |
| 635 | sessionId_, graph_id); | 751 | sessionId_, graph_id); |
| 636 | - GELOGD("BuildGraph finished in Session, graph_id: %u, isEnableSliceSchedule:%u", graph_id, isEnableSliceSchedule); | 752 | + GELOGD("BuildGraph finished in Session, graph_id: %u", graph_id); |
| 637 | return SUCCESS; | 753 | return SUCCESS; |
| 638 | } | 754 | } |
| 639 | 755 | ||
| @@ -653,18 +769,36 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<ge::Tensor> & | |||
| 653 | " graph_id: %u", graph_id); | 769 | " graph_id: %u", graph_id); |
| 654 | 770 | ||
| 655 | const uint64_t session_id = sessionId_; | 771 | const uint64_t session_id = sessionId_; |
| 656 | - auto callback_wrapper = [session_id, graph_id, callback](Status ret, std::vector<ge::Tensor> &outputs) -> void { | 772 | + auto callback_wrapper = [session_id, graph_id, callback](Status ret, std::vector<gert::Tensor> &outputs) -> void { |
| 657 | RunGraphAsyncCallback(ret, session_id, graph_id, outputs, callback); | 773 | RunGraphAsyncCallback(ret, session_id, graph_id, outputs, callback); |
| 658 | }; | 774 | }; |
| 659 | 775 | ||
| 660 | Status ret = FAILED; | 776 | Status ret = FAILED; |
| 661 | - auto isEnableSliceSchedule = EnableSliceSchedule(); | 777 | + auto inner_session = g_session_manager->GetSession(sessionId_); |
| 662 | - const UserHybridGraphManagerPtr user_hybrid_graph_manager = g_session_manager->GetUserHybridGraphManager(sessionId_); | 778 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Run graph async failed, session_id:%lu.", sessionId_); |
| 663 | - GE_CHK_BOOL_RET_STATUS(user_hybrid_graph_manager != nullptr, FAILED, "Run graph async failed, session_id:%lu.", sessionId_); | 779 | + |
| 664 | - ret = user_hybrid_graph_manager->RunGraphAsync(graph_id, inputs, callback_wrapper); | 780 | + // Check if dflow session is enabled (not supported for RunGraphAsync) |
| 781 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 782 | + GE_CHK_BOOL_RET_STATUS(dflow_session == nullptr, UNSUPPORTED, | ||
| 783 | + "Dflow session does not support current function, pls check."); | ||
| 784 | + | ||
| 785 | + const auto check_ret = CheckCompiledFlag(inner_session, graph_id, false); | ||
| 786 | + if (check_ret != SUCCESS) { | ||
| 787 | + if (callback != nullptr) { | ||
| 788 | + std::vector<ge::Tensor> outputs; | ||
| 789 | + callback(check_ret, outputs); | ||
| 790 | + } | ||
| 791 | + GELOGE(check_ret, "Run graph async failed, incompatible with API CompileGraph, graph_id=%u", graph_id); | ||
| 792 | + REPORT_INNER_ERR_MSG("E19999", "Run graph async failed, incompatible with API CompileGraph, graph_id=%u", graph_id); | ||
| 793 | + return check_ret; | ||
| 794 | + } | ||
| 795 | + | ||
| 796 | + std::vector<gert::Tensor> tensors_view; | ||
| 797 | + GE_ASSERT_SUCCESS(TensorTransUtils::AsTensorsView(inputs, tensors_view)); | ||
| 798 | + ret = inner_session->RunGraphAsync(graph_id, std::move(tensors_view), callback_wrapper); | ||
| 665 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Run graph async failed, error code:%u, session_id:%lu, graph_id:%u.", | 799 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Run graph async failed, error code:%u, session_id:%lu, graph_id:%u.", |
| 666 | ret, sessionId_, graph_id); | 800 | ret, sessionId_, graph_id); |
| 667 | - GELOGD("RunGraphAsync finished in Session, graph_id: %u, isEnableSliceSchedule:%u", graph_id, isEnableSliceSchedule); | 801 | + GELOGD("RunGraphAsync finished in Session, graph_id: %u", graph_id); |
| 668 | return SUCCESS; | 802 | return SUCCESS; |
| 669 | } | 803 | } |
| 670 | 804 | ||
| @@ -719,10 +853,9 @@ bool Session::IsGraphNeedRebuild(uint32_t graph_id) { | |||
| 719 | REPORT_INNER_ERR_MSG("E19999", "Creating session failed because lack GEInitialize call before."); | 853 | REPORT_INNER_ERR_MSG("E19999", "Creating session failed because lack GEInitialize call before."); |
| 720 | return false; | 854 | return false; |
| 721 | } | 855 | } |
| 722 | - | 856 | + auto inner_session = g_session_manager->GetSession(sessionId_); |
| 723 | - const UserHybridGraphManagerPtr user_hybrid_graph_manager = g_session_manager->GetUserHybridGraphManager(sessionId_); | 857 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Add graph failed, session_id:%lu.", sessionId_); |
| 724 | - GE_CHK_BOOL_RET_STATUS(user_hybrid_graph_manager != nullptr, FAILED, "Add graph failed, session_id:%lu.", sessionId_); | 858 | + return inner_session->IsGraphNeedRebuild(graph_id); |
| 725 | - return user_hybrid_graph_manager->IsGraphNeedRebuild(graph_id); | ||
| 726 | } | 859 | } |
| 727 | 860 | ||
| 728 | uint64_t Session::GetSessionId() const { | 861 | uint64_t Session::GetSessionId() const { |
| @@ -745,9 +878,10 @@ Status Session::FeedDataFlowGraph(uint32_t graph_id, const std::vector<uint32_t> | |||
| 745 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); | 878 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); |
| 746 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); | 879 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 747 | 880 | ||
| 748 | - | ||
| 749 | GELOGI("Feed data flow graph, graph_id: %u, timeout: %d ms", graph_id, timeout); | 881 | GELOGI("Feed data flow graph, graph_id: %u, timeout: %d ms", graph_id, timeout); |
| 750 | - const Status ret = inner_session->FeedDataFlowGraph(graph_id, indexes, inputs, info, timeout); | 882 | + const auto dflow_session = inner_session->GetDFlowSession(); |
| 883 | + GE_CHECK_NOTNULL(dflow_session, "dflow session is nullptr"); | ||
| 884 | + const Status ret = dflow_session->FeedDataFlowGraph(graph_id, indexes, inputs, info, timeout); | ||
| 751 | if (ret != SUCCESS && ret != ACL_ERROR_GE_REDEPLOYING && ret != ACL_ERROR_GE_SUBHEALTHY) { | 885 | if (ret != SUCCESS && ret != ACL_ERROR_GE_REDEPLOYING && ret != ACL_ERROR_GE_SUBHEALTHY) { |
| 752 | GELOGE(ret, "[Feed][Data]Failed, error code:%u, session_id:%lu, graph_id:%u.", ret, sessionId_, graph_id); | 886 | GELOGE(ret, "[Feed][Data]Failed, error code:%u, session_id:%lu, graph_id:%u.", ret, sessionId_, graph_id); |
| 753 | REPORT_INNER_ERR_MSG("E19999", "Feed data flow graph failed , error code:%u, session_id:%lu, graph_id:%u", ret, | 887 | REPORT_INNER_ERR_MSG("E19999", "Feed data flow graph failed , error code:%u, session_id:%lu, graph_id:%u", ret, |
| @@ -769,9 +903,10 @@ Status Session::FeedDataFlowGraph(uint32_t graph_id, const std::vector<uint32_t> | |||
| 769 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); | 903 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); |
| 770 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); | 904 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 771 | 905 | ||
| 772 | - | ||
| 773 | GELOGI("Feed flow msg, graph_id: %u, timeout: %d ms", graph_id, timeout); | 906 | GELOGI("Feed flow msg, graph_id: %u, timeout: %d ms", graph_id, timeout); |
| 774 | - const Status ret = inner_session->FeedDataFlowGraph(graph_id, indexes, inputs, timeout); | 907 | + const auto dflow_session = inner_session->GetDFlowSession(); |
| 908 | + GE_CHECK_NOTNULL(dflow_session, "dflow session is nullptr"); | ||
| 909 | + const Status ret = dflow_session->FeedDataFlowGraph(graph_id, indexes, inputs, timeout); | ||
| 775 | const auto status = ret > kExternalErrorCodeMaxValue ? FAILED : ret; | 910 | const auto status = ret > kExternalErrorCodeMaxValue ? FAILED : ret; |
| 776 | GE_CHK_BOOL_RET_STATUS((ret == SUCCESS || ret == ACL_ERROR_GE_REDEPLOYING || ret == ACL_ERROR_GE_SUBHEALTHY), | 911 | GE_CHK_BOOL_RET_STATUS((ret == SUCCESS || ret == ACL_ERROR_GE_REDEPLOYING || ret == ACL_ERROR_GE_SUBHEALTHY), |
| 777 | status, "[Feed][FlowMsg]Failed, error code:%u, session_id:%lu, graph_id:%u.", | 912 | status, "[Feed][FlowMsg]Failed, error code:%u, session_id:%lu, graph_id:%u.", |
| @@ -790,9 +925,10 @@ Status Session::FeedRawData(uint32_t graph_id, const std::vector<RawData> &raw_d | |||
| 790 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); | 925 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); |
| 791 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); | 926 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 792 | 927 | ||
| 793 | - | ||
| 794 | GELOGI("Feed raw data to data flow graph, graph_id: %u, timeout: %d ms", graph_id, timeout); | 928 | GELOGI("Feed raw data to data flow graph, graph_id: %u, timeout: %d ms", graph_id, timeout); |
| 795 | - const Status ret = inner_session->FeedRawData(graph_id, raw_data_list, index, info, timeout); | 929 | + const auto dflow_session = inner_session->GetDFlowSession(); |
| 930 | + GE_CHECK_NOTNULL(dflow_session, "dflow session is nullptr"); | ||
| 931 | + const Status ret = dflow_session->FeedRawData(graph_id, raw_data_list, index, info, timeout); | ||
| 796 | if (ret != SUCCESS && ret != ACL_ERROR_GE_REDEPLOYING && ret != ACL_ERROR_GE_SUBHEALTHY) { | 932 | if (ret != SUCCESS && ret != ACL_ERROR_GE_REDEPLOYING && ret != ACL_ERROR_GE_SUBHEALTHY) { |
| 797 | GELOGE(ret, "[Feed][Data]Failed, error code:%u, session_id:%lu, graph_id:%u.", ret, sessionId_, graph_id); | 933 | GELOGE(ret, "[Feed][Data]Failed, error code:%u, session_id:%lu, graph_id:%u.", ret, sessionId_, graph_id); |
| 798 | REPORT_INNER_ERR_MSG("E19999", "Feed data flow graph failed , error code:%u, session_id:%lu, graph_id:%u", ret, | 934 | REPORT_INNER_ERR_MSG("E19999", "Feed data flow graph failed , error code:%u, session_id:%lu, graph_id:%u", ret, |
| @@ -818,9 +954,10 @@ Status Session::FetchDataFlowGraph(uint32_t graph_id, const std::vector<uint32_t | |||
| 818 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); | 954 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); |
| 819 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); | 955 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 820 | 956 | ||
| 821 | - | ||
| 822 | GELOGI("Fetch data flow graph, graph_id: %u, timeout: %d ms", graph_id, timeout); | 957 | GELOGI("Fetch data flow graph, graph_id: %u, timeout: %d ms", graph_id, timeout); |
| 823 | - Status ret = inner_session->FetchDataFlowGraph(graph_id, indexes, outputs, info, timeout); | 958 | + const auto dflow_session = inner_session->GetDFlowSession(); |
| 959 | + GE_CHECK_NOTNULL(dflow_session, "dflow session is nullptr"); | ||
| 960 | + Status ret = dflow_session->FetchDataFlowGraph(graph_id, indexes, outputs, info, timeout); | ||
| 824 | const bool need_convert_error_code = ((ret == RT_ERROR_TO_GE_STATUS(ACL_ERROR_RT_QUEUE_EMPTY)) && timeout != 0); | 961 | const bool need_convert_error_code = ((ret == RT_ERROR_TO_GE_STATUS(ACL_ERROR_RT_QUEUE_EMPTY)) && timeout != 0); |
| 825 | ret = need_convert_error_code ? ACL_ERROR_GE_MODEL_EXECUTE_TIMEOUT : ret; | 962 | ret = need_convert_error_code ? ACL_ERROR_GE_MODEL_EXECUTE_TIMEOUT : ret; |
| 826 | if (ret != SUCCESS && ret != ACL_ERROR_GE_REDEPLOYING && ret != ACL_ERROR_GE_SUBHEALTHY) { | 963 | if (ret != SUCCESS && ret != ACL_ERROR_GE_REDEPLOYING && ret != ACL_ERROR_GE_SUBHEALTHY) { |
| @@ -844,9 +981,10 @@ Status Session::FetchDataFlowGraph(uint32_t graph_id, const std::vector<uint32_t | |||
| 844 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); | 981 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); |
| 845 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); | 982 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 846 | 983 | ||
| 847 | - | ||
| 848 | GELOGI("Fetch flow msg, graph_id: %u, timeout: %d ms", graph_id, timeout); | 984 | GELOGI("Fetch flow msg, graph_id: %u, timeout: %d ms", graph_id, timeout); |
| 849 | - Status ret = inner_session->FetchDataFlowGraph(graph_id, indexes, outputs, timeout); | 985 | + const auto dflow_session = inner_session->GetDFlowSession(); |
| 986 | + GE_CHECK_NOTNULL(dflow_session, "dflow session is nullptr"); | ||
| 987 | + Status ret = dflow_session->FetchDataFlowGraph(graph_id, indexes, outputs, timeout); | ||
| 850 | const bool need_convert_error_code = ((ret == RT_ERROR_TO_GE_STATUS(ACL_ERROR_RT_QUEUE_EMPTY)) && timeout != 0); | 988 | const bool need_convert_error_code = ((ret == RT_ERROR_TO_GE_STATUS(ACL_ERROR_RT_QUEUE_EMPTY)) && timeout != 0); |
| 851 | ret = need_convert_error_code ? ACL_ERROR_GE_MODEL_EXECUTE_TIMEOUT : ret; | 989 | ret = need_convert_error_code ? ACL_ERROR_GE_MODEL_EXECUTE_TIMEOUT : ret; |
| 852 | const auto status = ret > kExternalErrorCodeMaxValue ? FAILED : ret; | 990 | const auto status = ret > kExternalErrorCodeMaxValue ? FAILED : ret; |
| @@ -860,32 +998,39 @@ Status Session::CompileGraph(uint32_t graph_id) { | |||
| 860 | GE_ASSERT(IsGEInitialize(), "[Construct][Session]Failed because lack GEInitialize call before."); | 998 | GE_ASSERT(IsGEInitialize(), "[Construct][Session]Failed because lack GEInitialize call before."); |
| 861 | GELOGT(TRACE_INIT, "Start to compile graph, graph_id: %u", graph_id); | 999 | GELOGT(TRACE_INIT, "Start to compile graph, graph_id: %u", graph_id); |
| 862 | 1000 | ||
| 863 | - Status ret = FAILED; | 1001 | + const auto inner_session = g_session_manager->GetSession(sessionId_); |
| 864 | - auto is_enable_slice_schedule = EnableSliceSchedule(); | 1002 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 865 | - const UserGraphsManagerPtr user_graphs_manager = g_session_manager->GetUserGraphsManager(sessionId_); | ||
| 866 | - GE_ASSERT_NOTNULL(user_graphs_manager, "[Get][User Graph]Failed, session_id:%lu.", sessionId_); | ||
| 867 | - ret = user_graphs_manager->CompileGraph(graph_id); | ||
| 868 | 1003 | ||
| 869 | - GE_ASSERT_SUCCESS( | 1004 | + // Check if dflow session is enabled |
| 870 | - ret, | 1005 | + const auto dflow_session = inner_session->GetDFlowSession(); |
| 871 | - "[Compile][Graph]Compile graph failed, error code:%u, session_id:%lu, graph_id:%u, is_enable_slice_schedule:%d", | 1006 | + Status ret; |
| 872 | - ret, sessionId_, graph_id, is_enable_slice_schedule); | 1007 | + if (dflow_session != nullptr) { |
| 1008 | + inner_session->UpdateGlobalSessionContext(); | ||
| 1009 | + ret = dflow_session->CompileGraph(graph_id, {}); | ||
| 1010 | + GE_ASSERT_SUCCESS(ret, "[Compile][Graph]Compile graph failed, error code:%u, session_id:%lu, graph_id:%u", | ||
| 1011 | + ret, sessionId_, graph_id); | ||
| 1012 | + } else { | ||
| 1013 | + ret = inner_session->CompileGraph(graph_id, {}); | ||
| 1014 | + GE_ASSERT_SUCCESS(ret, "[Compile][Graph]Compile graph failed, error code:%u, session_id:%lu, graph_id:%u", | ||
| 1015 | + ret, sessionId_, graph_id); | ||
| 1016 | + GE_ASSERT_SUCCESS(inner_session->SetCompiledFlag(graph_id, true), | ||
| 1017 | + "[Compile][Graph]Compile graph failed, set compiled flag failed, session_id:%lu, graph_id:%u", | ||
| 1018 | + sessionId_, graph_id); | ||
| 1019 | + } | ||
| 873 | GELOGT(TRACE_STOP, "Compile graph success, graph_id: %u.", graph_id); | 1020 | GELOGT(TRACE_STOP, "Compile graph success, graph_id: %u.", graph_id); |
| 1021 | + GELOGI("Compile graph success, graph_id: %u.", graph_id); | ||
| 874 | return SUCCESS; | 1022 | return SUCCESS; |
| 875 | } | 1023 | } |
| 876 | 1024 | ||
| 877 | CompiledGraphSummaryPtr Session::GetCompiledGraphSummary(uint32_t graph_id) { | 1025 | CompiledGraphSummaryPtr Session::GetCompiledGraphSummary(uint32_t graph_id) { |
| 878 | GE_ASSERT(IsGEInitialize(), "[Construct][Session]Failed because lack GEInitialize call before."); | 1026 | GE_ASSERT(IsGEInitialize(), "[Construct][Session]Failed because lack GEInitialize call before."); |
| 879 | CompiledGraphSummaryPtr summary = nullptr; | 1027 | CompiledGraphSummaryPtr summary = nullptr; |
| 880 | - Status ret = FAILED; | 1028 | + const auto inner_session = g_session_manager->GetSession(sessionId_); |
| 881 | - | 1029 | + GE_ASSERT_NOTNULL(inner_session, "[Get][User Graph]Failed, session_id:%lu.", sessionId_); |
| 882 | - const UserGraphsManagerPtr user_graphs_manager = g_session_manager->GetUserGraphsManager(sessionId_); | 1030 | + const auto check_ret = CheckCompiledFlag(inner_session, graph_id, true); |
| 883 | - GE_ASSERT_NOTNULL(user_graphs_manager, "[Get][User Graph]Failed, session_id:%lu.", sessionId_); | 1031 | + GE_ASSERT_SUCCESS(check_ret, "[Get][Summary]Failed, graph needs to be compiled first, graph_id=%u", graph_id); |
| 884 | - auto is_enable_slice_schedule = EnableSliceSchedule(); | 1032 | + auto ret = inner_session->GetCompiledGraphSummary(graph_id, summary); |
| 885 | - ret = user_graphs_manager->GetCompiledGraphSummary(graph_id, summary); | 1033 | + GE_ASSERT_SUCCESS(ret, "[Get][Summary]Failed, error code:%u, session_id:%lu, graph_id:%u", ret, sessionId_, graph_id); |
| 886 | - GE_ASSERT_SUCCESS(ret, | ||
| 887 | - "[Get][Summary]Failed, error code:%u, session_id:%lu, graph_id:%u, is_enable_slice_schedule:%d", | ||
| 888 | - ret, sessionId_, graph_id, is_enable_slice_schedule); | ||
| 889 | return summary; | 1034 | return summary; |
| 890 | } | 1035 | } |
| 891 | 1036 | ||
| @@ -900,8 +1045,16 @@ Status Session::SetGraphConstMemoryBase(uint32_t graph_id, const void *const mem | |||
| 900 | } | 1045 | } |
| 901 | 1046 | ||
| 902 | const auto inner_session = g_session_manager->GetSession(sessionId_); | 1047 | const auto inner_session = g_session_manager->GetSession(sessionId_); |
| 903 | - GE_ASSERT_NOTNULL(inner_session, "[Get][Session]Failed, session_id:%lu.", sessionId_); | 1048 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 904 | 1049 | ||
| 1050 | + // Check if dflow session is enabled (not supported for SetGraphConstMemoryBase) | ||
| 1051 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 1052 | + GE_CHK_BOOL_RET_STATUS(dflow_session == nullptr, UNSUPPORTED, | ||
| 1053 | + "Dflow session does not support current function, pls check."); | ||
| 1054 | + | ||
| 1055 | + const auto check_ret = CheckCompiledFlag(inner_session, graph_id, true); | ||
| 1056 | + GE_CHK_BOOL_RET_STATUS(check_ret == SUCCESS, check_ret, | ||
| 1057 | + "[Set][Memory]Failed, graph needs to be compiled first, graph_id=%u", graph_id); | ||
| 905 | 1058 | ||
| 906 | const auto ret = inner_session->SetGraphConstMemoryBase(graph_id, memory, size); | 1059 | const auto ret = inner_session->SetGraphConstMemoryBase(graph_id, memory, size); |
| 907 | GE_ASSERT_SUCCESS(ret, "[Set][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", | 1060 | GE_ASSERT_SUCCESS(ret, "[Set][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", |
| @@ -919,8 +1072,16 @@ Status Session::UpdateGraphFeatureMemoryBase(uint32_t graph_id, const void *cons | |||
| 919 | return UNSUPPORTED; | 1072 | return UNSUPPORTED; |
| 920 | } | 1073 | } |
| 921 | const auto inner_session = g_session_manager->GetSession(sessionId_); | 1074 | const auto inner_session = g_session_manager->GetSession(sessionId_); |
| 922 | - GE_ASSERT_NOTNULL(inner_session, "[Get][Session]Failed, session_id:%lu.", sessionId_); | 1075 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 923 | 1076 | ||
| 1077 | + // Check if dflow session is enabled (not supported for UpdateGraphFeatureMemoryBase) | ||
| 1078 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 1079 | + GE_CHK_BOOL_RET_STATUS(dflow_session == nullptr, UNSUPPORTED, | ||
| 1080 | + "Dflow session does not support current function, pls check."); | ||
| 1081 | + | ||
| 1082 | + const auto check_ret = CheckCompiledFlag(inner_session, graph_id, true); | ||
| 1083 | + GE_CHK_BOOL_RET_STATUS(check_ret == SUCCESS, check_ret, | ||
| 1084 | + "[Update][Memory]Failed, graph needs to be compiled first, graph_id=%u", graph_id); | ||
| 924 | 1085 | ||
| 925 | const auto ret = inner_session->UpdateGraphFeatureMemoryBase(graph_id, memory, size); | 1086 | const auto ret = inner_session->UpdateGraphFeatureMemoryBase(graph_id, memory, size); |
| 926 | GE_ASSERT_SUCCESS(ret, "[Update][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", | 1087 | GE_ASSERT_SUCCESS(ret, "[Update][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", |
| @@ -943,8 +1104,16 @@ Status Session::SetGraphFixedFeatureMemoryBaseWithType(uint32_t graph_id, Memory | |||
| 943 | return UNSUPPORTED; | 1104 | return UNSUPPORTED; |
| 944 | } | 1105 | } |
| 945 | const auto inner_session = g_session_manager->GetSession(sessionId_); | 1106 | const auto inner_session = g_session_manager->GetSession(sessionId_); |
| 946 | - GE_ASSERT_NOTNULL(inner_session, "[Get][Session]Failed, session_id:%lu.", sessionId_); | 1107 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 947 | 1108 | ||
| 1109 | + // Check if dflow session is enabled (not supported for SetGraphFixedFeatureMemoryBaseWithType) | ||
| 1110 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 1111 | + GE_CHK_BOOL_RET_STATUS(dflow_session == nullptr, UNSUPPORTED, | ||
| 1112 | + "Dflow session does not support current function, pls check."); | ||
| 1113 | + | ||
| 1114 | + const auto check_ret = CheckCompiledFlag(inner_session, graph_id, true); | ||
| 1115 | + GE_CHK_BOOL_RET_STATUS(check_ret == SUCCESS, check_ret, | ||
| 1116 | + "[Set][Memory]Failed, graph needs to be compiled first, graph_id=%u", graph_id); | ||
| 948 | 1117 | ||
| 949 | const auto ret = inner_session->SetGraphFixedFeatureMemoryBase(graph_id, type, memory, size); | 1118 | const auto ret = inner_session->SetGraphFixedFeatureMemoryBase(graph_id, type, memory, size); |
| 950 | GE_ASSERT_SUCCESS(ret, "[Set][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, type:%d," | 1119 | GE_ASSERT_SUCCESS(ret, "[Set][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, type:%d," |
| @@ -962,8 +1131,16 @@ Status Session::UpdateGraphRefreshableFeatureMemoryBase(uint32_t graph_id, const | |||
| 962 | return UNSUPPORTED; | 1131 | return UNSUPPORTED; |
| 963 | } | 1132 | } |
| 964 | const auto inner_session = g_session_manager->GetSession(sessionId_); | 1133 | const auto inner_session = g_session_manager->GetSession(sessionId_); |
| 965 | - GE_ASSERT_NOTNULL(inner_session, "[Get][Session]Failed, session_id:%lu.", sessionId_); | 1134 | + GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][Session] failed, session_id:%lu.", sessionId_); |
| 966 | 1135 | ||
| 1136 | + // Check if dflow session is enabled (not supported for UpdateGraphRefreshableFeatureMemoryBase) | ||
| 1137 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 1138 | + GE_CHK_BOOL_RET_STATUS(dflow_session == nullptr, UNSUPPORTED, | ||
| 1139 | + "Dflow session does not support current function, pls check."); | ||
| 1140 | + | ||
| 1141 | + const auto check_ret = CheckCompiledFlag(inner_session, graph_id, true); | ||
| 1142 | + GE_CHK_BOOL_RET_STATUS(check_ret == SUCCESS, check_ret, | ||
| 1143 | + "[Update][Memory]Failed, graph needs to be compiled first, graph_id=%u", graph_id); | ||
| 967 | 1144 | ||
| 968 | const auto ret = inner_session->UpdateGraphRefreshableFeatureMemoryBase(graph_id, memory, size); | 1145 | const auto ret = inner_session->UpdateGraphRefreshableFeatureMemoryBase(graph_id, memory, size); |
| 969 | GE_ASSERT_SUCCESS(ret, "[Update][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", | 1146 | GE_ASSERT_SUCCESS(ret, "[Update][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", |
| @@ -1011,6 +1188,12 @@ Status Session::PaRemapped(const uint64_t va, const uint64_t new_pa, const uint6 | |||
| 1011 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); | 1188 | const SessionPtr inner_session = g_session_manager->GetSession(sessionId_); |
| 1012 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, INTERNAL_ERROR, "[Get][Session] failed, session_id:%lu.", | 1189 | GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, INTERNAL_ERROR, "[Get][Session] failed, session_id:%lu.", |
| 1013 | sessionId_); | 1190 | sessionId_); |
| 1191 | + | ||
| 1192 | + // Check if dflow session is enabled (not supported for PaRemapped) | ||
| 1193 | + const auto dflow_session = inner_session->GetDFlowSession(); | ||
| 1194 | + GE_CHK_BOOL_RET_STATUS(dflow_session == nullptr, UNSUPPORTED, | ||
| 1195 | + "Dflow session does not support current function, pls check."); | ||
| 1196 | + | ||
| 1014 | return inner_session->PaRemapped(va, new_pa, len); | 1197 | return inner_session->PaRemapped(va, new_pa, len); |
| 1015 | } | 1198 | } |
| 1016 | } // namespace ge | 1199 | } // namespace ge |
| @@ -43,8 +43,8 @@ | |||
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | -#include "session_v2/ge_session_manager.h" | 46 | +#include "session/session_manager.h" |
| 47 | -#include "session_v2/ge_session_impl.h" | 47 | +#include "session/ge_session_impl.h" |
| 48 | 48 | ||
| 49 | 49 | ||
| 50 | 50 | ||
| @@ -106,11 +106,6 @@ void ShutDownProfiling() { | |||
| 106 | 106 | ||
| 107 | static std::atomic_bool g_ge_initialized{false}; | 107 | static std::atomic_bool g_ge_initialized{false}; |
| 108 | static std::mutex g_ge_release_mutex; // GEFinalize and ~GeSession use | 108 | static std::mutex g_ge_release_mutex; // GEFinalize and ~GeSession use |
| 109 | -static std::shared_ptr<ge::GeSessionManager> g_ge_session_manager; | ||
| 110 | - | ||
| 111 | -ge::GeSessionManager *GetGeSessionManager() { | ||
| 112 | - return g_ge_session_manager.get(); | ||
| 113 | -} | ||
| 114 | 109 | ||
| 115 | namespace ge { | 110 | namespace ge { |
| 116 | namespace { | 111 | namespace { |
| @@ -130,18 +125,19 @@ void ConstructSession(const std::map<std::string, std::string> &options, Session | |||
| 130 | if (CheckAllowParallelCompile(options) != SUCCESS) { | 125 | if (CheckAllowParallelCompile(options) != SUCCESS) { |
| 131 | return; | 126 | return; |
| 132 | } | 127 | } |
| 133 | - uint64_t tmp_session_id = 0UL; | 128 | +} |
| 134 | - const Status ret = g_ge_session_manager->CreateSession(options, tmp_session_id); | 129 | + |
| 135 | - // failed guarder, should call GE_DISMISS_GUARD if success | 130 | +Status CheckRunGraphMode(const RunGraphMode &cur_mode, uint32_t graph_id, const RunGraphMode &expect_mode) { |
| 136 | - GE_DISMISSABLE_GUARD(create_failed, ([tmp_session_id]() { g_ge_session_manager->DestroySession(tmp_session_id); })); | 131 | + if ((cur_mode != RunGraphMode::kRunGraphModeEnd) && (cur_mode != expect_mode)) { |
| 137 | - if (ret != SUCCESS) { | 132 | + GELOGE(UNSUPPORTED, "Failed to execute %s for graph[%u] because %s was already called." |
| 138 | - GELOGE(ret, "Construct session failed, error code:%u.", ret); | 133 | + " These execution methods are mutually exclusive and cannot be mixed.", |
| 139 | - REPORT_INNER_ERR_MSG("E19999", "Construct session failed, error code:%u.", ret); | 134 | + GetRunGraphModeStr(expect_mode), graph_id, GetRunGraphModeStr(cur_mode)); |
| 140 | - return; | 135 | + REPORT_INNER_ERR_MSG("E19999", "Failed to execute %s for graph[%u] because %s was already called." |
| 136 | + " These execution methods are mutually exclusive and cannot be mixed.", | ||
| 137 | + GetRunGraphModeStr(expect_mode), graph_id, GetRunGraphModeStr(cur_mode)); | ||
| 138 | + return UNSUPPORTED; | ||
| 141 | } | 139 | } |
| 142 | - session_id = tmp_session_id; | 140 | + return SUCCESS; |
| 143 | - GE_DISMISS_GUARD(create_failed); | ||
| 144 | - GELOGT(TRACE_STOP, "GeSession construct finished, session id is %lu", session_id); | ||
| 145 | } | 141 | } |
| 146 | } // namespace | 142 | } // namespace |
| 147 | 143 | ||
| @@ -181,7 +177,7 @@ static Status CheckOptionsValid(const std::map<std::string, std::string> &option | |||
| 181 | return SUCCESS; | 177 | return SUCCESS; |
| 182 | } | 178 | } |
| 183 | 179 | ||
| 184 | -Status InitializeExecutionRuntime(const std::map<std::string, std::string> &options) { | 180 | +static Status InitializeExecutionRuntime(const std::map<std::string, std::string> &options) { |
| 185 | if (ExecutionRuntime::GetInstance() == nullptr) { | 181 | if (ExecutionRuntime::GetInstance() == nullptr) { |
| 186 | if (ExecutionRuntimeUtils::IsHeterogeneous()) { | 182 | if (ExecutionRuntimeUtils::IsHeterogeneous()) { |
| 187 | GE_CHK_STATUS_RET_NOLOG(ExecutionRuntime::InitHeterogeneousRuntime(options)); | 183 | GE_CHK_STATUS_RET_NOLOG(ExecutionRuntime::InitHeterogeneousRuntime(options)); |
| @@ -272,12 +268,6 @@ static Status GEInitializeImpl(const std::map<std::string, std::string> &options | |||
| 272 | // 8. init session manager | 268 | // 8. init session manager |
| 273 | GELOGI("GeSessionManager initial."); | 269 | GELOGI("GeSessionManager initial."); |
| 274 | GE_TIMESTAMP_START(GeSessionManagerInitialize); | 270 | GE_TIMESTAMP_START(GeSessionManagerInitialize); |
| 275 | - g_ge_session_manager = MakeShared<ge::GeSessionManager>(); | ||
| 276 | - if (g_ge_session_manager == nullptr) { | ||
| 277 | - GELOGE(GE_CLI_INIT_FAILED, "[Init][Create]GeSessionManager failed"); | ||
| 278 | - return FAILED; | ||
| 279 | - } | ||
| 280 | - ret = g_ge_session_manager->Initialize(); | ||
| 281 | GE_TIMESTAMP_EVENT_END(GeSessionManagerInitialize, "InnerInitialize::GeSessionManagerInitialize"); | 271 | GE_TIMESTAMP_EVENT_END(GeSessionManagerInitialize, "InnerInitialize::GeSessionManagerInitialize"); |
| 282 | if (ret != SUCCESS) { | 272 | if (ret != SUCCESS) { |
| 283 | GELOGE(ret, "[Init][GeSessionManager] GE session manager initial failed."); | 273 | GELOGE(ret, "[Init][GeSessionManager] GE session manager initial failed."); |
| @@ -313,7 +303,9 @@ Status GEInitializeV2(const std::map<AscendString, AscendString> &options) { | |||
| 313 | for (const auto &option_item : options) { | 303 | for (const auto &option_item : options) { |
| 314 | if (option_item.first.GetLength() == 0) { | 304 | if (option_item.first.GetLength() == 0) { |
| 315 | GELOGE(FAILED, "[Check][Param] GEInitialize failed, option key is empty."); | 305 | GELOGE(FAILED, "[Check][Param] GEInitialize failed, option key is empty."); |
| 316 | - REPORT_INNER_ERR_MSG("E19999", "Check parameter's options invalid, option key is empty."); | 306 | + REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 307 | + std::vector<const char *>({option_item.first.GetString(), | ||
| 308 | + option_item.second.GetString(), "parameter is empty"})); | ||
| 317 | return FAILED; | 309 | return FAILED; |
| 318 | } | 310 | } |
| 319 | const std::string &key = std::string(option_item.first.GetString(), option_item.first.GetLength()); | 311 | const std::string &key = std::string(option_item.first.GetString(), option_item.first.GetLength()); |
| @@ -349,9 +341,6 @@ Status GEFinalizeV2() { | |||
| 349 | GELOGT(TRACE_INIT, "GEFinalize start"); | 341 | GELOGT(TRACE_INIT, "GEFinalize start"); |
| 350 | 342 | ||
| 351 | GELOGI("GeSessionManager finalization."); | 343 | GELOGI("GeSessionManager finalization."); |
| 352 | - if (g_ge_session_manager != nullptr) { | ||
| 353 | - (void)g_ge_session_manager->Finalize(); // always success. | ||
| 354 | - } | ||
| 355 | ShutDownProfiling(); | 344 | ShutDownProfiling(); |
| 356 | 345 | ||
| 357 | (void)CustomPassHelper::Instance().Unload(); | 346 | (void)CustomPassHelper::Instance().Unload(); |
| @@ -399,26 +388,29 @@ ge::AscendString GEGetWarningMsgV3() { | |||
| 399 | return ge::AscendString(error_message::GetErrMgrWarningMessage().get()); | 388 | return ge::AscendString(error_message::GetErrMgrWarningMessage().get()); |
| 400 | } | 389 | } |
| 401 | 390 | ||
| 402 | -GeSession::GeSession(const std::map<AscendString, AscendString> &options) : impl_(std::make_shared<GeSession::Impl>()) { | 391 | +GeSession::GeSession(const std::map<AscendString, AscendString> &options) { |
| 403 | std::map<std::string, std::string> str_options; | 392 | std::map<std::string, std::string> str_options; |
| 404 | for (auto &option_item : options) { | 393 | for (auto &option_item : options) { |
| 405 | if (option_item.first.GetLength() == 0) { | 394 | if (option_item.first.GetLength() == 0) { |
| 406 | GELOGE(FAILED, "Construct session failed, option key is empty."); | 395 | GELOGE(FAILED, "Construct session failed, option key is empty."); |
| 407 | - REPORT_INNER_ERR_MSG("E19999", "Construct session failed, option key is empty."); | 396 | + REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 397 | + std::vector<const char *>({option_item.first.GetString(), | ||
| 398 | + option_item.second.GetString(), "parameter is empty"})); | ||
| 408 | return; | 399 | return; |
| 409 | } | 400 | } |
| 410 | const std::string &key = option_item.first.GetString(); | 401 | const std::string &key = option_item.first.GetString(); |
| 411 | const std::string &val = option_item.second.GetString(); | 402 | const std::string &val = option_item.second.GetString(); |
| 412 | str_options[key] = val; | 403 | str_options[key] = val; |
| 413 | } | 404 | } |
| 405 | + ge::SessionId session_id; | ||
| 406 | + impl_ = std::make_shared<GeSession::Impl>(str_options); | ||
| 414 | if (impl_ == nullptr) { | 407 | if (impl_ == nullptr) { |
| 415 | GELOGE(FAILED, "GeSession failed, impl_ is null."); | 408 | GELOGE(FAILED, "GeSession failed, impl_ is null."); |
| 416 | REPORT_INNER_ERR_MSG("E19999", "GeSession failed, impl_ is null."); | 409 | REPORT_INNER_ERR_MSG("E19999", "GeSession failed, impl_ is null."); |
| 417 | return; | 410 | return; |
| 418 | } | 411 | } |
| 419 | - ge::SessionId session_id; | 412 | + session_id = impl_->GetSessionId(); |
| 420 | ConstructSession(str_options, session_id); | 413 | ConstructSession(str_options, session_id); |
| 421 | - impl_->SetSessionId(session_id); | ||
| 422 | } | 414 | } |
| 423 | 415 | ||
| 424 | // session destructor | 416 | // session destructor |
| @@ -436,7 +428,8 @@ GeSession::~GeSession() { | |||
| 436 | const uint64_t session_id = GetSessionId(); | 428 | const uint64_t session_id = GetSessionId(); |
| 437 | // call DestroySession | 429 | // call DestroySession |
| 438 | GELOGT(TRACE_RUNNING, "GeSession id is %lu", session_id); | 430 | GELOGT(TRACE_RUNNING, "GeSession id is %lu", session_id); |
| 439 | - ret = g_ge_session_manager->DestroySession(session_id); | 431 | + RtContextUtil::GetInstance().DestroyRtContexts(session_id); |
| 432 | + impl_ = nullptr; | ||
| 440 | } catch (std::exception &e) { | 433 | } catch (std::exception &e) { |
| 441 | (void)e; | 434 | (void)e; |
| 442 | GELOGE(GE_CLI_SESS_DESTROY_FAILED, "[Destructor][GeSession]Failed: an exception occurred"); | 435 | GELOGE(GE_CLI_SESS_DESTROY_FAILED, "[Destructor][GeSession]Failed: an exception occurred"); |
| @@ -464,8 +457,6 @@ Status GeSession::AddGraph(uint32_t graph_id, const Graph &graph, const std::map | |||
| 464 | } | 457 | } |
| 465 | 458 | ||
| 466 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); | 459 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); |
| 467 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | ||
| 468 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Add graph failed, session_id:%lu.", GetSessionId()); | ||
| 469 | 460 | ||
| 470 | AscendString graph_name; | 461 | AscendString graph_name; |
| 471 | GE_ASSERT_SUCCESS(graph.GetName(graph_name), "Add graph failed, get graph name failed."); | 462 | GE_ASSERT_SUCCESS(graph.GetName(graph_name), "Add graph failed, get graph name failed."); |
| @@ -476,7 +467,9 @@ Status GeSession::AddGraph(uint32_t graph_id, const Graph &graph, const std::map | |||
| 476 | for (auto &option_item : options) { | 467 | for (auto &option_item : options) { |
| 477 | if (option_item.first.GetLength() == 0) { | 468 | if (option_item.first.GetLength() == 0) { |
| 478 | GELOGE(FAILED, "Add graph failed, option key is empty."); | 469 | GELOGE(FAILED, "Add graph failed, option key is empty."); |
| 479 | - REPORT_INNER_ERR_MSG("E19999", "Add graph failed, option key is empty."); | 470 | + REPORT_PREDEFINED_ERR_MSG("E10001", std::vector<const char *>({"parameter", "value", "reason"}), |
| 471 | + std::vector<const char *>({option_item.first.GetString(), | ||
| 472 | + option_item.second.GetString(), "parameter is empty"})); | ||
| 480 | return FAILED; | 473 | return FAILED; |
| 481 | } | 474 | } |
| 482 | 475 | ||
| @@ -489,7 +482,7 @@ Status GeSession::AddGraph(uint32_t graph_id, const Graph &graph, const std::map | |||
| 489 | GELOGW("[Check][Param] Check supported options failed."); | 482 | GELOGW("[Check][Param] Check supported options failed."); |
| 490 | } | 483 | } |
| 491 | GELOGD("Adding graph to session"); | 484 | GELOGD("Adding graph to session"); |
| 492 | - Status ret = inner_session->AddGraph(graph_id, graph, str_options); | 485 | + Status ret = impl_->AddGraph(graph_id, graph, str_options); |
| 493 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Add graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, | 486 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Add graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, |
| 494 | GetSessionId(), graph_id); | 487 | GetSessionId(), graph_id); |
| 495 | 488 | ||
| @@ -511,8 +504,6 @@ Status GeSession::AddGraphClone(uint32_t graph_id, const Graph &graph, | |||
| 511 | } | 504 | } |
| 512 | 505 | ||
| 513 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); | 506 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); |
| 514 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | ||
| 515 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Add graph failed, session_id:%lu.", GetSessionId()); | ||
| 516 | 507 | ||
| 517 | AscendString graph_name; | 508 | AscendString graph_name; |
| 518 | GE_ASSERT_SUCCESS(graph.GetName(graph_name), "Add graph failed, get graph name failed."); | 509 | GE_ASSERT_SUCCESS(graph.GetName(graph_name), "Add graph failed, get graph name failed."); |
| @@ -529,7 +520,7 @@ Status GeSession::AddGraphClone(uint32_t graph_id, const Graph &graph, | |||
| 529 | } | 520 | } |
| 530 | 521 | ||
| 531 | GELOGD("Adding graph to session"); | 522 | GELOGD("Adding graph to session"); |
| 532 | - const Status ret = inner_session->AddGraphWithCopy(graph_id, graph, str_options); | 523 | + const Status ret = impl_->AddGraphWithCopy(graph_id, graph, str_options); |
| 533 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Add graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, | 524 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Add graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, |
| 534 | GetSessionId(), graph_id); | 525 | GetSessionId(), graph_id); |
| 535 | 526 | ||
| @@ -546,14 +537,12 @@ Status GeSession::RemoveGraph(uint32_t graph_id) { | |||
| 546 | } | 537 | } |
| 547 | 538 | ||
| 548 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); | 539 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); |
| 549 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | ||
| 550 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Remove graph failed, session_id:%lu.", GetSessionId()); | ||
| 551 | 540 | ||
| 552 | GRAPH_PROFILING_REG(gert::GeProfInfoType::kRemoveGraph); | 541 | GRAPH_PROFILING_REG(gert::GeProfInfoType::kRemoveGraph); |
| 553 | GELOGT(TRACE_INIT, "GeSession RemoveGraph start, graph_id: %u", graph_id); | 542 | GELOGT(TRACE_INIT, "GeSession RemoveGraph start, graph_id: %u", graph_id); |
| 554 | 543 | ||
| 555 | // call RemoveGraph | 544 | // call RemoveGraph |
| 556 | - Status ret = inner_session->RemoveGraph(graph_id); | 545 | + Status ret = impl_->RemoveGraph(graph_id); |
| 557 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Remove graph failed, error code:%u, session_id:%lu, graph_id:%u.", | 546 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Remove graph failed, error code:%u, session_id:%lu, graph_id:%u.", |
| 558 | ret, GetSessionId(), graph_id); | 547 | ret, GetSessionId(), graph_id); |
| 559 | 548 | ||
| @@ -624,13 +613,25 @@ Status GeSession::RunGraph(uint32_t graph_id, const std::vector<gert::Tensor> &i | |||
| 624 | } | 613 | } |
| 625 | 614 | ||
| 626 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); | 615 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); |
| 627 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | 616 | + RunGraphMode cur_mode = RunGraphMode::kRunGraphModeEnd; |
| 628 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Run graph failed, session_id:%lu.", GetSessionId()); | 617 | + GE_ASSERT_SUCCESS(impl_->GetRunGraphMode(graph_id, cur_mode), "Run graph async failed, get run graph mode failed. graph_id: %u", graph_id); |
| 629 | - | 618 | + auto ret = CheckRunGraphMode(cur_mode, graph_id, RunGraphMode::kRunGraph); |
| 619 | + GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, ret, "Run graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, | ||
| 620 | + GetSessionId(), graph_id); | ||
| 621 | + if (!impl_->GetLoadFlag(graph_id)) { | ||
| 622 | + GELOGI("Graph is not loaded, start to load graph, session_id:%lu, graph_id:%u", GetSessionId(), graph_id); | ||
| 623 | + ret = LoadGraph(graph_id, {}, nullptr); | ||
| 624 | + GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, ret, "Run graph failed, error code:%u, session_id:%lu, graph_id:%u.", ret, | ||
| 625 | + GetSessionId(), graph_id); | ||
| 626 | + GELOGI("Graph loaded successfully, continue to run graph, session_id:%lu, graph_id:%u", GetSessionId(), graph_id); | ||
| 627 | + } | ||
| 630 | GELOGI("GeSession RunGraph start, session_id: %lu, graph_id: %u, input size %zu, output size %zu", GetSessionId(), | 628 | GELOGI("GeSession RunGraph start, session_id: %lu, graph_id: %u, input size %zu, output size %zu", GetSessionId(), |
| 631 | graph_id, inputs.size(), outputs.size()); | 629 | graph_id, inputs.size(), outputs.size()); |
| 632 | outputs.clear(); | 630 | outputs.clear(); |
| 633 | - Status ret = inner_session->RunGraph(graph_id, inputs, outputs); | 631 | + ret = impl_->RunGraph(graph_id, inputs, outputs); |
| 632 | + const auto set_result = impl_->SetRunGraphMode(graph_id, RunGraphMode::kRunGraph); | ||
| 633 | + GE_CHK_BOOL_RET_STATUS(set_result == SUCCESS, set_result, | ||
| 634 | + "Run graph failed, set run graph mode failed, session_id:%lu, graph_id:%u.", GetSessionId(), graph_id); | ||
| 634 | // check return status | 635 | // check return status |
| 635 | const bool need_convert_error_code = (ret == RT_ERROR_TO_GE_STATUS(ACL_ERROR_RT_QUEUE_EMPTY)); | 636 | const bool need_convert_error_code = (ret == RT_ERROR_TO_GE_STATUS(ACL_ERROR_RT_QUEUE_EMPTY)); |
| 636 | ret = need_convert_error_code ? ACL_ERROR_GE_MODEL_EXECUTE_TIMEOUT : ret; | 637 | ret = need_convert_error_code ? ACL_ERROR_GE_MODEL_EXECUTE_TIMEOUT : ret; |
| @@ -657,15 +658,24 @@ Status GeSession::RunGraphWithStreamAsync(uint32_t graph_id, void *stream, const | |||
| 657 | } | 658 | } |
| 658 | 659 | ||
| 659 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); | 660 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); |
| 660 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | 661 | + RunGraphMode cur_mode = RunGraphMode::kRunGraphModeEnd; |
| 661 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Execute graph with stream async failed, session_id:%lu.", | 662 | + GE_ASSERT_SUCCESS(impl_->GetRunGraphMode(graph_id, cur_mode), "Run graph with stream async failed, get run graph mode failed. graph_id: %u", graph_id); |
| 662 | - GetSessionId()); | 663 | + auto ret = CheckRunGraphMode(cur_mode, graph_id, RunGraphMode::kRunGraphWithStreamAsync); |
| 663 | - | 664 | + GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Run graph with stream async failed, error code:%u," |
| 664 | - Status ret = inner_session->RunGraphWithStreamAsync(graph_id, stream, inputs, outputs); | 665 | + " session_id:%lu, graph_id:%u, stream:%p.", ret, GetSessionId(), graph_id, stream); |
| 665 | - GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, | 666 | + if (!impl_->GetLoadFlag(graph_id)) { |
| 666 | - "Run graph with stream async failed, error code:%u," | 667 | + GELOGI("Graph is not loaded, start to load graph, session_id:%lu, graph_id:%u", GetSessionId(), graph_id); |
| 667 | - " session_id:%lu, graph_id:%u, stream:%p.", | 668 | + ret = LoadGraph(graph_id, {}, stream); |
| 668 | - ret, GetSessionId(), graph_id, stream); | 669 | + GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Run graph with stream async failed, error code:%u," |
| 670 | + " session_id:%lu, graph_id:%u, stream:%p.", ret, GetSessionId(), graph_id, stream); | ||
| 671 | + GELOGI("Graph loaded successfully, continue to run graph, session_id:%lu, graph_id:%u", GetSessionId(), graph_id); | ||
| 672 | + } | ||
| 673 | + ret = impl_->RunGraphWithStreamAsync(graph_id, stream, inputs, outputs); | ||
| 674 | + const auto set_result = impl_->SetRunGraphMode(graph_id, RunGraphMode::kRunGraphWithStreamAsync); | ||
| 675 | + GE_CHK_BOOL_RET_STATUS(set_result == SUCCESS, set_result, "Run graph with stream async failed," | ||
| 676 | + " set run graph mode failed, session_id:%lu, graph_id:%u.", GetSessionId(), graph_id); | ||
| 677 | + GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Run graph with stream async failed, error code:%u," | ||
| 678 | + " session_id:%lu, graph_id:%u, stream:%p.", ret, GetSessionId(), graph_id, stream); | ||
| 669 | return SUCCESS; | 679 | return SUCCESS; |
| 670 | } | 680 | } |
| 671 | 681 | ||
| @@ -682,9 +692,7 @@ Status GeSession::RegisterCallBackFunc(const char *key, const RunCallback &callb | |||
| 682 | str_key = key; | 692 | str_key = key; |
| 683 | } | 693 | } |
| 684 | 694 | ||
| 685 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | 695 | + return impl_->RegisterCallBackFunc(str_key, callback); |
| 686 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][GeSession] failed, session_id:%lu.", GetSessionId()); | ||
| 687 | - return inner_session->RegisterCallBackFunc(str_key, callback); | ||
| 688 | } | 696 | } |
| 689 | 697 | ||
| 690 | Status GeSession::LoadGraph(const uint32_t graph_id, const std::map<AscendString, AscendString> &options, | 698 | Status GeSession::LoadGraph(const uint32_t graph_id, const std::map<AscendString, AscendString> &options, |
| @@ -697,14 +705,19 @@ Status GeSession::LoadGraph(const uint32_t graph_id, const std::map<AscendString | |||
| 697 | } | 705 | } |
| 698 | 706 | ||
| 699 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); | 707 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); |
| 700 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | 708 | + if (!impl_->GetBuildFlag(graph_id)) { |
| 701 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Load graph failed, session_id:%lu.", GetSessionId()); | 709 | + GELOGI("Graph is not compiled, start to compile graph, session_id:%lu, graph_id:%u", GetSessionId(), graph_id); |
| 702 | - | 710 | + const auto ret = impl_->CompileGraph(graph_id, {}); |
| 703 | - Status ret = inner_session->LoadGraph(graph_id, options, stream); | 711 | + GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, ret, |
| 712 | + "Load graph failed, error code:%u, session_id:%lu, graph_id:%u.", | ||
| 713 | + ret, GetSessionId(), graph_id); | ||
| 714 | + GELOGI("Graph compiled successfully, continue to load graph, session_id:%lu, graph_id:%u", | ||
| 715 | + GetSessionId(), graph_id); | ||
| 716 | + } | ||
| 717 | + Status ret = impl_->LoadGraph(graph_id, options, stream); | ||
| 704 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, | 718 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, |
| 705 | "Load graph failed, error code:%u, session_id:%lu, graph_id:%u.", | 719 | "Load graph failed, error code:%u, session_id:%lu, graph_id:%u.", |
| 706 | ret, GetSessionId(), graph_id); | 720 | ret, GetSessionId(), graph_id); |
| 707 | - | ||
| 708 | return ret; | 721 | return ret; |
| 709 | } | 722 | } |
| 710 | 723 | ||
| @@ -718,9 +731,18 @@ Status GeSession::RunGraphAsync(uint32_t graph_id, const std::vector<gert::Tenso | |||
| 718 | } | 731 | } |
| 719 | 732 | ||
| 720 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); | 733 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); |
| 721 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | 734 | + RunGraphMode cur_mode = RunGraphMode::kRunGraphModeEnd; |
| 722 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "Run graph async failed, session_id:%lu.", GetSessionId()); | 735 | + GE_ASSERT_SUCCESS(impl_->GetRunGraphMode(graph_id, cur_mode), "Run graph async failed, get run graph mode failed. graph_id: %u", graph_id); |
| 723 | - | 736 | + auto ret = CheckRunGraphMode(cur_mode, graph_id, RunGraphMode::kRunGraphAsync); |
| 737 | + if (ret != SUCCESS) { | ||
| 738 | + if (callback != nullptr) { | ||
| 739 | + std::vector<gert::Tensor> outputs; | ||
| 740 | + callback(ret, outputs); | ||
| 741 | + } | ||
| 742 | + REPORT_INNER_ERR_MSG("E19999", "Run graph async failed, check run graph mode failed, graph_id:%u", graph_id); | ||
| 743 | + GELOGE(ret, "Run graph async failed, check run graph mode failed, graph_id:%u", graph_id); | ||
| 744 | + return ret; | ||
| 745 | + } | ||
| 724 | GRAPH_PROFILING_REG(gert::GeProfInfoType::kRunGraphAsync); | 746 | GRAPH_PROFILING_REG(gert::GeProfInfoType::kRunGraphAsync); |
| 725 | GELOGI("start to run graph async, session_id: %lu, graph_id: %u, input size %zu", GetSessionId(), graph_id, | 747 | GELOGI("start to run graph async, session_id: %lu, graph_id: %u, input size %zu", GetSessionId(), graph_id, |
| 726 | inputs.size()); | 748 | inputs.size()); |
| @@ -729,7 +751,11 @@ Status GeSession::RunGraphAsync(uint32_t graph_id, const std::vector<gert::Tenso | |||
| 729 | "The callback function will not be checked. Please ensure that the implementation of the function is trusted," | 751 | "The callback function will not be checked. Please ensure that the implementation of the function is trusted," |
| 730 | " graph_id: %u", graph_id); | 752 | " graph_id: %u", graph_id); |
| 731 | 753 | ||
| 732 | - Status ret = inner_session->RunGraphAsync(graph_id, inputs, callback); | 754 | + auto inputs_share = TensorTransUtils::ShareFromGertTenosrs(inputs); |
| 755 | + ret = impl_->RunGraphAsync(graph_id, std::move(inputs_share), callback); | ||
| 756 | + const auto set_result = impl_->SetRunGraphMode(graph_id, RunGraphMode::kRunGraphAsync); | ||
| 757 | + GE_CHK_BOOL_RET_STATUS(set_result == SUCCESS, set_result, "Run graph async failed," | ||
| 758 | + " set run graph mode failed, session_id:%lu, graph_id:%u.", GetSessionId(), graph_id); | ||
| 733 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Run graph async failed, error code:%u, session_id:%lu, graph_id:%u.", | 759 | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "Run graph async failed, error code:%u, session_id:%lu, graph_id:%u.", |
| 734 | ret, GetSessionId(), graph_id); | 760 | ret, GetSessionId(), graph_id); |
| 735 | GELOGD("RunGraphAsync finished in GeSession, graph_id: %u,", graph_id); | 761 | GELOGD("RunGraphAsync finished in GeSession, graph_id: %u,", graph_id); |
| @@ -745,12 +771,7 @@ bool GeSession::IsGraphNeedRebuild(uint32_t graph_id) { | |||
| 745 | } | 771 | } |
| 746 | 772 | ||
| 747 | GE_ASSERT_NOTNULL(impl_, "GeSession construction incomplete (null impl pointer)"); | 773 | GE_ASSERT_NOTNULL(impl_, "GeSession construction incomplete (null impl pointer)"); |
| 748 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | 774 | + return impl_->IsGraphNeedRebuild(graph_id); |
| 749 | - if (inner_session == nullptr) { | ||
| 750 | - GELOGE(FAILED, "[Get][GeSession] failed, session_id:%lu.", GetSessionId()); | ||
| 751 | - return true; | ||
| 752 | - } | ||
| 753 | - return inner_session->IsGraphNeedRebuild(graph_id); | ||
| 754 | } | 775 | } |
| 755 | 776 | ||
| 756 | uint64_t GeSession::GetSessionId() const { | 777 | uint64_t GeSession::GetSessionId() const { |
| @@ -768,13 +789,11 @@ Status GeSession::CompileGraph(uint32_t graph_id) { | |||
| 768 | Status GeSession::CompileGraph(uint32_t graph_id, const std::vector<ge::Tensor> &inputs) { | 789 | Status GeSession::CompileGraph(uint32_t graph_id, const std::vector<ge::Tensor> &inputs) { |
| 769 | GE_ASSERT(g_ge_initialized, "[Construct][GeSession]Failed because lack GEInitialize call before."); | 790 | GE_ASSERT(g_ge_initialized, "[Construct][GeSession]Failed because lack GEInitialize call before."); |
| 770 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); | 791 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); |
| 771 | - const auto inner_session = g_ge_session_manager->GetSession(GetSessionId()); | ||
| 772 | - GE_ASSERT_NOTNULL(inner_session, "[Get][GeSession]Failed, session_id:%lu.", GetSessionId()); | ||
| 773 | 792 | ||
| 774 | GELOGT(TRACE_INIT, "Start to compile graph, session_id:%lu, graph_id:%u, inputs size:%zu", | 793 | GELOGT(TRACE_INIT, "Start to compile graph, session_id:%lu, graph_id:%u, inputs size:%zu", |
| 775 | GetSessionId(), graph_id, inputs.size()); | 794 | GetSessionId(), graph_id, inputs.size()); |
| 776 | 795 | ||
| 777 | - Status ret = inner_session->CompileGraph(graph_id, inputs); | 796 | + Status ret = impl_->CompileGraph(graph_id, inputs); |
| 778 | GE_ASSERT_SUCCESS(ret, "[Compile][Graph]Compile graph failed, error code:%u, session_id:%lu, graph_id:%u.", | 797 | GE_ASSERT_SUCCESS(ret, "[Compile][Graph]Compile graph failed, error code:%u, session_id:%lu, graph_id:%u.", |
| 779 | ret, GetSessionId(), graph_id); | 798 | ret, GetSessionId(), graph_id); |
| 780 | GELOGT(TRACE_STOP, "Compile graph success, session_id:%lu, graph_id:%u, inputs size:%zu", | 799 | GELOGT(TRACE_STOP, "Compile graph success, session_id:%lu, graph_id:%u, inputs size:%zu", |
| @@ -785,11 +804,9 @@ Status GeSession::CompileGraph(uint32_t graph_id, const std::vector<ge::Tensor> | |||
| 785 | CompiledGraphSummaryPtr GeSession::GetCompiledGraphSummary(uint32_t graph_id) { | 804 | CompiledGraphSummaryPtr GeSession::GetCompiledGraphSummary(uint32_t graph_id) { |
| 786 | GE_ASSERT(g_ge_initialized, "[Construct][GeSession]Failed because lack GEInitialize call before."); | 805 | GE_ASSERT(g_ge_initialized, "[Construct][GeSession]Failed because lack GEInitialize call before."); |
| 787 | GE_ASSERT_NOTNULL(impl_, "GeSession construction incomplete (null impl pointer)"); | 806 | GE_ASSERT_NOTNULL(impl_, "GeSession construction incomplete (null impl pointer)"); |
| 788 | - const auto inner_session = g_ge_session_manager->GetSession(GetSessionId()); | ||
| 789 | - GE_ASSERT_NOTNULL(inner_session, "[Get][GeSession]Failed, session_id:%lu.", GetSessionId()); | ||
| 790 | 807 | ||
| 791 | CompiledGraphSummaryPtr summary = nullptr; | 808 | CompiledGraphSummaryPtr summary = nullptr; |
| 792 | - Status ret = inner_session->GetCompiledGraphSummary(graph_id, summary); | 809 | + Status ret = impl_->GetCompiledGraphSummary(graph_id, summary); |
| 793 | GE_ASSERT_SUCCESS(ret, "[Get][Summary]Failed, error code:%u, session_id:%lu, graph_id:%u.", | 810 | GE_ASSERT_SUCCESS(ret, "[Get][Summary]Failed, error code:%u, session_id:%lu, graph_id:%u.", |
| 794 | ret, GetSessionId(), graph_id); | 811 | ret, GetSessionId(), graph_id); |
| 795 | return summary; | 812 | return summary; |
| @@ -810,10 +827,7 @@ Status GeSession::SetGraphConstMemoryBase(uint32_t graph_id, const void *const m | |||
| 810 | return UNSUPPORTED; | 827 | return UNSUPPORTED; |
| 811 | } | 828 | } |
| 812 | 829 | ||
| 813 | - const auto inner_session = g_ge_session_manager->GetSession(GetSessionId()); | 830 | + const auto ret = impl_->SetGraphConstMemoryBase(graph_id, memory, size); |
| 814 | - GE_ASSERT_NOTNULL(inner_session, "[Get][GeSession]Failed, session_id:%lu.", GetSessionId()); | ||
| 815 | - | ||
| 816 | - const auto ret = inner_session->SetGraphConstMemoryBase(graph_id, memory, size); | ||
| 817 | GE_ASSERT_SUCCESS(ret, "[Set][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", ret, | 831 | GE_ASSERT_SUCCESS(ret, "[Set][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", ret, |
| 818 | GetSessionId(), graph_id, memory, size); | 832 | GetSessionId(), graph_id, memory, size); |
| 819 | return SUCCESS; | 833 | return SUCCESS; |
| @@ -833,10 +847,8 @@ Status GeSession::UpdateGraphFeatureMemoryBase(uint32_t graph_id, const void *co | |||
| 833 | GetSessionId(), graph_id, memory, size); | 847 | GetSessionId(), graph_id, memory, size); |
| 834 | return UNSUPPORTED; | 848 | return UNSUPPORTED; |
| 835 | } | 849 | } |
| 836 | - const auto inner_session = g_ge_session_manager->GetSession(GetSessionId()); | ||
| 837 | - GE_ASSERT_NOTNULL(inner_session, "[Get][GeSession]Failed, session_id:%lu.", GetSessionId()); | ||
| 838 | 850 | ||
| 839 | - const auto ret = inner_session->UpdateGraphFeatureMemoryBase(graph_id, memory, size); | 851 | + const auto ret = impl_->UpdateGraphFeatureMemoryBase(graph_id, memory, size); |
| 840 | GE_ASSERT_SUCCESS(ret, "[Update][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", ret, | 852 | GE_ASSERT_SUCCESS(ret, "[Update][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", ret, |
| 841 | GetSessionId(), graph_id, memory, size); | 853 | GetSessionId(), graph_id, memory, size); |
| 842 | return SUCCESS; | 854 | return SUCCESS; |
| @@ -857,10 +869,8 @@ Status GeSession::SetGraphFixedFeatureMemoryBaseWithType(uint32_t graph_id, Memo | |||
| 857 | GetSessionId(), graph_id, memory, size); | 869 | GetSessionId(), graph_id, memory, size); |
| 858 | return UNSUPPORTED; | 870 | return UNSUPPORTED; |
| 859 | } | 871 | } |
| 860 | - const auto inner_session = g_ge_session_manager->GetSession(GetSessionId()); | ||
| 861 | - GE_ASSERT_NOTNULL(inner_session, "[Get][GeSession]Failed, session_id:%lu.", GetSessionId()); | ||
| 862 | 872 | ||
| 863 | - const auto ret = inner_session->SetGraphFixedFeatureMemoryBase(graph_id, type, memory, size); | 873 | + const auto ret = impl_->SetGraphFixedFeatureMemoryBase(graph_id, type, memory, size); |
| 864 | GE_ASSERT_SUCCESS(ret, | 874 | GE_ASSERT_SUCCESS(ret, |
| 865 | "[Set][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, type:%d," | 875 | "[Set][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, type:%d," |
| 866 | " memory:%p, size:%zu", | 876 | " memory:%p, size:%zu", |
| @@ -882,10 +892,8 @@ Status GeSession::UpdateGraphRefreshableFeatureMemoryBase(uint32_t graph_id, con | |||
| 882 | GetSessionId(), graph_id, memory, size); | 892 | GetSessionId(), graph_id, memory, size); |
| 883 | return UNSUPPORTED; | 893 | return UNSUPPORTED; |
| 884 | } | 894 | } |
| 885 | - const auto inner_session = g_ge_session_manager->GetSession(GetSessionId()); | ||
| 886 | - GE_ASSERT_NOTNULL(inner_session, "[Get][GeSession]Failed, session_id:%lu.", GetSessionId()); | ||
| 887 | 895 | ||
| 888 | - const auto ret = inner_session->UpdateGraphRefreshableFeatureMemoryBase(graph_id, memory, size); | 896 | + const auto ret = impl_->UpdateGraphRefreshableFeatureMemoryBase(graph_id, memory, size); |
| 889 | GE_ASSERT_SUCCESS(ret, "[Update][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", ret, | 897 | GE_ASSERT_SUCCESS(ret, "[Update][Memory]Failed, error code:%u, session_id:%lu, graph_id:%u, memory:%p, size:%zu", ret, |
| 890 | GetSessionId(), graph_id, memory, size); | 898 | GetSessionId(), graph_id, memory, size); |
| 891 | return SUCCESS; | 899 | return SUCCESS; |
| @@ -894,40 +902,16 @@ Status GeSession::UpdateGraphRefreshableFeatureMemoryBase(uint32_t graph_id, con | |||
| 894 | Status GeSession::RegisterExternalAllocator(const void *const stream, AllocatorPtr allocator) const { | 902 | Status GeSession::RegisterExternalAllocator(const void *const stream, AllocatorPtr allocator) const { |
| 895 | GE_ASSERT(g_ge_initialized, "[Construct][GeSession]Failed because lack GEInitialize call before."); | 903 | GE_ASSERT(g_ge_initialized, "[Construct][GeSession]Failed because lack GEInitialize call before."); |
| 896 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); | 904 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); |
| 897 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | ||
| 898 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][GeSession] failed, session_id:%lu.", GetSessionId()); | ||
| 899 | 905 | ||
| 900 | - GE_CHK_STATUS_RET(inner_session->RegisterExternalAllocator(stream, allocator), "register external allocator failed"); | 906 | + GE_CHK_STATUS_RET(impl_->RegisterExternalAllocator(stream, allocator), "register external allocator failed"); |
| 901 | return SUCCESS; | 907 | return SUCCESS; |
| 902 | } | 908 | } |
| 903 | 909 | ||
| 904 | Status GeSession::UnregisterExternalAllocator(const void *const stream) const { | 910 | Status GeSession::UnregisterExternalAllocator(const void *const stream) const { |
| 905 | GE_ASSERT(g_ge_initialized, "[Construct][GeSession]Failed because lack GEInitialize call before."); | 911 | GE_ASSERT(g_ge_initialized, "[Construct][GeSession]Failed because lack GEInitialize call before."); |
| 906 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); | 912 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); |
| 907 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | ||
| 908 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][GeSession] failed, session_id:%lu.", GetSessionId()); | ||
| 909 | 913 | ||
| 910 | - GE_CHK_STATUS_RET(inner_session->UnregisterExternalAllocator(stream), "unregister external allocator failed"); | 914 | + GE_CHK_STATUS_RET(impl_->UnregisterExternalAllocator(stream), "unregister external allocator failed"); |
| 911 | - return SUCCESS; | ||
| 912 | -} | ||
| 913 | - | ||
| 914 | -Status GetSessionMemInfo(const uint64_t session_id, uint64_t &var_size, | ||
| 915 | - std::map<uint32_t, std::vector<uint64_t>> &graphs_mem_info) { | ||
| 916 | - if (!g_ge_initialized) { | ||
| 917 | - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Construct][GeSession]Failed because lack GEInitialize call before."); | ||
| 918 | - REPORT_INNER_ERR_MSG("E19999", "Creating session failed because lack GEInitialize call before."); | ||
| 919 | - return FAILED; | ||
| 920 | - } | ||
| 921 | - | ||
| 922 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(session_id); | ||
| 923 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][GeSession] failed, session_id:%lu.", session_id); | ||
| 924 | - | ||
| 925 | - auto &graph_manager = inner_session->getGraphManagerObj(); | ||
| 926 | - GE_CHK_STATUS_RET(graph_manager.GetGraphsMemInfo(graphs_mem_info), "Get graphs memory info failed"); | ||
| 927 | - const auto &var_manager = ge::VarManager::Instance(session_id); | ||
| 928 | - GE_CHECK_NOTNULL(var_manager); | ||
| 929 | - var_size = static_cast<uint64_t>(var_manager->GetVarMemSize(RT_MEMORY_HBM)); | ||
| 930 | - GELOGD("GeSession memory info:var_size:%lu", var_size); | ||
| 931 | return SUCCESS; | 915 | return SUCCESS; |
| 932 | } | 916 | } |
| 933 | 917 | ||
| @@ -938,13 +922,16 @@ Status GeSession::GetCompiledModel(uint32_t graph_id, ModelBufferData &model_buf | |||
| 938 | return FAILED; | 922 | return FAILED; |
| 939 | } | 923 | } |
| 940 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); | 924 | GE_CHK_BOOL_RET_STATUS(impl_ != nullptr, FAILED, "GeSession construction incomplete (null impl pointer)"); |
| 941 | - const InnerGeSessionPtr inner_session = g_ge_session_manager->GetSession(GetSessionId()); | 925 | + return impl_->GetCompiledModel(graph_id, model_buffer); |
| 942 | - GE_CHK_BOOL_RET_STATUS(inner_session != nullptr, FAILED, "[Get][GeSession] failed, session_id:%lu.", GetSessionId()); | ||
| 943 | - return inner_session->GetCompiledModel(graph_id, model_buffer); | ||
| 944 | } | 926 | } |
| 945 | } // namespace ge | 927 | } // namespace ge |
| 946 | 928 | ||
| 947 | extern "C" { | 929 | extern "C" { |
| 930 | +std::set<std::string> kSupportedFeatures = {INFERENCE_RULE}; | ||
| 931 | +bool IsIrRepSupport(const char *rep) { | ||
| 932 | + return kSupportedFeatures.count(rep) > 0; | ||
| 933 | +} | ||
| 934 | + | ||
| 948 | ge::Status GetRegisteredIrDef(const char *op_type, std::vector<std::pair<ge::AscendString, ge::AscendString>> &inputs, | 935 | ge::Status GetRegisteredIrDef(const char *op_type, std::vector<std::pair<ge::AscendString, ge::AscendString>> &inputs, |
| 949 | std::vector<std::pair<ge::AscendString, ge::AscendString>> &outputs, | 936 | std::vector<std::pair<ge::AscendString, ge::AscendString>> &outputs, |
| 950 | std::vector<std::pair<ge::AscendString, ge::AscendString>> &attrs) { | 937 | std::vector<std::pair<ge::AscendString, ge::AscendString>> &attrs) { |
| @@ -17,8 +17,8 @@ | |||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | namespace ge { | 19 | namespace ge { |
| 20 | -CompiledModelCache::CompiledModelCache(uint32_t user_graph_id, CompileContext &context, InnerSession &inner_session) : user_graph_id_(user_graph_id), | 20 | +CompiledModelCache::CompiledModelCache(uint32_t user_graph_id, CompileContext &context, GraphManager &graph_manager) : user_graph_id_(user_graph_id), |
| 21 | - compile_context_(context), inner_session_(inner_session) { | 21 | + compile_context_(context), graph_manager_(graph_manager) { |
| 22 | user_graph_key_ = ModelCache::GetGraphKeyFromContext(); | 22 | user_graph_key_ = ModelCache::GetGraphKeyFromContext(); |
| 23 | if (user_graph_key_.empty()) { | 23 | if (user_graph_key_.empty()) { |
| 24 | GELOGI("The user_graph_key is not set in the options, cmc will not restore or save cache."); | 24 | GELOGI("The user_graph_key is not set in the options, cmc will not restore or save cache."); |
| @@ -10,14 +10,12 @@ | |||
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | - | ||
| 14 | 13 | ||
| 15 | 14 | ||
| 16 | 15 | ||
| 17 | 16 | ||
| 18 | 17 | ||
| 19 | 18 | ||
| 20 | - | ||
| 21 | 19 | ||
| 22 | namespace ge { | 20 | namespace ge { |
| 23 | 21 | ||
| @@ -29,7 +27,7 @@ class CompiledModelCache { | |||
| 29 | public: | 27 | public: |
| 30 | CompiledModelCache() = delete; | 28 | CompiledModelCache() = delete; |
| 31 | 29 | ||
| 32 | - CompiledModelCache(uint32_t user_graph_id, CompileContext &context, InnerSession &inner_session); | 30 | + CompiledModelCache(uint32_t user_graph_id, CompileContext &context, GraphManager &graph_manager); |
| 33 | 31 | ||
| 34 | CompiledModelCache(const CompiledModelCache &) = delete; | 32 | CompiledModelCache(const CompiledModelCache &) = delete; |
| 35 | 33 | ||
| @@ -53,7 +51,7 @@ class CompiledModelCache { | |||
| 53 | 51 | ||
| 54 | CompileContext &compile_context_; | 52 | CompileContext &compile_context_; |
| 55 | 53 | ||
| 56 | - InnerSession &inner_session_; | 54 | + GraphManager &graph_manager_; |
| 57 | 55 | ||
| 58 | std::string user_graph_key_; | 56 | std::string user_graph_key_; |
| 59 | 57 | ||
| @@ -15,50 +15,52 @@ | |||
| 15 | namespace ge { | 15 | namespace ge { |
| 16 | // todo refactor func name to AddAndCompile | 16 | // todo refactor func name to AddAndCompile |
| 17 | Status CompileContext::Compile(uint32_t graph_id, const ComputeGraphPtr &graph, const std::vector<gert::Tensor> &inputs, | 17 | Status CompileContext::Compile(uint32_t graph_id, const ComputeGraphPtr &graph, const std::vector<gert::Tensor> &inputs, |
| 18 | - const std::map<std::string, std::string> &options) { | 18 | + const std::map<std::string, std::string> &options, uint64_t session_id) { |
| 19 | Graph graph_to_add = GraphUtilsEx::CreateGraphFromComputeGraph(graph); // todo check if need more info in graph | 19 | Graph graph_to_add = GraphUtilsEx::CreateGraphFromComputeGraph(graph); // todo check if need more info in graph |
| 20 | - GE_ASSERT_SUCCESS(inner_session_.AddGraph(graph_id, graph_to_add, options)); | 20 | + GE_ASSERT_SUCCESS(graph_manager_.AddGraph(graph_id, graph_to_add, options, domi::GetContext())); |
| 21 | - GELOGI("[Session: ][AddGraph] success to add slice graph id: %ld", graph_id); | 21 | + GELOGI("[Session: ][AddGraph] success to add slice graph id: %ld, session_id: %llu", graph_id, session_id); |
| 22 | std::vector<Tensor> inputs_to_ge; | 22 | std::vector<Tensor> inputs_to_ge; |
| 23 | GE_ASSERT_SUCCESS(TensorTransUtils::TransRtTensorToTensor(inputs, inputs_to_ge, false)); | 23 | GE_ASSERT_SUCCESS(TensorTransUtils::TransRtTensorToTensor(inputs, inputs_to_ge, false)); |
| 24 | GE_ASSERT_TRUE(inputs_to_ge.size() == inputs.size()); | 24 | GE_ASSERT_TRUE(inputs_to_ge.size() == inputs.size()); |
| 25 | - GE_ASSERT_SUCCESS(inner_session_.CompileGraph(graph_id, inputs_to_ge)); | 25 | + GE_ASSERT_SUCCESS(graph_manager_.CompileGraph(graph_id, session_id, inputs_to_ge), "graph id: %ld, session_id: %llu", |
| 26 | + graph_id, session_id); | ||
| 26 | return SUCCESS; | 27 | return SUCCESS; |
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | -Status CompileContext::Compile(uint32_t graph_id, const ComputeGraphPtr &graph, const std::vector<ge::Tensor> &inputs) { | 30 | +Status CompileContext::Compile(uint32_t graph_id, const ComputeGraphPtr &graph, const std::vector<ge::Tensor> &inputs, |
| 31 | + uint64_t session_id) { | ||
| 30 | Graph graph_to_add = GraphUtilsEx::CreateGraphFromComputeGraph(graph); | 32 | Graph graph_to_add = GraphUtilsEx::CreateGraphFromComputeGraph(graph); |
| 31 | - GE_ASSERT_SUCCESS(inner_session_.AddGraph(graph_id, graph_to_add)); | 33 | + GE_ASSERT_SUCCESS(graph_manager_.AddGraph(graph_id, graph_to_add, {}, domi::GetContext())); |
| 32 | - GELOGI("[Session: ][AddGraph] success to add slice graph id: %ld", graph_id); | 34 | + GELOGI("[Session: ][AddGraph] success to add slice graph id: %ld, session_id: %llu", graph_id, session_id); |
| 33 | - GE_ASSERT_SUCCESS(inner_session_.CompileGraph(graph_id, inputs)); | 35 | + GE_ASSERT_SUCCESS(graph_manager_.CompileGraph(graph_id, session_id, inputs), "graph id: %ld, session_id: %llu", |
| 36 | + graph_id, session_id); | ||
| 34 | return SUCCESS; | 37 | return SUCCESS; |
| 35 | } | 38 | } |
| 36 | 39 | ||
| 37 | -Status CompileContext::Load(uint32_t graph_id, rtStream_t stream) { | 40 | +Status CompileContext::Load(uint32_t graph_id, const rtStream_t stream) const { |
| 38 | - std::map<AscendString, AscendString> load_option; | 41 | + GE_ASSERT_SUCCESS(graph_manager_.LoadGraph(graph_id, {}, stream)); |
| 39 | - GE_ASSERT_SUCCESS(inner_session_.LoadGraph(graph_id, load_option, stream)); | ||
| 40 | GELOGI("[Session: ][AddGraph] success to load slice_graph_id: %ld", graph_id); | 42 | GELOGI("[Session: ][AddGraph] success to load slice_graph_id: %ld", graph_id); |
| 41 | return SUCCESS; | 43 | return SUCCESS; |
| 42 | } | 44 | } |
| 43 | 45 | ||
| 44 | Status CompileContext::Load(uint32_t graph_id, const std::map<AscendString, AscendString> &options, | 46 | Status CompileContext::Load(uint32_t graph_id, const std::map<AscendString, AscendString> &options, |
| 45 | - rtStream_t stream) { | 47 | + const rtStream_t stream) { |
| 46 | - GE_ASSERT_SUCCESS(inner_session_.LoadGraph(graph_id, options, stream)); | 48 | + GE_ASSERT_SUCCESS(graph_manager_.LoadGraph(graph_id, options, stream)); |
| 47 | GELOGI("[Session: ][LoadGraph] success to load slice_graph_id: %ld", graph_id); | 49 | GELOGI("[Session: ][LoadGraph] success to load slice_graph_id: %ld", graph_id); |
| 48 | return SUCCESS; | 50 | return SUCCESS; |
| 49 | } | 51 | } |
| 50 | 52 | ||
| 51 | Status CompileContext::Fork(uint32_t origin_graph_id, uint32_t forked_graph_id) { | 53 | Status CompileContext::Fork(uint32_t origin_graph_id, uint32_t forked_graph_id) { |
| 52 | - GE_ASSERT_SUCCESS(inner_session_.ForkGraph(origin_graph_id, forked_graph_id)); | 54 | + GE_ASSERT_SUCCESS(graph_manager_.ForkGraph(origin_graph_id, forked_graph_id)); |
| 53 | GELOGI("[Session: ][ForkGraph] success to fork graph: %u from graph:%u", forked_graph_id, origin_graph_id); | 55 | GELOGI("[Session: ][ForkGraph] success to fork graph: %u from graph:%u", forked_graph_id, origin_graph_id); |
| 54 | return SUCCESS; | 56 | return SUCCESS; |
| 55 | } | 57 | } |
| 56 | bool CompileContext::IsGraphNeedRebuild(uint32_t graph_id) { | 58 | bool CompileContext::IsGraphNeedRebuild(uint32_t graph_id) { |
| 57 | - return inner_session_.IsGraphNeedRebuild(graph_id); | 59 | + return graph_manager_.IsGraphNeedRebuild(graph_id); |
| 58 | } | 60 | } |
| 59 | 61 | ||
| 60 | Status CompileContext::GetCompiledGraphSummary(uint32_t graph_id, CompiledGraphSummaryPtr &summary) const { | 62 | Status CompileContext::GetCompiledGraphSummary(uint32_t graph_id, CompiledGraphSummaryPtr &summary) const { |
| 61 | - GE_ASSERT_SUCCESS(inner_session_.GetCompiledGraphSummary(graph_id, summary)); | 63 | + GE_ASSERT_SUCCESS(graph_manager_.GetCompiledGraphSummary(graph_id, summary)); |
| 62 | GELOGI("[Session: ][GetCompiledGraphSummary] success to get compiled graph: %u", graph_id); | 64 | GELOGI("[Session: ][GetCompiledGraphSummary] success to get compiled graph: %u", graph_id); |
| 63 | return SUCCESS; | 65 | return SUCCESS; |
| 64 | } | 66 | } |
| @@ -14,27 +14,27 @@ | |||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | -#include "api/session/session/inner_session.h" | 17 | +#include "graph/manager/graph_manager.h" |
| 18 | namespace ge { | 18 | namespace ge { |
| 19 | -using SessionPtr = std::shared_ptr<InnerSession>; | ||
| 20 | class CompileContext { | 19 | class CompileContext { |
| 21 | public: | 20 | public: |
| 22 | - explicit CompileContext(InnerSession &inner_session) : inner_session_(inner_session) {} | 21 | + explicit CompileContext(GraphManager &graph_manager) : graph_manager_(graph_manager) {} |
| 23 | uint32_t GenNewGraphId() { | 22 | uint32_t GenNewGraphId() { |
| 24 | return inner_ge_graph_id_generator_++; | 23 | return inner_ge_graph_id_generator_++; |
| 25 | } | 24 | } |
| 26 | Status Compile(uint32_t graph_id, const ComputeGraphPtr &graph, const std::vector<gert::Tensor> &inputs, | 25 | Status Compile(uint32_t graph_id, const ComputeGraphPtr &graph, const std::vector<gert::Tensor> &inputs, |
| 27 | - const std::map<std::string, std::string> &options); | 26 | + const std::map<std::string, std::string> &options, uint64_t session_id); |
| 28 | - Status Compile(uint32_t graph_id, const ComputeGraphPtr &graph, const std::vector<ge::Tensor> &inputs); | 27 | + Status Compile(uint32_t graph_id, const ComputeGraphPtr &graph, const std::vector<ge::Tensor> &inputs, |
| 28 | + uint64_t session_id); | ||
| 29 | Status Fork(uint32_t origin_graph_id, uint32_t forked_graph_id); | 29 | Status Fork(uint32_t origin_graph_id, uint32_t forked_graph_id); |
| 30 | - Status Load(uint32_t graph_id, rtStream_t stream); | 30 | + Status Load(uint32_t graph_id, const rtStream_t stream) const; |
| 31 | Status Load(uint32_t graph_id, const std::map<AscendString, AscendString> &options, | 31 | Status Load(uint32_t graph_id, const std::map<AscendString, AscendString> &options, |
| 32 | - rtStream_t stream); | 32 | + const rtStream_t stream); |
| 33 | bool IsGraphNeedRebuild(uint32_t graph_id); | 33 | bool IsGraphNeedRebuild(uint32_t graph_id); |
| 34 | Status GetCompiledGraphSummary(uint32_t graph_id, CompiledGraphSummaryPtr &summary) const; | 34 | Status GetCompiledGraphSummary(uint32_t graph_id, CompiledGraphSummaryPtr &summary) const; |
| 35 | 35 | ||
| 36 | private: | 36 | private: |
| 37 | - InnerSession &inner_session_; | 37 | + GraphManager &graph_manager_; |
| 38 | uint32_t inner_ge_graph_id_generator_{0}; | 38 | uint32_t inner_ge_graph_id_generator_{0}; |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | + | ||
| 16 | 17 | ||
| 17 | 18 | ||
| 18 | 19 | ||
| @@ -119,10 +120,7 @@ Status ExecutionOrder::ConstructInputTensors(const ComputeGraphPtr &compute_grap | |||
| 119 | PtrToValue(inputs_temp.back().GetData().GetData()), | 120 | PtrToValue(inputs_temp.back().GetData().GetData()), |
| 120 | inputs_temp.back().GetData().GetSize()); | 121 | inputs_temp.back().GetData().GetSize()); |
| 121 | } | 122 | } |
| 122 | - graph_inputs_.reserve(inputs_temp.size()); | 123 | + GE_ASSERT_SUCCESS(TensorTransUtils::GeTensors2GertTensors(inputs_temp, graph_inputs_)); |
| 123 | - for (const auto &input : inputs_temp) { | ||
| 124 | - graph_inputs_.emplace_back(TensorAdapter::AsTensor(input)); | ||
| 125 | - } | ||
| 126 | GE_ASSERT_SUCCESS(NormalizeOutputs(compute_graph)); | 124 | GE_ASSERT_SUCCESS(NormalizeOutputs(compute_graph)); |
| 127 | return SUCCESS; | 125 | return SUCCESS; |
| 128 | } | 126 | } |
| @@ -150,7 +148,7 @@ Status ExecutionOrder::NormalizeOutputs(const ComputeGraphPtr &compute_graph) co | |||
| 150 | return SUCCESS; | 148 | return SUCCESS; |
| 151 | } | 149 | } |
| 152 | 150 | ||
| 153 | -std::vector<Tensor> ExecutionOrder::GetInputTensors(bool &is_unknown_input_shape) { | 151 | +const std::vector<gert::Tensor> &ExecutionOrder::GetInputTensors(bool &is_unknown_input_shape) { |
| 154 | if (graph_inputs_.size() == 0) { | 152 | if (graph_inputs_.size() == 0) { |
| 155 | (void)ConstructInputTensors(user_graph_.compute_graph); | 153 | (void)ConstructInputTensors(user_graph_.compute_graph); |
| 156 | } | 154 | } |
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | + | ||
| 14 | 15 | ||
| 15 | 16 | ||
| 16 | 17 | ||
| @@ -41,7 +42,7 @@ class ExecutionOrder { | |||
| 41 | Status NextPoint(const ExecutionPoint &ep, const std::vector<GeTensor> &inputs, ExecutionPoint *&next_ep); | 42 | Status NextPoint(const ExecutionPoint &ep, const std::vector<GeTensor> &inputs, ExecutionPoint *&next_ep); |
| 42 | 43 | ||
| 43 | ExecutionPoint* GetFirstPoint(); | 44 | ExecutionPoint* GetFirstPoint(); |
| 44 | - std::vector<Tensor> GetInputTensors(bool &is_unknown_input_shape); | 45 | + const std::vector<gert::Tensor> &GetInputTensors(bool &is_unknown_input_shape); |
| 45 | UserGraph GetUserGraph() const; | 46 | UserGraph GetUserGraph() const; |
| 46 | private: | 47 | private: |
| 47 | bool HasNext(const ExecutionPoint &ep) const; | 48 | bool HasNext(const ExecutionPoint &ep) const; |
| @@ -54,7 +55,7 @@ class ExecutionOrder { | |||
| 54 | std::mutex mutex_; | 55 | std::mutex mutex_; |
| 55 | std::vector<std::unique_ptr<ExecutionPoint>> slice_graphs_; | 56 | std::vector<std::unique_ptr<ExecutionPoint>> slice_graphs_; |
| 56 | // todo add io relation between slicing graph later | 57 | // todo add io relation between slicing graph later |
| 57 | - std::vector<Tensor> graph_inputs_; | 58 | + std::vector<gert::Tensor> graph_inputs_; |
| 58 | bool is_unknown_input_shape_; | 59 | bool is_unknown_input_shape_; |
| 59 | friend class ExecutionOrderUtil; | 60 | friend class ExecutionOrderUtil; |
| 60 | }; | 61 | }; |
| @@ -11,10 +11,11 @@ | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | -#include "debug/ge_log.h" | 14 | +#include "framework/common/debug/ge_log.h" |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | + | ||
| 18 | 19 | ||
| 19 | 20 | ||
| 20 | 21 | ||
| @@ -18,7 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | -#include "common/checker.h" | 21 | + |
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | 24 | ||
| @@ -59,14 +59,14 @@ bool GuardCheckFuncCaller::Match(const vector<gert::Tensor> &inputs) const { | |||
| 59 | 59 | ||
| 60 | Status GuardCheckFuncCaller::LoadGuardCheckFunc(ComputeGraphPtr computeGraphPtr) { | 60 | Status GuardCheckFuncCaller::LoadGuardCheckFunc(ComputeGraphPtr computeGraphPtr) { |
| 61 | GELOGD("Start load guard check func"); | 61 | GELOGD("Start load guard check func"); |
| 62 | - std::string buffer; | 62 | + const std::string *buffer = ge::AttrUtils::GetStr(computeGraphPtr, kGuardCheckSoDataResult); |
| 63 | - if (!ge::AttrUtils::GetStr(computeGraphPtr, kGuardCheckSoDataResult, buffer)) { | 63 | + if ((buffer == nullptr) || buffer->empty()) { |
| 64 | GELOGE(ge::FAILED, "LoadGuardCheckFunc GetStr fail %s", kGuardCheckSoDataResult); | 64 | GELOGE(ge::FAILED, "LoadGuardCheckFunc GetStr fail %s", kGuardCheckSoDataResult); |
| 65 | return ge::FAILED; | 65 | return ge::FAILED; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | file_handle_ = static_cast<int32_t>(syscall(__NR_memfd_create, kGuardCheckSoName.c_str(), 0)); | 68 | file_handle_ = static_cast<int32_t>(syscall(__NR_memfd_create, kGuardCheckSoName.c_str(), 0)); |
| 69 | - const auto write_count = mmWrite(file_handle_, const_cast<char_t *>(buffer.c_str()), buffer.size()); | 69 | + const auto write_count = mmWrite(file_handle_, const_cast<char_t *>(buffer->c_str()), buffer->size()); |
| 70 | GE_ASSERT_TRUE(((write_count != EN_INVALID_PARAM) && (write_count != EN_ERROR)), "Write data failed, errno: %lld", | 70 | GE_ASSERT_TRUE(((write_count != EN_INVALID_PARAM) && (write_count != EN_ERROR)), "Write data failed, errno: %lld", |
| 71 | write_count); | 71 | write_count); |
| 72 | (void)lseek(static_cast<int32_t>(file_handle_), 0, SEEK_SET); | 72 | (void)lseek(static_cast<int32_t>(file_handle_), 0, SEEK_SET); |
| @@ -23,7 +23,7 @@ | |||
| 23 | do { \ | 23 | do { \ |
| 24 | bool tmp_ret = (exp); \ | 24 | bool tmp_ret = (exp); \ |
| 25 | if (!tmp_ret) { \ | 25 | if (!tmp_ret) { \ |
| 26 | - std::vector<Tensor> error_outputs; \ | 26 | + std::vector<gert::Tensor> error_outputs; \ |
| 27 | if ((tsk.callback) != nullptr) { \ | 27 | if ((tsk.callback) != nullptr) { \ |
| 28 | tsk.callback(ge::FAILED, error_outputs); \ | 28 | tsk.callback(ge::FAILED, error_outputs); \ |
| 29 | } \ | 29 | } \ |
| @@ -50,21 +50,21 @@ void PrepareOutputs(const ExecutionPoint &ep, std::vector<gert::Tensor> &outputs | |||
| 50 | } | 50 | } |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | -bool IsEnableBatchCpy(const std::vector<Tensor> &ge_tensors) { | 53 | +bool IsEnableBatchCpy(const std::vector<gert::Tensor> &inputs) { |
| 54 | std::string input_batch_cpy_str; | 54 | std::string input_batch_cpy_str; |
| 55 | (void)GetThreadLocalContext().GetOption(configure_option::INPUT_BATCH_CPY, input_batch_cpy_str); | 55 | (void)GetThreadLocalContext().GetOption(configure_option::INPUT_BATCH_CPY, input_batch_cpy_str); |
| 56 | - GELOGI("Get input_batch_cpy_str=%s, size of ge_tensors=%zu", input_batch_cpy_str.c_str(), ge_tensors.size()); | 56 | + GELOGI("Get input_batch_cpy_str=%s, size of inputs=%zu", input_batch_cpy_str.c_str(), inputs.size()); |
| 57 | - return (!input_batch_cpy_str.empty() && input_batch_cpy_str == "1" && ge_tensors.size() > 1); | 57 | + return (!input_batch_cpy_str.empty() && input_batch_cpy_str == "1" && inputs.size() > 1); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | // todo if host exec option, remember to handle | 60 | // todo if host exec option, remember to handle |
| 61 | -Status CopyHostInputsToDevice(UserGraphExecution &execution_task, Allocator *const allocator) { | 61 | +Status CopyHostInputsToDevice(UserGraphExecution &execution_task, Allocator *const allocator, |
| 62 | - auto &external_inputs = execution_task.external_inputs; | 62 | + std::vector<gert::Tensor> &device_gert_tensors) { |
| 63 | - auto &inputs = execution_task.rt_inputs; | 63 | + const auto *external_rt_inputs = execution_task.external_rt_inputs; |
| 64 | auto &inputs_memblocks = execution_task.inputs_memblocks; | 64 | auto &inputs_memblocks = execution_task.inputs_memblocks; |
| 65 | - bool enable_input_batch_cpy = IsEnableBatchCpy(external_inputs); | 65 | + bool enable_input_batch_cpy = IsEnableBatchCpy(*external_rt_inputs); |
| 66 | - GE_ASSERT_SUCCESS(TensorTransUtils::TransHostTensorsToDeviceGertTensors(allocator, external_inputs, inputs, | 66 | + GE_ASSERT_SUCCESS(TensorTransUtils::TransHostGertTensorsToDevice(allocator, *external_rt_inputs, |
| 67 | - inputs_memblocks, enable_input_batch_cpy)); | 67 | + device_gert_tensors, inputs_memblocks, enable_input_batch_cpy)); |
| 68 | return SUCCESS; | 68 | return SUCCESS; |
| 69 | } | 69 | } |
| 70 | 70 | ||
| @@ -90,32 +90,32 @@ Status CopyHostInputToDeviceAfterSlice(std::vector<gert::Tensor> *inputs, std::v | |||
| 90 | return SUCCESS; | 90 | return SUCCESS; |
| 91 | } | 91 | } |
| 92 | } // namespace | 92 | } // namespace |
| 93 | -JitExecutor::JitExecutor(InnerSession &inner_session, UserGraphExecutionQueue &task_queue, ExecutionOrder &order, | 93 | +JitExecutor::JitExecutor(GraphManager &graph_manager, UserGraphExecutionQueue &task_queue, ExecutionOrder &order, |
| 94 | CompileContext &compile_context, CompiledModelCache &cmc, std::mutex &mutex) | 94 | CompileContext &compile_context, CompiledModelCache &cmc, std::mutex &mutex) |
| 95 | - : inner_session_(inner_session), | 95 | + : graph_manager_(graph_manager), |
| 96 | task_queue_(task_queue), | 96 | task_queue_(task_queue), |
| 97 | order_(order), | 97 | order_(order), |
| 98 | compile_context_(compile_context), | 98 | compile_context_(compile_context), |
| 99 | cmc_(cmc), | 99 | cmc_(cmc), |
| 100 | mutex_(mutex) {} | 100 | mutex_(mutex) {} |
| 101 | 101 | ||
| 102 | -std::unique_ptr<JitExecutor> JitExecutor::Create(InnerSession &inner_session, UserGraphExecutionQueue &task_queue, | 102 | +std::unique_ptr<JitExecutor> JitExecutor::Create(GraphManager &graph_manager, UserGraphExecutionQueue &task_queue, |
| 103 | ExecutionOrder &order, CompileContext &compile_context, | 103 | ExecutionOrder &order, CompileContext &compile_context, |
| 104 | CompiledModelCache &cmc, std::mutex &mutex) { | 104 | CompiledModelCache &cmc, std::mutex &mutex) { |
| 105 | - auto jit = std::unique_ptr<JitExecutor>(new JitExecutor(inner_session, task_queue, order, compile_context, cmc, mutex)); | 105 | + auto jit = std::unique_ptr<JitExecutor>(new JitExecutor(graph_manager, task_queue, order, compile_context, cmc, mutex)); |
| 106 | GE_ASSERT_NOTNULL(jit); | 106 | GE_ASSERT_NOTNULL(jit); |
| 107 | 107 | ||
| 108 | // add rt context before create jix executor | 108 | // add rt context before create jix executor |
| 109 | jit.get()->device_id_ = static_cast<int32_t>(GetContext().DeviceId()); | 109 | jit.get()->device_id_ = static_cast<int32_t>(GetContext().DeviceId()); |
| 110 | GE_ASSERT_RT_OK(rtSetDevice(jit.get()->device_id_)); | 110 | GE_ASSERT_RT_OK(rtSetDevice(jit.get()->device_id_)); |
| 111 | - GELOGI("Set device, session id %lu,device id:%u.", inner_session.GetSessionId(), GetContext().DeviceId()); | 111 | + GELOGI("Set device, device id:%u.", GetContext().DeviceId()); |
| 112 | GE_ASSERT_RT_OK(rtStreamCreate(&(jit.get()->stream_), 0)); | 112 | GE_ASSERT_RT_OK(rtStreamCreate(&(jit.get()->stream_), 0)); |
| 113 | GE_ASSERT_RT_OK(rtStreamSetMode(jit.get()->stream_, kStopOnFailure)); | 113 | GE_ASSERT_RT_OK(rtStreamSetMode(jit.get()->stream_, kStopOnFailure)); |
| 114 | // prepare allocator | 114 | // prepare allocator |
| 115 | auto device_allocator = gert::AllocatorFactory::Create("usergraph", gert::kOnDeviceHbm); | 115 | auto device_allocator = gert::AllocatorFactory::Create("usergraph", gert::kOnDeviceHbm); |
| 116 | GE_ASSERT_NOTNULL(device_allocator); | 116 | GE_ASSERT_NOTNULL(device_allocator); |
| 117 | jit.get()->device_allocator_ = std::move(device_allocator); | 117 | jit.get()->device_allocator_ = std::move(device_allocator); |
| 118 | - GE_ASSERT_SUCCESS(inner_session.RegisterExternalAllocator(jit.get()->stream_, jit.get()->device_allocator_)); | 118 | + GE_ASSERT_SUCCESS(graph_manager.RegisterExternalAllocator(jit.get()->stream_, jit.get()->device_allocator_)); |
| 119 | // 对于Execute接口,子图间的output是jit内部给的,静态图场景且没有外置allocator时需要手动申请内存,上面的device_allocator是针对tf场景不考虑用户会外置allocator | 119 | // 对于Execute接口,子图间的output是jit内部给的,静态图场景且没有外置allocator时需要手动申请内存,上面的device_allocator是针对tf场景不考虑用户会外置allocator |
| 120 | auto jit_allocator = gert::AllocatorFactory::Create("usergraph", gert::kOnDeviceHbm); | 120 | auto jit_allocator = gert::AllocatorFactory::Create("usergraph", gert::kOnDeviceHbm); |
| 121 | GE_ASSERT_NOTNULL(jit_allocator); | 121 | GE_ASSERT_NOTNULL(jit_allocator); |
| @@ -129,13 +129,13 @@ Status JitExecutor::Finalize() { | |||
| 129 | // 在load graph之前外置allocator会导致load过程中去申请const、feature等内存,这就强制要求这个外置allocator的生命周期大于整个GE的生命周期,否则会在remove的时候释放const内存失败。所以不在JIT中外置allocator | 129 | // 在load graph之前外置allocator会导致load过程中去申请const、feature等内存,这就强制要求这个外置allocator的生命周期大于整个GE的生命周期,否则会在remove的时候释放const内存失败。所以不在JIT中外置allocator |
| 130 | auto sorted_geps_to_inner_graph_id = SortMapByValue(geps_to_inner_ge_graph_id_, false); | 130 | auto sorted_geps_to_inner_graph_id = SortMapByValue(geps_to_inner_ge_graph_id_, false); |
| 131 | for (const auto &gep_2_id : sorted_geps_to_inner_graph_id) { | 131 | for (const auto &gep_2_id : sorted_geps_to_inner_graph_id) { |
| 132 | - GELOGI("[Jit]RemoveGraph %u from session %u", gep_2_id.second, inner_session_.GetSessionId()); | 132 | + GELOGI("[Jit]RemoveGraph %u", gep_2_id.second); |
| 133 | - GE_ASSERT_SUCCESS(inner_session_.RemoveGraph(gep_2_id.second)); | 133 | + GE_ASSERT_SUCCESS(graph_manager_.RemoveGraph(gep_2_id.second)); |
| 134 | } | 134 | } |
| 135 | geps_to_inner_ge_graph_id_.clear(); | 135 | geps_to_inner_ge_graph_id_.clear(); |
| 136 | compiled_ge_graph_id_.clear(); | 136 | compiled_ge_graph_id_.clear(); |
| 137 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); | 137 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); |
| 138 | - GE_ASSERT_SUCCESS(inner_session_.UnregisterExternalAllocator(stream_)); | 138 | + GE_ASSERT_SUCCESS(graph_manager_.UnregisterExternalAllocator(stream_)); |
| 139 | device_allocator_ = nullptr; | 139 | device_allocator_ = nullptr; |
| 140 | external_allocator_ = nullptr; | 140 | external_allocator_ = nullptr; |
| 141 | GE_ASSERT_RT_OK(rtStreamDestroy(stream_)); | 141 | GE_ASSERT_RT_OK(rtStreamDestroy(stream_)); |
| @@ -143,24 +143,23 @@ Status JitExecutor::Finalize() { | |||
| 143 | return SUCCESS; | 143 | return SUCCESS; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | -Status JitExecutor::CompileGraph(UserGraphExecution &task) { | 146 | +Status JitExecutor::CompileGraph(UserGraphExecution &task, uint64_t session_id) { |
| 147 | ExecutionPoint *ep; | 147 | ExecutionPoint *ep; |
| 148 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); | 148 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); |
| 149 | std::vector<GeTensor> ge_tensors; | 149 | std::vector<GeTensor> ge_tensors; |
| 150 | - for (size_t i = 0U; i < task.external_inputs.size(); ++i) { | 150 | + GE_ASSERT_SUCCESS(TensorTransUtils::GertTensors2GeTensors(*task.external_rt_inputs, ge_tensors)); |
| 151 | - GE_ASSERT_SUCCESS(TensorTransUtils::TransTensorToGertTensor(task.external_inputs[i], task.rt_inputs[i])); | ||
| 152 | - ge_tensors.emplace_back(TensorAdapter::AsGeTensor(task.external_inputs[i])); | ||
| 153 | - } | ||
| 154 | GE_ASSERT_SUCCESS(order_.FirstPoint(ge_tensors, ep)); | 151 | GE_ASSERT_SUCCESS(order_.FirstPoint(ge_tensors, ep)); |
| 155 | GELOGD("Get EP[%ld] of USER_GRAPH[%u] for CompileGraph", ep->GetId(), task.user_graph_id); | 152 | GELOGD("Get EP[%ld] of USER_GRAPH[%u] for CompileGraph", ep->GetId(), task.user_graph_id); |
| 156 | 153 | ||
| 157 | - std::vector<gert::Tensor> tensors0 = std::move(task.rt_inputs); | 154 | + auto gep = ep->FindOrCreateGuarded(*task.external_rt_inputs); |
| 158 | - auto inputs = &tensors0; | ||
| 159 | - auto gep = ep->FindOrCreateGuarded(*inputs); | ||
| 160 | GE_ASSERT_NOTNULL(gep); | 155 | GE_ASSERT_NOTNULL(gep); |
| 161 | GELOGD("Get GEP[compiled_graph_id:%u] [compiled? %d] of EP[%ld] USER_GRAPH[%u].", gep->GetCompiledGraphId(), | 156 | GELOGD("Get GEP[compiled_graph_id:%u] [compiled? %d] of EP[%ld] USER_GRAPH[%u].", gep->GetCompiledGraphId(), |
| 162 | gep->Compiled(), ep->GetId(), task.user_graph_id); | 157 | gep->Compiled(), ep->GetId(), task.user_graph_id); |
| 163 | - GE_ASSERT_SUCCESS(Compile(task.external_inputs, gep)); | 158 | + std::vector<Tensor> tensors; |
| 159 | + for (auto ge_tensor : ge_tensors) { | ||
| 160 | + tensors.emplace_back(TensorAdapter::AsTensor(ge_tensor)); | ||
| 161 | + } | ||
| 162 | + GE_ASSERT_SUCCESS(Compile(tensors, gep, session_id)); | ||
| 164 | if (!ep->IsLast()) { | 163 | if (!ep->IsLast()) { |
| 165 | GELOGD("Get EP[%ld] of USER_GRAPH[%u] is not last, need compile whole graph", ep->GetId(), task.user_graph_id); | 164 | GELOGD("Get EP[%ld] of USER_GRAPH[%u] is not last, need compile whole graph", ep->GetId(), task.user_graph_id); |
| 166 | return ge::GE_GRAPH_NOT_BUILT; | 165 | return ge::GE_GRAPH_NOT_BUILT; |
| @@ -173,16 +172,11 @@ Status JitExecutor::LoadGraph(UserGraphExecution &task) { | |||
| 173 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); | 172 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); |
| 174 | rtStream_t const stream = (task.stream == nullptr) ? stream_ : task.stream; | 173 | rtStream_t const stream = (task.stream == nullptr) ? stream_ : task.stream; |
| 175 | std::vector<GeTensor> ge_tensors; | 174 | std::vector<GeTensor> ge_tensors; |
| 176 | - for (size_t i = 0U; i < task.external_inputs.size(); ++i) { | 175 | + GE_ASSERT_SUCCESS(TensorTransUtils::GertTensors2GeTensors(*task.external_rt_inputs, ge_tensors)); |
| 177 | - GE_ASSERT_SUCCESS(TensorTransUtils::TransTensorToGertTensor(task.external_inputs[i], task.rt_inputs[i])); | ||
| 178 | - ge_tensors.emplace_back(TensorAdapter::AsGeTensor(task.external_inputs[i])); | ||
| 179 | - } | ||
| 180 | GE_ASSERT_SUCCESS(order_.FirstPoint(ge_tensors, ep)); | 176 | GE_ASSERT_SUCCESS(order_.FirstPoint(ge_tensors, ep)); |
| 181 | GELOGD("Get EP[%ld] of USER_GRAPH[%u] for LoadGraph", ep->GetId(), task.user_graph_id); | 177 | GELOGD("Get EP[%ld] of USER_GRAPH[%u] for LoadGraph", ep->GetId(), task.user_graph_id); |
| 182 | 178 | ||
| 183 | - std::vector<gert::Tensor> tensors0 = std::move(task.rt_inputs); | 179 | + auto gep = ep->FindGuarded(*task.external_rt_inputs); |
| 184 | - auto inputs = &tensors0; | ||
| 185 | - auto gep = ep->FindGuarded(*inputs); | ||
| 186 | if (gep == nullptr || !gep->Compiled()) { | 180 | if (gep == nullptr || !gep->Compiled()) { |
| 187 | GELOGE(ge::FAILED, "Guarde is not exist or Compiled EP[%ld], USER_GRAPH[%u]", ep->GetId(), task.user_graph_id); | 181 | GELOGE(ge::FAILED, "Guarde is not exist or Compiled EP[%ld], USER_GRAPH[%u]", ep->GetId(), task.user_graph_id); |
| 188 | return FAILED; | 182 | return FAILED; |
| @@ -199,21 +193,20 @@ Status JitExecutor::LoadGraph(UserGraphExecution &task) { | |||
| 199 | Status JitExecutor::RunWithCallback(UserGraphExecution &&task) { | 193 | Status JitExecutor::RunWithCallback(UserGraphExecution &&task) { |
| 200 | ExecutionPoint *ep; | 194 | ExecutionPoint *ep; |
| 201 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); | 195 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); |
| 202 | - JIT_ASSERT_SUCCESS(CopyHostInputsToDevice(task, device_allocator_.get()), task); | 196 | + JIT_ASSERT_NOTNULL(task.external_rt_inputs, task); |
| 203 | - GE_MAKE_GUARD(free_input_mem, [&task]() { (void)FreeInputsAllocByJit(task.inputs_memblocks); }); | ||
| 204 | 197 | ||
| 205 | std::vector<GeTensor> ge_tensors; | 198 | std::vector<GeTensor> ge_tensors; |
| 206 | ep = order_.GetFirstPoint(); | 199 | ep = order_.GetFirstPoint(); |
| 207 | if (ep == nullptr) { | 200 | if (ep == nullptr) { |
| 208 | - ge_tensors.reserve(task.external_inputs.size()); | 201 | + JIT_ASSERT_SUCCESS(TensorTransUtils::GertTensors2GeTensors(*task.external_rt_inputs, ge_tensors), task); |
| 209 | - for (auto &input_tensor : task.external_inputs) { | ||
| 210 | - ge_tensors.emplace_back(TensorAdapter::AsGeTensor(input_tensor)); | ||
| 211 | - } | ||
| 212 | JIT_ASSERT_SUCCESS(order_.FirstPoint(ge_tensors, ep), task); | 202 | JIT_ASSERT_SUCCESS(order_.FirstPoint(ge_tensors, ep), task); |
| 213 | } | 203 | } |
| 214 | GELOGD("Get EP[%ld] of USER_GRAPH[%u]", ep->GetId(), task.user_graph_id); | 204 | GELOGD("Get EP[%ld] of USER_GRAPH[%u]", ep->GetId(), task.user_graph_id); |
| 215 | 205 | ||
| 216 | - std::vector<gert::Tensor> tensors0 = std::move(task.rt_inputs); | 206 | + std::vector<gert::Tensor> tensors0; |
| 207 | + GE_MAKE_GUARD(free_input_mem, [&task]() { (void)FreeInputsAllocByJit(task.inputs_memblocks); }); | ||
| 208 | + JIT_ASSERT_SUCCESS(CopyHostInputsToDevice(task, device_allocator_.get(), tensors0), task); | ||
| 209 | + | ||
| 217 | std::vector<gert::Tensor> tensors1; | 210 | std::vector<gert::Tensor> tensors1; |
| 218 | auto inputs = &tensors0; | 211 | auto inputs = &tensors0; |
| 219 | auto outputs = &tensors1; | 212 | auto outputs = &tensors1; |
| @@ -240,11 +233,11 @@ Status JitExecutor::RunWithCallback(UserGraphExecution &&task) { | |||
| 240 | GE_ASSERT_SUCCESS(CopyHostInputToDeviceAfterSlice(inputs, input_mem_block, device_allocator_)); | 233 | GE_ASSERT_SUCCESS(CopyHostInputToDeviceAfterSlice(inputs, input_mem_block, device_allocator_)); |
| 241 | } | 234 | } |
| 242 | } | 235 | } |
| 243 | - std::vector<Tensor> final_outputs; | ||
| 244 | JIT_ASSERT_RT_OK(rtStreamSynchronize(stream_), task); | 236 | JIT_ASSERT_RT_OK(rtStreamSynchronize(stream_), task); |
| 245 | - JIT_ASSERT_SUCCESS(TensorTransUtils::TransRtTensorToTensor(*outputs, final_outputs, true), task); | ||
| 246 | GE_CHECK_NOTNULL(task.callback); | 237 | GE_CHECK_NOTNULL(task.callback); |
| 247 | - task.callback(SUCCESS, final_outputs); | 238 | + std::vector<gert::Tensor> host_tensors; |
| 239 | + GE_ASSERT_SUCCESS(TensorTransUtils::TransGertTensorsToHost(*outputs, host_tensors)); | ||
| 240 | + task.callback(SUCCESS, host_tensors); | ||
| 248 | return SUCCESS; | 241 | return SUCCESS; |
| 249 | } | 242 | } |
| 250 | 243 | ||
| @@ -259,8 +252,9 @@ Status JitExecutor::Execute(UserGraphExecution &&task) { | |||
| 259 | const bool has_allocator = (ExternalAllocatorManager::GetExternalAllocator(stream) != nullptr); | 252 | const bool has_allocator = (ExternalAllocatorManager::GetExternalAllocator(stream) != nullptr); |
| 260 | 253 | ||
| 261 | std::vector<GeTensor> ge_tensors; | 254 | std::vector<GeTensor> ge_tensors; |
| 262 | - GE_ASSERT_SUCCESS(TensorTransUtils::TransRtTensorToTensor(*task.external_rt_inputs, task.external_inputs, true)); | 255 | + std::vector<Tensor> tensors; |
| 263 | - for (auto &input_tensor : task.external_inputs) { | 256 | + GE_ASSERT_SUCCESS(TensorTransUtils::TransRtTensorToTensor(*task.external_rt_inputs, tensors, true)); |
| 257 | + for (auto &input_tensor : tensors) { | ||
| 264 | ge_tensors.emplace_back(TensorAdapter::AsGeTensor(input_tensor)); | 258 | ge_tensors.emplace_back(TensorAdapter::AsGeTensor(input_tensor)); |
| 265 | } | 259 | } |
| 266 | GE_ASSERT_SUCCESS(order_.FirstPoint(ge_tensors, ep)); | 260 | GE_ASSERT_SUCCESS(order_.FirstPoint(ge_tensors, ep)); |
| @@ -284,8 +278,8 @@ Status JitExecutor::Execute(UserGraphExecution &&task) { | |||
| 284 | while (ep != nullptr) { | 278 | while (ep != nullptr) { |
| 285 | PrepareOutputs(*ep, *outputs, ge_tensors); | 279 | PrepareOutputs(*ep, *outputs, ge_tensors); |
| 286 | outputs = (ep->IsLast()) ? task.rt_outputs : outputs; | 280 | outputs = (ep->IsLast()) ? task.rt_outputs : outputs; |
| 287 | - const bool need_malloc_outputs = (!has_allocator && !ep->IsLast()); | 281 | + const bool need_malloc_outputs_local = (!has_allocator && !ep->IsLast()); |
| 288 | - GE_ASSERT_SUCCESS(ProcessAndExecuteGraphAsync(task, stream, *inputs, *outputs, ep, need_malloc_outputs)); | 282 | + GE_ASSERT_SUCCESS(ProcessAndExecuteGraphAsync(task, stream, *inputs, *outputs, ep, need_malloc_outputs_local)); |
| 289 | for (size_t i = 0U; i < ge_tensors.size(); ++i) { | 283 | for (size_t i = 0U; i < ge_tensors.size(); ++i) { |
| 290 | GE_ASSERT_SUCCESS(TensorTransUtils::TransRtTensorToGeTensor((*outputs)[i], ge_tensors[i])); | 284 | GE_ASSERT_SUCCESS(TensorTransUtils::TransRtTensorToGeTensor((*outputs)[i], ge_tensors[i])); |
| 291 | } | 285 | } |
| @@ -312,7 +306,7 @@ Status JitExecutor::ExecuteFirstPoint(UserGraphExecution &task, rtStream_t const | |||
| 312 | Status JitExecutor::MallocOutputsForStatic(uint32_t guarded_ep_instance_id, const GuardedExecutionPoint *gep, | 306 | Status JitExecutor::MallocOutputsForStatic(uint32_t guarded_ep_instance_id, const GuardedExecutionPoint *gep, |
| 313 | std::vector<gert::Tensor> &outputs) { | 307 | std::vector<gert::Tensor> &outputs) { |
| 314 | CompiledGraphSummaryPtr summary{nullptr}; | 308 | CompiledGraphSummaryPtr summary{nullptr}; |
| 315 | - GE_ASSERT_SUCCESS(inner_session_.GetCompiledGraphSummary(guarded_ep_instance_id, summary)); | 309 | + GE_ASSERT_SUCCESS(graph_manager_.GetCompiledGraphSummary(guarded_ep_instance_id, summary)); |
| 316 | GraphNodePtr graph_node = make_shared<GraphNode>(guarded_ep_instance_id); | 310 | GraphNodePtr graph_node = make_shared<GraphNode>(guarded_ep_instance_id); |
| 317 | graph_node->SetComputeGraph(gep->GetGraph()); | 311 | graph_node->SetComputeGraph(gep->GetGraph()); |
| 318 | // 只有静态的slice graph需要手动申请output内存,动态的ge内部会申请 | 312 | // 只有静态的slice graph需要手动申请output内存,动态的ge内部会申请 |
| @@ -322,7 +316,7 @@ Status JitExecutor::MallocOutputsForStatic(uint32_t guarded_ep_instance_id, cons | |||
| 322 | return SUCCESS; | 316 | return SUCCESS; |
| 323 | } | 317 | } |
| 324 | 318 | ||
| 325 | -Status JitExecutor::ProcessAndExecuteGraphAsync(UserGraphExecution &task, rtStream_t const stream, | 319 | +Status JitExecutor::ProcessAndExecuteGraphAsync(UserGraphExecution &task, const rtStream_t stream, |
| 326 | const std::vector<gert::Tensor> &inputs, | 320 | const std::vector<gert::Tensor> &inputs, |
| 327 | std::vector<gert::Tensor> &outputs, ExecutionPoint *ep, | 321 | std::vector<gert::Tensor> &outputs, ExecutionPoint *ep, |
| 328 | bool need_malloc_output) { | 322 | bool need_malloc_output) { |
| @@ -332,10 +326,11 @@ Status JitExecutor::ProcessAndExecuteGraphAsync(UserGraphExecution &task, rtStre | |||
| 332 | std::lock_guard<std::mutex> locker(mutex_); | 326 | std::lock_guard<std::mutex> locker(mutex_); |
| 333 | gep = ep->FindOrCreateGuarded(inputs); | 327 | gep = ep->FindOrCreateGuarded(inputs); |
| 334 | JIT_ASSERT_NOTNULL(gep, task); | 328 | JIT_ASSERT_NOTNULL(gep, task); |
| 335 | - GELOGD("Get GEP[compiled_graph_id:%u] [compiled? %d] of EP[%ld] USER_GRAPH[%u].", gep->GetCompiledGraphId(), | 329 | + GELOGD("Get GEP[compiled_graph_id:%u] [compiled? %d] of EP[%ld] USER_GRAPH[%u], session_id:%llu.", |
| 336 | - gep->Compiled(), ep->GetId(), task.user_graph_id); | 330 | + gep->GetCompiledGraphId(), gep->Compiled(), ep->GetId(), task.user_graph_id, task.session_id); |
| 337 | 331 | ||
| 338 | - JIT_ASSERT_SUCCESS(CompileAndLoad(inputs, gep, guarded_ep_instance_id, stream, task.load_options), task); | 332 | + JIT_ASSERT_SUCCESS(CompileAndLoad(inputs, gep, guarded_ep_instance_id, stream, task.load_options, task.session_id), |
| 333 | + task); | ||
| 339 | } | 334 | } |
| 340 | JIT_ASSERT_NOTNULL(gep, task); | 335 | JIT_ASSERT_NOTNULL(gep, task); |
| 341 | GELOGD("ExecuteGraphWithStreamAsync GEP[ins_id:%u] of EP[%ld] USER_GRAPH[%u].", guarded_ep_instance_id, | 336 | GELOGD("ExecuteGraphWithStreamAsync GEP[ins_id:%u] of EP[%ld] USER_GRAPH[%u].", guarded_ep_instance_id, |
| @@ -346,7 +341,7 @@ Status JitExecutor::ProcessAndExecuteGraphAsync(UserGraphExecution &task, rtStre | |||
| 346 | if (need_malloc_output) { | 341 | if (need_malloc_output) { |
| 347 | GE_ASSERT_SUCCESS(MallocOutputsForStatic(guarded_ep_instance_id, gep, outputs)); | 342 | GE_ASSERT_SUCCESS(MallocOutputsForStatic(guarded_ep_instance_id, gep, outputs)); |
| 348 | } | 343 | } |
| 349 | - JIT_ASSERT_SUCCESS(inner_session_.ExecuteGraphWithStreamAsync(guarded_ep_instance_id, stream, inputs, outputs), task); | 344 | + JIT_ASSERT_SUCCESS(graph_manager_.ExecuteGraphWithStreamAsync(guarded_ep_instance_id, stream, inputs, outputs), task); |
| 350 | return SUCCESS; | 345 | return SUCCESS; |
| 351 | } | 346 | } |
| 352 | 347 | ||
| @@ -364,21 +359,21 @@ Status JitExecutor::TryExecuteWithoutProcess(UserGraphExecution &task) { | |||
| 364 | if (iter != geps_to_inner_ge_graph_id_.end()) { | 359 | if (iter != geps_to_inner_ge_graph_id_.end()) { |
| 365 | GELOGD("Graph id:%u No need Execute with Jit process.", iter->second); | 360 | GELOGD("Graph id:%u No need Execute with Jit process.", iter->second); |
| 366 | rtStream_t const stream = (task.stream == nullptr) ? stream_ : task.stream; | 361 | rtStream_t const stream = (task.stream == nullptr) ? stream_ : task.stream; |
| 367 | - GE_ASSERT_SUCCESS(inner_session_.ExecuteGraphWithStreamAsync(iter->second, stream, *(task.external_rt_inputs), *(task.rt_outputs))); | 362 | + GE_ASSERT_SUCCESS(graph_manager_.ExecuteGraphWithStreamAsync(iter->second, stream, *(task.external_rt_inputs), *(task.rt_outputs))); |
| 368 | return SUCCESS; | 363 | return SUCCESS; |
| 369 | } | 364 | } |
| 370 | } | 365 | } |
| 371 | return ge::UNSUPPORTED; | 366 | return ge::UNSUPPORTED; |
| 372 | } | 367 | } |
| 373 | 368 | ||
| 374 | -Status JitExecutor::Compile(const std::vector<ge::Tensor> &inputs, GuardedExecutionPoint *gep) { | 369 | +Status JitExecutor::Compile(const std::vector<ge::Tensor> &inputs, GuardedExecutionPoint *gep, uint64_t session_id) { |
| 375 | std::lock_guard<std::mutex> locker(mutex_); | 370 | std::lock_guard<std::mutex> locker(mutex_); |
| 376 | if (!gep->Compiled()) { | 371 | if (!gep->Compiled()) { |
| 377 | auto instance_id = compile_context_.GenNewGraphId(); | 372 | auto instance_id = compile_context_.GenNewGraphId(); |
| 378 | GELOGI("Start to compile GEP[%u] for EP[%ld].", instance_id, gep->GetOwnerEp()->GetId()); | 373 | GELOGI("Start to compile GEP[%u] for EP[%ld].", instance_id, gep->GetOwnerEp()->GetId()); |
| 379 | GE_ASSERT_TRUE(geps_to_inner_ge_graph_id_.emplace(gep, instance_id).second); | 374 | GE_ASSERT_TRUE(geps_to_inner_ge_graph_id_.emplace(gep, instance_id).second); |
| 380 | 375 | ||
| 381 | - GE_ASSERT_SUCCESS(compile_context_.Compile(instance_id, gep->GetGraph(), inputs)); | 376 | + GE_ASSERT_SUCCESS(compile_context_.Compile(instance_id, gep->GetGraph(), inputs, session_id)); |
| 382 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); | 377 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); |
| 383 | compiled_ge_graph_id_.emplace_back(instance_id); | 378 | compiled_ge_graph_id_.emplace_back(instance_id); |
| 384 | GE_ASSERT_TRUE(gep->SetCompiled(instance_id, gep->GetGraph())); | 379 | GE_ASSERT_TRUE(gep->SetCompiled(instance_id, gep->GetGraph())); |
| @@ -387,7 +382,8 @@ Status JitExecutor::Compile(const std::vector<ge::Tensor> &inputs, GuardedExecut | |||
| 387 | } | 382 | } |
| 388 | 383 | ||
| 389 | Status JitExecutor::CompileAndLoad(const std::vector<gert::Tensor> &inputs, GuardedExecutionPoint *gep, | 384 | Status JitExecutor::CompileAndLoad(const std::vector<gert::Tensor> &inputs, GuardedExecutionPoint *gep, |
| 390 | - uint32_t &instance_id, rtStream_t stream, const std::map<AscendString, AscendString> &load_options) { | 385 | + uint32_t &instance_id, const rtStream_t stream, const std::map<AscendString, AscendString> &load_options, |
| 386 | + uint64_t session_id) { | ||
| 391 | /* | 387 | /* |
| 392 | * | epm status | instance exists | instance does not exist | | 388 | * | epm status | instance exists | instance does not exist | |
| 393 | * |---------------|-----------------|--------------------| | 389 | * |---------------|-----------------|--------------------| |
| @@ -403,12 +399,14 @@ Status JitExecutor::CompileAndLoad(const std::vector<gert::Tensor> &inputs, Guar | |||
| 403 | // find instance just read mutex | 399 | // find instance just read mutex |
| 404 | if (!gep->Compiled()) { | 400 | if (!gep->Compiled()) { |
| 405 | instance_id = compile_context_.GenNewGraphId(); | 401 | instance_id = compile_context_.GenNewGraphId(); |
| 406 | - GELOGI("Start to compile GEP[%u] for EP[%ld].", instance_id, gep->GetOwnerEp()->GetId()); | 402 | + GELOGI("Start to compile GEP[%u] for EP[%ld], session_id: %llu.", instance_id, gep->GetOwnerEp()->GetId(), |
| 403 | + session_id); | ||
| 407 | GE_ASSERT_TRUE(geps_to_inner_ge_graph_id_.emplace(gep, instance_id).second); | 404 | GE_ASSERT_TRUE(geps_to_inner_ge_graph_id_.emplace(gep, instance_id).second); |
| 408 | 405 | ||
| 409 | std::map<std::string, std::string> options; | 406 | std::map<std::string, std::string> options; |
| 410 | GE_ASSERT_SUCCESS(cmc_.CreateKeyOptionForGuardedExecutionPoint(gep, options)); | 407 | GE_ASSERT_SUCCESS(cmc_.CreateKeyOptionForGuardedExecutionPoint(gep, options)); |
| 411 | - GE_ASSERT_SUCCESS(compile_context_.Compile(instance_id, gep->GetGraph(), inputs, options)); | 408 | + GE_ASSERT_SUCCESS(compile_context_.Compile(instance_id, gep->GetGraph(), inputs, options, session_id), |
| 409 | + "GEP:%u, EP:%ld, session_id:%llu", instance_id, gep->GetOwnerEp()->GetId(), session_id); | ||
| 412 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); | 410 | GE_ASSERT_RT_OK(rtSetDevice(device_id_)); |
| 413 | // todo 编译失败的时候,需要处理死锁问题 | 411 | // todo 编译失败的时候,需要处理死锁问题 |
| 414 | compiled_ge_graph_id_.emplace_back(instance_id); | 412 | compiled_ge_graph_id_.emplace_back(instance_id); |
| @@ -21,24 +21,31 @@ | |||
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | ||
| 24 | - | ||
| 25 | 24 | ||
| 26 | 25 | ||
| 27 | 26 | ||
| 28 | namespace ge { | 27 | namespace ge { |
| 29 | struct UserGraphExecution { | 28 | struct UserGraphExecution { |
| 30 | - UserGraphExecution(uint32_t graph_id, const std::vector<Tensor> &inputs, const RunAsyncCallback &callback_func) | 29 | + UserGraphExecution(uint32_t graph_id, const std::vector<gert::Tensor> &inputs, |
| 31 | - : user_graph_id(graph_id), external_inputs(inputs), callback(callback_func) { | 30 | + const RunAsyncCallbackV2 &callback_func, uint64_t session_id_param) |
| 32 | - rt_inputs.resize(external_inputs.size()); | 31 | + : user_graph_id(graph_id), callback(callback_func), session_id(session_id_param), external_rt_inputs(&inputs) { |
| 33 | - inputs_memblocks.resize(external_inputs.size()); | 32 | + inputs_memblocks.resize(inputs.size()); |
| 33 | + } | ||
| 34 | + // for RunGraphAsync | ||
| 35 | + UserGraphExecution(uint32_t graph_id, std::vector<gert::Tensor> &&inputs, | ||
| 36 | + const RunAsyncCallbackV2 &callback_func, uint64_t session_id_param) | ||
| 37 | + : user_graph_id(graph_id), callback(callback_func), session_id(session_id_param), | ||
| 38 | + input_tensors_holder(std::move(inputs)), external_rt_inputs(&input_tensors_holder) { | ||
| 39 | + inputs_memblocks.resize(input_tensors_holder.size()); | ||
| 34 | } | 40 | } |
| 35 | ~UserGraphExecution() = default; | 41 | ~UserGraphExecution() = default; |
| 36 | uint32_t user_graph_id; | 42 | uint32_t user_graph_id; |
| 37 | - std::vector<Tensor> external_inputs; | ||
| 38 | - std::vector<gert::Tensor> rt_inputs; | ||
| 39 | std::vector<MemBlock *> inputs_memblocks; | 43 | std::vector<MemBlock *> inputs_memblocks; |
| 40 | - RunAsyncCallback callback{nullptr}; | 44 | + RunAsyncCallbackV2 callback{nullptr}; |
| 41 | void *stream{nullptr}; | 45 | void *stream{nullptr}; |
| 46 | + uint64_t session_id; | ||
| 47 | + // 仅RunGraphAsync,inputs需要保存在input_tensors_holder中 | ||
| 48 | + std::vector<gert::Tensor> input_tensors_holder; | ||
| 42 | const std::vector<gert::Tensor> *external_rt_inputs{nullptr}; | 49 | const std::vector<gert::Tensor> *external_rt_inputs{nullptr}; |
| 43 | std::vector<gert::Tensor> *rt_outputs{nullptr}; | 50 | std::vector<gert::Tensor> *rt_outputs{nullptr}; |
| 44 | std::map<AscendString, AscendString> load_options; | 51 | std::map<AscendString, AscendString> load_options; |
| @@ -57,7 +64,7 @@ std::vector<std::pair<K, V>> SortMapByValue(const std::map<K, V> &input_map, boo | |||
| 57 | 64 | ||
| 58 | class JitExecutor { | 65 | class JitExecutor { |
| 59 | public: | 66 | public: |
| 60 | - static std::unique_ptr<JitExecutor> Create(InnerSession &inner_session, UserGraphExecutionQueue &task_queue, | 67 | + static std::unique_ptr<JitExecutor> Create(GraphManager &graph_manager, UserGraphExecutionQueue &task_queue, |
| 61 | ExecutionOrder &order, CompileContext &compile_context, | 68 | ExecutionOrder &order, CompileContext &compile_context, |
| 62 | CompiledModelCache &cmc, std::mutex &mutex); | 69 | CompiledModelCache &cmc, std::mutex &mutex); |
| 63 | 70 | ||
| @@ -67,17 +74,17 @@ class JitExecutor { | |||
| 67 | 74 | ||
| 68 | bool IsUserGraphNeedRebuild(); | 75 | bool IsUserGraphNeedRebuild(); |
| 69 | 76 | ||
| 70 | - Status CompileGraph(UserGraphExecution &task); | 77 | + Status CompileGraph(UserGraphExecution &task, uint64_t session_id); |
| 71 | 78 | ||
| 72 | Status LoadGraph(UserGraphExecution &task); | 79 | Status LoadGraph(UserGraphExecution &task); |
| 73 | 80 | ||
| 74 | Status Execute(UserGraphExecution &&task); | 81 | Status Execute(UserGraphExecution &&task); |
| 75 | private: | 82 | private: |
| 76 | - JitExecutor(InnerSession &inner_session, UserGraphExecutionQueue &task_queue, ExecutionOrder &order, | 83 | + JitExecutor(GraphManager &graph_manager, UserGraphExecutionQueue &task_queue, ExecutionOrder &order, |
| 77 | CompileContext &compile_context, CompiledModelCache &cmc, std::mutex &mutex); | 84 | CompileContext &compile_context, CompiledModelCache &cmc, std::mutex &mutex); |
| 78 | Status CompileAndLoad(const std::vector<gert::Tensor> &inputs, GuardedExecutionPoint *gep, uint32_t &instance_id, | 85 | Status CompileAndLoad(const std::vector<gert::Tensor> &inputs, GuardedExecutionPoint *gep, uint32_t &instance_id, |
| 79 | - rtStream_t stream, const std::map<AscendString, AscendString> &load_options); | 86 | + const rtStream_t stream, const std::map<AscendString, AscendString> &load_options, uint64_t session_id); |
| 80 | - Status Compile(const std::vector<ge::Tensor> &inputs, GuardedExecutionPoint *gep); | 87 | + Status Compile(const std::vector<ge::Tensor> &inputs, GuardedExecutionPoint *gep, uint64_t session_id); |
| 81 | Status ProcessAndExecuteGraphAsync(UserGraphExecution &task, rtStream_t const stream, | 88 | Status ProcessAndExecuteGraphAsync(UserGraphExecution &task, rtStream_t const stream, |
| 82 | const std::vector<gert::Tensor> &inputs, | 89 | const std::vector<gert::Tensor> &inputs, |
| 83 | std::vector<gert::Tensor> &outputs, ExecutionPoint *ep, | 90 | std::vector<gert::Tensor> &outputs, ExecutionPoint *ep, |
| @@ -89,7 +96,7 @@ class JitExecutor { | |||
| 89 | Status MallocOutputsForStatic(uint32_t guarded_ep_instance_id, const GuardedExecutionPoint *gep, | 96 | Status MallocOutputsForStatic(uint32_t guarded_ep_instance_id, const GuardedExecutionPoint *gep, |
| 90 | std::vector<gert::Tensor> &outputs); | 97 | std::vector<gert::Tensor> &outputs); |
| 91 | private: | 98 | private: |
| 92 | - InnerSession &inner_session_; | 99 | + GraphManager &graph_manager_; |
| 93 | UserGraphExecutionQueue &task_queue_; | 100 | UserGraphExecutionQueue &task_queue_; |
| 94 | ExecutionOrder &order_; | 101 | ExecutionOrder &order_; |
| 95 | CompileContext &compile_context_; | 102 | CompileContext &compile_context_; |
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | + | ||
| 15 | 16 | ||
| 16 | 17 | ||
| 17 | do { \ | 18 | do { \ |
| @@ -31,16 +32,18 @@ namespace ge { | |||
| 31 | namespace { | 32 | namespace { |
| 32 | std::string UserGraphExecutionToString(const std::unique_ptr<UserGraphExecution> &task) { | 33 | std::string UserGraphExecutionToString(const std::unique_ptr<UserGraphExecution> &task) { |
| 33 | std::stringstream ss; | 34 | std::stringstream ss; |
| 34 | - ss << "ExeTask inputs_size: [" << task->rt_inputs.size() << "],"; | 35 | + if ((task != nullptr) && (task->external_rt_inputs != nullptr)) { |
| 35 | - for (size_t i = 0U; i < task->external_inputs.size(); ++i) { | 36 | + ss << "ExeTask inputs_size: [" << task->external_rt_inputs->size() << "],"; |
| 36 | - auto ge_tensor = TensorAdapter::AsGeTensor(task->external_inputs[i]); | 37 | + for (size_t i = 0U; i < task->external_rt_inputs->size(); ++i) { |
| 37 | - ss << i << ":["; | 38 | + const auto &gert_tensor = task->external_rt_inputs->at(i); |
| 38 | - ss << "shape:[" << ge_tensor.GetTensorDesc().GetShape().ToString() << "],"; | 39 | + ss << i << ":["; |
| 39 | - ss << "origin_shape:[" << ge_tensor.GetTensorDesc().GetOriginShape().ToString() << "],"; | 40 | + ss << "shape:[" << formats::GertShapeToString(gert_tensor.GetStorageShape()) << "],"; |
| 40 | - ss << "format:[" << TypeUtils::FormatToSerialString(ge_tensor.GetTensorDesc().GetFormat()) << "],"; | 41 | + ss << "origin_shape:[" << formats::GertShapeToString(gert_tensor.GetOriginShape()) << "],"; |
| 41 | - ss << "origin_format:[" << TypeUtils::FormatToSerialString(ge_tensor.GetTensorDesc().GetOriginFormat()) << "],"; | 42 | + ss << "format:[" << TypeUtils::FormatToSerialString(gert_tensor.GetStorageFormat()) << "],"; |
| 42 | - ss << "dtype:[" << TypeUtils::DataTypeToSerialString(ge_tensor.GetTensorDesc().GetDataType()) << "]"; | 43 | + ss << "origin_format:[" << TypeUtils::FormatToSerialString(gert_tensor.GetOriginFormat()) << "],"; |
| 43 | - ss << "]"; | 44 | + ss << "dtype:[" << TypeUtils::DataTypeToSerialString(gert_tensor.GetDataType()) << "]"; |
| 45 | + ss << "]"; | ||
| 46 | + } | ||
| 44 | } | 47 | } |
| 45 | return ss.str(); | 48 | return ss.str(); |
| 46 | } | 49 | } |
| @@ -114,9 +117,8 @@ Status UserGraphControl::Finalize() { | |||
| 114 | } | 117 | } |
| 115 | 118 | ||
| 116 | Status UserGraphControl::AddGraphInstance() { | 119 | Status UserGraphControl::AddGraphInstance() { |
| 117 | - auto jit_executor = JitExecutor::Create(inner_session_, executions_, order_, compile_context_, cmc_, compile_mutex_); | 120 | + auto jit_executor = JitExecutor::Create(graph_manager_, executions_, order_, compile_context_, cmc_, compile_mutex_); |
| 118 | - JIT_CTRL_ASSERT_NOTNULL(jit_executor, "[Session:%lu][UserGraph:%u]Failed to create jit executor instance.", | 121 | + JIT_CTRL_ASSERT_NOTNULL(jit_executor, "[UserGraph:%u]Failed to create jit executor instance.", user_graph_id_); |
| 119 | - inner_session_.GetSessionId(), user_graph_id_); | ||
| 120 | JIT_CTRL_ASSERT_SUCCESS(jit_executor_pool_.AddJitExecutor(jit_executor)); | 122 | JIT_CTRL_ASSERT_SUCCESS(jit_executor_pool_.AddJitExecutor(jit_executor)); |
| 121 | const auto size = jit_executor_pool_.Size(); | 123 | const auto size = jit_executor_pool_.Size(); |
| 122 | GELOGD("[AddGraphInstance]Add new jit executor for graph[%u], total instance is %zu.", user_graph_id_, | 124 | GELOGD("[AddGraphInstance]Add new jit executor for graph[%u], total instance is %zu.", user_graph_id_, |
| @@ -140,7 +142,7 @@ std::map<AscendString, AscendString> UserGraphControl::GetLoadOptions() const { | |||
| 140 | return load_options_; | 142 | return load_options_; |
| 141 | } | 143 | } |
| 142 | 144 | ||
| 143 | -Status UserGraphControl::CompileCompleteGraph() { | 145 | +Status UserGraphControl::CompileCompleteGraph(uint64_t session_id) { |
| 144 | auto iter = user_graph_id_to_ins_id.find(user_graph_id_); | 146 | auto iter = user_graph_id_to_ins_id.find(user_graph_id_); |
| 145 | uint32_t instance_id = 0; | 147 | uint32_t instance_id = 0; |
| 146 | if (iter == user_graph_id_to_ins_id.end()) { | 148 | if (iter == user_graph_id_to_ins_id.end()) { |
| @@ -149,13 +151,13 @@ Status UserGraphControl::CompileCompleteGraph() { | |||
| 149 | GE_ASSERT_NOTNULL(new_graph); | 151 | GE_ASSERT_NOTNULL(new_graph); |
| 150 | GE_ASSERT_SUCCESS(GraphUtils::CopyComputeGraph(order_.GetUserGraph().compute_graph, new_graph)); | 152 | GE_ASSERT_SUCCESS(GraphUtils::CopyComputeGraph(order_.GetUserGraph().compute_graph, new_graph)); |
| 151 | Graph graph_to_add = GraphUtilsEx::CreateGraphFromComputeGraph(new_graph); | 153 | Graph graph_to_add = GraphUtilsEx::CreateGraphFromComputeGraph(new_graph); |
| 152 | - GE_ASSERT_SUCCESS(inner_session_.AddGraph(instance_id, graph_to_add)); | 154 | + GE_ASSERT_SUCCESS(graph_manager_.AddGraph(instance_id, graph_to_add, {}, domi::GetContext())); |
| 153 | user_graph_id_to_ins_id.emplace(user_graph_id_, instance_id); | 155 | user_graph_id_to_ins_id.emplace(user_graph_id_, instance_id); |
| 154 | } else { | 156 | } else { |
| 155 | instance_id = iter->second; | 157 | instance_id = iter->second; |
| 156 | } | 158 | } |
| 157 | GELOGD("CompileGraph by inner session user_graph_id:%u instance_id:%u.", user_graph_id_, instance_id); | 159 | GELOGD("CompileGraph by inner session user_graph_id:%u instance_id:%u.", user_graph_id_, instance_id); |
| 158 | - return inner_session_.CompileGraph(instance_id); | 160 | + return graph_manager_.CompileGraph(instance_id, session_id, {}); |
| 159 | } | 161 | } |
| 160 | 162 | ||
| 161 | /* | 163 | /* |
| @@ -165,25 +167,25 @@ Status UserGraphControl::CompileCompleteGraph() { | |||
| 165 | * 2、对于图的data节点为动态tensor:a.不会切图的情况下,生成对于的ins id直接进行整图编译,不进入jit流程(因为通过动态tensor构造的hint产生的符号以及guard没有意义,后面执行时还是要根据input重编译,因此也不需要进入jit流程) | 167 | * 2、对于图的data节点为动态tensor:a.不会切图的情况下,生成对于的ins id直接进行整图编译,不进入jit流程(因为通过动态tensor构造的hint产生的符号以及guard没有意义,后面执行时还是要根据input重编译,因此也不需要进入jit流程) |
| 166 | * b.会切图的情况下,生成对于的ins id直接进行整图编译,不进入jit流程 | 168 | * b.会切图的情况下,生成对于的ins id直接进行整图编译,不进入jit流程 |
| 167 | */ | 169 | */ |
| 168 | -Status UserGraphControl::CompileGraph() { | 170 | +Status UserGraphControl::CompileGraph(uint64_t session_id) { |
| 169 | bool is_unknown_input_shape{false}; | 171 | bool is_unknown_input_shape{false}; |
| 170 | - auto inputs = order_.GetInputTensors(is_unknown_input_shape); | 172 | + const auto &inputs = order_.GetInputTensors(is_unknown_input_shape); |
| 171 | if (is_unknown_input_shape) { | 173 | if (is_unknown_input_shape) { |
| 172 | GELOGI("CompileGraph dynamic graph %u need compile whole graph not by JIT.", user_graph_id_); | 174 | GELOGI("CompileGraph dynamic graph %u need compile whole graph not by JIT.", user_graph_id_); |
| 173 | - GE_ASSERT_SUCCESS(CompileCompleteGraph()); | 175 | + GE_ASSERT_SUCCESS(CompileCompleteGraph(session_id)); |
| 174 | return SUCCESS; | 176 | return SUCCESS; |
| 175 | } | 177 | } |
| 176 | - auto compile_task = MakeUnique<UserGraphExecution>(user_graph_id_, std::move(inputs), nullptr); | 178 | + auto compile_task = MakeUnique<UserGraphExecution>(user_graph_id_, inputs, nullptr, session_id); |
| 177 | GE_ASSERT_NOTNULL(compile_task); | 179 | GE_ASSERT_NOTNULL(compile_task); |
| 178 | 180 | ||
| 179 | GELOGI("CompileGraph USER_GRAPH[%u] with %s", user_graph_id_, UserGraphExecutionToString(compile_task).c_str()); | 181 | GELOGI("CompileGraph USER_GRAPH[%u] with %s", user_graph_id_, UserGraphExecutionToString(compile_task).c_str()); |
| 180 | auto jit_executor = jit_executor_pool_.GetIdleExecutor(); | 182 | auto jit_executor = jit_executor_pool_.GetIdleExecutor(); |
| 181 | JIT_CTRL_ASSERT_NOTNULL(jit_executor); | 183 | JIT_CTRL_ASSERT_NOTNULL(jit_executor); |
| 182 | - auto ret = jit_executor->CompileGraph(*compile_task); | 184 | + auto ret = jit_executor->CompileGraph(*compile_task, session_id); |
| 183 | jit_executor_pool_.BackToIdle(jit_executor); | 185 | jit_executor_pool_.BackToIdle(jit_executor); |
| 184 | if (ret == ge::GE_GRAPH_NOT_BUILT) { | 186 | if (ret == ge::GE_GRAPH_NOT_BUILT) { |
| 185 | GELOGI("CompileGraph graph %u need compile whole graph not by JIT.", user_graph_id_); | 187 | GELOGI("CompileGraph graph %u need compile whole graph not by JIT.", user_graph_id_); |
| 186 | - GE_ASSERT_SUCCESS(CompileCompleteGraph()); | 188 | + GE_ASSERT_SUCCESS(CompileCompleteGraph(session_id)); |
| 187 | } | 189 | } |
| 188 | return SUCCESS; | 190 | return SUCCESS; |
| 189 | } | 191 | } |
| @@ -192,25 +194,19 @@ CompiledGraphSummaryPtr UserGraphControl::GetCompiledGraphSummary() { | |||
| 192 | CompiledGraphSummaryPtr ret{nullptr}; | 194 | CompiledGraphSummaryPtr ret{nullptr}; |
| 193 | auto iter = user_graph_id_to_ins_id.find(user_graph_id_); | 195 | auto iter = user_graph_id_to_ins_id.find(user_graph_id_); |
| 194 | if (iter != user_graph_id_to_ins_id.end()) { | 196 | if (iter != user_graph_id_to_ins_id.end()) { |
| 195 | - GE_ASSERT_SUCCESS(inner_session_.GetCompiledGraphSummary(iter->second, ret)); | 197 | + GE_ASSERT_SUCCESS(graph_manager_.GetCompiledGraphSummary(iter->second, ret)); |
| 196 | return ret; | 198 | return ret; |
| 197 | } | 199 | } |
| 198 | 200 | ||
| 199 | bool is_unknown_input_shape{false}; | 201 | bool is_unknown_input_shape{false}; |
| 200 | - auto inputs = order_.GetInputTensors(is_unknown_input_shape); | 202 | + const auto &inputs = order_.GetInputTensors(is_unknown_input_shape); |
| 201 | if (is_unknown_input_shape) { | 203 | if (is_unknown_input_shape) { |
| 202 | GELOGI("dynamic graph %u skip.", user_graph_id_); | 204 | GELOGI("dynamic graph %u skip.", user_graph_id_); |
| 203 | return nullptr; | 205 | return nullptr; |
| 204 | } | 206 | } |
| 205 | 207 | ||
| 206 | GELOGI("GetCompiledGraphSummary USER_GRAPH[%u]", user_graph_id_); | 208 | GELOGI("GetCompiledGraphSummary USER_GRAPH[%u]", user_graph_id_); |
| 207 | - std::vector<gert::Tensor> rt_inputs; | 209 | + ExecutionPoint *ep = order_.GetFirstPoint(); |
| 208 | - rt_inputs.resize(inputs.size()); | ||
| 209 | - for (size_t i = 0U; i < inputs.size(); ++i) { | ||
| 210 | - GE_ASSERT_SUCCESS(TensorTransUtils::TransTensorToGertTensor(inputs[i], rt_inputs[i])); | ||
| 211 | - } | ||
| 212 | - ExecutionPoint *ep; | ||
| 213 | - ep = order_.GetFirstPoint(); | ||
| 214 | if (ep == nullptr) { | 210 | if (ep == nullptr) { |
| 215 | GELOGI("CompiledGraph is not exist. USER_GRAPH[%u]", user_graph_id_); | 211 | GELOGI("CompiledGraph is not exist. USER_GRAPH[%u]", user_graph_id_); |
| 216 | return nullptr; | 212 | return nullptr; |
| @@ -221,7 +217,7 @@ CompiledGraphSummaryPtr UserGraphControl::GetCompiledGraphSummary() { | |||
| 221 | return nullptr; | 217 | return nullptr; |
| 222 | } | 218 | } |
| 223 | 219 | ||
| 224 | - auto gep = ep->FindGuarded(rt_inputs); | 220 | + auto gep = ep->FindGuarded(inputs); |
| 225 | if (gep == nullptr || !gep->Compiled()) { | 221 | if (gep == nullptr || !gep->Compiled()) { |
| 226 | GELOGD("Guarde is not exist or Compiled"); | 222 | GELOGD("Guarde is not exist or Compiled"); |
| 227 | return nullptr; | 223 | return nullptr; |
| @@ -234,13 +230,13 @@ CompiledGraphSummaryPtr UserGraphControl::GetCompiledGraphSummary() { | |||
| 234 | 230 | ||
| 235 | Status UserGraphControl::LoadGraph(const std::map<AscendString, AscendString> &options, void *stream) { | 231 | Status UserGraphControl::LoadGraph(const std::map<AscendString, AscendString> &options, void *stream) { |
| 236 | bool is_unknown_input_shape{false}; | 232 | bool is_unknown_input_shape{false}; |
| 237 | - auto inputs = order_.GetInputTensors(is_unknown_input_shape); | 233 | + const auto &inputs = order_.GetInputTensors(is_unknown_input_shape); |
| 238 | if (is_unknown_input_shape) { | 234 | if (is_unknown_input_shape) { |
| 239 | GELOGI("CompileGraph dynamic graph %u skip.", user_graph_id_); | 235 | GELOGI("CompileGraph dynamic graph %u skip.", user_graph_id_); |
| 240 | SetLoadOptions(options); | 236 | SetLoadOptions(options); |
| 241 | return SUCCESS; | 237 | return SUCCESS; |
| 242 | } | 238 | } |
| 243 | - auto load_task = MakeUnique<UserGraphExecution>(user_graph_id_, std::move(inputs), nullptr); | 239 | + auto load_task = MakeUnique<UserGraphExecution>(user_graph_id_, inputs, nullptr, INVALID_SESSION_ID); |
| 244 | GE_ASSERT_NOTNULL(load_task); | 240 | GE_ASSERT_NOTNULL(load_task); |
| 245 | load_task->stream = stream; | 241 | load_task->stream = stream; |
| 246 | load_task->load_options = options; | 242 | load_task->load_options = options; |
| @@ -305,6 +301,15 @@ void UserGraphControl::ExecuteUserGraph() { | |||
| 305 | jit_futures_.emplace(std::move(fut)); | 301 | jit_futures_.emplace(std::move(fut)); |
| 306 | } | 302 | } |
| 307 | } | 303 | } |
| 304 | + | ||
| 305 | +bool UserGraphControl::GetCompiledFlag() const { | ||
| 306 | + return compiled_flag_; | ||
| 307 | +} | ||
| 308 | + | ||
| 309 | +void UserGraphControl::SetCompiledFlag(bool flag) { | ||
| 310 | + compiled_flag_ = flag; | ||
| 311 | +} | ||
| 312 | + | ||
| 308 | bool UserGraphControl::IsUserGraphNeedRebuild() { | 313 | bool UserGraphControl::IsUserGraphNeedRebuild() { |
| 309 | const auto is_need_rebuild = jit_executor_pool_.IsGraphNeedRebuild(); | 314 | const auto is_need_rebuild = jit_executor_pool_.IsGraphNeedRebuild(); |
| 310 | GELOGI("Graph instance id %u need rebuild : %d", user_graph_id_, is_need_rebuild); | 315 | GELOGI("Graph instance id %u need rebuild : %d", user_graph_id_, is_need_rebuild); |
| @@ -48,13 +48,13 @@ class JitExecutorPool { | |||
| 48 | class UserGraphControl { | 48 | class UserGraphControl { |
| 49 | public: | 49 | public: |
| 50 | UserGraphControl(uint32_t user_graph_id, const ComputeGraphPtr &graph, CompileContext &compile_context, | 50 | UserGraphControl(uint32_t user_graph_id, const ComputeGraphPtr &graph, CompileContext &compile_context, |
| 51 | - InnerSession &inner_session) | 51 | + GraphManager &graph_manager) |
| 52 | : user_graph_id_(user_graph_id), | 52 | : user_graph_id_(user_graph_id), |
| 53 | order_(UserGraph({user_graph_id, graph})), | 53 | order_(UserGraph({user_graph_id, graph})), |
| 54 | compile_context_(compile_context), | 54 | compile_context_(compile_context), |
| 55 | - inner_session_(inner_session), | 55 | + graph_manager_(graph_manager), |
| 56 | jit_exe_thread_pool_("jit_exe", kDefaultJitExeThreadPoolSize, true), | 56 | jit_exe_thread_pool_("jit_exe", kDefaultJitExeThreadPoolSize, true), |
| 57 | - cmc_(user_graph_id_, compile_context_, inner_session_) { | 57 | + cmc_(user_graph_id_, compile_context_, graph_manager_) { |
| 58 | auto ge_context = ge::GetThreadLocalContext(); | 58 | auto ge_context = ge::GetThreadLocalContext(); |
| 59 | user_graph_exe_thread_ = std::thread( | 59 | user_graph_exe_thread_ = std::thread( |
| 60 | [this, ge_context]() mutable { | 60 | [this, ge_context]() mutable { |
| @@ -73,23 +73,25 @@ class UserGraphControl { | |||
| 73 | Status AddGraphInstance(); | 73 | Status AddGraphInstance(); |
| 74 | void RunGraphAsync(std::unique_ptr<UserGraphExecution> &task); | 74 | void RunGraphAsync(std::unique_ptr<UserGraphExecution> &task); |
| 75 | Status ExecuteGraphWithStreamAsync(std::unique_ptr<UserGraphExecution> task); | 75 | Status ExecuteGraphWithStreamAsync(std::unique_ptr<UserGraphExecution> task); |
| 76 | - Status CompileGraph(); | 76 | + Status CompileGraph(uint64_t session_id); |
| 77 | CompiledGraphSummaryPtr GetCompiledGraphSummary(); | 77 | CompiledGraphSummaryPtr GetCompiledGraphSummary(); |
| 78 | Status LoadGraph(const std::map<AscendString, AscendString> &options, void *stream); | 78 | Status LoadGraph(const std::map<AscendString, AscendString> &options, void *stream); |
| 79 | Status Finalize(); | 79 | Status Finalize(); |
| 80 | bool IsUserGraphNeedRebuild(); | 80 | bool IsUserGraphNeedRebuild(); |
| 81 | + bool GetCompiledFlag() const; | ||
| 82 | + void SetCompiledFlag(bool flag); | ||
| 81 | std::map<AscendString, AscendString> GetLoadOptions() const; | 83 | std::map<AscendString, AscendString> GetLoadOptions() const; |
| 82 | 84 | ||
| 83 | private: | 85 | private: |
| 84 | void StopQueue(); | 86 | void StopQueue(); |
| 85 | void ExecuteUserGraph(); | 87 | void ExecuteUserGraph(); |
| 86 | void SetLoadOptions(const std::map<AscendString, AscendString> &load_options); | 88 | void SetLoadOptions(const std::map<AscendString, AscendString> &load_options); |
| 87 | - Status CompileCompleteGraph(); | 89 | + Status CompileCompleteGraph(uint64_t session_id); |
| 88 | 90 | ||
| 89 | uint32_t user_graph_id_; | 91 | uint32_t user_graph_id_; |
| 90 | ExecutionOrder order_; | 92 | ExecutionOrder order_; |
| 91 | CompileContext &compile_context_; | 93 | CompileContext &compile_context_; |
| 92 | - InnerSession &inner_session_; | 94 | + GraphManager &graph_manager_; |
| 93 | std::mutex compile_mutex_; | 95 | std::mutex compile_mutex_; |
| 94 | 96 | ||
| 95 | std::mutex add_execution_mutex_; | 97 | std::mutex add_execution_mutex_; |
| @@ -107,6 +109,10 @@ class UserGraphControl { | |||
| 107 | std::map<uint32_t, uint32_t> user_graph_id_to_ins_id; | 109 | std::map<uint32_t, uint32_t> user_graph_id_to_ins_id; |
| 108 | // std::vector<std::unique_ptr<JitExecutor>> executors_; // 实例 | 110 | // std::vector<std::unique_ptr<JitExecutor>> executors_; // 实例 |
| 109 | CompiledModelCache cmc_; | 111 | CompiledModelCache cmc_; |
| 112 | + | ||
| 113 | + // set true only when Session::CompileGraph is called | ||
| 114 | + // only set or check in ge_api.cc | ||
| 115 | + bool compiled_flag_{false}; | ||
| 110 | }; | 116 | }; |
| 111 | } // namespace ge | 117 | } // namespace ge |
| 112 | 118 | ||
| @@ -15,19 +15,19 @@ | |||
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | namespace ge { | 17 | namespace ge { |
| 18 | - | 18 | +Status UserGraphsManager::AddGraph(uint32_t user_graph_id, const Graph &graph, |
| 19 | -Status UserGraphsManager::AddGraph(uint32_t user_graph_id, const Graph &graph, const std::map<std::string, std::string> &options) { | 19 | + const std::map<std::string, std::string> &options) { |
| 20 | if (!EnableSliceSchedule()) { | 20 | if (!EnableSliceSchedule()) { |
| 21 | - return inner_session_.AddGraph(user_graph_id, graph, options); | 21 | + return graph_manager_.AddGraph(user_graph_id, graph, options, domi::GetContext()); |
| 22 | } | 22 | } |
| 23 | auto compute_graph = GraphUtilsEx::GetComputeGraph(graph); | 23 | auto compute_graph = GraphUtilsEx::GetComputeGraph(graph); |
| 24 | GE_ASSERT_NOTNULL(compute_graph); | 24 | GE_ASSERT_NOTNULL(compute_graph); |
| 25 | SetLocalOmgContext(domi::GetContext()); | 25 | SetLocalOmgContext(domi::GetContext()); |
| 26 | - inner_session_.UpdateThreadContext(options); | 26 | + GetThreadLocalContext().SetGraphOption(options); |
| 27 | std::lock_guard<std::mutex> locker(user_graph_ctrl_mutex_); | 27 | std::lock_guard<std::mutex> locker(user_graph_ctrl_mutex_); |
| 28 | auto iter = ids_to_user_graph_ctrl_.find(user_graph_id); | 28 | auto iter = ids_to_user_graph_ctrl_.find(user_graph_id); |
| 29 | if (iter == ids_to_user_graph_ctrl_.end()) { | 29 | if (iter == ids_to_user_graph_ctrl_.end()) { |
| 30 | - auto user_graph_ctrl = MakeUnique<UserGraphControl>(user_graph_id, compute_graph, compile_context_, inner_session_); | 30 | + auto user_graph_ctrl = MakeUnique<UserGraphControl>(user_graph_id, compute_graph, compile_context_, graph_manager_); |
| 31 | GE_ASSERT_NOTNULL(user_graph_ctrl); | 31 | GE_ASSERT_NOTNULL(user_graph_ctrl); |
| 32 | GE_ASSERT_SUCCESS(user_graph_ctrl->AddGraphInstance()); | 32 | GE_ASSERT_SUCCESS(user_graph_ctrl->AddGraphInstance()); |
| 33 | ids_to_user_graph_ctrl_[user_graph_id] = std::move(user_graph_ctrl); | 33 | ids_to_user_graph_ctrl_[user_graph_id] = std::move(user_graph_ctrl); |
| @@ -37,19 +37,22 @@ Status UserGraphsManager::AddGraph(uint32_t user_graph_id, const Graph &graph, c | |||
| 37 | return SUCCESS; | 37 | return SUCCESS; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | -Status UserGraphsManager::BuildGraph(uint32_t user_graph_id, const std::vector<ge::Tensor> &inputs) const { | 40 | +Status UserGraphsManager::BuildGraph(uint32_t user_graph_id, const std::vector<GeTensor> &inputs, |
| 41 | + uint64_t session_id) const { | ||
| 41 | if (!EnableSliceSchedule()) { | 42 | if (!EnableSliceSchedule()) { |
| 42 | - return inner_session_.BuildGraph(user_graph_id, inputs); | 43 | + GeRootModelPtr ge_root_model; |
| 44 | + return graph_manager_.BuildGraph(user_graph_id, inputs, ge_root_model, session_id, true); | ||
| 43 | } | 45 | } |
| 44 | (void)user_graph_id; | 46 | (void)user_graph_id; |
| 45 | (void)inputs; | 47 | (void)inputs; |
| 46 | return SUCCESS; | 48 | return SUCCESS; |
| 47 | } | 49 | } |
| 48 | 50 | ||
| 49 | -Status UserGraphsManager::RunGraphAsync(uint32_t user_graph_id, const std::vector<Tensor> &inputs, | 51 | +Status UserGraphsManager::RunGraphAsync(uint32_t user_graph_id, std::vector<gert::Tensor> &&inputs, |
| 50 | - const RunAsyncCallback &callback) { | 52 | + uint64_t session_id, const RunAsyncCallbackV2 &callback) { |
| 53 | + | ||
| 51 | if (!EnableSliceSchedule()) { | 54 | if (!EnableSliceSchedule()) { |
| 52 | - return inner_session_.RunGraphAsync(user_graph_id, inputs, callback); | 55 | + return graph_manager_.RunGraphAsync(user_graph_id, std::move(inputs), session_id, callback); |
| 53 | } | 56 | } |
| 54 | UserGraphControl *user_graph_control = nullptr; | 57 | UserGraphControl *user_graph_control = nullptr; |
| 55 | { | 58 | { |
| @@ -59,7 +62,9 @@ Status UserGraphsManager::RunGraphAsync(uint32_t user_graph_id, const std::vecto | |||
| 59 | user_graph_control = iter->second.get(); | 62 | user_graph_control = iter->second.get(); |
| 60 | } | 63 | } |
| 61 | GE_ASSERT_NOTNULL(user_graph_control, "Failed to find user graph ctrl of graph[%u], session[]", user_graph_id); | 64 | GE_ASSERT_NOTNULL(user_graph_control, "Failed to find user graph ctrl of graph[%u], session[]", user_graph_id); |
| 62 | - auto exe_task = MakeUnique<UserGraphExecution>(user_graph_id, inputs, callback); | 65 | + |
| 66 | + auto exe_task = MakeUnique<UserGraphExecution>(user_graph_id, std::move(inputs), callback, session_id); | ||
| 67 | + GE_ASSERT_NOTNULL(exe_task); | ||
| 63 | user_graph_control->RunGraphAsync(exe_task); | 68 | user_graph_control->RunGraphAsync(exe_task); |
| 64 | return SUCCESS; | 69 | return SUCCESS; |
| 65 | } | 70 | } |
| @@ -73,19 +78,19 @@ UserGraphControl* UserGraphsManager::GetUserGraphControl(uint32_t user_graph_id) | |||
| 73 | return user_graph_control; | 78 | return user_graph_control; |
| 74 | } | 79 | } |
| 75 | 80 | ||
| 76 | -Status UserGraphsManager::CompileGraph(uint32_t user_graph_id) { | 81 | +Status UserGraphsManager::CompileGraph(uint32_t user_graph_id, uint64_t session_id, const vector<ge::Tensor> &inputs) { |
| 77 | if (!EnableSliceSchedule()) { | 82 | if (!EnableSliceSchedule()) { |
| 78 | - return inner_session_.CompileGraph(user_graph_id); | 83 | + return graph_manager_.CompileGraph(user_graph_id, session_id, inputs); |
| 79 | } | 84 | } |
| 80 | UserGraphControl *user_graph_control = GetUserGraphControl(user_graph_id); | 85 | UserGraphControl *user_graph_control = GetUserGraphControl(user_graph_id); |
| 81 | GE_ASSERT_NOTNULL(user_graph_control, "Failed to find user graph ctrl of graph[%u], session[]", user_graph_id); | 86 | GE_ASSERT_NOTNULL(user_graph_control, "Failed to find user graph ctrl of graph[%u], session[]", user_graph_id); |
| 82 | - GE_ASSERT_SUCCESS(user_graph_control->CompileGraph()); | 87 | + GE_ASSERT_SUCCESS(user_graph_control->CompileGraph(session_id)); |
| 83 | return SUCCESS; | 88 | return SUCCESS; |
| 84 | } | 89 | } |
| 85 | 90 | ||
| 86 | Status UserGraphsManager::GetCompiledGraphSummary(uint32_t user_graph_id, CompiledGraphSummaryPtr &summary) { | 91 | Status UserGraphsManager::GetCompiledGraphSummary(uint32_t user_graph_id, CompiledGraphSummaryPtr &summary) { |
| 87 | if (!EnableSliceSchedule()) { | 92 | if (!EnableSliceSchedule()) { |
| 88 | - return inner_session_.GetCompiledGraphSummary(user_graph_id, summary); | 93 | + return graph_manager_.GetCompiledGraphSummary(user_graph_id, summary); |
| 89 | } | 94 | } |
| 90 | UserGraphControl *user_graph_control = GetUserGraphControl(user_graph_id); | 95 | UserGraphControl *user_graph_control = GetUserGraphControl(user_graph_id); |
| 91 | GE_ASSERT_NOTNULL(user_graph_control, "Failed to find user graph ctrl of graph[%u], session[]", user_graph_id); | 96 | GE_ASSERT_NOTNULL(user_graph_control, "Failed to find user graph ctrl of graph[%u], session[]", user_graph_id); |
| @@ -96,7 +101,7 @@ Status UserGraphsManager::GetCompiledGraphSummary(uint32_t user_graph_id, Compil | |||
| 96 | Status UserGraphsManager::LoadGraph(const uint32_t user_graph_id, const std::map<AscendString, AscendString> &options, | 101 | Status UserGraphsManager::LoadGraph(const uint32_t user_graph_id, const std::map<AscendString, AscendString> &options, |
| 97 | void *stream) { | 102 | void *stream) { |
| 98 | if (!EnableSliceSchedule()) { | 103 | if (!EnableSliceSchedule()) { |
| 99 | - return inner_session_.LoadGraph(user_graph_id, options, stream); | 104 | + return graph_manager_.LoadGraph(user_graph_id, options, stream); |
| 100 | } | 105 | } |
| 101 | UserGraphControl *user_graph_control = GetUserGraphControl(user_graph_id); | 106 | UserGraphControl *user_graph_control = GetUserGraphControl(user_graph_id); |
| 102 | GE_ASSERT_NOTNULL(user_graph_control, "Failed to find user graph ctrl of graph[%u], session[]", user_graph_id); | 107 | GE_ASSERT_NOTNULL(user_graph_control, "Failed to find user graph ctrl of graph[%u], session[]", user_graph_id); |
| @@ -106,17 +111,16 @@ Status UserGraphsManager::LoadGraph(const uint32_t user_graph_id, const std::map | |||
| 106 | 111 | ||
| 107 | Status UserGraphsManager::ExecuteGraphWithStreamAsync(uint32_t user_graph_id, void *stream, | 112 | Status UserGraphsManager::ExecuteGraphWithStreamAsync(uint32_t user_graph_id, void *stream, |
| 108 | const std::vector<gert::Tensor> &inputs, | 113 | const std::vector<gert::Tensor> &inputs, |
| 109 | - std::vector<gert::Tensor> &outputs) { | 114 | + std::vector<gert::Tensor> &outputs, uint64_t session_id) { |
| 110 | if (!EnableSliceSchedule()) { | 115 | if (!EnableSliceSchedule()) { |
| 111 | - return inner_session_.ExecuteGraphWithStreamAsync(user_graph_id, stream, inputs, outputs); | 116 | + return graph_manager_.ExecuteGraphWithStreamAsync(user_graph_id, stream, inputs, outputs); |
| 112 | } | 117 | } |
| 113 | UserGraphControl *user_graph_control = GetUserGraphControl(user_graph_id); | 118 | UserGraphControl *user_graph_control = GetUserGraphControl(user_graph_id); |
| 114 | GE_ASSERT_NOTNULL(user_graph_control, "Failed to find user graph ctrl of graph[%u], session[]", user_graph_id); | 119 | GE_ASSERT_NOTNULL(user_graph_control, "Failed to find user graph ctrl of graph[%u], session[]", user_graph_id); |
| 115 | - std::vector<Tensor> jit_input; | 120 | + auto exe_task = MakeUnique<UserGraphExecution>(user_graph_id, inputs, nullptr, session_id); |
| 116 | - auto exe_task = MakeUnique<UserGraphExecution>(user_graph_id, std::move(jit_input), nullptr); | ||
| 117 | GE_ASSERT_NOTNULL(exe_task); | 121 | GE_ASSERT_NOTNULL(exe_task); |
| 118 | exe_task->stream = stream; | 122 | exe_task->stream = stream; |
| 119 | - exe_task->external_rt_inputs = &inputs; | 123 | + exe_task->session_id = session_id; |
| 120 | exe_task->rt_outputs = &outputs; | 124 | exe_task->rt_outputs = &outputs; |
| 121 | exe_task->load_options = user_graph_control->GetLoadOptions(); | 125 | exe_task->load_options = user_graph_control->GetLoadOptions(); |
| 122 | GE_ASSERT_SUCCESS(user_graph_control->ExecuteGraphWithStreamAsync(std::move(exe_task))); | 126 | GE_ASSERT_SUCCESS(user_graph_control->ExecuteGraphWithStreamAsync(std::move(exe_task))); |
| @@ -130,7 +134,7 @@ Status UserGraphsManager::Finalize() { | |||
| 130 | 134 | ||
| 131 | Status UserGraphsManager::RemoveGraph(uint32_t user_graph_id) { | 135 | Status UserGraphsManager::RemoveGraph(uint32_t user_graph_id) { |
| 132 | if (!EnableSliceSchedule()) { | 136 | if (!EnableSliceSchedule()) { |
| 133 | - return inner_session_.RemoveGraph(user_graph_id); | 137 | + return graph_manager_.RemoveGraph(user_graph_id); |
| 134 | } | 138 | } |
| 135 | std::lock_guard<std::mutex> locker(user_graph_ctrl_mutex_); | 139 | std::lock_guard<std::mutex> locker(user_graph_ctrl_mutex_); |
| 136 | auto iter = ids_to_user_graph_ctrl_.find(user_graph_id); | 140 | auto iter = ids_to_user_graph_ctrl_.find(user_graph_id); |
| @@ -146,7 +150,7 @@ Status UserGraphsManager::RemoveGraph(uint32_t user_graph_id) { | |||
| 146 | 150 | ||
| 147 | bool UserGraphsManager::IsGraphNeedRebuild(uint32_t user_graph_id) { | 151 | bool UserGraphsManager::IsGraphNeedRebuild(uint32_t user_graph_id) { |
| 148 | if (!EnableSliceSchedule()) { | 152 | if (!EnableSliceSchedule()) { |
| 149 | - return inner_session_.IsGraphNeedRebuild(user_graph_id); | 153 | + return graph_manager_.IsGraphNeedRebuild(user_graph_id); |
| 150 | } | 154 | } |
| 151 | std::lock_guard<std::mutex> locker(user_graph_ctrl_mutex_); | 155 | std::lock_guard<std::mutex> locker(user_graph_ctrl_mutex_); |
| 152 | auto iter = ids_to_user_graph_ctrl_.find(user_graph_id); | 156 | auto iter = ids_to_user_graph_ctrl_.find(user_graph_id); |
| @@ -158,8 +162,28 @@ bool UserGraphsManager::IsGraphNeedRebuild(uint32_t user_graph_id) { | |||
| 158 | return iter->second->IsUserGraphNeedRebuild(); | 162 | return iter->second->IsUserGraphNeedRebuild(); |
| 159 | } | 163 | } |
| 160 | 164 | ||
| 165 | +Status UserGraphsManager::GetCompiledFlag(uint32_t user_graph_id, bool &flag) { | ||
| 166 | + if (!EnableSliceSchedule()) { | ||
| 167 | + return graph_manager_.GetCompiledFlag(user_graph_id, flag); | ||
| 168 | + } | ||
| 169 | + const UserGraphControl *user_graph_control = GetUserGraphControl(user_graph_id); | ||
| 170 | + GE_ASSERT_NOTNULL(user_graph_control); | ||
| 171 | + flag = user_graph_control->GetCompiledFlag(); | ||
| 172 | + return SUCCESS; | ||
| 173 | +} | ||
| 174 | + | ||
| 175 | +Status UserGraphsManager::SetCompiledFlag(uint32_t user_graph_id, bool flag) { | ||
| 176 | + if (!EnableSliceSchedule()) { | ||
| 177 | + return graph_manager_.SetCompiledFlag(user_graph_id, flag); | ||
| 178 | + } | ||
| 179 | + UserGraphControl *user_graph_control = GetUserGraphControl(user_graph_id); | ||
| 180 | + GE_ASSERT_NOTNULL(user_graph_control); | ||
| 181 | + user_graph_control->SetCompiledFlag(flag); | ||
| 182 | + return SUCCESS; | ||
| 183 | +} | ||
| 184 | + | ||
| 161 | Status UserGraphsManager::GetOmeContextByGraphId(const GraphId &graph_id, OmeContext &ome_context) const { | 185 | Status UserGraphsManager::GetOmeContextByGraphId(const GraphId &graph_id, OmeContext &ome_context) const { |
| 162 | - GE_ASSERT_SUCCESS(inner_session_.GetOmeContextByGraphId(graph_id, ome_context)); | 186 | + GE_ASSERT_SUCCESS(graph_manager_.GetOmeContextByGraphId(graph_id, ome_context)); |
| 163 | return SUCCESS; | 187 | return SUCCESS; |
| 164 | } | 188 | } |
| 165 | 189 | ||
| @@ -22,30 +22,34 @@ | |||
| 22 | namespace ge { | 22 | namespace ge { |
| 23 | class UserGraphsManager { | 23 | class UserGraphsManager { |
| 24 | public: | 24 | public: |
| 25 | - explicit UserGraphsManager(InnerSession &inner_session) | 25 | + explicit UserGraphsManager(GraphManager &graph_manager) |
| 26 | - : compile_context_(inner_session), inner_session_(inner_session) {} | 26 | + : compile_context_(graph_manager), graph_manager_(graph_manager) {} |
| 27 | Status AddGraph(uint32_t user_graph_id, const Graph &graph, const std::map<std::string, std::string> &options); | 27 | Status AddGraph(uint32_t user_graph_id, const Graph &graph, const std::map<std::string, std::string> &options); |
| 28 | - Status BuildGraph(uint32_t user_graph_id, const std::vector<ge::Tensor> &inputs) const; | 28 | + Status BuildGraph(uint32_t user_graph_id, const std::vector<GeTensor> &inputs, uint64_t session_id) const; |
| 29 | - Status RunGraphAsync(uint32_t user_graph_id, const std::vector<Tensor> &inputs, const RunAsyncCallback &callback); | 29 | + Status RunGraphAsync(uint32_t user_graph_id, std::vector<gert::Tensor> &&inputs, |
| 30 | + uint64_t session_id, const RunAsyncCallbackV2 &callback); | ||
| 30 | Status RemoveGraph(uint32_t user_graph_id); | 31 | Status RemoveGraph(uint32_t user_graph_id); |
| 31 | bool IsGraphNeedRebuild(uint32_t user_graph_id); | 32 | bool IsGraphNeedRebuild(uint32_t user_graph_id); |
| 33 | + Status GetCompiledFlag(uint32_t user_graph_id, bool &flag); | ||
| 34 | + Status SetCompiledFlag(uint32_t user_graph_id, bool flag); | ||
| 32 | Status Finalize(); | 35 | Status Finalize(); |
| 33 | - Status CompileGraph(uint32_t user_graph_id); | 36 | + Status CompileGraph(uint32_t user_graph_id, uint64_t session_id, const vector<ge::Tensor> &inputs); |
| 34 | Status GetCompiledGraphSummary(uint32_t user_graph_id, CompiledGraphSummaryPtr &summary); | 37 | Status GetCompiledGraphSummary(uint32_t user_graph_id, CompiledGraphSummaryPtr &summary); |
| 35 | Status LoadGraph(const uint32_t user_graph_id, const std::map<AscendString, AscendString> &options, | 38 | Status LoadGraph(const uint32_t user_graph_id, const std::map<AscendString, AscendString> &options, |
| 36 | void *stream); | 39 | void *stream); |
| 37 | Status ExecuteGraphWithStreamAsync(uint32_t user_graph_id, void *stream, const std::vector<gert::Tensor> &inputs, | 40 | Status ExecuteGraphWithStreamAsync(uint32_t user_graph_id, void *stream, const std::vector<gert::Tensor> &inputs, |
| 38 | - std::vector<gert::Tensor> &outputs); | 41 | + std::vector<gert::Tensor> &outputs, uint64_t session_id); |
| 39 | Status GetOmeContextByGraphId(const GraphId &graph_id, OmeContext &ome_context) const; | 42 | Status GetOmeContextByGraphId(const GraphId &graph_id, OmeContext &ome_context) const; |
| 40 | private: | 43 | private: |
| 41 | UserGraphControl* GetUserGraphControl(uint32_t user_graph_id); | 44 | UserGraphControl* GetUserGraphControl(uint32_t user_graph_id); |
| 42 | private: | 45 | private: |
| 43 | CompileContext compile_context_; | 46 | CompileContext compile_context_; |
| 44 | - InnerSession &inner_session_; | 47 | + GraphManager &graph_manager_; |
| 45 | 48 | ||
| 46 | std::mutex user_graph_ctrl_mutex_; | 49 | std::mutex user_graph_ctrl_mutex_; |
| 47 | std::map<uint32_t, std::unique_ptr<UserGraphControl>> ids_to_user_graph_ctrl_; | 50 | std::map<uint32_t, std::unique_ptr<UserGraphControl>> ids_to_user_graph_ctrl_; |
| 48 | }; | 51 | }; |
| 52 | +using UserGraphsManagerPtr = std::shared_ptr<UserGraphsManager>; | ||
| 49 | } // ge | 53 | } // ge |
| 50 | 54 | ||
| 51 | 55 | ||
| @@ -11,7 +11,6 @@ | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | - | ||
| 15 | 14 | ||
| 16 | 15 | ||
| 17 | 16 | ||
| @@ -14,26 +14,27 @@ | |||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | namespace ge { | 16 | namespace ge { |
| 17 | -void to_json(nlohmann::json &json_obj, const SliceGraphInfo &info) { | 17 | + |
| 18 | +static void to_json(nlohmann::json &json_obj, const SliceGraphInfo &info) { | ||
| 18 | json_obj = Json(); | 19 | json_obj = Json(); |
| 19 | json_obj[kSliceGraphInfoSliceGraphIDKeyName] = info.slice_graph_id; | 20 | json_obj[kSliceGraphInfoSliceGraphIDKeyName] = info.slice_graph_id; |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | -void to_json(nlohmann::json &json_obj, const SlicingResult &result) { | 23 | +static void to_json(nlohmann::json &json_obj, const SlicingResult &result) { |
| 23 | json_obj = Json(); | 24 | json_obj = Json(); |
| 24 | json_obj[kSlicingResultUserGraphKeyKeyName] = result.user_graph_key; | 25 | json_obj[kSlicingResultUserGraphKeyKeyName] = result.user_graph_key; |
| 25 | json_obj[kSlicingResultUserGraphIDKeyName] = result.user_graph_id; | 26 | json_obj[kSlicingResultUserGraphIDKeyName] = result.user_graph_id; |
| 26 | json_obj[kSlicingResultSliceGraphListKeyName] = result.slice_graph_infos; | 27 | json_obj[kSlicingResultSliceGraphListKeyName] = result.slice_graph_infos; |
| 27 | } | 28 | } |
| 28 | 29 | ||
| 29 | -void from_json(const nlohmann::json &json_obj, SliceGraphInfo &info) { | 30 | +static void from_json(const nlohmann::json &json_obj, SliceGraphInfo &info) { |
| 30 | auto iter = json_obj.find(kSliceGraphInfoSliceGraphIDKeyName); | 31 | auto iter = json_obj.find(kSliceGraphInfoSliceGraphIDKeyName); |
| 31 | if (iter != json_obj.end()) { | 32 | if (iter != json_obj.end()) { |
| 32 | info.slice_graph_id = iter.value().get<int64_t>(); | 33 | info.slice_graph_id = iter.value().get<int64_t>(); |
| 33 | } | 34 | } |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | -void from_json(const nlohmann::json &json_obj, SlicingResult &result) { | 37 | +static void from_json(const nlohmann::json &json_obj, SlicingResult &result) { |
| 37 | auto iter = json_obj.find(kSlicingResultUserGraphKeyKeyName); | 38 | auto iter = json_obj.find(kSlicingResultUserGraphKeyKeyName); |
| 38 | if (iter != json_obj.end()) { | 39 | if (iter != json_obj.end()) { |
| 39 | result.user_graph_key = iter.value().get<std::string>(); | 40 | result.user_graph_key = iter.value().get<std::string>(); |
| @@ -48,7 +49,7 @@ void from_json(const nlohmann::json &json_obj, SlicingResult &result) { | |||
| 48 | } | 49 | } |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | -Status ReadSlicingResultFromFile(const std::string &slicing_result_file, SlicingResult &slicing_result) { | 52 | +static Status ReadSlicingResultFromFile(const std::string &slicing_result_file, SlicingResult &slicing_result) { |
| 52 | nlohmann::json slicing_result_json_obj; | 53 | nlohmann::json slicing_result_json_obj; |
| 53 | GE_CHK_STATUS_RET(ModelCache::ReadJsonFile(slicing_result_file, slicing_result_json_obj), | 54 | GE_CHK_STATUS_RET(ModelCache::ReadJsonFile(slicing_result_file, slicing_result_json_obj), |
| 54 | "Failed to read json file file[%s].", slicing_result_file.c_str()); | 55 | "Failed to read json file file[%s].", slicing_result_file.c_str()); |
| @@ -62,7 +63,7 @@ Status ReadSlicingResultFromFile(const std::string &slicing_result_file, Slicing | |||
| 62 | return SUCCESS; | 63 | return SUCCESS; |
| 63 | } | 64 | } |
| 64 | 65 | ||
| 65 | -Status SaveSlicingResultToFile(const std::string &slicing_result_file, const SlicingResult &slicing_result) { | 66 | +static Status SaveSlicingResultToFile(const std::string &slicing_result_file, const SlicingResult &slicing_result) { |
| 66 | nlohmann::json json_obj; | 67 | nlohmann::json json_obj; |
| 67 | try { | 68 | try { |
| 68 | to_json(json_obj, slicing_result); | 69 | to_json(json_obj, slicing_result); |
| @@ -14,21 +14,21 @@ | |||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | namespace ge { | 16 | namespace ge { |
| 17 | -void from_json(const nlohmann::json &json_obj, GuardedExecutionPointInfo &info) { | 17 | +static void from_json(const nlohmann::json &json_obj, GuardedExecutionPointInfo &info) { |
| 18 | auto iter = json_obj.find(kGuardedExecutionPointInfoKeyName); | 18 | auto iter = json_obj.find(kGuardedExecutionPointInfoKeyName); |
| 19 | if (iter != json_obj.end()) { | 19 | if (iter != json_obj.end()) { |
| 20 | info.gep_graph_key = iter.value().get<std::string>(); | 20 | info.gep_graph_key = iter.value().get<std::string>(); |
| 21 | } | 21 | } |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | -void from_json(const nlohmann::json &json_obj, GuardedExecutionPointInfoList &list) { | 24 | +static void from_json(const nlohmann::json &json_obj, GuardedExecutionPointInfoList &list) { |
| 25 | auto iter = json_obj.find(kGuardedExecutionPointListKeyName); | 25 | auto iter = json_obj.find(kGuardedExecutionPointListKeyName); |
| 26 | if (iter != json_obj.end()) { | 26 | if (iter != json_obj.end()) { |
| 27 | list.gep_list = iter.value().get<std::vector<GuardedExecutionPointInfo>>(); | 27 | list.gep_list = iter.value().get<std::vector<GuardedExecutionPointInfo>>(); |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | -Status ReadGEPListFromFile(const std::string &gep_list_file, GuardedExecutionPointInfoList &gep_info_list) { | 31 | +static Status ReadGEPListFromFile(const std::string &gep_list_file, GuardedExecutionPointInfoList &gep_info_list) { |
| 32 | nlohmann::json json_obj; | 32 | nlohmann::json json_obj; |
| 33 | GE_CHK_STATUS_RET(ModelCache::ReadJsonFile(gep_list_file, json_obj), "Failed to read gep_list file[%s]", gep_list_file.c_str()); | 33 | GE_CHK_STATUS_RET(ModelCache::ReadJsonFile(gep_list_file, json_obj), "Failed to read gep_list file[%s]", gep_list_file.c_str()); |
| 34 | try { | 34 | try { |
| @@ -28,17 +28,17 @@ static Status TryLoadCompiledGraphFromCache(const ComputeGraphPtr &root_graph, C | |||
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | -void to_json(nlohmann::json &json_obj, const GuardedExecutionPointInfo &info) { | 31 | +static void to_json(nlohmann::json &json_obj, const GuardedExecutionPointInfo &info) { |
| 32 | json_obj = Json(); | 32 | json_obj = Json(); |
| 33 | json_obj[kGuardedExecutionPointInfoKeyName] = info.gep_graph_key; | 33 | json_obj[kGuardedExecutionPointInfoKeyName] = info.gep_graph_key; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | -void to_json(nlohmann::json &json_obj, const GuardedExecutionPointInfoList &list) { | 36 | +static void to_json(nlohmann::json &json_obj, const GuardedExecutionPointInfoList &list) { |
| 37 | json_obj = Json(); | 37 | json_obj = Json(); |
| 38 | json_obj[kGuardedExecutionPointListKeyName] = list.gep_list; | 38 | json_obj[kGuardedExecutionPointListKeyName] = list.gep_list; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | -Status SaveGepListJsonFile(const std::string &gep_list_file, const GuardedExecutionPointInfoList &gep_info_list) { | 41 | +static Status SaveGepListJsonFile(const std::string &gep_list_file, const GuardedExecutionPointInfoList &gep_info_list) { |
| 42 | nlohmann::json json_obj; | 42 | nlohmann::json json_obj; |
| 43 | try { | 43 | try { |
| 44 | to_json(json_obj, gep_info_list); // transfer gep_info_list to JSON object | 44 | to_json(json_obj, gep_info_list); // transfer gep_info_list to JSON object |
| @@ -51,7 +51,7 @@ Status SaveGepListJsonFile(const std::string &gep_list_file, const GuardedExecut | |||
| 51 | return SUCCESS; | 51 | return SUCCESS; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | -std::string GetCurTimeInNs() { | 54 | +static std::string GetCurTimeInNs() { |
| 55 | const auto cur_time = std::chrono::system_clock::now(); | 55 | const auto cur_time = std::chrono::system_clock::now(); |
| 56 | const auto cur_time_ns = std::chrono::time_point_cast<std::chrono::nanoseconds>(cur_time); | 56 | const auto cur_time_ns = std::chrono::time_point_cast<std::chrono::nanoseconds>(cur_time); |
| 57 | const auto value_ns = cur_time_ns.time_since_epoch().count(); | 57 | const auto value_ns = cur_time_ns.time_since_epoch().count(); |
| @@ -43,7 +43,7 @@ Status JitInferUtils::PrepareBeforeInferSymbol(const ComputeGraphPtr &graph, con | |||
| 43 | return SUCCESS; | 43 | return SUCCESS; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | -void ClearInferedNodesWithAllDataNodes(std::vector<NodePtr> &infered_nodes) { | 46 | +static void ClearInferedNodesWithAllDataNodes(std::vector<NodePtr> &infered_nodes) { |
| 47 | size_t data_node_num = 0; | 47 | size_t data_node_num = 0; |
| 48 | for (auto &node : infered_nodes) { | 48 | for (auto &node : infered_nodes) { |
| 49 | auto node_type = node->GetType(); | 49 | auto node_type = node->GetType(); |
| @@ -58,7 +58,7 @@ void ClearInferedNodesWithAllDataNodes(std::vector<NodePtr> &infered_nodes) { | |||
| 58 | } | 58 | } |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | -bool ParentNodeInfered(const NodePtr &node, std::vector<NodePtr> &infered_nodes) { | 61 | +static bool ParentNodeInfered(const NodePtr &node, std::vector<NodePtr> &infered_nodes) { |
| 62 | if (!node->GetInDataNodes().empty()) { | 62 | if (!node->GetInDataNodes().empty()) { |
| 63 | for (auto &in_data_node : node->GetInDataNodes()) { | 63 | for (auto &in_data_node : node->GetInDataNodes()) { |
| 64 | // check parents data nodes | 64 | // check parents data nodes |
| @@ -78,7 +78,7 @@ bool ParentNodeInfered(const NodePtr &node, std::vector<NodePtr> &infered_nodes) | |||
| 78 | return true; | 78 | return true; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | -void DeleteNodesWithoutParentNode(std::vector<NodePtr> &infered_nodes) { | 81 | +static void DeleteNodesWithoutParentNode(std::vector<NodePtr> &infered_nodes) { |
| 82 | // delete nodes whose parents node not infered | 82 | // delete nodes whose parents node not infered |
| 83 | for (auto it = infered_nodes.begin(); it != infered_nodes.end();) { | 83 | for (auto it = infered_nodes.begin(); it != infered_nodes.end();) { |
| 84 | if (!ParentNodeInfered(*it, infered_nodes)) { | 84 | if (!ParentNodeInfered(*it, infered_nodes)) { |
| @@ -11,7 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | -#include "graph/debug/ge_log.h" | 14 | +#include "framework/common/debug/ge_log.h" |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| @@ -21,7 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | namespace ge { | 22 | namespace ge { |
| 23 | 23 | ||
| 24 | -ComputeGraphPtr BinaryGraphBuilder::BuildGraph(const std::vector<NodePtr> &nodes, const std::string &name) { | 24 | +ComputeGraphPtr BinaryGraphBuilder::BuildGraph(const std::vector<NodePtr> &nodes, const std::string &name) const { |
| 25 | if (nodes.empty()) { | 25 | if (nodes.empty()) { |
| 26 | GELOGE(ge::FAILED, "nodes is empty, no need to build graph:%s", name.c_str()); | 26 | GELOGE(ge::FAILED, "nodes is empty, no need to build graph:%s", name.c_str()); |
| 27 | return nullptr; | 27 | return nullptr; |
| @@ -73,7 +73,7 @@ void BinaryGraphBuilder::RefreshNodeName(const ComputeGraphPtr &graph, const std | |||
| 73 | } | 73 | } |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | -Status BinaryGraphBuilder::GetIOMapping(BinaryGraphIOLinkage &io_link) { | 76 | +Status BinaryGraphBuilder::GetIOMapping(BinaryGraphIOLinkage &io_link) const { |
| 77 | GE_ASSERT_SUCCESS(GetIONodeMapping(io_link), "GetIOMapping failed! sliced graph:%s, remaining graph:%s", | 77 | GE_ASSERT_SUCCESS(GetIONodeMapping(io_link), "GetIOMapping failed! sliced graph:%s, remaining graph:%s", |
| 78 | io_link.sliced_graph->GetName().c_str(), io_link.remaining_graph->GetName().c_str()); | 78 | io_link.sliced_graph->GetName().c_str(), io_link.remaining_graph->GetName().c_str()); |
| 79 | 79 | ||
| @@ -82,14 +82,14 @@ Status BinaryGraphBuilder::GetIOMapping(BinaryGraphIOLinkage &io_link) { | |||
| 82 | return GRAPH_SUCCESS; | 82 | return GRAPH_SUCCESS; |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | -Status BinaryGraphBuilder::GetIONodeMapping(BinaryGraphIOLinkage &io_link) { | 85 | +Status BinaryGraphBuilder::GetIONodeMapping(BinaryGraphIOLinkage &io_link) const { |
| 86 | for (const auto &node : io_link.infered_nodes) { | 86 | for (const auto &node : io_link.infered_nodes) { |
| 87 | std::list<std::pair<std::string, uint32_t>> peer_data; | 87 | std::list<std::pair<std::string, uint32_t>> peer_data; |
| 88 | for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { | 88 | for (const auto &out_data_anchor : node->GetAllOutDataAnchors()) { |
| 89 | peer_data.clear(); | 89 | peer_data.clear(); |
| 90 | - const auto &peer_in_anchors = out_data_anchor->GetPeerInDataAnchors(); | 90 | + const auto &peer_in_anchors = out_data_anchor->GetPeerInDataAnchorsPtr(); |
| 91 | (void)std::for_each(peer_in_anchors.begin(), peer_in_anchors.end(), | 91 | (void)std::for_each(peer_in_anchors.begin(), peer_in_anchors.end(), |
| 92 | - [io_link, &peer_data](const InDataAnchorPtr &peer_in_anchor) { | 92 | + [io_link, &peer_data](const InDataAnchor *peer_in_anchor) { |
| 93 | if (std::count(io_link.infered_nodes.begin(), io_link.infered_nodes.end(), | 93 | if (std::count(io_link.infered_nodes.begin(), io_link.infered_nodes.end(), |
| 94 | peer_in_anchor->GetOwnerNode()) == 0) { | 94 | peer_in_anchor->GetOwnerNode()) == 0) { |
| 95 | peer_data.emplace_back(peer_in_anchor->GetOwnerNode()->GetName(), peer_in_anchor->GetIdx()); | 95 | peer_data.emplace_back(peer_in_anchor->GetOwnerNode()->GetName(), peer_in_anchor->GetIdx()); |
| @@ -115,7 +115,7 @@ Status BinaryGraphBuilder::GetIONodeMapping(BinaryGraphIOLinkage &io_link) { | |||
| 115 | Status BinaryGraphBuilder::GetIOIdxMapping(BinaryGraphIOLinkage &io_link) const { | 115 | Status BinaryGraphBuilder::GetIOIdxMapping(BinaryGraphIOLinkage &io_link) const { |
| 116 | auto netout_node = io_link.sliced_graph->GetOrUpdateNetOutputNode(); | 116 | auto netout_node = io_link.sliced_graph->GetOrUpdateNetOutputNode(); |
| 117 | GE_ASSERT_NOTNULL(netout_node); | 117 | GE_ASSERT_NOTNULL(netout_node); |
| 118 | - for (const auto &in_data_anchor : netout_node->GetAllInDataAnchors()) { | 118 | + for (const auto &in_data_anchor : netout_node->GetAllInDataAnchorsPtr()) { |
| 119 | const auto out_idx = in_data_anchor->GetIdx(); | 119 | const auto out_idx = in_data_anchor->GetIdx(); |
| 120 | auto out_data_anchor = in_data_anchor->GetPeerOutAnchor(); | 120 | auto out_data_anchor = in_data_anchor->GetPeerOutAnchor(); |
| 121 | GE_ASSERT_NOTNULL(out_data_anchor, | 121 | GE_ASSERT_NOTNULL(out_data_anchor, |
| @@ -174,7 +174,7 @@ bool BinaryGraphBuilder::CheckPeerNodeIsValid(const std::list<std::pair<std::str | |||
| 174 | return true; | 174 | return true; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | -Status BinaryGraphBuilder::ReplaceInputNode(BinaryGraphIOLinkage &io_link) { | 177 | +Status BinaryGraphBuilder::ReplaceInputNode(BinaryGraphIOLinkage &io_link) const { |
| 178 | auto netout_node = io_link.sliced_graph->GetOrUpdateNetOutputNode(); | 178 | auto netout_node = io_link.sliced_graph->GetOrUpdateNetOutputNode(); |
| 179 | GE_ASSERT_NOTNULL(netout_node); | 179 | GE_ASSERT_NOTNULL(netout_node); |
| 180 | auto in_data_nodes = io_link.remaining_graph->GetInputNodes(); | 180 | auto in_data_nodes = io_link.remaining_graph->GetInputNodes(); |
| @@ -221,7 +221,7 @@ OpDescPtr BinaryGraphBuilder::MakeNetOutputDesc(const BinaryGraphIOLinkage &io_l | |||
| 221 | GE_ASSERT_NOTNULL(net_output_desc); | 221 | GE_ASSERT_NOTNULL(net_output_desc); |
| 222 | auto netout_node = io_link.sliced_graph->GetOrUpdateNetOutputNode(); | 222 | auto netout_node = io_link.sliced_graph->GetOrUpdateNetOutputNode(); |
| 223 | GE_ASSERT_NOTNULL(netout_node); | 223 | GE_ASSERT_NOTNULL(netout_node); |
| 224 | - for (const auto &in_data_anchor : netout_node->GetAllInDataAnchors()) { | 224 | + for (const auto &in_data_anchor : netout_node->GetAllInDataAnchorsPtr()) { |
| 225 | auto peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); | 225 | auto peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); |
| 226 | GE_ASSERT_NOTNULL(peer_out_anchor, "GetPeerOutAnchor failed! out_node_idx:%d does not exist", in_data_anchor->GetIdx()); | 226 | GE_ASSERT_NOTNULL(peer_out_anchor, "GetPeerOutAnchor failed! out_node_idx:%d does not exist", in_data_anchor->GetIdx()); |
| 227 | auto out_node = peer_out_anchor->GetOwnerNode(); | 227 | auto out_node = peer_out_anchor->GetOwnerNode(); |
| @@ -269,7 +269,7 @@ Status BinaryGraphBuilder::RemoveOutputNode(const BinaryGraphIOLinkage &io_link, | |||
| 269 | return GRAPH_SUCCESS; | 269 | return GRAPH_SUCCESS; |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | -Status BinaryGraphBuilder::MergeSameInputNode(BinaryGraphIOLinkage &io_link) { | 272 | +Status BinaryGraphBuilder::MergeSameInputNode(BinaryGraphIOLinkage &io_link) const { |
| 273 | std::unordered_map<int64_t, std::vector<int64_t>> out_2_in_map; | 273 | std::unordered_map<int64_t, std::vector<int64_t>> out_2_in_map; |
| 274 | (void)std::for_each(io_link.out_idx_2_in_idxs.begin(), io_link.out_idx_2_in_idxs.end(), | 274 | (void)std::for_each(io_link.out_idx_2_in_idxs.begin(), io_link.out_idx_2_in_idxs.end(), |
| 275 | [&out_2_in_map](const std::pair<int64_t, int64_t> &idx_pair) { | 275 | [&out_2_in_map](const std::pair<int64_t, int64_t> &idx_pair) { |
| @@ -303,8 +303,8 @@ Status BinaryGraphBuilder::SetInputNodeDesc(const BinaryGraphIOLinkage &io_link) | |||
| 303 | auto in_data_nodes = io_link.remaining_graph->GetInputNodes(); | 303 | auto in_data_nodes = io_link.remaining_graph->GetInputNodes(); |
| 304 | for (const auto &in_data_node : in_data_nodes) { | 304 | for (const auto &in_data_node : in_data_nodes) { |
| 305 | GE_ASSERT_NOTNULL(in_data_node->GetOutDataAnchor(0)); | 305 | GE_ASSERT_NOTNULL(in_data_node->GetOutDataAnchor(0)); |
| 306 | - auto peer_in_anchors = in_data_node->GetOutDataAnchor(0)->GetPeerInDataAnchors(); | 306 | + auto peer_in_anchors = in_data_node->GetOutDataAnchor(0)->GetPeerInDataAnchorsPtr(); |
| 307 | - auto in_node = peer_in_anchors.at(0)->GetOwnerNode(); | 307 | + auto in_node = peer_in_anchors.at(0)->GetOwnerNodeBarePtr(); |
| 308 | auto in_node_desc = in_node->GetOpDesc()->GetInputDesc(static_cast<uint32_t>(peer_in_anchors.at(0)->GetIdx())); | 308 | auto in_node_desc = in_node->GetOpDesc()->GetInputDesc(static_cast<uint32_t>(peer_in_anchors.at(0)->GetIdx())); |
| 309 | auto op_desc = in_data_node->GetOpDesc(); | 309 | auto op_desc = in_data_node->GetOpDesc(); |
| 310 | GE_ASSERT_SUCCESS(op_desc->UpdateInputDesc(0U, in_node_desc), | 310 | GE_ASSERT_SUCCESS(op_desc->UpdateInputDesc(0U, in_node_desc), |
| @@ -42,16 +42,16 @@ class BinaryGraphBuilder { | |||
| 42 | BinaryGraphBuilder(BinaryGraphBuilder&&) = delete; | 42 | BinaryGraphBuilder(BinaryGraphBuilder&&) = delete; |
| 43 | BinaryGraphBuilder& operator=(BinaryGraphBuilder&&) = delete; | 43 | BinaryGraphBuilder& operator=(BinaryGraphBuilder&&) = delete; |
| 44 | 44 | ||
| 45 | - ComputeGraphPtr BuildGraph(const std::vector<NodePtr> &nodes, const std::string &name); | 45 | + ComputeGraphPtr BuildGraph(const std::vector<NodePtr> &nodes, const std::string &name) const; |
| 46 | - Status GetIOMapping(BinaryGraphIOLinkage &io_link); | 46 | + Status GetIOMapping(BinaryGraphIOLinkage &io_link) const; |
| 47 | // preserve the variable and const nodes in the original graph and repalce data node in remaining graph | 47 | // preserve the variable and const nodes in the original graph and repalce data node in remaining graph |
| 48 | - Status ReplaceInputNode(BinaryGraphIOLinkage &io_link); | 48 | + Status ReplaceInputNode(BinaryGraphIOLinkage &io_link) const; |
| 49 | // merge the output nodes corresponding to nodes with single output and multiple references in remaining graph | 49 | // merge the output nodes corresponding to nodes with single output and multiple references in remaining graph |
| 50 | - Status MergeSameInputNode(BinaryGraphIOLinkage &io_link); | 50 | + Status MergeSameInputNode(BinaryGraphIOLinkage &io_link) const; |
| 51 | Status SetInputNodeDesc(const BinaryGraphIOLinkage &io_link) const; | 51 | Status SetInputNodeDesc(const BinaryGraphIOLinkage &io_link) const; |
| 52 | private: | 52 | private: |
| 53 | void RefreshNodeName(const ComputeGraphPtr &graph, const std::string &name) const; | 53 | void RefreshNodeName(const ComputeGraphPtr &graph, const std::string &name) const; |
| 54 | - Status GetIONodeMapping(BinaryGraphIOLinkage &io_link); | 54 | + Status GetIONodeMapping(BinaryGraphIOLinkage &io_link) const; |
| 55 | Status GetIOIdxMapping(BinaryGraphIOLinkage &io_link) const; | 55 | Status GetIOIdxMapping(BinaryGraphIOLinkage &io_link) const; |
| 56 | Status FindIOIdxMappingAndSet(BinaryGraphIOLinkage &io_link, const std::string &out_node_name, | 56 | Status FindIOIdxMappingAndSet(BinaryGraphIOLinkage &io_link, const std::string &out_node_name, |
| 57 | const int32_t out_node_idx, const int32_t out_idx) const; | 57 | const int32_t out_node_idx, const int32_t out_idx) const; |
| @@ -9,7 +9,7 @@ | |||
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | -#include "graph/debug/ge_log.h" | 12 | +#include "framework/common/debug/ge_log.h" |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | 15 | ||
| @@ -0,0 +1,197 @@ | |||
| 1 | +/* Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 2 | + * This file is a part of the CANN Open Software. | ||
| 3 | + * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). | ||
| 4 | + * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 5 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 6 | + * 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 | + | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + | ||
| 32 | + | ||
| 33 | +namespace ge { | ||
| 34 | +GeSession::Impl::Impl(const std::map<std::string, std::string> &options) { | ||
| 35 | + const auto next_session_id = SessionIdManager::GetNextSessionId(); | ||
| 36 | + SessionPtr sessionPtr = MakeShared<InnerSession>(next_session_id, options); | ||
| 37 | + if (sessionPtr == nullptr) { | ||
| 38 | + GELOGE(GE_CLI_INIT_FAILED, "[Init][Create]GeSession failed"); | ||
| 39 | + return; | ||
| 40 | + } | ||
| 41 | + Status ret = sessionPtr->Initialize(); | ||
| 42 | + if (ret != SUCCESS) { | ||
| 43 | + GELOGE(ret, "Construct session failed, error code:%u.", ret); | ||
| 44 | + return; | ||
| 45 | + } | ||
| 46 | + session_id_ = next_session_id; | ||
| 47 | + inner_session_ = sessionPtr; | ||
| 48 | +} | ||
| 49 | + | ||
| 50 | +GeSession::Impl::~Impl() { | ||
| 51 | + if (inner_session_ == nullptr) { | ||
| 52 | + return; | ||
| 53 | + } | ||
| 54 | + Status ret = inner_session_->Finalize(); | ||
| 55 | + if (ret != SUCCESS) { | ||
| 56 | + GELOGE(ret, "[Finalize] session failed, error code:%u.", ret); | ||
| 57 | + return; | ||
| 58 | + } | ||
| 59 | + session_id_ = 0; | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +void GeSession::Impl::SetSessionId(uint64_t session_id) { | ||
| 63 | + session_id_ = session_id; | ||
| 64 | +} | ||
| 65 | + | ||
| 66 | +uint64_t GeSession::Impl::GetSessionId() const { | ||
| 67 | + return session_id_; | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +std::shared_ptr<InnerSession> GeSession::Impl::GetInnerSession() { | ||
| 71 | + return inner_session_; | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +Status GeSession::Impl::AddGraph(uint32_t graph_id, const Graph &graph, const std::map<std::string, std::string> &options) { | ||
| 75 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 76 | + return inner_session_->AddGraph(graph_id, graph, options); | ||
| 77 | +} | ||
| 78 | + | ||
| 79 | +Status GeSession::Impl::AddGraphWithCopy(uint32_t graph_id, const Graph &graph, const std::map<std::string, std::string> &options) { | ||
| 80 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 81 | + return inner_session_->AddGraphWithCopy(graph_id, graph, options); | ||
| 82 | +} | ||
| 83 | + | ||
| 84 | +Status GeSession::Impl::RemoveGraph(uint32_t graph_id) { | ||
| 85 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 86 | + return inner_session_->RemoveGraph(graph_id); | ||
| 87 | +} | ||
| 88 | + | ||
| 89 | +Status GeSession::Impl::CompileGraph(uint32_t graph_id, const std::vector<ge::Tensor> &inputs) { | ||
| 90 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 91 | + return inner_session_->CompileGraph(graph_id, inputs); | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +Status GeSession::Impl::LoadGraph(const uint32_t graph_id, const std::map<AscendString, AscendString> &options, void *stream) { | ||
| 95 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 96 | + return inner_session_->LoadGraph(graph_id, options, stream); | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | +Status GeSession::Impl::RunGraph(uint32_t graph_id, const std::vector<gert::Tensor> &inputs, std::vector<gert::Tensor> &outputs) { | ||
| 100 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 101 | + return inner_session_->RunGraph(graph_id, inputs, outputs); | ||
| 102 | +} | ||
| 103 | + | ||
| 104 | +Status GeSession::Impl::RunGraphAsync(uint32_t graph_id, std::vector<gert::Tensor> &&inputs, | ||
| 105 | + std::function<void(Status status, std::vector<gert::Tensor> &outputs)> callback) { | ||
| 106 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 107 | + return inner_session_->RunGraphAsync(graph_id, std::move(inputs), callback); | ||
| 108 | +} | ||
| 109 | + | ||
| 110 | +Status GeSession::Impl::RunGraphWithStreamAsync(uint32_t graph_id, const rtStream_t stream, | ||
| 111 | + const std::vector<gert::Tensor> &inputs, std::vector<gert::Tensor> &outputs) { | ||
| 112 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 113 | + return inner_session_->ExecuteGraphWithStreamAsync(graph_id, stream, inputs, outputs); | ||
| 114 | +} | ||
| 115 | + | ||
| 116 | +Status GeSession::Impl::RegisterCallBackFunc( | ||
| 117 | + const std::string &key, | ||
| 118 | + const std::function<Status(uint32_t, const std::map<AscendString, gert::Tensor> &)> &callback) { | ||
| 119 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 120 | + return inner_session_->RegisterCallBackFunc(key, callback); | ||
| 121 | +} | ||
| 122 | + | ||
| 123 | +bool GeSession::Impl::IsGraphNeedRebuild(uint32_t graph_id) { | ||
| 124 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 125 | + return inner_session_->IsGraphNeedRebuild(graph_id); | ||
| 126 | +} | ||
| 127 | + | ||
| 128 | +Status GeSession::Impl::AddDumpProperties(const DumpProperties &dump_properties) const { | ||
| 129 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 130 | + return inner_session_->AddDumpProperties(dump_properties); | ||
| 131 | +} | ||
| 132 | + | ||
| 133 | +Status GeSession::Impl::RemoveDumpProperties() const { | ||
| 134 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 135 | + return inner_session_->RemoveDumpProperties(); | ||
| 136 | +} | ||
| 137 | + | ||
| 138 | +Status GeSession::Impl::GetCompiledGraphSummary(uint32_t graph_id, CompiledGraphSummaryPtr &summary) { | ||
| 139 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 140 | + return inner_session_->GetCompiledGraphSummary(graph_id, summary); | ||
| 141 | +} | ||
| 142 | + | ||
| 143 | +Status GeSession::Impl::SetGraphConstMemoryBase(uint32_t graph_id, const void *const memory, size_t size) { | ||
| 144 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 145 | + return inner_session_->SetGraphConstMemoryBase(graph_id, memory, size); | ||
| 146 | +} | ||
| 147 | + | ||
| 148 | +Status GeSession::Impl::UpdateGraphFeatureMemoryBase(uint32_t graph_id, const void *const memory, size_t size) { | ||
| 149 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 150 | + return inner_session_->UpdateGraphFeatureMemoryBase(graph_id, memory, size); | ||
| 151 | +} | ||
| 152 | + | ||
| 153 | +Status GeSession::Impl::SetGraphFixedFeatureMemoryBase(uint32_t graph_id, MemoryType type, const void *const memory, size_t size) { | ||
| 154 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 155 | + return inner_session_->SetGraphFixedFeatureMemoryBase(graph_id, type, memory, size); | ||
| 156 | +} | ||
| 157 | + | ||
| 158 | +Status GeSession::Impl::UpdateGraphRefreshableFeatureMemoryBase(uint32_t graph_id, const void *const memory, size_t size) { | ||
| 159 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 160 | + return inner_session_->UpdateGraphRefreshableFeatureMemoryBase(graph_id, memory, size); | ||
| 161 | +} | ||
| 162 | + | ||
| 163 | +Status GeSession::Impl::RegisterExternalAllocator(const void *const stream, AllocatorPtr allocator) const { | ||
| 164 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 165 | + return inner_session_->RegisterExternalAllocator(stream, allocator); | ||
| 166 | +} | ||
| 167 | + | ||
| 168 | +Status GeSession::Impl::UnregisterExternalAllocator(const void * const stream) const { | ||
| 169 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 170 | + return inner_session_->UnregisterExternalAllocator(stream); | ||
| 171 | +} | ||
| 172 | + | ||
| 173 | +Status GeSession::Impl::GetRunGraphMode(uint32_t graph_id, RunGraphMode &mode) const { | ||
| 174 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 175 | + return inner_session_->GetRunGraphMode(graph_id, mode); | ||
| 176 | +} | ||
| 177 | + | ||
| 178 | +Status GeSession::Impl::SetRunGraphMode(uint32_t graph_id, const RunGraphMode &mode) { | ||
| 179 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 180 | + return inner_session_->SetRunGraphMode(graph_id, mode); | ||
| 181 | +} | ||
| 182 | + | ||
| 183 | +Status GeSession::Impl::GetCompiledModel(uint32_t graph_id, ModelBufferData &model_buffer) { | ||
| 184 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 185 | + return inner_session_->GetCompiledModel(graph_id, model_buffer); | ||
| 186 | +} | ||
| 187 | + | ||
| 188 | +bool GeSession::Impl::GetBuildFlag(uint32_t graph_id) const { | ||
| 189 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 190 | + return inner_session_->GetBuildFlag(graph_id); | ||
| 191 | +} | ||
| 192 | + | ||
| 193 | +bool GeSession::Impl::GetLoadFlag(uint32_t graph_id) const { | ||
| 194 | + GE_CHK_BOOL_RET_STATUS(inner_session_ != nullptr, FAILED, "inner_session is null (null inner_session pointer)"); | ||
| 195 | + return inner_session_->GetLoadFlag(graph_id); | ||
| 196 | +} | ||
| 197 | +} // namespace ge | ||
| @@ -0,0 +1,95 @@ | |||
| 1 | +/* Copyright (c) 2026 Huawei Technologies Co., Ltd. | ||
| 2 | + * This file is a part of the CANN Open Software. | ||
| 3 | + * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). | ||
| 4 | + * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| 5 | + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| 6 | + * 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 | + | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | +namespace ge { | ||
| 23 | + | ||
| 24 | +class GeSession::Impl { | ||
| 25 | + public: | ||
| 26 | + Impl(const std::map<std::string, std::string> &options); | ||
| 27 | + | ||
| 28 | + ~Impl(); | ||
| 29 | + | ||
| 30 | + void SetSessionId(uint64_t session_id); | ||
| 31 | + | ||
| 32 | + uint64_t GetSessionId() const; | ||
| 33 | + | ||
| 34 | + std::shared_ptr<InnerSession> GetInnerSession(); | ||
| 35 | + | ||
| 36 | + Status AddGraph(uint32_t graph_id, const Graph &graph, const std::map<std::string, std::string> &options); | ||
| 37 | + | ||
| 38 | + Status AddGraphWithCopy(uint32_t graph_id, const Graph &graph, const std::map<std::string, std::string> &options); | ||
| 39 | + | ||
| 40 | + Status RemoveGraph(uint32_t graph_id); | ||
| 41 | + | ||
| 42 | + Status CompileGraph(uint32_t graph_id, const std::vector<ge::Tensor> &inputs); | ||
| 43 | + | ||
| 44 | + Status LoadGraph(const uint32_t graph_id, const std::map<AscendString, AscendString> &options, void *stream); | ||
| 45 | + | ||
| 46 | + Status RunGraph(uint32_t graph_id, const std::vector<gert::Tensor> &inputs, std::vector<gert::Tensor> &outputs); | ||
| 47 | + | ||
| 48 | + Status RunGraphAsync(uint32_t graph_id, std::vector<gert::Tensor> &&inputs, | ||
| 49 | + std::function<void(Status status, std::vector<gert::Tensor> &outputs)> callback); | ||
| 50 | + | ||
| 51 | + Status RunGraphWithStreamAsync(uint32_t graph_id, const rtStream_t stream, | ||
| 52 | + const std::vector<gert::Tensor> &inputs, std::vector<gert::Tensor> &outputs); | ||
| 53 | + | ||
| 54 | + Status RegisterCallBackFunc( | ||
| 55 | + const std::string &key, | ||
| 56 | + const std::function<Status(uint32_t, const std::map<AscendString, gert::Tensor> &)> &callback); | ||
| 57 | + | ||
| 58 | + bool IsGraphNeedRebuild(uint32_t graph_id); | ||
| 59 | + | ||
| 60 | + Status AddDumpProperties(const DumpProperties &dump_properties) const; | ||
| 61 | + | ||
| 62 | + Status RemoveDumpProperties() const; | ||
| 63 | + | ||
| 64 | + Status GetCompiledGraphSummary(uint32_t graph_id, CompiledGraphSummaryPtr &summary); | ||
| 65 | + | ||
| 66 | + Status SetGraphConstMemoryBase(uint32_t graph_id, const void *const memory, size_t size); | ||
| 67 | + | ||
| 68 | + Status UpdateGraphFeatureMemoryBase(uint32_t graph_id, const void *const memory, size_t size); | ||
| 69 | + | ||
| 70 | + Status SetGraphFixedFeatureMemoryBase(uint32_t graph_id, MemoryType type, const void *const memory, size_t size); | ||
| 71 | + | ||
| 72 | + Status UpdateGraphRefreshableFeatureMemoryBase(uint32_t graph_id, const void *const memory, size_t size); | ||
| 73 | + | ||
| 74 | + Status RegisterExternalAllocator(const void *const stream, AllocatorPtr allocator) const; | ||
| 75 | + | ||
| 76 | + Status UnregisterExternalAllocator(const void * const stream) const; | ||
| 77 | + | ||
| 78 | + Status GetRunGraphMode(uint32_t graph_id, RunGraphMode &mode) const; | ||
| 79 | + | ||
| 80 | + Status SetRunGraphMode(uint32_t graph_id, const RunGraphMode &mode); | ||
| 81 | + | ||
| 82 | + Status GetCompiledModel(uint32_t graph_id, ModelBufferData &model_buffer); | ||
| 83 | + | ||
| 84 | + bool GetBuildFlag(uint32_t graph_id) const; | ||
| 85 | + | ||
| 86 | + bool GetLoadFlag(uint32_t graph_id) const; | ||
| 87 | + | ||
| 88 | + void UpdateGlobalSessionContext() const; | ||
| 89 | + private: | ||
| 90 | + uint64_t session_id_{0}; | ||
| 91 | + SessionPtr inner_session_; | ||
| 92 | +}; | ||
| 93 | +} // namespace ge | ||
| 94 | + | ||
| 95 | + | ||
Rruntime/v1/graph/load/model_manager/kernel_handles_manager/aicore_kernel_handles_manager.cc→base/common/kernel_handles_manager/aicore_kernel_handles_manager.cc+2-7
Rruntime/v1/graph/load/model_manager/kernel_handles_manager/aicore_kernel_handles_manager.h→base/common/kernel_handles_manager/aicore_kernel_handles_manager.h+6-5
Rruntime/v1/graph/load/model_manager/kernel_handles_manager/aicpu_kernel_handles_manager.cc→base/common/kernel_handles_manager/aicpu_kernel_handles_manager.cc+3-6
Rruntime/v1/graph/load/model_manager/kernel_handles_manager/aicpu_kernel_handles_manager.h→base/common/kernel_handles_manager/aicpu_kernel_handles_manager.h+6-5
Rruntime/v1/graph/load/model_manager/kernel_handles_manager/cust_aicpu_kernel_handles_manager.cc→base/common/kernel_handles_manager/cust_aicpu_kernel_handles_manager.cc+2-6
Rruntime/v1/graph/load/model_manager/kernel_handles_manager/cust_aicpu_kernel_handles_manager.h→base/common/kernel_handles_manager/cust_aicpu_kernel_handles_manager.h+6-5
Rruntime/v1/graph/load/model_manager/kernel_handles_manager/kernel_handle_utils.cc→base/common/kernel_handles_manager/kernel_handle_utils.cc+26-2
Rruntime/v1/graph/load/model_manager/kernel_handles_manager/kernel_handle_utils.h→base/common/kernel_handles_manager/kernel_handle_utils.h+2-1
Rruntime/v1/graph/load/model_manager/kernel_handles_manager/kernel_handles_manager.cc→base/common/kernel_handles_manager/kernel_handles_manager.cc+9-14
Rruntime/v1/graph/load/model_manager/kernel_handles_manager/kernel_handles_manager.h→base/common/kernel_handles_manager/kernel_handles_manager.h+7-8
Rbase/metadef/pkg_inc/register/opp_so_manager.h→graph_metadef/graph/normal_graph/custom_op_factory.cc+21-20
Rbase/metadef/pkg_inc/common/ge_common/debug/log.h→inc/graph_metadef/common/ge_common/debug/log.h+2-0
Rtests/parser/depends/graph/src/opp_so_manager_stub.cc→inc/graph_metadef/external/graph/custom_op.h+32-20
Rruntime/v1/graph/load/model_manager/data_inputer.cc→inc/graph_metadef/graph/custom_op_factory.h+18-16
Rbase/metadef/pkg_inc/register/op_ct_impl_registry_api.h→inc/graph_metadef/graph/custom_op_factory_impl.h+25-26
Rinc/graph_metadef/register/hidden_inputs_func_registry.h→inc/graph_metadef/register/core_num_utils.h+25-29
Rruntime/ops/update_model_param/ascend910B/CMakeLists.txt→runtime/ops/update_model_param/dav_2201/CMakeLists.txt+75-90
Rruntime/ops/update_model_param/ascend910B/update_model_param.h→runtime/ops/update_model_param/dav_2201/update_model_param.h+150-156
Rruntime/ops/update_model_param/ascend910B/update_model_param_tiling.h→runtime/ops/update_model_param/dav_2201/update_model_param_tiling.h+38-44
Rruntime/v1/graph/load/model_manager/model_kernel_handles_manager.cc→runtime/v1/graph/load/model_manager/kernel/model_kernel_handles_manager.cc+2-1
Rruntime/v1/graph/load/model_manager/model_kernel_handles_manager.h→runtime/v1/graph/load/model_manager/kernel/model_kernel_handles_manager.h+7-7
Rapi/acl/acl_op_executor/types/data_buffer_internal.h→runtime/v2/engine/custom/converter/custom_node_converter.h+7-14