| @@ -11,7 +11,7 @@ AlignTrailingComments: true | |||||
| AllowAllParametersOfDeclarationOnNextLine: true | AllowAllParametersOfDeclarationOnNextLine: true | ||||
| AllowShortBlocksOnASingleLine: false | AllowShortBlocksOnASingleLine: false | ||||
| AllowShortCaseLabelsOnASingleLine: false | AllowShortCaseLabelsOnASingleLine: false | ||||
| AllowShortFunctionsOnASingleLine: All | |||||
| AllowShortFunctionsOnASingleLine: Empty | |||||
| AllowShortIfStatementsOnASingleLine: true | AllowShortIfStatementsOnASingleLine: true | ||||
| AllowShortLoopsOnASingleLine: true | AllowShortLoopsOnASingleLine: true | ||||
| AlwaysBreakAfterDefinitionReturnType: None | AlwaysBreakAfterDefinitionReturnType: None | ||||
| @@ -88,11 +88,9 @@ else () | |||||
| find_module(hccl libhccl.so ${GE_LIB_PATH}) | find_module(hccl libhccl.so ${GE_LIB_PATH}) | ||||
| find_module(adump_server libadump_server.a ${GE_LIB_PATH}) | find_module(adump_server libadump_server.a ${GE_LIB_PATH}) | ||||
| find_module(runtime libruntime.so ${GE_LIB_PATH}) | find_module(runtime libruntime.so ${GE_LIB_PATH}) | ||||
| find_module(runtime_compile libruntime_compile.so ${GE_LIB_PATH}) | |||||
| find_module(resource libresource.so ${GE_LIB_PATH}) | find_module(resource libresource.so ${GE_LIB_PATH}) | ||||
| find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) | find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH}) | ||||
| find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${GE_LIB_PATH}) | find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${GE_LIB_PATH}) | ||||
| #find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH}) | |||||
| else() | else() | ||||
| find_module(slog libalog.so ${ASCEND_ATC_DIR}) | find_module(slog libalog.so ${ASCEND_ATC_DIR}) | ||||
| find_module(opt_feature libopt_feature.so ${ASCEND_ATC_DIR}) | find_module(opt_feature libopt_feature.so ${ASCEND_ATC_DIR}) | ||||
| @@ -108,7 +106,6 @@ else () | |||||
| elseif(PLATFORM STREQUAL "inference") | elseif(PLATFORM STREQUAL "inference") | ||||
| find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) | find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR}) | ||||
| find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) | find_module(runtime libruntime.so ${ASCEND_ACL_DIR}) | ||||
| find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) | |||||
| find_module(msprofiler_ext libmsprofiler.a ${ASCEND_ACL_DIR}) | find_module(msprofiler_ext libmsprofiler.a ${ASCEND_ACL_DIR}) | ||||
| if(PRODUCT STREQUAL "flr3") | if(PRODUCT STREQUAL "flr3") | ||||
| elseif(PRODUCT STREQUAL "flr1") | elseif(PRODUCT STREQUAL "flr1") | ||||
| @@ -120,10 +117,9 @@ else () | |||||
| endif() | endif() | ||||
| elseif(PLATFORM STREQUAL "all") | elseif(PLATFORM STREQUAL "all") | ||||
| find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) | find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) | ||||
| find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) | |||||
| find_module(runtime libruntime.so ${ASCEND_ATC_DIR}) | |||||
| find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${ASCEND_RUNTIME_DIR}) | find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${ASCEND_RUNTIME_DIR}) | ||||
| find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}) | |||||
| find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR}) | |||||
| find_module(ascend_hal_stub libascend_hal.so ${ASCEND_ATC_DIR}/stub) | |||||
| find_module(msprofiler_ext libmsprofiler.a ${ASCEND_ACL_DIR}) | find_module(msprofiler_ext libmsprofiler.a ${ASCEND_ACL_DIR}) | ||||
| else() | else() | ||||
| message(STATUS "PLATFORM param is invalid, should be train or inference, you choose nothing!") | message(STATUS "PLATFORM param is invalid, should be train or inference, you choose nothing!") | ||||
| @@ -10,12 +10,17 @@ if ((${CMAKE_INSTALL_PREFIX} STREQUAL /usr/local) OR | |||||
| message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | message(STATUS "No install prefix selected, default to ${CMAKE_INSTALL_PREFIX}.") | ||||
| endif() | endif() | ||||
| if (ENABLE_GITEE) | |||||
| set(REQ_URL "https://gitee.com/mirrors/gflags/repository/archive/v2.2.2.tar.gz") | |||||
| set(MD5 "") | |||||
| if (GE_PB_PKG) | |||||
| set(REQ_URL "${GE_PB_PKG}/libs/gflags/v2.2.2.tar.gz") | |||||
| set(MD5 "1a865b93bacfa963201af3f75b7bd64c") | |||||
| else() | else() | ||||
| set(REQ_URL "https://github.com/gflags/gflags/archive/v2.2.2.tar.gz") | |||||
| set(MD5 "") | |||||
| if (ENABLE_GITEE) | |||||
| set(REQ_URL "https://gitee.com/mirrors/gflags/repository/archive/v2.2.2.tar.gz") | |||||
| set(MD5 "") | |||||
| else() | |||||
| set(REQ_URL "https://github.com/gflags/gflags/archive/v2.2.2.tar.gz") | |||||
| set(MD5 "1a865b93bacfa963201af3f75b7bd64c") | |||||
| endif () | |||||
| endif () | endif () | ||||
| set (gflags_CXXFLAGS "-D_GLIBCXX_USE_CXX11_ABI=0 -Dgoogle=ascend_private") | set (gflags_CXXFLAGS "-D_GLIBCXX_USE_CXX11_ABI=0 -Dgoogle=ascend_private") | ||||
| @@ -109,26 +109,16 @@ endif () | |||||
| ################################################################## | ################################################################## | ||||
| set(EXECUTOR_SRC_LIST | set(EXECUTOR_SRC_LIST | ||||
| "analyzer/analyzer.cc" | |||||
| "common/dump/dump_manager.cc" | |||||
| "common/dump/dump_op.cc" | "common/dump/dump_op.cc" | ||||
| "common/dump/dump_properties.cc" | |||||
| "common/dump/exception_dumper.cc" | "common/dump/exception_dumper.cc" | ||||
| "common/dump/opdebug_register.cc" | "common/dump/opdebug_register.cc" | ||||
| "common/formats/format_transfers/format_transfer_transpose.cc" | |||||
| "common/formats/utils/formats_trans_utils.cc" | |||||
| "common/fp16_t.cc" | |||||
| "common/ge/op_tiling_manager.cc" | "common/ge/op_tiling_manager.cc" | ||||
| "common/ge/plugin_manager.cc" | "common/ge/plugin_manager.cc" | ||||
| "common/profiling/ge_profiling.cc" | "common/profiling/ge_profiling.cc" | ||||
| "common/profiling/profiling_manager.cc" | "common/profiling/profiling_manager.cc" | ||||
| "engine_manager/dnnengine_manager.cc" | |||||
| "executor/ge_executor.cc" | "executor/ge_executor.cc" | ||||
| "ge_local_engine/engine/host_cpu_engine.cc" | "ge_local_engine/engine/host_cpu_engine.cc" | ||||
| "graph/build/memory/var_mem_assign_util.cc" | "graph/build/memory/var_mem_assign_util.cc" | ||||
| "graph/common/bcast.cc" | |||||
| "graph/common/local_context.cc" | |||||
| "graph/common/omg_util.cc" | |||||
| "graph/execute/graph_execute.cc" | "graph/execute/graph_execute.cc" | ||||
| "graph/execute/model_executor.cc" | "graph/execute/model_executor.cc" | ||||
| "graph/load/graph_loader.cc" | "graph/load/graph_loader.cc" | ||||
| @@ -240,7 +230,6 @@ set(EXECUTOR_SRC_LIST | |||||
| "hybrid/node_executor/aicore/aicore_node_executor.cc" | "hybrid/node_executor/aicore/aicore_node_executor.cc" | ||||
| "hybrid/node_executor/aicore/aicore_op_task.cc" | "hybrid/node_executor/aicore/aicore_op_task.cc" | ||||
| "hybrid/node_executor/aicore/aicore_task_builder.cc" | "hybrid/node_executor/aicore/aicore_task_builder.cc" | ||||
| "hybrid/node_executor/aicore/aicore_task_compiler.cc" | |||||
| "hybrid/node_executor/aicpu/aicpu_ext_info.cc" | "hybrid/node_executor/aicpu/aicpu_ext_info.cc" | ||||
| "hybrid/node_executor/aicpu/aicpu_node_executor.cc" | "hybrid/node_executor/aicpu/aicpu_node_executor.cc" | ||||
| "hybrid/node_executor/compiledsubgraph/known_node_executor.cc" | "hybrid/node_executor/compiledsubgraph/known_node_executor.cc" | ||||
| @@ -254,11 +243,7 @@ set(EXECUTOR_SRC_LIST | |||||
| "hybrid/node_executor/rts/rts_node_task.cc" | "hybrid/node_executor/rts/rts_node_task.cc" | ||||
| "hybrid/node_executor/rts/rts_task_factory.cc" | "hybrid/node_executor/rts/rts_task_factory.cc" | ||||
| "hybrid/node_executor/task_context.cc" | "hybrid/node_executor/task_context.cc" | ||||
| "init/gelib.cc" | |||||
| "model/ge_model.cc" | |||||
| "model/ge_root_model.cc" | |||||
| "opskernel_manager/ops_kernel_builder_manager.cc" | "opskernel_manager/ops_kernel_builder_manager.cc" | ||||
| "opskernel_manager/ops_kernel_manager.cc" | |||||
| "single_op/single_op.cc" | "single_op/single_op.cc" | ||||
| "single_op/single_op_manager.cc" | "single_op/single_op_manager.cc" | ||||
| "single_op/single_op_model.cc" | "single_op/single_op_model.cc" | ||||
| @@ -274,32 +259,9 @@ set(EXECUTOR_SRC_LIST | |||||
| ################################################################## | ################################################################## | ||||
| set(COMPILER_SRC_LIST | set(COMPILER_SRC_LIST | ||||
| "analyzer/analyzer.cc" | "analyzer/analyzer.cc" | ||||
| "common/dump/dump_manager.cc" | |||||
| "common/dump/dump_op.cc" | "common/dump/dump_op.cc" | ||||
| "common/dump/dump_properties.cc" | |||||
| "common/formats/format_transfers/datatype_transfer.cc" | |||||
| "common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc" | |||||
| "common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc" | |||||
| "common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc" | |||||
| "common/formats/format_transfers/format_transfer_fractal_nz.cc" | |||||
| "common/formats/format_transfers/format_transfer_fractal_z.cc" | |||||
| "common/formats/format_transfers/format_transfer_fractal_zz.cc" | |||||
| "common/formats/format_transfers/format_transfer_fracz_hwcn.cc" | |||||
| "common/formats/format_transfers/format_transfer_fracz_nchw.cc" | |||||
| "common/formats/format_transfers/format_transfer_fracz_nhwc.cc" | |||||
| "common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc" | |||||
| "common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc" | |||||
| "common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc" | |||||
| "common/formats/format_transfers/format_transfer_nchw_fz_c04.cc" | |||||
| "common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc" | |||||
| "common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc" | |||||
| "common/formats/format_transfers/format_transfer_transpose.cc" | |||||
| "common/formats/formats.cc" | |||||
| "common/formats/utils/formats_trans_utils.cc" | |||||
| "common/fp16_t.cc" | |||||
| "common/ge/op_tiling_manager.cc" | "common/ge/op_tiling_manager.cc" | ||||
| "common/ge/plugin_manager.cc" | "common/ge/plugin_manager.cc" | ||||
| "common/helper/model_cache_helper.cc" | |||||
| "common/profiling/profiling_manager.cc" | "common/profiling/profiling_manager.cc" | ||||
| "engine_manager/dnnengine_manager.cc" | "engine_manager/dnnengine_manager.cc" | ||||
| "ge_local_engine/engine/host_cpu_engine.cc" | "ge_local_engine/engine/host_cpu_engine.cc" | ||||
| @@ -322,10 +284,6 @@ set(COMPILER_SRC_LIST | |||||
| "graph/build/stream_allocator.cc" | "graph/build/stream_allocator.cc" | ||||
| "graph/build/stream_graph_optimizer.cc" | "graph/build/stream_graph_optimizer.cc" | ||||
| "graph/build/task_generator.cc" | "graph/build/task_generator.cc" | ||||
| "graph/common/bcast.cc" | |||||
| "graph/common/local_context.cc" | |||||
| "graph/common/omg_util.cc" | |||||
| "graph/common/transop_util.cc" | |||||
| "graph/label/case_label_maker.cc" | "graph/label/case_label_maker.cc" | ||||
| "graph/label/if_label_maker.cc" | "graph/label/if_label_maker.cc" | ||||
| "graph/label/label_maker.cc" | "graph/label/label_maker.cc" | ||||
| @@ -341,7 +299,6 @@ set(COMPILER_SRC_LIST | |||||
| "graph/manager/graph_var_manager.cc" | "graph/manager/graph_var_manager.cc" | ||||
| "graph/manager/host_mem_allocator.cc" | "graph/manager/host_mem_allocator.cc" | ||||
| "graph/manager/host_mem_manager.cc" | "graph/manager/host_mem_manager.cc" | ||||
| "graph/manager/model_manager/event_manager.cc" | |||||
| "graph/manager/rdma_pool_allocator.cc" | "graph/manager/rdma_pool_allocator.cc" | ||||
| "graph/manager/session_scope_mem_allocator.cc" | "graph/manager/session_scope_mem_allocator.cc" | ||||
| "graph/manager/trans_var_data_utils.cc" | "graph/manager/trans_var_data_utils.cc" | ||||
| @@ -508,8 +465,6 @@ set(COMPILER_SRC_LIST | |||||
| "ir_build/attr_options/weight_compress_option.cc" | "ir_build/attr_options/weight_compress_option.cc" | ||||
| "ir_build/ge_ir_build.cc" | "ir_build/ge_ir_build.cc" | ||||
| "ir_build/option_utils.cc" | "ir_build/option_utils.cc" | ||||
| "model/ge_model.cc" | |||||
| "model/ge_root_model.cc" | |||||
| "opskernel_manager/ops_kernel_builder_manager.cc" | "opskernel_manager/ops_kernel_builder_manager.cc" | ||||
| "opskernel_manager/ops_kernel_manager.cc" | "opskernel_manager/ops_kernel_manager.cc" | ||||
| ) | ) | ||||
| @@ -523,6 +478,7 @@ set(RUNNER_SRC_LIST | |||||
| "graph/manager/util/hcom_util.cc" | "graph/manager/util/hcom_util.cc" | ||||
| "graph/load/model_manager/task_info/hccl_task_info.cc" | "graph/load/model_manager/task_info/hccl_task_info.cc" | ||||
| "hybrid/node_executor/hccl/hccl_node_executor.cc" | "hybrid/node_executor/hccl/hccl_node_executor.cc" | ||||
| "hybrid/node_executor/aicore/aicore_task_compiler.cc" | |||||
| ) | ) | ||||
| if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) | if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) | ||||
| @@ -639,7 +595,6 @@ target_compile_definitions(ge_compiler PRIVATE | |||||
| REUSE_MEMORY=1 | REUSE_MEMORY=1 | ||||
| FMK_SUPPORT_DUMP | FMK_SUPPORT_DUMP | ||||
| FMK_HOST_INFER | FMK_HOST_INFER | ||||
| COMPILE_OMG_PACKAGE | |||||
| google=ascend_private | google=ascend_private | ||||
| FUNC_VISIBILITY | FUNC_VISIBILITY | ||||
| $<$<STREQUAL:${ENABLE_OPEN_SRC},True>:ONLY_COMPILE_OPEN_SRC> | $<$<STREQUAL:${ENABLE_OPEN_SRC},True>:ONLY_COMPILE_OPEN_SRC> | ||||
| @@ -701,8 +656,7 @@ target_link_libraries(ge_compiler PRIVATE | |||||
| c_sec | c_sec | ||||
| error_manager | error_manager | ||||
| slog | slog | ||||
| $<$<NOT:$<BOOL:${ENABLE_OPEN_SRC}>>:$<BUILD_INTERFACE:runtime>> | |||||
| $<$<BOOL:${ENABLE_OPEN_SRC}>:$<BUILD_INTERFACE:runtime_compile>> | |||||
| runtime | |||||
| opt_feature | opt_feature | ||||
| -Wl,--as-needed | -Wl,--as-needed | ||||
| json | json | ||||
| @@ -763,7 +717,6 @@ target_link_libraries(ge_executor PRIVATE | |||||
| $<$<NOT:$<BOOL:${ENABLE_OPEN_SRC}>>:$<BUILD_INTERFACE:msprof_headers>> | $<$<NOT:$<BOOL:${ENABLE_OPEN_SRC}>>:$<BUILD_INTERFACE:msprof_headers>> | ||||
| $<$<NOT:$<BOOL:${ENABLE_OPEN_SRC}>>:$<BUILD_INTERFACE:mmpa_headers>> | $<$<NOT:$<BOOL:${ENABLE_OPEN_SRC}>>:$<BUILD_INTERFACE:mmpa_headers>> | ||||
| json | json | ||||
| ge_proto_client | |||||
| ascend_protobuf_static | ascend_protobuf_static | ||||
| c_sec | c_sec | ||||
| $<$<NOT:$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-lrt> | $<$<NOT:$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-lrt> | ||||
| @@ -826,7 +779,6 @@ target_link_libraries(ge_executor_shared PRIVATE | |||||
| $<$<NOT:$<BOOL:${ENABLE_OPEN_SRC}>>:$<BUILD_INTERFACE:cce_headers>> | $<$<NOT:$<BOOL:${ENABLE_OPEN_SRC}>>:$<BUILD_INTERFACE:cce_headers>> | ||||
| -Wl,--no-as-needed | -Wl,--no-as-needed | ||||
| ge_common | ge_common | ||||
| ge_proto_client | |||||
| runtime | runtime | ||||
| slog | slog | ||||
| graph | graph | ||||
| @@ -29,7 +29,7 @@ | |||||
| #include "graph/opsproto_manager.h" | #include "graph/opsproto_manager.h" | ||||
| #include "graph/utils/type_utils.h" | #include "graph/utils/type_utils.h" | ||||
| #include "graph/manager/util/rt_context_util.h" | #include "graph/manager/util/rt_context_util.h" | ||||
| #include "graph/common/ge_call_wrapper.h" | |||||
| #include "common/ge_call_wrapper.h" | |||||
| #include "register/op_registry.h" | #include "register/op_registry.h" | ||||
| #include "common/ge/tbe_plugin_manager.h" | #include "common/ge/tbe_plugin_manager.h" | ||||
| #include "common/util/error_manager/error_manager.h" | #include "common/util/error_manager/error_manager.h" | ||||
| @@ -1,48 +1,55 @@ | |||||
| set(SRC_LIST | set(SRC_LIST | ||||
| "context/ctx.cc" | |||||
| "model_saver.cc" | |||||
| "ge/datatype_util.cc" | |||||
| "helper/om_file_helper.cc" | |||||
| "helper/model_helper.cc" | |||||
| "../model/ge_model.cc" | |||||
| "../model/ge_root_model.cc" | |||||
| "auth/file_saver.cc" | |||||
| "fp16_t.cc" | |||||
| "math/fp16_math.cc" | |||||
| "debug/memory_dumper.cc" | |||||
| "formats/utils/formats_trans_utils.cc" | |||||
| "dump/dump_properties.cc" | |||||
| "formats/format_transfers/datatype_transfer.cc" | |||||
| "formats/format_transfers/format_transfer_transpose.cc" | |||||
| "formats/format_transfers/format_transfer_nchw_nc1hwc0.cc" | |||||
| "formats/format_transfers/format_transfer_fractal_z.cc" | |||||
| "formats/format_transfers/format_transfer_fractal_nz.cc" | |||||
| "formats/format_transfers/format_transfer_fractal_zz.cc" | |||||
| "formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc" | |||||
| "formats/format_transfers/format_transfer_nc1hwc0_nchw.cc" | |||||
| "formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc" | |||||
| "formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc" | |||||
| "formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc" | |||||
| "formats/format_transfers/format_transfer_fracz_nchw.cc" | |||||
| "formats/format_transfers/format_transfer_fracz_nhwc.cc" | |||||
| "formats/format_transfers/format_transfer_fracz_hwcn.cc" | |||||
| "formats/format_transfers/format_transfer_dhwcn_fracz3D.cc" | |||||
| "formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc" | |||||
| "formats/format_transfers/format_transfer_nchw_fz_c04.cc" | |||||
| "formats/formats.cc" | |||||
| "ge_format_util.cc" | |||||
| "fmk_error_codes.cc" | |||||
| "util.cc" | |||||
| "properties_manager.cc" | |||||
| "types.cc" | |||||
| "model_parser/model_parser.cc" | |||||
| "kernel_store.cc" | |||||
| "tbe_kernel_store.cc" | |||||
| "cust_aicpu_kernel_store.cc" | |||||
| "op/attr_value_util.cc" | |||||
| "op/ge_op_utils.cc" | |||||
| "thread_pool.cc" | |||||
| "ge/tbe_plugin_manager.cc" | |||||
| "${GE_CODE_DIR}/ge/common/auth/file_saver.cc" | |||||
| "${GE_CODE_DIR}/ge/common/bcast.cc" | |||||
| "${GE_CODE_DIR}/ge/common/context/ctx.cc" | |||||
| "${GE_CODE_DIR}/ge/common/cust_aicpu_kernel_store.cc" | |||||
| "${GE_CODE_DIR}/ge/common/debug/memory_dumper.cc" | |||||
| "${GE_CODE_DIR}/ge/common/dump/dump_manager.cc" | |||||
| "${GE_CODE_DIR}/ge/common/dump/dump_properties.cc" | |||||
| "${GE_CODE_DIR}/ge/common/fmk_error_codes.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/datatype_transfer.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_fractal_z.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/format_transfers/format_transfer_transpose.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/formats.cc" | |||||
| "${GE_CODE_DIR}/ge/common/formats/utils/formats_trans_utils.cc" | |||||
| "${GE_CODE_DIR}/ge/common/fp16_t.cc" | |||||
| "${GE_CODE_DIR}/ge/common/ge/datatype_util.cc" | |||||
| "${GE_CODE_DIR}/ge/common/ge/op_tiling_manager.cc" | |||||
| "${GE_CODE_DIR}/ge/common/ge/plugin_manager.cc" | |||||
| "${GE_CODE_DIR}/ge/common/ge/tbe_plugin_manager.cc" | |||||
| "${GE_CODE_DIR}/ge/common/ge_format_util.cc" | |||||
| "${GE_CODE_DIR}/ge/common/helper/model_helper.cc" | |||||
| "${GE_CODE_DIR}/ge/common/helper/om_file_helper.cc" | |||||
| "${GE_CODE_DIR}/ge/common/kernel_store.cc" | |||||
| "${GE_CODE_DIR}/ge/common/local_context.cc" | |||||
| "${GE_CODE_DIR}/ge/common/math/fp16_math.cc" | |||||
| "${GE_CODE_DIR}/ge/common/model/ge_model.cc" | |||||
| "${GE_CODE_DIR}/ge/common/model/ge_root_model.cc" | |||||
| "${GE_CODE_DIR}/ge/common/model_parser/model_parser.cc" | |||||
| "${GE_CODE_DIR}/ge/common/model_saver.cc" | |||||
| "${GE_CODE_DIR}/ge/common/omg_util.cc" | |||||
| "${GE_CODE_DIR}/ge/common/op/attr_value_util.cc" | |||||
| "${GE_CODE_DIR}/ge/common/op/ge_op_utils.cc" | |||||
| "${GE_CODE_DIR}/ge/common/properties_manager.cc" | |||||
| "${GE_CODE_DIR}/ge/common/tbe_kernel_store.cc" | |||||
| "${GE_CODE_DIR}/ge/common/thread_pool.cc" | |||||
| "${GE_CODE_DIR}/ge/common/transop_util.cc" | |||||
| "${GE_CODE_DIR}/ge/common/types.cc" | |||||
| "${GE_CODE_DIR}/ge/common/util.cc" | |||||
| ) | ) | ||||
| if (NOT ENABLE_D AND NOT ENABLE_ACL) | if (NOT ENABLE_D AND NOT ENABLE_ACL) | ||||
| @@ -63,7 +70,7 @@ target_compile_definitions(ge_common PRIVATE | |||||
| ) | ) | ||||
| target_compile_options(ge_common PRIVATE | target_compile_options(ge_common PRIVATE | ||||
| -fvisibility=hidden | |||||
| -fvisibility=default | |||||
| -O2 | -O2 | ||||
| -Werror | -Werror | ||||
| -Wno-deprecated-declarations | -Wno-deprecated-declarations | ||||
| @@ -183,7 +190,7 @@ target_compile_definitions(ge_common PRIVATE | |||||
| ) | ) | ||||
| target_compile_options(ge_common PRIVATE | target_compile_options(ge_common PRIVATE | ||||
| -fvisibility=hidden | |||||
| -fvisibility=default | |||||
| -O2 | -O2 | ||||
| -Werror | -Werror | ||||
| -Wno-deprecated-declarations | -Wno-deprecated-declarations | ||||
| @@ -238,7 +238,7 @@ Status FileSaver::SaveToBuffWithFileHeader(const ModelFileHeader &file_header, | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(const std::string &file_path) { | |||||
| Status FileSaver::CheckPath(const std::string &file_path) { | |||||
| // Determine file path length | // Determine file path length | ||||
| if (file_path.size() >= MMPA_MAX_PATH) { | if (file_path.size() >= MMPA_MAX_PATH) { | ||||
| GELOGE(FAILED, "[Check][FilePath]Failed, file path's length:%zu > mmpa_max_path:%d", | GELOGE(FAILED, "[Check][FilePath]Failed, file path's length:%zu > mmpa_max_path:%d", | ||||
| @@ -271,8 +271,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(con | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | |||||
| FileSaver::SaveToFile(const string &file_path, const ge::ModelData &model, const ModelFileHeader *model_file_header) { | |||||
| Status FileSaver::SaveToFile(const string &file_path, const ge::ModelData &model, | |||||
| const ModelFileHeader *model_file_header) { | |||||
| if (file_path.empty() || model.model_data == nullptr || model.model_len == 0) { | if (file_path.empty() || model.model_data == nullptr || model.model_len == 0) { | ||||
| GELOGE(FAILED, "[Save][File]Incorrect input param, " | GELOGE(FAILED, "[Save][File]Incorrect input param, " | ||||
| "file_path is empty or model_data is nullptr or model_len is 0"); | "file_path is empty or model_data is nullptr or model_len is 0"); | ||||
| @@ -301,19 +301,18 @@ FileSaver::SaveToFile(const string &file_path, const ge::ModelData &model, const | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | |||||
| FileSaver::SaveToFile(const string &file_path, ModelFileHeader &file_header, ModelPartitionTable &model_partition_table, | |||||
| const std::vector<ModelPartition> &partition_datas) { | |||||
| Status FileSaver::SaveToFile(const string &file_path, ModelFileHeader &file_header, | |||||
| ModelPartitionTable &model_partition_table, | |||||
| const std::vector<ModelPartition> &partition_datas) { | |||||
| const Status ret = SaveWithFileHeader(file_path, file_header, model_partition_table, partition_datas); | const Status ret = SaveWithFileHeader(file_path, file_header, model_partition_table, partition_datas); | ||||
| GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "save file failed, file_path:%s, file header len:%u.", | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "save file failed, file_path:%s, file header len:%u.", | ||||
| file_path.c_str(), file_header.length); | file_path.c_str(), file_header.length); | ||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | |||||
| FileSaver::SaveToFile(const string &file_path, ModelFileHeader &file_header, | |||||
| vector<ModelPartitionTable *> &model_partition_tables, | |||||
| const vector<vector<ModelPartition>> &all_partition_datas) { | |||||
| Status FileSaver::SaveToFile(const string &file_path, ModelFileHeader &file_header, | |||||
| vector<ModelPartitionTable *> &model_partition_tables, | |||||
| const vector<vector<ModelPartition>> &all_partition_datas) { | |||||
| const Status ret = SaveWithFileHeader(file_path, file_header, model_partition_tables, all_partition_datas); | const Status ret = SaveWithFileHeader(file_path, file_header, model_partition_tables, all_partition_datas); | ||||
| GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "save file failed, file_path:%s, file header len:%u.", | GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "save file failed, file_path:%s, file header len:%u.", | ||||
| file_path.c_str(), file_header.length); | file_path.c_str(), file_header.length); | ||||
| @@ -372,8 +371,7 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(const string &file_path, const void *data, | |||||
| int len) { | |||||
| Status FileSaver::SaveToFile(const string &file_path, const void *data, int len) { | |||||
| if (data == nullptr || len <= 0) { | if (data == nullptr || len <= 0) { | ||||
| GELOGE(FAILED, "[Check][Param]Failed, model_data is null or the " | GELOGE(FAILED, "[Check][Param]Failed, model_data is null or the " | ||||
| "length[%d] is less than 1.", len); | "length[%d] is less than 1.", len); | ||||
| @@ -14,12 +14,12 @@ | |||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "graph/common/bcast.h" | |||||
| #include "common/bcast.h" | |||||
| #include <vector> | #include <vector> | ||||
| #include "common/math_util.h" | #include "common/math_util.h" | ||||
| #include "framework/common/util.h" | |||||
| #include "common/util.h" | |||||
| using domi::Status; | using domi::Status; | ||||
| @@ -21,11 +21,11 @@ | |||||
| #include <functional> | #include <functional> | ||||
| #include <vector> | #include <vector> | ||||
| #include "framework/common/debug/log.h" | |||||
| #include "framework/common/types.h" | |||||
| #include "common/debug/log.h" | |||||
| #include "common/types.h" | |||||
| #include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
| #include "framework/common/ge_inner_error_codes.h" | #include "framework/common/ge_inner_error_codes.h" | ||||
| #include "external/graph/attr_value.h" | |||||
| #include "graph/attr_value.h" | |||||
| #include "graph/ge_tensor.h" | #include "graph/ge_tensor.h" | ||||
| #include "graph/utils/tensor_adapter.h" | #include "graph/utils/tensor_adapter.h" | ||||
| @@ -18,7 +18,7 @@ | |||||
| using ge::OmgContext; | using ge::OmgContext; | ||||
| namespace domi { | namespace domi { | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY OmgContext &GetContext() { | |||||
| OmgContext &GetContext() { | |||||
| static OmgContext context; | static OmgContext context; | ||||
| return context; | return context; | ||||
| } | } | ||||
| @@ -21,7 +21,7 @@ | |||||
| namespace ge { | namespace ge { | ||||
| class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY CustAICPUKernelStore : public KernelStore { | |||||
| class CustAICPUKernelStore : public KernelStore { | |||||
| public: | public: | ||||
| CustAICPUKernelStore(); | CustAICPUKernelStore(); | ||||
| ~CustAICPUKernelStore() {} | ~CustAICPUKernelStore() {} | ||||
| @@ -30,13 +30,12 @@ const int kInvalidFd = (-1); | |||||
| } // namespace | } // namespace | ||||
| namespace ge { | namespace ge { | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY MemoryDumper::MemoryDumper() : fd_(kInvalidFd) {} | |||||
| MemoryDumper::MemoryDumper() : fd_(kInvalidFd) {} | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY MemoryDumper::~MemoryDumper() { Close(); } | |||||
| MemoryDumper::~MemoryDumper() { Close(); } | |||||
| // Dump the data to the file | // Dump the data to the file | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::DumpToFile(const char *filename, void *data, | |||||
| int64_t len) { | |||||
| Status MemoryDumper::DumpToFile(const char *filename, void *data, int64_t len) { | |||||
| #ifdef FMK_SUPPORT_DUMP | #ifdef FMK_SUPPORT_DUMP | ||||
| GE_CHECK_NOTNULL(filename); | GE_CHECK_NOTNULL(filename); | ||||
| GE_CHECK_NOTNULL(data); | GE_CHECK_NOTNULL(data); | ||||
| @@ -81,7 +80,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::DumpToFile | |||||
| } | } | ||||
| // Open file | // Open file | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::Open(const char *filename) { | |||||
| Status MemoryDumper::Open(const char *filename) { | |||||
| GE_CHK_BOOL_RET_STATUS(filename != nullptr, FAILED, "Incorrect parameter. filename is nullptr"); | GE_CHK_BOOL_RET_STATUS(filename != nullptr, FAILED, "Incorrect parameter. filename is nullptr"); | ||||
| // Try to remove file first for reduce the close time by overwriting way | // Try to remove file first for reduce the close time by overwriting way | ||||
| @@ -104,7 +103,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::Open(const | |||||
| } | } | ||||
| // Dump the data to file | // Dump the data to file | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::Dump(void *data, uint32_t len) const { | |||||
| Status MemoryDumper::Dump(void *data, uint32_t len) const { | |||||
| GE_CHK_BOOL_RET_STATUS(data != nullptr, FAILED, "Incorrect parameter. data is nullptr"); | GE_CHK_BOOL_RET_STATUS(data != nullptr, FAILED, "Incorrect parameter. data is nullptr"); | ||||
| #ifdef FMK_SUPPORT_DUMP | #ifdef FMK_SUPPORT_DUMP | ||||
| @@ -15,6 +15,7 @@ | |||||
| */ | */ | ||||
| #include "common/dump/dump_manager.h" | #include "common/dump/dump_manager.h" | ||||
| #include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
| #include "framework/common/debug/log.h" | #include "framework/common/debug/log.h" | ||||
| @@ -26,7 +27,7 @@ const uint64_t kInferSessionId = 0; | |||||
| const uint32_t kAllOverflow = 3; | const uint32_t kAllOverflow = 3; | ||||
| } // namespace | } // namespace | ||||
| namespace ge { | namespace ge { | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpManager &DumpManager::GetInstance() { | |||||
| DumpManager &DumpManager::GetInstance() { | |||||
| static DumpManager instance; | static DumpManager instance; | ||||
| return instance; | return instance; | ||||
| } | } | ||||
| @@ -74,7 +75,7 @@ void DumpManager::SetDumpList(const DumpConfig &dump_config, DumpProperties &dum | |||||
| Status DumpManager::SetNormalDumpConf(const DumpConfig &dump_config, DumpProperties &dump_properties) { | Status DumpManager::SetNormalDumpConf(const DumpConfig &dump_config, DumpProperties &dump_properties) { | ||||
| if (dump_config.dump_status == kDumpOn) { | if (dump_config.dump_status == kDumpOn) { | ||||
| GELOGI("Only do normal dump process, dump status is %s.", dump_config.dump_status.c_str()); | |||||
| GELOGI("Only do normal dump process, dump status is %s", dump_config.dump_status.c_str()); | |||||
| dump_properties.SetDumpStatus(dump_config.dump_status); | dump_properties.SetDumpStatus(dump_config.dump_status); | ||||
| std::string dump_op_switch = dump_config.dump_op_switch; | std::string dump_op_switch = dump_config.dump_op_switch; | ||||
| dump_properties.SetDumpOpSwitch(dump_op_switch); | dump_properties.SetDumpOpSwitch(dump_op_switch); | ||||
| @@ -104,8 +105,8 @@ Status DumpManager::SetNormalDumpConf(const DumpConfig &dump_config, DumpPropert | |||||
| Status DumpManager::SetDumpPath(const DumpConfig &dump_config, DumpProperties &dump_properties) { | Status DumpManager::SetDumpPath(const DumpConfig &dump_config, DumpProperties &dump_properties) { | ||||
| std::string dump_path = dump_config.dump_path; | std::string dump_path = dump_config.dump_path; | ||||
| if (dump_path.empty()) { | if (dump_path.empty()) { | ||||
| GELOGE(PARAM_INVALID, "[Check][DumpPath]It is empty"); | |||||
| REPORT_INNER_ERROR("E19999", "Dump path check is empty"); | |||||
| GELOGE(PARAM_INVALID, "[Check][DumpPath]It is empty."); | |||||
| REPORT_INNER_ERROR("E19999", "Dump path check is empty."); | |||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| if (dump_path[dump_path.size() - 1] != '/') { | if (dump_path[dump_path.size() - 1] != '/') { | ||||
| @@ -117,7 +118,7 @@ Status DumpManager::SetDumpPath(const DumpConfig &dump_config, DumpProperties &d | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf(const DumpConfig &dump_config) { | |||||
| Status DumpManager::SetDumpConf(const DumpConfig &dump_config) { | |||||
| DumpProperties dump_properties; | DumpProperties dump_properties; | ||||
| if (!NeedDoDump(dump_config, dump_properties)) { | if (!NeedDoDump(dump_config, dump_properties)) { | ||||
| GELOGD("No need do dump process."); | GELOGD("No need do dump process."); | ||||
| @@ -131,8 +132,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const DumpProperties &DumpManager::GetDumpProperties( | |||||
| uint64_t session_id) { | |||||
| const DumpProperties &DumpManager::GetDumpProperties(uint64_t session_id) { | |||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| auto iter = dump_properties_map_.find(session_id); | auto iter = dump_properties_map_.find(session_id); | ||||
| if (iter != dump_properties_map_.end()) { | if (iter != dump_properties_map_.end()) { | ||||
| @@ -142,13 +142,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const DumpProperties &DumpManag | |||||
| return default_properties; | return default_properties; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpManager::AddDumpProperties( | |||||
| uint64_t session_id, const DumpProperties &dump_properties) { | |||||
| void DumpManager::AddDumpProperties(uint64_t session_id, const DumpProperties &dump_properties) { | |||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| dump_properties_map_.emplace(session_id, dump_properties); | dump_properties_map_.emplace(session_id, dump_properties); | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpManager::RemoveDumpProperties(uint64_t session_id) { | |||||
| void DumpManager::RemoveDumpProperties(uint64_t session_id) { | |||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| auto iter = dump_properties_map_.find(session_id); | auto iter = dump_properties_map_.find(session_id); | ||||
| if (iter != dump_properties_map_.end()) { | if (iter != dump_properties_map_.end()) { | ||||
| @@ -38,9 +38,7 @@ const uint32_t kAtomicOverflow = (0x1 << 1); | |||||
| const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow); | const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow); | ||||
| } // namespace | } // namespace | ||||
| namespace ge { | namespace ge { | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::Split(const std::string &s, | |||||
| std::vector<std::string> &result, | |||||
| const char *delchar) { | |||||
| void DumpProperties::Split(const std::string &s, std::vector<std::string> &result, const char *delchar) { | |||||
| if (s.empty()) { | if (s.empty()) { | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -68,7 +66,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::Split(cons | |||||
| delete[] buffer; | delete[] buffer; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckDumpStep(const std::string &dump_step) { | |||||
| Status DumpProperties::CheckDumpStep(const std::string &dump_step) { | |||||
| std::string modified_dum_step = dump_step + "|"; | std::string modified_dum_step = dump_step + "|"; | ||||
| std::smatch result; | std::smatch result; | ||||
| std::vector<string> match_vecs; | std::vector<string> match_vecs; | ||||
| @@ -126,7 +124,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckDum | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckDumpMode(const std::string &dump_mode) { | |||||
| Status DumpProperties::CheckDumpMode(const std::string &dump_mode) { | |||||
| const std::set<string> dump_mode_list = {"input", "output", "all"}; | const std::set<string> dump_mode_list = {"input", "output", "all"}; | ||||
| std::set<string>::iterator iter; | std::set<string>::iterator iter; | ||||
| @@ -143,7 +141,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckDum | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckDumpPath(const std::string &input) { | |||||
| Status DumpProperties::CheckDumpPath(const std::string &input) { | |||||
| if (mmIsDir(input.c_str()) != EN_OK) { | if (mmIsDir(input.c_str()) != EN_OK) { | ||||
| REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}), | REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}), | ||||
| std::vector<std::string>({ | std::vector<std::string>({ | ||||
| @@ -175,7 +173,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckDum | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckEnableDump(const std::string &input) { | |||||
| Status DumpProperties::CheckEnableDump(const std::string &input) { | |||||
| std::set<string> enable_dump_option_list = {"1", "0"}; | std::set<string> enable_dump_option_list = {"1", "0"}; | ||||
| auto it = enable_dump_option_list.find(input); | auto it = enable_dump_option_list.find(input); | ||||
| if (it == enable_dump_option_list.end()) { | if (it == enable_dump_option_list.end()) { | ||||
| @@ -191,17 +189,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::CheckEna | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties::DumpProperties(const DumpProperties &other) { | |||||
| DumpProperties::DumpProperties(const DumpProperties &other) { | |||||
| CopyFrom(other); | CopyFrom(other); | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties &DumpProperties::operator=( | |||||
| const DumpProperties &other) { | |||||
| DumpProperties &DumpProperties::operator=(const DumpProperties &other) { | |||||
| CopyFrom(other); | CopyFrom(other); | ||||
| return *this; | return *this; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::SetDumpOptions() { | |||||
| Status DumpProperties::SetDumpOptions() { | |||||
| if (enable_dump_ == kEnableFlag) { | if (enable_dump_ == kEnableFlag) { | ||||
| std::string dump_step; | std::string dump_step; | ||||
| if (GetContext().GetOption(OPTION_EXEC_DUMP_STEP, dump_step) == GRAPH_SUCCESS && !dump_step.empty()) { | if (GetContext().GetOption(OPTION_EXEC_DUMP_STEP, dump_step) == GRAPH_SUCCESS && !dump_step.empty()) { | ||||
| @@ -220,7 +217,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::SetDumpO | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::InitByOptions() { | |||||
| Status DumpProperties::InitByOptions() { | |||||
| enable_dump_.clear(); | enable_dump_.clear(); | ||||
| enable_dump_debug_.clear(); | enable_dump_debug_.clear(); | ||||
| dump_path_.clear(); | dump_path_.clear(); | ||||
| @@ -281,8 +278,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpProperties::InitByOp | |||||
| } | } | ||||
| // The following is the new dump scenario of the fusion operator | // The following is the new dump scenario of the fusion operator | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::AddPropertyValue( | |||||
| const std::string &model, const std::set<std::string> &layers) { | |||||
| void DumpProperties::AddPropertyValue(const std::string &model, const std::set<std::string> &layers) { | |||||
| for (const std::string &layer : layers) { | for (const std::string &layer : layers) { | ||||
| GELOGI("This model %s config to dump layer %s", model.c_str(), layer.c_str()); | GELOGI("This model %s config to dump layer %s", model.c_str(), layer.c_str()); | ||||
| } | } | ||||
| @@ -290,18 +286,18 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::AddPropert | |||||
| model_dump_properties_map_[model] = layers; | model_dump_properties_map_[model] = layers; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::DeletePropertyValue(const std::string &model) { | |||||
| void DumpProperties::DeletePropertyValue(const std::string &model) { | |||||
| auto iter = model_dump_properties_map_.find(model); | auto iter = model_dump_properties_map_.find(model); | ||||
| if (iter != model_dump_properties_map_.end()) { | if (iter != model_dump_properties_map_.end()) { | ||||
| model_dump_properties_map_.erase(iter); | model_dump_properties_map_.erase(iter); | ||||
| } | } | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::ClearDumpPropertyValue() { | |||||
| void DumpProperties::ClearDumpPropertyValue() { | |||||
| model_dump_properties_map_.clear(); | model_dump_properties_map_.clear(); | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::ClearDumpInfo() { | |||||
| void DumpProperties::ClearDumpInfo() { | |||||
| enable_dump_.clear(); | enable_dump_.clear(); | ||||
| enable_dump_debug_.clear(); | enable_dump_debug_.clear(); | ||||
| dump_path_.clear(); | dump_path_.clear(); | ||||
| @@ -314,7 +310,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::ClearDumpI | |||||
| op_debug_mode_ = 0; | op_debug_mode_ = 0; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpProperties::GetAllDumpModel() const { | |||||
| std::set<std::string> DumpProperties::GetAllDumpModel() const { | |||||
| std::set<std::string> model_list; | std::set<std::string> model_list; | ||||
| for (auto &iter : model_dump_properties_map_) { | for (auto &iter : model_dump_properties_map_) { | ||||
| model_list.insert(iter.first); | model_list.insert(iter.first); | ||||
| @@ -323,8 +319,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpPrope | |||||
| return model_list; | return model_list; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpProperties::GetPropertyValue( | |||||
| const std::string &model) const { | |||||
| std::set<std::string> DumpProperties::GetPropertyValue(const std::string &model) const { | |||||
| auto iter = model_dump_properties_map_.find(model); | auto iter = model_dump_properties_map_.find(model); | ||||
| if (iter != model_dump_properties_map_.end()) { | if (iter != model_dump_properties_map_.end()) { | ||||
| return iter->second; | return iter->second; | ||||
| @@ -332,8 +327,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::set<std::string> DumpPrope | |||||
| return {}; | return {}; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsLayerNeedDump( | |||||
| const std::string &model, const std::string &om_name, const std::string &op_name) const { | |||||
| bool DumpProperties::IsLayerNeedDump(const std::string &model, const std::string &om_name, | |||||
| const std::string &op_name) const { | |||||
| // if dump all | // if dump all | ||||
| GELOGD("model name is %s om name is %s op is %s in layer need dump", model.c_str(), om_name.c_str(), op_name.c_str()); | GELOGD("model name is %s om name is %s op is %s in layer need dump", model.c_str(), om_name.c_str(), op_name.c_str()); | ||||
| if (model_dump_properties_map_.find(DUMP_ALL_MODEL) != model_dump_properties_map_.end()) { | if (model_dump_properties_map_.find(DUMP_ALL_MODEL) != model_dump_properties_map_.end()) { | ||||
| @@ -353,67 +348,66 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsLayerNee | |||||
| return model_iter->second.find(op_name) != model_iter->second.end(); | return model_iter->second.find(op_name) != model_iter->second.end(); | ||||
| } | } | ||||
| GELOGD("Model %s is not seated to be dump.", model.c_str()); | |||||
| GELOGD("Model %s is not seated to be dump", model.c_str()); | |||||
| return false; | return false; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpPath(const std::string &path) { | |||||
| void DumpProperties::SetDumpPath(const std::string &path) { | |||||
| dump_path_ = path; | dump_path_ = path; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpPath() const { | |||||
| const std::string &DumpProperties::GetDumpPath() const { | |||||
| return dump_path_; | return dump_path_; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpStep(const std::string &step) { | |||||
| void DumpProperties::SetDumpStep(const std::string &step) { | |||||
| dump_step_ = step; | dump_step_ = step; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpStep() const { | |||||
| const std::string &DumpProperties::GetDumpStep() const { | |||||
| return dump_step_; | return dump_step_; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpMode(const std::string &mode) { | |||||
| void DumpProperties::SetDumpMode(const std::string &mode) { | |||||
| dump_mode_ = mode; | dump_mode_ = mode; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpMode() const { | |||||
| const std::string &DumpProperties::GetDumpMode() const { | |||||
| return dump_mode_; | return dump_mode_; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpStatus(const std::string &status) { | |||||
| void DumpProperties::SetDumpStatus(const std::string &status) { | |||||
| dump_status_ = status; | dump_status_ = status; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpStatus() const { | |||||
| const std::string &DumpProperties::GetDumpStatus() const { | |||||
| return dump_status_; | return dump_status_; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::InitInferOpDebug() { | |||||
| void DumpProperties::InitInferOpDebug() { | |||||
| is_infer_op_debug_ = true; | is_infer_op_debug_ = true; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetOpDebugMode(const uint32_t &op_debug_mode) { | |||||
| void DumpProperties::SetOpDebugMode(const uint32_t &op_debug_mode) { | |||||
| op_debug_mode_ = op_debug_mode; | op_debug_mode_ = op_debug_mode; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpOpSwitch( | |||||
| const std::string &dump_op_switch) { | |||||
| void DumpProperties::SetDumpOpSwitch(const std::string &dump_op_switch) { | |||||
| dump_op_switch_ = dump_op_switch; | dump_op_switch_ = dump_op_switch; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpOpSwitch() const { | |||||
| const std::string &DumpProperties::GetDumpOpSwitch() const { | |||||
| return dump_op_switch_; | return dump_op_switch_; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsSingleOpNeedDump() const { | |||||
| bool DumpProperties::IsSingleOpNeedDump() const { | |||||
| if (dump_op_switch_ == kDumpStatusOpen) { | if (dump_op_switch_ == kDumpStatusOpen) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsDumpOpen() const { | |||||
| bool DumpProperties::IsDumpOpen() const { | |||||
| if (enable_dump_ == kEnableFlag || dump_status_ == kDumpStatusOpen) { | if (enable_dump_ == kEnableFlag || dump_status_ == kDumpStatusOpen) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -441,7 +435,7 @@ Status DumpProperties::SetDumpDebugOptions() { | |||||
| if (enable_dump_debug_ == kEnableFlag) { | if (enable_dump_debug_ == kEnableFlag) { | ||||
| std::string dump_debug_mode; | std::string dump_debug_mode; | ||||
| if (GetContext().GetOption(OPTION_EXEC_DUMP_DEBUG_MODE, dump_debug_mode) == GRAPH_SUCCESS) { | if (GetContext().GetOption(OPTION_EXEC_DUMP_DEBUG_MODE, dump_debug_mode) == GRAPH_SUCCESS) { | ||||
| GELOGD("Get ge.exec.dumpDebugMode %s successfully", dump_debug_mode.c_str()); | |||||
| GELOGD("Get ge.exec.dumpDebugMode %s successfully.", dump_debug_mode.c_str()); | |||||
| } else { | } else { | ||||
| GELOGW("ge.exec.dumpDebugMode is not set."); | GELOGW("ge.exec.dumpDebugMode is not set."); | ||||
| return SUCCESS; | return SUCCESS; | ||||
| @@ -469,7 +463,7 @@ Status DumpProperties::SetDumpDebugOptions() { | |||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| } else { | } else { | ||||
| GELOGI("ge.exec.enableDumpDebug is false or is not set."); | |||||
| GELOGI("ge.exec.enableDumpDebug is false or is not set"); | |||||
| } | } | ||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| @@ -17,19 +17,18 @@ | |||||
| #include "framework/common/fmk_error_codes.h" | #include "framework/common/fmk_error_codes.h" | ||||
| namespace domi { | namespace domi { | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY StatusFactory *StatusFactory::Instance() { | |||||
| StatusFactory *StatusFactory::Instance() { | |||||
| static StatusFactory instance; | static StatusFactory instance; | ||||
| return &instance; | return &instance; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void StatusFactory::RegisterErrorNo(uint32_t err, | |||||
| const std::string &desc) { | |||||
| void StatusFactory::RegisterErrorNo(uint32_t err, const std::string &desc) { | |||||
| if (err_desc_.find(err) != err_desc_.end()) { | if (err_desc_.find(err) != err_desc_.end()) { | ||||
| return; | return; | ||||
| } | } | ||||
| err_desc_[err] = desc; | err_desc_[err] = desc; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string StatusFactory::GetErrDesc(uint32_t err) { | |||||
| std::string StatusFactory::GetErrDesc(uint32_t err) { | |||||
| auto iter_find = err_desc_.find(err); | auto iter_find = err_desc_.find(err); | ||||
| if (iter_find == err_desc_.end()) { | if (iter_find == err_desc_.end()) { | ||||
| return ""; | return ""; | ||||
| @@ -17,6 +17,7 @@ | |||||
| #include "common/formats/format_transfers/format_transfer_fracz_hwcn.h" | #include "common/formats/format_transfers/format_transfer_fracz_hwcn.h" | ||||
| #include <securec.h> | #include <securec.h> | ||||
| #include <memory> | #include <memory> | ||||
| #include "common/formats/utils/formats_definitions.h" | #include "common/formats/utils/formats_definitions.h" | ||||
| @@ -35,8 +36,8 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { | |||||
| auto dst_shape = args.dst_shape; | auto dst_shape = args.dst_shape; | ||||
| if (args.src_format != FORMAT_FRACTAL_Z || args.dst_format != FORMAT_HWCN) { | if (args.src_format != FORMAT_FRACTAL_Z || args.dst_format != FORMAT_HWCN) { | ||||
| std::string error = "Dose not support trans format from " + | std::string error = "Dose not support trans format from " + | ||||
| FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + | |||||
| FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); | |||||
| FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + | |||||
| FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); | |||||
| GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); | GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); | ||||
| return ACL_ERROR_GE_FORMAT_INVALID; | return ACL_ERROR_GE_FORMAT_INVALID; | ||||
| } | } | ||||
| @@ -52,15 +53,13 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { | |||||
| if (!CheckShapeValid(src_shape, kFracZDimsNum)) { | if (!CheckShapeValid(src_shape, kFracZDimsNum)) { | ||||
| GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Value is invalid, src shape %s", | GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Value is invalid, src shape %s", | ||||
| ShapeToString(src_shape).c_str()); | ShapeToString(src_shape).c_str()); | ||||
| REPORT_CALL_ERROR("E19999", "Src shape %s check invalid", | |||||
| ShapeToString(src_shape).c_str()); | |||||
| REPORT_CALL_ERROR("E19999", "Src shape %s check invalid", ShapeToString(src_shape).c_str()); | |||||
| return ACL_ERROR_GE_SHAPE_INVALID; | return ACL_ERROR_GE_SHAPE_INVALID; | ||||
| } | } | ||||
| if (!CheckShapeValid(dst_shape, kHwcnDimsNum)) { | if (!CheckShapeValid(dst_shape, kHwcnDimsNum)) { | ||||
| GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Value is invalid, dst shape %s", | GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Value is invalid, dst shape %s", | ||||
| ShapeToString(dst_shape).c_str()); | ShapeToString(dst_shape).c_str()); | ||||
| REPORT_CALL_ERROR("E19999", "Dst shape %s check invalid", | |||||
| ShapeToString(dst_shape).c_str()); | |||||
| REPORT_CALL_ERROR("E19999", "Dst shape %s check invalid", ShapeToString(dst_shape).c_str()); | |||||
| return ACL_ERROR_GE_SHAPE_INVALID; | return ACL_ERROR_GE_SHAPE_INVALID; | ||||
| } | } | ||||
| int64_t c0 = GetCubeSizeByDataType(args.src_data_type); | int64_t c0 = GetCubeSizeByDataType(args.src_data_type); | ||||
| @@ -71,9 +70,8 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { | |||||
| int64_t n0 = Ceil(dst_shape.at(kHwcnN), static_cast<int64_t>(kNiSize)); | int64_t n0 = Ceil(dst_shape.at(kHwcnN), static_cast<int64_t>(kNiSize)); | ||||
| if (src_shape.at(kFracZHWC1) != dst_shape.at(kHwcnH) * dst_shape.at(kHwcnW) * c1 || src_shape.at(kFracZC0) != c0 || | if (src_shape.at(kFracZHWC1) != dst_shape.at(kHwcnH) * dst_shape.at(kHwcnW) * c1 || src_shape.at(kFracZC0) != c0 || | ||||
| src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { | src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { | ||||
| std::string error = "Failed to check relationship between src shape" + | |||||
| FmtToStr(ShapeToString(src_shape)) + " and dst shape" + | |||||
| FmtToStr(ShapeToString(dst_shape)); | |||||
| std::string error = "Failed to check relationship between src shape" + FmtToStr(ShapeToString(src_shape)) + | |||||
| " and dst shape" + FmtToStr(ShapeToString(dst_shape)); | |||||
| GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_SHAPE_INVALID, error.c_str()); | GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_SHAPE_INVALID, error.c_str()); | ||||
| return ACL_ERROR_GE_SHAPE_INVALID; | return ACL_ERROR_GE_SHAPE_INVALID; | ||||
| } | } | ||||
| @@ -33,7 +33,6 @@ Status TransposeWithShapeCheck(const uint8_t *src, const std::vector<int64_t> &s | |||||
| Status GetPermByForamt(Format src_format, Format dst_format, std::vector<int64_t> &perm); | Status GetPermByForamt(Format src_format, Format dst_format, std::vector<int64_t> &perm); | ||||
| class FormatTransferTranspose : public FormatTransfer { | class FormatTransferTranspose : public FormatTransfer { | ||||
| public: | public: | ||||
| Status TransFormat(const TransArgs &args, TransResult &result) override; | Status TransFormat(const TransArgs &args, TransResult &result) override; | ||||
| @@ -17,6 +17,7 @@ | |||||
| #include "common/formats/formats.h" | #include "common/formats/formats.h" | ||||
| #include <securec.h> | #include <securec.h> | ||||
| #include <cmath> | #include <cmath> | ||||
| #include <cstring> | #include <cstring> | ||||
| #include <functional> | #include <functional> | ||||
| @@ -32,7 +33,7 @@ | |||||
| namespace ge { | namespace ge { | ||||
| namespace formats { | namespace formats { | ||||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransFormat(const TransArgs &args, TransResult &result) { | |||||
| Status TransFormat(const TransArgs &args, TransResult &result) { | |||||
| auto transfer = BuildFormatTransfer(args); | auto transfer = BuildFormatTransfer(args); | ||||
| if (transfer == nullptr) { | if (transfer == nullptr) { | ||||
| std::string error = "Failed to trans data from format " + | std::string error = "Failed to trans data from format " + | ||||
| @@ -56,11 +57,8 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransFormat(const TransArg | |||||
| return transfer->TransFormat(args, result); | return transfer->TransFormat(args, result); | ||||
| } | } | ||||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransShape(Format src_format, | |||||
| const std::vector<int64_t> &src_shape, | |||||
| DataType data_type, | |||||
| Format dst_format, | |||||
| std::vector<int64_t> &dst_shape) { | |||||
| Status TransShape(Format src_format, const std::vector<int64_t> &src_shape, DataType data_type, Format dst_format, | |||||
| std::vector<int64_t> &dst_shape) { | |||||
| formats::TransArgs args; | formats::TransArgs args; | ||||
| args.src_format = src_format; | args.src_format = src_format; | ||||
| args.dst_format = dst_format; | args.dst_format = dst_format; | ||||
| @@ -76,7 +74,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransShape(Format src_form | |||||
| return transfer->TransShape(src_format, src_shape, data_type, dst_format, dst_shape); | return transfer->TransShape(src_format, src_shape, data_type, dst_format, dst_shape); | ||||
| } | } | ||||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransDataType(const CastArgs &args, TransResult &result) { | |||||
| Status TransDataType(const CastArgs &args, TransResult &result) { | |||||
| auto transfer = BuildDataTypeTransfer(args); | auto transfer = BuildDataTypeTransfer(args); | ||||
| if (transfer == nullptr) { | if (transfer == nullptr) { | ||||
| std::string error = "Failed to trans data from datatype " + | std::string error = "Failed to trans data from datatype " + | ||||
| @@ -95,11 +93,11 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransDataType(const CastAr | |||||
| return transfer->TransDataType(args, result); | return transfer->TransDataType(args, result); | ||||
| } | } | ||||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransFormatSupport(const TransArgs &args) { | |||||
| bool IsTransFormatSupport(const TransArgs &args) { | |||||
| return FormatTransferExists(args); | return FormatTransferExists(args); | ||||
| } | } | ||||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool IsTransDataTypeSupport(const CastArgs &args) { | |||||
| bool IsTransDataTypeSupport(const CastArgs &args) { | |||||
| return DataTypeTransferExists(args); | return DataTypeTransferExists(args); | ||||
| } | } | ||||
| } // namespace formats | } // namespace formats | ||||
| @@ -41,15 +41,14 @@ int64_t GetCubeSizeByDataType(DataType data_type) { | |||||
| } | } | ||||
| } | } | ||||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::string ShapeToString(const GeShape &shape) { | |||||
| std::string ShapeToString(const GeShape &shape) { | |||||
| return ShapeToString(shape.GetDims()); | return ShapeToString(shape.GetDims()); | ||||
| } | } | ||||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY std::string ShapeToString(const std::vector<int64_t> &shape) { | |||||
| std::string ShapeToString(const std::vector<int64_t> &shape) { | |||||
| return JoinToString(shape); | return JoinToString(shape); | ||||
| } | } | ||||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY | |||||
| std::string RangeToString(const std::vector<std::pair<int64_t, int64_t>> &ranges) { | std::string RangeToString(const std::vector<std::pair<int64_t, int64_t>> &ranges) { | ||||
| bool first = true; | bool first = true; | ||||
| std::stringstream ss; | std::stringstream ss; | ||||
| @@ -1180,20 +1180,40 @@ fp16_t &fp16_t::operator=(const double &d_val) { | |||||
| } | } | ||||
| // convert | // convert | ||||
| fp16_t::operator float() const { return Fp16ToFloat(val); } | |||||
| fp16_t::operator double() const { return Fp16ToDouble(val); } | |||||
| fp16_t::operator int8_t() const { return Fp16ToInt8(val); } | |||||
| fp16_t::operator uint8_t() const { return Fp16ToUInt8(val); } | |||||
| fp16_t::operator int16_t() const { return Fp16ToInt16(val); } | |||||
| fp16_t::operator uint16_t() const { return Fp16ToUInt16(val); } | |||||
| fp16_t::operator int32_t() const { return Fp16ToInt32(val); } | |||||
| fp16_t::operator uint32_t() const { return Fp16ToUInt32(val); } | |||||
| fp16_t::operator float() const { | |||||
| return Fp16ToFloat(val); | |||||
| } | |||||
| fp16_t::operator double() const { | |||||
| return Fp16ToDouble(val); | |||||
| } | |||||
| fp16_t::operator int8_t() const { | |||||
| return Fp16ToInt8(val); | |||||
| } | |||||
| fp16_t::operator uint8_t() const { | |||||
| return Fp16ToUInt8(val); | |||||
| } | |||||
| fp16_t::operator int16_t() const { | |||||
| return Fp16ToInt16(val); | |||||
| } | |||||
| fp16_t::operator uint16_t() const { | |||||
| return Fp16ToUInt16(val); | |||||
| } | |||||
| fp16_t::operator int32_t() const { | |||||
| return Fp16ToInt32(val); | |||||
| } | |||||
| fp16_t::operator uint32_t() const { | |||||
| return Fp16ToUInt32(val); | |||||
| } | |||||
| // Cannot be used, just in order to solve the compile error | // Cannot be used, just in order to solve the compile error | ||||
| fp16_t::operator int64_t() const { return 0; } | |||||
| fp16_t::operator int64_t() const { | |||||
| return 0; | |||||
| } | |||||
| // Cannot be used, just in order to solve the compile error | // Cannot be used, just in order to solve the compile error | ||||
| fp16_t::operator uint64_t() const { return 0; } | |||||
| fp16_t::operator uint64_t() const { | |||||
| return 0; | |||||
| } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int fp16_t::IsInf() { | |||||
| int fp16_t::IsInf() { | |||||
| if ((val & kFp16AbsMax) == kFp16ExpMask) { | if ((val & kFp16AbsMax) == kFp16ExpMask) { | ||||
| if (val & kFp16SignMask) { | if (val & kFp16SignMask) { | ||||
| return -1; | return -1; | ||||
| @@ -1205,12 +1225,28 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int fp16_t::IsInf() { | |||||
| } | } | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY float fp16_t::ToFloat() const { return Fp16ToFloat(val); } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY double fp16_t::ToDouble() const { return Fp16ToDouble(val); } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int8_t fp16_t::ToInt8() const { return Fp16ToInt8(val); } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint8_t fp16_t::ToUInt8() const { return Fp16ToUInt8(val); } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int16_t fp16_t::ToInt16() const { return Fp16ToInt16(val); } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint16_t fp16_t::ToUInt16() const { return Fp16ToUInt16(val); } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int32_t fp16_t::ToInt32() const { return Fp16ToInt32(val); } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint32_t fp16_t::ToUInt32() const { return Fp16ToUInt32(val); } | |||||
| float fp16_t::ToFloat() const { | |||||
| return Fp16ToFloat(val); | |||||
| } | |||||
| double fp16_t::ToDouble() const { | |||||
| return Fp16ToDouble(val); | |||||
| } | |||||
| int8_t fp16_t::ToInt8() const { | |||||
| return Fp16ToInt8(val); | |||||
| } | |||||
| uint8_t fp16_t::ToUInt8() const { | |||||
| return Fp16ToUInt8(val); | |||||
| } | |||||
| int16_t fp16_t::ToInt16() const { | |||||
| return Fp16ToInt16(val); | |||||
| } | |||||
| uint16_t fp16_t::ToUInt16() const { | |||||
| return Fp16ToUInt16(val); | |||||
| } | |||||
| int32_t fp16_t::ToInt32() const { | |||||
| return Fp16ToInt32(val); | |||||
| } | |||||
| uint32_t fp16_t::ToUInt32() const { | |||||
| return Fp16ToUInt32(val); | |||||
| } | |||||
| } // namespace ge | } // namespace ge | ||||
| @@ -42,7 +42,7 @@ static std::map<ge::DataType, int32_t> CONST_OPDATA_TYPE_SIZE_MAP = { | |||||
| {ge::DT_UINT8, kGeSizeUint8}, {ge::DT_UINT16, kGeSizeUint16}, {ge::DT_UINT32, kGeSizeUint32}, | {ge::DT_UINT8, kGeSizeUint8}, {ge::DT_UINT16, kGeSizeUint16}, {ge::DT_UINT32, kGeSizeUint32}, | ||||
| {ge::DT_UINT64, kGeSizeUint64}, {ge::DT_DOUBLE, kGeSizeDouble}, {ge::DT_BOOL, kGeSizeBool}}; | {ge::DT_UINT64, kGeSizeUint64}, {ge::DT_DOUBLE, kGeSizeDouble}, {ge::DT_BOOL, kGeSizeBool}}; | ||||
| class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY DataTypeUtil { | |||||
| class DataTypeUtil { | |||||
| public: | public: | ||||
| static bool DataTypeTranslatable(const ge::DataType &src_out_data_type, const ge::DataType &dst_in_data_type); | static bool DataTypeTranslatable(const ge::DataType &src_out_data_type, const ge::DataType &dst_in_data_type); | ||||
| static const std::vector<ge::DataType> &GetTranslatableDataTypesBySrc(const ge::DataType &src_out_data_type); | static const std::vector<ge::DataType> &GetTranslatableDataTypesBySrc(const ge::DataType &src_out_data_type); | ||||
| @@ -42,7 +42,7 @@ const int kBaseInt = 10; | |||||
| std::map<string, string> TBEPluginManager::options_ = {}; | std::map<string, string> TBEPluginManager::options_ = {}; | ||||
| // Get Singleton Instance | // Get Singleton Instance | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY TBEPluginManager &TBEPluginManager::Instance() { | |||||
| TBEPluginManager &TBEPluginManager::Instance() { | |||||
| static TBEPluginManager instance_ptr_; | static TBEPluginManager instance_ptr_; | ||||
| return instance_ptr_; | return instance_ptr_; | ||||
| } | } | ||||
| @@ -61,7 +61,7 @@ Status TBEPluginManager::ClearHandles_() { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status TBEPluginManager::Finalize() { | |||||
| Status TBEPluginManager::Finalize() { | |||||
| Status ret = ClearHandles_(); | Status ret = ClearHandles_(); | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| @@ -207,7 +207,6 @@ void TBEPluginManager::LoadCustomOpLib() { | |||||
| } | } | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY | |||||
| void TBEPluginManager::LoadPluginSo(const std::map<string, string> &options) { | void TBEPluginManager::LoadPluginSo(const std::map<string, string> &options) { | ||||
| vector<string> file_list; | vector<string> file_list; | ||||
| string caffe_parser_path; | string caffe_parser_path; | ||||
| @@ -246,7 +245,6 @@ void TBEPluginManager::LoadPluginSo(const std::map<string, string> &options) { | |||||
| } | } | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY | |||||
| void TBEPluginManager::InitPreparation(const std::map<string, string> &options) { | void TBEPluginManager::InitPreparation(const std::map<string, string> &options) { | ||||
| options_.insert(options.begin(), options.end()); | options_.insert(options.begin(), options.end()); | ||||
| // Load TBE plugin | // Load TBE plugin | ||||
| @@ -18,9 +18,7 @@ | |||||
| #include "common/formats/formats.h" | #include "common/formats/formats.h" | ||||
| namespace ge { | namespace ge { | ||||
| GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status GeFormatUtil::TransShape(const TensorDesc &src_desc, | |||||
| Format dst_format, | |||||
| std::vector<int64_t> &dst_shape) { | |||||
| Status GeFormatUtil::TransShape(const TensorDesc &src_desc, Format dst_format, std::vector<int64_t> &dst_shape) { | |||||
| return formats::TransShape(src_desc.GetFormat(), src_desc.GetShape().GetDims(), src_desc.GetDataType(), dst_format, | return formats::TransShape(src_desc.GetFormat(), src_desc.GetShape().GetDims(), src_desc.GetDataType(), dst_format, | ||||
| dst_shape); | dst_shape); | ||||
| } | } | ||||
| @@ -1,123 +0,0 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #ifndef GE_COMMON_HELPER_MODEL_CACHE_HELPER_H_ | |||||
| #define GE_COMMON_HELPER_MODEL_CACHE_HELPER_H_ | |||||
| #include <nlohmann/json.hpp> | |||||
| #include <set> | |||||
| #include <string> | |||||
| #include "external/ge/ge_api_error_codes.h" | |||||
| #include "graph/compute_graph.h" | |||||
| #include "graph/manager/graph_var_manager.h" | |||||
| #include "model/ge_model.h" | |||||
| namespace ge { | |||||
| using Json = nlohmann::json; | |||||
| struct CacheInfo { | |||||
| size_t node_num; | |||||
| size_t edge_num; | |||||
| size_t graph_hash; | |||||
| map<std::string, size_t> nodes_hash; | |||||
| CacheInfo() : node_num(0), edge_num(0), graph_hash(0) {} | |||||
| }; | |||||
| class ModelCacheHelper { | |||||
| public: | |||||
| ModelCacheHelper(uint64_t session_id, uint32_t graph_id, ComputeGraphPtr &compute_graph); | |||||
| ~ModelCacheHelper(); | |||||
| Status SaveCacheInfoToCache () const; | |||||
| Status SaveVarManagerToCache(bool before_build) const; | |||||
| Status SaveOmModelToCache(const GeModelPtr &ge_model) const; | |||||
| bool IsModelCacheHit() const; | |||||
| Status RecoverVarManagerFromCache() const; | |||||
| Status LoadOmModelFromCache(GeModelPtr &ge_model) const; | |||||
| Status RefreshComputeGraph(const ComputeGraphPtr &compute_graph); | |||||
| Status ClearCache(uint32_t graph_id) const; | |||||
| private: | |||||
| Status GetComputeGraphHash(size_t &hash) const; | |||||
| Status GetNodesHash(map<std::string, size_t> &hash_map) const; | |||||
| Status GetCacheInfo(CacheInfo &cache_info) const; | |||||
| Status RecoverMemResource(const Json &json) const; | |||||
| Status RecoverAllocatedGraphId(const Json &json) const; | |||||
| Status RecoverChangedGraphId(const Json &json) const; | |||||
| Status RecoverVarAddrAndTensorDesc(const Json &json) const; | |||||
| Status RecoverBroadcastInfo(const Json &json) const; | |||||
| Status RecoverTransRoads(const Json &json) const; | |||||
| static Status GetNodesNeedRecompile(ComputeGraphPtr &graph, vector<NodePtr> &nodes); | |||||
| static Status RecompileNodes(GeModelPtr &ge_model); | |||||
| bool IsNodeHashSameAsCache(const map<std::string, size_t> &hash_map) const; | |||||
| bool IsMemResourceSameAsCache(Json &json) const; | |||||
| bool IsChangedGraphIdSameAsCache(Json &json) const; | |||||
| bool IsAllocatedGraphIdSameAsCache(Json &json) const; | |||||
| bool IsCurVarTensorDescSameAsCache(Json &json) const; | |||||
| bool IsVarAddrMgrMapSameAsCache(Json &json) const; | |||||
| bool IsBroadcastInfoSameAsCache(Json &json) const; | |||||
| bool IsTransRoadsSameAsCache(Json &json) const; | |||||
| bool IsVarManagerSameAsCache(Json &json) const; | |||||
| bool IsVarManagerParamSameAsCache(Json &json) const; | |||||
| Status SaveJsonToFile(const string &file_name, const Json &json) const; | |||||
| Status LoadJsonFromFile(const string &file_name, Json &json) const; | |||||
| Status GetNodesHashMapJson(Json &json) const; | |||||
| Status GetMemResourceMap(Json &json) const; | |||||
| Status GetVarAddrMgrMapJson(Json &json) const; | |||||
| Status GetCurVarTensorDescMapJson(Json &json) const; | |||||
| Status GetTransRoadsJson(Json &json) const; | |||||
| Status GetChangedGraphIdJson(Json &json) const; | |||||
| Status GetAllocatedGraphIdJson(Json &json) const; | |||||
| Status GetBroadcastInfoJson(Json &json) const; | |||||
| Status GetVarResourceJson(Json &json) const; | |||||
| Status GetVarManagerJson(Json &json) const; | |||||
| static Status TensorDescToJson(const GeTensorDesc &ge_tensor_desc, Json &json); | |||||
| static Status JsonToTensorDesc(const Json &json, GeTensorDesc &ge_tensor_desc); | |||||
| static Status ParseMemResourceFromJson(const Json &json, map<rtMemType_t, int64_t> &mem_resource); | |||||
| static Status ParseVarAddrMgrMapFromJson(const Json &json, | |||||
| std::vector<std::pair<std::string, VarAddrMgr>> &var_addr_mgr_vector, | |||||
| std::set<uint64_t> &var_offset_set); | |||||
| static Status ParseCurVarTensorDescMapFromJson( | |||||
| const Json &json, std::unordered_map<std::string, ge::GeTensorDesc> &cur_var_tensor_desc_map); | |||||
| static Status ParseTransRoadsFromJson(const Json &json, | |||||
| std::unordered_map<std::string, std::vector<TransNodeInfo>> &trans_roads); | |||||
| static Status ParseChangedGraphIdFromJson(const Json &json, | |||||
| std::map<std::string, uint32_t> &changed_graph_id); | |||||
| static Status ParseAllocatedGraphIdFromJson(const Json &json, | |||||
| std::map<std::string, uint32_t> &allocated_graph_id); | |||||
| static Status ParseBroadcastInfoFromJson(const Json &json, | |||||
| std::unordered_map<std::string, VarBroadCastInfo> &var_broadcast_info); | |||||
| static Status GetVarNameFromVarKey(const string &var_key, const GeTensorDesc &tensor_desc, string &var_name); | |||||
| uint64_t session_id_; | |||||
| uint32_t graph_id_; | |||||
| string cache_path_; | |||||
| ComputeGraphPtr compute_graph_; | |||||
| std::set<string> var_names_; | |||||
| bool is_cache_path_valid_for_output; | |||||
| static map<uint32_t, uint32_t> graph_id_run_times_; | |||||
| }; | |||||
| using ModelCacheHelperPtr = std::shared_ptr<ModelCacheHelper>; | |||||
| } // namespace ge | |||||
| #endif // GE_COMMON_HELPER_MODEL_CACHE_HELPER_H_ | |||||
| @@ -33,7 +33,7 @@ const uint32_t kStatiOmFileModelNum = 1; | |||||
| namespace ge { | namespace ge { | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelHelper::~ModelHelper() { (void)ReleaseLocalModelData(); } | |||||
| ModelHelper::~ModelHelper() { (void)ReleaseLocalModelData(); } | |||||
| Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, ModelPartitionType type, | Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, ModelPartitionType type, | ||||
| const uint8_t *data, size_t size, size_t model_index) { | const uint8_t *data, size_t size, size_t model_index) { | ||||
| @@ -108,8 +108,8 @@ Status ModelHelper::SaveSizeToModelDef(const GeModelPtr &ge_model) { | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| Status ModelHelper::SaveModelDef(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, | |||||
| const GeModelPtr &ge_model, ge::Buffer &model_buffer, size_t model_index) { | |||||
| Status ModelHelper::SaveModelDef(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, const GeModelPtr &ge_model, | |||||
| ge::Buffer &model_buffer, size_t model_index) { | |||||
| ModelPtr model_tmp = ge::MakeShared<ge::Model>(ge_model->GetName(), ge_model->GetPlatformVersion()); | ModelPtr model_tmp = ge::MakeShared<ge::Model>(ge_model->GetName(), ge_model->GetPlatformVersion()); | ||||
| if (model_tmp == nullptr) { | if (model_tmp == nullptr) { | ||||
| GELOGE(FAILED, "[Creat][Model]Failed, Model %s Ptr", ge_model->GetName().c_str()); | GELOGE(FAILED, "[Creat][Model]Failed, Model %s Ptr", ge_model->GetName().c_str()); | ||||
| @@ -143,8 +143,8 @@ Status ModelHelper::SaveModelDef(std::shared_ptr<OmFileSaveHelper> &om_file_save | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| Status ModelHelper::SaveModelWeights(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, | |||||
| const GeModelPtr &ge_model, size_t model_index) { | |||||
| Status ModelHelper::SaveModelWeights(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, const GeModelPtr &ge_model, | |||||
| size_t model_index) { | |||||
| auto ge_model_weight = ge_model->GetWeight(); | auto ge_model_weight = ge_model->GetWeight(); | ||||
| GELOGD("WEIGHTS_DATA size is %zu, %p", ge_model_weight.GetSize(), ge_model_weight.GetData()); | GELOGD("WEIGHTS_DATA size is %zu, %p", ge_model_weight.GetSize(), ge_model_weight.GetData()); | ||||
| // weight is not necessary | // weight is not necessary | ||||
| @@ -187,8 +187,8 @@ Status ModelHelper::SaveModelCustAICPU(std::shared_ptr<OmFileSaveHelper> &om_fil | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| Status ModelHelper::SaveModelTaskDef(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, | |||||
| const GeModelPtr &ge_model, ge::Buffer &task_buffer, size_t model_index) { | |||||
| Status ModelHelper::SaveModelTaskDef(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, const GeModelPtr &ge_model, | |||||
| ge::Buffer &task_buffer, size_t model_index) { | |||||
| std::shared_ptr<ModelTaskDef> model_task_def = ge_model->GetModelTaskDefPtr(); | std::shared_ptr<ModelTaskDef> model_task_def = ge_model->GetModelTaskDefPtr(); | ||||
| if (model_task_def == nullptr) { | if (model_task_def == nullptr) { | ||||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Creat][ModelTaskDef]Failed, it is nullptr, " | GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Creat][ModelTaskDef]Failed, it is nullptr, " | ||||
| @@ -231,8 +231,8 @@ Status ModelHelper::SaveModelTaskDef(std::shared_ptr<OmFileSaveHelper> &om_file_ | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| Status ModelHelper::SaveModelHeader(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, | |||||
| const GeModelPtr &ge_model, size_t model_num) { | |||||
| Status ModelHelper::SaveModelHeader(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, const GeModelPtr &ge_model, | |||||
| size_t model_num) { | |||||
| // Save target/version to model_header | // Save target/version to model_header | ||||
| ModelFileHeader &model_header = om_file_save_helper->GetModelFileHeader(); | ModelFileHeader &model_header = om_file_save_helper->GetModelFileHeader(); | ||||
| model_header.platform_type = ge_model->GetPlatformType(); | model_header.platform_type = ge_model->GetPlatformType(); | ||||
| @@ -246,8 +246,10 @@ Status ModelHelper::SaveModelHeader(std::shared_ptr<OmFileSaveHelper> &om_file_s | |||||
| if (err != EOK) { | if (err != EOK) { | ||||
| GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | ||||
| "[Save][Model]Failed while allocating memory for platform_version %s, model %s, " | "[Save][Model]Failed while allocating memory for platform_version %s, model %s, " | ||||
| "errno %d", platform_version.c_str(), ge_model->GetName().c_str(), err); | |||||
| REPORT_CALL_ERROR("E19999", "ModelHelper save model %s failed while " | |||||
| "errno %d", | |||||
| platform_version.c_str(), ge_model->GetName().c_str(), err); | |||||
| REPORT_CALL_ERROR("E19999", | |||||
| "ModelHelper save model %s failed while " | |||||
| "allocating memory for platform_version %s, errno %d", | "allocating memory for platform_version %s, errno %d", | ||||
| ge_model->GetName().c_str(), platform_version.c_str(), err); | ge_model->GetName().c_str(), platform_version.c_str(), err); | ||||
| return ACL_ERROR_GE_MEMORY_ALLOCATION; | return ACL_ERROR_GE_MEMORY_ALLOCATION; | ||||
| @@ -271,9 +273,9 @@ Status ModelHelper::SaveModelHeader(std::shared_ptr<OmFileSaveHelper> &om_file_s | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| Status ModelHelper::SaveAllModelPartiton(std::shared_ptr<OmFileSaveHelper>& om_file_save_helper, | |||||
| const GeModelPtr &ge_model, ge::Buffer &model_buffer, | |||||
| ge::Buffer &task_buffer, size_t model_index) { | |||||
| Status ModelHelper::SaveAllModelPartiton(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, | |||||
| const GeModelPtr &ge_model, ge::Buffer &model_buffer, ge::Buffer &task_buffer, | |||||
| size_t model_index) { | |||||
| if (SaveModelDef(om_file_save_helper, ge_model, model_buffer, model_index) != SUCCESS) { | if (SaveModelDef(om_file_save_helper, ge_model, model_buffer, model_index) != SUCCESS) { | ||||
| GELOGE(FAILED, "[Save][ModelDef]Failed, model %s, model index %zu", | GELOGE(FAILED, "[Save][ModelDef]Failed, model %s, model index %zu", | ||||
| ge_model->GetName().c_str(), model_index); | ge_model->GetName().c_str(), model_index); | ||||
| @@ -316,10 +318,8 @@ Status ModelHelper::SaveAllModelPartiton(std::shared_ptr<OmFileSaveHelper>& om_f | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmModel(const GeModelPtr &ge_model, | |||||
| const SaveParam &save_param, | |||||
| const std::string &output_file, | |||||
| ModelBufferData& model) { | |||||
| Status ModelHelper::SaveToOmModel(const GeModelPtr &ge_model, const SaveParam &save_param, | |||||
| const std::string &output_file, ModelBufferData &model) { | |||||
| if (output_file.empty()) { | if (output_file.empty()) { | ||||
| GELOGE(FAILED, "[Save][Model]GraphBuilder SaveModel received invalid file name prefix, " | GELOGE(FAILED, "[Save][Model]GraphBuilder SaveModel received invalid file name prefix, " | ||||
| "model %s", ge_model->GetName().c_str()); | "model %s", ge_model->GetName().c_str()); | ||||
| @@ -367,13 +367,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRootModel( | |||||
| const GeRootModelPtr &ge_root_model, | |||||
| const SaveParam &save_param, | |||||
| const std::string &output_file, | |||||
| ModelBufferData& model, | |||||
| bool is_unknown_shape) { | |||||
| Status ModelHelper::SaveToOmRootModel(const GeRootModelPtr &ge_root_model, const SaveParam &save_param, | |||||
| const std::string &output_file, ModelBufferData &model, bool is_unknown_shape) { | |||||
| GE_CHECK_NOTNULL(ge_root_model); | GE_CHECK_NOTNULL(ge_root_model); | ||||
| GE_IF_BOOL_EXEC(ge_root_model == nullptr, | GE_IF_BOOL_EXEC(ge_root_model == nullptr, | ||||
| GELOGE(FAILED, "[Check][GERootModel]Ge_root_model is nullptr"); | GELOGE(FAILED, "[Check][GERootModel]Ge_root_model is nullptr"); | ||||
| @@ -466,8 +461,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | |||||
| ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file) { | |||||
| Status ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file) { | |||||
| if (output_file.empty()) { | if (output_file.empty()) { | ||||
| GELOGE(FAILED, "[Save][Model]Received invalid file name prefix, output_file %s", output_file.c_str()); | GELOGE(FAILED, "[Save][Model]Received invalid file name prefix, output_file %s", output_file.c_str()); | ||||
| REPORT_INNER_ERROR("E19999", "Save model received invalid file name prefix, output_file %s", output_file.c_str()); | REPORT_INNER_ERROR("E19999", "Save model received invalid file name prefix, output_file %s", output_file.c_str()); | ||||
| @@ -545,7 +539,7 @@ ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::strin | |||||
| return (ret == SUCCESS ? SUCCESS : FAILED); | return (ret == SUCCESS ? SUCCESS : FAILED); | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(const ge::ModelData &model_data) { | |||||
| Status ModelHelper::LoadModel(const ge::ModelData &model_data) { | |||||
| if (model_data.model_data == nullptr || model_data.model_len == 0) { | if (model_data.model_data == nullptr || model_data.model_len == 0) { | ||||
| GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, | GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, | ||||
| "[Load][Model]Model_data is nullptr or model_data_size is 0"); | "[Load][Model]Model_data is nullptr or model_data_size is 0"); | ||||
| @@ -597,7 +591,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(c | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadRootModel(const ge::ModelData &model_data) { | |||||
| Status ModelHelper::LoadRootModel(const ge::ModelData &model_data) { | |||||
| if (model_data.model_data == nullptr || model_data.model_len == 0) { | if (model_data.model_data == nullptr || model_data.model_len == 0) { | ||||
| GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "[Load][RootModel] " | GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "[Load][RootModel] " | ||||
| "Model_data is nullptr or model data is empty."); | "Model_data is nullptr or model data is empty."); | ||||
| @@ -783,7 +777,6 @@ Status ModelHelper::LoadModelData(OmFileLoadHelper &om_load_helper, GeModelPtr & | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper) { | Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper) { | ||||
| ModelPartition partition; | ModelPartition partition; | ||||
| if (om_load_helper.GetModelPartition(ModelPartitionType::WEIGHTS_DATA, partition) != SUCCESS) { | if (om_load_helper.GetModelPartition(ModelPartitionType::WEIGHTS_DATA, partition) != SUCCESS) { | ||||
| @@ -814,7 +807,7 @@ Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper, GeModelPtr &cu | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadTask(OmFileLoadHelper &om_load_helper) { | |||||
| Status ModelHelper::LoadTask(OmFileLoadHelper &om_load_helper) { | |||||
| ModelPartition task_partition; | ModelPartition task_partition; | ||||
| if (om_load_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition) != SUCCESS) { | if (om_load_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition) != SUCCESS) { | ||||
| GELOGE(FAILED, "[Get][ModelTaskPartition]Failed, task_partition size:%u", task_partition.size); | GELOGE(FAILED, "[Get][ModelTaskPartition]Failed, task_partition size:%u", task_partition.size); | ||||
| @@ -838,9 +831,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadTask(Om | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadTask(OmFileLoadHelper &om_load_helper, | |||||
| GeModelPtr &cur_model, | |||||
| size_t mode_index) { | |||||
| Status ModelHelper::LoadTask(OmFileLoadHelper &om_load_helper, GeModelPtr &cur_model, size_t mode_index) { | |||||
| ModelPartition task_partition; | ModelPartition task_partition; | ||||
| if (om_load_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition, mode_index) != SUCCESS) { | if (om_load_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition, mode_index) != SUCCESS) { | ||||
| GELOGE(FAILED, "Get task model partition failed."); | GELOGE(FAILED, "Get task model partition failed."); | ||||
| @@ -915,8 +906,8 @@ Status ModelHelper::LoadCustAICPUKernelStore(OmFileLoadHelper &om_load_helper) { | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| Status ModelHelper::LoadCustAICPUKernelStore(OmFileLoadHelper &om_load_helper, | |||||
| GeModelPtr &cur_model, size_t mode_index) { | |||||
| Status ModelHelper::LoadCustAICPUKernelStore(OmFileLoadHelper &om_load_helper, GeModelPtr &cur_model, | |||||
| size_t mode_index) { | |||||
| // Load cust aicpu kernels | // Load cust aicpu kernels | ||||
| ModelPartition partition_kernel_def; | ModelPartition partition_kernel_def; | ||||
| CustAICPUKernelStore kernel_store; | CustAICPUKernelStore kernel_store; | ||||
| @@ -933,7 +924,7 @@ Status ModelHelper::LoadCustAICPUKernelStore(OmFileLoadHelper &om_load_helper, | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY GeModelPtr ModelHelper::GetGeModel() { | |||||
| GeModelPtr ModelHelper::GetGeModel() { | |||||
| if (model_ != nullptr) { | if (model_ != nullptr) { | ||||
| return model_; | return model_; | ||||
| } | } | ||||
| @@ -946,7 +937,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY GeModelPtr ModelHelper::GetGeMo | |||||
| return out_model; | return out_model; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY GeRootModelPtr ModelHelper::GetGeRootModel() { | |||||
| GeRootModelPtr ModelHelper::GetGeRootModel() { | |||||
| if (root_model_ != nullptr) { | if (root_model_ != nullptr) { | ||||
| return root_model_; | return root_model_; | ||||
| } | } | ||||
| @@ -959,7 +950,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY GeRootModelPtr ModelHelper::Get | |||||
| return out_model; | return out_model; | ||||
| } | } | ||||
| Status ModelHelper::ReleaseLocalModelData() noexcept { | Status ModelHelper::ReleaseLocalModelData() noexcept { | ||||
| Status result = SUCCESS; | Status result = SUCCESS; | ||||
| if (model_addr_tmp_ != nullptr) { | if (model_addr_tmp_ != nullptr) { | ||||
| @@ -976,8 +966,7 @@ Status ModelHelper::ReleaseLocalModelData() noexcept { | |||||
| return result; | return result; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::GetBaseNameFromFileName( | |||||
| const string &file_name, string &base_name) { | |||||
| Status ModelHelper::GetBaseNameFromFileName(const string &file_name, string &base_name) { | |||||
| GELOGD("Get base_name from file, file_name:%s", file_name.c_str()); | GELOGD("Get base_name from file, file_name:%s", file_name.c_str()); | ||||
| GE_CHK_BOOL_EXEC_WARN(!file_name.empty(), return FAILED, "File path may not valid, check params --output"); | GE_CHK_BOOL_EXEC_WARN(!file_name.empty(), return FAILED, "File path may not valid, check params --output"); | ||||
| size_t start_position = 0; | size_t start_position = 0; | ||||
| @@ -992,8 +981,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::GetBaseName | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::GetModelNameFromMergedGraphName( | |||||
| const string &graph_name, string &model_name) { | |||||
| Status ModelHelper::GetModelNameFromMergedGraphName(const string &graph_name, string &model_name) { | |||||
| GELOGD("Get model_name from graph_name, graph_name:%s", graph_name.c_str()); | GELOGD("Get model_name from graph_name, graph_name:%s", graph_name.c_str()); | ||||
| // this can only be used after merged graph(graph name will be append with "_x", x is index); | // this can only be used after merged graph(graph name will be append with "_x", x is index); | ||||
| GE_CHK_BOOL_EXEC_WARN(!graph_name.empty(), return FAILED, "File path may not valid, check params --output"); | GE_CHK_BOOL_EXEC_WARN(!graph_name.empty(), return FAILED, "File path may not valid, check params --output"); | ||||
| @@ -1035,8 +1023,7 @@ Status ModelTool::GetModelInfoFromOm(const char *model_file, ge::proto::ModelDef | |||||
| ErrorManager::GetInstance().ATCReportErrMessage("E10003", | ErrorManager::GetInstance().ATCReportErrMessage("E10003", | ||||
| {"parameter", "value", "reason"}, {"om", model_file, "invalid om file, can't be parsed"}); | {"parameter", "value", "reason"}, {"om", model_file, "invalid om file, can't be parsed"}); | ||||
| GELOGE(ACL_ERROR_GE_PARAM_INVALID, | GELOGE(ACL_ERROR_GE_PARAM_INVALID, | ||||
| "[Parse][ModelContent]Failed because of invalid om file %s, please check om param", | |||||
| model_file); | |||||
| "[Parse][ModelContent]Failed because of invalid om file %s, please check om param", model_file); | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| @@ -18,10 +18,11 @@ | |||||
| #include <string> | #include <string> | ||||
| #include <vector> | #include <vector> | ||||
| #include "common/math/math_util.h" | |||||
| #include "common/auth/file_saver.h" | #include "common/auth/file_saver.h" | ||||
| #include "framework/common/debug/log.h" | |||||
| #include "common/math/math_util.h" | |||||
| #include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
| #include "framework/common/debug/log.h" | |||||
| #include "framework/common/ge_inner_error_codes.h" | #include "framework/common/ge_inner_error_codes.h" | ||||
| #include "framework/common/util.h" | #include "framework/common/util.h" | ||||
| @@ -32,7 +33,7 @@ const int32_t kOptionalNum = 2; | |||||
| } | } | ||||
| namespace ge { | namespace ge { | ||||
| // For Load | // For Load | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OmFileLoadHelper::Init(const ge::ModelData &model) { | |||||
| Status OmFileLoadHelper::Init(const ge::ModelData &model) { | |||||
| if (CheckModelValid(model) != SUCCESS) { | if (CheckModelValid(model) != SUCCESS) { | ||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| @@ -42,8 +43,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OmFileLoadHelper::Init(c | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OmFileLoadHelper::Init(uint8_t *model_data, | |||||
| const uint32_t model_data_size) { | |||||
| Status OmFileLoadHelper::Init(uint8_t *model_data, const uint32_t model_data_size) { | |||||
| Status status = LoadModelPartitionTable(model_data, model_data_size); | Status status = LoadModelPartitionTable(model_data, model_data_size); | ||||
| if (status != SUCCESS) { | if (status != SUCCESS) { | ||||
| return status; | return status; | ||||
| @@ -52,9 +52,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OmFileLoadHelper::Init(u | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OmFileLoadHelper::Init(uint8_t *model_data, | |||||
| uint32_t model_data_size, | |||||
| uint32_t model_num) { | |||||
| Status OmFileLoadHelper::Init(uint8_t *model_data, uint32_t model_data_size, uint32_t model_num) { | |||||
| Status status = LoadModelPartitionTable(model_data, model_data_size, model_num); | Status status = LoadModelPartitionTable(model_data, model_data_size, model_num); | ||||
| if (status != SUCCESS) { | if (status != SUCCESS) { | ||||
| return status; | return status; | ||||
| @@ -64,8 +62,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OmFileLoadHelper::Init(u | |||||
| } | } | ||||
| // Use both | // Use both | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OmFileLoadHelper::GetModelPartition(ModelPartitionType type, | |||||
| ModelPartition &partition) { | |||||
| Status OmFileLoadHelper::GetModelPartition(ModelPartitionType type, ModelPartition &partition) { | |||||
| if (!is_inited_) { | if (!is_inited_) { | ||||
| GELOGE(PARAM_INVALID, "OmFileLoadHelper has not been initialized!"); | GELOGE(PARAM_INVALID, "OmFileLoadHelper has not been initialized!"); | ||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| @@ -90,9 +87,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OmFileLoadHelper::GetMod | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OmFileLoadHelper::GetModelPartition(ModelPartitionType type, | |||||
| ModelPartition &partition, | |||||
| size_t model_index) { | |||||
| Status OmFileLoadHelper::GetModelPartition(ModelPartitionType type, ModelPartition &partition, size_t model_index) { | |||||
| if (!is_inited_) { | if (!is_inited_) { | ||||
| GELOGE(PARAM_INVALID, "OmFileLoadHelper has not been initialized!"); | GELOGE(PARAM_INVALID, "OmFileLoadHelper has not been initialized!"); | ||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| @@ -248,12 +243,11 @@ Status OmFileLoadHelper::LoadModelPartitionTable(uint8_t *model_data, uint32_t m | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::vector<ModelPartition> | |||||
| &OmFileSaveHelper::GetModelPartitions() const { | |||||
| const std::vector<ModelPartition> &OmFileSaveHelper::GetModelPartitions() const { | |||||
| return context_.partition_datas_; | return context_.partition_datas_; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelPartitionTable *OmFileSaveHelper::GetPartitionTable() { | |||||
| ModelPartitionTable *OmFileSaveHelper::GetPartitionTable() { | |||||
| auto partition_size = static_cast<uint32_t>(context_.partition_datas_.size()); | auto partition_size = static_cast<uint32_t>(context_.partition_datas_.size()); | ||||
| // Build ModelPartitionTable, flex array | // Build ModelPartitionTable, flex array | ||||
| context_.partition_table_.clear(); | context_.partition_table_.clear(); | ||||
| @@ -272,8 +266,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelPartitionTable *OmFileSave | |||||
| return partition_table; | return partition_table; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelPartitionTable *OmFileSaveHelper::GetPartitionTable( | |||||
| size_t cur_ctx_index) { | |||||
| ModelPartitionTable *OmFileSaveHelper::GetPartitionTable(size_t cur_ctx_index) { | |||||
| auto &cur_ctx = model_contexts_[cur_ctx_index]; | auto &cur_ctx = model_contexts_[cur_ctx_index]; | ||||
| auto partition_size = static_cast<uint32_t>(cur_ctx.partition_datas_.size()); | auto partition_size = static_cast<uint32_t>(cur_ctx.partition_datas_.size()); | ||||
| // Build ModelPartitionTable, flex array | // Build ModelPartitionTable, flex array | ||||
| @@ -293,8 +286,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelPartitionTable *OmFileSave | |||||
| return partition_table; | return partition_table; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OmFileSaveHelper::AddPartition(ModelPartition &partition) { | |||||
| Status OmFileSaveHelper::AddPartition(ModelPartition &partition) { | |||||
| if (ge::CheckUint32AddOverflow(context_.model_data_len_, partition.size) != SUCCESS) { | if (ge::CheckUint32AddOverflow(context_.model_data_len_, partition.size) != SUCCESS) { | ||||
| GELOGE(FAILED, "UINT32 %u and %u addition can result in overflow!", context_.model_data_len_, partition.size); | GELOGE(FAILED, "UINT32 %u and %u addition can result in overflow!", context_.model_data_len_, partition.size); | ||||
| return FAILED; | return FAILED; | ||||
| @@ -379,8 +371,8 @@ Status OmFileSaveHelper::SaveModelToFile(const char *output_file, ModelBufferDat | |||||
| #endif | #endif | ||||
| } | } | ||||
| Status OmFileSaveHelper::SaveRootModel(const SaveParam &save_param, const char *output_file, | |||||
| ModelBufferData &model, bool is_offline) { | |||||
| Status OmFileSaveHelper::SaveRootModel(const SaveParam &save_param, const char *output_file, ModelBufferData &model, | |||||
| bool is_offline) { | |||||
| (void)save_param.cert_file; | (void)save_param.cert_file; | ||||
| (void)save_param.ek_file; | (void)save_param.ek_file; | ||||
| (void)save_param.encode_mode; | (void)save_param.encode_mode; | ||||
| @@ -409,8 +401,8 @@ Status OmFileSaveHelper::SaveRootModel(const SaveParam &save_param, const char * | |||||
| model_header_.length += size_of_table + cur_model_data_len; | model_header_.length += size_of_table + cur_model_data_len; | ||||
| model_partition_tabels.push_back(tmp_table); | model_partition_tabels.push_back(tmp_table); | ||||
| all_model_partitions.push_back(cur_ctx.partition_datas_); | all_model_partitions.push_back(cur_ctx.partition_datas_); | ||||
| GELOGD("sizeof(ModelPartitionTable):%u, cur_model_data_len:%u, cur_context_index:%zu", | |||||
| size_of_table, cur_model_data_len, ctx_index); | |||||
| GELOGD("sizeof(ModelPartitionTable):%u, cur_model_data_len:%u, cur_context_index:%zu", size_of_table, | |||||
| cur_model_data_len, ctx_index); | |||||
| } | } | ||||
| Status ret; | Status ret; | ||||
| if (is_offline) { | if (is_offline) { | ||||
| @@ -48,7 +48,7 @@ struct KernelStoreItemHead { | |||||
| uint32_t bin_len; | uint32_t bin_len; | ||||
| }; | }; | ||||
| class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY KernelStore { | |||||
| class KernelStore { | |||||
| public: | public: | ||||
| KernelStore() = default; | KernelStore() = default; | ||||
| virtual ~KernelStore() = default; | virtual ~KernelStore() = default; | ||||
| @@ -14,7 +14,7 @@ | |||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "graph/common/local_context.h" | |||||
| #include "common/local_context.h" | |||||
| #include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
| @@ -18,7 +18,7 @@ | |||||
| #include "external/register/register_types.h" | #include "external/register/register_types.h" | ||||
| namespace ge { | namespace ge { | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t sqrt(fp16_t fp) { | |||||
| fp16_t sqrt(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| // Convert half precision float number to double | // Convert half precision float number to double | ||||
| double dVal = fp; | double dVal = fp; | ||||
| @@ -29,7 +29,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t sqrt(fp16_t fp) { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t rsqrt(fp16_t fp) { | |||||
| fp16_t rsqrt(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| // Convert half precision float number to double | // Convert half precision float number to double | ||||
| double dVal = fp; | double dVal = fp; | ||||
| @@ -40,7 +40,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t rsqrt(fp16_t fp) { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t rcp(fp16_t fp) { | |||||
| fp16_t rcp(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| // Convert half precision float number to double | // Convert half precision float number to double | ||||
| double dVal = fp; | double dVal = fp; | ||||
| @@ -51,7 +51,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t rcp(fp16_t fp) { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t exp(fp16_t fp) { | |||||
| fp16_t exp(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| // Convert half precision float number to double | // Convert half precision float number to double | ||||
| double dVal = fp; | double dVal = fp; | ||||
| @@ -63,7 +63,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t exp(fp16_t fp) { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t pow2(fp16_t fp) { | |||||
| fp16_t pow2(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| // Convert half precision float number to double | // Convert half precision float number to double | ||||
| double dVal = fp; | double dVal = fp; | ||||
| @@ -75,7 +75,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t pow2(fp16_t fp) { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t pow10(fp16_t fp) { | |||||
| fp16_t pow10(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| // Convert half precision float number to double | // Convert half precision float number to double | ||||
| double dVal = fp; | double dVal = fp; | ||||
| @@ -87,7 +87,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t pow10(fp16_t fp) { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t ln(fp16_t fp) { | |||||
| fp16_t ln(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| // Convert half precision float number to double | // Convert half precision float number to double | ||||
| double dVal = fp; | double dVal = fp; | ||||
| @@ -99,7 +99,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t ln(fp16_t fp) { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t log2(fp16_t fp) { | |||||
| fp16_t log2(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| // Convert half precision float number to double | // Convert half precision float number to double | ||||
| double dVal = fp; | double dVal = fp; | ||||
| @@ -111,7 +111,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t log2(fp16_t fp) { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t log10(fp16_t fp) { | |||||
| fp16_t log10(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| // Convert half precision float number to double | // Convert half precision float number to double | ||||
| double dVal = fp; | double dVal = fp; | ||||
| @@ -123,7 +123,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t log10(fp16_t fp) { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t cos(fp16_t fp) { | |||||
| fp16_t cos(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| // Convert half precision float number to double | // Convert half precision float number to double | ||||
| double dVal = fp; | double dVal = fp; | ||||
| @@ -135,7 +135,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t cos(fp16_t fp) { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t sin(fp16_t fp) { | |||||
| fp16_t sin(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| // Convert half precision float number to double | // Convert half precision float number to double | ||||
| double dVal = fp; | double dVal = fp; | ||||
| @@ -147,13 +147,13 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t sin(fp16_t fp) { | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t abs(fp16_t fp) { | |||||
| fp16_t abs(fp16_t fp) { | |||||
| fp16_t ret; | fp16_t ret; | ||||
| ret.val = (fp.val & kFp16AbsMax); | ret.val = (fp.val & kFp16AbsMax); | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t max(fp16_t fp1, fp16_t fp2) { | |||||
| fp16_t max(fp16_t fp1, fp16_t fp2) { | |||||
| if (fp1 >= fp2) { | if (fp1 >= fp2) { | ||||
| return fp1; | return fp1; | ||||
| } else { | } else { | ||||
| @@ -161,7 +161,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t max(fp16_t fp1, fp16_t f | |||||
| } | } | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY fp16_t min(fp16_t fp1, fp16_t fp2) { | |||||
| fp16_t min(fp16_t fp1, fp16_t fp2) { | |||||
| if (fp1 <= fp2) { | if (fp1 <= fp2) { | ||||
| return fp1; | return fp1; | ||||
| } else { | } else { | ||||
| @@ -14,7 +14,7 @@ | |||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "model/ge_model.h" | |||||
| #include "common/model/ge_model.h" | |||||
| #include <utility> | #include <utility> | ||||
| #include "framework/common/debug/log.h" | #include "framework/common/debug/log.h" | ||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| @@ -31,7 +31,7 @@ | |||||
| namespace ge { | namespace ge { | ||||
| const uint32_t INVALID_MODEL_ID = 0xFFFFFFFFUL; | const uint32_t INVALID_MODEL_ID = 0xFFFFFFFFUL; | ||||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeModel : public AttrHolder { | |||||
| class GeModel : public AttrHolder { | |||||
| public: | public: | ||||
| GeModel(); | GeModel(); | ||||
| ~GeModel() = default; | ~GeModel() = default; | ||||
| @@ -82,13 +82,13 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeModel : public AttrHolder | |||||
| private: | private: | ||||
| void Init(); | void Init(); | ||||
| ProtoAttrMapHelper attrs_; | |||||
| ProtoAttrMapHelper attrs_; /*lint !e148*/ | |||||
| Graph graph_; | Graph graph_; | ||||
| std::shared_ptr<domi::ModelTaskDef> task_; | |||||
| TBEKernelStore tbe_kernal_store_; | |||||
| CustAICPUKernelStore cust_aicpu_kernal_store_; | |||||
| Buffer weights_buffer_; | |||||
| std::shared_ptr<domi::ModelTaskDef> task_; /*lint !e148*/ | |||||
| TBEKernelStore tbe_kernal_store_; /*lint !e148*/ | |||||
| CustAICPUKernelStore cust_aicpu_kernal_store_; /*lint !e148*/ | |||||
| Buffer weights_buffer_; /*lint !e148*/ | |||||
| std::string name_; | std::string name_; | ||||
| uint32_t version_ = {0}; | uint32_t version_ = {0}; | ||||
| @@ -14,8 +14,9 @@ | |||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "model/ge_root_model.h" | |||||
| #include "common/model/ge_root_model.h" | |||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| namespace ge { | namespace ge { | ||||
| void GeRootModel::SetSubgraphInstanceNameToModel(string instance_name, GeModelPtr ge_model) { | void GeRootModel::SetSubgraphInstanceNameToModel(string instance_name, GeModelPtr ge_model) { | ||||
| subgraph_instance_name_to_model_.insert(std::pair<string, GeModelPtr>(instance_name, ge_model)); | subgraph_instance_name_to_model_.insert(std::pair<string, GeModelPtr>(instance_name, ge_model)); | ||||
| @@ -15,7 +15,7 @@ | |||||
| */ | */ | ||||
| #include <map> | #include <map> | ||||
| #include "graph/compute_graph.h" | #include "graph/compute_graph.h" | ||||
| #include "model/ge_model.h" | |||||
| #include "common/model/ge_model.h" | |||||
| #ifndef GE_MODEL_GE_ROOT_MODEL_H_ | #ifndef GE_MODEL_GE_ROOT_MODEL_H_ | ||||
| #define GE_MODEL_GE_ROOT_MODEL_H_ | #define GE_MODEL_GE_ROOT_MODEL_H_ | ||||
| @@ -23,12 +23,10 @@ | |||||
| #include "framework/common/helper/model_helper.h" | #include "framework/common/helper/model_helper.h" | ||||
| namespace ge { | namespace ge { | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelParserBase::ModelParserBase() {} | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelParserBase::~ModelParserBase() {} | |||||
| ModelParserBase::ModelParserBase() {} | |||||
| ModelParserBase::~ModelParserBase() {} | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFromFile(const char *model_path, | |||||
| int32_t priority, | |||||
| ge::ModelData &model_data) { | |||||
| Status ModelParserBase::LoadFromFile(const char *model_path, int32_t priority, ge::ModelData &model_data) { | |||||
| std::string real_path = RealPath(model_path); | std::string real_path = RealPath(model_path); | ||||
| if (real_path.empty()) { | if (real_path.empty()) { | ||||
| GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "[Check][Param]Model file path %s is invalid", | GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "[Check][Param]Model file path %s is invalid", | ||||
| @@ -81,9 +79,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::ParseModelContent(const ge::ModelData &model, | |||||
| uint8_t *&model_data, | |||||
| uint32_t &model_len) { | |||||
| Status ModelParserBase::ParseModelContent(const ge::ModelData &model, uint8_t *&model_data, uint32_t &model_len) { | |||||
| // Parameter validity check | // Parameter validity check | ||||
| GE_CHECK_NOTNULL(model.model_data); | GE_CHECK_NOTNULL(model.model_data); | ||||
| @@ -29,8 +29,7 @@ | |||||
| namespace ge { | namespace ge { | ||||
| const uint32_t kInteval = 2; | const uint32_t kInteval = 2; | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFile(const char *file_path, | |||||
| const Json &model) { | |||||
| Status ModelSaver::SaveJsonToFile(const char *file_path, const Json &model) { | |||||
| Status ret = SUCCESS; | Status ret = SUCCESS; | ||||
| if (file_path == nullptr || SUCCESS != CheckPath(file_path)) { | if (file_path == nullptr || SUCCESS != CheckPath(file_path)) { | ||||
| GELOGE(FAILED, "[Check][OutputFile]Failed, file %s", file_path); | GELOGE(FAILED, "[Check][OutputFile]Failed, file %s", file_path); | ||||
| @@ -14,7 +14,7 @@ | |||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "graph/common/omg_util.h" | |||||
| #include "common/omg_util.h" | |||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/utils/graph_utils.h" | #include "graph/utils/graph_utils.h" | ||||
| @@ -59,8 +59,8 @@ Status SetStreamLabel(const ge::NodePtr &node, const std::string &label) { | |||||
| if (!AttrUtils::SetStr(tmp_desc, ge::ATTR_NAME_STREAM_LABEL, label)) { | if (!AttrUtils::SetStr(tmp_desc, ge::ATTR_NAME_STREAM_LABEL, label)) { | ||||
| REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_STREAM_LABEL.c_str(), | REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_STREAM_LABEL.c_str(), | ||||
| node->GetName().c_str(), node->GetType().c_str()); | node->GetName().c_str(), node->GetType().c_str()); | ||||
| GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_STREAM_LABEL.c_str(), | |||||
| node->GetName().c_str(), node->GetType().c_str()); | |||||
| GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_STREAM_LABEL.c_str(), node->GetName().c_str(), | |||||
| node->GetType().c_str()); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| @@ -100,8 +100,8 @@ Status SetActiveLabelList(const ge::NodePtr &node, const std::vector<std::string | |||||
| if (!AttrUtils::SetListStr(tmp_desc, ge::ATTR_NAME_ACTIVE_LABEL_LIST, active_label_list)) { | if (!AttrUtils::SetListStr(tmp_desc, ge::ATTR_NAME_ACTIVE_LABEL_LIST, active_label_list)) { | ||||
| REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_ACTIVE_LABEL_LIST.c_str(), | REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_ACTIVE_LABEL_LIST.c_str(), | ||||
| node->GetName().c_str(), node->GetType().c_str()); | node->GetName().c_str(), node->GetType().c_str()); | ||||
| GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_ACTIVE_LABEL_LIST.c_str(), | |||||
| node->GetName().c_str(), node->GetType().c_str()); | |||||
| GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_ACTIVE_LABEL_LIST.c_str(), node->GetName().c_str(), | |||||
| node->GetType().c_str()); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| @@ -163,8 +163,8 @@ Status SetOriginalNodeName(const ge::NodePtr &node, const std::string &orig_name | |||||
| if (!AttrUtils::SetStr(tmp_desc, ge::ATTR_NAME_ORIG_NODE_NAME, orig_name)) { | if (!AttrUtils::SetStr(tmp_desc, ge::ATTR_NAME_ORIG_NODE_NAME, orig_name)) { | ||||
| REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_ORIG_NODE_NAME.c_str(), | REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_ORIG_NODE_NAME.c_str(), | ||||
| node->GetName().c_str(), node->GetType().c_str()); | node->GetName().c_str(), node->GetType().c_str()); | ||||
| GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_ORIG_NODE_NAME.c_str(), | |||||
| node->GetName().c_str(), node->GetType().c_str()); | |||||
| GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_ORIG_NODE_NAME.c_str(), node->GetName().c_str(), | |||||
| node->GetType().c_str()); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| @@ -207,8 +207,8 @@ Status SetNextIteration(const NodePtr &node, const NodePtr &next) { | |||||
| if (!AttrUtils::SetStr(op_desc, ATTR_NAME_NEXT_ITERATION, name)) { | if (!AttrUtils::SetStr(op_desc, ATTR_NAME_NEXT_ITERATION, name)) { | ||||
| REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_NEXT_ITERATION.c_str(), | REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_NEXT_ITERATION.c_str(), | ||||
| op_desc->GetName().c_str(), op_desc->GetType().c_str()); | op_desc->GetName().c_str(), op_desc->GetType().c_str()); | ||||
| GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_NEXT_ITERATION.c_str(), | |||||
| op_desc->GetName().c_str(), op_desc->GetType().c_str()); | |||||
| GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_NEXT_ITERATION.c_str(), op_desc->GetName().c_str(), | |||||
| op_desc->GetType().c_str()); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| return SUCCESS; | return SUCCESS; | ||||
| @@ -290,8 +290,8 @@ void SetControlFlowGroup(const NodePtr &node, int64_t group) { | |||||
| if (!AttrUtils::SetInt(op_desc, ATTR_NAME_CONTROL_FLOW_GROUP, group)) { | if (!AttrUtils::SetInt(op_desc, ATTR_NAME_CONTROL_FLOW_GROUP, group)) { | ||||
| REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_CONTROL_FLOW_GROUP.c_str(), | REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_CONTROL_FLOW_GROUP.c_str(), | ||||
| node->GetName().c_str(), node->GetType().c_str()); | node->GetName().c_str(), node->GetType().c_str()); | ||||
| GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_CONTROL_FLOW_GROUP.c_str(), | |||||
| node->GetName().c_str(), node->GetType().c_str()); | |||||
| GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_CONTROL_FLOW_GROUP.c_str(), node->GetName().c_str(), | |||||
| node->GetType().c_str()); | |||||
| } | } | ||||
| } | } | ||||
| } // namespace ge | } // namespace ge | ||||
| @@ -27,11 +27,10 @@ | |||||
| #include "graph/node.h" | #include "graph/node.h" | ||||
| namespace ge { | namespace ge { | ||||
| namespace { | |||||
| const int64_t kBufferPoolMemAlignSize = 512; | |||||
| const uint32_t kBufferPoolNodeOutIndex = 0; | |||||
| const uint32_t kEventReuseThreshold = 65500; | |||||
| } // namespace | |||||
| static constexpr int64_t kBufferPoolMemAlignSize = 512; | |||||
| static constexpr uint32_t kBufferPoolNodeOutIndex = 0; | |||||
| static constexpr uint32_t kEventReuseThreshold = 65500; | |||||
| /// | /// | ||||
| /// @brief get the Original Type of FrameworkOp | /// @brief get the Original Type of FrameworkOp | ||||
| /// @param [in] node | /// @param [in] node | ||||
| @@ -77,37 +77,33 @@ DEFINE_SET_ATTR_VALUE_LIST(const std::string &, s); | |||||
| } \ | } \ | ||||
| } while (0); | } while (0); | ||||
| #define DEFINE_ADD_ATTR_VALUE(KEY_TYPE, VALUE_TYPE) \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpAttr(KEY_TYPE map_key, VALUE_TYPE value, OpDef *op_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(op_def); \ | |||||
| auto attr = op_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP(map_key, value, attr) \ | |||||
| } \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpAttr(KEY_TYPE map_key, VALUE_TYPE value, \ | |||||
| AttrDefMap *attr_map) { \ | |||||
| ADD_TO_ATTR_MAP(map_key, value, attr_map) \ | |||||
| } \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddModelAttr(KEY_TYPE map_key, VALUE_TYPE value, \ | |||||
| ModelDef *model_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(model_def); \ | |||||
| auto attr = model_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP(map_key, value, attr) \ | |||||
| #define DEFINE_ADD_ATTR_VALUE(KEY_TYPE, VALUE_TYPE) \ | |||||
| void AddOpAttr(KEY_TYPE map_key, VALUE_TYPE value, OpDef *op_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(op_def); \ | |||||
| auto attr = op_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP(map_key, value, attr) \ | |||||
| } \ | |||||
| void AddOpAttr(KEY_TYPE map_key, VALUE_TYPE value, AttrDefMap *attr_map) { \ | |||||
| ADD_TO_ATTR_MAP(map_key, value, attr_map) \ | |||||
| } \ | |||||
| void AddModelAttr(KEY_TYPE map_key, VALUE_TYPE value, ModelDef *model_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(model_def); \ | |||||
| auto attr = model_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP(map_key, value, attr) \ | |||||
| } | } | ||||
| #define DEFINE_ADD_ATTR_VALUE_LIST(KEY_TYPE, VALUE_TYPE) \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpAttrList(KEY_TYPE map_key, VALUE_TYPE value, \ | |||||
| OpDef *op_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(op_def); \ | |||||
| auto attr = op_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr) \ | |||||
| } \ | |||||
| FMK_FUNC_DEV_VISIBILITY void AddOpAttrList(KEY_TYPE map_key, VALUE_TYPE value, AttrDefMap *attr_map) { \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr_map) \ | |||||
| } \ | |||||
| FMK_FUNC_DEV_VISIBILITY void AddModelAttrList(KEY_TYPE map_key, VALUE_TYPE value, ModelDef *model_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(model_def); \ | |||||
| auto attr = model_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr) \ | |||||
| #define DEFINE_ADD_ATTR_VALUE_LIST(KEY_TYPE, VALUE_TYPE) \ | |||||
| void AddOpAttrList(KEY_TYPE map_key, VALUE_TYPE value, OpDef *op_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(op_def); \ | |||||
| auto attr = op_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr) \ | |||||
| } \ | |||||
| void AddOpAttrList(KEY_TYPE map_key, VALUE_TYPE value, AttrDefMap *attr_map) { \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr_map)} FMK_FUNC_DEV_VISIBILITY void \ | |||||
| AddModelAttrList(KEY_TYPE map_key, VALUE_TYPE value, ModelDef *model_def) { \ | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(model_def); \ | |||||
| auto attr = model_def->mutable_attr(); \ | |||||
| ADD_TO_ATTR_MAP_LIST(map_key, value, attr) \ | |||||
| } | } | ||||
| DEFINE_ADD_ATTR_VALUE(const std::string &, const std::string &); | DEFINE_ADD_ATTR_VALUE(const std::string &, const std::string &); | ||||
| @@ -127,46 +123,42 @@ DEFINE_ADD_ATTR_VALUE_LIST(const std::string &, const bool); | |||||
| DEFINE_ADD_ATTR_VALUE_LIST(const std::string &, const int64_t); | DEFINE_ADD_ATTR_VALUE_LIST(const std::string &, const int64_t); | ||||
| DEFINE_ADD_ATTR_VALUE_LIST(const std::string &, const std::string &); | DEFINE_ADD_ATTR_VALUE_LIST(const std::string &, const std::string &); | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpAttr(const std::string &map_key, AttrDef &attr, | |||||
| OpDef *op_def) { | |||||
| void AddOpAttr(const std::string &map_key, AttrDef &attr, OpDef *op_def) { | |||||
| GE_CHECK_NOTNULL_JUST_RETURN(op_def); | GE_CHECK_NOTNULL_JUST_RETURN(op_def); | ||||
| GE_CHECK_NOTNULL_JUST_RETURN(op_def->mutable_attr()); | GE_CHECK_NOTNULL_JUST_RETURN(op_def->mutable_attr()); | ||||
| (void)op_def->mutable_attr()->insert(AttrDefPair(map_key, attr)); | (void)op_def->mutable_attr()->insert(AttrDefPair(map_key, attr)); | ||||
| } | } | ||||
| #define DEFINE_GET_ATTR_VALUE(ARG_TYPE_KEY, ARG_TYPE_VALUE, FIELD) \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool GetAttrDefValue(ARG_TYPE_KEY map_key, ARG_TYPE_VALUE value, \ | |||||
| const AttrDefMap &attr) { \ | |||||
| auto it = attr.find(map_key); \ | |||||
| if (it != attr.end()) { \ | |||||
| *value = it->second.FIELD(); \ | |||||
| return true; \ | |||||
| } \ | |||||
| return false; \ | |||||
| #define DEFINE_GET_ATTR_VALUE(ARG_TYPE_KEY, ARG_TYPE_VALUE, FIELD) \ | |||||
| bool GetAttrDefValue(ARG_TYPE_KEY map_key, ARG_TYPE_VALUE value, const AttrDefMap &attr) { \ | |||||
| auto it = attr.find(map_key); \ | |||||
| if (it != attr.end()) { \ | |||||
| *value = it->second.FIELD(); \ | |||||
| return true; \ | |||||
| } \ | |||||
| return false; \ | |||||
| } | } | ||||
| #define DEFINE_GET_ATTR_POINT_REF(ARG_TYPE_KEY, ARG_TYPE_VALUE, FIELD) \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool GetAttrDefValue(ARG_TYPE_KEY map_key, ARG_TYPE_VALUE *&value, \ | |||||
| AttrDefMap *attr) { \ | |||||
| GE_RT_FALSE_CHECK_NOTNULL(attr); \ | |||||
| auto it = attr->find(map_key); \ | |||||
| if (it != attr->end()) { \ | |||||
| value = it->second.mutable_##FIELD(); \ | |||||
| return true; \ | |||||
| } \ | |||||
| return false; \ | |||||
| #define DEFINE_GET_ATTR_POINT_REF(ARG_TYPE_KEY, ARG_TYPE_VALUE, FIELD) \ | |||||
| bool GetAttrDefValue(ARG_TYPE_KEY map_key, ARG_TYPE_VALUE *&value, AttrDefMap *attr) { \ | |||||
| GE_RT_FALSE_CHECK_NOTNULL(attr); \ | |||||
| auto it = attr->find(map_key); \ | |||||
| if (it != attr->end()) { \ | |||||
| value = it->second.mutable_##FIELD(); \ | |||||
| return true; \ | |||||
| } \ | |||||
| return false; \ | |||||
| } | } | ||||
| #define DEFINE_GET_ATTR_CONST_POINT_REF(ARG_TYPE_KEY, ARG_TYPE_VALUE, FIELD) \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool GetAttrDefValue( \ | |||||
| ARG_TYPE_KEY map_key, const ARG_TYPE_VALUE *&value, const AttrDefMap &attr) { \ | |||||
| auto it = attr.find(map_key); \ | |||||
| if (it == attr.end()) { \ | |||||
| return false; \ | |||||
| } \ | |||||
| \ | |||||
| value = &(it->second.FIELD()); \ | |||||
| return true; \ | |||||
| #define DEFINE_GET_ATTR_CONST_POINT_REF(ARG_TYPE_KEY, ARG_TYPE_VALUE, FIELD) \ | |||||
| bool GetAttrDefValue(ARG_TYPE_KEY map_key, const ARG_TYPE_VALUE *&value, const AttrDefMap &attr) { \ | |||||
| auto it = attr.find(map_key); \ | |||||
| if (it == attr.end()) { \ | |||||
| return false; \ | |||||
| } \ | |||||
| \ | |||||
| value = &(it->second.FIELD()); \ | |||||
| return true; \ | |||||
| } | } | ||||
| #define DEFINE_GET_BYTES_ATTR_VALUE(ARG_TYPE_KEY, ARG_TYPE_VALUE) \ | #define DEFINE_GET_BYTES_ATTR_VALUE(ARG_TYPE_KEY, ARG_TYPE_VALUE) \ | ||||
| @@ -216,16 +208,14 @@ DEFINE_GET_ATTR_CONST_POINT_REF(const std::string &, NamedAttrs, func); | |||||
| DEFINE_GET_BYTES_ATTR_VALUE(const std::string &, std::string *); | DEFINE_GET_BYTES_ATTR_VALUE(const std::string &, std::string *); | ||||
| #define DEFINE_GET_OP_ATTR(ARG_TYPE_KEY, ARG_TYPE_VALUE) \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool GetOpAttr(ARG_TYPE_KEY map_key, ARG_TYPE_VALUE value, \ | |||||
| const OpDef *op_def) { \ | |||||
| GE_RT_FALSE_CHECK_NOTNULL(op_def); \ | |||||
| return GetAttrDefValue(map_key, value, op_def->attr()); \ | |||||
| } \ | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool GetModelAttr(ARG_TYPE_KEY map_key, ARG_TYPE_VALUE value, \ | |||||
| const ModelDef *model_def) { \ | |||||
| GE_RT_FALSE_CHECK_NOTNULL(model_def); \ | |||||
| return GetAttrDefValue(map_key, value, model_def->attr()); \ | |||||
| #define DEFINE_GET_OP_ATTR(ARG_TYPE_KEY, ARG_TYPE_VALUE) \ | |||||
| bool GetOpAttr(ARG_TYPE_KEY map_key, ARG_TYPE_VALUE value, const OpDef *op_def) { \ | |||||
| GE_RT_FALSE_CHECK_NOTNULL(op_def); \ | |||||
| return GetAttrDefValue(map_key, value, op_def->attr()); \ | |||||
| } \ | |||||
| bool GetModelAttr(ARG_TYPE_KEY map_key, ARG_TYPE_VALUE value, const ModelDef *model_def) { \ | |||||
| GE_RT_FALSE_CHECK_NOTNULL(model_def); \ | |||||
| return GetAttrDefValue(map_key, value, model_def->attr()); \ | |||||
| } | } | ||||
| DEFINE_GET_OP_ATTR(const std::string &, std::string *); | DEFINE_GET_OP_ATTR(const std::string &, std::string *); | ||||
| @@ -238,8 +228,7 @@ DEFINE_GET_OP_ATTR(const std::string &, bool *); | |||||
| DEFINE_GET_OP_ATTR(const std::string &, AttrDef_ListValue *); | DEFINE_GET_OP_ATTR(const std::string &, AttrDef_ListValue *); | ||||
| #define DEFINE_GET_BT_ATTR(ARG_TYPE_KEY, ARG_TYPE_VALUE) \ | #define DEFINE_GET_BT_ATTR(ARG_TYPE_KEY, ARG_TYPE_VALUE) \ | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool GetBytesAttr(ARG_TYPE_KEY key, ARG_TYPE_VALUE value, \ | |||||
| const OpDef *op_def) { \ | |||||
| bool GetBytesAttr(ARG_TYPE_KEY key, ARG_TYPE_VALUE value, const OpDef *op_def) { \ | |||||
| GE_RT_FALSE_CHECK_NOTNULL(op_def); \ | GE_RT_FALSE_CHECK_NOTNULL(op_def); \ | ||||
| return GetBytesValue(key, value, op_def->attr()); \ | return GetBytesValue(key, value, op_def->attr()); \ | ||||
| } \ | } \ | ||||
| @@ -250,7 +239,7 @@ DEFINE_GET_OP_ATTR(const std::string &, AttrDef_ListValue *); | |||||
| DEFINE_GET_BT_ATTR(const std::string &, std::string *); | DEFINE_GET_BT_ATTR(const std::string &, std::string *); | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool HasOpAttr(const OpDef *op_def, const std::string &attr_name) { | |||||
| bool HasOpAttr(const OpDef *op_def, const std::string &attr_name) { | |||||
| if (op_def == nullptr) { | if (op_def == nullptr) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -263,8 +252,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool HasOpAttr(const OpDef *op_ | |||||
| return false; | return false; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddModelAttr(const std::string &map_key, const void *value, | |||||
| size_t size, ModelDef *model_def) { | |||||
| void AddModelAttr(const std::string &map_key, const void *value, size_t size, ModelDef *model_def) { | |||||
| if (model_def == nullptr) { | if (model_def == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -280,8 +268,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddModelAttr(const std::st | |||||
| } | } | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void AddOpBytesAttr(const std::string &key, const void *value, | |||||
| size_t size, OpDef *op_def) { | |||||
| void AddOpBytesAttr(const std::string &key, const void *value, size_t size, OpDef *op_def) { | |||||
| if (op_def == nullptr) { | if (op_def == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -115,8 +115,7 @@ const int NORMAL_TENSOR_SIZE = 4; | |||||
| #define AIPP_CONVERT_LIST_FLOAT(KEY, REQUIRED) AIPP_CONVERT_LIST_FORMAT(KEY, float, REQUIRED, GeAttrValue::FLOAT) | #define AIPP_CONVERT_LIST_FLOAT(KEY, REQUIRED) AIPP_CONVERT_LIST_FORMAT(KEY, float, REQUIRED, GeAttrValue::FLOAT) | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | |||||
| OpUtils::ConvertAippParams(const GeAttrValue::NAMED_ATTRS &aipp_attr, domi::AippOpParams *aipp_params) { | |||||
| Status OpUtils::ConvertAippParams(const GeAttrValue::NAMED_ATTRS &aipp_attr, domi::AippOpParams *aipp_params) { | |||||
| GE_CHECK_NOTNULL(aipp_params); | GE_CHECK_NOTNULL(aipp_params); | ||||
| AIPP_CONVERT_FORMAT_EX(aipp_mode, domi::AippOpParams::AippMode, int32_t, GeAttrValue::INT); | AIPP_CONVERT_FORMAT_EX(aipp_mode, domi::AippOpParams::AippMode, int32_t, GeAttrValue::INT); | ||||
| AIPP_CONVERT_INT(related_input_rank); | AIPP_CONVERT_INT(related_input_rank); | ||||
| @@ -178,8 +177,7 @@ OpUtils::ConvertAippParams(const GeAttrValue::NAMED_ATTRS &aipp_attr, domi::Aipp | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OpUtils::TransferDim(const std::vector<int64_t> &dim, | |||||
| std::vector<int64_t> &dim_vector) { | |||||
| Status OpUtils::TransferDim(const std::vector<int64_t> &dim, std::vector<int64_t> &dim_vector) { | |||||
| size_t input_shape_size = dim.size(); | size_t input_shape_size = dim.size(); | ||||
| std::list<uint32_t> new_dim_list; | std::list<uint32_t> new_dim_list; | ||||
| for (auto dim_temp : dim) { | for (auto dim_temp : dim) { | ||||
| @@ -301,9 +299,9 @@ Status OpUtils::SetOutputSliceDataByDataType(void *data, int64_t data_size, cons | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OpUtils::SetOutputSliceData( | |||||
| void *data, int64_t data_size, int32_t data_type, std::vector<int64_t> &input_dims, std::vector<int64_t> &begin, | |||||
| std::vector<int64_t> &output_dims, GeTensor *output, std::vector<int64_t> &stride) { | |||||
| Status OpUtils::SetOutputSliceData(void *data, int64_t data_size, int32_t data_type, std::vector<int64_t> &input_dims, | |||||
| std::vector<int64_t> &begin, std::vector<int64_t> &output_dims, GeTensor *output, | |||||
| std::vector<int64_t> &stride) { | |||||
| if (data == nullptr || output == nullptr) { | if (data == nullptr || output == nullptr) { | ||||
| GELOGE(PARAM_INVALID, "[Check][Param]Input param is nullptr"); | GELOGE(PARAM_INVALID, "[Check][Param]Input param is nullptr"); | ||||
| REPORT_INNER_ERROR("E19999", "Input param is nullptr"); | REPORT_INNER_ERROR("E19999", "Input param is nullptr"); | ||||
| @@ -352,9 +350,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OpUtils::SetOutputSliceD | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void OpUtils::TransDataHWCK2KCHW(const void *input, int64_t h, | |||||
| int64_t w, int64_t c, int64_t k, | |||||
| void **output) { | |||||
| void OpUtils::TransDataHWCK2KCHW(const void *input, int64_t h, int64_t w, int64_t c, int64_t k, void **output) { | |||||
| if (input == nullptr) { | if (input == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| @@ -386,9 +382,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void OpUtils::TransDataHWCK2KCH | |||||
| *output = buf; | *output = buf; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void OpUtils::TransDataKCHW2HWCK(const void *input, int64_t k, | |||||
| int64_t c, int64_t h, int64_t w, | |||||
| void *output) { | |||||
| void OpUtils::TransDataKCHW2HWCK(const void *input, int64_t k, int64_t c, int64_t h, int64_t w, void *output) { | |||||
| if ((input == nullptr) || (output == nullptr)) { | if ((input == nullptr) || (output == nullptr)) { | ||||
| GELOGD("%s[%d]: input param is nullptr.", __FILE__, __LINE__); | GELOGD("%s[%d]: input param is nullptr.", __FILE__, __LINE__); | ||||
| return; | return; | ||||
| @@ -417,31 +411,22 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void OpUtils::TransDataKCHW2HWC | |||||
| vector<ConstGeTensorPtr> OpUtils::GetWeights(const ge::Node &node) { return OpDescUtils::GetWeights(node); } | vector<ConstGeTensorPtr> OpUtils::GetWeights(const ge::Node &node) { return OpDescUtils::GetWeights(node); } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY vector<ConstGeTensorPtr> OpUtils::GetWeights(ge::ConstNodePtr node) { | |||||
| return OpDescUtils::GetWeights(node); | |||||
| } | |||||
| vector<ConstGeTensorPtr> OpUtils::GetWeights(ge::ConstNodePtr node) { return OpDescUtils::GetWeights(node); } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY vector<GeTensorPtr> OpUtils::MutableWeights(const ge::Node &node) { | |||||
| return OpDescUtils::MutableWeights(node); | |||||
| } | |||||
| vector<GeTensorPtr> OpUtils::MutableWeights(const ge::Node &node) { return OpDescUtils::MutableWeights(node); } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY vector<GeTensorPtr> OpUtils::MutableWeights(const ge::NodePtr node) { | |||||
| return OpDescUtils::MutableWeights(node); | |||||
| } | |||||
| vector<GeTensorPtr> OpUtils::MutableWeights(const ge::NodePtr node) { return OpDescUtils::MutableWeights(node); } | |||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OpUtils::SetWeights(ge::Node &node, | |||||
| const vector<ge::GeTensorPtr> &weights) { | |||||
| Status OpUtils::SetWeights(ge::Node &node, const vector<ge::GeTensorPtr> &weights) { | |||||
| return OpDescUtils::SetWeights(node, weights); | return OpDescUtils::SetWeights(node, weights); | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status OpUtils::SetWeights(ge::NodePtr node, | |||||
| const vector<ge::GeTensorPtr> &weights) { | |||||
| Status OpUtils::SetWeights(ge::NodePtr node, const vector<ge::GeTensorPtr> &weights) { | |||||
| return OpDescUtils::SetWeights(node, weights); | return OpDescUtils::SetWeights(node, weights); | ||||
| } | } | ||||
| // The caller guarantees that the input sensor is constant | // The caller guarantees that the input sensor is constant | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | |||||
| OpUtils::GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType type, std::vector<int64_t> &dims) { | |||||
| Status OpUtils::GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType type, std::vector<int64_t> &dims) { | |||||
| if (tensor == nullptr) { | if (tensor == nullptr) { | ||||
| GELOGE(PARAM_INVALID, "[Check][Param]Input tensor is nullptr"); | GELOGE(PARAM_INVALID, "[Check][Param]Input tensor is nullptr"); | ||||
| REPORT_INNER_ERROR("E19999", "Input tensor is nullptr"); | REPORT_INNER_ERROR("E19999", "Input tensor is nullptr"); | ||||
| @@ -23,7 +23,7 @@ | |||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| #include "init/gelib.h" | #include "init/gelib.h" | ||||
| #include "framework/common/ge_inner_error_codes.h" | #include "framework/common/ge_inner_error_codes.h" | ||||
| #include "model/ge_model.h" | |||||
| #include "common/model/ge_model.h" | |||||
| #include "framework/omg/omg_inner_types.h" | #include "framework/omg/omg_inner_types.h" | ||||
| namespace { | namespace { | ||||
| @@ -77,12 +77,12 @@ ProfilingManager::ProfilingManager() | |||||
| ProfilingManager::~ProfilingManager() {} | ProfilingManager::~ProfilingManager() {} | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager &ProfilingManager::Instance() { | |||||
| ProfilingManager &ProfilingManager::Instance() { | |||||
| static ProfilingManager profiling_manager; | static ProfilingManager profiling_manager; | ||||
| return profiling_manager; | return profiling_manager; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::Init(const Options &options) { | |||||
| ge::Status ProfilingManager::Init(const Options &options) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| vector<int32_t>().swap(device_id_); | vector<int32_t>().swap(device_id_); | ||||
| subscribe_count_ = 0; | subscribe_count_ = 0; | ||||
| @@ -221,7 +221,7 @@ ge::Status ProfilingManager::ParseOptions(const std::string &options) { | |||||
| return ge::SUCCESS; | return ge::SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProfiling() { | |||||
| void ProfilingManager::StopProfiling() { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| uint64_t module = GetProfilingModule(); | uint64_t module = GetProfilingModule(); | ||||
| // The following if case will not be executed in normal case, inc case of ProfStopProfiling is abnormal | // The following if case will not be executed in normal case, inc case of ProfStopProfiling is abnormal | ||||
| @@ -259,8 +259,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProf | |||||
| #endif | #endif | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ProfilingOpInputOutInfo( | |||||
| const TaskDescInfo &task, Json &task_json) { | |||||
| void ProfilingManager::ProfilingOpInputOutInfo(const TaskDescInfo &task, Json &task_json) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| for (size_t i = 0; i < task.input_format.size(); i++) { | for (size_t i = 0; i < task.input_format.size(); i++) { | ||||
| Json tmp_input; | Json tmp_input; | ||||
| @@ -286,8 +285,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin | |||||
| #endif | #endif | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ProfilingTaskDescInfo( | |||||
| uint32_t model_id, const std::vector<TaskDescInfo> &task_desc_info, const int32_t &device_id) { | |||||
| void ProfilingManager::ProfilingTaskDescInfo(uint32_t model_id, const std::vector<TaskDescInfo> &task_desc_info, | |||||
| const int32_t &device_id) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| for (const auto &task : task_desc_info) { | for (const auto &task : task_desc_info) { | ||||
| Json task_info; | Json task_info; | ||||
| @@ -324,8 +323,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin | |||||
| #endif | #endif | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfileStepInfo( | |||||
| uint64_t index_id, uint64_t model_id, uint16_t tag_id, rtStream_t stream, int32_t device_id) { | |||||
| Status ProfilingManager::ProfileStepInfo(uint64_t index_id, uint64_t model_id, uint16_t tag_id, rtStream_t stream, | |||||
| int32_t device_id) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| if (!is_load_profiling_ && subscribe_count_ == 0) { | if (!is_load_profiling_ && subscribe_count_ == 0) { | ||||
| GELOGD("Profiling is not turned on, no need to profile step info."); | GELOGD("Profiling is not turned on, no need to profile step info."); | ||||
| @@ -385,8 +384,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Profil | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportData( | |||||
| const int32_t &device_id, const string &data, const string &tag_name) { | |||||
| void ProfilingManager::ReportData(const int32_t &device_id, const string &data, const string &tag_name) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| ReporterData reporter_data{}; | ReporterData reporter_data{}; | ||||
| int ret = -1; | int ret = -1; | ||||
| @@ -426,8 +424,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportDa | |||||
| #endif | #endif | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportProfilingData( | |||||
| uint32_t model_id, const std::vector<TaskDescInfo> &task_desc_info) { | |||||
| void ProfilingManager::ReportProfilingData(uint32_t model_id, const std::vector<TaskDescInfo> &task_desc_info) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| int32_t logic_device_id = 0; | int32_t logic_device_id = 0; | ||||
| rtError_t rt_ret = rtGetDevice(&logic_device_id); | rtError_t rt_ret = rtGetDevice(&logic_device_id); | ||||
| @@ -443,7 +440,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportPr | |||||
| #endif | #endif | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t ProfilingManager::GetProfilingModule() { | |||||
| uint64_t ProfilingManager::GetProfilingModule() { | |||||
| uint64_t module = PROF_MODEL_EXECUTE_MASK | | uint64_t module = PROF_MODEL_EXECUTE_MASK | | ||||
| PROF_RUNTIME_API_MASK | | PROF_RUNTIME_API_MASK | | ||||
| PROF_RUNTIME_TRACE_MASK | | PROF_RUNTIME_TRACE_MASK | | ||||
| @@ -485,8 +482,7 @@ void ProfilingManager::UpdateSubscribeDeviceModuleMap(std::string prof_type, uin | |||||
| #endif | #endif | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfModelSubscribe( | |||||
| uint64_t module, void *model) { | |||||
| Status ProfilingManager::ProfModelSubscribe(uint64_t module, void *model) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| uint64_t model_load_mask = module & PROF_MODEL_LOAD_MASK; | uint64_t model_load_mask = module & PROF_MODEL_LOAD_MASK; | ||||
| @@ -526,8 +522,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfMo | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfModelUnsubscribe( | |||||
| void *model) { | |||||
| Status ProfilingManager::ProfModelUnsubscribe(void *model) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| if (subscribe_count_ == 0) { | if (subscribe_count_ == 0) { | ||||
| @@ -568,7 +563,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfMo | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfInit(uint64_t module) { | |||||
| Status ProfilingManager::ProfInit(uint64_t module) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| uint64_t model_load_mask = module & PROF_MODEL_LOAD_MASK; | uint64_t model_load_mask = module & PROF_MODEL_LOAD_MASK; | ||||
| @@ -602,7 +597,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfIn | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfFinalize() { | |||||
| Status ProfilingManager::ProfFinalize() { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| is_load_profiling_ = false; | is_load_profiling_ = false; | ||||
| @@ -697,8 +692,8 @@ Status ProfilingManager::ProfParseDeviceId(const std::map<std::string, std::stri | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| Status ProfilingManager::ProfParseParam(const std::map<std::string, std::string> &config_para, | |||||
| int32_t &device_num, vector<int32_t> &device_list) { | |||||
| Status ProfilingManager::ProfParseParam(const std::map<std::string, std::string> &config_para, int32_t &device_num, | |||||
| vector<int32_t> &device_list) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| // device num | // device num | ||||
| auto iter = config_para.find(kConfigNumsdev); | auto iter = config_para.find(kConfigNumsdev); | ||||
| @@ -747,8 +742,7 @@ Status ProfilingManager::ProfParseParam(const std::map<std::string, std::string> | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfStartProfiling( | |||||
| uint64_t module, const std::map<std::string, std::string> &config_para) { | |||||
| Status ProfilingManager::ProfStartProfiling(uint64_t module, const std::map<std::string, std::string> &config_para) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| uint64_t training_trace_mask = module & PROF_TRAINING_TRACE_MASK; | uint64_t training_trace_mask = module & PROF_TRAINING_TRACE_MASK; | ||||
| @@ -803,8 +797,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfStopProfiling(uint64_t module, | |||||
| const std::map<std::string, std::string> &config_para) { | |||||
| Status ProfilingManager::ProfStopProfiling(uint64_t module, const std::map<std::string, std::string> &config_para) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| int32_t device_num = 0; | int32_t device_num = 0; | ||||
| @@ -855,8 +848,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfSt | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::UpdateDeviceIdModuleMap(string prof_type, | |||||
| uint64_t module, const vector<int32_t> &device_list) { | |||||
| void ProfilingManager::UpdateDeviceIdModuleMap(string prof_type, uint64_t module, const vector<int32_t> &device_list) { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| if (prof_type == kProfStart) { | if (prof_type == kProfStart) { | ||||
| for (uint32_t i = 0; i < device_list.size(); i++) { | for (uint32_t i = 0; i < device_list.size(); i++) { | ||||
| @@ -886,7 +878,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::UpdateDe | |||||
| #endif | #endif | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ProfilingManager::ProfilingModelExecuteOn() const { | |||||
| bool ProfilingManager::ProfilingModelExecuteOn() const { | |||||
| int32_t logic_device_id = 0; | int32_t logic_device_id = 0; | ||||
| rtError_t rt_ret = rtGetDevice(&logic_device_id); | rtError_t rt_ret = rtGetDevice(&logic_device_id); | ||||
| if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
| @@ -904,7 +896,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ProfilingManager::Profilin | |||||
| return execute_model_prof_on; | return execute_model_prof_on; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::PluginInit() { | |||||
| Status ProfilingManager::PluginInit() { | |||||
| if (prof_cb_.msprofReporterCallback == nullptr) { | if (prof_cb_.msprofReporterCallback == nullptr) { | ||||
| GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); | GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); | ||||
| REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); | REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); | ||||
| @@ -933,7 +925,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Plugin | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::PluginUnInit() const { | |||||
| void ProfilingManager::PluginUnInit() const { | |||||
| #ifdef DAVINCI_SUPPORT_PROFILING | #ifdef DAVINCI_SUPPORT_PROFILING | ||||
| if (prof_cb_.msprofReporterCallback == nullptr) { | if (prof_cb_.msprofReporterCallback == nullptr) { | ||||
| GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); | GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); | ||||
| @@ -950,8 +942,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::PluginUn | |||||
| #endif | #endif | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::CallMsprofReport( | |||||
| ReporterData &reporter_data) const { | |||||
| Status ProfilingManager::CallMsprofReport(ReporterData &reporter_data) const { | |||||
| if (prof_cb_.msprofReporterCallback == nullptr) { | if (prof_cb_.msprofReporterCallback == nullptr) { | ||||
| GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); | GELOGE(ge::PARAM_INVALID, "[Check][Param]MsprofReporterCallback callback is nullptr"); | ||||
| REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); | REPORT_INNER_ERROR("E19999", "MsprofReporterCallback callback is nullptr"); | ||||
| @@ -1007,14 +998,12 @@ void ProfilingManager::GetOpOutputInfo(const OpDescPtr &op, TaskDescInfo &task_d | |||||
| task_desc_info.output_data_type = output_data_type.empty() ? data_type_default : output_data_type; | task_desc_info.output_data_type = output_data_type.empty() ? data_type_default : output_data_type; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetOpInputOutputInfo( | |||||
| const OpDescPtr &op, TaskDescInfo &task_desc_info) const { | |||||
| void ProfilingManager::GetOpInputOutputInfo(const OpDescPtr &op, TaskDescInfo &task_desc_info) const { | |||||
| GetOpInputInfo(op, task_desc_info); | GetOpInputInfo(op, task_desc_info); | ||||
| GetOpOutputInfo(op, task_desc_info); | GetOpOutputInfo(op, task_desc_info); | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetFpBpPoint( | |||||
| std::string &fp_point, std::string &bp_point) { | |||||
| void ProfilingManager::GetFpBpPoint(std::string &fp_point, std::string &bp_point) { | |||||
| // Env or options mode, fp_point_/bp_point_ have initiliazed on profiling init | // Env or options mode, fp_point_/bp_point_ have initiliazed on profiling init | ||||
| if (!fp_point_.empty() && !bp_point_.empty()) { | if (!fp_point_.empty() && !bp_point_.empty()) { | ||||
| fp_point = fp_point_; | fp_point = fp_point_; | ||||
| @@ -1025,7 +1014,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetFpBpP | |||||
| } | } | ||||
| // ProfApi mode and training trace is set | // ProfApi mode and training trace is set | ||||
| // Parse options first | // Parse options first | ||||
| char env_profiling_options[MSPROF_OPTIONS_DEF_LEN_MAX] = { 0x00 }; | |||||
| char env_profiling_options[MSPROF_OPTIONS_DEF_LEN_MAX] = {0x00}; | |||||
| bool is_profiling_valid = false; | bool is_profiling_valid = false; | ||||
| std::string profiling_options; | std::string profiling_options; | ||||
| if (ge::GetContext().GetOption(OPTION_EXEC_PROFILING_OPTIONS, profiling_options) == SUCCESS && | if (ge::GetContext().GetOption(OPTION_EXEC_PROFILING_OPTIONS, profiling_options) == SUCCESS && | ||||
| @@ -73,7 +73,7 @@ struct MsprofCallback { | |||||
| MsprofReporterCallback msprofReporterCallback; | MsprofReporterCallback msprofReporterCallback; | ||||
| }; | }; | ||||
| class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { | |||||
| class ProfilingManager { | |||||
| public: | public: | ||||
| ProfilingManager(); | ProfilingManager(); | ||||
| virtual ~ProfilingManager(); | virtual ~ProfilingManager(); | ||||
| @@ -35,13 +35,13 @@ PropertiesManager::PropertiesManager() : is_inited_(false), delimiter("=") {} | |||||
| PropertiesManager::~PropertiesManager() {} | PropertiesManager::~PropertiesManager() {} | ||||
| // singleton | // singleton | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY PropertiesManager &PropertiesManager::Instance() { | |||||
| PropertiesManager &PropertiesManager::Instance() { | |||||
| static PropertiesManager instance; | static PropertiesManager instance; | ||||
| return instance; | return instance; | ||||
| } | } | ||||
| // Initialize property configuration | // Initialize property configuration | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool PropertiesManager::Init(const std::string &file_path) { | |||||
| bool PropertiesManager::Init(const std::string &file_path) { | |||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| if (is_inited_) { | if (is_inited_) { | ||||
| GELOGW("Already inited, will be initialized again"); | GELOGW("Already inited, will be initialized again"); | ||||
| @@ -139,8 +139,7 @@ std::string PropertiesManager::Trim(const std::string &str) { | |||||
| } | } | ||||
| // Get property value, if not found, return "" | // Get property value, if not found, return "" | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string PropertiesManager::GetPropertyValue( | |||||
| const std::string &map_key) { | |||||
| std::string PropertiesManager::GetPropertyValue(const std::string &map_key) { | |||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| auto iter = properties_map_.find(map_key); | auto iter = properties_map_.find(map_key); | ||||
| if (properties_map_.end() != iter) { | if (properties_map_.end() != iter) { | ||||
| @@ -151,21 +150,19 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string PropertiesManager:: | |||||
| } | } | ||||
| // Set property value | // Set property value | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void PropertiesManager::SetPropertyValue(const std::string &map_key, | |||||
| const std::string &value) { | |||||
| void PropertiesManager::SetPropertyValue(const std::string &map_key, const std::string &value) { | |||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| properties_map_[map_key] = value; | properties_map_[map_key] = value; | ||||
| } | } | ||||
| // return properties_map_ | // return properties_map_ | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::map<std::string, std::string> | |||||
| PropertiesManager::GetPropertyMap() { | |||||
| std::map<std::string, std::string> PropertiesManager::GetPropertyMap() { | |||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| return properties_map_; | return properties_map_; | ||||
| } | } | ||||
| // Set separator | // Set separator | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void PropertiesManager::SetPropertyDelimiter(const std::string &de) { | |||||
| void PropertiesManager::SetPropertyDelimiter(const std::string &de) { | |||||
| std::lock_guard<std::mutex> lock(mutex_); | std::lock_guard<std::mutex> lock(mutex_); | ||||
| delimiter = de; | delimiter = de; | ||||
| } | } | ||||
| @@ -21,7 +21,7 @@ | |||||
| namespace ge { | namespace ge { | ||||
| class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY TBEKernelStore : public KernelStore { | |||||
| class TBEKernelStore : public KernelStore { | |||||
| public: | public: | ||||
| TBEKernelStore(); | TBEKernelStore(); | ||||
| ~TBEKernelStore() {} | ~TBEKernelStore() {} | ||||
| @@ -26,7 +26,7 @@ | |||||
| #include "external/register/register_types.h" | #include "external/register/register_types.h" | ||||
| namespace ge { | namespace ge { | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ThreadPool::ThreadPool(uint32_t size) : is_stoped_(false) { | |||||
| ThreadPool::ThreadPool(uint32_t size) : is_stoped_(false) { | |||||
| idle_thrd_num_ = size < 1 ? 1 : size; | idle_thrd_num_ = size < 1 ? 1 : size; | ||||
| for (uint32_t i = 0; i < idle_thrd_num_; ++i) { | for (uint32_t i = 0; i < idle_thrd_num_; ++i) { | ||||
| @@ -34,7 +34,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ThreadPool::ThreadPool(uint32_t | |||||
| } | } | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ThreadPool::~ThreadPool() { | |||||
| ThreadPool::~ThreadPool() { | |||||
| is_stoped_.store(true); | is_stoped_.store(true); | ||||
| { | { | ||||
| std::unique_lock<std::mutex> lock{m_lock_}; | std::unique_lock<std::mutex> lock{m_lock_}; | ||||
| @@ -37,7 +37,7 @@ | |||||
| namespace ge { | namespace ge { | ||||
| using ThreadTask = std::function<void()>; | using ThreadTask = std::function<void()>; | ||||
| class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ThreadPool { | |||||
| class ThreadPool { | |||||
| public: | public: | ||||
| explicit ThreadPool(uint32_t size = 4); | explicit ThreadPool(uint32_t size = 4); | ||||
| ~ThreadPool(); | ~ThreadPool(); | ||||
| @@ -14,9 +14,9 @@ | |||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "graph/common/transop_util.h" | |||||
| #include "common/transop_util.h" | |||||
| #include "framework/common/types.h" | |||||
| #include "common/types.h" | |||||
| #include "graph/utils/type_utils.h" | #include "graph/utils/type_utils.h" | ||||
| #include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
| @@ -23,7 +23,7 @@ | |||||
| #include "graph/node.h" | #include "graph/node.h" | ||||
| namespace ge { | namespace ge { | ||||
| class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY TransOpUtil { | |||||
| class TransOpUtil { | |||||
| public: | public: | ||||
| static bool IsTransOp(const NodePtr &node); | static bool IsTransOp(const NodePtr &node); | ||||
| @@ -70,7 +70,7 @@ static bool ReadProtoFromCodedInputStream(CodedInputStream &coded_stream, Messag | |||||
| return proto->ParseFromCodedStream(&coded_stream); | return proto->ParseFromCodedStream(&coded_stream); | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromArray(const void *data, int size, Message *proto) { | |||||
| bool ReadProtoFromArray(const void *data, int size, Message *proto) { | |||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((proto == nullptr || data == nullptr || size == 0), return false, | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((proto == nullptr || data == nullptr || size == 0), return false, | ||||
| "incorrect parameter. proto is nullptr || data is nullptr || size is 0"); | "incorrect parameter. proto is nullptr || data is nullptr || size is 0"); | ||||
| @@ -112,8 +112,7 @@ long GetFileLength(const std::string &input_file) { | |||||
| * @return false fail | * @return false fail | ||||
| * @return true success | * @return true success | ||||
| */ | */ | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(const char *file_name, char **buffer, | |||||
| int &length) { | |||||
| bool ReadBytesFromBinaryFile(const char *file_name, char **buffer, int &length) { | |||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file_name == nullptr), return false, "incorrect parameter. file is nullptr"); | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file_name == nullptr), return false, "incorrect parameter. file is nullptr"); | ||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((buffer == nullptr), return false, "incorrect parameter. buffer is nullptr"); | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((buffer == nullptr), return false, "incorrect parameter. buffer is nullptr"); | ||||
| @@ -141,8 +140,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co | |||||
| return true; | return true; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(const char *file_name, | |||||
| std::vector<char> &buffer) { | |||||
| bool ReadBytesFromBinaryFile(const char *file_name, std::vector<char> &buffer) { | |||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file_name == nullptr), return false, "incorrect parameter. file path is null"); | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file_name == nullptr), return false, "incorrect parameter. file path is null"); | ||||
| std::string real_path = RealPath(file_name); | std::string real_path = RealPath(file_name); | ||||
| @@ -177,7 +175,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co | |||||
| * @return -1 fail | * @return -1 fail | ||||
| * @return 0 success | * @return 0 success | ||||
| */ | */ | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int CreateDirectory(const std::string &directory_path) { | |||||
| int CreateDirectory(const std::string &directory_path) { | |||||
| GE_CHK_BOOL_EXEC(!directory_path.empty(), return -1, "directory path is empty."); | GE_CHK_BOOL_EXEC(!directory_path.empty(), return -1, "directory path is empty."); | ||||
| auto dir_path_len = directory_path.length(); | auto dir_path_len = directory_path.length(); | ||||
| if (dir_path_len >= MMPA_MAX_PATH) { | if (dir_path_len >= MMPA_MAX_PATH) { | ||||
| @@ -219,7 +217,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int CreateDirectory(const std:: | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string CurrentTimeInStr() { | |||||
| std::string CurrentTimeInStr() { | |||||
| std::time_t now = std::time(nullptr); | std::time_t now = std::time(nullptr); | ||||
| std::tm *ptm = std::localtime(&now); | std::tm *ptm = std::localtime(&now); | ||||
| if (ptm == nullptr) { | if (ptm == nullptr) { | ||||
| @@ -235,8 +233,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string CurrentTimeInStr() | |||||
| return std::string(buffer); | return std::string(buffer); | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromText(const char *file, | |||||
| google::protobuf::Message *message) { | |||||
| bool ReadProtoFromText(const char *file, google::protobuf::Message *message) { | |||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file == nullptr || message == nullptr), return false, | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file == nullptr || message == nullptr), return false, | ||||
| "incorrect parameter. nullptr == file || nullptr == message"); | "incorrect parameter. nullptr == file || nullptr == message"); | ||||
| @@ -266,8 +263,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromText(const ch | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromMem(const char *data, int size, | |||||
| google::protobuf::Message *message) { | |||||
| bool ReadProtoFromMem(const char *data, int size, google::protobuf::Message *message) { | |||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((data == nullptr || message == nullptr), return false, | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((data == nullptr || message == nullptr), return false, | ||||
| "incorrect parameter. data is nullptr || message is nullptr"); | "incorrect parameter. data is nullptr || message is nullptr"); | ||||
| std::string str(data, static_cast<size_t>(size)); | std::string str(data, static_cast<size_t>(size)); | ||||
| @@ -281,7 +277,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromMem(const cha | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() { | |||||
| uint64_t GetCurrentTimestamp() { | |||||
| mmTimeval tv{}; | mmTimeval tv{}; | ||||
| int ret = mmGetTimeOfDay(&tv, nullptr); | int ret = mmGetTimeOfDay(&tv, nullptr); | ||||
| GE_LOGE_IF(ret != EN_OK, "Func gettimeofday may failed, ret:%d, errmsg:%s", ret, strerror(errno)); | GE_LOGE_IF(ret != EN_OK, "Func gettimeofday may failed, ret:%d, errmsg:%s", ret, strerror(errno)); | ||||
| @@ -289,7 +285,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint64_t GetCurrentTimestamp() | |||||
| return static_cast<uint64_t>(total_use_time); | return static_cast<uint64_t>(total_use_time); | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint32_t GetCurrentSecondTimestap() { | |||||
| uint32_t GetCurrentSecondTimestap() { | |||||
| mmTimeval tv{}; | mmTimeval tv{}; | ||||
| int ret = mmGetTimeOfDay(&tv, nullptr); | int ret = mmGetTimeOfDay(&tv, nullptr); | ||||
| GE_LOGE_IF(ret != EN_OK, "Func gettimeofday may failed, ret:%d, errmsg:%s", ret, strerror(errno)); | GE_LOGE_IF(ret != EN_OK, "Func gettimeofday may failed, ret:%d, errmsg:%s", ret, strerror(errno)); | ||||
| @@ -297,7 +293,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY uint32_t GetCurrentSecondTimest | |||||
| return static_cast<uint32_t>(total_use_time); | return static_cast<uint32_t>(total_use_time); | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInt64MulOverflow(int64_t a, int64_t b) { | |||||
| bool CheckInt64MulOverflow(int64_t a, int64_t b) { | |||||
| if (a > 0) { | if (a > 0) { | ||||
| if (b > 0) { | if (b > 0) { | ||||
| if (a > (INT64_MAX / b)) { | if (a > (INT64_MAX / b)) { | ||||
| @@ -322,7 +318,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInt64MulOverflow(int6 | |||||
| return true; | return true; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string RealPath(const char *path) { | |||||
| std::string RealPath(const char *path) { | |||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL."); | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(path == nullptr, return "", "path pointer is NULL."); | ||||
| GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(path) >= MMPA_MAX_PATH, | GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(path) >= MMPA_MAX_PATH, | ||||
| ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, | ErrorManager::GetInstance().ATCReportErrMessage("E19002", {"filepath", "size"}, | ||||
| @@ -349,8 +345,7 @@ void PathValidErrReport(const std::string &file_path, const std::string &atc_par | |||||
| } | } | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const std::string &file_path, | |||||
| const std::string &atc_param) { | |||||
| bool CheckInputPathValid(const std::string &file_path, const std::string &atc_param) { | |||||
| // The specified path is empty | // The specified path is empty | ||||
| std::map<std::string, std::string> args_map; | std::map<std::string, std::string> args_map; | ||||
| if (file_path.empty()) { | if (file_path.empty()) { | ||||
| @@ -395,8 +390,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const | |||||
| return true; | return true; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const std::string &file_path, | |||||
| const std::string &atc_param) { | |||||
| bool CheckOutputPathValid(const std::string &file_path, const std::string &atc_param) { | |||||
| // The specified path is empty | // The specified path is empty | ||||
| if (file_path.empty()) { | if (file_path.empty()) { | ||||
| if (!atc_param.empty()) { | if (!atc_param.empty()) { | ||||
| @@ -552,7 +546,7 @@ FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) { | |||||
| return true; | return true; | ||||
| } | } | ||||
| FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status CheckPath(const char *path, size_t length) { | |||||
| Status CheckPath(const char *path, size_t length) { | |||||
| if (path == nullptr) { | if (path == nullptr) { | ||||
| GELOGE(PARAM_INVALID, "[Check][Param]Config path is invalid"); | GELOGE(PARAM_INVALID, "[Check][Param]Config path is invalid"); | ||||
| REPORT_CALL_ERROR("E19999", "Config path is invalid"); | REPORT_CALL_ERROR("E19999", "Config path is invalid"); | ||||
| @@ -239,6 +239,10 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { | |||||
| op_desc->SetOpEngineName(it.engine); | op_desc->SetOpEngineName(it.engine); | ||||
| op_desc->SetOpKernelLibName(kernel_name); | op_desc->SetOpKernelLibName(kernel_name); | ||||
| // set attrs for taking information when load txt to graph object | // set attrs for taking information when load txt to graph object | ||||
| if (it.flagAsync) { | |||||
| GELOGD("Set aicpu blocking op:%s attribute(is_blocking_op):true", op_desc->GetName().c_str()); | |||||
| (void)AttrUtils::SetBool(op_desc, ATTR_NAME_IS_BLOCKING_OP, true); | |||||
| } | |||||
| (void) AttrUtils::SetStr(op_desc, ATTR_NAME_ENGINE_NAME_FOR_LX, it.engine); | (void) AttrUtils::SetStr(op_desc, ATTR_NAME_ENGINE_NAME_FOR_LX, it.engine); | ||||
| (void) AttrUtils::SetStr(op_desc, ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX, kernel_name); | (void) AttrUtils::SetStr(op_desc, ATTR_NAME_KKERNEL_LIB_NAME_FOR_LX, kernel_name); | ||||
| GELOGD("DNNEngineManager:Set OpKernelLibName %s and engine name %s to op_desc %s", kernel_name.c_str(), | GELOGD("DNNEngineManager:Set OpKernelLibName %s and engine name %s to op_desc %s", kernel_name.c_str(), | ||||
| @@ -1,13 +1,9 @@ | |||||
| set(SRC_LIST | set(SRC_LIST | ||||
| "ge_executor.cc" | "ge_executor.cc" | ||||
| "../common/profiling/profiling_manager.cc" | "../common/profiling/profiling_manager.cc" | ||||
| "../common/ge/plugin_manager.cc" | |||||
| "../common/ge/op_tiling_manager.cc" | |||||
| "../common/dump/dump_properties.cc" | |||||
| "../common/dump/exception_dumper.cc" | |||||
| "../common/dump/dump_manager.cc" | |||||
| "../common/dump/dump_op.cc" | "../common/dump/dump_op.cc" | ||||
| "../common/dump/opdebug_register.cc" | "../common/dump/opdebug_register.cc" | ||||
| "../common/dump/exception_dumper.cc" | |||||
| "../common/profiling/ge_profiling.cc" | "../common/profiling/ge_profiling.cc" | ||||
| "../graph/load/graph_loader.cc" | "../graph/load/graph_loader.cc" | ||||
| "../graph/execute/graph_execute.cc" | "../graph/execute/graph_execute.cc" | ||||
| @@ -22,8 +18,6 @@ set(SRC_LIST | |||||
| "../graph/manager/rdma_pool_allocator.cc" | "../graph/manager/rdma_pool_allocator.cc" | ||||
| "../graph/manager/host_mem_allocator.cc" | "../graph/manager/host_mem_allocator.cc" | ||||
| "../hybrid/node_executor/aicpu/aicpu_ext_info.cc" | "../hybrid/node_executor/aicpu/aicpu_ext_info.cc" | ||||
| "../model/ge_model.cc" | |||||
| "../model/ge_root_model.cc" | |||||
| "../graph/load/model_manager/davinci_model.cc" | "../graph/load/model_manager/davinci_model.cc" | ||||
| "../graph/load/model_manager/model_manager.cc" | "../graph/load/model_manager/model_manager.cc" | ||||
| "../graph/load/model_manager/tbe_handle_store.cc" | "../graph/load/model_manager/tbe_handle_store.cc" | ||||
| @@ -55,7 +49,6 @@ set(SRC_LIST | |||||
| "../graph/load/model_manager/task_info/model_exit_task_info.cc" | "../graph/load/model_manager/task_info/model_exit_task_info.cc" | ||||
| "../graph/load/model_manager/task_info/super_kernel/super_kernel_factory.cc" | "../graph/load/model_manager/task_info/super_kernel/super_kernel_factory.cc" | ||||
| "../graph/load/model_manager/task_info/super_kernel/super_kernel.cc" | "../graph/load/model_manager/task_info/super_kernel/super_kernel.cc" | ||||
| "../graph/common/local_context.cc" | |||||
| "../opskernel_manager/ops_kernel_builder_manager.cc" | "../opskernel_manager/ops_kernel_builder_manager.cc" | ||||
| "../single_op/single_op_manager.cc" | "../single_op/single_op_manager.cc" | ||||
| "../single_op/single_op_model.cc" | "../single_op/single_op_model.cc" | ||||
| @@ -102,7 +95,6 @@ set(SRC_LIST | |||||
| "../hybrid/node_executor/task_context.cc" | "../hybrid/node_executor/task_context.cc" | ||||
| "../hybrid/hybrid_davinci_model.cc" | "../hybrid/hybrid_davinci_model.cc" | ||||
| "../ge_local_engine/engine/host_cpu_engine.cc" | "../ge_local_engine/engine/host_cpu_engine.cc" | ||||
| "../graph/common/omg_util.cc" | |||||
| "../graph/manager/host_mem_manager.cc" | "../graph/manager/host_mem_manager.cc" | ||||
| "../graph/build/memory/var_mem_assign_util.cc" | "../graph/build/memory/var_mem_assign_util.cc" | ||||
| "../host_kernels/transpose_kernel.cc" | "../host_kernels/transpose_kernel.cc" | ||||
| @@ -144,10 +136,6 @@ set(SRC_LIST | |||||
| "../host_kernels/transdata_kernel.cc" | "../host_kernels/transdata_kernel.cc" | ||||
| "../host_kernels/unpack_kernel.cc" | "../host_kernels/unpack_kernel.cc" | ||||
| "../graph/passes/pass_utils.cc" | "../graph/passes/pass_utils.cc" | ||||
| "../graph/common/bcast.cc" | |||||
| "../common/fp16_t.cc" | |||||
| "../common/formats/format_transfers/format_transfer_transpose.cc" | |||||
| "../common/formats/utils/formats_trans_utils.cc" | |||||
| ) | ) | ||||
| ######## libge_executor.a ######## | ######## libge_executor.a ######## | ||||
| @@ -27,6 +27,7 @@ | |||||
| #include "graph/load/graph_loader.h" | #include "graph/load/graph_loader.h" | ||||
| #include "graph/load/model_manager/model_manager.h" | #include "graph/load/model_manager/model_manager.h" | ||||
| #include "graph/manager/graph_mem_manager.h" | #include "graph/manager/graph_mem_manager.h" | ||||
| #include "graph/manager/graph_var_manager.h" | |||||
| #include "single_op/single_op_manager.h" | #include "single_op/single_op_manager.h" | ||||
| #include "graph/load/model_manager/davinci_model.h" | #include "graph/load/model_manager/davinci_model.h" | ||||
| #include "opskernel_manager/ops_kernel_builder_manager.h" | #include "opskernel_manager/ops_kernel_builder_manager.h" | ||||
| @@ -63,7 +63,7 @@ local_ge_executor_src_files := \ | |||||
| ../single_op/task/aicpu_task_builder.cc \ | ../single_op/task/aicpu_task_builder.cc \ | ||||
| ../single_op/task/aicpu_kernel_task_builder.cc \ | ../single_op/task/aicpu_kernel_task_builder.cc \ | ||||
| ../hybrid/node_executor/aicpu/aicpu_ext_info.cc \ | ../hybrid/node_executor/aicpu/aicpu_ext_info.cc \ | ||||
| ../graph/common/local_context.cc \ | |||||
| ../common/local_context.cc \ | |||||
| ../hybrid/common/tensor_value.cc \ | ../hybrid/common/tensor_value.cc \ | ||||
| ../hybrid/common/npu_memory_allocator.cc \ | ../hybrid/common/npu_memory_allocator.cc \ | ||||
| ../hybrid/executor/rt_callback_manager.cc \ | ../hybrid/executor/rt_callback_manager.cc \ | ||||
| @@ -102,7 +102,7 @@ local_ge_executor_src_files := \ | |||||
| ../hybrid/node_executor/task_context.cc \ | ../hybrid/node_executor/task_context.cc \ | ||||
| ../hybrid/hybrid_davinci_model.cc \ | ../hybrid/hybrid_davinci_model.cc \ | ||||
| ../ge_local_engine/engine/host_cpu_engine.cc \ | ../ge_local_engine/engine/host_cpu_engine.cc \ | ||||
| ../graph/common/omg_util.cc \ | |||||
| ../common/omg_util.cc \ | |||||
| ../graph/manager/host_mem_manager.cc \ | ../graph/manager/host_mem_manager.cc \ | ||||
| ../graph/build/memory/var_mem_assign_util.cc \ | ../graph/build/memory/var_mem_assign_util.cc \ | ||||
| ../host_kernels/transpose_kernel.cc \ | ../host_kernels/transpose_kernel.cc \ | ||||
| @@ -144,7 +144,7 @@ local_ge_executor_src_files := \ | |||||
| ../host_kernels/transdata_kernel.cc \ | ../host_kernels/transdata_kernel.cc \ | ||||
| ../host_kernels/unpack_kernel.cc \ | ../host_kernels/unpack_kernel.cc \ | ||||
| ../graph/passes/pass_utils.cc \ | ../graph/passes/pass_utils.cc \ | ||||
| ../graph/common/bcast.cc \ | |||||
| ../common/bcast.cc \ | |||||
| ../common/fp16_t.cc \ | ../common/fp16_t.cc \ | ||||
| ../common/formats/format_transfers/format_transfer_transpose.cc \ | ../common/formats/format_transfers/format_transfer_transpose.cc \ | ||||
| ../common/formats/utils/formats_trans_utils.cc \ | ../common/formats/utils/formats_trans_utils.cc \ | ||||
| @@ -80,7 +80,7 @@ ANALYZER_SRC_FILES:= \ | |||||
| OMG_HOST_SRC_FILES := \ | OMG_HOST_SRC_FILES := \ | ||||
| model/ge_model.cc \ | model/ge_model.cc \ | ||||
| model/ge_root_model.cc \ | model/ge_root_model.cc \ | ||||
| graph/common/transop_util.cc \ | |||||
| common/transop_util.cc \ | |||||
| graph/passes/pass_manager.cc \ | graph/passes/pass_manager.cc \ | ||||
| graph/passes/resource_pair_add_control_pass.cc \ | graph/passes/resource_pair_add_control_pass.cc \ | ||||
| graph/passes/resource_pair_remove_control_pass.cc \ | graph/passes/resource_pair_remove_control_pass.cc \ | ||||
| @@ -115,9 +115,9 @@ OMG_HOST_SRC_FILES := \ | |||||
| graph/passes/mark_graph_unknown_status_pass.cc \ | graph/passes/mark_graph_unknown_status_pass.cc \ | ||||
| graph/passes/mark_node_unknown_shape_pass.cc \ | graph/passes/mark_node_unknown_shape_pass.cc \ | ||||
| graph/passes/mark_agnostic_pass.cc \ | graph/passes/mark_agnostic_pass.cc \ | ||||
| graph/common/omg_util.cc \ | |||||
| graph/common/bcast.cc \ | |||||
| graph/common/local_context.cc \ | |||||
| common/omg_util.cc \ | |||||
| common/bcast.cc \ | |||||
| common/local_context.cc \ | |||||
| graph/passes/dimension_compute_pass.cc \ | graph/passes/dimension_compute_pass.cc \ | ||||
| graph/passes/dimension_adjust_pass.cc \ | graph/passes/dimension_adjust_pass.cc \ | ||||
| graph/passes/get_original_format_pass.cc \ | graph/passes/get_original_format_pass.cc \ | ||||
| @@ -43,10 +43,10 @@ LIBGE_LOCAL_SRC_FILES := \ | |||||
| graph/build/stream_allocator.cc \ | graph/build/stream_allocator.cc \ | ||||
| graph/build/stream_graph_optimizer.cc \ | graph/build/stream_graph_optimizer.cc \ | ||||
| graph/build/task_generator.cc \ | graph/build/task_generator.cc \ | ||||
| graph/common/bcast.cc \ | |||||
| graph/common/local_context.cc \ | |||||
| graph/common/omg_util.cc \ | |||||
| graph/common/transop_util.cc \ | |||||
| common/bcast.cc \ | |||||
| common/local_context.cc \ | |||||
| common/omg_util.cc \ | |||||
| common/transop_util.cc \ | |||||
| graph/execute/graph_execute.cc \ | graph/execute/graph_execute.cc \ | ||||
| graph/label/case_label_maker.cc \ | graph/label/case_label_maker.cc \ | ||||
| graph/label/if_label_maker.cc \ | graph/label/if_label_maker.cc \ | ||||
| @@ -30,13 +30,14 @@ | |||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| #include "graph/manager/graph_manager.h" | #include "graph/manager/graph_manager.h" | ||||
| #include "graph/manager/graph_var_manager.h" | |||||
| #include "graph/manager/util/rt_context_util.h" | #include "graph/manager/util/rt_context_util.h" | ||||
| #include "graph/operator_factory_impl.h" | #include "graph/operator_factory_impl.h" | ||||
| #include "graph/opsproto_manager.h" | #include "graph/opsproto_manager.h" | ||||
| #include "graph/utils/graph_utils.h" | #include "graph/utils/graph_utils.h" | ||||
| #include "graph/utils/type_utils.h" | #include "graph/utils/type_utils.h" | ||||
| #include "init/gelib.h" | #include "init/gelib.h" | ||||
| #include "model/ge_model.h" | |||||
| #include "common/model/ge_model.h" | |||||
| #include "analyzer/analyzer.h" | #include "analyzer/analyzer.h" | ||||
| using std::map; | using std::map; | ||||
| @@ -1157,7 +1158,6 @@ Status GeGenerator::Impl::BuildModel(const Graph &graph, const vector<GeTensor> | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| REPORT_CALL_ERROR("E19999", "build graph failed, graph id:%u, ret:%d", graph_id, ret); | REPORT_CALL_ERROR("E19999", "build graph failed, graph id:%u, ret:%d", graph_id, ret); | ||||
| GELOGE(GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED, "[Build][Graph] fail, graph id: %u", graph_id); | GELOGE(GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED, "[Build][Graph] fail, graph id: %u", graph_id); | ||||
| ret = GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED; | |||||
| } | } | ||||
| RtContextUtil::GetInstance().DestroyRtContexts(session_id); | RtContextUtil::GetInstance().DestroyRtContexts(session_id); | ||||
| @@ -21,14 +21,14 @@ | |||||
| #include "graph/build/logical_stream_allocator.h" | #include "graph/build/logical_stream_allocator.h" | ||||
| #include "graph/build/run_context.h" | #include "graph/build/run_context.h" | ||||
| #include "graph/build/stream_graph_optimizer.h" | #include "graph/build/stream_graph_optimizer.h" | ||||
| #include "graph/common/ge_call_wrapper.h" | |||||
| #include "common/ge_call_wrapper.h" | |||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| #include "graph/manager/graph_var_manager.h" | #include "graph/manager/graph_var_manager.h" | ||||
| #include "graph/passes/mark_same_addr_pass.h" | #include "graph/passes/mark_same_addr_pass.h" | ||||
| #include "graph/utils/node_utils.h" | #include "graph/utils/node_utils.h" | ||||
| #include "graph/utils/type_utils.h" | #include "graph/utils/type_utils.h" | ||||
| #include "init/gelib.h" | #include "init/gelib.h" | ||||
| #include "model/ge_model.h" | |||||
| #include "common/model/ge_model.h" | |||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| #include "opskernel_manager/ops_kernel_builder_manager.h" | #include "opskernel_manager/ops_kernel_builder_manager.h" | ||||
| #include "graph/utils/op_desc_utils.h" | #include "graph/utils/op_desc_utils.h" | ||||
| @@ -38,7 +38,7 @@ | |||||
| #include "graph/partition/graph_partition.h" | #include "graph/partition/graph_partition.h" | ||||
| #include "graph/utils/graph_utils.h" | #include "graph/utils/graph_utils.h" | ||||
| #include "graph/utils/tensor_utils.h" | #include "graph/utils/tensor_utils.h" | ||||
| #include "model/ge_root_model.h" | |||||
| #include "common/model/ge_root_model.h" | |||||
| namespace ge { | namespace ge { | ||||
| class GraphBuilder { | class GraphBuilder { | ||||
| @@ -22,7 +22,7 @@ | |||||
| #include "framework/common/types.h" | #include "framework/common/types.h" | ||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/utils/graph_utils.h" | #include "graph/utils/graph_utils.h" | ||||
| #include "graph/common/ge_call_wrapper.h" | |||||
| #include "common/ge_call_wrapper.h" | |||||
| using std::map; | using std::map; | ||||
| using std::set; | using std::set; | ||||
| @@ -34,7 +34,7 @@ | |||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/common/local_context.h" | |||||
| #include "common/local_context.h" | |||||
| #include "graph/optimize/common/params.h" | #include "graph/optimize/common/params.h" | ||||
| #include "framework/omg/omg_inner_types.h" | #include "framework/omg/omg_inner_types.h" | ||||
| #include "runtime/mem.h" | #include "runtime/mem.h" | ||||
| @@ -15,7 +15,7 @@ | |||||
| */ | */ | ||||
| #include "graph/build/memory/buffer_pool_mem_assigner.h" | #include "graph/build/memory/buffer_pool_mem_assigner.h" | ||||
| #include "graph/common/omg_util.h" | |||||
| #include "common/omg_util.h" | |||||
| #include "graph/utils/tensor_utils.h" | #include "graph/utils/tensor_utils.h" | ||||
| #include "framework/common/util.h" | #include "framework/common/util.h" | ||||
| #include "graph/compute_graph.h" | #include "graph/compute_graph.h" | ||||
| @@ -24,7 +24,7 @@ | |||||
| #include "graph/build/memory/hybrid_mem_assigner.h" | #include "graph/build/memory/hybrid_mem_assigner.h" | ||||
| #include "graph/build/memory/var_mem_assign_util.h" | #include "graph/build/memory/var_mem_assign_util.h" | ||||
| #include "graph/build/memory/block_mem_assigner.h" | #include "graph/build/memory/block_mem_assigner.h" | ||||
| #include "graph/common/omg_util.h" | |||||
| #include "common/omg_util.h" | |||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/ge_attr_value.h" | #include "graph/ge_attr_value.h" | ||||
| #include "graph/manager/graph_var_manager.h" | #include "graph/manager/graph_var_manager.h" | ||||
| @@ -275,7 +275,7 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, map<uint64_t, siz | |||||
| "E19022", std::vector<std::string>({"size", "item", "maxsize"}), | "E19022", std::vector<std::string>({"size", "item", "maxsize"}), | ||||
| std::vector<std::string>({std::to_string(total_mem_offset), "featuremap", | std::vector<std::string>({std::to_string(total_mem_offset), "featuremap", | ||||
| std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())})); | std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())})); | ||||
| return ge::FAILED; | |||||
| return ACL_ERROR_GE_MEMORY_ALLOCATION; | |||||
| } | } | ||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| @@ -29,9 +29,10 @@ Status MemoryAssigner::AssignMemory(bool is_loop_graph, map<uint64_t, size_t> &m | |||||
| } | } | ||||
| // Reassign memory for special nodes | // Reassign memory for special nodes | ||||
| if (graph_mem_assigner.ReAssignMemory(is_loop_graph, mem_offset) != ge::SUCCESS) { | |||||
| Status ret = graph_mem_assigner.ReAssignMemory(is_loop_graph, mem_offset); | |||||
| if (ret != ge::SUCCESS) { | |||||
| GELOGE(ge::FAILED, "[ReAssign][Memory] failed, graph:%s", compute_graph_->GetName().c_str()); | GELOGE(ge::FAILED, "[ReAssign][Memory] failed, graph:%s", compute_graph_->GetName().c_str()); | ||||
| return ge::FAILED; | |||||
| return ret; | |||||
| } | } | ||||
| // Assign memory (block and offset) for zero copy nodes | // Assign memory (block and offset) for zero copy nodes | ||||
| @@ -18,7 +18,7 @@ | |||||
| #include <vector> | #include <vector> | ||||
| #include "framework/common/types.h" | #include "framework/common/types.h" | ||||
| #include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
| #include "graph/common/transop_util.h" | |||||
| #include "common/transop_util.h" | |||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/manager/graph_mem_allocator.h" | #include "graph/manager/graph_mem_allocator.h" | ||||
| #include "graph/manager/graph_var_manager.h" | #include "graph/manager/graph_var_manager.h" | ||||
| @@ -25,9 +25,9 @@ | |||||
| #include "external/graph/attr_value.h" | #include "external/graph/attr_value.h" | ||||
| #include "graph/buffer.h" | #include "graph/buffer.h" | ||||
| #include "graph/build/stream_allocator.h" | #include "graph/build/stream_allocator.h" | ||||
| #include "graph/common/omg_util.h" | |||||
| #include "graph/common/ge_call_wrapper.h" | |||||
| #include "graph/common/local_context.h" | |||||
| #include "common/omg_util.h" | |||||
| #include "common/ge_call_wrapper.h" | |||||
| #include "common/local_context.h" | |||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/ge_attr_value.h" | #include "graph/ge_attr_value.h" | ||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| @@ -32,7 +32,7 @@ | |||||
| #include "graph/manager/graph_manager_utils.h" | #include "graph/manager/graph_manager_utils.h" | ||||
| #include "graph/model.h" | #include "graph/model.h" | ||||
| #include "graph/node.h" | #include "graph/node.h" | ||||
| #include "model/ge_model.h" | |||||
| #include "common/model/ge_model.h" | |||||
| #include "framework/omg/omg_inner_types.h" | #include "framework/omg/omg_inner_types.h" | ||||
| namespace ge { | namespace ge { | ||||
| @@ -18,7 +18,7 @@ | |||||
| #include "framework/common/util.h" | #include "framework/common/util.h" | ||||
| #include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/common/omg_util.h" | |||||
| #include "common/omg_util.h" | |||||
| namespace ge { | namespace ge { | ||||
| RunContextUtil::~RunContextUtil() { DestroyRtModelResources(); } | RunContextUtil::~RunContextUtil() { DestroyRtModelResources(); } | ||||
| @@ -22,7 +22,7 @@ | |||||
| #include "framework/common/fmk_error_codes.h" | #include "framework/common/fmk_error_codes.h" | ||||
| #include "framework/common/types.h" | #include "framework/common/types.h" | ||||
| #include "graph/build/logical_stream_allocator.h" | #include "graph/build/logical_stream_allocator.h" | ||||
| #include "graph/common/omg_util.h" | |||||
| #include "common/omg_util.h" | |||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| #include "graph/utils/graph_utils.h" | #include "graph/utils/graph_utils.h" | ||||
| @@ -29,7 +29,7 @@ | |||||
| #include "graph/utils/node_utils.h" | #include "graph/utils/node_utils.h" | ||||
| #include "graph/utils/tensor_utils.h" | #include "graph/utils/tensor_utils.h" | ||||
| #include "graph/utils/type_utils.h" | #include "graph/utils/type_utils.h" | ||||
| #include "graph/common/ge_call_wrapper.h" | |||||
| #include "common/ge_call_wrapper.h" | |||||
| #include "init/gelib.h" | #include "init/gelib.h" | ||||
| #include "graph/ge_local_context.h" | #include "graph/ge_local_context.h" | ||||
| #include "external/ge/ge_api_types.h" | #include "external/ge/ge_api_types.h" | ||||
| @@ -50,6 +50,7 @@ const char *const kIsInputVar = "INPUT_IS_VAR"; | |||||
| const char *const kIsOutputVar = "OUTPUT_IS_VAR"; | const char *const kIsOutputVar = "OUTPUT_IS_VAR"; | ||||
| const char *const kProfilingMode = "PROFILING_MODE"; | const char *const kProfilingMode = "PROFILING_MODE"; | ||||
| const char *const kIteratorV2 = "IteratorV2"; | const char *const kIteratorV2 = "IteratorV2"; | ||||
| const char *const kKernelInfoNameHccl = "ops_kernel_info_hccl"; | |||||
| const uint32_t kProfilingArStep = 2; | const uint32_t kProfilingArStep = 2; | ||||
| const uint64_t kProfilingFpStartLogid = 1; | const uint64_t kProfilingFpStartLogid = 1; | ||||
| const uint64_t kProfilingBpEndLogid = 2; | const uint64_t kProfilingBpEndLogid = 2; | ||||
| @@ -386,13 +387,7 @@ Status TaskGenerator::GenerateTask(RunContext &run_context, ComputeGraphPtr &gra | |||||
| GE_CHK_BOOL_EXEC_INFO(!op_kernel_lib_name.empty(), continue, | GE_CHK_BOOL_EXEC_INFO(!op_kernel_lib_name.empty(), continue, | ||||
| "Node[name:%s, type:%s] does not need to generate task.", name.c_str(), type.c_str()); | "Node[name:%s, type:%s] does not need to generate task.", name.c_str(), type.c_str()); | ||||
| auto kernel_info_store = ops_kernel_manager.GetOpsKernelInfoStore(op_kernel_lib_name); | auto kernel_info_store = ops_kernel_manager.GetOpsKernelInfoStore(op_kernel_lib_name); | ||||
| if (kernel_info_store == nullptr) { | |||||
| REPORT_INNER_ERROR("E19999", "Get ops kernel info store failed for op:%s(%s), op_kernel_name:%s", | |||||
| node->GetName().c_str(), node->GetType().c_str(), op_kernel_lib_name.c_str()); | |||||
| GELOGE(INTERNAL_ERROR, "[Call][GetOpsKernelInfoStore] No ops kernel store or ops kernel builder found. " | |||||
| "node:%s(%s), op_kernel_lib_name=%s.", name.c_str(), type.c_str(), op_kernel_lib_name.c_str()); | |||||
| return INTERNAL_ERROR; | |||||
| } | |||||
| GE_CHECK_NOTNULL(kernel_info_store); | |||||
| GE_CHK_STATUS_RET(UpdateAnchorStatus(node), "[Call][UpdateAnchorStatus] node:%s(%s) failed", name.c_str(), | GE_CHK_STATUS_RET(UpdateAnchorStatus(node), "[Call][UpdateAnchorStatus] node:%s(%s) failed", name.c_str(), | ||||
| type.c_str()); | type.c_str()); | ||||
| if (node->GetOpDesc()->HasAttr(ATTR_NAME_FFTS_SUB_GRAPH)) { | if (node->GetOpDesc()->HasAttr(ATTR_NAME_FFTS_SUB_GRAPH)) { | ||||
| @@ -437,14 +432,15 @@ Status TaskGenerator::GenerateTask(RunContext &run_context, ComputeGraphPtr &gra | |||||
| } | } | ||||
| // Reset stream id to ge stream id, as graph load must use ge stream to reassign stream | // Reset stream id to ge stream id, as graph load must use ge stream to reassign stream | ||||
| void *ops_kernel_info_store_ptr = kernel_info_store.get(); | |||||
| for (size_t idx = task_list_size_before; idx < task_list_size_after; ++idx) { | for (size_t idx = task_list_size_before; idx < task_list_size_after; ++idx) { | ||||
| task_def_list[idx].set_stream_id(static_cast<uint32_t>(stream_id)); | task_def_list[idx].set_stream_id(static_cast<uint32_t>(stream_id)); | ||||
| op_name_map[idx] = name; | op_name_map[idx] = name; | ||||
| // Set opsKernelInfoStorePtr and op_index, the two fields be use in DistributeTask and InitTaskInfo | |||||
| TaskDef *task_def_ptr = &task_def_list[idx]; | TaskDef *task_def_ptr = &task_def_list[idx]; | ||||
| GE_CHECK_NOTNULL(task_def_ptr); | GE_CHECK_NOTNULL(task_def_ptr); | ||||
| task_def_ptr->set_ops_kernel_store_ptr(reinterpret_cast<uintptr_t>(ops_kernel_info_store_ptr)); | |||||
| // Set opsKernelInfoStorePtr for hccl which will be use in DistributeTask and InitTaskInfo | |||||
| if (op_kernel_lib_name == kKernelInfoNameHccl) { | |||||
| task_def_ptr->set_ops_kernel_store_ptr(reinterpret_cast<uintptr_t>(kernel_info_store.get())); | |||||
| } | |||||
| } | } | ||||
| GELOGD("Call %s to generate node[name:%s(%s), id:%ld, stream_id:%ld] task finished, generate %zu task(s).", | GELOGD("Call %s to generate node[name:%s(%s), id:%ld, stream_id:%ld] task finished, generate %zu task(s).", | ||||
| op_kernel_lib_name.c_str(), name.c_str(), type.c_str(), op_id, stream_id, | op_kernel_lib_name.c_str(), name.c_str(), type.c_str(), op_id, stream_id, | ||||
| @@ -18,8 +18,8 @@ | |||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/common/ge_call_wrapper.h" | |||||
| #include "graph/common/local_context.h" | |||||
| #include "common/ge_call_wrapper.h" | |||||
| #include "common/local_context.h" | |||||
| #include "graph/manager/graph_var_manager.h" | #include "graph/manager/graph_var_manager.h" | ||||
| #include "graph/utils/tensor_adapter.h" | #include "graph/utils/tensor_adapter.h" | ||||
| #include "graph/load/graph_loader.h" | #include "graph/load/graph_loader.h" | ||||
| @@ -32,7 +32,7 @@ | |||||
| #include "common/thread_pool.h" | #include "common/thread_pool.h" | ||||
| #include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
| #include "framework/common/util.h" | #include "framework/common/util.h" | ||||
| #include "graph/common/ge_call_wrapper.h" | |||||
| #include "common/ge_call_wrapper.h" | |||||
| #include "graph/compute_graph.h" | #include "graph/compute_graph.h" | ||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| @@ -57,9 +57,9 @@ | |||||
| #include "runtime/rt_model.h" | #include "runtime/rt_model.h" | ||||
| #include "runtime/stream.h" | #include "runtime/stream.h" | ||||
| #include "securec.h" | #include "securec.h" | ||||
| #include "graph/common/local_context.h" | |||||
| #include "common/local_context.h" | |||||
| #include "common/formats/utils/formats_trans_utils.h" | #include "common/formats/utils/formats_trans_utils.h" | ||||
| #include "graph/common/omg_util.h" | |||||
| #include "common/omg_util.h" | |||||
| #include "graph/build/memory/block_mem_assigner.h" | #include "graph/build/memory/block_mem_assigner.h" | ||||
| #include "graph/manager/session_scope_mem_allocator.h" | #include "graph/manager/session_scope_mem_allocator.h" | ||||
| #include "framework/omg/omg_inner_types.h" | #include "framework/omg/omg_inner_types.h" | ||||
| @@ -238,6 +238,12 @@ DavinciModel::~DavinciModel() { | |||||
| GE_LOGW_IF(rtEventDestroy(event_list_[i]) != RT_ERROR_NONE, "Destroy event failed, index: %zu", i); | GE_LOGW_IF(rtEventDestroy(event_list_[i]) != RT_ERROR_NONE, "Destroy event failed, index: %zu", i); | ||||
| } | } | ||||
| for (const auto &it : stream_2_event_) { | |||||
| if (rtEventDestroy(it.second) != RT_ERROR_NONE) { | |||||
| GELOGW("Destroy event failed"); | |||||
| } | |||||
| } | |||||
| FreeWeightsMem(); | FreeWeightsMem(); | ||||
| FreeFeatureMapMem(); | FreeFeatureMapMem(); | ||||
| @@ -4648,4 +4654,50 @@ Status DavinciModel::GetTotalMemSizeExcludeZeroCopy(int64_t &total_useful_size) | |||||
| total_useful_size = runtime_param_.mem_size - runtime_param_.zero_copy_size; | total_useful_size = runtime_param_.mem_size - runtime_param_.zero_copy_size; | ||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| Status DavinciModel::GetEventIdForBlockingAicpuOp(const OpDescPtr &op_desc, rtStream_t stream, uint32_t &event_id) { | |||||
| GELOGI("Get event id for aicpu blocking op:%s", op_desc->GetName().c_str()); | |||||
| auto it = stream_2_event_.find(stream); | |||||
| if (it != stream_2_event_.end()) { | |||||
| auto rt_ret = rtGetEventID(it->second, &event_id); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtGetEventID failed for op:%s(%s), ret:0x%X", | |||||
| op_desc->GetName().c_str(), op_desc->GetType().c_str(), rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][rtGetEventID] failed for op:%s(%s), ret:0x%X", | |||||
| op_desc->GetName().c_str(), op_desc->GetType().c_str(), rt_ret); | |||||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
| } | |||||
| } else { | |||||
| rtEvent_t rt_event = nullptr; | |||||
| auto rt_ret = rtEventCreateWithFlag(&rt_event, RT_EVENT_WITH_FLAG); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtEventCreateWithFlag failed for op:%s(%s), ret:0x%X", | |||||
| op_desc->GetName().c_str(), op_desc->GetType().c_str(), rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][rtEventCreateWithFlag] failed for op:%s(%s), ret:0x%X", | |||||
| op_desc->GetName().c_str(), op_desc->GetType().c_str(), rt_ret); | |||||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
| } | |||||
| rt_ret = rtGetEventID(rt_event, &event_id); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtGetEventID failed for op:%s(%s), ret:0x%X", | |||||
| op_desc->GetName().c_str(), op_desc->GetType().c_str(), rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][rtGetEventID] failed for op:%s(%s), ret:0x%X", | |||||
| op_desc->GetName().c_str(), op_desc->GetType().c_str(), rt_ret); | |||||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
| } | |||||
| stream_2_event_.emplace(stream, rt_event); | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| Status DavinciModel::GetEventByStream(const rtStream_t &stream, rtEvent_t &rt_event) { | |||||
| auto it = stream_2_event_.find(stream); | |||||
| if (it == stream_2_event_.end()) { | |||||
| REPORT_INNER_ERROR("E19999", "Get event failed"); | |||||
| GELOGE(FAILED, "[Get][Event] Get event failed"); | |||||
| return FAILED; | |||||
| } | |||||
| rt_event = it->second; | |||||
| return SUCCESS; | |||||
| } | |||||
| } // namespace ge | } // namespace ge | ||||
| @@ -49,7 +49,7 @@ | |||||
| #include "mmpa/mmpa_api.h" | #include "mmpa/mmpa_api.h" | ||||
| #include "proto/task.pb.h" | #include "proto/task.pb.h" | ||||
| #include "graph/load/model_manager/task_info/task_info.h" | #include "graph/load/model_manager/task_info/task_info.h" | ||||
| #include "graph/common/local_context.h" | |||||
| #include "common/local_context.h" | |||||
| using std::mutex; | using std::mutex; | ||||
| using std::thread; | using std::thread; | ||||
| @@ -582,6 +582,10 @@ class DavinciModel { | |||||
| void SetRunningFlag(bool flag) { running_flg_ = flag; } | void SetRunningFlag(bool flag) { running_flg_ = flag; } | ||||
| Status SetRunAsyncListenerCallback(const RunAsyncCallback &callback); | Status SetRunAsyncListenerCallback(const RunAsyncCallback &callback); | ||||
| // for blocking aicpu op | |||||
| Status GetEventByStream(const rtStream_t &stream, rtEvent_t &rt_event); | |||||
| Status GetEventIdForBlockingAicpuOp(const OpDescPtr &op_desc, rtStream_t stream, uint32_t &event_id); | |||||
| private: | private: | ||||
| // memory address of weights | // memory address of weights | ||||
| uint8_t *weights_mem_base_; | uint8_t *weights_mem_base_; | ||||
| @@ -1107,6 +1111,8 @@ class DavinciModel { | |||||
| // op name to attrs mapping | // op name to attrs mapping | ||||
| std::map<std::string, std::map<std::string, std::vector<std::string>>> op_name_to_attrs_; | std::map<std::string, std::map<std::string, std::vector<std::string>>> op_name_to_attrs_; | ||||
| std::map<rtStream_t, rtEvent_t> stream_2_event_; | |||||
| }; | }; | ||||
| } // namespace ge | } // namespace ge | ||||
| #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_DAVINCI_MODEL_H_ | #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_DAVINCI_MODEL_H_ | ||||
| @@ -23,9 +23,9 @@ | |||||
| #include "common/dump/dump_manager.h" | #include "common/dump/dump_manager.h" | ||||
| #include "framework/common/l2_cache_optimize.h" | #include "framework/common/l2_cache_optimize.h" | ||||
| #include "common/profiling/profiling_manager.h" | #include "common/profiling/profiling_manager.h" | ||||
| #include "graph/common/ge_call_wrapper.h" | |||||
| #include "common/ge_call_wrapper.h" | |||||
| #include "graph/load/model_manager/davinci_model.h" | #include "graph/load/model_manager/davinci_model.h" | ||||
| #include "model/ge_root_model.h" | |||||
| #include "common/model/ge_root_model.h" | |||||
| #include "common/formats/utils/formats_trans_utils.h" | #include "common/formats/utils/formats_trans_utils.h" | ||||
| namespace ge { | namespace ge { | ||||
| @@ -17,7 +17,7 @@ | |||||
| #ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_MODEL_MANAGER_H_ | #ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_MODEL_MANAGER_H_ | ||||
| #define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_MODEL_MANAGER_H_ | #define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_MODEL_MANAGER_H_ | ||||
| #include <model/ge_root_model.h> | |||||
| #include <common/model/ge_root_model.h> | |||||
| #include <stdint.h> | #include <stdint.h> | ||||
| #include <algorithm> | #include <algorithm> | ||||
| #include <map> | #include <map> | ||||
| @@ -26,8 +26,8 @@ | |||||
| #include "external/graph/attr_value.h" | #include "external/graph/attr_value.h" | ||||
| #include "graph/load/model_manager/davinci_model.h" | #include "graph/load/model_manager/davinci_model.h" | ||||
| #include "graph/load/model_manager/model_manager.h" | #include "graph/load/model_manager/model_manager.h" | ||||
| #include "hybrid/node_executor/aicpu/aicpu_ext_info.h" | |||||
| #include "framework/common/debug/log.h" | #include "framework/common/debug/log.h" | ||||
| #include "runtime/rt.h" | |||||
| namespace { | namespace { | ||||
| const char *const kAicpuAllshape = "_AllShape"; | const char *const kAicpuAllshape = "_AllShape"; | ||||
| @@ -43,7 +43,7 @@ Status KernelExTaskInfo::InitTaskExtInfo(const std::string &ext_info, const OpDe | |||||
| UnknowShapeOpType unknown_type = static_cast<UnknowShapeOpType>(unknown_shape_type_val); | UnknowShapeOpType unknown_type = static_cast<UnknowShapeOpType>(unknown_shape_type_val); | ||||
| uint32_t num_inputs = op_desc->GetInputsSize(); | uint32_t num_inputs = op_desc->GetInputsSize(); | ||||
| uint32_t num_outputs = op_desc->GetOutputsSize(); | uint32_t num_outputs = op_desc->GetOutputsSize(); | ||||
| std::unique_ptr<ge::hybrid::AicpuExtInfoHandler> ext_handle( | |||||
| std::shared_ptr<ge::hybrid::AicpuExtInfoHandler> ext_handle( | |||||
| new(std::nothrow) ::ge::hybrid::AicpuExtInfoHandler(op_desc->GetName(), | new(std::nothrow) ::ge::hybrid::AicpuExtInfoHandler(op_desc->GetName(), | ||||
| num_inputs, | num_inputs, | ||||
| num_outputs, | num_outputs, | ||||
| @@ -76,6 +76,16 @@ Status KernelExTaskInfo::InitTaskExtInfo(const std::string &ext_info, const OpDe | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| AttrUtils::GetBool(op_desc, ATTR_NAME_IS_BLOCKING_OP, is_blocking_aicpu_op_); | |||||
| GELOGD("Get op:%s attribute(is_blocking_op), value:%d", op_desc->GetName().c_str(), is_blocking_aicpu_op_); | |||||
| if (UpdateEventIdForAicpuBlockingOp(op_desc, ext_handle) != SUCCESS) { | |||||
| GELOGE(FAILED, "[Call][UpdateEventIdForAicpuBlockingOp] failed for op:%s(%s)", | |||||
| op_desc->GetName().c_str(), op_desc->GetType().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| auto rt_ret = rtMalloc(&ext_info_addr_, ext_handle->GetExtInfoLen(), RT_MEMORY_HBM); | auto rt_ret = rtMalloc(&ext_info_addr_, ext_handle->GetExtInfoLen(), RT_MEMORY_HBM); | ||||
| GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, | GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, | ||||
| REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, size:%zu, ret:0x%X", ext_info.size(), rt_ret); | REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, size:%zu, ret:0x%X", ext_info.size(), rt_ret); | ||||
| @@ -106,6 +116,7 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin | |||||
| // 1. Copy context from kernelExDef.private to workspace | // 1. Copy context from kernelExDef.private to workspace | ||||
| uint32_t op_index = kernel_ex_def.op_index(); | uint32_t op_index = kernel_ex_def.op_index(); | ||||
| OpDescPtr op_desc = davinci_model_->GetOpByIndex(op_index); | OpDescPtr op_desc = davinci_model_->GetOpByIndex(op_index); | ||||
| op_desc_ = op_desc; | |||||
| if (op_desc == nullptr) { | if (op_desc == nullptr) { | ||||
| REPORT_INNER_ERROR("E19999", "Can't get op_desc from davinci_model by index:%u", op_index); | REPORT_INNER_ERROR("E19999", "Can't get op_desc from davinci_model by index:%u", op_index); | ||||
| GELOGE(INTERNAL_ERROR, "[Get][Op] by index failed, index:%u is out of range!", op_index); | GELOGE(INTERNAL_ERROR, "[Get][Op] by index failed, index:%u is out of range!", op_index); | ||||
| @@ -422,7 +433,7 @@ Status KernelExTaskInfo::Distribute() { | |||||
| if (topic_type_flag_ > 0) { | if (topic_type_flag_ > 0) { | ||||
| dump_flag_ = dump_flag_ | static_cast<uint32_t>(topic_type_flag_); | dump_flag_ = dump_flag_ | static_cast<uint32_t>(topic_type_flag_); | ||||
| } | } | ||||
| rtError_t rt_ret = rtKernelLaunchEx(kernel_buf_, kernel_buf_size_, dump_flag_, stream_); | |||||
| rtError_t rt_ret = rtKernelLaunchFwk(op_desc_->GetName().c_str(), kernel_buf_, kernel_buf_size_, dump_flag_, stream_); | |||||
| if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
| REPORT_CALL_ERROR("E19999", "Call rtKernelLaunchEx failed, ret:0x%X", rt_ret); | REPORT_CALL_ERROR("E19999", "Call rtKernelLaunchEx failed, ret:0x%X", rt_ret); | ||||
| GELOGE(RT_FAILED, "[Call][RtKernelLaunchEx] failed, ret:0x%X", rt_ret); | GELOGE(RT_FAILED, "[Call][RtKernelLaunchEx] failed, ret:0x%X", rt_ret); | ||||
| @@ -447,6 +458,101 @@ Status KernelExTaskInfo::Distribute() { | |||||
| stream_id_ = stream_id; | stream_id_ = stream_id; | ||||
| GELOGI("KernelExTaskInfo Distribute Success. task id: %u, stream id: %u", task_id_, stream_id_); | GELOGI("KernelExTaskInfo Distribute Success. task id: %u, stream id: %u", task_id_, stream_id_); | ||||
| if (is_blocking_aicpu_op_) { | |||||
| if (DistributeWaitTaskForAicpuBlockingOp() != SUCCESS) { | |||||
| GELOGE(FAILED, "[Call][DistributeWaitTaskForAicpuBlockingOp] Call DistributeWaitTaskForAicpuBlockingOp failed"); | |||||
| return FAILED; | |||||
| } | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| Status KernelExTaskInfo::CheckDeviceSupportBlockingAicpuOpProcess(bool &is_support) { | |||||
| int32_t device_id = 0; | |||||
| auto rt_ret = rtGetDevice(&device_id); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtGetDevice failed, ret:0x%X", rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][rtGetDevice] failed, ret:0x%X", rt_ret); | |||||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
| } | |||||
| int32_t value = 0; | |||||
| rt_ret = rtGetDeviceCapability(device_id, FEATURE_TYPE_BLOCKING_OPERATOR, RT_MODULE_TYPE_AICPU, &value); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtGetDeviceCapability failed, ret:0x%X", rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][rtGetDeviceCapability] failed, ret:0x%X", rt_ret); | |||||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
| } | |||||
| if (value != RT_AICPU_BLOCKING_OP_NOT_SUPPORT && value != RT_AICPU_BLOCKING_OP_SUPPORT) { | |||||
| REPORT_INNER_ERROR("E19999", "Value should be %d or %d but %d", | |||||
| RT_AICPU_BLOCKING_OP_NOT_SUPPORT, RT_AICPU_BLOCKING_OP_SUPPORT, value); | |||||
| GELOGE(FAILED, "[Check][Value] Value should be %d or %d but %d", | |||||
| RT_AICPU_BLOCKING_OP_NOT_SUPPORT, RT_AICPU_BLOCKING_OP_SUPPORT, value); | |||||
| return FAILED; | |||||
| } | |||||
| is_support = (value == RT_AICPU_BLOCKING_OP_SUPPORT ? true : false); | |||||
| return SUCCESS; | |||||
| } | |||||
| Status KernelExTaskInfo::UpdateEventIdForAicpuBlockingOp(const OpDescPtr &op_desc, | |||||
| std::shared_ptr<ge::hybrid::AicpuExtInfoHandler> &ext_handle) { | |||||
| if (is_blocking_aicpu_op_) { | |||||
| bool is_support = false; | |||||
| if (CheckDeviceSupportBlockingAicpuOpProcess(is_support) != SUCCESS) { | |||||
| GELOGE(FAILED, "[Call][CheckDeviceSupportBlockingAicpuOpProcess] Call CheckDeviceSupportBlockingAicpuOpProcess failed"); | |||||
| return FAILED; | |||||
| } | |||||
| if (!is_support) { | |||||
| GELOGD("Device not support blocking aicpu op process"); | |||||
| return SUCCESS; | |||||
| } | |||||
| uint32_t event_id = 0; | |||||
| if (davinci_model_->GetEventIdForBlockingAicpuOp(op_desc, stream_, event_id) != SUCCESS) { | |||||
| REPORT_CALL_ERROR("E19999", "Get event id failed for op:%s(%s).", op_desc->GetName().c_str(), | |||||
| op_desc->GetType().c_str()); | |||||
| GELOGE(FAILED, "[Get][EventId] Get event id failed for op:%s(%s)", op_desc->GetName().c_str(), | |||||
| op_desc->GetType().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| if (ext_handle->UpdateEventId(event_id) != SUCCESS) { | |||||
| REPORT_CALL_ERROR("E19999", "Update event id failed for op:%s(%s).", op_desc->GetName().c_str(), | |||||
| op_desc->GetType().c_str()); | |||||
| GELOGE(FAILED, "[Update][EventId] Update event id failed for op:%s(%s)", op_desc->GetName().c_str(), | |||||
| op_desc->GetType().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| GELOGI("Update event_id=%u success", event_id); | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| Status KernelExTaskInfo::DistributeWaitTaskForAicpuBlockingOp() { | |||||
| bool is_support = false; | |||||
| if (CheckDeviceSupportBlockingAicpuOpProcess(is_support) != SUCCESS) { | |||||
| GELOGE(FAILED, "[Call][CheckDeviceSupportBlockingAicpuOpProcess] Call CheckDeviceSupportBlockingAicpuOpProcess failed"); | |||||
| return FAILED; | |||||
| } | |||||
| if (!is_support) { | |||||
| GELOGD("Device not support blocking aicpu op process."); | |||||
| return SUCCESS; | |||||
| } | |||||
| GELOGD("Distribute wait task begin"); | |||||
| rtEvent_t rt_event = nullptr; | |||||
| if (davinci_model_->GetEventByStream(stream_, rt_event) != SUCCESS) { | |||||
| GELOGE(FAILED, "[Call][GetEventByStream] Call GetEventByStream failed"); | |||||
| return FAILED; | |||||
| } | |||||
| auto rt_ret = rtStreamWaitEvent(stream_, rt_event); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtStreamWaitEvent failed, ret:0x%X", rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][RtApi] failed, ret:0x%X", rt_ret); | |||||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
| } | |||||
| rt_ret = rtEventReset(rt_event, stream_); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtEventReset failed, ret:0x%X", rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][RtApi] failed, ret:0x%X", rt_ret); | |||||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
| } | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| @@ -19,6 +19,7 @@ | |||||
| #include "graph/load/model_manager/task_info/task_info.h" | #include "graph/load/model_manager/task_info/task_info.h" | ||||
| #include "graph/op_desc.h" | #include "graph/op_desc.h" | ||||
| #include "hybrid/node_executor/aicpu/aicpu_ext_info.h" | |||||
| namespace ge { | namespace ge { | ||||
| class KernelExTaskInfo : public TaskInfo { | class KernelExTaskInfo : public TaskInfo { | ||||
| @@ -65,11 +66,18 @@ class KernelExTaskInfo : public TaskInfo { | |||||
| void InitDumpArgs(void *addr, const OpDescPtr &op_desc); | void InitDumpArgs(void *addr, const OpDescPtr &op_desc); | ||||
| Status InitTaskExtInfo(const std::string &ext_info, const OpDescPtr &op_desc); | Status InitTaskExtInfo(const std::string &ext_info, const OpDescPtr &op_desc); | ||||
| // for blocking aicpu op | |||||
| Status DistributeWaitTaskForAicpuBlockingOp(); | |||||
| Status CheckDeviceSupportBlockingAicpuOpProcess(bool &is_support); | |||||
| Status UpdateEventIdForAicpuBlockingOp(const OpDescPtr &op_desc, | |||||
| std::shared_ptr<ge::hybrid::AicpuExtInfoHandler> &ext_handle); | |||||
| uint32_t task_id_; | uint32_t task_id_; | ||||
| uint32_t stream_id_; | uint32_t stream_id_; | ||||
| uint32_t dump_flag_; | uint32_t dump_flag_; | ||||
| uint32_t kernel_buf_size_; | uint32_t kernel_buf_size_; | ||||
| DavinciModel *davinci_model_; | DavinciModel *davinci_model_; | ||||
| OpDescPtr op_desc_; | |||||
| void *kernel_buf_; | void *kernel_buf_; | ||||
| void *input_output_addr_; | void *input_output_addr_; | ||||
| void *ext_info_addr_; | void *ext_info_addr_; | ||||
| @@ -78,6 +86,7 @@ class KernelExTaskInfo : public TaskInfo { | |||||
| uint32_t args_offset_ = 0; | uint32_t args_offset_ = 0; | ||||
| int64_t fixed_addr_offset_ = 0; | int64_t fixed_addr_offset_ = 0; | ||||
| int32_t topic_type_flag_ = -1; | int32_t topic_type_flag_ = -1; | ||||
| bool is_blocking_aicpu_op_ = false; | |||||
| }; | }; | ||||
| } // namespace ge | } // namespace ge | ||||
| #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_KERNEL_EX_TASK_INFO_H_ | #endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_KERNEL_EX_TASK_INFO_H_ | ||||
| @@ -28,11 +28,10 @@ | |||||
| #include "graph/load/model_manager/davinci_model.h" | #include "graph/load/model_manager/davinci_model.h" | ||||
| #include "graph/load/model_manager/model_manager.h" | #include "graph/load/model_manager/model_manager.h" | ||||
| #include "graph/load/model_manager/model_utils.h" | #include "graph/load/model_manager/model_utils.h" | ||||
| #include "runtime/kernel.h" | |||||
| #include "runtime/rt.h" | |||||
| #include "graph/load/model_manager/task_info/super_kernel/super_kernel.h" | #include "graph/load/model_manager/task_info/super_kernel/super_kernel.h" | ||||
| #include "graph/load/model_manager/task_info/super_kernel/super_kernel_factory.h" | #include "graph/load/model_manager/task_info/super_kernel/super_kernel_factory.h" | ||||
| #include "cce/aicpu_engine_struct.h" | #include "cce/aicpu_engine_struct.h" | ||||
| #include "hybrid/node_executor/aicpu/aicpu_ext_info.h" | |||||
| #include "framework/common/debug/log.h" | #include "framework/common/debug/log.h" | ||||
| namespace { | namespace { | ||||
| @@ -440,9 +439,10 @@ Status KernelTaskInfo::Distribute() { | |||||
| } | } | ||||
| GELOGI("distribute task info kernel_type %d, flag %d", kernel_type_, dump_flag_); | GELOGI("distribute task info kernel_type %d, flag %d", kernel_type_, dump_flag_); | ||||
| // blockDim is reserved parameter, set to 1 | // blockDim is reserved parameter, set to 1 | ||||
| rt_ret = rtCpuKernelLaunchWithFlag(reinterpret_cast<const void *>(so_name_.c_str()), | |||||
| reinterpret_cast<const void *>(kernel_name_.c_str()), 1, args_, args_size_, | |||||
| nullptr, stream_, dump_flag_); | |||||
| std::string op_name = op_desc_->GetName(); | |||||
| rtKernelLaunchNames_t launch_name = {so_name_.c_str(), kernel_name_.c_str(), op_name.c_str()}; | |||||
| rt_ret = rtAicpuKernelLaunchWithFlag(&launch_name, 1, args_, args_size_, | |||||
| nullptr, stream_, dump_flag_); | |||||
| call_save_dump_ = true; | call_save_dump_ = true; | ||||
| } else { | } else { | ||||
| /* default: not skt launch */ | /* default: not skt launch */ | ||||
| @@ -473,6 +473,12 @@ Status KernelTaskInfo::Distribute() { | |||||
| } | } | ||||
| // set for task_id_ | // set for task_id_ | ||||
| UpdateTaskId(); | UpdateTaskId(); | ||||
| if (is_blocking_aicpu_op_) { | |||||
| if (DistributeWaitTaskForAicpuBlockingOp() != SUCCESS) { | |||||
| GELOGE(FAILED, "[Call][DistributeWaitTaskForAicpuBlockingOp] Call DistributeWaitTaskForAicpuBlockingOp failed"); | |||||
| return FAILED; | |||||
| } | |||||
| } | |||||
| GELOGD( | GELOGD( | ||||
| "KernelTaskInfo Distribute Success. sktenable:%d taskid:%d sktid:%d stubfunc_name:%s stubfunc:%p " | "KernelTaskInfo Distribute Success. sktenable:%d taskid:%d sktid:%d stubfunc_name:%s stubfunc:%p " | ||||
| "blockdim:%d stream:%p", | "blockdim:%d stream:%p", | ||||
| @@ -481,6 +487,91 @@ Status KernelTaskInfo::Distribute() { | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| Status KernelTaskInfo::CheckDeviceSupportBlockingAicpuOpProcess(bool &is_support) { | |||||
| int32_t device_id = 0; | |||||
| auto rt_ret = rtGetDevice(&device_id); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtGetDevice failed, ret:0x%X", rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][rtGetDevice] failed, ret:0x%X", rt_ret); | |||||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
| } | |||||
| int32_t value = 0; | |||||
| rt_ret = rtGetDeviceCapability(device_id, FEATURE_TYPE_BLOCKING_OPERATOR, RT_MODULE_TYPE_AICPU, &value); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtGetDeviceCapability failed, ret:0x%X", rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][rtGetDeviceCapability] failed, ret:0x%X", rt_ret); | |||||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
| } | |||||
| if (value != RT_AICPU_BLOCKING_OP_NOT_SUPPORT && value != RT_AICPU_BLOCKING_OP_SUPPORT) { | |||||
| REPORT_INNER_ERROR("E19999", "Value should be %d or %d but %d", | |||||
| RT_AICPU_BLOCKING_OP_NOT_SUPPORT, RT_AICPU_BLOCKING_OP_SUPPORT, value); | |||||
| GELOGE(FAILED, "[Check][Value] Value should be %d or %d but %d", | |||||
| RT_AICPU_BLOCKING_OP_NOT_SUPPORT, RT_AICPU_BLOCKING_OP_SUPPORT, value); | |||||
| return FAILED; | |||||
| } | |||||
| is_support = (value == RT_AICPU_BLOCKING_OP_SUPPORT ? true : false); | |||||
| return SUCCESS; | |||||
| } | |||||
| Status KernelTaskInfo::UpdateEventIdForAicpuBlockingOp(std::shared_ptr<ge::hybrid::AicpuExtInfoHandler> &ext_handle) { | |||||
| if (is_blocking_aicpu_op_) { | |||||
| bool is_support = false; | |||||
| if (CheckDeviceSupportBlockingAicpuOpProcess(is_support) != SUCCESS) { | |||||
| GELOGE(FAILED, "[Call][CheckDeviceSupportBlockingAicpuOpProcess] Call CheckDeviceSupportBlockingAicpuOpProcess failed"); | |||||
| return FAILED; | |||||
| } | |||||
| if (!is_support) { | |||||
| GELOGD("Device not support blocking aicpu op process"); | |||||
| return SUCCESS; | |||||
| } | |||||
| uint32_t event_id = 0; | |||||
| if (davinci_model_->GetEventIdForBlockingAicpuOp(op_desc_, stream_, event_id) != SUCCESS) { | |||||
| GELOGE(FAILED, "[Get][EventId] Get event id failed for op:%s(%s)", op_desc_->GetName().c_str(), | |||||
| op_desc_->GetType().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| if (ext_handle->UpdateEventId(event_id) != SUCCESS) { | |||||
| GELOGE(FAILED, "[Update][EventId] Update event id failed for op:%s(%s)", op_desc_->GetName().c_str(), | |||||
| op_desc_->GetType().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| GELOGI("Update event_id=%u success", event_id); | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| Status KernelTaskInfo::DistributeWaitTaskForAicpuBlockingOp() { | |||||
| bool is_support = false; | |||||
| if (CheckDeviceSupportBlockingAicpuOpProcess(is_support) != SUCCESS) { | |||||
| GELOGE(FAILED, "[Call][CheckDeviceSupportBlockingAicpuOpProcess] Call CheckDeviceSupportBlockingAicpuOpProcess failed"); | |||||
| return FAILED; | |||||
| } | |||||
| if (!is_support) { | |||||
| GELOGD("device not support blocking aicpu op process."); | |||||
| return SUCCESS; | |||||
| } | |||||
| GELOGD("Distribute wait task begin"); | |||||
| rtEvent_t rt_event = nullptr; | |||||
| if (davinci_model_->GetEventByStream(stream_, rt_event) != SUCCESS) { | |||||
| REPORT_CALL_ERROR("E19999", "Call GetEventByStream failed"); | |||||
| GELOGE(FAILED, "[Call][GetEventByStream] Call GetEventByStream failed"); | |||||
| return FAILED; | |||||
| } | |||||
| auto rt_ret = rtStreamWaitEvent(stream_, rt_event); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtStreamWaitEvent failed, ret:0x%X", rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][RtApi] failed, ret:0x%X", rt_ret); | |||||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
| } | |||||
| rt_ret = rtEventReset(rt_event, stream_); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtEventReset failed, ret:0x%X", rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][RtApi] failed, ret:0x%X", rt_ret); | |||||
| return RT_ERROR_TO_GE_STATUS(rt_ret); | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| void KernelTaskInfo::SetIoAddrs(const OpDescPtr &op_desc) { | void KernelTaskInfo::SetIoAddrs(const OpDescPtr &op_desc) { | ||||
| const RuntimeParam &rts_param = davinci_model_->GetRuntimeParam(); | const RuntimeParam &rts_param = davinci_model_->GetRuntimeParam(); | ||||
| vector<void *> input_data_addrs = ModelUtils::GetInputDataAddrs(rts_param, op_desc); | vector<void *> input_data_addrs = ModelUtils::GetInputDataAddrs(rts_param, op_desc); | ||||
| @@ -1108,7 +1199,7 @@ Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) { | |||||
| UnknowShapeOpType unknown_type = static_cast<UnknowShapeOpType>(unknown_shape_type_val); | UnknowShapeOpType unknown_type = static_cast<UnknowShapeOpType>(unknown_shape_type_val); | ||||
| uint32_t num_inputs = op_desc_->GetInputsSize(); | uint32_t num_inputs = op_desc_->GetInputsSize(); | ||||
| uint32_t num_outputs = op_desc_->GetOutputsSize(); | uint32_t num_outputs = op_desc_->GetOutputsSize(); | ||||
| std::unique_ptr<ge::hybrid::AicpuExtInfoHandler> ext_handle( | |||||
| std::shared_ptr<ge::hybrid::AicpuExtInfoHandler> ext_handle( | |||||
| new(std::nothrow) ::ge::hybrid::AicpuExtInfoHandler(op_desc_->GetName(), | new(std::nothrow) ::ge::hybrid::AicpuExtInfoHandler(op_desc_->GetName(), | ||||
| num_inputs, | num_inputs, | ||||
| num_outputs, | num_outputs, | ||||
| @@ -1144,6 +1235,16 @@ Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) { | |||||
| j, op_desc_->GetName().c_str()); | j, op_desc_->GetName().c_str()); | ||||
| } | } | ||||
| } | } | ||||
| AttrUtils::GetBool(op_desc_, ATTR_NAME_IS_BLOCKING_OP, is_blocking_aicpu_op_); | |||||
| GELOGD("Get op:%s attribute(is_blocking_op), value:%d", op_desc_->GetName().c_str(), is_blocking_aicpu_op_); | |||||
| if (UpdateEventIdForAicpuBlockingOp(ext_handle) != SUCCESS) { | |||||
| GELOGE(FAILED, "[Call][UpdateEventIdForAicpuBlockingOp] failed for op:%s(%s)", | |||||
| op_desc_->GetName().c_str(), op_desc_->GetType().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| auto rt_ret = rtMalloc(&aicpu_ext_info_addr_, ext_handle->GetExtInfoLen(), RT_MEMORY_HBM); | auto rt_ret = rtMalloc(&aicpu_ext_info_addr_, ext_handle->GetExtInfoLen(), RT_MEMORY_HBM); | ||||
| if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
| REPORT_CALL_ERROR("E19999", "Call rtMalloc failed for op:%s(%s), size:%zu, ret:0x%X", | REPORT_CALL_ERROR("E19999", "Call rtMalloc failed for op:%s(%s), size:%zu, ret:0x%X", | ||||
| @@ -24,6 +24,8 @@ | |||||
| #include "graph/load/model_manager/task_info/task_info.h" | #include "graph/load/model_manager/task_info/task_info.h" | ||||
| #include "graph/op_desc.h" | #include "graph/op_desc.h" | ||||
| #include "hybrid/node_executor/aicpu/aicpu_ext_info.h" | |||||
| namespace ge { | namespace ge { | ||||
| class KernelTaskInfo : public TaskInfo { | class KernelTaskInfo : public TaskInfo { | ||||
| public: | public: | ||||
| @@ -148,6 +150,11 @@ class KernelTaskInfo : public TaskInfo { | |||||
| bool DoubleCallSKTSaveCheck(); | bool DoubleCallSKTSaveCheck(); | ||||
| void SetArgs(); | void SetArgs(); | ||||
| // for blocking aicpu op | |||||
| Status DistributeWaitTaskForAicpuBlockingOp(); | |||||
| Status CheckDeviceSupportBlockingAicpuOpProcess(bool &is_support); | |||||
| Status UpdateEventIdForAicpuBlockingOp(std::shared_ptr<ge::hybrid::AicpuExtInfoHandler> &ext_handle); | |||||
| void *stub_func_; | void *stub_func_; | ||||
| void *args_; | void *args_; | ||||
| void *sm_desc_; | void *sm_desc_; | ||||
| @@ -187,6 +194,7 @@ class KernelTaskInfo : public TaskInfo { | |||||
| uint32_t skt_dump_flag_ = RT_KERNEL_DEFAULT; | uint32_t skt_dump_flag_ = RT_KERNEL_DEFAULT; | ||||
| void *superkernel_device_args_addr_ = nullptr; | void *superkernel_device_args_addr_ = nullptr; | ||||
| void *superkernel_dev_nav_table_ = nullptr; | void *superkernel_dev_nav_table_ = nullptr; | ||||
| bool is_blocking_aicpu_op_ = false; | |||||
| struct AICPUCustomInfo { | struct AICPUCustomInfo { | ||||
| void *input_descs = nullptr; | void *input_descs = nullptr; | ||||
| @@ -29,9 +29,9 @@ | |||||
| #include "common/dump/dump_manager.h" | #include "common/dump/dump_manager.h" | ||||
| #include "ge_opt_info/ge_opt_info.h" | #include "ge_opt_info/ge_opt_info.h" | ||||
| #include "analyzer/analyzer.h" | #include "analyzer/analyzer.h" | ||||
| #include "graph/common/ge_call_wrapper.h" | |||||
| #include "graph/common/local_context.h" | |||||
| #include "graph/common/transop_util.h" | |||||
| #include "common/ge_call_wrapper.h" | |||||
| #include "common/local_context.h" | |||||
| #include "common/transop_util.h" | |||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| #include "graph/ge_global_options.h" | #include "graph/ge_global_options.h" | ||||
| #include "graph/manager/util/rt_context_util.h" | #include "graph/manager/util/rt_context_util.h" | ||||
| @@ -103,8 +103,8 @@ | |||||
| #include "inc/pass_manager.h" | #include "inc/pass_manager.h" | ||||
| #include "init/gelib.h" | #include "init/gelib.h" | ||||
| #include "ir_build/option_utils.h" | #include "ir_build/option_utils.h" | ||||
| #include "graph/common/local_context.h" | |||||
| #include "graph/common/omg_util.h" | |||||
| #include "common/local_context.h" | |||||
| #include "common/omg_util.h" | |||||
| #include "common/formats/utils/formats_trans_utils.h" | #include "common/formats/utils/formats_trans_utils.h" | ||||
| #include "register/custom_pass_helper.h" | #include "register/custom_pass_helper.h" | ||||
| #include "external/graph/types.h" | #include "external/graph/types.h" | ||||
| @@ -248,7 +248,6 @@ Status GraphManager::Finalize() { | |||||
| Analyzer::GetInstance()->DestroyGraphJsonObject(session_id, graph_id); | Analyzer::GetInstance()->DestroyGraphJsonObject(session_id, graph_id); | ||||
| } | } | ||||
| graph_map_.clear(); | graph_map_.clear(); | ||||
| cache_helper_map_.clear(); | |||||
| graph_count_.clear(); | graph_count_.clear(); | ||||
| // graph context | // graph context | ||||
| @@ -1005,13 +1004,6 @@ Status GraphManager::PreRun(const GraphNodePtr &graph_node, const std::vector<Ge | |||||
| } | } | ||||
| } | } | ||||
| ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); | |||||
| // when set incre build, save om model and var manager | |||||
| GeModelPtr ge_model = nullptr; | |||||
| auto save_ret = SaveCacheAfterBuild(graph_node->GetGraphId(), compute_graph, ge_model); | |||||
| if (save_ret != SUCCESS) { | |||||
| GELOGW("Fail to save cache."); | |||||
| } | |||||
| GEEVENT("[GEPERFTRACE] GE PreRun End"); | GEEVENT("[GEPERFTRACE] GE PreRun End"); | ||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| @@ -1063,18 +1055,15 @@ Status GraphManager::StartForRunGraph(const GraphNodePtr &graph_node, const std: | |||||
| graph_node->GetGraphId()); | graph_node->GetGraphId()); | ||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| GeModelPtr ge_model = nullptr; | |||||
| // check need incre build. | |||||
| ret = IncreBuild(graph_node, ge_model); | |||||
| ret = PreRun(graph_node, inputs, ge_root_model, session_id); | |||||
| // release rts generate context | |||||
| RtContextUtil::GetInstance().DestroyRtContexts(session_id, graph_node->GetGraphId()); | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| ret = PreRun(graph_node, inputs, ge_root_model, session_id); | |||||
| // release rts generate context | |||||
| RtContextUtil::GetInstance().DestroyRtContexts(session_id, graph_node->GetGraphId()); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Call][PreRun] Failed, graph_id:%u, session_id:%lu.", graph_node->GetGraphId(), session_id); | |||||
| return ret; | |||||
| } | |||||
| GELOGE(ret, "[Call][PreRun] Failed, graph_id:%u, session_id:%lu.", graph_node->GetGraphId(), session_id); | |||||
| return ret; | |||||
| } | } | ||||
| ret = LoadGraph(ge_root_model, graph_node); | ret = LoadGraph(ge_root_model, graph_node); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "[Load][Graph] Failed, graph_id:%u.", graph_node->GetGraphId()); | GELOGE(ret, "[Load][Graph] Failed, graph_id:%u.", graph_node->GetGraphId()); | ||||
| @@ -1104,91 +1093,6 @@ Status GraphManager::LoadGraph(const GeRootModelPtr &ge_root_model, const GraphN | |||||
| return executor_->LoadGraph(ge_root_model, graph_node); | return executor_->LoadGraph(ge_root_model, graph_node); | ||||
| } | } | ||||
| Status GraphManager::LoadFromCache(const GraphNodePtr &graph_node, const ModelCacheHelperPtr &cache_helper, | |||||
| GeModelPtr &ge_model) { | |||||
| auto graph_id = graph_node->GetGraphId(); | |||||
| auto ret = cache_helper->LoadOmModelFromCache(ge_model); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGW("Fail to load om model from cache."); | |||||
| if (cache_helper->ClearCache(graph_id) != SUCCESS) { | |||||
| GELOGW("Fail to clear cache of graph %u.", graph_id); | |||||
| } | |||||
| return FAILED; | |||||
| } | |||||
| ret = cache_helper->RecoverVarManagerFromCache(); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGW("Fail to recover VarManager from cache."); | |||||
| if (cache_helper->ClearCache(graph_id) != SUCCESS) { | |||||
| GELOGW("Fail to clear cache of graph %u.", graph_id); | |||||
| } | |||||
| return FAILED; | |||||
| } | |||||
| ComputeGraphPtr compute_graph_in_model = GraphUtils::GetComputeGraph(ge_model->GetGraph()); | |||||
| if (compute_graph_in_model == nullptr) { | |||||
| GELOGW("Error occurred when get compute graph from om, abandon."); | |||||
| return FAILED; | |||||
| } else { | |||||
| graph_node->SetComputeGraph(compute_graph_in_model); | |||||
| graph_node->SetGeModel(ge_model); | |||||
| GELOGI("Load model and graph form cache om file."); | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| Status GraphManager::SaveCacheBeforeBuild(uint32_t graph_id, const ModelCacheHelperPtr &cache_helper) { | |||||
| auto ret = cache_helper->SaveCacheInfoToCache(); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGW("Fail to save cache info of graph[%d] to cache.", graph_id); | |||||
| return FAILED; | |||||
| } | |||||
| ret = cache_helper->SaveVarManagerToCache(true); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGW("Fail to save var manager to cache."); | |||||
| cache_helper->ClearCache(graph_id); | |||||
| return FAILED; | |||||
| } | |||||
| GELOGI("Cache files have been saved."); | |||||
| return SUCCESS; | |||||
| } | |||||
| Status GraphManager::SaveCacheAfterBuild(uint32_t graph_id, ge::ComputeGraphPtr graph, GeModelPtr &ge_model) { | |||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||||
| if ((instance_ptr == nullptr) || !instance_ptr->InitFlag()) { | |||||
| GELOGW("GELib not initialized."); | |||||
| return FAILED; | |||||
| } | |||||
| if (instance_ptr->IsIncreBuild()) { | |||||
| std::lock_guard<std::mutex> lock(member_mutex_); | |||||
| auto iter = cache_helper_map_.find(graph_id); | |||||
| if (iter == cache_helper_map_.end()) { | |||||
| GELOGW("Can not find ModelCacheHelper of graph[%u]", graph_id); | |||||
| return FAILED; | |||||
| } else { | |||||
| ModelCacheHelperPtr cache_helper = iter->second; | |||||
| auto ret = cache_helper->RefreshComputeGraph(graph); | |||||
| if (ret != SUCCESS) { | |||||
| cache_helper->ClearCache(graph_id); | |||||
| GELOGW("Fail to refresh cache helper's compute graph"); | |||||
| return FAILED; | |||||
| } | |||||
| ret = cache_helper->SaveVarManagerToCache(false); | |||||
| if (ret != SUCCESS) { | |||||
| cache_helper->ClearCache(graph_id); | |||||
| GELOGW("Fail to save VarManager to cache"); | |||||
| return FAILED; | |||||
| } | |||||
| ret = cache_helper->SaveOmModelToCache(ge_model); | |||||
| if (ret != SUCCESS) { | |||||
| cache_helper->ClearCache(graph_id); | |||||
| GELOGW("Fail to save om model to cache"); | |||||
| return FAILED; | |||||
| } | |||||
| } | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| Status GraphManager::InnerRunGraph(GraphNodePtr &graph_node, const GraphId &graph_id, | Status GraphManager::InnerRunGraph(GraphNodePtr &graph_node, const GraphId &graph_id, | ||||
| const std::vector<GeTensor> &inputs, std::vector<GeTensor> &outputs) { | const std::vector<GeTensor> &inputs, std::vector<GeTensor> &outputs) { | ||||
| GE_CHECK_NOTNULL(executor_); | GE_CHECK_NOTNULL(executor_); | ||||
| @@ -1239,8 +1143,6 @@ Status GraphManager::RunGraphWithStreamAsync(const GraphId &graph_id, rtStream_t | |||||
| graph_node->SetIsSpecificStream(true); | graph_node->SetIsSpecificStream(true); | ||||
| ComputeGraphPtr compute_graph_tmp = GraphUtils::GetComputeGraph(*(graph_node->GetGraph())); | ComputeGraphPtr compute_graph_tmp = GraphUtils::GetComputeGraph(*(graph_node->GetGraph())); | ||||
| // when set incre build, add cache helper map | |||||
| AddModelCacheHelperToMap(graph_id, session_id, compute_graph_tmp); | |||||
| if (options_.local_fmk_op_flag) { | if (options_.local_fmk_op_flag) { | ||||
| GetCompilerStages(graph_id).optimizer.TranFrameOp(compute_graph_tmp); | GetCompilerStages(graph_id).optimizer.TranFrameOp(compute_graph_tmp); | ||||
| } | } | ||||
| @@ -1299,9 +1201,6 @@ Status GraphManager::RunGraph(const GraphId &graph_id, const std::vector<GeTenso | |||||
| "compute_graph_tmp is NULL, graph id = %u.", graph_id); | "compute_graph_tmp is NULL, graph id = %u.", graph_id); | ||||
| return GE_GRAPH_GRAPH_NODE_NULL;)) | return GE_GRAPH_GRAPH_NODE_NULL;)) | ||||
| // when set incre build, add cache helper map | |||||
| AddModelCacheHelperToMap(graph_id, session_id, compute_graph_tmp); | |||||
| if (options_.local_fmk_op_flag) { | if (options_.local_fmk_op_flag) { | ||||
| GetCompilerStages(graph_id).optimizer.TranFrameOp(compute_graph_tmp); | GetCompilerStages(graph_id).optimizer.TranFrameOp(compute_graph_tmp); | ||||
| } | } | ||||
| @@ -1482,8 +1381,8 @@ Status GraphManager::BuildGraph(const GraphId &graph_id, const std::vector<GeTen | |||||
| ret = StartForRunGraph(graph_node, inputs, ge_root_model, session_id); | ret = StartForRunGraph(graph_node, inputs, ge_root_model, session_id); | ||||
| graph_node->SetRunFlag(false); | graph_node->SetRunFlag(false); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(GE_GRAPH_PRERUN_FAILED, "[Call][StartForRunGraph] failed! graph_id:%u.", graph_id); | |||||
| return GE_GRAPH_PRERUN_FAILED; | |||||
| GELOGE(ret, "[Call][StartForRunGraph] failed! graph_id:%u.", graph_id); | |||||
| return ret; | |||||
| } | } | ||||
| GELOGI("[BuildGraph] build graph success, graph_id=%u.", graph_id); | GELOGI("[BuildGraph] build graph success, graph_id=%u.", graph_id); | ||||
| @@ -1518,16 +1417,6 @@ Status GraphManager::SaveParams(ge::GeModel &model, const std::string &type, con | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| void GraphManager::RemoveModelCacheHelper(const GraphId &graph_id) { | |||||
| std::lock_guard<std::mutex> lock(member_mutex_); | |||||
| auto iter = cache_helper_map_.find(graph_id); | |||||
| if (iter != cache_helper_map_.end()) { | |||||
| cache_helper_map_.erase(iter); | |||||
| } else { | |||||
| GELOGW("[GraphManager] cache helper does not exist, graph_id = %u", graph_id); | |||||
| } | |||||
| } | |||||
| bool GraphManager::CheckModelLoad(const GeRootModelPtr &ge_root_model, bool load_flag) { | bool GraphManager::CheckModelLoad(const GeRootModelPtr &ge_root_model, bool load_flag) { | ||||
| return ((ge_root_model != nullptr) && (ge_root_model->GetModelId() != INVALID_MODEL_ID) && load_flag); | return ((ge_root_model != nullptr) && (ge_root_model->GetModelId() != INVALID_MODEL_ID) && load_flag); | ||||
| } | } | ||||
| @@ -1555,7 +1444,6 @@ Status GraphManager::RemoveGraph(const GraphId &graph_id) { | |||||
| var_acc_ctrl_.RemoveGraph(graph_id); | var_acc_ctrl_.RemoveGraph(graph_id); | ||||
| RemoveGraphNode(graph_id); | RemoveGraphNode(graph_id); | ||||
| RemoveModelCacheHelper(graph_id); | |||||
| auto ge_root_model = graph_node->GetGeRootModel(); | auto ge_root_model = graph_node->GetGeRootModel(); | ||||
| if (CheckModelLoad(ge_root_model, graph_node->GetLoadFlag())) { | if (CheckModelLoad(ge_root_model, graph_node->GetLoadFlag())) { | ||||
| @@ -2727,61 +2615,6 @@ Status GraphManager::RunGraphAsync(const GraphId &graph_id, const std::vector<ge | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| void GraphManager::AddModelCacheHelperToMap(const GraphId &graph_id, uint64_t session_id, | |||||
| ComputeGraphPtr &compute_graph) { | |||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||||
| if (instance_ptr != nullptr && instance_ptr->IsIncreBuild()) { | |||||
| std::lock_guard<std::mutex> lock(member_mutex_); | |||||
| auto iter = cache_helper_map_.find(graph_id); | |||||
| if (iter == cache_helper_map_.end()) { | |||||
| ModelCacheHelperPtr cache_helper = MakeShared<ge::ModelCacheHelper>(session_id, graph_id, compute_graph); | |||||
| if (cache_helper != nullptr) { | |||||
| cache_helper_map_.emplace(std::make_pair(graph_id, cache_helper)); | |||||
| } else { | |||||
| GELOGW("Cache helper make shared failed, graph_id = %u.", graph_id); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| ModelCacheHelperPtr GraphManager::FindModelCacheHelper(GraphId graph_id) { | |||||
| std::lock_guard<std::mutex> lock(member_mutex_); | |||||
| auto iter = cache_helper_map_.find(graph_id); | |||||
| if (iter != cache_helper_map_.end()) { | |||||
| return iter->second; | |||||
| } | |||||
| return nullptr; | |||||
| } | |||||
| Status GraphManager::IncreBuild(const GraphNodePtr &graph_node, GeModelPtr &ge_model) { | |||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||||
| if (instance_ptr == nullptr || !instance_ptr->IsIncreBuild()) { | |||||
| return FAILED; | |||||
| } | |||||
| const uint32_t graph_id = graph_node->GetGraphId(); | |||||
| ModelCacheHelperPtr cache_helper = FindModelCacheHelper(graph_id); | |||||
| if (cache_helper == nullptr) { | |||||
| GELOGW("Can not find ModelCacheHelper of graph[%u]", graph_id); | |||||
| return FAILED; | |||||
| } | |||||
| if (cache_helper->IsModelCacheHit()) { | |||||
| GEEVENT("Model cache hit."); | |||||
| Status ret = LoadFromCache(graph_node, cache_helper, ge_model); | |||||
| if (ret == SUCCESS) { | |||||
| return SUCCESS; | |||||
| } else { | |||||
| GELOGW("Error occurred when load from cache, abandon."); | |||||
| } | |||||
| } else { | |||||
| GEEVENT("Model cache miss."); | |||||
| } | |||||
| if (SaveCacheBeforeBuild(graph_node->GetGraphId(), cache_helper) != SUCCESS) { | |||||
| GELOGW("Error occurred when save cache."); | |||||
| } | |||||
| return FAILED; | |||||
| } | |||||
| Status GraphManager::CheckIncreBuildAndPreRun(const PreRunArgs &args, | Status GraphManager::CheckIncreBuildAndPreRun(const PreRunArgs &args, | ||||
| GraphNodePtr &graph_node, GeRootModelPtr &ge_root_model) { | GraphNodePtr &graph_node, GeRootModelPtr &ge_root_model) { | ||||
| if (!IsGraphNeedBuild(graph_node)) { | if (!IsGraphNeedBuild(graph_node)) { | ||||
| @@ -2796,20 +2629,18 @@ Status GraphManager::CheckIncreBuildAndPreRun(const PreRunArgs &args, | |||||
| return PARAM_INVALID; | return PARAM_INVALID; | ||||
| } | } | ||||
| // check need incre build. | // check need incre build. | ||||
| GeModelPtr ge_model = nullptr; | |||||
| if (IncreBuild(graph_node, ge_model) != SUCCESS) { | |||||
| std::vector<GeTensor> ge_inputs; | |||||
| for (const auto &item: args.input_tensor) { | |||||
| ge_inputs.emplace_back(TensorAdapter::AsGeTensor(item)); | |||||
| } | |||||
| Status ret = PreRun(graph_node, ge_inputs, ge_root_model, args.session_id); | |||||
| // release rts generate context | |||||
| RtContextUtil::GetInstance().DestroyRtContexts(args.session_id, graph_node->GetGraphId()); | |||||
| if (ret != SUCCESS) { | |||||
| ReturnError(args.callback, ret, "PreRun Failed."); | |||||
| return ret; | |||||
| } | |||||
| std::vector<GeTensor> ge_inputs; | |||||
| for (const auto &item: args.input_tensor) { | |||||
| ge_inputs.emplace_back(TensorAdapter::AsGeTensor(item)); | |||||
| } | } | ||||
| Status ret = PreRun(graph_node, ge_inputs, ge_root_model, args.session_id); | |||||
| // release rts generate context | |||||
| RtContextUtil::GetInstance().DestroyRtContexts(args.session_id, graph_node->GetGraphId()); | |||||
| if (ret != SUCCESS) { | |||||
| ReturnError(args.callback, ret, "PreRun Failed."); | |||||
| return ret; | |||||
| } | |||||
| graph_node->SetBuildFlag(true); | graph_node->SetBuildFlag(true); | ||||
| var_acc_ctrl_.SetGraphBuildEnd(graph_node->GetGraphId()); | var_acc_ctrl_.SetGraphBuildEnd(graph_node->GetGraphId()); | ||||
| return SUCCESS; | return SUCCESS; | ||||
| @@ -2878,10 +2709,6 @@ void GraphManager::PreRunThread() { | |||||
| graph_node->Unlock(); | graph_node->Unlock(); | ||||
| return; | return; | ||||
| } | } | ||||
| // when set incre build, save cache helper. | |||||
| AddModelCacheHelperToMap(args.graph_id, args.session_id, compute_graph_tmp); | |||||
| std::vector<GeModelPtr> ge_models; | |||||
| if (options_.local_fmk_op_flag) { | if (options_.local_fmk_op_flag) { | ||||
| GetCompilerStages(graph_node->GetGraphId()).optimizer.TranFrameOp(compute_graph_tmp); | GetCompilerStages(graph_node->GetGraphId()).optimizer.TranFrameOp(compute_graph_tmp); | ||||
| @@ -27,7 +27,6 @@ | |||||
| #include "common/blocking_queue.h" | #include "common/blocking_queue.h" | ||||
| #include "framework/common/ge_inner_error_codes.h" | #include "framework/common/ge_inner_error_codes.h" | ||||
| #include "common/helper/model_cache_helper.h" | |||||
| #include "external/graph/types.h" | #include "external/graph/types.h" | ||||
| #include "external/ge/ge_api_types.h" | #include "external/ge/ge_api_types.h" | ||||
| #include "graph/build/graph_builder.h" | #include "graph/build/graph_builder.h" | ||||
| @@ -38,7 +37,7 @@ | |||||
| #include "graph/partition/graph_partition.h" | #include "graph/partition/graph_partition.h" | ||||
| #include "graph/preprocess/graph_preprocess.h" | #include "graph/preprocess/graph_preprocess.h" | ||||
| #include "graph/tuning_utils.h" | #include "graph/tuning_utils.h" | ||||
| #include "model/ge_model.h" | |||||
| #include "common/model/ge_model.h" | |||||
| #include "common/executor.h" | #include "common/executor.h" | ||||
| namespace ge { | namespace ge { | ||||
| @@ -339,14 +338,6 @@ class GraphManager { | |||||
| bool IsGraphNeedBuild(const GraphNodePtr &graph_node); | bool IsGraphNeedBuild(const GraphNodePtr &graph_node); | ||||
| Status LoadFromCache(const GraphNodePtr &graph_node, const ModelCacheHelperPtr &cache_helper, GeModelPtr &ge_model); | |||||
| Status SaveCacheBeforeBuild(uint32_t graph_id, const ModelCacheHelperPtr &cache_helper); | |||||
| Status SaveCacheAfterBuild(uint32_t graph_id, ComputeGraphPtr graph, GeModelPtr &ge_model); | |||||
| void AddModelCacheHelperToMap(const GraphId &graph_id, uint64_t session_id, ComputeGraphPtr &compute_graph); | |||||
| Status IncreBuild(const GraphNodePtr &graph_node, GeModelPtr &ge_model); | |||||
| void RemoveModelCacheHelper(const GraphId &graph_id); | |||||
| ModelCacheHelperPtr FindModelCacheHelper(GraphId graph_id); | |||||
| void SetRunContext(const GraphNodePtr &graph_node); | void SetRunContext(const GraphNodePtr &graph_node); | ||||
| void PushGraph(const RunArgs &args); | void PushGraph(const RunArgs &args); | ||||
| @@ -411,7 +402,6 @@ class GraphManager { | |||||
| std::thread prerun_thread_; | std::thread prerun_thread_; | ||||
| ComputeGraphPtr compute_graph_; | ComputeGraphPtr compute_graph_; | ||||
| std::map<GraphId, GraphNodePtr> graph_map_; | std::map<GraphId, GraphNodePtr> graph_map_; | ||||
| std::map<GraphId, ModelCacheHelperPtr> cache_helper_map_; | |||||
| // summary and checkpoint callback function list for ME, key is summary or checkpoint | // summary and checkpoint callback function list for ME, key is summary or checkpoint | ||||
| std::map<std::string, std::function<Status(uint32_t, const std::map<std::string, ge::Tensor> &)>> me_callback_map_; | std::map<std::string, std::function<Status(uint32_t, const std::map<std::string, ge::Tensor> &)>> me_callback_map_; | ||||
| @@ -70,45 +70,9 @@ void GraphNode::IncreaseLoadCount() { | |||||
| ++load_count_; | ++load_count_; | ||||
| } | } | ||||
| SubGraphInfo::SubGraphInfo() : subgraph_ptr_(nullptr), ge_model_ptr_(nullptr), malloc_flag_(false) {} | |||||
| SubGraphInfo::SubGraphInfo() : subgraph_ptr_(nullptr), ge_model_ptr_(nullptr) {} | |||||
| SubGraphInfo::~SubGraphInfo() { | SubGraphInfo::~SubGraphInfo() { | ||||
| if (malloc_flag_) { | |||||
| for (auto &buffer_addr : buffer_addr_) { | |||||
| if (buffer_addr == nullptr) { | |||||
| continue; | |||||
| } | |||||
| rtError_t rt_ret; | |||||
| rt_ret = rtFreeHost(buffer_addr); | |||||
| buffer_addr = nullptr; | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| GELOGE(rt_ret, "[Call][RtFreeHost] subgraph free buffer failed, modelId = %u", | |||||
| model_id_info_.model_id); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| Status SubGraphInfo::FreeInOutBuffer() { | |||||
| if (malloc_flag_) { | |||||
| for (auto iter = buffer_addr_.begin(); iter != buffer_addr_.end(); ++iter) { | |||||
| rtError_t rt_ret; | |||||
| rt_ret = rtFreeHost(*iter); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtFreeHost fail, ret:%d", rt_ret); | |||||
| GELOGE(rt_ret, "[Call][RtFreeHost] subgraph free buffer failed, modelId = %u", model_id_info_.model_id); | |||||
| buffer_addr_.erase(buffer_addr_.begin(), iter); | |||||
| return GE_GRAPH_FREE_FAILED; | |||||
| } | |||||
| } | |||||
| buffer_addr_.clear(); | |||||
| malloc_flag_ = false; | |||||
| return SUCCESS; | |||||
| } else { | |||||
| GELOGI("[GraphManager] not malloc buffer, modelId = %u", model_id_info_.model_id); | |||||
| return SUCCESS; | |||||
| } | |||||
| } | } | ||||
| GraphModelListener::GraphModelListener(std::mutex &mutex, std::condition_variable &cond) | GraphModelListener::GraphModelListener(std::mutex &mutex, std::condition_variable &cond) | ||||
| @@ -33,11 +33,11 @@ | |||||
| #include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
| #include "framework/common/ge_inner_error_codes.h" | #include "framework/common/ge_inner_error_codes.h" | ||||
| #include "graph/compute_graph.h" | #include "graph/compute_graph.h" | ||||
| #include "graph/common/local_context.h" | |||||
| #include "common/local_context.h" | |||||
| #include "external/graph/graph.h" | #include "external/graph/graph.h" | ||||
| #include "graph/model.h" | #include "graph/model.h" | ||||
| #include "model/ge_model.h" | |||||
| #include "model/ge_root_model.h" | |||||
| #include "common/model/ge_model.h" | |||||
| #include "common/model/ge_root_model.h" | |||||
| #include "external/register/register_fmk_types.h" | #include "external/register/register_fmk_types.h" | ||||
| #include "external/ge/ge_api_types.h" | #include "external/ge/ge_api_types.h" | ||||
| @@ -86,8 +86,6 @@ class SubGraphInfo { | |||||
| void SetGeModelPtr(const GeModelPtr &ge_model_ptr) { ge_model_ptr_ = ge_model_ptr; } | void SetGeModelPtr(const GeModelPtr &ge_model_ptr) { ge_model_ptr_ = ge_model_ptr; } | ||||
| bool GeModelIsValid() const { return ge_model_ptr_ != nullptr; } | bool GeModelIsValid() const { return ge_model_ptr_ != nullptr; } | ||||
| Status FreeInOutBuffer(); | |||||
| void SetOutputContext(const std::string &output) { output_names_ = output; } | void SetOutputContext(const std::string &output) { output_names_ = output; } | ||||
| std::string GetOutputContext() const { return output_names_; } | std::string GetOutputContext() const { return output_names_; } | ||||
| @@ -107,10 +105,7 @@ class SubGraphInfo { | |||||
| std::vector<bool> output_flag_; | std::vector<bool> output_flag_; | ||||
| ModelIdInfo model_id_info_; | ModelIdInfo model_id_info_; | ||||
| GeModelPtr ge_model_ptr_; | GeModelPtr ge_model_ptr_; | ||||
| bool malloc_flag_; | |||||
| std::vector<void *> buffer_addr_; | |||||
| std::string output_names_; | std::string output_names_; | ||||
| std::vector<uint32_t> buffer_size_; | |||||
| std::string stream_label_; | std::string stream_label_; | ||||
| std::unordered_map<ge::NodePtr, ge::NodePtr> end_to_pld_; | std::unordered_map<ge::NodePtr, ge::NodePtr> end_to_pld_; | ||||
| std::unordered_map<ge::NodePtr, ge::NodePtr> pld_to_end_; | std::unordered_map<ge::NodePtr, ge::NodePtr> pld_to_end_; | ||||
| @@ -20,6 +20,7 @@ | |||||
| #include "graph/manager/graph_mem_manager.h" | #include "graph/manager/graph_mem_manager.h" | ||||
| #include "graph/manager/trans_var_data_utils.h" | #include "graph/manager/trans_var_data_utils.h" | ||||
| #include "graph/utils/type_utils.h" | #include "graph/utils/type_utils.h" | ||||
| #include "graph/ge_context.h" | |||||
| using std::map; | using std::map; | ||||
| using std::string; | using std::string; | ||||
| @@ -428,10 +429,6 @@ ge::Status VarManager::GetVarAddr(const std::string &var_name, const ge::GeTenso | |||||
| return GetVarAddr(var_name, tensor_desc, dev_ptr, memory_type); | return GetVarAddr(var_name, tensor_desc, dev_ptr, memory_type); | ||||
| } | } | ||||
| void VarManager::GetAllVarAddrMgr(std::unordered_map<std::string, VarAddrMgr> &var_addr_mgr_map) { | |||||
| var_resource_->GetAllVarAddrMgr(var_addr_mgr_map); | |||||
| } | |||||
| int64_t VarManager::GetVarMemSize(rtMemType_t memory_type) { | int64_t VarManager::GetVarMemSize(rtMemType_t memory_type) { | ||||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | std::lock_guard<std::recursive_mutex> lock(mutex_); | ||||
| MemResource *mem_resource = nullptr; | MemResource *mem_resource = nullptr; | ||||
| @@ -452,36 +449,6 @@ int64_t VarManager::GetVarMemSize(rtMemType_t memory_type) { | |||||
| return mem_resource->GetVarMemSize(); | return mem_resource->GetVarMemSize(); | ||||
| } | } | ||||
| Status VarManager::UpdateVarMemSize(rtMemType_t memory_type, int64_t mem_size) { | |||||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | |||||
| MemResource *mem_resource = nullptr; | |||||
| auto iter = mem_resource_map_.find(memory_type); | |||||
| if (iter == mem_resource_map_.end()) { | |||||
| mem_resource = MemResource::BuildMemResourceFromType(memory_type); | |||||
| if (mem_resource == nullptr) { | |||||
| REPORT_CALL_ERROR("E19999", "memory_type:%d invalid or New MemResource fail, session_id:%lu", | |||||
| memory_type, session_id_); | |||||
| GELOGE(ge::INTERNAL_ERROR, "[Alloc][MemResource] failed, memory_type:%u, session_id:%lu", | |||||
| memory_type, session_id_); | |||||
| return ge::INTERNAL_ERROR; | |||||
| } else { | |||||
| mem_resource_map_[memory_type] = mem_resource; | |||||
| } | |||||
| } else { | |||||
| mem_resource = iter->second; | |||||
| } | |||||
| if (mem_resource == nullptr) { | |||||
| REPORT_INNER_ERROR("E19999", "MemResource is invalid, memory_type:%d, session_id:%lu", | |||||
| memory_type, session_id_); | |||||
| GELOGE(ge::INTERNAL_ERROR, "[Check][Param] MemResource is invalid, memory_type:%u, session_id:%lu", | |||||
| memory_type, session_id_); | |||||
| return FAILED; | |||||
| } | |||||
| mem_resource->UpdateVarMemSize(mem_size); | |||||
| return SUCCESS; | |||||
| } | |||||
| ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTensorDesc &tensor_desc, | ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTensorDesc &tensor_desc, | ||||
| rtMemType_t memory_type) { | rtMemType_t memory_type) { | ||||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | std::lock_guard<std::recursive_mutex> lock(mutex_); | ||||
| @@ -637,16 +604,6 @@ ge::Status VarManager::SaveBroadCastInfo(uint32_t graph_id, const VarBroadCastIn | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| ge::Status VarManager::GetBroadCastInfo(uint32_t graph_id, const string &var_name, VarBroadCastInfo &broad_cast_info) { | |||||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | |||||
| if (var_resource_ == nullptr) { | |||||
| GELOGW("VarManager has not been init."); | |||||
| return ge::INTERNAL_ERROR; | |||||
| } | |||||
| return var_resource_->GetBroadCastInfo(graph_id, var_name, broad_cast_info); | |||||
| } | |||||
| ge::Status VarManager::RenewCurVarDesc(const std::string &var_name, ge::OpDescPtr op_desc) { | ge::Status VarManager::RenewCurVarDesc(const std::string &var_name, ge::OpDescPtr op_desc) { | ||||
| std::lock_guard<std::recursive_mutex> lock(mutex_); | std::lock_guard<std::recursive_mutex> lock(mutex_); | ||||
| GELOGD("VarManager::RenewCurVarDesc var_name = %s.", var_name.c_str()); | GELOGD("VarManager::RenewCurVarDesc var_name = %s.", var_name.c_str()); | ||||
| @@ -767,25 +724,52 @@ Status VarManager::GetChangedGraphId(const std::string &var_name, uint32_t &grap | |||||
| return var_resource_->GetChangedGraphId(var_name, graph_id); | return var_resource_->GetChangedGraphId(var_name, graph_id); | ||||
| } | } | ||||
| Status VarManager::GetTotalMemorySize(size_t &total_mem_size) { | |||||
| rtError_t rt_ret = rtSetDevice(GetContext().DeviceId()); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtSetDevice failed, device_id:%u, ret:0x%X", | |||||
| GetContext().DeviceId(), rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][RtSetDevice] failed, device_id:%u, ret:0x%X", GetContext().DeviceId(), rt_ret); | |||||
| return RT_FAILED; | |||||
| } | |||||
| size_t free_mem = 0; | |||||
| rt_ret = rtMemGetInfoEx(RT_MEMORYINFO_HBM, &free_mem, &total_mem_size); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtMemGetInfo failed, ret:0x%X", rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][RtMemGetInfo] failed, ret:0x%X", rt_ret); | |||||
| return RT_FAILED; | |||||
| } | |||||
| rt_ret = rtDeviceReset(GetContext().DeviceId()); | |||||
| if (rt_ret != RT_ERROR_NONE) { | |||||
| REPORT_CALL_ERROR("E19999", "Call rtDeviceReset failed, device_id:%u, ret:0x%X", | |||||
| GetContext().DeviceId(), rt_ret); | |||||
| GELOGE(RT_FAILED, "[Call][RtDeviceReset] failed, device_id:%u, ret:0x%X", GetContext().DeviceId(), rt_ret); | |||||
| return RT_FAILED; | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| Status VarManager::SetMemoryMallocSize(const map<string, string> &options) { | Status VarManager::SetMemoryMallocSize(const map<string, string> &options) { | ||||
| auto it = options.find(GRAPH_MEMORY_MAX_SIZE); | |||||
| if (it == options.end()) { | |||||
| graph_mem_max_size_ = kGraphMemoryManagerMallocMaxSize; | |||||
| } else { | |||||
| string graph_memory_manager_malloc_max_size = it->second; | |||||
| size_t total_mem_size = 0; | |||||
| GE_CHK_STATUS_RET_NOLOG(VarManager::GetTotalMemorySize(total_mem_size)); | |||||
| GEEVENT("Total memory size is %zu", total_mem_size); | |||||
| graph_mem_max_size_ = floor(total_mem_size * kGraphMemoryManagerMallocRatio); | |||||
| var_mem_max_size_ = floor(total_mem_size * kVarMemoryManagerMallocRatio); | |||||
| auto it1 = options.find(GRAPH_MEMORY_MAX_SIZE); | |||||
| if (it1 != options.end()) { | |||||
| string graph_memory_manager_malloc_max_size = it1->second; | |||||
| ge::Status ret = ParseMemoryMallocSize(graph_memory_manager_malloc_max_size, graph_mem_max_size_); | ge::Status ret = ParseMemoryMallocSize(graph_memory_manager_malloc_max_size, graph_mem_max_size_); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "[Call][ParseMemoryMallocSize] failed, session id:%lu.", session_id_); | GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "[Call][ParseMemoryMallocSize] failed, session id:%lu.", session_id_); | ||||
| return ge::GE_GRAPH_OPTIONS_INVALID; | return ge::GE_GRAPH_OPTIONS_INVALID; | ||||
| } | } | ||||
| GELOGI("The max size for graph mem is set to %zu", graph_mem_max_size_); | |||||
| } | } | ||||
| it = options.find(VARIABLE_MEMORY_MAX_SIZE); | |||||
| if (it == options.end()) { | |||||
| var_mem_max_size_ = kMemoryVarManagerMallocSize; | |||||
| } else { | |||||
| string memory_var_manager_malloc_size = it->second; | |||||
| auto it2 = options.find(VARIABLE_MEMORY_MAX_SIZE); | |||||
| if (it2 != options.end()) { | |||||
| string memory_var_manager_malloc_size = it2->second; | |||||
| ge::Status ret = ParseMemoryMallocSize(memory_var_manager_malloc_size, var_mem_max_size_); | ge::Status ret = ParseMemoryMallocSize(memory_var_manager_malloc_size, var_mem_max_size_); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "[Call][ParseMemoryMallocSize] failed, session id:%lu.", session_id_); | GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "[Call][ParseMemoryMallocSize] failed, session id:%lu.", session_id_); | ||||
| @@ -793,6 +777,8 @@ Status VarManager::SetMemoryMallocSize(const map<string, string> &options) { | |||||
| } | } | ||||
| } | } | ||||
| GEEVENT("The graph_mem_max_size is %zu and the var_mem_max_size is %zu", graph_mem_max_size_, var_mem_max_size_); | |||||
| var_mem_logic_base_ = graph_mem_max_size_ + kGraphMemoryBuffer; | var_mem_logic_base_ = graph_mem_max_size_ + kGraphMemoryBuffer; | ||||
| if (var_mem_logic_base_ > kMaxMemorySize) { | if (var_mem_logic_base_ > kMaxMemorySize) { | ||||
| REPORT_INNER_ERROR("E19999", "var_login_base:%zu can not exeed limit:%zu, session_id:%lu, check invalid", | REPORT_INNER_ERROR("E19999", "var_login_base:%zu can not exeed limit:%zu, session_id:%lu, check invalid", | ||||
| @@ -43,6 +43,8 @@ const size_t kMaxMemorySize = 256UL * 1024UL * 1024UL * 1024UL; | |||||
| const char kEnvGeuseStaticMemory[] = "GE_USE_STATIC_MEMORY"; | const char kEnvGeuseStaticMemory[] = "GE_USE_STATIC_MEMORY"; | ||||
| const uint64_t kSessionMemAlignSize = 512; | const uint64_t kSessionMemAlignSize = 512; | ||||
| const size_t kSessionMemAlignUnit = 2; | const size_t kSessionMemAlignUnit = 2; | ||||
| const double kGraphMemoryManagerMallocRatio = 26.0 / 32.0; | |||||
| const double kVarMemoryManagerMallocRatio = 5.0 / 32.0; | |||||
| enum MemStatus { | enum MemStatus { | ||||
| NORMAL = 0, | NORMAL = 0, | ||||
| @@ -221,14 +223,10 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY VarManager { | |||||
| ge::Status GetVarAddr(const std::string &var_name, const ge::GeTensorDesc &tensor_desc, uint8_t **dev_ptr, | ge::Status GetVarAddr(const std::string &var_name, const ge::GeTensorDesc &tensor_desc, uint8_t **dev_ptr, | ||||
| rtMemType_t &memory_type); | rtMemType_t &memory_type); | ||||
| void GetAllVarAddrMgr(std::unordered_map<std::string, VarAddrMgr> &var_addr_mgr_map); | |||||
| ge::Status GetVarAddr(const std::string &var_name, const ge::GeTensorDesc &tensor_desc, uint8_t **dev_ptr); | ge::Status GetVarAddr(const std::string &var_name, const ge::GeTensorDesc &tensor_desc, uint8_t **dev_ptr); | ||||
| ge::Status SaveBroadCastInfo(uint32_t graph_id, const VarBroadCastInfo &broad_cast_info); | ge::Status SaveBroadCastInfo(uint32_t graph_id, const VarBroadCastInfo &broad_cast_info); | ||||
| ge::Status GetBroadCastInfo(uint32_t graph_id, const string &var_name, VarBroadCastInfo &broad_cast_info); | |||||
| ge::Status GetCurVarDesc(const std::string &var_name, ge::GeTensorDesc &tensor_desc); | ge::Status GetCurVarDesc(const std::string &var_name, ge::GeTensorDesc &tensor_desc); | ||||
| ge::Status RenewCurVarDesc(const std::string &var_name, ge::OpDescPtr op_desc); | ge::Status RenewCurVarDesc(const std::string &var_name, ge::OpDescPtr op_desc); | ||||
| @@ -271,8 +269,6 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY VarManager { | |||||
| int64_t GetVarMemSize(rtMemType_t memory_type); | int64_t GetVarMemSize(rtMemType_t memory_type); | ||||
| Status UpdateVarMemSize(rtMemType_t memory_type, int64_t mem_size); | |||||
| bool IsVarExist(const std::string &var_name, const ge::GeTensorDesc &tensor_desc); | bool IsVarExist(const std::string &var_name, const ge::GeTensorDesc &tensor_desc); | ||||
| bool IsVarExist(const std::string &var_name); | bool IsVarExist(const std::string &var_name); | ||||
| @@ -301,6 +297,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY VarManager { | |||||
| mutable std::recursive_mutex mutex_; | mutable std::recursive_mutex mutex_; | ||||
| Status ParseMemoryMallocSize(std::string &memory_size, size_t &my_size); | Status ParseMemoryMallocSize(std::string &memory_size, size_t &my_size); | ||||
| Status GetTotalMemorySize(size_t &total_mem_size); | |||||
| }; | }; | ||||
| class VarManagerPool { | class VarManagerPool { | ||||
| @@ -1,83 +0,0 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #include "graph/manager/model_manager/event_manager.h" | |||||
| #define RETURN_IF_COND_NOT_MET(condition, ...) \ | |||||
| do { \ | |||||
| if (!(condition)) { \ | |||||
| GELOGE(FAILED, __VA_ARGS__); \ | |||||
| return; \ | |||||
| } \ | |||||
| } while (0); | |||||
| namespace ge { | |||||
| Status EventManager::Init(size_t event_num) { | |||||
| if (this->inited_) { | |||||
| return SUCCESS; | |||||
| } | |||||
| rtEvent_t event = nullptr; | |||||
| current_idx_ = 0; | |||||
| for (size_t i = 0; i < event_num; ++i) { | |||||
| GE_CHK_RT_RET(rtEventCreate(&event)); | |||||
| this->event_list_.push_back(event); | |||||
| } | |||||
| this->inited_ = true; | |||||
| return SUCCESS; | |||||
| } | |||||
| void EventManager::Release() noexcept { | |||||
| for (size_t i = 0; i < this->event_list_.size(); ++i) { | |||||
| rtError_t rt_ret = rtEventDestroy(this->event_list_[i]); | |||||
| RETURN_IF_COND_NOT_MET(rt_ret == RT_ERROR_NONE, "[Destroy][Event] failed, idx is %zu, ret is 0x%x.", i, rt_ret); | |||||
| } | |||||
| this->event_list_.clear(); | |||||
| this->inited_ = false; | |||||
| } | |||||
| Status EventManager::EventRecord(size_t event_idx, rtStream_t stream) { | |||||
| GE_CHK_BOOL_RET_STATUS_NOLOG(this->inited_, INTERNAL_ERROR); | |||||
| GE_CHK_BOOL_RET_STATUS_NOLOG(event_idx < this->event_list_.size(), PARAM_INVALID); | |||||
| GE_CHK_RT_RET(rtEventRecord(this->event_list_[event_idx], stream)); | |||||
| current_idx_ = static_cast<uint32_t>(event_idx); | |||||
| return SUCCESS; | |||||
| } | |||||
| Status EventManager::EventElapsedTime(size_t start_event_idx, size_t stop_event_idx, float &time) { | |||||
| GE_CHK_BOOL_RET_STATUS_NOLOG(this->inited_, INTERNAL_ERROR); | |||||
| GE_CHK_BOOL_RET_STATUS_NOLOG(start_event_idx < this->event_list_.size() && | |||||
| stop_event_idx < this->event_list_.size() && start_event_idx <= stop_event_idx, | |||||
| PARAM_INVALID); | |||||
| GE_CHK_RT_RET(rtEventElapsedTime(&time, this->event_list_[start_event_idx], this->event_list_[stop_event_idx])); | |||||
| return SUCCESS; | |||||
| } | |||||
| Status EventManager::GetEvent(uint32_t index, rtEvent_t &event) { | |||||
| GE_CHK_BOOL_RET_STATUS_NOLOG(index < this->event_list_.size(), PARAM_INVALID); | |||||
| event = this->event_list_[index]; | |||||
| return SUCCESS; | |||||
| } | |||||
| } // namespace ge | |||||
| @@ -1,98 +0,0 @@ | |||||
| /** | |||||
| * Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #ifndef GE_GRAPH_MANAGER_MODEL_MANAGER_EVENT_MANAGER_H_ | |||||
| #define GE_GRAPH_MANAGER_MODEL_MANAGER_EVENT_MANAGER_H_ | |||||
| #include <vector> | |||||
| #include "framework/common/fmk_error_codes.h" | |||||
| #include "framework/common/fmk_types.h" | |||||
| #include "framework/common/util.h" | |||||
| #include "runtime/event.h" | |||||
| namespace ge { | |||||
| class EventManager { | |||||
| public: | |||||
| /// | |||||
| /// @ingroup domi_ome | |||||
| /// @brief constructor | |||||
| /// | |||||
| EventManager() : inited_(false), current_idx_(0) {} | |||||
| /// | |||||
| /// @ingroup domi_ome | |||||
| /// @brief destructor | |||||
| /// | |||||
| ~EventManager() { this->Release(); } | |||||
| /// | |||||
| /// @ingroup domi_ome | |||||
| /// @brief init and create event list | |||||
| /// @param [in] event_num event number created | |||||
| /// @return exec result | |||||
| /// | |||||
| Status Init(size_t event_num); | |||||
| /// | |||||
| /// @ingroup domi_ome | |||||
| /// @brief event record | |||||
| /// @param [in] event_idx event index | |||||
| /// @param [in] stream related stream | |||||
| /// @return exec result | |||||
| /// | |||||
| Status EventRecord(size_t event_idx, rtStream_t stream); | |||||
| /// | |||||
| /// @ingroup domi_ome | |||||
| /// @brief time between start and end in ms | |||||
| /// @param [in] start_event_idx start event index | |||||
| /// @param [in] stop_event_idx stop event index | |||||
| /// @param [out] time | |||||
| /// @return exec result | |||||
| /// | |||||
| Status EventElapsedTime(size_t start_event_idx, size_t stop_event_idx, float &time); | |||||
| /// | |||||
| /// @ingroup domi_ome | |||||
| /// @brief current event index | |||||
| /// @return | |||||
| /// | |||||
| uint32_t CurrentIdx() const { return current_idx_; } | |||||
| /// | |||||
| /// @ingroup domi_ome | |||||
| /// @brief get event at specific loc | |||||
| /// @param [in] index event index | |||||
| /// @return | |||||
| /// | |||||
| Status GetEvent(uint32_t index, rtEvent_t &event); | |||||
| /// | |||||
| /// @ingroup domi_ome | |||||
| /// @brief release event list | |||||
| /// @param [in] | |||||
| /// @return | |||||
| /// | |||||
| void Release() noexcept; | |||||
| private: | |||||
| std::vector<rtEvent_t> event_list_; | |||||
| bool inited_; | |||||
| uint32_t current_idx_; | |||||
| }; // EventManager | |||||
| } // namespace ge | |||||
| #endif // GE_GRAPH_MANAGER_MODEL_MANAGER_EVENT_MANAGER_H_ | |||||
| @@ -24,7 +24,6 @@ | |||||
| #include "graph/utils/tensor_utils.h" | #include "graph/utils/tensor_utils.h" | ||||
| #include "graph/node.h" | #include "graph/node.h" | ||||
| #include "runtime/context.h" | #include "runtime/context.h" | ||||
| #include "graph/manager/graph_var_manager.h" | |||||
| namespace ge { | namespace ge { | ||||
| class TransVarDataUtils { | class TransVarDataUtils { | ||||
| @@ -17,7 +17,7 @@ | |||||
| #include "graph/optimize/graph_optimize.h" | #include "graph/optimize/graph_optimize.h" | ||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| #include "graph/common/local_context.h" | |||||
| #include "common/local_context.h" | |||||
| #include "graph/passes/dimension_adjust_pass.h" | #include "graph/passes/dimension_adjust_pass.h" | ||||
| #include "inc/pass_manager.h" | #include "inc/pass_manager.h" | ||||
| #include "init/gelib.h" | #include "init/gelib.h" | ||||
| @@ -17,7 +17,7 @@ | |||||
| #include <vector> | #include <vector> | ||||
| #include "common/ge/ge_util.h" | #include "common/ge/ge_util.h" | ||||
| #include "graph/common/omg_util.h" | |||||
| #include "common/omg_util.h" | |||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/optimize/graph_optimize.h" | #include "graph/optimize/graph_optimize.h" | ||||
| #include "graph/utils/graph_utils.h" | #include "graph/utils/graph_utils.h" | ||||
| @@ -31,7 +31,7 @@ | |||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/utils/graph_utils.h" | #include "graph/utils/graph_utils.h" | ||||
| #include "graph/utils/op_desc_utils.h" | #include "graph/utils/op_desc_utils.h" | ||||
| #include "graph/common/omg_util.h" | |||||
| #include "common/omg_util.h" | |||||
| #define REQUIRE(cond, ...) \ | #define REQUIRE(cond, ...) \ | ||||
| do { \ | do { \ | ||||
| @@ -28,7 +28,7 @@ | |||||
| #include "framework/common/types.h" | #include "framework/common/types.h" | ||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/manager/graph_manager_utils.h" | #include "graph/manager/graph_manager_utils.h" | ||||
| #include "graph/common/ge_call_wrapper.h" | |||||
| #include "common/ge_call_wrapper.h" | |||||
| #include "graph/utils/graph_utils.h" | #include "graph/utils/graph_utils.h" | ||||
| #include "graph/utils/op_desc_utils.h" | #include "graph/utils/op_desc_utils.h" | ||||
| #include "graph/utils/type_utils.h" | #include "graph/utils/type_utils.h" | ||||
| @@ -70,6 +70,8 @@ class GraphPartitioner { | |||||
| // Return all subgraphs | // Return all subgraphs | ||||
| const Graph2SubGraphInfoList &GetSubGraphMap(); | const Graph2SubGraphInfoList &GetSubGraphMap(); | ||||
| const Graph2InputNodesSubGraphInfo &GetSubGraphInfoMap() {return graph_2_input_subgraph_; } | |||||
| private: | private: | ||||
| Status MergeSubGraph(ge::ComputeGraphPtr &output_merged_compute_graph, | Status MergeSubGraph(ge::ComputeGraphPtr &output_merged_compute_graph, | ||||
| const ge::ComputeGraphPtr &original_compute_graph); | const ge::ComputeGraphPtr &original_compute_graph); | ||||
| @@ -24,7 +24,7 @@ | |||||
| #include "framework/common/ge_inner_error_codes.h" | #include "framework/common/ge_inner_error_codes.h" | ||||
| #include "common/ge/ge_util.h" | #include "common/ge/ge_util.h" | ||||
| #include "graph/common/ge_call_wrapper.h" | |||||
| #include "common/ge_call_wrapper.h" | |||||
| #include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
| #include "graph/utils/node_utils.h" | #include "graph/utils/node_utils.h" | ||||
| #include "init/gelib.h" | #include "init/gelib.h" | ||||
| @@ -16,7 +16,7 @@ | |||||
| #include "graph/passes/attach_stream_label_pass.h" | #include "graph/passes/attach_stream_label_pass.h" | ||||
| #include "external/ge/ge_api_types.h" | #include "external/ge/ge_api_types.h" | ||||
| #include "graph/common/omg_util.h" | |||||
| #include "common/omg_util.h" | |||||
| using std::string; | using std::string; | ||||
| @@ -1,374 +1,475 @@ | |||||
| /** | |||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #include "graph/passes/base_pass.h" | |||||
| #include <queue> | |||||
| #include <unordered_set> | |||||
| #include "framework/common/debug/log.h" | |||||
| #include "framework/common/debug/ge_log.h" | |||||
| #include "graph/compute_graph.h" | |||||
| #include "graph/utils/graph_utils.h" | |||||
| namespace ge { | |||||
| namespace { | |||||
| constexpr int kMaxRePassTimes = 10000; | |||||
| constexpr size_t kMaxOneInNodes = 1000; | |||||
| // Each iteration, we take about 0.3k memory on the stack, we should change the recursion to loop later | |||||
| constexpr int kMaxRecursiveDepth = 20; | |||||
| struct DuringPassNodeSets { | |||||
| std::unordered_set<Node *> nodes_seen; | |||||
| std::unordered_set<NodePtr> nodes_deleted; | |||||
| std::unordered_set<NodePtr> nodes_re_pass; | |||||
| std::unordered_set<NodePtr> nodes_re_pass_immediately; | |||||
| std::unordered_set<NodePtr> nodes_last; | |||||
| std::unordered_set<NodePtr> nodes_suspend; | |||||
| std::unordered_set<NodePtr> nodes_resume; | |||||
| }; | |||||
| void GetAllNodesNoInputEdge(const ComputeGraphPtr &graph, std::deque<NodePtr> &input_edge_nodes, | |||||
| std::unordered_set<Node *> &nodes_seen, std::unordered_set<NodePtr> &nodes_last) { | |||||
| nodes_last.clear(); | |||||
| for (auto &node : graph->GetDirectNode()) { | |||||
| if (node == nullptr) { | |||||
| continue; | |||||
| } | |||||
| size_t in_nums = node->GetInNodes().size(); | |||||
| if (in_nums == 0) { | |||||
| input_edge_nodes.push_back(node); | |||||
| nodes_seen.insert(node.get()); | |||||
| } else if (in_nums > kMaxOneInNodes) { | |||||
| nodes_last.insert(node); | |||||
| } | |||||
| } | |||||
| } | |||||
| bool IsAllInNodesAlive(const Node::Vistor<NodePtr> &nodes, const std::unordered_set<NodePtr> &nodes_suspend) { | |||||
| return !std::any_of(nodes.begin(), nodes.end(), [&](const NodePtr &n) { return nodes_suspend.count(n) > 0; }); | |||||
| } | |||||
| void AddNextIterNodes(const Node::Vistor<NodePtr> &nodes, std::deque<NodePtr> &nodes_to_pass, | |||||
| DuringPassNodeSets &during_pass_node_set) { | |||||
| auto &nodes_seen = during_pass_node_set.nodes_seen; | |||||
| const auto &nodes_last = during_pass_node_set.nodes_last; | |||||
| const auto &nodes_suspend = during_pass_node_set.nodes_suspend; | |||||
| for (auto &node : nodes) { | |||||
| if (node == nullptr) { | |||||
| continue; | |||||
| } | |||||
| if (nodes_last.count(node) != 0) { | |||||
| continue; | |||||
| } | |||||
| if (nodes_suspend.count(node) > 0) { | |||||
| GELOGD("The node %s has suspend by pass, skip it.", node->GetName().c_str()); | |||||
| continue; | |||||
| } | |||||
| bool all_in_nodes_alive = IsAllInNodesAlive(node->GetInAllNodes(), nodes_suspend); | |||||
| bool all_in_nodes_seen = node->IsAllInNodesSeen(nodes_seen); | |||||
| if (all_in_nodes_seen && all_in_nodes_alive && nodes_seen.insert(node.get()).second) { | |||||
| nodes_to_pass.push_back(node); | |||||
| } | |||||
| } | |||||
| } | |||||
| void AddRepassNodes(DuringPassNodeSets &during_pass_node_set, std::deque<NodePtr> &nodes) { | |||||
| for (const auto &node : during_pass_node_set.nodes_re_pass_immediately) { | |||||
| GELOGD("The node %s will be re-pass immediately.", node->GetName().c_str()); | |||||
| nodes.push_front(node); | |||||
| } | |||||
| during_pass_node_set.nodes_re_pass_immediately.clear(); | |||||
| } | |||||
| void AddResumeNodes(DuringPassNodeSets &during_pass_node_set, std::deque<NodePtr> &nodes) { | |||||
| for (auto &node : during_pass_node_set.nodes_resume) { | |||||
| const auto &it = during_pass_node_set.nodes_suspend.find(node); | |||||
| if (it != during_pass_node_set.nodes_suspend.end()) { | |||||
| during_pass_node_set.nodes_suspend.erase(node); | |||||
| GELOGD("The node %s resumed by pass.", node->GetName().c_str()); | |||||
| nodes.push_back(node); | |||||
| } else { | |||||
| GELOGW("The node %s not suspend, drop from resumed", node->GetName().c_str()); | |||||
| } | |||||
| } | |||||
| during_pass_node_set.nodes_resume.clear(); | |||||
| } | |||||
| void PushToSuspendNodes(DuringPassNodeSets &during_pass_node_set, const std::string &pass_name, | |||||
| const std::unordered_set<NodePtr> &nodes_suspend, | |||||
| const std::unordered_set<NodePtr> &nodes_resume) { | |||||
| for (const auto &node : nodes_suspend) { | |||||
| GELOGD("The iteration suspend of node %s has been set by pass %s", node->GetName().c_str(), pass_name.c_str()); | |||||
| during_pass_node_set.nodes_suspend.emplace(node); | |||||
| } | |||||
| for (const auto &node : nodes_resume) { | |||||
| GELOGD("The iteration suspend of node %s has been resumed by pass %s", node->GetName().c_str(), pass_name.c_str()); | |||||
| during_pass_node_set.nodes_resume.emplace(node); | |||||
| } | |||||
| } | |||||
| void PushToRePassIfSeen(NodePtr &node, const std::pair<std::string, BaseNodePass *> &name_to_pass, | |||||
| std::unordered_set<Node *> &nodes_seen, const std::unordered_set<NodePtr> &nodes_to_re_pass, | |||||
| std::unordered_set<NodePtr> &nodes_re_pass) { | |||||
| for (const auto &node_to_re_pass : nodes_to_re_pass) { | |||||
| if (node_to_re_pass == nullptr) { | |||||
| GELOGW("Found null re-pass node when executing %s on node %s type %s", name_to_pass.first.c_str(), | |||||
| node->GetName().c_str(), node->GetType().c_str()); | |||||
| continue; | |||||
| } | |||||
| if (nodes_seen.count(node_to_re_pass.get()) > 0 || node_to_re_pass->IsAllInNodesSeen(nodes_seen)) { | |||||
| GELOGD("The node %s will be re-pass.", node_to_re_pass->GetName().c_str()); | |||||
| nodes_re_pass.insert(node_to_re_pass); | |||||
| } else { | |||||
| GELOGD("The node %s are not all seen, don't set repass this time", node_to_re_pass->GetName().c_str()); | |||||
| } | |||||
| } | |||||
| } | |||||
| Status RunPasses(NodePtr &node, const NamesToPass &names_to_passes, DuringPassNodeSets &during_pass_node_set) { | |||||
| if (node == nullptr) { | |||||
| REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid."); | |||||
| GELOGE(FAILED, "[Check][Param] parameter node is nullptr."); | |||||
| return FAILED; | |||||
| } | |||||
| GELOGD("Begin to run pass for node %s", node->GetName().c_str()); | |||||
| for (const auto &name_to_pass : names_to_passes) { | |||||
| if (name_to_pass.second == nullptr) { | |||||
| GELOGE(INTERNAL_ERROR, "[Check][Param] There is null pointer in passes(%s), skip it", name_to_pass.first.c_str()); | |||||
| continue; | |||||
| } | |||||
| GELOGD("Begin to run pass %s for node %s", name_to_pass.first.c_str(), node->GetName().c_str()); | |||||
| name_to_pass.second->init(); | |||||
| auto result = name_to_pass.second->Run(node); | |||||
| if (result != SUCCESS) { | |||||
| REPORT_CALL_ERROR("E19999", "process pass %s on node:%s failed, ret:%u", | |||||
| name_to_pass.first.c_str(), node->GetName().c_str(), result); | |||||
| GELOGE(INTERNAL_ERROR, "[Process][Pass] %s on node %s failed, result " | |||||
| "%u, the passes will be terminated immediately.", | |||||
| name_to_pass.first.c_str(), node->GetName().c_str(), result); | |||||
| return result; | |||||
| } | |||||
| const auto &nodes_to_re_pass = name_to_pass.second->GetNodesNeedRePass(); | |||||
| PushToRePassIfSeen(node, name_to_pass, during_pass_node_set.nodes_seen, nodes_to_re_pass, | |||||
| during_pass_node_set.nodes_re_pass); | |||||
| const auto &nodes_to_re_pass_immediately = name_to_pass.second->GetNodesNeedRePassImmediately(); | |||||
| PushToRePassIfSeen(node, name_to_pass, during_pass_node_set.nodes_seen, nodes_to_re_pass_immediately, | |||||
| during_pass_node_set.nodes_re_pass_immediately); | |||||
| PushToSuspendNodes(during_pass_node_set, name_to_pass.first, | |||||
| name_to_pass.second->GetNodesSuspend(), name_to_pass.second->GetNodesResume()); | |||||
| const auto &nodes_deleted_by_pass = name_to_pass.second->GetNodesDeleted(); | |||||
| during_pass_node_set.nodes_deleted.insert(nodes_deleted_by_pass.begin(), nodes_deleted_by_pass.end()); | |||||
| if (nodes_deleted_by_pass.count(node) > 0) { | |||||
| GELOGD("The node %s was deleted by pass %s, stop the remain passes", node->GetName().c_str(), | |||||
| name_to_pass.first.c_str()); | |||||
| break; | |||||
| } | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| void SetFlagOption(NodePassOption option, NamesToPass names_to_pass) { | |||||
| for (auto &name_to_pass : names_to_pass) { | |||||
| name_to_pass.second->SetOption(option, ""); | |||||
| } | |||||
| } | |||||
| void ClearOption(NamesToPass names_to_pass) { | |||||
| for (auto &name_to_pass : names_to_pass) { | |||||
| name_to_pass.second->ClearOptions(); | |||||
| } | |||||
| } | |||||
| bool CheckNode(const NodePtr &node, const DuringPassNodeSets &during_pass_node_set) { | |||||
| if (node == nullptr) { | |||||
| GELOGW("node is null"); | |||||
| return false; | |||||
| } | |||||
| if (during_pass_node_set.nodes_deleted.count(node) > 0) { | |||||
| GELOGD("The node %s was deleted before, skip it.", node->GetName().c_str()); | |||||
| return false; | |||||
| } | |||||
| if (during_pass_node_set.nodes_suspend.count(node) > 0) { | |||||
| GELOGD("The node %s has been added to suspend-iteration nodes list, the iteration of it will be suspend.", | |||||
| node->GetName().c_str()); | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| } // namespace | |||||
| Status BaseNodePass::IsolateAndDeleteNode(NodePtr &node, const std::vector<int> &io_map) { | |||||
| if (node == nullptr) { | |||||
| REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid."); | |||||
| GELOGE(FAILED, "[Check][Param] parameter node is nullptr."); | |||||
| return FAILED; | |||||
| } | |||||
| GELOGI("Prepare to isolate and delete node, name:%s, type:%s.", node->GetName().c_str(), | |||||
| node->GetType().c_str()); | |||||
| ComputeGraphPtr graph = node->GetOwnerComputeGraph(); | |||||
| if (graph == nullptr) { | |||||
| REPORT_INNER_ERROR("E19999", "The owner graph of node:%s must not be null.", node->GetName().c_str()); | |||||
| GELOGE(FAILED, "[Get][OwnerComputeGraph] failed, The owner graph of node:%s must not be null.", | |||||
| node->GetName().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| AddRePassNodesWithInOut(node); | |||||
| if (GraphUtils::IsolateNode(node, io_map) != GRAPH_SUCCESS) { | |||||
| REPORT_CALL_ERROR("E19999", "Isolate Node:%s failed", node->GetName().c_str()); | |||||
| GELOGE(FAILED, "[Isolate][Node] %s failed.", node->GetName().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != SUCCESS) { | |||||
| REPORT_CALL_ERROR("E19999", "call RemoveNodeWithoutRelink for node:%s failed.", node->GetName().c_str()); | |||||
| GELOGE(FAILED, "[Call][RemoveNodeWithoutRelink] for node:%s failed.", node->GetName().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| AddNodeDeleted(node); | |||||
| return SUCCESS; | |||||
| } | |||||
| Status GEPass::Run(const NamesToPass &names_to_passes) { | |||||
| if (graph_ == nullptr) { | |||||
| REPORT_INNER_ERROR("E19999", "graph_ is nullptr, check invalid."); | |||||
| GELOGE(INTERNAL_ERROR, "[Check][Param] The graph is nullptr"); | |||||
| return INTERNAL_ERROR; | |||||
| } | |||||
| if (names_to_passes.empty()) { | |||||
| GELOGW("No passes input, the GEPass will do nothing"); | |||||
| return INTERNAL_ERROR; | |||||
| } | |||||
| if (depth_ > kMaxRecursiveDepth) { | |||||
| GELOGE(PARAM_INVALID, | |||||
| "[Check][Param] The pass for root graph %s will be terminated because too many nesting" | |||||
| " levels(%d) of subgraphs, last subgraph is %s", | |||||
| root_graph_->GetName().c_str(), depth_, graph_->GetName().c_str()); | |||||
| return PARAM_INVALID; | |||||
| } | |||||
| return RunPassesOneGraph(names_to_passes); | |||||
| } | |||||
| Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { | |||||
| GELOGD("Begin to run pass on graph, passes count %zu", names_to_passes.size()); | |||||
| std::deque<NodePtr> nodes; | |||||
| DuringPassNodeSets during_pass_node_set; | |||||
| GetAllNodesNoInputEdge(graph_, nodes, during_pass_node_set.nodes_seen, during_pass_node_set.nodes_last); | |||||
| GELOGD("Start points count %zu", nodes.size()); | |||||
| int re_pass_times = 0; | |||||
| do { | |||||
| for (auto &node : during_pass_node_set.nodes_re_pass) { | |||||
| nodes.push_back(node); | |||||
| during_pass_node_set.nodes_seen.insert(node.get()); | |||||
| } | |||||
| during_pass_node_set.nodes_re_pass.clear(); | |||||
| while (!nodes.empty()) { | |||||
| NodePtr node = nodes.front(); | |||||
| nodes.pop_front(); | |||||
| (void)during_pass_node_set.nodes_re_pass.erase(node); | |||||
| if (!CheckNode(node, during_pass_node_set)) { | |||||
| continue; | |||||
| } | |||||
| AddNextIterNodes(node->GetOutNodes(), nodes, during_pass_node_set); | |||||
| auto ret = RunPasses(node, names_to_passes, during_pass_node_set); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Process][Passes] on node %s type %s failed, error code:%u", | |||||
| node->GetName().c_str(), node->GetType().c_str(), ret); | |||||
| return ret; | |||||
| } | |||||
| bool has_sub_graph = false; | |||||
| ret = RunPassesOnSubGraph(node, names_to_passes, has_sub_graph); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Run][Passes] on the sub graph of node %s failed", node->GetName().c_str()); | |||||
| return ret; | |||||
| } | |||||
| if (has_sub_graph) { | |||||
| GELOGD("There are subgraphs on node %s, run passes for for the second time", node->GetName().c_str()); | |||||
| SetFlagOption(kOptimizeAfterSubGraph, names_to_passes); | |||||
| ret = RunPasses(node, names_to_passes, during_pass_node_set); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Process][Passes] on node %s type %s failed, error code: %u", | |||||
| node->GetName().c_str(), node->GetType().c_str(), ret); | |||||
| return ret; | |||||
| } | |||||
| // There is only one option scene, so set and clear options around the `RunPasses` func. | |||||
| // if there are more than one scene to set options, the `ClearOption` function | |||||
| // should be called each time at the begin of the iteration | |||||
| ClearOption(names_to_passes); | |||||
| } | |||||
| AddRepassNodes(during_pass_node_set, nodes); | |||||
| AddResumeNodes(during_pass_node_set, nodes); | |||||
| } | |||||
| for (auto &node : during_pass_node_set.nodes_last) { | |||||
| bool all_in_nodes_seen = node->IsAllInNodesSeen(during_pass_node_set.nodes_seen); | |||||
| if (all_in_nodes_seen && during_pass_node_set.nodes_seen.insert(node.get()).second) { | |||||
| nodes.push_back(node); | |||||
| } | |||||
| } | |||||
| during_pass_node_set.nodes_last.clear(); | |||||
| } while ((!during_pass_node_set.nodes_re_pass.empty() || !nodes.empty()) && ++re_pass_times < kMaxRePassTimes); | |||||
| if (re_pass_times == kMaxRePassTimes) { | |||||
| GELOGW("re_pass_times should not come to %d", kMaxRePassTimes); | |||||
| } | |||||
| GELOGD("All passes runs end"); | |||||
| return SUCCESS; | |||||
| } | |||||
| Status GEPass::RunPassesOnSubGraph(const NodePtr &node, const NamesToPass &names_to_passes, bool &has_sub_graph) { | |||||
| auto sub_graph_names = node->GetOpDesc()->GetSubgraphInstanceNames(); | |||||
| has_sub_graph = false; | |||||
| for (const auto &name : sub_graph_names) { | |||||
| auto graph = root_graph_->GetSubgraph(name); | |||||
| if (graph == nullptr) { | |||||
| GELOGW("Can not find the sub graph %s from node %s, the pass-process will skip it", | |||||
| name.c_str(), node->GetName().c_str()); | |||||
| continue; | |||||
| } | |||||
| has_sub_graph = true; | |||||
| GELOGI("Begin to run passes on the sub graph %s of node %s", name.c_str(), node->GetName().c_str()); | |||||
| GEPass pass(graph, root_graph_, depth_ + 1); | |||||
| auto ret = pass.Run(names_to_passes); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Run][Passes] for sub graph:%s from node:%s failed", name.c_str(), node->GetName().c_str()); | |||||
| return ret; | |||||
| } | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| } // namespace ge | |||||
| /** | |||||
| * Copyright 2020 Huawei Technologies Co., Ltd | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #include "graph/passes/base_pass.h" | |||||
| #include <queue> | |||||
| #include <unordered_set> | |||||
| #include "common/debug/log.h" | |||||
| #include "graph/utils/graph_utils.h" | |||||
| namespace ge { | |||||
| namespace { | |||||
| constexpr int kMaxRePassTimes = 10000; | |||||
| constexpr size_t kMaxOneInNodes = 1000; | |||||
| // Each iteration, we take about 0.3k memory on the stack, we should change the recursion to loop later | |||||
| constexpr int kMaxRecursiveDepth = 20; | |||||
| void GetAllNodesNoInputEdge(const ComputeGraphPtr &graph, | |||||
| GEPass::GraphLevelState &g_state) { | |||||
| for (auto &node : graph->GetDirectNode()) { | |||||
| if (node == nullptr) { | |||||
| continue; | |||||
| } | |||||
| size_t in_nums = node->GetInNodes().size(); | |||||
| if (in_nums == 0) { | |||||
| g_state.AddNodeToQueueIfNotSeen(node); | |||||
| } else if (in_nums > kMaxOneInNodes) { | |||||
| g_state.nodes_last.insert(node); | |||||
| } | |||||
| } | |||||
| } | |||||
| bool AnyNodesIn(const Node::Vistor<NodePtr> &nodes, const std::unordered_set<NodePtr> &nodes_set) { | |||||
| return std::any_of(nodes.begin(), nodes.end(), [&](const NodePtr &n) { | |||||
| return nodes_set.count(n) > 0; | |||||
| }); | |||||
| } | |||||
| bool IsNodeReadyToQueue(const NodePtr &node, GEPass::GraphLevelState &g_state) { | |||||
| if (node == nullptr) { | |||||
| GELOGW("node is null"); | |||||
| return false; | |||||
| } | |||||
| if (g_state.nodes_deleted.count(node) > 0) { | |||||
| GELOGD("The node %s was deleted before, skip it.", node->GetName().c_str()); | |||||
| return false; | |||||
| } | |||||
| if (g_state.nodes_last.count(node) != 0) { | |||||
| return false; | |||||
| } | |||||
| // all in_node seen && all in_node not suspend | |||||
| if (!node->IsAllInNodesSeen(g_state.nodes_seen)) { | |||||
| return false; | |||||
| } | |||||
| if (g_state.nodes_suspend.count(node) > 0) { | |||||
| GELOGD("The node %s has been added to suspend-iteration nodes list, the iteration of it will be suspend.", | |||||
| node->GetName().c_str()); | |||||
| return false; | |||||
| } | |||||
| if (AnyNodesIn(node->GetInAllNodes(), g_state.nodes_suspend)) { | |||||
| GELOGD("The node %s has been added to suspend-iteration nodes list, the iteration of it will be suspend.", | |||||
| node->GetName().c_str()); | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| void AddNextIterNodes(const NodePtr &cur_node, | |||||
| std::unordered_set<NodePtr> &out_nodes_before_pass, | |||||
| GEPass::GraphLevelState &g_state) { | |||||
| for (auto &node : cur_node->GetOutNodes()) { | |||||
| if (node == nullptr) { | |||||
| continue; | |||||
| } | |||||
| if(out_nodes_before_pass.erase(node) == 0) { | |||||
| // after pass node, new output node come up | |||||
| GELOGI("New output node %s come up after pass %s.", | |||||
| node->GetName().c_str(), cur_node->GetName().c_str()); | |||||
| } | |||||
| // all in_node seen && all in_node not suspend | |||||
| if (IsNodeReadyToQueue(node, g_state)) { | |||||
| g_state.AddNodeToQueueIfNotSeen(node); | |||||
| } | |||||
| } | |||||
| // | |||||
| for (const auto &node : out_nodes_before_pass) { | |||||
| // A-->B-->C if B was | |||||
| // unlink edge may happend, add these node to queue if needed | |||||
| if (node->GetInAllNodes().empty() && IsNodeReadyToQueue(node, g_state)) { | |||||
| GELOGI("Node %s may lost from cur node, add to queue if not seen.", | |||||
| node->GetName().c_str(), cur_node->GetName().c_str()); | |||||
| g_state.AddNodeToQueueIfNotSeen(node); | |||||
| } | |||||
| } | |||||
| } | |||||
| void AddImmediateRepassNodesToQueue(NodePtr &cur_node, | |||||
| std::unordered_map<NodePtr, std::string> re_pass_imm_nodes_to_pass_names, | |||||
| GEPass::GraphLevelState &g_state) { | |||||
| for (const auto &node_2_pass_names : re_pass_imm_nodes_to_pass_names) { | |||||
| auto imme_repass_node = node_2_pass_names.first; | |||||
| if (imme_repass_node == nullptr) { | |||||
| GELOGW("Found null immediately re-pass node when executing pass %s on node %s type %s", | |||||
| node_2_pass_names.second.c_str(), | |||||
| cur_node->GetName().c_str(), cur_node->GetType().c_str()); | |||||
| continue; | |||||
| } | |||||
| if (g_state.nodes_passed.count(imme_repass_node) > 0) { | |||||
| GELOGD("The node %s specified by pass %s has been passed, it will repass immediately", | |||||
| imme_repass_node->GetName().c_str(), node_2_pass_names.second.c_str()); | |||||
| g_state.AddNodeToQueueFront(imme_repass_node); | |||||
| continue; | |||||
| } | |||||
| GELOGW("The node %s specified by pass %s has un-passed, it will not repass immediately", | |||||
| node_2_pass_names.first->GetName().c_str(), node_2_pass_names.second.c_str()); | |||||
| } | |||||
| } | |||||
| void AddLastNodesToQueue(GEPass::GraphLevelState &g_state) { | |||||
| for (auto &node : g_state.nodes_last) { | |||||
| if (node->IsAllInNodesSeen(g_state.nodes_seen)) { | |||||
| g_state.AddNodeToQueueIfNotSeen(node); | |||||
| } | |||||
| } | |||||
| g_state.nodes_last.clear(); | |||||
| } | |||||
| void AddResumeNodesToQueue(const std::unordered_map<NodePtr, std::string> resume_node_2_pass_names, | |||||
| GEPass::GraphLevelState &g_state) { | |||||
| // Now base pass doesnt record the order of suspend & resume, so we dont know which one come first in a node pass. | |||||
| // Here if one node pass suspend and resume a node ,consider it resume that node. | |||||
| // Better way to record the order, and here suspend or resume in order. | |||||
| for (const auto &node_2_pass_names : resume_node_2_pass_names) { | |||||
| auto node = node_2_pass_names.first; | |||||
| if (g_state.nodes_suspend.erase(node) > 0) { | |||||
| if (g_state.nodes_seen.count(node.get()) > 0 || node->IsAllInNodesSeen(g_state.nodes_seen)) { | |||||
| g_state.nodes.push_back(node); | |||||
| GELOGD("Node %s has been resumed by pass %s, and add to pass queue", | |||||
| node->GetName().c_str(), node_2_pass_names.second.c_str()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| void PushToRePassIfSeen(NodePtr &node, const std::pair<std::string, BaseNodePass *> &name_to_pass, | |||||
| std::unordered_set<Node *> &nodes_seen, const std::vector<NodePtr> &nodes_to_re_pass, | |||||
| GEPass::RepassLevelState &rp_state) { | |||||
| for (const auto &node_to_re_pass : nodes_to_re_pass) { | |||||
| if (node_to_re_pass == nullptr) { | |||||
| GELOGW("Found null re-pass node when executing %s on node %s type %s", name_to_pass.first.c_str(), | |||||
| node->GetName().c_str(), node->GetType().c_str()); | |||||
| continue; | |||||
| } | |||||
| if (nodes_seen.count(node_to_re_pass.get()) > 0 || node_to_re_pass->IsAllInNodesSeen(nodes_seen)) { | |||||
| if (rp_state.AddNodeToRepass(node_to_re_pass)) { | |||||
| GELOGD("The node %s will be re-pass.", node_to_re_pass->GetName().c_str()); | |||||
| continue; | |||||
| } | |||||
| GELOGD("Node %s has been added to repass queue, no need to add again.", node_to_re_pass->GetName().c_str()); | |||||
| } else { | |||||
| GELOGD("The node %s are not all seen, don't set repass this time", node_to_re_pass->GetName().c_str()); | |||||
| } | |||||
| } | |||||
| } | |||||
| void SetFlagOption(NodePassOption option, NamesToPass names_to_pass) { | |||||
| for (auto &name_to_pass : names_to_pass) { | |||||
| name_to_pass.second->SetOption(option, ""); | |||||
| } | |||||
| } | |||||
| void ClearOption(NamesToPass names_to_pass) { | |||||
| for (auto &name_to_pass : names_to_pass) { | |||||
| name_to_pass.second->ClearOptions(); | |||||
| } | |||||
| } | |||||
| } // namespace | |||||
| Status BaseNodePass::IsolateAndDeleteNode(NodePtr &node, const std::vector<int> &io_map, | |||||
| bool is_repass_io_immediately) { | |||||
| if (node == nullptr) { | |||||
| REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid."); | |||||
| GELOGE(FAILED, "[Check][Param] parameter node is nullptr."); | |||||
| return FAILED; | |||||
| } | |||||
| GELOGI("Prepare to isolate and delete node, name:%s, type:%s.", node->GetName().c_str(), | |||||
| node->GetType().c_str()); | |||||
| ComputeGraphPtr graph = node->GetOwnerComputeGraph(); | |||||
| if (graph == nullptr) { | |||||
| REPORT_INNER_ERROR("E19999", "The owner graph of node:%s must not be null.", node->GetName().c_str()); | |||||
| GELOGE(FAILED, "[Get][OwnerComputeGraph] failed, The owner graph of node:%s must not be null.", | |||||
| node->GetName().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| is_repass_io_immediately ? AddImmediateRePassNodesWithInOut(node) : AddRePassNodesWithInOut(node); | |||||
| if (GraphUtils::IsolateNode(node, io_map) != GRAPH_SUCCESS) { | |||||
| REPORT_CALL_ERROR("E19999", "Isolate Node:%s failed", node->GetName().c_str()); | |||||
| GELOGE(FAILED, "[Isolate][Node] %s failed.", node->GetName().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != SUCCESS) { | |||||
| REPORT_CALL_ERROR("E19999", "call RemoveNodeWithoutRelink for node:%s failed.", node->GetName().c_str()); | |||||
| GELOGE(FAILED, "[Call][RemoveNodeWithoutRelink] for node:%s failed.", node->GetName().c_str()); | |||||
| return FAILED; | |||||
| } | |||||
| AddNodeDeleted(node); | |||||
| return SUCCESS; | |||||
| } | |||||
| Status GEPass::Run(const NamesToPass &names_to_passes) { | |||||
| if (graph_ == nullptr) { | |||||
| REPORT_INNER_ERROR("E19999", "graph_ is nullptr, check invalid."); | |||||
| GELOGE(INTERNAL_ERROR, "[Check][Param] The graph is nullptr"); | |||||
| return INTERNAL_ERROR; | |||||
| } | |||||
| if (names_to_passes.empty()) { | |||||
| GELOGW("No passes input, the GEPass will do nothing"); | |||||
| return INTERNAL_ERROR; | |||||
| } | |||||
| for (const auto &name_to_pass : names_to_passes) { | |||||
| if (name_to_pass.second == nullptr) { | |||||
| GELOGE(INTERNAL_ERROR, "[Check][Param] There is null pointer in passes(%s)", name_to_pass.first.c_str()); | |||||
| return INTERNAL_ERROR; | |||||
| } | |||||
| } | |||||
| if (depth_ > kMaxRecursiveDepth) { | |||||
| GELOGE(PARAM_INVALID, | |||||
| "[Check][Param] The pass for root graph %s will be terminated because too many nesting" | |||||
| " levels(%d) of subgraphs, last subgraph is %s", | |||||
| root_graph_->GetName().c_str(), depth_, graph_->GetName().c_str()); | |||||
| return PARAM_INVALID; | |||||
| } | |||||
| return RunPassesOneGraph(names_to_passes); | |||||
| // todo debug mode is on, find first node in topo order which is not passed. and give a warning | |||||
| } | |||||
| void NotifyPassGraphStart(const ComputeGraphPtr &graph, const NamesToPass &names_to_pass) { | |||||
| for (auto &name_to_pass : names_to_pass) { | |||||
| name_to_pass.second->OnStartPassGraph(graph); | |||||
| } | |||||
| } | |||||
| Status GEPass::HandleLeakedSuspendNodes(const NamesToPass &names_to_passes, GraphLevelState &g_state) { | |||||
| std::unordered_map<NodePtr, std::string> resume_nodes_to_pass_names; | |||||
| for (auto &name_to_pass : names_to_passes) { | |||||
| name_to_pass.second->init(); | |||||
| auto ret = name_to_pass.second->OnSuspendNodesLeaked(); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "Internal error with OnSuspendNodesLeaked on pass %s.", name_to_pass.first.c_str()); | |||||
| return ret; | |||||
| } | |||||
| for (const auto &resume_node : name_to_pass.second->GetNodesResume()){ | |||||
| resume_nodes_to_pass_names[resume_node].append(name_to_pass.first + ","); | |||||
| } | |||||
| } | |||||
| AddResumeNodesToQueue(resume_nodes_to_pass_names, g_state); | |||||
| return SUCCESS; | |||||
| } | |||||
| Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { | |||||
| GELOGD("Begin to run pass on graph, passes count %zu", names_to_passes.size()); | |||||
| NotifyPassGraphStart(graph_, names_to_passes); | |||||
| GraphLevelState g_state; | |||||
| g_state.re_pass_times = 0; | |||||
| GetAllNodesNoInputEdge(graph_, g_state); | |||||
| GELOGD("Start points count %zu", g_state.nodes.size()); | |||||
| do { | |||||
| if (!g_state.nodes_suspend.empty()) { | |||||
| auto ret = HandleLeakedSuspendNodes(names_to_passes, g_state); | |||||
| if (ret != SUCCESS) { | |||||
| // log inside upper function | |||||
| return ret; | |||||
| } | |||||
| if (g_state.nodes.empty()) { | |||||
| GELOGE(INTERNAL_ERROR, "There are some suspended nodes leaked and no pass resume them."); | |||||
| return INTERNAL_ERROR; | |||||
| } | |||||
| } | |||||
| auto ret = RunPassesGraphRepass(names_to_passes, g_state); | |||||
| if (ret != SUCCESS) { | |||||
| return ret; | |||||
| } | |||||
| } while (!g_state.nodes_suspend.empty()); | |||||
| return SUCCESS; | |||||
| } | |||||
| Status GEPass::RunPassesGraphRepass(const NamesToPass &names_to_passes, GraphLevelState &g_state) { | |||||
| RepassLevelState rp_state; | |||||
| do { | |||||
| for (auto &node : rp_state.nodes_re_pass) { | |||||
| if (rp_state.nodes_re_pass_set.count(node) > 0) { | |||||
| GELOGD("Add node %s to queue for re-pass", node->GetName().c_str()); | |||||
| g_state.AddNodeToQueue(node); | |||||
| } | |||||
| } | |||||
| rp_state.ClearRepass(); | |||||
| while (!g_state.nodes.empty()) { | |||||
| auto node = g_state.PopFront(); | |||||
| if (g_state.nodes_deleted.count(node) > 0) { | |||||
| GELOGD("The node %s was deleted before, skip it.", node->GetName().c_str()); | |||||
| continue; | |||||
| } | |||||
| rp_state.EraseNodeFromRepass(node); | |||||
| g_state.nodes_seen.insert(node.get()); | |||||
| // collect out nodes before pass | |||||
| std::unordered_set<NodePtr> out_nodes_before_pass; | |||||
| for (const auto &out_node : node->GetOutNodes()) { | |||||
| out_nodes_before_pass.insert(out_node); | |||||
| } | |||||
| auto ret = RunPassesNodeOnce(node, names_to_passes, g_state, rp_state); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Process][Passes] on node %s type %s failed, error code:%u", node->GetName().c_str(), | |||||
| node->GetType().c_str(), ret); | |||||
| return ret; | |||||
| } | |||||
| AddNextIterNodes(node, out_nodes_before_pass, g_state); | |||||
| } | |||||
| AddLastNodesToQueue(g_state); | |||||
| } while ((!rp_state.nodes_re_pass.empty() || !g_state.nodes.empty()) && ++g_state.re_pass_times < kMaxRePassTimes); | |||||
| if (g_state.re_pass_times == kMaxRePassTimes) { | |||||
| GELOGW("re_pass_times should not come to %d", kMaxRePassTimes); | |||||
| } | |||||
| GELOGD("All passes runs end"); | |||||
| return SUCCESS; | |||||
| } | |||||
| Status GEPass::RunPassesOnSubGraph(const NodePtr &node, const NamesToPass &names_to_passes, bool &has_sub_graph) { | |||||
| auto sub_graph_names = node->GetOpDesc()->GetSubgraphInstanceNames(); | |||||
| has_sub_graph = false; | |||||
| for (const auto &name : sub_graph_names) { | |||||
| auto graph = root_graph_->GetSubgraph(name); | |||||
| if (graph == nullptr) { | |||||
| GELOGW("Can not find the sub graph %s from node %s, the pass-process will skip it", | |||||
| name.c_str(), node->GetName().c_str()); | |||||
| continue; | |||||
| } | |||||
| has_sub_graph = true; | |||||
| GELOGI("Begin to run passes on the sub graph %s of node %s", name.c_str(), node->GetName().c_str()); | |||||
| GEPass pass(graph, root_graph_, depth_ + 1); | |||||
| auto ret = pass.Run(names_to_passes); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Run][Passes] for sub graph:%s from node:%s failed", name.c_str(), node->GetName().c_str()); | |||||
| return ret; | |||||
| } | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| Status GEPass::RunPassesNodeOnce(NodePtr &node, const NamesToPass &names_to_passes, | |||||
| GraphLevelState &g_state, RepassLevelState &rp_state) { | |||||
| auto ret = RunPassesOnNode(node, names_to_passes, g_state, rp_state); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Process][Passes] on node %s type %s failed, error code:%u", node->GetName().c_str(), | |||||
| node->GetType().c_str(), ret); | |||||
| return ret; | |||||
| } | |||||
| bool has_sub_graph = false; | |||||
| ret = RunPassesOnSubGraph(node, names_to_passes, has_sub_graph); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Run][Passes] on the sub graph of node %s failed", node->GetName().c_str()); | |||||
| return ret; | |||||
| } | |||||
| if (has_sub_graph) { | |||||
| GELOGD("There are subgraphs on node %s, run passes for for the second time", node->GetName().c_str()); | |||||
| SetFlagOption(kOptimizeAfterSubGraph, names_to_passes); | |||||
| ret = RunPassesOnNode(node, names_to_passes, g_state, rp_state); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Process][Passes] on node %s type %s failed, error code: %u", node->GetName().c_str(), | |||||
| node->GetType().c_str(), ret); | |||||
| return ret; | |||||
| } | |||||
| // There is only one option scene, so set and clear options around the `RunPasses` func. | |||||
| // if there are more than one scene to set options, the `ClearOption` function | |||||
| // should be called each time at the begin of the iteration | |||||
| ClearOption(names_to_passes); | |||||
| } | |||||
| return SUCCESS; | |||||
| } | |||||
| Status GEPass::RunPassesOnNode(NodePtr &node, const NamesToPass &names_to_passes, GraphLevelState &g_state, | |||||
| RepassLevelState &rp_state) { | |||||
| if (node == nullptr) { | |||||
| REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid."); | |||||
| GELOGE(FAILED, "[Check][Param] parameter node is nullptr."); | |||||
| return FAILED; | |||||
| } | |||||
| GELOGD("Begin to run pass for node %s", node->GetName().c_str()); | |||||
| for (const auto &name_to_pass : names_to_passes) { | |||||
| GELOGD("Begin to run pass %s for node %s", name_to_pass.first.c_str(), node->GetName().c_str()); | |||||
| name_to_pass.second->init(); | |||||
| auto result = name_to_pass.second->Run(node); | |||||
| if (result != SUCCESS) { | |||||
| REPORT_CALL_ERROR("E19999", "process pass %s on node:%s failed, ret:%u", | |||||
| name_to_pass.first.c_str(), node->GetName().c_str(), result); | |||||
| GELOGE(INTERNAL_ERROR, "[Process][Pass] %s on node %s failed, result " | |||||
| "%u, the passes will be terminated immediately.", | |||||
| name_to_pass.first.c_str(), node->GetName().c_str(), result); | |||||
| return result; | |||||
| } | |||||
| if (name_to_pass.second->GetNodesDeleted().count(node) > 0) { | |||||
| GELOGD("The node %s was deleted by pass %s, stop the remain passes", node->GetName().c_str(), | |||||
| name_to_pass.first.c_str()); | |||||
| break; | |||||
| } | |||||
| } | |||||
| g_state.nodes_passed.insert(node); | |||||
| std::unordered_map<NodePtr, std::string> re_pass_imm_nodes_to_pass_names; | |||||
| std::unordered_map<NodePtr, std::string> resume_nodes_to_pass_names; | |||||
| // if muti psss repass one same node, it will add to queue many times, so collect and duplicate | |||||
| for (const auto &name_to_pass : names_to_passes) { | |||||
| PushToRePassIfSeen(node, name_to_pass, g_state.nodes_seen, | |||||
| name_to_pass.second->GetNodesNeedRePass(), | |||||
| rp_state); | |||||
| // collect imm_node && resume_node among these passes | |||||
| for (const auto &imm_node : name_to_pass.second->GetNodesNeedRePassImmediately()){ | |||||
| re_pass_imm_nodes_to_pass_names[imm_node].append(name_to_pass.first + ","); | |||||
| } | |||||
| for (const auto &resume_node : name_to_pass.second->GetNodesResume()){ | |||||
| resume_nodes_to_pass_names[resume_node].append(name_to_pass.first + ","); | |||||
| } | |||||
| for (const auto &suspend_node : name_to_pass.second->GetNodesSuspend()) { | |||||
| GELOGD("The iteration suspend of node %s has been set by pass %s", suspend_node->GetName().c_str(), | |||||
| name_to_pass.first.c_str()); | |||||
| g_state.nodes_suspend.insert(suspend_node); | |||||
| } | |||||
| const auto &nodes_deleted_by_pass = name_to_pass.second->GetNodesDeleted(); | |||||
| g_state.nodes_deleted.insert(nodes_deleted_by_pass.begin(), nodes_deleted_by_pass.end()); | |||||
| } | |||||
| AddImmediateRepassNodesToQueue(node, re_pass_imm_nodes_to_pass_names, g_state); | |||||
| AddResumeNodesToQueue(resume_nodes_to_pass_names, g_state); | |||||
| return SUCCESS; | |||||
| } | |||||
| } // namespace ge | |||||
| @@ -22,7 +22,6 @@ | |||||
| #include <unordered_set> | #include <unordered_set> | ||||
| #include <utility> | #include <utility> | ||||
| #include <vector> | #include <vector> | ||||
| #include "framework/common/ge_inner_error_codes.h" | #include "framework/common/ge_inner_error_codes.h" | ||||
| #include "framework/common/types.h" | #include "framework/common/types.h" | ||||
| #include "graph/compute_graph.h" | #include "graph/compute_graph.h" | ||||
| @@ -40,6 +39,7 @@ enum NodePassOption { | |||||
| }; | }; | ||||
| class BaseNodePass { | class BaseNodePass { | ||||
| // todo comments | |||||
| public: | public: | ||||
| /// | /// | ||||
| /// Optimize on one node. the function can add nodes to the graph, change | /// Optimize on one node. the function can add nodes to the graph, change | ||||
| @@ -51,7 +51,7 @@ class BaseNodePass { | |||||
| virtual ~BaseNodePass() = default; | virtual ~BaseNodePass() = default; | ||||
| const std::unordered_set<NodePtr> &GetNodesNeedRePass() { return nodes_need_re_pass_; } | |||||
| const std::vector<NodePtr> &GetNodesNeedRePass() { return nodes_need_re_pass_; } | |||||
| const std::unordered_set<NodePtr> &GetNodesNeedRePassImmediately() { return nodes_need_re_pass_immediately_; } | const std::unordered_set<NodePtr> &GetNodesNeedRePassImmediately() { return nodes_need_re_pass_immediately_; } | ||||
| @@ -61,23 +61,32 @@ class BaseNodePass { | |||||
| const std::unordered_set<NodePtr> &GetNodesResume() { return nodes_resume_; } | const std::unordered_set<NodePtr> &GetNodesResume() { return nodes_resume_; } | ||||
| virtual Status OnSuspendNodesLeaked() { return SUCCESS; } | |||||
| void SetOption(NodePassOption option, const std::string &value) { options_[option] = value; } | void SetOption(NodePassOption option, const std::string &value) { options_[option] = value; } | ||||
| void ClearOptions() { options_.clear(); } | void ClearOptions() { options_.clear(); } | ||||
| void init() { | void init() { | ||||
| nodes_need_re_pass_.clear(); | nodes_need_re_pass_.clear(); | ||||
| nodes_deleted_.clear(); | |||||
| nodes_need_re_pass_immediately_.clear(); | nodes_need_re_pass_immediately_.clear(); | ||||
| nodes_deleted_.clear(); | |||||
| nodes_suspend_.clear(); | nodes_suspend_.clear(); | ||||
| nodes_resume_.clear(); | nodes_resume_.clear(); | ||||
| } | } | ||||
| virtual void OnStartPassGraph(const ComputeGraphPtr &graph) { | |||||
| current_graph_name_ = graph->GetName(); | |||||
| } | |||||
| protected: | protected: | ||||
| Status IsolateAndDeleteNode(NodePtr &node, const std::vector<int> &io_map); | |||||
| const string &GetCurrentGraphName() const { | |||||
| return current_graph_name_; | |||||
| } | |||||
| Status IsolateAndDeleteNode(NodePtr &node, const std::vector<int> &io_map, bool is_repass_io_immediately = false); | |||||
| Status IsolateAndDeleteNode(NodePtr &node, const std::initializer_list<int> &io_map) { | |||||
| return IsolateAndDeleteNode(node, std::vector<int>(io_map)); | |||||
| Status IsolateAndDeleteNode(NodePtr &node, const std::initializer_list<int> &io_map, bool is_repass_io_immediately = false) { | |||||
| return IsolateAndDeleteNode(node, std::vector<int>(io_map), is_repass_io_immediately); | |||||
| } | } | ||||
| /// | /// | ||||
| @@ -86,7 +95,7 @@ class BaseNodePass { | |||||
| /// optimized by other passes, call this function. | /// optimized by other passes, call this function. | ||||
| /// @param node | /// @param node | ||||
| /// | /// | ||||
| void AddRePassNode(const NodePtr &node) { nodes_need_re_pass_.insert(node); } | |||||
| void AddRePassNode(const NodePtr &node) { nodes_need_re_pass_.emplace_back(node); } | |||||
| /// | /// | ||||
| /// Add a node to be optimized immediately again. If you add a new node to the graph, or | /// Add a node to be optimized immediately again. If you add a new node to the graph, or | ||||
| @@ -101,14 +110,30 @@ class BaseNodePass { | |||||
| /// @param node | /// @param node | ||||
| /// | /// | ||||
| void AddRePassNodesWithInOut(const NodePtr &node) { | void AddRePassNodesWithInOut(const NodePtr &node) { | ||||
| auto in_nodes = node->GetInNodes(); | |||||
| for (auto &in_node : in_nodes) { | |||||
| AddRePassNode(in_node); | |||||
| } | |||||
| AddRePassNode(node); | AddRePassNode(node); | ||||
| auto out_nodes = node->GetOutNodes(); | auto out_nodes = node->GetOutNodes(); | ||||
| for (auto &out_node : out_nodes) { | for (auto &out_node : out_nodes) { | ||||
| AddRePassNode(out_node); | AddRePassNode(out_node); | ||||
| } | } | ||||
| } | |||||
| /// | |||||
| /// Add a node and it's input/output data nodes to be optimized immediately again. | |||||
| /// @param node | |||||
| /// | |||||
| void AddImmediateRePassNodesWithInOut(const NodePtr &node) { | |||||
| auto in_nodes = node->GetInNodes(); | auto in_nodes = node->GetInNodes(); | ||||
| for (auto &in_node : in_nodes) { | for (auto &in_node : in_nodes) { | ||||
| AddRePassNode(in_node); | |||||
| AddImmediateRePassNode(in_node); | |||||
| } | |||||
| AddImmediateRePassNode(node); | |||||
| auto out_nodes = node->GetOutNodes(); | |||||
| for (auto &out_node : out_nodes) { | |||||
| AddImmediateRePassNode(out_node); | |||||
| } | } | ||||
| } | } | ||||
| @@ -123,34 +148,27 @@ class BaseNodePass { | |||||
| void AddNodeDeleted(const NodePtr &node) { nodes_deleted_.insert(node); } | void AddNodeDeleted(const NodePtr &node) { nodes_deleted_.insert(node); } | ||||
| /// | /// | ||||
| /// If you suspend a node from the graph, especially following node. The remain | |||||
| /// iterate passes will stop process on the suspend node(if it can be | |||||
| /// If you postpone a node from the graph, especially following node. The remain | |||||
| /// iterate passes will stop process on the postpone node(if it can be | |||||
| /// reached by edge connections) till the last one. Obviously it is a waste of | /// reached by edge connections) till the last one. Obviously it is a waste of | ||||
| /// time. You can add the suspend nodes by calling this function, to stop the | |||||
| /// time. You can add the postpone nodes by calling this function, to stop the | |||||
| /// next iterations. | /// next iterations. | ||||
| /// @param node | /// @param node | ||||
| /// | /// | ||||
| void AddNodeSuspend(const NodePtr &node) { nodes_suspend_.insert(node); } | void AddNodeSuspend(const NodePtr &node) { nodes_suspend_.insert(node); } | ||||
| /// | |||||
| /// If you resume a node from the graph, especially following node. The remain | |||||
| /// iterate passes will continue process on the resume node(if it can be | |||||
| /// reached by edge connections) till the last one. | |||||
| /// You can add the resume nodes by calling this function, to resume the | |||||
| /// next iterations. | |||||
| /// @param node | |||||
| /// | |||||
| void AddNodeResume(const NodePtr &node) { nodes_resume_.insert(node); } | void AddNodeResume(const NodePtr &node) { nodes_resume_.insert(node); } | ||||
| bool OptionExists(NodePassOption option) { return options_.count(option) > 0; } | bool OptionExists(NodePassOption option) { return options_.count(option) > 0; } | ||||
| private: | private: | ||||
| std::unordered_set<NodePtr> nodes_need_re_pass_; | |||||
| std::vector<NodePtr> nodes_need_re_pass_; | |||||
| std::unordered_set<NodePtr> nodes_need_re_pass_immediately_; | std::unordered_set<NodePtr> nodes_need_re_pass_immediately_; | ||||
| std::unordered_set<NodePtr> nodes_deleted_; | std::unordered_set<NodePtr> nodes_deleted_; | ||||
| std::unordered_set<NodePtr> nodes_suspend_; | std::unordered_set<NodePtr> nodes_suspend_; | ||||
| std::unordered_set<NodePtr> nodes_resume_; | std::unordered_set<NodePtr> nodes_resume_; | ||||
| std::map<NodePassOption, std::string> options_; | std::map<NodePassOption, std::string> options_; | ||||
| std::string current_graph_name_; | |||||
| }; | }; | ||||
| using NamesToPass = std::vector<std::pair<std::string, BaseNodePass *>>; | using NamesToPass = std::vector<std::pair<std::string, BaseNodePass *>>; | ||||
| @@ -160,12 +178,75 @@ class GEPass { | |||||
| explicit GEPass(ComputeGraphPtr &graph) : graph_(graph), root_graph_(graph), depth_(1) {} | explicit GEPass(ComputeGraphPtr &graph) : graph_(graph), root_graph_(graph), depth_(1) {} | ||||
| virtual ~GEPass() = default; | virtual ~GEPass() = default; | ||||
| Status Run(const NamesToPass &names_to_passes); | Status Run(const NamesToPass &names_to_passes); | ||||
| /* | |||||
| * todo | |||||
| * OneGraph: nodes_deleted, nodes_seen, nodes_passed, nodes_suspended | |||||
| * RePass: nodes_re_pass | |||||
| * GraphOneTime: nodes_last | |||||
| * NodeOneTime: nodes_re_pass_immediately, nodes_resume | |||||
| */ | |||||
| struct GraphLevelState { | |||||
| std::unordered_set<NodePtr> nodes_deleted; | |||||
| std::unordered_set<Node *> nodes_seen; | |||||
| std::unordered_set<NodePtr> nodes_passed; | |||||
| std::unordered_set<NodePtr> nodes_suspend; | |||||
| std::unordered_set<NodePtr> nodes_last; | |||||
| std::deque<NodePtr> nodes; | |||||
| int re_pass_times; | |||||
| void AddNodeToQueueFront(NodePtr node) { | |||||
| nodes_seen.insert(node.get()); | |||||
| nodes.emplace_front(std::move(node)); | |||||
| } | |||||
| void AddNodeToQueue(NodePtr node) { | |||||
| nodes_seen.insert(node.get()); | |||||
| nodes.emplace_back(std::move(node)); | |||||
| } | |||||
| void AddNodeToQueueIfNotSeen(NodePtr node) { | |||||
| if (nodes_seen.insert(node.get()).second) { | |||||
| nodes.emplace_back(std::move(node)); | |||||
| } | |||||
| } | |||||
| NodePtr PopFront() { | |||||
| NodePtr node = nodes.front(); | |||||
| nodes.pop_front(); | |||||
| return node; | |||||
| } | |||||
| }; | |||||
| struct RepassLevelState { | |||||
| std::vector<NodePtr> nodes_re_pass; | |||||
| std::unordered_set<NodePtr> nodes_re_pass_set; | |||||
| bool AddNodeToRepass(NodePtr node) { | |||||
| if (!nodes_re_pass_set.insert(node).second) { | |||||
| return false; | |||||
| } | |||||
| nodes_re_pass.emplace_back(node); | |||||
| return true; | |||||
| } | |||||
| void EraseNodeFromRepass(NodePtr node) { | |||||
| nodes_re_pass_set.erase(node); | |||||
| } | |||||
| void ClearRepass() { | |||||
| nodes_re_pass_set.clear(); | |||||
| nodes_re_pass.clear(); | |||||
| } | |||||
| }; | |||||
| struct GraphOneTimeLevelState { | |||||
| std::unordered_set<NodePtr> nodes_last; | |||||
| }; | |||||
| private: | private: | ||||
| GEPass(ComputeGraphPtr &graph, ComputeGraphPtr &root_graph, int depth) | GEPass(ComputeGraphPtr &graph, ComputeGraphPtr &root_graph, int depth) | ||||
| : graph_(graph), root_graph_(root_graph), depth_(depth) {} | : graph_(graph), root_graph_(root_graph), depth_(depth) {} | ||||
| Status RunPassesNodeOnce(NodePtr &node, const NamesToPass &names_to_passes, | |||||
| GraphLevelState &g_state, RepassLevelState &rp_state); | |||||
| Status RunPassesGraphRepass(const NamesToPass &names_to_passes, GraphLevelState &g_state); | |||||
| Status RunPassesOneGraph(const NamesToPass &names_to_passes); | Status RunPassesOneGraph(const NamesToPass &names_to_passes); | ||||
| Status RunPassesOnSubGraph(const NodePtr &node, const NamesToPass &names_to_passes, bool &has_sub_graph); | Status RunPassesOnSubGraph(const NodePtr &node, const NamesToPass &names_to_passes, bool &has_sub_graph); | ||||
| Status RunPassesOnNode(NodePtr &node, const NamesToPass &names_to_passes, GraphLevelState &g_state, | |||||
| RepassLevelState &rp_state); | |||||
| Status HandleLeakedSuspendNodes(const NamesToPass &names_to_passes, GraphLevelState &g_state); | |||||
| ComputeGraphPtr graph_; | ComputeGraphPtr graph_; | ||||
| ComputeGraphPtr root_graph_; | ComputeGraphPtr root_graph_; | ||||
| int depth_; | int depth_; | ||||
| @@ -18,7 +18,7 @@ | |||||
| #include <string> | #include <string> | ||||
| #include <vector> | #include <vector> | ||||
| #include "graph/common/omg_util.h" | |||||
| #include "common/omg_util.h" | |||||
| #include "graph/utils/node_utils.h" | #include "graph/utils/node_utils.h" | ||||
| #include "graph/utils/tensor_utils.h" | #include "graph/utils/tensor_utils.h" | ||||
| #include "graph/utils/op_desc_utils.h" | #include "graph/utils/op_desc_utils.h" | ||||