Compare commits

...

18 Commits
master ... r1.0

Author SHA1 Message Date
  mindspore-ci-bot d2ab1c2819 !504 sync-code-1203 4 years ago
  wuweikang 078e3677b5 sync-code-1203 4 years ago
  mindspore-ci-bot 433521ddbf !149 modify cmakelists 4 years ago
  wuweikang 6554560693 modifly cmakelists 4 years ago
  mindspore-ci-bot 806ee7f877 !148 libpath modification for atlas env 4 years ago
  wuweikang 8cdc787496 libpath modification for atlas env 4 years ago
  mindspore-ci-bot 5d3588ed36 !122 Mindspore support to compile at ascendcl 4 years ago
  zhoufeng af33ab7589 Mindspore support to compile at ascendcl 4 years ago
  mindspore-ci-bot 1b479e5d03 !106 speed up third party download via domestic source 4 years ago
  yanghaoran 0a529fa225 speed up third party download via domestic source 4 years ago
  mindspore-ci-bot 87f4fa2228 !93 Handle empty label resource 4 years ago
  zhoufeng b19551f3db handle empty label resource 4 years ago
  mindspore-ci-bot dfd23235fa !88 sync-from-trunk-to-blue-zone-1012-c75b220spc1009 4 years ago
  wuweikang 4ce0f3386f graphengine-281-sync-from-trunk-to-blue-zone-1012-c75b220spc1009 4 years ago
  mindspore-ci-bot e14f112a6d !87 sync from master to r1.0 4 years ago
  wuweikang 7337277390 sync from master to r1.0 4 years ago
  mindspore-ci-bot 9e8585f8ac !78 fix securec download links due to mistakes made by openeuler community 4 years ago
  yanghaoran ce4f118c83 fix securec download links due to mistakes made by openeuler community 4 years ago
100 changed files with 1938 additions and 507 deletions
Split View
  1. +15
    -3
      CMakeLists.txt
  2. +11
    -2
      cmake/external_libs/eigen.cmake
  3. +10
    -2
      cmake/external_libs/gtest.cmake
  4. +14
    -3
      cmake/external_libs/json.cmake
  5. +10
    -2
      cmake/external_libs/onnx.cmake
  6. +11
    -2
      cmake/external_libs/protobuf.cmake
  7. +2
    -2
      cmake/external_libs/securec.cmake
  8. +4
    -5
      inc/common/opskernel/ops_kernel_info_store.h
  9. +1
    -5
      inc/common/opskernel/ops_kernel_info_types.h
  10. +0
    -2
      inc/common/optimizer/graph_optimizer.h
  11. +1
    -1
      inc/external/ge/ge_api_error_codes.h
  12. +102
    -0
      inc/external/ge/ge_prof.h
  13. +0
    -2
      inc/external/graph/attr_value.h
  14. +10
    -13
      inc/external/graph/operator.h
  15. +0
    -1
      inc/external/graph/tensor.h
  16. +134
    -0
      inc/external/hccl/hccl.h
  17. +101
    -0
      inc/external/hccl/hccl_types.h
  18. +0
    -2
      inc/external/register/register.h
  19. +0
    -1
      inc/external/register/scope/scope_fusion_pass_register.h
  20. +8
    -4
      inc/framework/common/ge_inner_error_codes.h
  21. +2
    -0
      inc/framework/common/ge_types.h
  22. +3
    -3
      inc/framework/common/string_util.h
  23. +18
    -0
      inc/framework/common/util.h
  24. +2
    -0
      inc/framework/executor/ge_executor.h
  25. +3
    -0
      inc/framework/omg/omg_inner_types.h
  26. +3
    -3
      inc/graph/buffer.h
  27. +0
    -2
      inc/graph/compute_graph.h
  28. +9
    -2
      inc/graph/debug/ge_attr_define.h
  29. +1
    -1
      inc/graph/detail/any_map.h
  30. +2
    -2
      inc/graph/detail/attributes_holder.h
  31. +3
    -3
      inc/graph/ge_attr_value.h
  32. +1
    -1
      inc/graph/node.h
  33. +2
    -1
      inc/graph/op_desc.h
  34. +3
    -0
      inc/graph/runtime_inference_context.h
  35. +1
    -0
      inc/graph/utils/op_desc_utils.h
  36. +1
    -1
      src/common/graph/CMakeLists.txt
  37. +1
    -1
      src/common/graph/compute_graph.cc
  38. +1
    -1
      src/common/graph/detail/attributes_holder.cc
  39. +6
    -3
      src/common/graph/format_refiner.cc
  40. +9
    -0
      src/common/graph/ge_attr_define.cc
  41. +12
    -17
      src/common/graph/ge_attr_value.cc
  42. +1
    -1
      src/common/graph/ge_tensor.cc
  43. +1
    -1
      src/common/graph/graph.mk
  44. +2
    -2
      src/common/graph/model_serialize.cc
  45. +38
    -21
      src/common/graph/node.cc
  46. +42
    -3
      src/common/graph/op_desc.cc
  47. +21
    -20
      src/common/graph/operator.cc
  48. +0
    -2
      src/common/graph/opsproto/opsproto_manager.cc
  49. +1
    -1
      src/common/graph/ref_relation.cc
  50. +33
    -0
      src/common/graph/runtime_inference_context.cc
  51. +7
    -1
      src/common/graph/shape_refiner.cc
  52. +10
    -14
      src/common/graph/tensor.cc
  53. +14
    -3
      src/common/graph/utils/ge_ir_utils.cc
  54. +1
    -2
      src/common/graph/utils/graph_utils.cc
  55. +61
    -12
      src/common/graph/utils/node_utils.cc
  56. +51
    -7
      src/common/graph/utils/op_desc_utils.cc
  57. +16
    -4
      src/ge/CMakeLists.txt
  58. +19
    -8
      src/ge/analyzer/analyzer.cc
  59. +2
    -0
      src/ge/analyzer/analyzer.h
  60. +4
    -0
      src/ge/client/CMakeLists.txt
  61. +5
    -1
      src/ge/client/ge_api.cc
  62. +369
    -0
      src/ge/client/ge_prof.cc
  63. +6
    -0
      src/ge/client/module.mk
  64. +1
    -0
      src/ge/common/CMakeLists.txt
  65. +3
    -8
      src/ge/common/dump/dump_manager.cc
  66. +0
    -1
      src/ge/common/dump/dump_manager.h
  67. +11
    -11
      src/ge/common/dump/dump_op.cc
  68. +34
    -3
      src/ge/common/dump/dump_properties.cc
  69. +18
    -0
      src/ge/common/dump/dump_properties.h
  70. +21
    -0
      src/ge/common/dump/dump_server.cc
  71. +1
    -1
      src/ge/common/ge/datatype_util.cc
  72. +6
    -3
      src/ge/common/ge/op_tiling_manager.cc
  73. +1
    -0
      src/ge/common/ge_common.mk
  74. +19
    -1
      src/ge/common/helper/model_cache_helper.cc
  75. +17
    -2
      src/ge/common/helper/model_helper.cc
  76. +9
    -19
      src/ge/common/profiling/profiling_manager.cc
  77. +6
    -0
      src/ge/common/properties_manager.cc
  78. +5
    -1
      src/ge/common/properties_manager.h
  79. +69
    -3
      src/ge/common/util.cc
  80. +4
    -1
      src/ge/executor/CMakeLists.txt
  81. +64
    -1
      src/ge/executor/ge_executor.cc
  82. +8
    -0
      src/ge/executor/module.mk
  83. +6
    -2
      src/ge/ge_inference.mk
  84. +1
    -1
      src/ge/ge_local_engine/CMakeLists.txt
  85. +57
    -32
      src/ge/ge_local_engine/engine/host_cpu_engine.cc
  86. +1
    -1
      src/ge/ge_local_engine/module.mk
  87. +12
    -2
      src/ge/ge_runner.mk
  88. +3
    -0
      src/ge/ge_runtime/runtime_model.cc
  89. +9
    -2
      src/ge/generator/ge_generator.cc
  90. +18
    -4
      src/ge/graph/build/memory/block_mem_assigner.cc
  91. +2
    -1
      src/ge/graph/build/memory/block_mem_assigner.h
  92. +199
    -159
      src/ge/graph/build/memory/graph_mem_assigner.cc
  93. +6
    -7
      src/ge/graph/build/memory/graph_mem_assigner.h
  94. +56
    -20
      src/ge/graph/build/task_generator.cc
  95. +2
    -1
      src/ge/graph/build/task_generator.h
  96. +0
    -2
      src/ge/graph/common/ge_call_wrapper.h
  97. +10
    -0
      src/ge/graph/execute/graph_execute.cc
  98. +2
    -0
      src/ge/graph/execute/graph_execute.h
  99. +33
    -22
      src/ge/graph/load/new_model_manager/data_dumper.cc
  100. +3
    -0
      src/ge/graph/load/new_model_manager/data_dumper.h

+ 15
- 3
CMakeLists.txt View File

@@ -69,10 +69,12 @@ elseif(DEFINED ENV{D_LINK_PATH})
find_library(mmpa libmmpa.so ${GE_LIB_PATH})
find_library(runtime libruntime.so ${GE_LIB_PATH})
find_library(msprof libmsprof.so ${GE_LIB_PATH})
find_library(msprofiler libmsprofiler.a ${GE_LIB_PATH})
find_library(register libregister.so ${GE_LIB_PATH})
find_library(hccl libhccl.so ${GE_LIB_PATH})
find_library(resource libresource.so ${GE_LIB_PATH})
find_library(error_manager liberror_manager.so ${GE_LIB_PATH})
find_library(adump_server libadump_server.a ${GE_LIB_PATH})
else()
# Ascend mode
if(DEFINED ENV{ASCEND_CUSTOM_PATH})
@@ -80,17 +82,27 @@ else()
else()
set(ASCEND_DIR /usr/local/Ascend)
endif()
set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64/common)
set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64)
set(ASCEND_DRIVER_DIR ${ASCEND_DIR}/driver/lib64/common ${ASCEND_DIR}/driver/lib64)
set(ASCEND_RUNTIME_DIR ${ASCEND_DIR}/fwkacllib/lib64 ${ASCEND_DIR}/acllib/lib64 ${ASCEND_DIR}/atc/lib64)
find_library(slog libslog.so ${ASCEND_DRIVER_DIR})
find_library(mmpa libmmpa.so ${ASCEND_DRIVER_DIR})
find_library(msprof libmsprof.so ${ASCEND_DRIVER_DIR})
find_library(msprofiler libmsprofiler.a ${ASCEND_RUNTIME_DIR})
find_library(hccl libhccl.so ${ASCEND_RUNTIME_DIR})
find_library(runtime libruntime.so ${ASCEND_RUNTIME_DIR})
find_library(register libregister.so ${ASCEND_RUNTIME_DIR})
find_library(resource libresource.so ${ASCEND_RUNTIME_DIR})
find_library(error_manager liberror_manager.so ${ASCEND_RUNTIME_DIR})
find_library(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR})
# for Atlas env
set(ASCEND_TOOLKIT_RUNTIME_DIR ${ASCEND_PATH}/ascend-toolkit/latest/fwkacllib/lib64)
find_library(msprofiler libmsprofiler.a ${ASCEND_TOOLKIT_RUNTIME_DIR})
find_library(hccl libhccl.so ${ASCEND_TOOLKIT_RUNTIME_DIR})
find_library(runtime libruntime.so ${ASCEND_TOOLKIT_RUNTIME_DIR})
find_library(register libregister.so ${ASCEND_TOOLKIT_RUNTIME_DIR})
find_library(resource libresource.so ${ASCEND_TOOLKIT_RUNTIME_DIR})
find_library(error_manager liberror_manager.so ${ASCEND_TOOLKIT_RUNTIME_DIR})
find_library(adump_server libadump_server.a ${ASCEND_TOOLKIT_RUNTIME_DIR})
endif()

# add compile flags


+ 11
- 2
cmake/external_libs/eigen.cmake View File

@@ -1,10 +1,19 @@
set(Eigen3_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(Eigen3_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(Eigen3_NS "ge_")

if (ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/eigen-git-mirrorsource/repository/archive/3.3.7.tar.gz")
set(MD5 "cf6552a5d90c1aca4b5e0b011f65ea93")
else()
set(REQ_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz")
set(MD5 "9e30f67e8531477de4117506fe44669b")
endif ()

graphengine_add_pkg(Eigen3
VER 3.3.7
URL https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.tar.gz
MD5 9e30f67e8531477de4117506fe44669b
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DBUILD_TESTING=OFF)

find_package(Eigen3 3.3.7 REQUIRED ${GE_FIND_NO_DEFAULT_PATH})


+ 10
- 2
cmake/external_libs/gtest.cmake View File

@@ -1,11 +1,19 @@
set(ge_gtest_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack")
set(ge_gtest_CFLAGS "-D_FORTIFY_SOURCE=2 -O2 -fstack-protector-all -Wl,-z,relro,-z,now,-z,noexecstack")

if (ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/googletest/repository/archive/release-1.8.0.tar.gz")
set(MD5 "89e13ca1aa48d370719d58010b83f62c")
else()
set(REQ_URL "https://github.com/google/googletest/archive/release-1.8.0.tar.gz")
set(MD5 "16877098823401d1bf2ed7891d7dce36")
endif ()

graphengine_add_pkg(ge_gtest
VER 1.8.0
LIBS gtest gtest_main
URL https://github.com/google/googletest/archive/release-1.8.0.tar.gz
MD5 16877098823401d1bf2ed7891d7dce36
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON
-DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON)



+ 14
- 3
cmake/external_libs/json.cmake View File

@@ -1,9 +1,20 @@
set(nlohmann_json_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(nlohmann_json_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")

if (ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/JSON-for-Modern-CPP/repository/archive/v3.6.1.zip")
set(MD5 "5bda78ce308e6cfcf614dcf1d5ff27a7")
set(INCLUDE "./include")
else()
set(REQ_URL "https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip")
set(MD5 "0dc903888211db3a0f170304cd9f3a89")
set(INCLUDE "./")
endif ()

graphengine_add_pkg(ge_nlohmann_json
VER 3.6.1
HEAD_ONLY ./
URL https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip
MD5 0dc903888211db3a0f170304cd9f3a89)
HEAD_ONLY ${INCLUDE}
URL ${REQ_URL}
MD5 ${MD5})
include_directories(${ge_nlohmann_json_INC})
add_library(graphengine::json ALIAS ge_nlohmann_json)

+ 10
- 2
cmake/external_libs/onnx.cmake View File

@@ -1,5 +1,13 @@
if (ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/ONNX/repository/archive/v1.6.0.tar.gz")
set(MD5 "1bdbcecdd68ea8392630467646776e02")
else()
set(REQ_URL "https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz")
set(MD5 "512f2779d6215d4a36f366b6b9acdf1e")
endif ()

graphengine_add_pkg(onnx
VER 1.6.0
HEAD_ONLY ./
URL https://github.com/onnx/onnx/releases/download/v1.6.0/onnx-1.6.0.tar.gz
MD5 512f2779d6215d4a36f366b6b9acdf1e)
URL ${REQ_URL}
MD5 ${MD5})

+ 11
- 2
cmake/external_libs/protobuf.cmake View File

@@ -5,12 +5,21 @@ set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
set(_ge_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

if (ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/protobuf_source/repository/archive/v3.8.0.tar.gz")
set(MD5 "eba86ae9f07ba5cfbaf8af3bc4e84236")
else()
set(REQ_URL "https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz")
set(MD5 "3d9e32700639618a4d2d342c99d4507a")
endif ()

graphengine_add_pkg(protobuf
VER 3.8.0
LIBS protobuf
EXE protoc
URL https://github.com/protocolbuffers/protobuf/archive/v3.8.0.tar.gz
MD5 3d9e32700639618a4d2d342c99d4507a
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_PATH ../cmake/
CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF)
set(CMAKE_CXX_FLAGS ${_ge_tmp_CMAKE_CXX_FLAGS})


+ 2
- 2
cmake/external_libs/securec.cmake View File

@@ -1,7 +1,7 @@
graphengine_add_pkg(securec
VER 1.1.10
URL https://gitee.com/openeuler/bounds_checking_function/repository/archive/v1.1.10.tar.gz
MD5 0782dd2351fde6920d31a599b23d8c91
URL https://gitee.com/openeuler/libboundscheck/repository/archive/v1.1.10.tar.gz
MD5 193f0ca5246c1dd84920db34d2d8249f
LIBS c_sec
PATCHES ${GE_SOURCE_DIR}/third_party/patch/securec/securec.patch001
CMAKE_OPTION "-DCMAKE_BUILD_TYPE=Release"


+ 4
- 5
inc/common/opskernel/ops_kernel_info_store.h View File

@@ -43,10 +43,10 @@ class OpsKernelInfoStore {
virtual ~OpsKernelInfoStore() {}

// initialize opsKernelInfoStore
virtual Status Initialize(const map<string, string> &options) = 0; /*lint -e148*/
virtual Status Initialize(const map<string, string> &options) = 0;

// close opsKernelInfoStore
virtual Status Finalize() = 0; /*lint -e148*/
virtual Status Finalize() = 0;

virtual Status CreateSession(const std::map<std::string, std::string> &session_options) { return SUCCESS; }

@@ -66,11 +66,10 @@ class OpsKernelInfoStore {
virtual void opsFlagCheck(const ge::Node &node, std::string &opsFlag){};

// memory allocation requirement
virtual Status CalcOpRunningParam(Node &node) = 0; /*lint -e148*/
virtual Status CalcOpRunningParam(Node &node) = 0;

// generate task for op。
virtual Status GenerateTask(const Node &node, RunContext &context,
std::vector<domi::TaskDef> &tasks) = 0; /*lint -e148*/
virtual Status GenerateTask(const Node &node, RunContext &context, std::vector<domi::TaskDef> &tasks) = 0;

// only call fe engine interface to compile single op
virtual Status CompileOp(vector<ge::NodePtr> &node_vec) { return SUCCESS; }


+ 1
- 5
inc/common/opskernel/ops_kernel_info_types.h View File

@@ -26,7 +26,6 @@
using std::string;

namespace ge {
/*lint -e148*/
struct RunContext {
rtModel_t model;
rtStream_t stream;
@@ -41,8 +40,6 @@ struct RunContext {
std::vector<rtLabel_t> graphLabelList; // all labels of graph, order by ge label id(0,1,...)
};

/*lint +e148*/

struct Task {
uint32_t id;
uint16_t type;
@@ -51,8 +48,7 @@ struct Task {
};

struct OpInfo {
string engine; // which engin
/*lint -e148*/
string engine; // which engin
string opKernelLib; // which opsKernelStore
int computeCost; // compute cost
bool flagPartial; // whether to support is related to shape


+ 0
- 2
inc/common/optimizer/graph_optimizer.h View File

@@ -27,7 +27,6 @@
using std::map;
using std::string;

/*lint -e148*/
namespace ge {
class GraphOptimizer {
public:
@@ -67,5 +66,4 @@ class GraphOptimizer {
virtual Status OptimizeFusedGraphAfterGraphSlice(ComputeGraph &graph) { return SUCCESS; }
};
} // namespace ge
/*lint +e148*/
#endif // INC_COMMON_OPTIMIZER_GRAPH_OPTIMIZER_H_

+ 1
- 1
inc/external/ge/ge_api_error_codes.h View File

@@ -70,7 +70,7 @@ using Status = uint32_t;

// General error code
GE_ERRORNO(0, 0, 0, 0, 0, SUCCESS, 0, "success");
GE_ERRORNO(0b11, 0b11, 0b111, 0xFF, 0b11111, FAILED, 0xFFF, "failed"); /*lint !e401*/
GE_ERRORNO(0b11, 0b11, 0b111, 0xFF, 0b11111, FAILED, 0xFFF, "failed");
} // namespace ge

#endif // INC_EXTERNAL_GE_GE_API_ERROR_CODES_H_

+ 102
- 0
inc/external/ge/ge_prof.h View File

@@ -0,0 +1,102 @@
/**
* 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 INC_EXTERNAL_GE_GE_PROF_H_
#define INC_EXTERNAL_GE_GE_PROF_H_

#include <map>
#include <string>
#include <vector>

#include "ge/ge_api_error_codes.h"

namespace ge {
enum ProfDataTypeConfig {
kProfTaskTime = 0x0002,
kProfAiCoreMetrics = 0x0004,
kProfAicpuTrace = 0x0008,
kProfTrainingTrace = 0x0800,
kProfHcclTrace = 0x1000
};

enum ProfilingAicoreMetrics {
kAicoreArithmaticThroughput = 0,
kAicorePipeline = 1,
kAicoreSynchronization = 2,
kAicoreMemory = 3,
kAicoreInternalMemory = 4,
kAicoreStall = 5
};

typedef struct ProfAicoreEvents ProfAicoreEvents;
typedef struct aclgrphProfConfig aclgrphProfConfig;

///
/// @ingroup AscendCL
/// @brief Initialize the profiling and set profiling configuration path
/// @param [in] profiler_path: configuration path of profiling
/// @param [in] length: length of configuration path
/// @return Status result of function
///
Status aclgrphProfInit(const char *profiler_path, uint32_t length);

///
/// @ingroup AscendCL
/// @brief Finalize profiling
/// @return Status result of function
///
Status aclgrphProfFinalize();

///
/// @ingroup AscendCL
/// @brief Create data of type aclgrphProfConfig
/// @param [in] deviceid_list: device id list
/// @param [in] device_nums: device numbers
/// @param [in] aicore_metrics: type of aicore metrics
/// @param [in] aicore_events: pointer to aicore events be reserved, only support NULL now
/// @param [in] data_type_config: modules need profiling
/// @return Status result of function
///
aclgrphProfConfig *aclgrphProfCreateConfig(uint32_t *deviceid_list, uint32_t device_nums,
ProfilingAicoreMetrics aicore_metrics, ProfAicoreEvents *aicore_events,
uint64_t data_type_config);

///
/// @ingroup AscendCL
/// @brief Destroy data of type aclgrphProfConfig
/// @param [in] profiler_config: config of profiling
/// @return Status result of function
///
Status aclgrphProfDestroyConfig(aclgrphProfConfig *profiler_config);

///
/// @ingroup AscendCL
/// @brief Start profiling of modules which is configured by profiler config
/// @param [in] profiler_config: config of profiling
/// @return Status result of function
///
Status aclgrphProfStart(aclgrphProfConfig *profiler_config);

///
/// @ingroup AscendCL
/// @brief Stop profiling of modules which is configured by profiler config
/// @param [in] profiler_config: config of profiling
/// @return Status result of function
///
Status aclgrphProfStop(aclgrphProfConfig *profiler_config);
} // namespace ge

#endif // INC_EXTERNAL_GE_GE_PROF_H_

+ 0
- 2
inc/external/graph/attr_value.h View File

@@ -34,7 +34,6 @@ using std::vector;

namespace ge {
class AttrValueImpl;
/*lint -e148*/
class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrValue {
public:
using INT = int64_t;
@@ -70,6 +69,5 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrValue {
VALUE_SET_GET_DEC(AttrValue::FLOAT)
#undef VALUE_SET_GET_DEC
};
/*lint +e148*/
} // namespace ge
#endif // INC_EXTERNAL_GRAPH_ATTR_VALUE_H_

+ 10
- 13
inc/external/graph/operator.h View File

@@ -63,7 +63,6 @@ using std::function;
using std::shared_ptr;
using std::string;

/*lint -e148*/
class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {
public:
friend class OperatorImpl;
@@ -91,7 +90,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {

explicit Operator(const string &type);

Operator(const string &name, const string &type); // lint !e148
Operator(const string &name, const string &type);

virtual ~Operator() = default;

@@ -104,7 +103,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {
// Only has one output index = 0
Operator &SetInput(const string &dst_name, const Operator &src_oprt);

Operator &SetInput(const string &dst_name, const Operator &src_oprt, const string &name); // lint !e148
Operator &SetInput(const string &dst_name, const Operator &src_oprt, const string &name);

Operator &SetInput(const string &dst_name, const Operator &src_oprt, uint32_t index);

@@ -128,22 +127,22 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {

TensorDesc GetOutputDesc(uint32_t index) const;

graphStatus UpdateOutputDesc(const string &name, const TensorDesc &tensor_desc); // lint !e148
graphStatus UpdateOutputDesc(const string &name, const TensorDesc &tensor_desc);

TensorDesc GetDynamicInputDesc(const string &name, uint32_t index) const;

graphStatus UpdateDynamicInputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); // lint !e148
graphStatus UpdateDynamicInputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc);

TensorDesc GetDynamicOutputDesc(const string &name, uint32_t index) const;

graphStatus UpdateDynamicOutputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc); // lint !e148
graphStatus UpdateDynamicOutputDesc(const string &name, uint32_t index, const TensorDesc &tensor_desc);

graphStatus InferShapeAndType(); // lint !e148
graphStatus InferShapeAndType();

void SetInferenceContext(const InferenceContextPtr &inference_context);
InferenceContextPtr GetInferenceContext() const;

graphStatus VerifyAllAttr(bool disable_common_verifier = false); // lint !e148
graphStatus VerifyAllAttr(bool disable_common_verifier = false);

size_t GetInputsSize() const;

@@ -256,20 +255,19 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {

void RequiredAttrRegister(const string &name);

graphStatus VerifyAll(); // lint !e148
graphStatus VerifyAll();

// Only has one output index = 0
Operator &SetInput(const string &dst_name, uint32_t dst_index, const Operator &src_oprt);

Operator &SetInput(const string &dst_name, uint32_t dst_index, const Operator &src_oprt,
const string &name); // lint !e148
Operator &SetInput(const string &dst_name, uint32_t dst_index, const Operator &src_oprt, const string &name);

void SubgraphRegister(const string &ir_name, bool dynamic);
void SubgraphCountRegister(const string &ir_name, uint32_t count);
void SetSubgraphBuilder(const string &ir_name, uint32_t index, const SubgraphBuilder &builder);

private:
Operator &SetInput(const string &dst_name, const OutHandler &out_handler); // lint !e148
Operator &SetInput(const string &dst_name, const OutHandler &out_handler);

OutHandler GetOutput(const string &name) const;

@@ -283,7 +281,6 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Operator {

std::shared_ptr<const Node> GetNode() const;
};
/*lint +e148*/
} // namespace ge

#endif // INC_EXTERNAL_GRAPH_OPERATOR_H_

+ 0
- 1
inc/external/graph/tensor.h View File

@@ -126,6 +126,5 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Tensor {
friend class TensorAdapter;
};
} // namespace ge
/*lint +e148*/

#endif // INC_EXTERNAL_GRAPH_TENSOR_H_

+ 134
- 0
inc/external/hccl/hccl.h View File

@@ -0,0 +1,134 @@
/**
* 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.
*/

/**
* @file hccl.h
* @brief HCCL API
*/

#ifndef HCCL_H_
#define HCCL_H_

#include <hccl/hccl_types.h>
#include <acl/acl.h>

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

/**
* @brief Initialize HCCL.
*
* @param clusterInfo A string identifying the cluster info file path, include file name.
* @param rank A integer identifying the identify for the rank.
* @param comm A pointer identifying the initialized communication resource.
* @return HcclResult
* @see HcclCommDestroy()
*/
extern HcclResult HcclCommInitClusterInfo(const char *clusterInfo, uint32_t rank, HcclComm *comm);

/**
* @brief Get hccl root info.
*
* @param rootInfo A pointer identifying the hccl root info.
* @return HcclResult
*/
extern HcclResult HcclGetRootInfo(HcclRootInfo *rootInfo);

/**
* @brief Initialize HCCL with root info.
*
* @param nRanks A integer identifying the rank size of the cluster.
* @param rootInfo A struct identifying the hccl root info.
* @param rank A integer identifying the identify for the rank.
* @param comm A pointer identifying the initialized communication resource.
* @return HcclResult
* @see HcclCommDestroy()
*/
extern HcclResult HcclCommInitRootInfo(uint32_t nRanks, const HcclRootInfo *rootInfo, uint32_t rank, HcclComm *comm);

/**
* @brief AllReduce operator.
*
* @param sendBuf A pointer identifying the input data address of the operator.
* @param recvBuf A pointer identifying the output data address of the operator.
* @param count An integer(u64) identifying the number of the output data.
* @param dataType The data type of the operator, must be one of the following types: int8, int16, int32, float16,
* float32.
* @param op The reduction type of the operator, must be one of the following types: sum, min, max, prod.
* @param comm A pointer identifying the communication resource based on.
* @param stream A pointer identifying the stream information.
* @return HcclResult
*/
extern HcclResult HcclAllReduce(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op,
HcclComm comm, aclrtStream stream);

/**
* @brief Broadcast operator.
*
* @param buf A pointer identifying the data address of the operator.
* @param count An integer(u64) identifying the number of the data.
* @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32.
* @param root An integer(u32) identifying the the root rank in the operator.
* @param comm A pointer identifying the communication resource based on
* @param stream A pointer identifying the stream information.
* @return HcclResult
*/
extern HcclResult HcclBroadcast(void *buf, uint64_t count, HcclDataType dataType, uint32_t root, HcclComm comm,
aclrtStream stream);

/**
* @brief ReduceScatter operator.
*
* @param sendBuf A pointer identifying the input data address of the operator.
* @param recvBuf A pointer identifying the output data address of the operator.
* @param recvCount An integer(u64) identifying the number of the output data.
* @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32.
* @param op The reduction type of the operator, must be one of the following types: sum, min, max, prod.
* @param comm A pointer identifying the communication resource based on.
* @param stream A pointer identifying the stream information.
* @return HcclResult
*/
extern HcclResult HcclReduceScatter(void *sendBuf, void *recvBuf, uint64_t recvCount, HcclDataType dataType,
HcclReduceOp op, HcclComm comm, aclrtStream stream);

/**
* @brief AllGather operator.
*
* @param sendBuf A pointer identifying the input data address of the operator.
* @param recvBuf A pointer identifying the output data address of the operator.
* @param sendCount An integer(u64) identifying the number of the input data.
* @param dataType The data type of the operator, must be one of the following types: int8, int32, float16, float32.
* @param comm A pointer identifying the communication resource based on.
* @param stream A pointer identifying the stream information.
* @return HcclResult
*/
extern HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm,
aclrtStream stream);

/**
* @brief Destroy HCCL comm
*
* @param comm A pointer identifying the communication resource targetting
* @return HcclResult
* @see HcclCommInitClusterInfo()
*/
extern HcclResult HcclCommDestroy(HcclComm comm);

#ifdef __cplusplus
}
#endif // __cplusplus
#endif // HCCL_H_

+ 101
- 0
inc/external/hccl/hccl_types.h View File

@@ -0,0 +1,101 @@
/**
* 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.
*/

/**
* @file hccl_types.h
* @brief HCCL data type definition
*
*/

#ifndef HCCL_TYPES_H_
#define HCCL_TYPES_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

/**
* @brief HCCL functions return value definition
*/
typedef enum {
HCCL_SUCCESS = 0, /**< success */
HCCL_E_PARA = 1, /**< parameter error */
HCCL_E_PTR = 2, /**< empty pointer */
HCCL_E_MEMORY = 3, /**< memory error */
HCCL_E_INTERNAL = 4, /**< internal error */
HCCL_E_NOT_SUPPORT = 5, /**< not support feature */
HCCL_E_NOT_FOUND = 6, /**< not found specific resource */
HCCL_E_UNAVAIL = 7, /**< resource unavailable */
HCCL_E_SYSCALL = 8, /**< call system interface error */
HCCL_E_TIMEOUT = 9, /**< timeout */
HCCL_E_OPEN_FILE_FAILURE = 10, /**< open file fail */
HCCL_E_TCP_CONNECT = 11, /**< tcp connect fail */
HCCL_E_ROCE_CONNECT = 12, /**< roce connect fail */
HCCL_E_TCP_TRANSFER = 13, /**< tcp transfer fail */
HCCL_E_ROCE_TRANSFER = 14, /**< roce transfer fail */
HCCL_E_RUNTIME = 15, /**< call runtime api fail */
HCCL_E_DRV = 16, /**< call driver api fail */
HCCL_E_PROFILING = 17, /**< call profiling api fail */
HCCL_E_CCE = 18, /**< call cce api fail */
HCCL_E_NETWORK = 19, /**< call network api fail */
HCCL_E_RESERVED /**< reserved */
} HcclResult;

/**
* @brief handle to HCCL communicator
*/
typedef void *HcclComm;

/**
* @brief HCCL Reduction opperation
*/
typedef enum {
HCCL_REDUCE_SUM = 0, /**< sum */
HCCL_REDUCE_PROD = 1, /**< prod */
HCCL_REDUCE_MAX = 2, /**< max */
HCCL_REDUCE_MIN = 3, /**< min */
HCCL_REDUCE_RESERVED /**< reserved */
} HcclReduceOp;

/**
* @brief HCCL data type
*/
typedef enum {
HCCL_DATA_TYPE_INT8 = 0, /**< int8 */
HCCL_DATA_TYPE_INT16 = 1, /**< int16 */
HCCL_DATA_TYPE_INT32 = 2, /**< int32 */
HCCL_DATA_TYPE_FP16 = 3, /**< fp16 */
HCCL_DATA_TYPE_FP32 = 4, /**< fp32 */
HCCL_DATA_TYPE_INT64 = 5, /**< int64 */
HCCL_DATA_TYPE_UINT64 = 6, /**< uint64 */
HCCL_DATA_TYPE_RESERVED /**< reserved */
} HcclDataType;

const uint32_t HCCL_ROOT_INFO_BYTES = 4108; // 4108: root info length

/**
* @brief HCCL root info
*/
typedef struct HcclRootInfoDef {
char internal[HCCL_ROOT_INFO_BYTES];
} HcclRootInfo;

#ifdef __cplusplus
}
#endif // __cplusplus
#endif // HCCL_TYPES_H_

+ 0
- 2
inc/external/register/register.h View File

@@ -40,7 +40,6 @@ using std::to_string;
using std::unique_ptr;
using std::vector;

/*lint -e148*/
namespace ge {
class Operator;
class TensorDesc;
@@ -159,5 +158,4 @@ namespace ge {
using OpRegistrationData = domi::OpRegistrationData;
using OpReceiver = domi::OpReceiver;
} // namespace ge
/*lint +e148*/
#endif // INC_EXTERNAL_REGISTER_REGISTER_H_

+ 0
- 1
inc/external/register/scope/scope_fusion_pass_register.h View File

@@ -301,7 +301,6 @@ class GE_FUNC_HOST_VISIBILITY GE_FUNC_DEV_VISIBILITY ScopeFusionPassRegistry {
private:
ScopeFusionPassRegistry();
class ScopeFusionPassRegistryImpl;
/*lint -e148*/
std::unique_ptr<ScopeFusionPassRegistryImpl> impl_;
friend class TensorFlowModelParser;
};


+ 8
- 4
inc/framework/common/ge_inner_error_codes.h View File

@@ -14,7 +14,6 @@
* limitations under the License.
*/

/*lint -e* */
#ifndef INC_FRAMEWORK_COMMON_GE_INNER_ERROR_CODES_H_
#define INC_FRAMEWORK_COMMON_GE_INNER_ERROR_CODES_H_

@@ -97,6 +96,7 @@ GE_ERRORNO_COMMON(INTERNAL_ERROR, 4, "Internal errors"); // 1343225
GE_ERRORNO_COMMON(CSEC_ERROR, 5, "Failed to call libc_sec API!"); // 1343225861
GE_ERRORNO_COMMON(TEE_ERROR, 6, "Failed to call tee API!"); // 1343225862
GE_ERRORNO_COMMON(END_OF_SEQUENCE, 7, "End of sequence!"); // 1343225863
GE_ERRORNO_COMMON(PATH_INVALID, 8, "Path is invalid!"); // 1343225864

// Error code for plugin manager
GE_ERRORNO_COMMON(GE_PLGMGR_PATH_INVALID, 30, "Path is invalid!"); // 1343225886
@@ -124,9 +124,13 @@ GE_ERRORNO_CLIENT(GE_CLI_GE_ALREADY_INITIALIZED, 10, "GE is already initialized.
GE_ERRORNO_CLIENT(GE_CLI_GE_NOT_INITIALIZED, 11, "GE is not yet initialized or is finalized."); // 1343229963

// Init module error code definition
GE_ERRORNO_INIT(GE_MULTI_INIT, 0, "Multiple initializations are not supported."); // 1343234048
GE_ERRORNO_INIT(GE_FINALIZE_NOT_INIT, 1, "Finalize is not allowed before initialization."); // 1343234049
GE_ERRORNO_INIT(GE_MULTI_FINALIZE, 2, "Multiple finalizations are not supported."); // 1343234050
GE_ERRORNO_INIT(GE_MULTI_INIT, 0, "Multiple initializations are not supported."); // 1343234048
GE_ERRORNO_INIT(GE_FINALIZE_NOT_INIT, 1, "Finalize is not allowed before initialization."); // 1343234049
GE_ERRORNO_INIT(GE_MULTI_FINALIZE, 2, "Multiple finalizations are not supported."); // 1343234050
GE_ERRORNO_INIT(GE_PROF_MULTI_INIT, 3, "Multiple profiling initializations are not supported."); // 1343234051
GE_ERRORNO_INIT(GE_PROF_NOT_INIT, 4, "Profing initializations have not been done."); // 1343234052
GE_ERRORNO_INIT(GE_PROF_MODE_CONFLICT, 5,
"Profiling command mode which is preferred is running, the api mode will not work."); // 1343234053

// Session module error code definition
GE_ERRORNO_SESSION(GE_SESS_INIT_FAILED, 0, "Failed to initialize session."); // 1343238144


+ 2
- 0
inc/framework/common/ge_types.h View File

@@ -48,6 +48,8 @@ enum OpEngineType {
ENGINE_AIVECTOR = 4 // not support
};

enum InputAippType { DATA_WITHOUT_AIPP = 0, DATA_WITH_STATIC_AIPP, DATA_WITH_DYNAMIC_AIPP, DYNAMIC_AIPP_NODE };

const char *const GE_ENGINE_ATTR_MEM_TYPE_HBM = "HBM";
const char *const GE_OPTION_EXEC_PLACEMENT = "ge.exec.placement";



+ 3
- 3
inc/framework/common/string_util.h View File

@@ -36,8 +36,8 @@ class StringUtils {
#endif
return s;
}
// lint -esym(551,*)
static std::string &Rtrim(std::string &s) { /*lint !e618*/
static std::string &Rtrim(std::string &s) {
#if __cplusplus >= 201103L
(void)s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) { return !std::isspace(c); }));
#else
@@ -45,7 +45,7 @@ class StringUtils {
#endif
return s;
}
// lint -esym(551,*)
///
/// @ingroup domi_common
/// @brief delete spaces at the beginning and end of a string


+ 18
- 0
inc/framework/common/util.h View File

@@ -398,6 +398,24 @@ bool CheckOutputPathValid(const std::string &file_path, const std::string &atc_p
/// @param [out] result
///
bool ValidateStr(const std::string &filePath, const std::string &mode);

///
/// @ingroup domi_common
/// @brief Check whether the file is normal file.
/// @param [in] file_path file path
/// @param [out] result
///
bool IsValidFile(const char *file_path);

///
/// @ingroup domi_common
/// @brief Check path invalid
/// @param [in] path, path to be checked
/// @param [in] length, length of path
/// @return 0 success
/// @return -1 fail
///
Status CheckPath(const char *path, size_t length);
} // namespace ge

#endif // INC_FRAMEWORK_COMMON_UTIL_H_

+ 2
- 0
inc/framework/executor/ge_executor.h View File

@@ -163,6 +163,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeExecutor {
ge::Status GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigInfo &aipp_info);
ge::Status GetModelAttr(uint32_t model_id, std::vector<std::string> &dynamic_output_shape_info);

ge::Status GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index);

ge::Status GetModelDescInfoForZeroCopy(uint32_t model_id, std::vector<ge::TensorDesc> &input_desc,
std::vector<ge::TensorDesc> &output_desc);



+ 3
- 0
inc/framework/omg/omg_inner_types.h View File

@@ -92,6 +92,9 @@ struct OmgContext {
std::map<std::string, std::vector<int32_t>> out_nodes_map;
// user-designate out nodes (this is used for determing the orders)
std::vector<std::pair<std::string, int32_t>> user_out_nodes;
// save the output node of the network, value = topName,
// topName indicates the output name of the operator.
std::vector<std::string> user_out_nodes_top_vec;
// net out nodes (where user_out_nodes or leaf nodes)
std::vector<std::string> net_out_nodes;
// net out nodes top names(only caffe has top)


+ 3
- 3
inc/graph/buffer.h View File

@@ -57,11 +57,11 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Buffer {

// For compatibility
inline const std::uint8_t *data() const { return GetData(); }
inline std::uint8_t *data() { return GetData(); } // lint !e659
inline std::uint8_t *data() { return GetData(); }
inline std::size_t size() const { return GetSize(); }
inline void clear() { return ClearBuffer(); }
uint8_t operator[](size_t index) const { // lint !e1022 !e1042
if (buffer_ != nullptr && index < buffer_->size()) { // lint !e574
uint8_t operator[](size_t index) const {
if (buffer_ != nullptr && index < buffer_->size()) {
return (uint8_t)(*buffer_)[index];
}
return 0xff;


+ 0
- 2
inc/graph/compute_graph.h View File

@@ -84,7 +84,6 @@ class ComputeGraph : public std::enable_shared_from_this<ComputeGraph>, public A

NodePtr FindNode(const std::string &name) const;
NodePtr FindFirstNodeMatchType(const std::string &name) const;
/*lint -e504*/
// AddNode with NodePtr
NodePtr AddNode(NodePtr node);
NodePtr AddNode(OpDescPtr op);
@@ -152,7 +151,6 @@ class ComputeGraph : public std::enable_shared_from_this<ComputeGraph>, public A
graphStatus InsertEventNodes();
bool operator==(const ComputeGraph &r_compute_graph) const;

/*lint +e504*/
const std::map<std::vector<std::string>, std::vector<std::string>> &GetShareParamLayer() const {
return params_share_map_;
}


+ 9
- 2
inc/graph/debug/ge_attr_define.h View File

@@ -14,7 +14,6 @@
* limitations under the License.
*/

/*lint -e618*/
#ifndef INC_GRAPH_DEBUG_GE_ATTR_DEFINE_H_
#define INC_GRAPH_DEBUG_GE_ATTR_DEFINE_H_

@@ -141,6 +140,11 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAM
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_AIPP_OUTPUTS;

GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_INPUT_DIMS;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_DYNAMIC_AIPP_INPUT_DIMS;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_DATA_RELATED_AIPP_MODE;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_DATA_AIPP_DATA_NAME_MAP;

GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_GRAPH_HAS_BEEN_ADDED;

GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_SESSION_GRAPH_ID;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_PARENT_GRAPH_NAME;
@@ -1047,6 +1051,10 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAM
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_OP_DEBUG_FLAG;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_OP_DEBUG_MODE;

// op dynamic input
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DYNAMIC_INPUT_START;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_DYNAMIC_INPUT_END;

// functional ops attr
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IF_THEN_BRANCH;
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_NAME_IF_ELSE_BRANCH;
@@ -1118,4 +1126,3 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY extern const std::string ATTR_ZER
} // namespace ge

#endif // INC_GRAPH_DEBUG_GE_ATTR_DEFINE_H_
/*lint +e618*/

+ 1
- 1
inc/graph/detail/any_map.h View File

@@ -38,7 +38,7 @@ class TypeID {
bool operator==(const TypeID &__arg) const { return type_ == __arg.type_; }

private:
explicit TypeID(string type) : type_(std::move(type)) {} // lint !e30 !e32
explicit TypeID(string type) : type_(std::move(type)) {}

string type_;
};


+ 2
- 2
inc/graph/detail/attributes_holder.h View File

@@ -50,7 +50,7 @@ class OpDef;
class GraphDef;
} // namespace proto

using ProtoAttrMap = ::google::protobuf::Map<::std::string, ::ge::proto::AttrDef>; // lint !e1073
using ProtoAttrMap = ::google::protobuf::Map<::std::string, ::ge::proto::AttrDef>;
using ProtoMsgOwner = std::shared_ptr<::google::protobuf::Message>;

template <class ProtoType>
@@ -147,7 +147,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY AttrHolder {
protected:
graphStatus AddRequiredAttr(const std::string &name);
const std::unordered_set<string> GetAllAttrNames() const;
const std::map<string, GeAttrValue> GetAllAttrs() const; // lint !e1073
const std::map<string, GeAttrValue> GetAllAttrs() const;

virtual ProtoAttrMapHelper MutableAttrMap() = 0;
virtual ConstProtoAttrMapHelper GetAttrMap() const = 0;


+ 3
- 3
inc/graph/ge_attr_value.h View File

@@ -310,7 +310,7 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeAttrValue {
VALUE_SET_GET_DEC(GeAttrValue::GRAPH)
VALUE_SET_GET_DEC(BYTES)
VALUE_SET_GET_DEC(NamedAttrs)
VALUE_SET_GET_DEC(ge::DataType) // lint !e665
VALUE_SET_GET_DEC(ge::DataType)
VALUE_SET_GET_DEC(vector<GeAttrValue::STR>)
VALUE_SET_GET_DEC(vector<GeAttrValue::INT>)
VALUE_SET_GET_DEC(vector<GeAttrValue::FLOAT>)
@@ -320,8 +320,8 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY GeAttrValue {
VALUE_SET_GET_DEC(vector<GeAttrValue::GRAPH>)
VALUE_SET_GET_DEC(vector<GeAttrValue::BYTES>)
VALUE_SET_GET_DEC(vector<NamedAttrs>)
VALUE_SET_GET_DEC(vector<vector<int64_t>>) // lint !e665
VALUE_SET_GET_DEC(vector<ge::DataType>) // lint !e665
VALUE_SET_GET_DEC(vector<vector<int64_t>>)
VALUE_SET_GET_DEC(vector<ge::DataType>)
#undef VALUE_SET_GET_DEC

GeIrProtoHelper<proto::AttrDef> value_;


+ 1
- 1
inc/graph/node.h View File

@@ -193,7 +193,7 @@ class Node : public std::enable_shared_from_this<Node> {
vector<OutDataAnchorPtr> out_data_anchors_;
InControlAnchorPtr in_control_anchor_;
OutControlAnchorPtr out_control_anchor_;
map<string, GeAttrValue> attrs_; // lint !e1073
map<string, GeAttrValue> attrs_;
bool has_init_{false};
bool host_node_{false};
bool anchor_status_updated_{false};


+ 2
- 1
inc/graph/op_desc.h View File

@@ -235,7 +235,8 @@ class OpDesc : public std::enable_shared_from_this<OpDesc>, public AttrHolder {
vector<string> GetOpInferDepends() const;

string GetInputNameByIndex(uint32_t index) const;

string GetValidInputNameByIndex(uint32_t index) const;
int GetValidInputIndexByName(const string &name) const;
int GetInputIndexByName(const string &name) const;

string GetOutputNameByIndex(uint32_t index) const;


+ 3
- 0
inc/graph/runtime_inference_context.h View File

@@ -23,6 +23,7 @@
#include <vector>
#include "external/graph/ge_error_codes.h"
#include "external/graph/tensor.h"
#include "ge_attr_value.h"

namespace ge {
class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY RuntimeInferenceContext {
@@ -32,10 +33,12 @@ class GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY RuntimeInferenceContext {
static void DestroyContext(const std::string &context_id);

graphStatus SetTensor(int64_t node_id, int output_id, Tensor &&tensor);
graphStatus GetTensor(int64_t node_id, int output_id, GeTensorPtr &tensor);
graphStatus GetTensor(int64_t node_id, int output_id, Tensor &tensor);

private:
std::map<int64_t, std::vector<Tensor>> tensors_;
std::map<int64_t, std::vector<GeTensorPtr>> ge_tensors_;
std::mutex mu_;

static std::map<std::string, std::unique_ptr<RuntimeInferenceContext>> contexts_;


+ 1
- 0
inc/graph/utils/op_desc_utils.h View File

@@ -53,6 +53,7 @@ class OpDescUtils {
static vector<GeTensorPtr> MutableWeights(const ge::NodePtr node);
static graphStatus SetWeights(ge::Node& node, const vector<ge::GeTensorPtr>& weights);
static graphStatus SetWeights(ge::NodePtr node, const vector<ge::GeTensorPtr>& weights);
static graphStatus SetWeights(ge::Node& node, const map<int, ge::GeTensorPtr>& weights_map);
static graphStatus ClearWeights(ge::NodePtr node);

static bool ClearInputDesc(ge::OpDescPtr op_desc, uint32_t index);


+ 1
- 1
src/common/graph/CMakeLists.txt View File

@@ -24,7 +24,7 @@ file(GLOB_RECURSE PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"../../proto/task.proto"
"../../proto/fwk_adaper.proto"
"../../proto/op_mapping_info.proto"
"../proto/dump_task.proto"
"../../proto/dump_task.proto"
)

file(GLOB_RECURSE ONNX_PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}


+ 1
- 1
src/common/graph/compute_graph.cc View File

@@ -658,7 +658,7 @@ ComputeGraph::UpdateOutputMapping(const std::map<uint32_t, uint32_t> &output_map
return GRAPH_FAILED;
}

size_t num = op_desc->GetInputsSize();
size_t num = op_desc->GetAllInputsSize();
for (size_t i = 0; i < num; i++) {
GeTensorDesc tensor = op_desc->GetInputDesc(i);
uint32_t cur_index = 0;


+ 1
- 1
src/common/graph/detail/attributes_holder.cc View File

@@ -28,7 +28,7 @@ using std::unordered_set;
void AttrHolder::CopyAttrsFrom(const AttrHolder &holder) { MutableAttrMap().CopyValueFrom(holder.GetAttrMap()); }
graphStatus AttrHolder::SetAttr(const std::string &name, const GeAttrValue &value) {
if (value.IsEmpty()) {
GELOGE(GRAPH_FAILED, "value is empty, key %s", name.c_str());
GELOGE(GRAPH_FAILED, "value is empty, key of the attr is %s", name.c_str());
return GRAPH_FAILED;
}
auto proto_map = MutableAttrMap().GetProtoMsg();


+ 6
- 3
src/common/graph/format_refiner.cc View File

@@ -149,9 +149,10 @@ graphStatus FormatRefiner::GetAnchorPoints(const ge::ComputeGraphPtr &graph, std
// consider special node save process
// get all input desc format
bool node_is_all_nd = false;
auto input_size = static_cast<uint32_t>(op_desc->GetInputsSize());
auto input_size = static_cast<uint32_t>(op_desc->GetAllInputsSize());
for (uint32_t i = 0; i < input_size; i++) {
// Operator pre-set format but not origin format
GE_IF_BOOL_EXEC(op_desc->MutableInputDesc(i) == nullptr, continue);
auto input_format = op_desc->MutableInputDesc(i)->GetFormat();
// Pre-save data node (only main graph data) and default infer fail
if (node_ptr->GetType() == DATA) {
@@ -164,6 +165,7 @@ graphStatus FormatRefiner::GetAnchorPoints(const ge::ComputeGraphPtr &graph, std
// Get all output desc format
auto output_size = static_cast<uint32_t>(op_desc->GetOutputsSize());
for (uint32_t i = 0; i < output_size; i++) {
GE_IF_BOOL_EXEC(op_desc->MutableOutputDesc(i) == nullptr, continue);
auto output_format = op_desc->MutableOutputDesc(i)->GetFormat();
if (output_format != FORMAT_ND && output_format != FORMAT_RESERVED) {
node_is_all_nd = true;
@@ -222,8 +224,9 @@ graphStatus FormatRefiner::BackInferProcess(std::deque<ge::NodePtr> &nodes, ge::
for (const auto &in_anchor : node->GetAllInDataAnchors()) {
GELOGD("Node is [%s] [B]", (node->GetName()).c_str());
auto in_data_anchor_idx = in_anchor->GetIdx();
auto to_be_set_format =
node->GetOpDesc()->MutableInputDesc(static_cast<uint32_t>(in_data_anchor_idx))->GetOriginFormat();
auto input_desc = node->GetOpDesc()->MutableInputDesc(static_cast<uint32_t>(in_data_anchor_idx));
GE_IF_BOOL_EXEC(input_desc == nullptr, continue);
auto to_be_set_format = input_desc->GetOriginFormat();
if (to_be_set_format == FORMAT_ND) {
GELOGD("Node [%s] [B], format is ND", (node->GetName()).c_str());
continue;


+ 9
- 0
src/common/graph/ge_attr_define.cc View File

@@ -122,6 +122,11 @@ const std::string ATTR_NAME_AIPP_INPUTS = "_aipp_inputs";
const std::string ATTR_NAME_AIPP_OUTPUTS = "_aipp_outputs";

const std::string ATTR_NAME_INPUT_DIMS = "input_dims";
const std::string ATTR_DYNAMIC_AIPP_INPUT_DIMS = "_dynamic_aipp_input_dims";
const std::string ATTR_DATA_RELATED_AIPP_MODE = "_data_related_aipp_mode";
const std::string ATTR_DATA_AIPP_DATA_NAME_MAP = "_data_aipp_data_name_map";

const std::string ATTR_NAME_GRAPH_HAS_BEEN_ADDED = "_graph_has_been_added";

const std::string ATTR_NAME_SESSION_GRAPH_ID = "_session_graph_id";
const std::string ATTR_NAME_PARENT_GRAPH_NAME = "_parent_graph_name";
@@ -1055,6 +1060,10 @@ const std::string ATTR_NAME_HCCL_FUSED_FLAG = "_hccl_fused_node";
const std::string ATTR_DYNAMIC_SHAPE_FIXED_ADDR = "_alloc_fixed_addr";
const std::string ATTR_DYNAMIC_SHAPE_FIXED_ADDR_INDEX = "_alloc_fixed_addr_index";

// op dynamic input
const std::string ATTR_NAME_DYNAMIC_INPUT_START = "_dynamic_input_index_start";
const std::string ATTR_NAME_DYNAMIC_INPUT_END = "_dynamic_input_index_end";

// atc user def dtype&format
const std::string ATTR_ATC_USER_DEFINE_DATATYPE = "_user_defined_data_type";
const std::string ATTR_ATC_USER_DEFINE_FORMAT = "_user_defined_format";


+ 12
- 17
src/common/graph/ge_attr_value.cc View File

@@ -33,8 +33,7 @@ using std::vector;
namespace ge {
NamedAttrs::NamedAttrs() { named_attrs_.InitDefault(); }

NamedAttrs::NamedAttrs(const ProtoMsgOwner &owner, proto::NamedAttrs *proto_msg)
: named_attrs_(owner, proto_msg) {} // lint !e1744
NamedAttrs::NamedAttrs(const ProtoMsgOwner &owner, proto::NamedAttrs *proto_msg) : named_attrs_(owner, proto_msg) {}

void NamedAttrs::SetName(const std::string &name) {
auto proto_msg = named_attrs_.GetProtoMsg();
@@ -239,7 +238,7 @@ ATTR_VALUE_SET_GET_IMP(GeAttrValue::STR)
ATTR_VALUE_SET_GET_IMP(vector<GeAttrValue::STR>)
ATTR_VALUE_SET_GET_IMP(GeAttrValue::INT)
ATTR_VALUE_SET_GET_IMP(vector<GeAttrValue::INT>)
ATTR_VALUE_SET_GET_IMP(GeAttrValue::FLOAT) // lint !e524
ATTR_VALUE_SET_GET_IMP(GeAttrValue::FLOAT)
ATTR_VALUE_SET_GET_IMP(vector<GeAttrValue::FLOAT>)
ATTR_VALUE_SET_GET_IMP(GeAttrValue::BOOL)
ATTR_VALUE_SET_GET_IMP(vector<GeAttrValue::BOOL>)
@@ -253,11 +252,9 @@ ATTR_VALUE_SET_GET_IMP(GeAttrValue::BYTES)
ATTR_VALUE_SET_GET_IMP(vector<GeAttrValue::BYTES>)
ATTR_VALUE_SET_GET_IMP(GeAttrValue::NAMED_ATTRS)
ATTR_VALUE_SET_GET_IMP(vector<GeAttrValue::NAMED_ATTRS>)
/*lint -e665*/
ATTR_VALUE_SET_GET_IMP(vector<vector<int64_t>>)
/*lint +e665*/
ATTR_VALUE_SET_GET_IMP(vector<DataType>) // lint !e665
ATTR_VALUE_SET_GET_IMP(GeAttrValue::DATA_TYPE) // lint !e665
ATTR_VALUE_SET_GET_IMP(vector<DataType>)
ATTR_VALUE_SET_GET_IMP(GeAttrValue::DATA_TYPE)

#undef ATTR_VALUE_SET_GET_IMP

@@ -785,14 +782,14 @@ bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoM
if (graph_def == nullptr) {
GELOGE(GRAPH_FAILED, "proto::GraphDef make shared failed");
graph_def = nullptr;
return false; // lint !e665
return false;
} else {
ModelSerializeImp imp;
imp.SetProtobufOwner(graph_def);
if (!imp.UnserializeGraph(graph, *graph_def)) {
GELOGE(GRAPH_FAILED, "UnserializeGraph Failed");
return false;
} // lint !e514
}
value = graph;
}
return true;
@@ -812,7 +809,7 @@ bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoM
if (graph_def == nullptr) {
GELOGE(GRAPH_FAILED, "proto::GraphDef make shared failed");
graph_def = nullptr;
return false; // lint !e665
return false;
} else {
ComputeGraphPtr graph = nullptr;
ModelSerializeImp imp;
@@ -820,7 +817,7 @@ bool GeAttrValueImp::GetValue(const proto::AttrDef &proto_attr_val, const ProtoM
if (!imp.UnserializeGraph(graph, *graph_def)) {
GELOGE(GRAPH_FAILED, "UnserializeGraph Failed");
return false;
} // lint !e514
}
value.push_back(graph);
}
}
@@ -972,9 +969,7 @@ ATTR_UTILS_SET_IMP(Tensor, GeTensor)
ATTR_UTILS_SET_GET_IMP(NamedAttrs, GeAttrValue::NAMED_ATTRS)
ATTR_UTILS_SET_GET_IMP(Bytes, Buffer)
ATTR_UTILS_SET_GET_IMP(Graph, ComputeGraphPtr)
/*lint -e665*/
ATTR_UTILS_SET_GET_IMP(ListListInt, vector<vector<int64_t>>)
/*lint +e665*/

ATTR_UTILS_SET_GET_IMP(ListInt, vector<int64_t>)
ATTR_UTILS_SET_IMP(ListInt, vector<int32_t>)
@@ -989,8 +984,8 @@ ATTR_UTILS_SET_IMP(ListTensor, vector<GeTensor>)
ATTR_UTILS_SET_GET_IMP(ListNamedAttrs, vector<GeAttrValue::NAMED_ATTRS>)
ATTR_UTILS_SET_GET_IMP(ListBytes, vector<Buffer>)
ATTR_UTILS_SET_GET_IMP(ListGraph, vector<ComputeGraphPtr>)
ATTR_UTILS_SET_GET_IMP(ListDataType, vector<ge::DataType>) // lint !e665
ATTR_UTILS_SET_GET_IMP(DataType, ge::DataType) // lint !e665
ATTR_UTILS_SET_GET_IMP(ListDataType, vector<ge::DataType>)
ATTR_UTILS_SET_GET_IMP(DataType, ge::DataType)

bool AttrUtils::SetListTensor(AttrHolderAdapter &&obj, const string &name,
std::initializer_list<ConstGeTensorPtr> &&value) {
@@ -1159,7 +1154,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY bool AttrUtils::GetListOpDesc(Con
}
for (const auto &item : bytes_vals) {
ModelSerialize serialize;
auto op_desc = serialize.UnserializeOpDesc(item.GetData(), item.GetSize()); // lint !e732
auto op_desc = serialize.UnserializeOpDesc(item.GetData(), item.GetSize());
value.push_back(op_desc);
}
return true;
@@ -1211,7 +1206,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY OpDescPtr AttrUtils::CloneOpDesc(
op_def = ComGraphMakeShared<proto::OpDef>();
if (op_def == nullptr) {
GELOGE(GRAPH_FAILED, "proto::OpDef make shared failed");
return nullptr; // lint !e665
return nullptr;
}
ModelSerializeImp imp;
(void)imp.SerializeOpDesc(org_op_desc, op_def.get());


+ 1
- 1
src/common/graph/ge_tensor.cc View File

@@ -431,7 +431,7 @@ graphStatus GeTensorDesc::GetShapeRange(std::vector<std::pair<int64_t, int64_t>>
return GRAPH_FAILED;
}
std::pair<int64_t, int64_t> pair({ele[0], ele[1]});
range.push_back(pair);
range.emplace_back(pair);
}

return GRAPH_SUCCESS;


+ 1
- 1
src/common/graph/graph.mk View File

@@ -33,7 +33,6 @@ COMMON_LOCAL_SRC_FILES := \
./utils/tuning_utils.cc \
./utils/graph_utils.cc \
./utils/ge_ir_utils.cc \
./utils/node_utils.cc \
./utils/op_desc_utils.cc \
./utils/type_utils.cc \
./utils/tensor_utils.cc \
@@ -44,6 +43,7 @@ COMMON_LOCAL_SRC_FILES := \
option/ge_context.cc \
option/ge_local_context.cc \
./runtime_inference_context.cc \
./utils/node_utils.cc \

COMMON_LOCAL_C_INCLUDES := \
proto/om.proto \


+ 2
- 2
src/common/graph/model_serialize.cc View File

@@ -409,13 +409,13 @@ bool ModelSerializeImp::HandleNodeNameRef() {
item.dst_node_name.c_str(), item.dst_in_index);
return false;
}
GE_CHK_BOOL_ONLY_LOG((src_anchor->LinkTo(dst_anchor) == GRAPH_SUCCESS), " linkTo failed."); // lint !e737
GE_CHK_BOOL_ONLY_LOG((src_anchor->LinkTo(dst_anchor) == GRAPH_SUCCESS), " linkTo failed.");
} else {
// Control edge
auto src_anchor = src_node_it->second->GetOutControlAnchor();
auto dst_anchor = item.dst_node->GetInControlAnchor();
if (src_anchor != nullptr && dst_anchor != nullptr) {
GE_CHK_BOOL_ONLY_LOG((src_anchor->LinkTo(dst_anchor) == GRAPH_SUCCESS), " linkTo failed."); // lint !e737
GE_CHK_BOOL_ONLY_LOG((src_anchor->LinkTo(dst_anchor) == GRAPH_SUCCESS), " linkTo failed.");
}
}
}


+ 38
- 21
src/common/graph/node.cc View File

@@ -68,7 +68,7 @@ graphStatus Node::Init() {
return GRAPH_SUCCESS;
}
GE_CHK_BOOL_EXEC(op_ != nullptr, return GRAPH_FAILED, "original OpDesc is nullptr");
size_t size = op_->GetInputsSize();
size_t size = op_->GetAllInputsSize();
for (size_t i = 0; i < size; i++) {
std::shared_ptr<InDataAnchor> anchor = ComGraphMakeShared<InDataAnchor>(shared_from_this(), i);
if (anchor == nullptr) {
@@ -305,13 +305,19 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::AddLinkFrom(con
GELOGE(GRAPH_FAILED, "add input desc failed.");
return GRAPH_FAILED;
}
std::shared_ptr<InDataAnchor> anchor = ComGraphMakeShared<InDataAnchor>(shared_from_this(), in_data_anchors_.size());
if (anchor == nullptr) {
GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, malloc shared_ptr failed.", out_anchors.size());
return GRAPH_FAILED;

if (index < GetAllInDataAnchors().size()) {
(void)out_anchors.at(0)->LinkTo(in_data_anchors_[index]);
} else {
std::shared_ptr<InDataAnchor> anchor =
ComGraphMakeShared<InDataAnchor>(shared_from_this(), in_data_anchors_.size());
if (anchor == nullptr) {
GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, malloc shared_ptr failed.", out_anchors.size());
return GRAPH_FAILED;
}
in_data_anchors_.push_back(anchor);
(void)out_anchors.at(0)->LinkTo(in_data_anchors_.back());
}
in_data_anchors_.push_back(anchor);
(void)out_anchors.at(0)->LinkTo(in_data_anchors_.back());

return GRAPH_SUCCESS;
}
@@ -347,20 +353,30 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus Node::AddLinkFrom(con
}

GE_CHECK_NOTNULL(op_);
auto op_desc = input_node->GetOpDesc();
GE_CHECK_NOTNULL(op_desc);

if (op_->AddInputDesc(name, op_desc->GetOutputDesc(0)) != GRAPH_SUCCESS) {
GELOGE(GRAPH_FAILED, "add input desc failed.");
return GRAPH_FAILED;
auto input_op_desc = input_node->GetOpDesc();
GE_CHECK_NOTNULL(input_op_desc);
auto index = op_->GetInputIndexByName(name);
if (index != -1) {
if (index >= static_cast<int>(in_data_anchors_.size())) {
GELOGE(GRAPH_FAILED, "op %s get input name %s 's index %d is illegal.", op_->GetName().c_str(), name.c_str(),
index);
return GRAPH_FAILED;
}
(void)out_anchors.at(0)->LinkTo(in_data_anchors_[index]);
} else {
std::shared_ptr<InDataAnchor> anchor =
ComGraphMakeShared<InDataAnchor>(shared_from_this(), in_data_anchors_.size());
if (anchor == nullptr) {
GELOGE(GRAPH_FAILED, "in_data_anchors_size is:%zu, malloc shared_ptr failed.", in_data_anchors_.size());
return GRAPH_FAILED;
}
in_data_anchors_.push_back(anchor);
(void)out_anchors.at(0)->LinkTo(in_data_anchors_.back());
}
std::shared_ptr<InDataAnchor> anchor = ComGraphMakeShared<InDataAnchor>(shared_from_this(), in_data_anchors_.size());
if (anchor == nullptr) {
GELOGE(GRAPH_FAILED, "out_anchor size is:%zu, malloc shared_ptr failed.", out_anchors.size());
if (op_->AddInputDesc(name, input_op_desc->GetOutputDesc(0)) != GRAPH_SUCCESS) {
GELOGE(GRAPH_FAILED, "add input desc failed.");
return GRAPH_FAILED;
}
in_data_anchors_.push_back(anchor);
(void)out_anchors.at(0)->LinkTo(in_data_anchors_.back());

return GRAPH_SUCCESS;
}
@@ -746,9 +762,10 @@ graphStatus Node::Verify() const {
if (!is_unknown_graph) {
for (const auto &in_anchor_ptr : GetAllInDataAnchors()) {
GE_IF_BOOL_EXEC(in_anchor_ptr == nullptr, GELOGW("in anchor ptr is null"); continue);
bool valid_anchor = op_->GetType() == data_type || op_->GetType() == aipp_data_type ||
op_->GetType() == const_type || op_->GetType() == variable_type ||
op_->IsOptionalInput(in_anchor_ptr->GetIdx()) || in_anchor_ptr->GetPeerAnchors().size() > 0;
bool valid_anchor =
op_->GetType() == data_type || op_->GetType() == aipp_data_type || op_->GetType() == const_type ||
op_->GetType() == variable_type || op_->IsOptionalInput(in_anchor_ptr->GetIdx()) ||
op_->MutableInputDesc(in_anchor_ptr->GetIdx()) == nullptr || in_anchor_ptr->GetPeerAnchors().size() > 0;
if (!valid_anchor) {
ErrorManager::GetInstance().ATCReportErrMessage("E11019", {"opname", "index"},
{GetName(), std::to_string(in_anchor_ptr->GetIdx())});


+ 42
- 3
src/common/graph/op_desc.cc View File

@@ -33,7 +33,6 @@ using std::shared_ptr;
using std::string;
using std::vector;

/*lint -save -e521 -e681 -e732 -e737*/
namespace ge {
const std::string ATTR_NAME_ID = "id";

@@ -347,7 +346,10 @@ graphStatus OpDesc::AddOptionalInputDesc(const string &name, const ge::GeTensorD

GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus
OpDesc::UpdateInputDesc(uint32_t index, const ge::GeTensorDesc &tensor_Desc) {
GE_CHK_BOOL_RET_STATUS((index < inputs_desc_.size()), GRAPH_FAILED, "The index is invalid. index[%u]", index);
if (index >= inputs_desc_.size()) {
GELOGW("The index is invalid. index[%u]", index);
return GRAPH_FAILED;
}

inputs_desc_[index] = ComGraphMakeShared<GeTensorDesc>(tensor_Desc);
if (inputs_desc_[index] == nullptr) {
@@ -675,7 +677,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY ConstGeTensorDescPtr OpDesc::GetI
return nullptr;
}
if (inputs_desc_[index]->IsValid() != GRAPH_SUCCESS) {
GELOGE(GRAPH_FAILED, "inputsDesc[%u] is InValid", index);
GELOGW("inputsDesc[%u] is InValid", index);
return nullptr;
} else {
return inputs_desc_[static_cast<size_t>(index)];
@@ -949,6 +951,43 @@ int OpDesc::GetInputIndexByName(const string &name) const {
return static_cast<int>(it_find->second);
}

int OpDesc::GetValidInputIndexByName(const string &name) const {
map<string, uint32_t> valid_input_name_idx{};
uint32_t j = 0;
for (size_t i = 0; i < GetAllInputsSize(); i++) {
if (MutableInputDesc(static_cast<uint32_t>(i)) != nullptr) {
auto valid_name = GetInputNameByIndex(static_cast<uint32_t>(i));
GE_CHK_BOOL_RET_STATUS_NOLOG(!valid_name.empty(), -1);
valid_input_name_idx.insert({valid_name, j});
j++;
}
}
auto it_find = valid_input_name_idx.find(name);
GE_CHK_BOOL_RET_STATUS_NOLOG(it_find != valid_input_name_idx.end(), -1);
return static_cast<int>(it_find->second);
}

string OpDesc::GetValidInputNameByIndex(uint32_t index) const {
map<string, uint32_t> valid_input_name_idx{};
uint32_t j = 0;
for (size_t i = 0; i < GetAllInputsSize(); i++) {
if (MutableInputDesc(static_cast<uint32_t>(i)) != nullptr) {
auto valid_name = GetInputNameByIndex(static_cast<uint32_t>(i));
GE_CHK_BOOL_RET_STATUS_NOLOG(!valid_name.empty(), "");
valid_input_name_idx.insert({valid_name, j});
j++;
}
}
auto it = valid_input_name_idx.begin();
for (; it != valid_input_name_idx.end(); ++it) {
if (it->second == index) {
break;
}
}
GE_CHK_BOOL_RET_STATUS_NOLOG(it != valid_input_name_idx.end(), "");
return it->first;
}

GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY string OpDesc::GetOutputNameByIndex(uint32_t index) const {
auto it = output_name_idx_.begin();
for (; it != output_name_idx_.end(); ++it) {


+ 21
- 20
src/common/graph/operator.cc View File

@@ -56,9 +56,6 @@ using std::string;
using std::to_string;
using std::vector;

/*lint -save -e529 -e728*/
/*lint -e446 -e732*/
/*lint -e665*/
namespace ge {
class OpIO {
public:
@@ -943,7 +940,7 @@ OperatorImplPtr Operator::GetOperatorImplPtr() const { return operator_impl_; }
GELOGW("set attr name %s failed.", name.c_str()); \
} \
return *this; \
} // lint !e665
}

#define OP_ATTR_GET_IMP(ArgType, AttrUtilsFun) \
graphStatus Operator::GetAttr(const string &name, ArgType attr_value) const { \
@@ -956,7 +953,7 @@ OperatorImplPtr Operator::GetOperatorImplPtr() const { return operator_impl_; }
return GRAPH_FAILED; \
} \
return GRAPH_SUCCESS; \
} // lint !e665
}

void Operator::BreakConnect() const {
if (operator_impl_ == nullptr) {
@@ -977,7 +974,7 @@ void Operator::BreakConnect() const {
if (!AttrUtils::Set##AttrUtilsFun(operator_impl_->GetOpDescImpl(), name, attr_value)) { \
GELOGW("reg attr name %s failed.", name.c_str()); \
} \
} // lint !e665
}

OP_ATTR_SET_IMP(int64_t, Int)
OP_ATTR_SET_IMP(int32_t, Int)
@@ -998,22 +995,22 @@ OP_ATTR_SET_IMP(const vector<vector<int64_t>> &, ListListInt)
OP_ATTR_SET_IMP(float, Float)
OP_ATTR_GET_IMP(float &, Float)
OP_ATTR_SET_IMP(const vector<float> &, ListFloat)
OP_ATTR_GET_IMP(vector<float> &, ListFloat) // lint !e665
OP_ATTR_GET_IMP(vector<float> &, ListFloat)

OP_ATTR_SET_IMP(bool, Bool)
OP_ATTR_GET_IMP(bool &, Bool)
OP_ATTR_SET_IMP(const vector<bool> &, ListBool)
OP_ATTR_GET_IMP(vector<bool> &, ListBool) // lint !e665
OP_ATTR_GET_IMP(vector<bool> &, ListBool)

OP_ATTR_SET_IMP(const string &, Str)
OP_ATTR_GET_IMP(string &, Str)
OP_ATTR_SET_IMP(const vector<string> &, ListStr)
OP_ATTR_GET_IMP(vector<string> &, ListStr) // lint !e665
OP_ATTR_GET_IMP(vector<string> &, ListStr)

OP_ATTR_SET_IMP(const GeAttrValue::NAMED_ATTRS &, NamedAttrs)
OP_ATTR_GET_IMP(GeAttrValue::NAMED_ATTRS &, NamedAttrs)
OP_ATTR_SET_IMP(const vector<GeAttrValue::NAMED_ATTRS> &, ListNamedAttrs)
OP_ATTR_GET_IMP(vector<GeAttrValue::NAMED_ATTRS> &, ListNamedAttrs) // lint !e665
OP_ATTR_GET_IMP(vector<GeAttrValue::NAMED_ATTRS> &, ListNamedAttrs)

OP_ATTR_REG_IMP(int64_t, Int)
OP_ATTR_REG_IMP(const vector<int64_t> &, ListInt)
@@ -1504,7 +1501,9 @@ class GraphBuilderImpl {
GE_CHK_BOOL_EXEC(dst_anchor != nullptr, return GRAPH_FAILED, "GetInDataAnchor failed.");

auto ret = GraphUtils::AddEdge(src_anchor, dst_anchor);
GE_CHK_BOOL_EXEC(ret == GRAPH_SUCCESS, return GRAPH_FAILED, "AddEdge failed.");
GE_CHK_BOOL_EXEC(ret == GRAPH_SUCCESS, return GRAPH_FAILED,
"from node[%s][%d] to node[%s][%d]AddEdge failed.", src_node_ptr->GetName().c_str(),
src_anchor->GetIdx(), dst_node_info->second->GetName().c_str(), dst_anchor->GetIdx());
}
}
auto out_control_anchor = src_node_ptr->GetOutControlAnchor();
@@ -1536,19 +1535,23 @@ inline bool HasSameNameNode(const ComputeGraphPtr &compute_graph) {
for (const auto &graph : compute_graph->GetAllSubgraphs()) {
std::set<string> node_names;
for (auto const &node : graph->GetDirectNode()) {
node_names.insert(node->GetName());
}
if (node_names.size() != graph->GetDirectNodesSize()) {
return true;
auto result = node_names.insert(node->GetName());
if (!result.second) {
GELOGE(GRAPH_FAILED, "graph %s has same name node%s", graph->GetName().c_str(), node->GetName().c_str());
return true;
}
}
}

std::set<string> node_names;
for (auto const &node : compute_graph->GetDirectNode()) {
node_names.insert(node->GetName());
auto result = node_names.insert(node->GetName());
if (!result.second) {
GELOGE(GRAPH_FAILED, "graph %s has same name node%s", compute_graph->GetName().c_str(), node->GetName().c_str());
return true;
}
}
return node_names.size() != compute_graph->GetDirectNodesSize();
return false;
}

ComputeGraphPtr GraphUtils::CreateGraphFromOperator(const string &name, const vector<ge::Operator> &inputs) {
@@ -1577,5 +1580,3 @@ void GraphUtils::BreakConnect(const std::map<OperatorImplPtr, NodePtr> &all_node
}
}
} // namespace ge
/*lint +e446 +e732*/
/*lint +e665*/

+ 0
- 2
src/common/graph/opsproto/opsproto_manager.cc View File

@@ -38,9 +38,7 @@ bool OpsProtoManager::Initialize(const std::map<std::string, std::string> &optio
return true;
}

/*lint -e1561*/
auto proto_iter = options.find("ge.opsProtoLibPath");
/*lint +e1561*/
if (proto_iter == options.end()) {
GELOGW("ge.opsProtoLibPath option not set, return.");
return false;


+ 1
- 1
src/common/graph/ref_relation.cc View File

@@ -56,7 +56,7 @@ class RefRelations::Impl {
}
return GRAPH_SUCCESS;
}
GELOGW("can not find any relations! key value is %s", lookup_key.c_str());
GELOGW("can not find any relations! key value of dest relation is %s", lookup_key.c_str());
return GRAPH_SUCCESS;
};
graphStatus BuildRefRelations(ge::ComputeGraph &root_graph);


+ 33
- 0
src/common/graph/runtime_inference_context.cc View File

@@ -15,6 +15,7 @@
*/

#include "graph/runtime_inference_context.h"
#include "graph/utils/tensor_adapter.h"
#include <cstdint>
#include "framework/common/debug/ge_log.h"

@@ -67,6 +68,14 @@ graphStatus RuntimeInferenceContext::SetTensor(int64_t node_id, int output_id, T

GELOGD("Set tensor for node_id = %ld, output_id = %d", node_id, output_id);
output_tensors[output_id] = std::move(tensor);

auto &output_ge_tensors = ge_tensors_[node_id];
if (static_cast<uint32_t>(output_id) >= output_ge_tensors.size()) {
output_ge_tensors.resize(output_id + 1);
}

GELOGD("Set ge tensor for node_id = %ld, output_id = %d", node_id, output_id);
output_ge_tensors[output_id] = TensorAdapter::AsGeTensorPtr(tensor);
return GRAPH_SUCCESS;
}

@@ -93,4 +102,28 @@ graphStatus RuntimeInferenceContext::GetTensor(int64_t node_id, int output_id, T
tensor = output_tensors[output_id];
return GRAPH_SUCCESS;
}

graphStatus RuntimeInferenceContext::GetTensor(int64_t node_id, int output_id, GeTensorPtr &tensor) {
if (output_id < 0) {
GELOGE(GRAPH_PARAM_INVALID, "Invalid output index: %d", output_id);
return GRAPH_PARAM_INVALID;
}

std::lock_guard<std::mutex> lk(mu_);
auto iter = ge_tensors_.find(node_id);
if (iter == ge_tensors_.end()) {
GELOGE(INTERNAL_ERROR, "Node not register. Id = %ld", node_id);
return INTERNAL_ERROR;
}

auto &output_tensors = iter->second;
if (static_cast<uint32_t>(output_id) >= output_tensors.size()) {
GELOGE(GRAPH_FAILED, "Node output is not registered. node_id = %ld, output index = %d", node_id, output_id);
return GRAPH_FAILED;
}

GELOGD("Get ge tensor for node_id = %ld, output_id = %d", node_id, output_id);
tensor = output_tensors[output_id];
return GRAPH_SUCCESS;
}
} // namespace ge

+ 7
- 1
src/common/graph/shape_refiner.cc View File

@@ -51,6 +51,9 @@ graphStatus ReverseBrushWhileBodySubGraph(const ConstNodePtr &node) {
for (const auto &node_sub : sub_graph_body->GetAllNodes()) {
for (size_t i = 0; i < node_sub->GetAllInDataAnchorsSize(); i++) {
auto input_desc = node_sub->GetOpDesc()->MutableInputDesc(i);
GE_IF_BOOL_EXEC(input_desc == nullptr,
GELOGW("Get null input by index %zu from node %s ", i, node_sub->GetName().c_str());
continue);
(void)input_desc->SetUnknownDimNumShape();
}
for (size_t i = 0; i < node_sub->GetAllOutDataAnchorsSize(); i++) {
@@ -376,10 +379,13 @@ graphStatus UpdateOpInputDesc(const ConstNodePtr &node_ptr) {
continue;
}
int peer_out_idx = peer_out_data_anchor->GetIdx();
auto in_desc = node_ptr->GetOpDesc()->MutableInputDesc(static_cast<uint32_t>(in_idx));
auto peer_out_desc = peer_out_data_node->GetOpDesc()->MutableOutputDesc(static_cast<uint32_t>(peer_out_idx));

// check shape and dtype continuity. do not stop process
auto in_desc = node_ptr->GetOpDesc()->MutableInputDesc(static_cast<uint32_t>(in_idx));
if (in_desc == nullptr) {
continue;
}
auto in_shape = in_desc->GetShape().GetDims();
auto in_dtype = in_desc->GetDataType();
auto peer_out_shape = peer_out_desc->GetShape().GetDims();


+ 10
- 14
src/common/graph/tensor.cc View File

@@ -178,18 +178,16 @@ int64_t Shape::GetShapeSize() const {
return 0;
}

TensorDesc::TensorDesc() {
impl = ComGraphMakeShared<TensorDescImpl>(); // lint !e665
}
TensorDesc::TensorDesc() { impl = ComGraphMakeShared<TensorDescImpl>(); }

TensorDesc::TensorDesc(Shape shape, Format format, DataType dt) {
impl = ComGraphMakeShared<TensorDescImpl>(shape, format, dt); // lint !e665
impl = ComGraphMakeShared<TensorDescImpl>(shape, format, dt);
SetRealDimCnt(shape.GetDimNum());
}

TensorDesc::TensorDesc(const TensorDesc &desc) {
// Copy
impl = ComGraphMakeShared<TensorDescImpl>(); // lint !e665
impl = ComGraphMakeShared<TensorDescImpl>();
if (desc.impl != nullptr && impl != nullptr) {
*impl = *desc.impl;
}
@@ -360,9 +358,7 @@ void TensorDesc::SetName(const std::string &name) {

Tensor::Tensor() { impl = ComGraphMakeShared<TensorImpl>(); }

Tensor::Tensor(const TensorDesc &tensor_desc) {
impl = ComGraphMakeShared<TensorImpl>(tensor_desc); // lint !e665
}
Tensor::Tensor(const TensorDesc &tensor_desc) { impl = ComGraphMakeShared<TensorImpl>(tensor_desc); }

Tensor::Tensor(const TensorDesc &tensor_desc, const std::vector<uint8_t> &data) {
uint64_t shape_size = tensor_desc.GetShape().GetShapeSize();
@@ -384,7 +380,7 @@ Tensor::Tensor(const TensorDesc &tensor_desc, const std::vector<uint8_t> &data)
}
}
}
impl = ComGraphMakeShared<TensorImpl>(tensor_desc, data); // lint !e665
impl = ComGraphMakeShared<TensorImpl>(tensor_desc, data);
}

Tensor::Tensor(const TensorDesc &tensor_desc, const uint8_t *data, size_t size) {
@@ -406,7 +402,7 @@ Tensor::Tensor(const TensorDesc &tensor_desc, const uint8_t *data, size_t size)
}
}

impl = ComGraphMakeShared<TensorImpl>(tensor_desc, data, size); // lint !e665
impl = ComGraphMakeShared<TensorImpl>(tensor_desc, data, size);
}

Tensor::Tensor(TensorDesc &&tensor_desc, std::vector<uint8_t> &&data) {
@@ -429,7 +425,7 @@ Tensor::Tensor(TensorDesc &&tensor_desc, std::vector<uint8_t> &&data) {
}
}
}
impl = ComGraphMakeShared<TensorImpl>(std::move(tensor_desc), std::move(data)); // lint !e665
impl = ComGraphMakeShared<TensorImpl>(std::move(tensor_desc), std::move(data));
}

TensorDesc Tensor::GetTensorDesc() const {
@@ -643,7 +639,7 @@ TensorDesc TensorAdapter::GeTensorDesc2TensorDesc(const GeTensorDesc &ge_tensor_
GeTensorPtr TensorAdapter::Tensor2GeTensor(const Tensor &tensor) {
GeTensorPtr ge_tensor;
if (tensor.impl != nullptr) {
ge_tensor = ComGraphMakeShared<GeTensor>(tensor.impl->ge_tensor.Clone()); // lint !e665
ge_tensor = ComGraphMakeShared<GeTensor>(tensor.impl->ge_tensor.Clone());
}
return ge_tensor;
}
@@ -659,7 +655,7 @@ Tensor TensorAdapter::GeTensor2Tensor(const ConstGeTensorPtr &ge_tensor) {
ConstGeTensorPtr TensorAdapter::AsGeTensorPtr(const Tensor &tensor) {
GeTensorPtr ge_tensor;
if (tensor.impl != nullptr) {
ge_tensor = ComGraphMakeShared<GeTensor>(tensor.impl->ge_tensor); // lint !e665
ge_tensor = ComGraphMakeShared<GeTensor>(tensor.impl->ge_tensor);
}
return ge_tensor;
}
@@ -667,7 +663,7 @@ ConstGeTensorPtr TensorAdapter::AsGeTensorPtr(const Tensor &tensor) {
GeTensorPtr TensorAdapter::AsGeTensorPtr(Tensor &tensor) {
GeTensorPtr ge_tensor;
if (tensor.impl != nullptr) {
ge_tensor = ComGraphMakeShared<GeTensor>(tensor.impl->ge_tensor); // lint !e665
ge_tensor = ComGraphMakeShared<GeTensor>(tensor.impl->ge_tensor);
}
return ge_tensor;
}


+ 14
- 3
src/common/graph/utils/ge_ir_utils.cc View File

@@ -264,11 +264,11 @@ void OnnxUtils::AddAttrProtoForOpInAndOutDesc(onnx::NodeProto *node_proto, const
return;
}
// Input describes
auto size_in = op_desc->GetInputsSize();
auto size_in = op_desc->GetAllInputsSize();
AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INT, "input_desc_nums", &size_in);
if (size_in > 0) {
for (uint32_t i = 0; i < size_in; i++) {
auto input_desc = op_desc->GetInputDescPtr(i);
auto input_desc = op_desc->GetInputDescPtrDfault(i);
if (input_desc != nullptr) {
auto data_type = TypeUtils::DataTypeToSerialString(input_desc->GetDataType());
AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRING, "input_desc_dtype:" + std::to_string(i),
@@ -480,9 +480,20 @@ void OnnxUtils::AddAttrProtoFromNodeMembers(const NodePtr &node, onnx::NodeProto
if (!recv_list.empty()) {
AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "recv_event_id_list", &recv_list);
}
// 2.Attributes added from node's op_(message OpDef)
auto op_desc = node->op_;
if (op_desc != nullptr) {
// for input_name_idx_ in opdesc
auto input_name_2_indexs = op_desc->GetAllInputName();
::google::protobuf::RepeatedPtrField<::std::string> input_names;
::google::protobuf::RepeatedField<::google::protobuf::int64> input_indexes;
for (const auto &input_name_2_index : input_name_2_indexs) {
std::string input_name = input_name_2_index.first;
input_names.Add(std::move(input_name));
input_indexes.Add(input_name_2_index.second);
}
AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_STRINGS, "_input_name_key", input_names);
AddAttrProto(node_proto, onnx::AttributeProto_AttributeType_INTS, "_input_name_value", input_indexes);
// 2.Attributes added from node's op_(message OpDef)
// Input and out describes
AddAttrProtoForOpInAndOutDesc(node_proto, op_desc);
// Others


+ 1
- 2
src/common/graph/utils/graph_utils.cc View File

@@ -1470,8 +1470,7 @@ graphStatus GraphUtils::CopyTensorAttrs(const OpDescPtr &dst_desc, const NodePtr
for (uint32_t i = 0; i < src_node->GetAllInDataAnchorsSize(); ++i) {
auto input_desc = dst_desc->MutableInputDesc(i);
if (input_desc == nullptr) {
GELOGE(GRAPH_FAILED, "Param dst node not valid");
return GRAPH_FAILED;
continue;
}
input_desc->CopyAttrsFrom(src_desc->GetInputDesc(i));
}


+ 61
- 12
src/common/graph/utils/node_utils.cc View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/

#include "utils/node_utils.h"
#include "utils/op_desc_utils.h"
#include "graph/utils/node_utils.h"
#include "graph/utils/op_desc_utils.h"
#include "graph/utils/graph_utils.h"
#include "debug/ge_op_types.h"
#include "debug/ge_util.h"
@@ -23,8 +23,13 @@
#include "graph/anchor.h"
#include "graph/debug/ge_attr_define.h"
#include "graph/types.h"
#include "utils/tensor_utils.h"
#include "utils/type_utils.h"
#include "external/graph/operator.h"
#include "graph/ge_context.h"
#include "graph/runtime_inference_context.h"
#include "graph/utils/op_desc_utils.h"
#include "graph/utils/tensor_utils.h"
#include "graph/utils/tensor_adapter.h"
#include "graph/utils/type_utils.h"

namespace ge {
std::map<NodePtr, std::vector<uint32_t>> NodeUtils::map_send_info_{};
@@ -575,6 +580,58 @@ graphStatus NodeUtils::GetNodeUnknownShapeStatus(const Node &node, bool &is_unkn
return GRAPH_SUCCESS;
}

graphStatus NodeUtils::GetInputConstData(const ConstNodePtr &node_ptr, const string &dst_name, GeTensorPtr &ge_tensor) {
GE_CHECK_NOTNULL(node_ptr);
return NodeUtils::GetInputConstData(*node_ptr, dst_name, ge_tensor);
}

graphStatus NodeUtils::GetInputConstData(const Node &node, const string &dst_name, GeTensorPtr &ge_tensor) {
// For inner compute graph
auto op_desc = node.GetOpDesc();
GE_CHECK_NOTNULL(op_desc);
auto index = op_desc->GetInputIndexByName(dst_name);
auto in_data_anchor = node.GetInDataAnchor(index);
GE_CHECK_NOTNULL(in_data_anchor);
auto out_data_anchor = in_data_anchor->GetPeerOutAnchor();
GE_CHECK_NOTNULL(out_data_anchor);
auto peer_node = out_data_anchor->GetOwnerNode();
GE_CHECK_NOTNULL(peer_node);
auto peer_op_desc = peer_node->GetOpDesc();
GE_CHECK_NOTNULL(peer_op_desc);
auto peer_op_type = peer_op_desc->GetType();
if (peer_op_type == CONSTANTOP || peer_op_type == CONSTANT) {
if (!AttrUtils::MutableTensor(peer_node->GetOpDesc(), ATTR_NAME_WEIGHTS, ge_tensor)) {
GELOGW("get attr name %s failed.", ATTR_NAME_WEIGHTS.c_str());
return GRAPH_FAILED;
}
return GRAPH_SUCCESS;
} else if (peer_op_type == DATA) {
auto parent_node = NodeUtils::GetParentInput(peer_node);
while ((parent_node != nullptr) && (parent_node->GetType() == DATA)) {
parent_node = NodeUtils::GetParentInput(parent_node);
}
if ((parent_node != nullptr) && ((parent_node->GetType() == CONSTANT) || (parent_node->GetType() == CONSTANTOP))) {
if (!AttrUtils::MutableTensor(parent_node->GetOpDesc(), ATTR_NAME_WEIGHTS, ge_tensor)) {
GELOGW("get attr name %s failed.", ATTR_NAME_WEIGHTS.c_str());
return GRAPH_FAILED;
}
return GRAPH_SUCCESS;
}
}
// Try get from runtime inference context
auto session_id = std::to_string(GetContext().SessionId());
RuntimeInferenceContext *runtime_infer_ctx = nullptr;
if (RuntimeInferenceContext::GetContext(session_id, &runtime_infer_ctx) == GRAPH_SUCCESS) {
GELOGD("To get constant from runtime inference context. session_id = %s", session_id.c_str());
auto ret = runtime_infer_ctx->GetTensor(peer_node->GetOpDesc()->GetId(), out_data_anchor->GetIdx(), ge_tensor);
if (ret == GRAPH_SUCCESS) {
return GRAPH_SUCCESS;
}
}
GELOGW("node[%s]'s input[%s]'s peer node is not const", node.GetName().c_str(), dst_name.c_str());
return GRAPH_FAILED;
}

std::string NodeUtils::GetNodeType(const Node &node) {
if (node.GetType() != FRAMEWORKOP) {
return node.GetType();
@@ -587,14 +644,6 @@ std::string NodeUtils::GetNodeType(const Node &node) {

std::string NodeUtils::GetNodeType(const NodePtr &node) { return node == nullptr ? "" : GetNodeType(*node); }

graphStatus NodeUtils::GetInputConstData(const ConstNodePtr &node_ptr, const string &dst_name, GeTensorPtr &ge_tensor) {
return GRAPH_SUCCESS;
}

graphStatus NodeUtils::GetInputConstData(const Node &node, const string &dst_name, GeTensorPtr &ge_tensor) {
return GRAPH_SUCCESS;
}

ComputeGraphPtr NodeUtils::GetSubgraph(const Node &node, uint32_t index) {
auto op_desc = node.GetOpDesc();
if (op_desc == nullptr) {


+ 51
- 7
src/common/graph/utils/op_desc_utils.cc View File

@@ -28,7 +28,6 @@

using std::vector;

/*lint -e512 -e737 -e752*/
namespace ge {
const char OP_DESC_QUANT_PARAMS[] = "quantize_factor";
static const int CONST_OP_NORMAL_WEIGHT_SIZE = 1;
@@ -133,11 +132,11 @@ graphStatus OpDescUtils::GetQuantizeFactorParams(const OpDesc &op_desc, Quantize
GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus
OpDescUtils::SetQuantizeFactorParams(const OpDescPtr &op_desc, const QuantizeFactorParams &quant) {
GE_CHK_BOOL_EXEC_INFO(op_desc != nullptr, return GRAPH_FAILED, "op_desc is nullptr");
return op_desc->SetAttr(OP_DESC_QUANT_PARAMS, GeAttrValue::CreateFrom<QuantizeFactorParams>(quant)); // lint !e732
return op_desc->SetAttr(OP_DESC_QUANT_PARAMS, GeAttrValue::CreateFrom<QuantizeFactorParams>(quant));
}

graphStatus OpDescUtils::SetQuantizeFactorParams(OpDesc &op_desc, const QuantizeFactorParams &quant) {
return op_desc.SetAttr(OP_DESC_QUANT_PARAMS, GeAttrValue::CreateFrom<QuantizeFactorParams>(quant)); // lint !e732
return op_desc.SetAttr(OP_DESC_QUANT_PARAMS, GeAttrValue::CreateFrom<QuantizeFactorParams>(quant));
}

GeTensorPtr OpDescUtils::MutableWeights(OpDesc &op_desc) {
@@ -255,7 +254,7 @@ size_t OpDescUtils::GetNonConstInputsSize(const ge::Node &node) {
continue;
}
}
return input_num; // lint !e712
return input_num;
} else {
GE_IF_BOOL_EXEC(
node.GetInDataNodes().size() < GetConstInputs(node).size(),
@@ -360,7 +359,7 @@ bool OpDescUtils::IsNonConstInput(const ge::Node &node, const size_t index) {
bool ret = false;
if (index < node.GetAllInDataAnchors().size()) {
if (NodeUtils::IsAnchorStatusSet(node)) {
ret = (ge::AnchorUtils::GetStatus(node.GetInDataAnchor(static_cast<int>(index))) == ANCHOR_DATA); // lint !e712
ret = (ge::AnchorUtils::GetStatus(node.GetInDataAnchor(static_cast<int>(index))) == ANCHOR_DATA);
} else {
for (const auto &anchor : node.GetAllInDataAnchors()) {
if (anchor->GetIdx() != static_cast<int>(index)) {
@@ -513,7 +512,6 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY vector<GeTensorPtr> OpDescUtils::
}
return MutableWeights(*node);
}

GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus
OpDescUtils::SetWeights(ge::Node &node, const vector<ge::GeTensorPtr> &weights) {
GE_CHK_BOOL_EXEC(node.GetOpDesc() != nullptr, return GRAPH_PARAM_INVALID, "node.GetOpDesc is nullptr!");
@@ -561,6 +559,53 @@ OpDescUtils::SetWeights(ge::Node &node, const vector<ge::GeTensorPtr> &weights)
return GRAPH_SUCCESS;
}

GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus
OpDescUtils::SetWeights(ge::Node &node, const map<int, ge::GeTensorPtr> &weights_map) {
GE_CHECK_NOTNULL(node.GetOpDesc());
// 1. node is const
if (node.GetOpDesc()->GetType() == CONSTANT) {
if (weights_map.size() == CONST_OP_NORMAL_WEIGHT_SIZE) {
return SetWeights(node.GetOpDesc(), weights_map.begin()->second);
}
GELOGE(GRAPH_PARAM_INVALID, "const op %s weight size %zu should be 1", node.GetName().c_str(), weights_map.size());
return GRAPH_PARAM_INVALID;
}
// 2. node is not const
for (const auto &pair : weights_map) {
auto in_data_anchor = node.GetInDataAnchor(pair.first);
if (in_data_anchor != nullptr && in_data_anchor->GetPeerOutAnchor() != nullptr) {
// a. update const input node
auto out_anchor = in_data_anchor->GetPeerOutAnchor();
auto peer_node = out_anchor->GetOwnerNode();
if (peer_node == nullptr) {
GELOGE(GRAPH_PARAM_INVALID, "op %s [%d]'s input node is null", node.GetName().c_str(), pair.first);
return GRAPH_PARAM_INVALID;
}
if (peer_node->GetType() != CONSTANT) {
GELOGE(GRAPH_PARAM_INVALID, " op %s [%d]'s input node should be const, but is %s type:%s ",
node.GetName().c_str(), pair.first, peer_node->GetName().c_str(), peer_node->GetType().c_str());
}
SetWeights(peer_node->GetOpDesc(), pair.second);
} else {
// b. create new const input node
auto const_opdesc = CreateConstOp(pair.second);
GE_CHECK_NOTNULL(const_opdesc);
auto owner_graph = node.GetOwnerComputeGraph();
if (owner_graph == nullptr) {
GELOGE(GRAPH_PARAM_INVALID, "node's graph is empty, name: %s", node.GetName().c_str());
return GRAPH_PARAM_INVALID;
}
auto const_node = owner_graph->AddNodeFront(const_opdesc);
if (node.AddLinkFrom(static_cast<uint32_t>(pair.first), const_node) != GRAPH_SUCCESS) {
GELOGE(GRAPH_FAILED, "op %s add const to input index[%d] failed", node.GetName().c_str(), pair.first);
return GRAPH_FAILED;
}
}
}
NodeUtils::UpdateIsInputConst(node);
return GRAPH_SUCCESS;
}

OpDescPtr OpDescUtils::CreateConstOp(const GeTensorPtr &tensor_ptr) {
GE_CHK_BOOL_EXEC(tensor_ptr != nullptr, return nullptr, "tensor_ptr is nullptr!");
shared_ptr<OpDesc> const_opdesc = ComGraphMakeShared<OpDesc>();
@@ -776,4 +821,3 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus OpDescUtils::SetSubgr
return op_desc->SetSubgraphInstanceName(iter->second, subgraph_instance_name);
}
} // namespace ge
/*lint +e512 +e737 +e752*/

+ 16
- 4
src/ge/CMakeLists.txt View File

@@ -51,6 +51,7 @@ include_directories(${GE_SOURCE_DIR}/inc/graph)
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib)
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc)
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce)
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/toolchain)
include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_BINARY_DIR}/proto/ge)

@@ -58,6 +59,7 @@ include_directories(${CMAKE_BINARY_DIR}/proto/ge)
# need to remove dependencies on pb files later
file(GLOB TRAIN_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"analyzer/analyzer.cc"
"client/ge_prof.cc"
"client/ge_api.cc"
"common/dump/dump_manager.cc"
"common/dump/dump_properties.cc"
@@ -206,13 +208,14 @@ file(GLOB TRAIN_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}


######### libge_runner.so #############
add_library(ge_runner SHARED ${TRAIN_SRC_LIST} ${PROTO_SRCS} ${PROTO_CLIENT_SRCS} ${PROTO_HEADER_HDRS})
target_compile_definitions(ge_runner PRIVATE
if (NOT ENABLE_ACL)
add_library(ge_runner SHARED ${TRAIN_SRC_LIST} ${PROTO_SRCS} ${PROTO_CLIENT_SRCS} ${PROTO_HEADER_HDRS})
target_compile_definitions(ge_runner PRIVATE
PROTOBUF_INLINE_NOT_IN_HEADERS=0
DAVINCI_SUPPORT_PROFILING
REUSE_MEMORY=1
DAVINCI_CLOUD)
target_link_libraries(ge_runner
target_link_libraries(ge_runner
graph
ge_common
ge_memory
@@ -225,8 +228,12 @@ target_link_libraries(ge_runner
${msprof}
${runtime}
${resouce}
${ascend_hal}
${adump_server}
${msprofiler}
rt
dl)
endif ()

######### libge_compiler.so #############
# need to remove dependencies on pb files later
@@ -235,6 +242,7 @@ file(GLOB INFER_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"common/dump/dump_properties.cc"
"common/dump/dump_manager.cc"
"common/dump/dump_op.cc"
"common/dump/dump_server.cc"
"common/formats/format_transfers/*.cc"
"common/formats/formats.cc"
"common/formats/utils/formats_trans_utils.cc"
@@ -335,6 +343,7 @@ file(GLOB INFER_SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"host_kernels/unpack_kernel.cc"
"host_kernels/unsqueeze_kernel.cc"
"hybrid/hybrid_davinci_model_stub.cc"
"hybrid/node_executor/aicpu/aicpu_ext_info.cc"
"init/gelib.cc"
"ir_build/atc_ir_common.cc"
"ir_build/ge_ir_build.cc"
@@ -352,7 +361,10 @@ add_library(ge_compiler SHARED ${INFER_SRC_LIST} ${PROTO_SRCS} ${PROTO_HEADER_HD
target_compile_definitions(ge_compiler PRIVATE
PROTOBUF_INLINE_NOT_IN_HEADERS=0
REUSE_MEMORY=1
FMK_HOST_INFER)
FMK_HOST_INFER
FMK_SUPPORT_DUMP
COMPILE_OMG_PACKAGE
REUSE_MEMORY=1)
target_link_libraries(ge_compiler
graph
ge_common


+ 19
- 8
src/ge/analyzer/analyzer.cc View File

@@ -101,7 +101,7 @@ Status Analyzer::BuildJsonObject(uint64_t session_id, uint64_t graph_id) {

ge::Status Analyzer::Initialize() {
ClearHistoryFile();
return CreateAnalyzerFile();
return SUCCESS;
}

void Analyzer::Finalize() {
@@ -136,7 +136,7 @@ void Analyzer::DestroyGraphJsonObject(uint64_t session_id, uint64_t graph_id) {
} else {
auto iter1 = (iter->second).find(graph_id);
if (iter1 == (iter->second).end()) {
GELOGW("can not find the graph json object by session_id[%lu] and graph_id[%lu].Do nothing", session_id,
GELOGW("Can not find the graph json object by session_id[%lu] and graph_id[%lu]. Do nothing.", session_id,
graph_id);
}
(iter->second).erase(iter1);
@@ -169,6 +169,10 @@ void Analyzer::ClearHistoryFile() {
}

ge::Status Analyzer::CreateAnalyzerFile() {
if (is_json_file_create_) {
GELOGD("analyzer file has been created!No necessary to create again!");
return SUCCESS;
}
GELOGD("start to create analyzer file!");
// Check whether the manifest exists, if not, create it.
string real_path = RealPath(kFilePath.c_str());
@@ -176,18 +180,19 @@ ge::Status Analyzer::CreateAnalyzerFile() {
GELOGE(FAILED, "File path is invalid.");
return FAILED;
}
string file = real_path + "/" + kAnalyzeFile;
GELOGD("Created analyzer file:[%s]", file.c_str());
int fd = open(file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority);
std::lock_guard<std::mutex> lg(file_mutex_);
json_file_name_ = real_path + "/" + kAnalyzeFile;
GELOGD("Created analyzer file:[%s]", json_file_name_.c_str());
int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority);
if (fd < 0) {
GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", file.c_str());
GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", json_file_name_.c_str());
return INTERNAL_ERROR;
}
if (close(fd) != 0) {
GELOGE(INTERNAL_ERROR, "Fail to close the file: %s.", file.c_str());
GELOGE(INTERNAL_ERROR, "Fail to close the file: %s.", json_file_name_.c_str());
return INTERNAL_ERROR;
}
json_file_name_ = file;
is_json_file_create_ = true;

GELOGD("success to create analyzer file[%s]!", json_file_name_.c_str());
return SUCCESS;
@@ -231,6 +236,12 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) {
GELOGE(status, "save op info failed!");
return FAILED;
}
// create json file
status = CreateAnalyzerFile();
if (status != SUCCESS) {
GELOGE(status, "create analyzer file failed!");
return status;
}
// save data to file
return SaveAnalyzerDataToFile();
}


+ 2
- 0
src/ge/analyzer/analyzer.h View File

@@ -24,6 +24,7 @@
#include <mutex>
#include <memory>
#include <fstream>
#include <atomic>

#include "external/ge/ge_api_types.h"
#include "graph/compute_graph.h"
@@ -181,6 +182,7 @@ class Analyzer {
std::mutex file_mutex_; // protect json_file_
std::ofstream json_file_;
std::string json_file_name_;
std::atomic_bool is_json_file_create_{false};
};
} // namespace ge
#endif // DOMI_ANALYZER_ANANLYZER_H_

+ 4
- 0
src/ge/client/CMakeLists.txt View File

@@ -29,6 +29,7 @@ file(GLOB PROTO_HEADER_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}

file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"ge_api.cc"
"ge_prof.cc"
)

ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST})
@@ -66,5 +67,8 @@ target_link_libraries(ge_client
${slog}
${mmpa}
${runtime}
${msprof}
${msprofiler}
${ascend_hal}
rt
dl)

+ 5
- 1
src/ge/client/ge_api.cc View File

@@ -16,6 +16,7 @@

#include "ge/ge_api.h"
#include <iostream>
#include <malloc.h>
#include "common/debug/log.h"
#include "framework/common/debug/ge_log.h"
#include "common/ge/datatype_util.h"
@@ -39,7 +40,7 @@ using std::vector;

namespace {
const int32_t kMaxStrLen = 128;
}
} // namespace

static bool g_ge_initialized = false;
static std::mutex g_ge_release_mutex; // GEFinalize and ~Session use
@@ -163,6 +164,9 @@ Status GEFinalize() {
g_ge_initialized = false;
}

// to avoid memory fragment, use malloc_trim to back free stack to system
malloc_trim(0);

GELOGT(TRACE_STOP, "GEFinalize finished");
return ret;
}


+ 369
- 0
src/ge/client/ge_prof.cc View File

@@ -0,0 +1,369 @@
/**
* 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 "ge/ge_prof.h"
#include "common/debug/log.h"
#include "common/profiling/profiling_manager.h"
#include "framework/common/debug/ge_log.h"
#include "ge/ge_api.h"
#include "graph/load/graph_loader.h"
#include "init/gelib.h"
#include "toolchain/prof_acl_api.h"

using std::map;
using std::string;
using std::vector;

namespace {
const uint32_t kMaxDeviceNum = 64;
const uint32_t kDeviceListIndex = 3;
const std::string kProfilingInit = "prof_init";
const std::string kProfilingFinalize = "prof_finalize";
const std::string kProfilingStart = "prof_start";
const std::string kProfilingStop = "prof_stop";
const std::string kDeviceNums = "devNums";
const std::string kDeviceIdList = "devIdList";
const std::string kAicoreMetrics = "aicoreMetrics";

const std::map<ge::ProfilingAicoreMetrics, std::string> kProfAicoreMetricsToString = {
{ge::kAicoreArithmaticThroughput, "AICORE_ARITHMATIC_THROUGHPUT"},
{ge::kAicorePipeline, "AICORE_PIPELINE"},
{ge::kAicoreSynchronization, "AICORE_SYNCHRONIZATION"},
{ge::kAicoreMemory, "AICORE_MEMORY"},
{ge::kAicoreInternalMemory, "AICORE_INTERNAL_MEMORY"},
{ge::kAicoreStall, "AICORE_STALL"}};
} // namespace

static bool g_graph_prof_init_ = false;
static std::mutex g_prof_mutex_;

namespace ge {
struct aclgrphProfConfig {
ProfConfig config;
};

Status aclgrphProfInit(const char *profiler_path, uint32_t length) {
GELOGT(TRACE_INIT, "Graph prof init start");

std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Ge client is not initialized.");
return FAILED;
}

std::lock_guard<std::mutex> lock(g_prof_mutex_);
if (g_graph_prof_init_) {
GELOGW("Multi graph profiling initializations.");
return GE_PROF_MULTI_INIT;
}

Status ret = CheckPath(profiler_path, length);
if (ret != SUCCESS) {
GELOGE(ret, "Profiling config path is invalid.");
return ret;
}
// if command mode is set, just return
if (ProfilingManager::Instance().ProfilingOn()) {
GELOGW("Graph prof init failed, cause profiling command pattern is running.");
return GE_PROF_MODE_CONFLICT;
}

ret = ProfInit(profiler_path);
if (ret != SUCCESS) {
GELOGE(ret, "ProfInit init fail");
return ret;
}

GraphLoader graph_loader;
Command command;
command.cmd_params.clear();
command.cmd_type = kProfilingInit;
command.module_index = PROF_MODEL_LOAD;
ret = graph_loader.CommandHandle(command);
if (ret != SUCCESS) {
GELOGE(ret, "Handle profiling command %s failed, config = %s", kProfilingInit.c_str(), profiler_path);
return ret;
}
if (!g_graph_prof_init_) {
g_graph_prof_init_ = true;
GELOGI("Profiling init successfully.");
}

GELOGI("Successfully execute GraphProfInit.");
return SUCCESS;
}

Status aclgrphProfFinalize() {
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Ge client is not initialized.");
return FAILED;
}
std::lock_guard<std::mutex> lock(g_prof_mutex_);
// if command mode is set, just return
if (ProfilingManager::Instance().ProfilingOn()) {
GELOGW("Graph prof finalize failed, cause profiling command pattern is running.");
return GE_PROF_MODE_CONFLICT;
}

if (!g_graph_prof_init_) {
GELOGE(GE_PROF_NOT_INIT, "Graph not profiling initialize.");
return GE_PROF_NOT_INIT;
}
GraphLoader graph_loader;
Command command;
command.cmd_params.clear();
command.cmd_type = kProfilingFinalize;
Status ret = graph_loader.CommandHandle(command);
if (ret != SUCCESS) {
GELOGE(ret, "Handle profiling command %s failed.", kProfilingFinalize.c_str());
return ret;
}

ret = ProfFinalize();
if (ret != SUCCESS) {
GELOGE(ret, "Finalize profiling failed, result = %d", ret);
}

if (ret == SUCCESS) {
g_graph_prof_init_ = false;
GELOGI("Successfully execute GraphProfFinalize.");
}
return ret;
}

bool TransProfConfigToParam(const aclgrphProfConfig *profiler_config, vector<string> &prof_config_params) {
prof_config_params.clear();
prof_config_params.emplace_back(kDeviceNums);
prof_config_params.emplace_back(std::to_string(profiler_config->config.devNums));
prof_config_params.emplace_back(kDeviceIdList);
std::string devID = "";
if (profiler_config->config.devNums == 0) {
GELOGW("The device num is invalid.");
return false;
}
for (uint32_t i = 0; i < profiler_config->config.devNums; i++) {
devID.append(std::to_string(profiler_config->config.devIdList[i]));
if (i != profiler_config->config.devNums - 1) {
devID.append(",");
}
}

prof_config_params.push_back(devID);
prof_config_params.push_back(kAicoreMetrics);
auto iter =
kProfAicoreMetricsToString.find(static_cast<ProfilingAicoreMetrics>(profiler_config->config.aicoreMetrics));
if (iter == kProfAicoreMetricsToString.end()) {
GELOGW("The prof aicore metrics is invalid.");
return false;
}
prof_config_params.push_back(iter->second);
return true;
}

bool isProfConfigValid(const uint32_t *deviceid_list, uint32_t device_nums) {
if (deviceid_list == nullptr) {
GELOGE(PARAM_INVALID, "deviceIdList is nullptr");
return false;
}
if (device_nums == 0 || device_nums > kMaxDeviceNum) {
GELOGE(PARAM_INVALID, "The device nums is invalid.");
return false;
}

// real device num
int32_t dev_count = 0;
rtError_t rt_err = rtGetDeviceCount(&dev_count);
if (rt_err != RT_ERROR_NONE) {
GELOGE(INTERNAL_ERROR, "Get the Device count fail.");
return false;
}

if (device_nums > static_cast<uint32_t>(dev_count)) {
GELOGE(PARAM_INVALID, "Device num(%u) is not in range 1 ~ %d.", device_nums, dev_count);
return false;
}

std::unordered_set<uint32_t> record;
for (size_t i = 0; i < device_nums; ++i) {
uint32_t dev_id = deviceid_list[i];
if (dev_id >= static_cast<uint32_t>(dev_count)) {
GELOGE(PARAM_INVALID, "Device id %u is not in range 0 ~ %d(exclude %d)", dev_id, dev_count, dev_count);
return false;
}
if (record.count(dev_id) > 0) {
GELOGE(PARAM_INVALID, "Device id %u is duplicatedly set", dev_id);
return false;
}
record.insert(dev_id);
}
return true;
}

aclgrphProfConfig *aclgrphProfCreateConfig(uint32_t *deviceid_list, uint32_t device_nums,
ProfilingAicoreMetrics aicore_metrics, ProfAicoreEvents *aicore_events,
uint64_t data_type_config) {
if (!isProfConfigValid(deviceid_list, device_nums)) {
return nullptr;
}
aclgrphProfConfig *config = new (std::nothrow) aclgrphProfConfig();
if (config == nullptr) {
GELOGE(INTERNAL_ERROR, "new aclgrphProfConfig fail");
return nullptr;
}
config->config.devNums = device_nums;
if (memcpy_s(config->config.devIdList, sizeof(config->config.devIdList), deviceid_list,
device_nums * sizeof(uint32_t)) != EOK) {
GELOGE(INTERNAL_ERROR, "copy devID failed. size = %u", device_nums);
delete config;
return nullptr;
}

config->config.aicoreMetrics = static_cast<ProfAicoreMetrics>(aicore_metrics);
config->config.dataTypeConfig = data_type_config;
GELOGI("Successfully create prof config.");
return config;
}

Status aclgrphProfDestroyConfig(aclgrphProfConfig *profiler_config) {
if (profiler_config == nullptr) {
GELOGE(PARAM_INVALID, "destroy profilerConfig failed, profilerConfig must not be nullptr");
return PARAM_INVALID;
}

delete profiler_config;
GELOGI("Successfully destroy prof config.");
return SUCCESS;
}

Status aclgrphProfStart(aclgrphProfConfig *profiler_config) {
if (profiler_config == nullptr) {
GELOGE(PARAM_INVALID, "aclgrphProfConfig is invalid.");
return FAILED;
}
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Ge client is not initialized.");
return FAILED;
}

std::lock_guard<std::mutex> lock(g_prof_mutex_);
// if command mode is set, just return
if (ProfilingManager::Instance().ProfilingOn()) {
GELOGW("Graph prof finalize failed, cause profiling command pattern is running.");
return GE_PROF_MODE_CONFLICT;
}
if (!g_graph_prof_init_) {
GELOGE(GE_PROF_NOT_INIT, "Graph not profiling initialize.");
return GE_PROF_NOT_INIT;
}

Status ret = ProfStartProfiling(&profiler_config->config);
if (ret != SUCCESS) {
GELOGE(ret, "Start profiling failed, prof result = %d", ret);
return FAILED;
}

std::vector<string> prof_params;
if (!TransProfConfigToParam(profiler_config, prof_params)) {
GELOGE(PARAM_INVALID, "Transfer profilerConfig to string vector failed");
return PARAM_INVALID;
}

GraphLoader graph_loader;
Command command;
command.cmd_params.clear();
command.cmd_type = kProfilingStart;
command.cmd_params = prof_params;
command.module_index = profiler_config->config.dataTypeConfig;
GELOGI("Profiling will start, device nums:%s , deviceID:[%s], data type config: 0x%llx", prof_params[0].c_str(),
prof_params[kDeviceListIndex].c_str(), command.module_index);
ret = graph_loader.CommandHandle(command);
if (ret != SUCCESS) {
GELOGE(ret, "Handle profiling command failed");
return FAILED;
}

GELOGI("Successfully execute GraphProfStartProfiling.");

return SUCCESS;
}

Status aclgrphProfStop(aclgrphProfConfig *profiler_config) {
if (profiler_config == nullptr) {
GELOGE(PARAM_INVALID, "aclgrphProfConfig is invalid.");
return FAILED;
}
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Ge client is not initialized.");
return FAILED;
}

std::lock_guard<std::mutex> lock(g_prof_mutex_);
// if command mode is set, just return
if (ProfilingManager::Instance().ProfilingOn()) {
GELOGW("Graph prof finalize failed, cause profiling command pattern is running.");
return GE_PROF_MODE_CONFLICT;
}
if (!g_graph_prof_init_) {
GELOGE(GE_PROF_NOT_INIT, "Graph not profiling initialize.");
return GE_PROF_NOT_INIT;
}

for (uint32_t i = 0; i < profiler_config->config.devNums; i++) {
uint64_t data_type_config;
Status status = ProfGetDataTypeConfig(profiler_config->config.devIdList[i], data_type_config);
if (status != SUCCESS) {
GELOGE(status, "Prof get data type config failed, prof result = %d", status);
return status;
}
if (data_type_config != profiler_config->config.dataTypeConfig) {
GELOGE(FAILED, "data type config verify failed");
return FAILED;
}
}

std::vector<string> prof_params;
if (!TransProfConfigToParam(profiler_config, prof_params)) {
GELOGE(PARAM_INVALID, "Transfer profilerConfig to string vector failed");
return PARAM_INVALID;
}

GraphLoader graph_loader;
Command command;
command.cmd_params.clear();
command.cmd_type = kProfilingStop;
command.cmd_params = prof_params;
command.module_index = profiler_config->config.dataTypeConfig;
GELOGI("Profiling will stop, device nums:%s , deviceID:[%s], data type config: 0x%llx", prof_params[0].c_str(),
prof_params[kDeviceListIndex].c_str(), command.module_index);
Status ret = graph_loader.CommandHandle(command);
if (ret != SUCCESS) {
GELOGE(ret, "Handle profiling command failed");
return FAILED;
}

ret = ProfStopProfiling(&profiler_config->config);
if (ret != SUCCESS) {
GELOGE(ret, "Stop profiling failed, prof result = %d", ret);
return ret;
}

GELOGI("Successfully execute GraphProfStopProfiling.");
return SUCCESS;
}
} // namespace ge

+ 6
- 0
src/ge/client/module.mk View File

@@ -4,6 +4,7 @@ LOCAL_PATH := $(call my-dir)
COMMON_LOCAL_SRC_FILES := \
proto/ge_api.proto \
ge_api.cc \
ge_prof.cc \


COMMON_LOCAL_C_INCLUDES := \
@@ -69,7 +70,10 @@ LOCAL_SHARED_LIBRARIES := \
libregister \
libge_compiler \
libge_common \
libmsprof \
stub/libascend_hal

LOCAL_STATIC_LIBRARIES := libmsprofiler

LOCAL_LDFLAGS := -lrt -ldl

@@ -102,7 +106,9 @@ LOCAL_SHARED_LIBRARIES := \
libruntime \
libge_compiler \
libge_common \
libmsprof

LOCAL_STATIC_LIBRARIES := libmsprofiler

LOCAL_LDFLAGS := -lrt -ldl
LOCAL_CFLAGS += \


+ 1
- 0
src/ge/common/CMakeLists.txt View File

@@ -27,6 +27,7 @@ file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"context/ctx.cc"
"cust_aicpu_kernel_store.cc"
"debug/memory_dumper.cc"
"dump/dump_properties.cc"
"fmk_error_codes.cc"
"formats/format_transfers/datatype_transfer.cc"
"formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc"


+ 3
- 8
src/ge/common/dump/dump_manager.cc View File

@@ -49,7 +49,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf
dump_properties_.ClearDumpPropertyValue();
return SUCCESS;
}
dump_properties_.SetDumpStatus(dump_status);

dump_op_switch = dump_config.dump_op_switch;
dump_properties_.SetDumpOpSwitch(dump_op_switch);
if (dump_op_switch == kDumpoff && dump_config.dump_list.empty()) {
GELOGE(PARAM_INVALID, "Dump list is invalid,dump_op_switch is %s", dump_op_switch.c_str());
return PARAM_INVALID;
@@ -95,14 +98,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf
return SUCCESS;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpManager::IsDumpOpen() {
std::lock_guard<std::mutex> lock(mutex_);
if (!dump_properties_.GetDumpPath().empty()) {
return true;
}
return false;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const DumpProperties &DumpManager::GetDumpProperties() {
std::lock_guard<std::mutex> lock(mutex_);
return dump_properties_;


+ 0
- 1
src/ge/common/dump/dump_manager.h View File

@@ -28,7 +28,6 @@ class DumpManager {
static DumpManager &GetInstance();

Status SetDumpConf(const DumpConfig &dump_config);
bool IsDumpOpen();
const DumpProperties &GetDumpProperties();
void SetModelName(const std::string &model_name);
const std::string &GetModelName();


+ 11
- 11
src/ge/common/dump/dump_op.cc View File

@@ -16,7 +16,6 @@

#include "common/dump/dump_op.h"

#include "aicpu/common/aicpu_task_struct.h"
#include "common/dump/dump_manager.h"
#include "common/ge/datatype_util.h"
#include "framework/common/debug/ge_log.h"
@@ -28,6 +27,7 @@
#include "proto/ge_ir.pb.h"
#include "proto/op_mapping_info.pb.h"
#include "runtime/mem.h"
#include "aicpu/common/aicpu_task_struct.h"

namespace {
const uint32_t kAicpuLoadFlag = 1;
@@ -172,18 +172,18 @@ Status DumpOp::ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info) {
return RT_FAILED;
}

constexpr int32_t ioAddrNum = 2;
constexpr uint32_t argsSize = sizeof(aicpu::AicpuParamHead) + ioAddrNum * sizeof(uint64_t);
char args[argsSize] = {0};
auto paramHead = reinterpret_cast<aicpu::AicpuParamHead *>(args);
paramHead->length = argsSize;
paramHead->ioAddrNum = ioAddrNum;
auto ioAddr = reinterpret_cast<uint64_t *>(args + sizeof(aicpu::AicpuParamHead));
ioAddr[0] = reinterpret_cast<uintptr_t>(proto_dev_mem_);
ioAddr[1] = reinterpret_cast<uintptr_t>(proto_size_dev_mem_);
constexpr int32_t io_addr_num = 2;
constexpr uint32_t args_size = sizeof(aicpu::AicpuParamHead) + io_addr_num * sizeof(uint64_t);
char args[args_size] = {0};
auto param_head = reinterpret_cast<aicpu::AicpuParamHead *>(args);
param_head->length = args_size;
param_head->ioAddrNum = io_addr_num;
auto io_addr = reinterpret_cast<uint64_t *>(args + sizeof(aicpu::AicpuParamHead));
io_addr[0] = reinterpret_cast<uintptr_t>(proto_dev_mem_);
io_addr[1] = reinterpret_cast<uintptr_t>(proto_size_dev_mem_);
rt_ret = rtCpuKernelLaunch(nullptr, kDumpKernelsDumpOp,
1, // blockDim default 1
args, argsSize,
args, args_size,
nullptr, // no need smDesc
stream_);
if (rt_ret != RT_ERROR_NONE) {


+ 34
- 3
src/ge/common/dump/dump_properties.cc View File

@@ -31,7 +31,7 @@

namespace {
const std::string kEnableFlag = "1";
const std::string kDumpStatusOpen = "on";
const uint32_t kAicoreOverflow = (0x1 << 0);
const uint32_t kAtomicOverflow = (0x1 << 1);
const uint32_t kAllOverflow = (kAicoreOverflow | kAtomicOverflow);
@@ -81,12 +81,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::InitByOpti
if (enable_dump_ == kEnableFlag) {
std::string dump_step;
if (GetContext().GetOption(OPTION_EXEC_DUMP_STEP, dump_step) == GRAPH_SUCCESS) {
GELOGD("Get dump step %s successfully", dump_step.c_str());
GELOGI("Get dump step %s successfully", dump_step.c_str());
SetDumpStep(dump_step);
}
string dump_mode;
if (GetContext().GetOption(OPTION_EXEC_DUMP_MODE, dump_mode) == GRAPH_SUCCESS) {
GELOGD("Get dump mode %s successfully", dump_mode.c_str());
GELOGI("Get dump mode %s successfully", dump_mode.c_str());
SetDumpMode(dump_mode);
}
AddPropertyValue(DUMP_ALL_MODEL, {});
@@ -192,6 +192,37 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperti
return dump_mode_;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpStatus(const std::string &status) {
dump_status_ = status;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpStatus() const {
return dump_status_;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpProperties::SetDumpOpSwitch(
const std::string &dump_op_switch) {
dump_op_switch_ = dump_op_switch;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const std::string &DumpProperties::GetDumpOpSwitch() const {
return dump_op_switch_;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsSingleOpNeedDump() const {
if (dump_op_switch_ == kDumpStatusOpen) {
return true;
}
return false;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool DumpProperties::IsDumpOpen() const {
if (enable_dump_ == kEnableFlag || dump_status_ == kDumpStatusOpen) {
return true;
}
return false;
}

void DumpProperties::CopyFrom(const DumpProperties &other) {
if (&other != this) {
enable_dump_ = other.enable_dump_;


+ 18
- 0
src/ge/common/dump/dump_properties.h View File

@@ -61,10 +61,26 @@ class DumpProperties {

const std::string &GetDumpMode() const;

void SetDumpStatus(const std::string &status);

const std::string &GetDumpStatus() const;

void SetDumpOpSwitch(const std::string &dump_op_switch);

const std::string &GetDumpOpSwitch() const;

bool IsOpDebugOpen() const { return is_op_debug_; }

bool IsDumpOpen() const;

bool IsSingleOpNeedDump() const;

uint32_t GetOpDebugMode() const { return op_debug_mode_; }

const std::string &GetEnableDump() const { return enable_dump_; }

const std::string &GetEnableDumpDebug() const { return enable_dump_debug_; }

private:
void CopyFrom(const DumpProperties &other);

@@ -76,6 +92,8 @@ class DumpProperties {
std::string dump_path_;
std::string dump_step_;
std::string dump_mode_;
std::string dump_status_;
std::string dump_op_switch_;
std::map<std::string, std::set<std::string>> model_dump_properties_map_;

bool is_op_debug_ = false;


+ 21
- 0
src/ge/common/dump/dump_server.cc View File

@@ -0,0 +1,21 @@
/**
* 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 "adx_datadump_server.h"

int AdxDataDumpServerUnInit() { return 0; }

int AdxDataDumpServerInit() { return 0; }

+ 1
- 1
src/ge/common/ge/datatype_util.cc View File

@@ -34,7 +34,7 @@ std::map<ge::DataType, std::vector<ge::DataType>> g_reverse_translatable_data_ty
{ge::DT_INT32, {ge::DT_BOOL, ge::DT_INT64}},
{ge::DT_FLOAT, {ge::DT_FLOAT16, ge::DT_FLOAT}}};

static const std::map<ge::DataType, ge::proto::DataType> g_dump_data_type_map = {
std::map<ge::DataType, ge::proto::DataType> g_dump_data_type_map = {
// key:ge datatype,value:proto datatype
{ge::DT_UNDEFINED, ge::proto::DT_UNDEFINED},
{ge::DT_FLOAT, ge::proto::DT_FLOAT},


+ 6
- 3
src/ge/common/ge/op_tiling_manager.cc View File

@@ -15,14 +15,15 @@
*/

#include "common/ge/op_tiling_manager.h"
#include "common/util/error_manager/error_manager.h"
#include "framework/common/debug/log.h"
#include <string>

namespace {
const char *const kEnvName = "ASCEND_OPP_PATH";
const std::string kDefaultPath = "/usr/local/Ascend/opp";
const std::string kDefaultBuiltInTilingPath = "/op_impl/built-in/liboptiling.so";
const std::string kDefaultCustomTilingPath = "/op_impl/custom/liboptiling.so";
const std::string kDefaultBuiltInTilingPath = "/op_impl/built-in/ai_core/tbe/op_tiling/liboptiling.so";
const std::string kDefaultCustomTilingPath = "/op_impl/custom/ai_core/tbe/op_tiling/liboptiling.so";
const uint8_t kPrefixIndex = 9;
} // namespace

@@ -44,7 +45,9 @@ std::string OpTilingManager::GetPath() {
if (opp_path_env != nullptr) {
char resolved_path[PATH_MAX];
if (realpath(opp_path_env, resolved_path) == NULL) {
GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'(%s) is invalid path.", opp_path_env);
ErrorManager::GetInstance().ATCReportErrMessage("E19024", {"env", "value", "situation"},
{"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"});
GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'[%s] is invalid path.", opp_path_env);
return std::string();
}
opp_path = resolved_path;


+ 1
- 0
src/ge/common/ge_common.mk View File

@@ -12,6 +12,7 @@ GE_COMMON_LOCAL_SRC_FILES := \
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 \


+ 19
- 1
src/ge/common/helper/model_cache_helper.cc View File

@@ -497,7 +497,25 @@ Status ModelCacheHelper::LoadJsonFromFile(const string &file_name, Json &json) c
GELOGW("Fail to open the file: %s.", path.c_str());
return INTERNAL_ERROR;
}
ifs >> json;
try {
ifs >> json;
} catch (nlohmann::detail::parse_error e) {
GELOGW("Fail to load json from file, json throw an error:%s.", e.what());
return INTERNAL_ERROR;
} catch (nlohmann::detail::invalid_iterator e) {
GELOGW("Fail to load json from file, json throw an error:%s.", e.what());
return INTERNAL_ERROR;
} catch (nlohmann::detail::type_error e) {
GELOGW("Fail to load json from file, json throw an error:%s.", e.what());
return INTERNAL_ERROR;
} catch (nlohmann::detail::out_of_range e) {
GELOGW("Fail to load json from file, json throw an error:%s.", e.what());
return INTERNAL_ERROR;
} catch (nlohmann::detail::other_error e) {
GELOGW("Fail to load json from file, json throw an error:%s.", e.what());
return INTERNAL_ERROR;
}

if (!json.is_object()) {
GELOGW("Fail to load the json file: %s.", path.c_str());
return INTERNAL_ERROR;


+ 17
- 2
src/ge/common/helper/model_helper.cc View File

@@ -41,7 +41,22 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_fil
const uint8_t *data, size_t size) {
if (size < 1 || size > UINT32_MAX) {
GELOGE(PARAM_INVALID, "Add model partition failed, partition size %zu invalid", size);
ErrorManager::GetInstance().ATCReportErrMessage("E19022");
if (size > UINT32_MAX) {
string item = "item";
if (type == MODEL_DEF) {
item = "model info";
} else if (type == WEIGHTS_DATA) {
item = "weight data";
} else if (type == TASK_INFO) {
item = "task info";
} else if (type == TBE_KERNELS) {
item = "tbe kernels";
} else if (type == CUST_AICPU_KERNELS) {
item = "aicpu kernels";
}
ErrorManager::GetInstance().ATCReportErrMessage("E19023", {"size", "item", "maxsize"},
{std::to_string(size), item, std::to_string(UINT32_MAX)});
}
return PARAM_INVALID;
}
if (data == nullptr) {
@@ -263,7 +278,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(c
}

Status status = ge::DavinciModelParser::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_);
if (ge::DavinciModelParser::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_) != SUCCESS) {
if (status != SUCCESS) {
GELOGE(status, "Parse model content failed!");
return status;
}


+ 9
- 19
src/ge/common/profiling/profiling_manager.cc View File

@@ -54,15 +54,19 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager &ProfilingMana
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::Init(const Options &options) {
#ifdef DAVINCI_SUPPORT_PROFILING
vector<int32_t>().swap(device_id_);
device_id_.push_back(options.device_id);
job_id_ = options.job_id;

GELOGI("ProfilingManager::Init job_id:%s", job_id_.c_str());

Status ret;
if (!recv_profiling_config_.empty()) {
GELOGI("Profiling json config from acl:%s", recv_profiling_config_.c_str());
ret = InitFromAclCfg(recv_profiling_config_);
} else {
ret = InitFromOptions(options);
if (ret == SUCCESS && is_load_profiling_) {
device_id_.push_back(options.device_id);
}
}
if (ret != SUCCESS) {
GELOGE(ret, "Failed to init profiling.");
@@ -543,25 +547,17 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::ReportPr
return;
}
GELOGI("current logic_device_id:%d", logic_device_id);

uint32_t phy_device_id = 0;
rt_ret = rtGetDevicePhyIdByIndex((uint32_t)logic_device_id, &phy_device_id);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "runtime get phy_device_id failed, current phy_device_id:%d", phy_device_id);
return;
}
GELOGI("current phy_device_id:%d", phy_device_id);
if (!is_acl_api_mode_) {
auto ret = std::find(device_id_.begin(), device_id_.end(), phy_device_id);
auto ret = std::find(device_id_.begin(), device_id_.end(), logic_device_id);
if (ret == device_id_.end()) {
GELOGE(FAILED, "get valid phy_device_id failed, profiling report failed.");
return;
}
}
GELOGI("start ProfilingTaskDescInfo.");
ProfilingTaskDescInfo(task_desc_info, phy_device_id);
ProfilingTaskDescInfo(task_desc_info, logic_device_id);
GELOGI("start ProfilingGraphDescInfo.");
ProfilingGraphDescInfo(compute_graph_desc_info, phy_device_id);
ProfilingGraphDescInfo(compute_graph_desc_info, logic_device_id);
GELOGI("Report profiling data for GE end.");
#endif
}
@@ -855,14 +851,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ProfilingManager::Profilin
}
GELOGI("Current logic_device_id:%d", logic_device_id);

uint32_t phy_device_id = 0;
rt_ret = rtGetDevicePhyIdByIndex((uint32_t)logic_device_id, &phy_device_id);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "runtime get phy_device_id failed, current phy_device_id:%d", phy_device_id);
}
GELOGI("Current phy_device_id:%d", phy_device_id);
bool execute_model_prof_on = false;
auto iter = std::find(device_id_.begin(), device_id_.end(), phy_device_id);
auto iter = std::find(device_id_.begin(), device_id_.end(), logic_device_id);
if (iter != device_id_.end()) {
execute_model_prof_on = true;
}


+ 6
- 0
src/ge/common/properties_manager.cc View File

@@ -172,6 +172,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY DumpProperties &PropertiesManag
return dump_properties_map_[session_id];
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void PropertiesManager::AddDumpProperties(
uint64_t session_id, const DumpProperties &dump_properties) {
std::lock_guard<std::mutex> lock(mutex_);
dump_properties_map_.emplace(session_id, dump_properties);
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void PropertiesManager::RemoveDumpProperties(uint64_t session_id) {
std::lock_guard<std::mutex> lock(mutex_);
auto iter = dump_properties_map_.find(session_id);


+ 5
- 1
src/ge/common/properties_manager.h View File

@@ -23,8 +23,8 @@
#include <string>
#include <vector>

#include "graph/op_desc.h"
#include "common/dump/dump_properties.h"
#include "graph/op_desc.h"

namespace ge {
// Configuration property management
@@ -83,6 +83,10 @@ class PropertiesManager {
void SetPropertyDelimiter(const std::string &de);

DumpProperties &GetDumpProperties(uint64_t session_id);

const map<uint64_t, DumpProperties> &GetDumpPropertiesMap() { return dump_properties_map_; }

void AddDumpProperties(uint64_t session_id, const DumpProperties &dump_properties);
void RemoveDumpProperties(uint64_t session_id);

private:


+ 69
- 3
src/ge/common/util.cc View File

@@ -19,16 +19,16 @@
#include <fcntl.h>
#include <sys/stat.h>

#include <unistd.h>
#include <regex.h>
#include <unistd.h>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <fstream>

#include "external/ge/ge_api_error_codes.h"
#include "common/util/error_manager/error_manager.h"
#include "external/ge/ge_api_error_codes.h"
#include "framework/common/debug/ge_log.h"
#include "framework/common/fmk_types.h"
#include "framework/common/ge_inner_error_codes.h"
@@ -58,6 +58,7 @@ const int kWarningThreshold = 536870912 * 2; // 536870912 represent 512M
const int kMaxFileSizeLimit = INT_MAX;
const int kMaxBuffSize = 256;
const char *const kPathValidReason = "The path can only contain 'a-z' 'A-Z' '0-9' '-' '.' '_' and chinese character";
constexpr uint32_t kMaxConfigFileByte = 10 * 1024 * 1024;
} // namespace

namespace ge {
@@ -471,7 +472,7 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str
return true;
}

ret = regexec(&reg, str.c_str(), 0, nullptr, 0);
ret = regexec(&reg, str.c_str(), 0, NULL, 0);
if (ret) {
regerror(ret, &reg, ebuff, kMaxBuffSize);
GELOGE(ge::PARAM_INVALID, "regexec failed, reason: %s", ebuff);
@@ -482,4 +483,69 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str
regfree(&reg);
return true;
}

FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) {
if (file_path == nullptr) {
GELOGE(PARAM_INVALID, "Config path is null.");
return false;
}
if (!CheckInputPathValid(file_path)) {
GELOGE(PARAM_INVALID, "Config path is invalid: %s", file_path);
return false;
}
// Normalize the path
std::string resolved_file_path = RealPath(file_path);
if (resolved_file_path.empty()) {
GELOGE(PARAM_INVALID, "Invalid input file path [%s], make sure that the file path is correct.", file_path);
return false;
}

mmStat_t stat = {0};
int32_t ret = mmStatGet(resolved_file_path.c_str(), &stat);
if (ret != EN_OK) {
GELOGE(PARAM_INVALID, "cannot get config file status, which path is %s, maybe not exist, return %d, errcode %d",
resolved_file_path.c_str(), ret, mmGetErrorCode());
return false;
}
if ((stat.st_mode & S_IFMT) != S_IFREG) {
GELOGE(PARAM_INVALID, "config file is not a common file, which path is %s, mode is %u", resolved_file_path.c_str(),
stat.st_mode);
return false;
}
if (stat.st_size > kMaxConfigFileByte) {
GELOGE(PARAM_INVALID, "config file %s size[%ld] is larger than max config file Bytes[%u]",
resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte);
return false;
}
return true;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status CheckPath(const char *path, size_t length) {
if (path == nullptr) {
GELOGE(PARAM_INVALID, "Config path is invalid.");
return PARAM_INVALID;
}

if (strlen(path) != length) {
GELOGE(PARAM_INVALID, "Path is invalid or length of config path is not equal to given length.");
return PARAM_INVALID;
}

if (length == 0 || length > MMPA_MAX_PATH) {
GELOGE(PARAM_INVALID, "Length of config path is invalid.");
return PARAM_INVALID;
}

INT32 is_dir = mmIsDir(path);
if (is_dir != EN_OK) {
GELOGE(PATH_INVALID, "Open directory %s failed, maybe it is not exit or not a dir", path);
return PATH_INVALID;
}

if (mmAccess2(path, M_R_OK) != EN_OK) {
GELOGE(PATH_INVALID, "Read path[%s] failed, errmsg[%s]", path, strerror(errno));
return PATH_INVALID;
}
return SUCCESS;
}
} // namespace ge

+ 4
- 1
src/ge/executor/CMakeLists.txt View File

@@ -22,7 +22,7 @@ file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"../../proto/insert_op.proto"
"../../proto/op_mapping_info.proto"
"../../proto/ge_ir.proto"
"../proto/dump_task.proto"
"../../proto/dump_task.proto"
)

file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
@@ -73,6 +73,7 @@ file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"../graph/manager/trans_var_data_utils.cc"
"../graph/manager/util/debug.cc"
"../hybrid/hybrid_davinci_model_stub.cc"
"../hybrid/node_executor/aicpu/aicpu_ext_info.cc"
"../model/ge_model.cc"
"../model/ge_root_model.cc"
"../omm/csa_interact.cc"
@@ -118,6 +119,8 @@ target_link_libraries(ge_executor
${slog}
${mmpa}
${msprof}
${error_manager}
${ascend_hal}
rt
dl)


+ 64
- 1
src/ge/executor/ge_executor.cc View File

@@ -182,6 +182,37 @@ bool IsDynamicImageSizeMatchModel(uint64_t image_height, uint64_t image_width,
GELOGE(ge::FAILED, "Dynamic resolution (%lu,%lu) can not match the gear of model.", image_height, image_width);
return false;
}

bool IsDynmaicDimsSizeMatchModel(const vector<uint64_t> cur_dynamic_dims, const vector<vector<int64_t>> &batch_info) {
if (batch_info.empty()) {
GELOGE(ge::FAILED, "Dynamic batch info is empty.");
return false;
}

bool find_match = false;
for (auto resolution : batch_info) {
if (cur_dynamic_dims.size() != resolution.size()) {
GELOGE(ge::FAILED, "Cur dynamic dims param num is %zu, current resolution size is %zu.", cur_dynamic_dims.size(),
resolution.size());
return false;
}
bool flag = true;
for (std::size_t i = 0; i < resolution.size(); ++i) {
if (cur_dynamic_dims[i] != static_cast<uint64_t>(resolution[i])) {
flag = false;
break;
}
}
if (flag) {
find_match = true;
break;
}
}
if (!find_match) {
GELOGE(ge::FAILED, "choose dynamic dims can not match the gear of model.");
}
return find_match;
}
} // namespace

namespace ge {
@@ -347,9 +378,21 @@ Status GeExecutor::SetDynamicDims(uint32_t model_id, void *dynamic_input_addr, u
vector<uint64_t> cur_dynamic_dims;
Status ret = GetCurDynamicDims(model_id, dynamic_dims, cur_dynamic_dims);
if (ret != SUCCESS) {
GELOGE(FAILED, "Set cur gear dynmaic dims failed");
GELOGE(FAILED, "Set cur gear dynamic dims failed");
return FAILED;
}
std::vector<std::vector<int64_t>> batch_info;
int32_t dynamic_type = static_cast<int32_t>(FIXED);
ret = GraphExecutor::GetDynamicBatchInfo(model_id, batch_info, dynamic_type);
if (ret != SUCCESS) {
GELOGE(ret, "Get dynamic input info failed.");
return ret;
}

if (!IsDynmaicDimsSizeMatchModel(cur_dynamic_dims, batch_info)) {
GELOGE(PARAM_INVALID, "The current dynamic input does not match the gear of the model.");
return PARAM_INVALID;
}

ret = GraphExecutor::SetDynamicSize(model_id, cur_dynamic_dims, static_cast<int32_t>(DYNAMIC_DIMS));
if (ret != SUCCESS) {
@@ -410,6 +453,10 @@ Status GeExecutor::GetCurDynamicDims(uint32_t model_id, const vector<uint64_t> &
for (std::size_t i = 0; i < all_data_dims.size(); ++i) {
if (all_data_dims[i] < 0) {
cur_dynamic_dims.push_back(dynamic_dims[i]);
} else if (static_cast<uint64_t>(all_data_dims[i]) != dynamic_dims[i]) {
GELOGE(PARAM_INVALID, "Static dims should be same, index: %zu value: %d should be %d", i, dynamic_dims[i],
all_data_dims[i]);
return PARAM_INVALID;
}
}
return SUCCESS;
@@ -698,6 +745,22 @@ Status GeExecutor::GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigInfo
GELOGI("GetAIPPInfo succ.");
return SUCCESS;
}

Status GeExecutor::GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index) {
GELOGI("Begin to get aipp type.");
if (!isInit_) {
GELOGE(GE_EXEC_NOT_INIT, "not inited yet!");
return GE_EXEC_NOT_INIT;
}
Status ret = GraphExecutor::GetAippType(model_id, index, type, aipp_index);
if (ret != SUCCESS) {
GELOGW("Get aipp type is not success.");
return ret;
}
GELOGI("Get aipp type success.");
return SUCCESS;
}

Status GeExecutor::GetModelAttr(uint32_t model_id, std::vector<std::string> &dynamic_output_shape_info) {
GELOGI("Begin to get dynamic batch output shape info");
if (!isInit_) {


+ 8
- 0
src/ge/executor/module.mk View File

@@ -60,6 +60,7 @@ local_ge_executor_src_files := \
../single_op/task/aicpu_task_builder.cc \
../single_op/task/aicpu_kernel_task_builder.cc \
../hybrid/hybrid_davinci_model_stub.cc\
../hybrid/node_executor/aicpu/aicpu_ext_info.cc \

local_ge_executor_c_include := \
proto/insert_op.proto \
@@ -87,6 +88,8 @@ local_ge_executor_shared_library := \
libgraph \
libregister \
libmsprof \
liberror_manager \
libascend_hal

local_ge_executor_ldflags := -lrt -ldl \

@@ -102,6 +105,7 @@ LOCAL_SRC_FILES := $(local_ge_executor_src_files)
LOCAL_C_INCLUDES := $(local_ge_executor_c_include)

LOCAL_SHARED_LIBRARIES := $(local_ge_executor_shared_library)
LOCAL_STATIC_LIBRARIES := libmsprofiler
ifeq ($(device_os),android)
LOCAL_LDFLAGS += -ldl
LOCAL_LDLIBS += -L$(PWD)/prebuilts/clang/linux-x86/aarch64/android-ndk-r21/sysroot/usr/lib/aarch64-linux-android/29 -llog
@@ -137,6 +141,10 @@ LOCAL_SHARED_LIBRARIES := \
libgraph \
libregister \
libmsprof \
liberror_manager \
stub/libascend_hal

LOCAL_STATIC_LIBRARIES := libmsprofiler

LOCAL_LDFLAGS += $(local_ge_executor_ldflags)



+ 6
- 2
src/ge/ge_inference.mk View File

@@ -29,6 +29,7 @@ COMMON_LOCAL_SRC_FILES := \
common/dump/dump_properties.cc \
common/dump/dump_manager.cc \
common/dump/dump_op.cc \
common/dump/dump_server.cc \
common/helper/model_cache_helper.cc \
ge_local_engine/engine/host_cpu_engine.cc \

@@ -254,6 +255,7 @@ OME_HOST_SRC_FILES := \
single_op/stream_resource.cc \
single_op/single_op_manager.cc \
hybrid/hybrid_davinci_model_stub.cc \
hybrid/node_executor/aicpu/aicpu_ext_info.cc \
# graph/load/new_model_manager/task_info/hccl_task_info.cc

OME_DEVICE_SRC_FILES := $(OME_HOST_SRC_FILES)
@@ -286,6 +288,7 @@ COMMON_LOCAL_C_INCLUDES := \
$(TOPDIR)inc/runtime \
$(TOPDIR)libc_sec/include \
$(TOPDIR)ops/built-in/op_proto/inc \
$(TOPDIR)toolchain/ide/ide-daemon/external \
third_party/json/include \
third_party/protobuf/include \
third_party/opencv/include \
@@ -340,6 +343,7 @@ DEVICE_LOCAL_C_INCLUDES := \
$(TOPDIR)inc/runtime \
$(TOPDIR)ops/built-in/op_proto/inc \
$(TOPDIR)framework/domi \
$(TOPDIR)toolchain/ide/ide-daemon/external \
third_party/json/include \
third_party/protobuf/include \
third_party/opencv/include \
@@ -351,7 +355,7 @@ LOCAL_MODULE := libge_compiler

LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0 -DREUSE_MEMORY=1 -O2
# from ome_inference.mk
LOCAL_CFLAGS += -DFMK_HOST_INFER -DFMK_SUPPORT_DUMP
LOCAL_CFLAGS += -DFMK_HOST_INFER -DFMK_SUPPORT_DUMP -DCOMPILE_OMG_PACKAGE
ifeq ($(DEBUG), 1)
LOCAL_CFLAGS += -g -O0
endif
@@ -414,7 +418,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libge_compiler
LOCAL_CFLAGS += -DGOOGLE_PROTOBUF_NO_RTTI -DDEV_VISIBILITY -DNONSUPPORT_SAVE_TO_FILE
LOCAL_CFLAGS += -DPROTOBUF_INLINE_NOT_IN_HEADERS=0
LOCAL_CFLAGS += -DREUSE_MEMORY=1 -DFMK_SUPPORT_DUMP
LOCAL_CFLAGS += -DREUSE_MEMORY=1 -DFMK_SUPPORT_DUMP -DCOMPILE_OMG_PACKAGE
LOCAL_CFLAGS += -DOMG_DEVICE_VERSION
LOCAL_CFLAGS += -O2
LOCAL_MODULE_CLASS := SHARED_LIBRARIES


+ 1
- 1
src/ge/ge_local_engine/CMakeLists.txt View File

@@ -42,7 +42,7 @@ include_directories(${CMAKE_BINARY_DIR}/proto/ge)

######### libge_local_engine.so #############
add_library(ge_local_engine SHARED ${SRC_LIST} ${PROTO_HDRS})
target_compile_definitions(ge_local_engine PRIVATE Werror)
target_compile_definitions(ge_local_engine PRIVATE Werror COMPILE_OMG_PACKAGE)
target_link_libraries(ge_local_engine
graph
${PROTOBUF_LIBRARY}


+ 57
- 32
src/ge/ge_local_engine/engine/host_cpu_engine.cc View File

@@ -25,40 +25,65 @@
#include "common/ge/plugin_manager.h"
#include "graph/utils/type_utils.h"
#include "common/fp16_t.h"
#include "common/math/math_util.h"

namespace {
#define CREATE_OUTPUT_CASE(DTYPE, TYPE) \
case (DTYPE): { \
GeTensorPtr ge_tensor = nullptr; \
if (need_create_flag) { \
int64_t data_num = out_desc.GetShape().IsScalar() ? 1 : out_desc.GetShape().GetShapeSize(); \
std::unique_ptr<TYPE[]> buf(new (std::nothrow) TYPE[data_num]()); \
if (buf == nullptr) { \
GELOGE(MEMALLOC_FAILED, "New sizeof(T) * data_num(%zu) memory failed", \
static_cast<size_t>(sizeof(TYPE) * data_num)); \
return MEMALLOC_FAILED; \
} \
ge_tensor = MakeShared<GeTensor>(out_desc); \
GE_CHECK_NOTNULL(ge_tensor); \
GELOGI("node:%s allocate output %zu, size=%lld", op_desc->GetName().c_str(), i, data_num * sizeof(TYPE)); \
ge_tensor->SetData(reinterpret_cast<uint8_t *>(buf.get()), data_num * sizeof(TYPE)); \
ge_tensor->MutableTensorDesc().SetDataType(out_desc.GetDataType()); \
ge_tensor->MutableTensorDesc().SetShape(out_desc.GetShape()); \
outputs.emplace_back(ge_tensor); \
} else { \
ge_tensor = outputs[i]; \
GE_CHECK_NOTNULL(ge_tensor); \
GELOGI("node:%s existed output %zu, addr=%p, size=%lld", op_desc->GetName().c_str(), i, \
reinterpret_cast<const uint8_t *>(ge_tensor->GetData().data()), ge_tensor->GetData().size()); \
} \
auto tensor = TensorAdapter::AsTensor(*ge_tensor); \
auto tensor_name = op_desc->GetOutputNameByIndex(i); \
GE_RETURN_WITH_LOG_IF_TRUE(tensor_name.empty(), "Failed to get output name. node = %s, index = %zu", \
op_desc->GetName().c_str(), i); \
GELOGD("Successfully inserted output tensor. node = %s, index = %zu, output name = %s, addr = %p, size = %zu", \
op_desc->GetName().c_str(), i, tensor_name.c_str(), tensor.GetData(), tensor.GetSize()); \
named_outputs.emplace(tensor_name, tensor); \
break; \
#define CREATE_OUTPUT_CASE(DTYPE, TYPE) \
case (DTYPE): { \
GeTensorPtr ge_tensor = nullptr; \
if (need_create_flag) { \
int64_t num_size = out_desc.GetShape().IsScalar() ? 1 : out_desc.GetShape().GetShapeSize(); \
if (out_desc.GetShape().IsUnknownShape()) { \
std::vector<std::pair<int64_t, int64_t>> range; \
if (out_desc.GetShapeRange(range) != GRAPH_SUCCESS) { \
GELOGE(INTERNAL_ERROR, "Get shape range failed, node:%s", op_desc->GetName().c_str()); \
return INTERNAL_ERROR; \
} \
int64_t max_range_size = 1; \
for (const auto &item : range) { \
FMK_INT64_MULCHECK(max_range_size, item.second); \
max_range_size *= item.second; \
} \
num_size = max_range_size; \
} \
if (num_size < 0) { \
GELOGE(INTERNAL_ERROR, "node:%s, get size for output %zu failed, num=%lld", op_desc->GetName().c_str(), i, \
num_size); \
return INTERNAL_ERROR; \
} \
auto data_num = static_cast<uint64_t>(num_size); \
GELOGI("node:%s allocate output %zu start, size=%lld", op_desc->GetName().c_str(), i, data_num * sizeof(TYPE)); \
std::unique_ptr<TYPE[]> buf(new (std::nothrow) TYPE[data_num]()); \
if (buf == nullptr) { \
GELOGE(MEMALLOC_FAILED, "New sizeof(T) * data_num(%zu) memory failed", \
static_cast<size_t>(sizeof(TYPE) * data_num)); \
return MEMALLOC_FAILED; \
} \
ge_tensor = MakeShared<GeTensor>(out_desc); \
GE_CHECK_NOTNULL(ge_tensor); \
GELOGI("node:%s allocate output %zu success, size=%lld", op_desc->GetName().c_str(), i, \
data_num * sizeof(TYPE)); \
if (ge_tensor->SetData(reinterpret_cast<uint8_t *>(buf.get()), data_num * sizeof(TYPE)) != GRAPH_SUCCESS) { \
GELOGE(MEMALLOC_FAILED, "Set data for output %zu of node %s failed.", i, op_desc->GetName().c_str()); \
return MEMALLOC_FAILED; \
} \
ge_tensor->MutableTensorDesc().SetDataType(out_desc.GetDataType()); \
ge_tensor->MutableTensorDesc().SetShape(out_desc.GetShape()); \
outputs.emplace_back(ge_tensor); \
} else { \
ge_tensor = outputs[i]; \
GE_CHECK_NOTNULL(ge_tensor); \
GELOGI("node:%s existed output %zu, addr=%p, size=%lld", op_desc->GetName().c_str(), i, \
reinterpret_cast<const uint8_t *>(ge_tensor->GetData().data()), ge_tensor->GetData().size()); \
} \
auto tensor = TensorAdapter::AsTensor(*ge_tensor); \
auto tensor_name = op_desc->GetOutputNameByIndex(i); \
GE_RETURN_WITH_LOG_IF_TRUE(tensor_name.empty(), "Failed to get output name. node = %s, index = %zu", \
op_desc->GetName().c_str(), i); \
GELOGD("Successfully inserted output tensor. node = %s, index = %zu, output name = %s, addr = %p, size = %zu", \
op_desc->GetName().c_str(), i, tensor_name.c_str(), tensor.GetData(), tensor.GetSize()); \
named_outputs.emplace(tensor_name, tensor); \
break; \
}
} // namespace



+ 1
- 1
src/ge/ge_local_engine/module.mk View File

@@ -42,7 +42,7 @@ include ${BUILD_HOST_SHARED_LIBRARY}
include $(CLEAR_VARS)
LOCAL_MODULE := atclib/libge_local_engine
LOCAL_CFLAGS += -Werror
LOCAL_CFLAGS += -std=c++11
LOCAL_CFLAGS += -std=c++11 -DCOMPILE_OMG_PACKAGE
LOCAL_LDFLAGS :=

LOCAL_STATIC_LIBRARIES :=


+ 12
- 2
src/ge/ge_runner.mk View File

@@ -1,5 +1,5 @@
LOCAL_PATH := $(call my-dir)
include $(LOCAL_PATH)/stub/Makefile
LIBGE_LOCAL_SRC_FILES := \
proto/fusion_model.proto \
proto/optimizer_priority.proto \
@@ -296,6 +296,7 @@ LIBGE_LOCAL_SRC_FILES := \
LIBCLIENT_LOCAL_SRC_FILES := \
proto/ge_api.proto \
client/ge_api.cc \
client/ge_prof.cc \

RUNNER_LOCAL_C_INCLUDES := \
$(LOCAL_PATH) ./ \
@@ -312,6 +313,7 @@ RUNNER_LOCAL_C_INCLUDES := \
$(TOPDIR)libc_sec/include \
$(TOPDIR)ops/built-in/op_proto/inc \
$(TOPDIR)framework/domi/analyzer \
$(TOPDIR)toolchain/ide/ide-daemon/external \
proto/fwk_adapter.proto \
proto/ge_ir.proto \
proto/insert_op.proto \
@@ -353,6 +355,8 @@ LOCAL_SRC_FILES := $(LIBGE_LOCAL_SRC_FILES)
LOCAL_SRC_FILES += $(LIBCLIENT_LOCAL_SRC_FILES)

LOCAL_STATIC_LIBRARIES := libge_memory \
libadump_server \
libmsprofiler \

LOCAL_SHARED_LIBRARIES := \
libc_sec \
@@ -371,6 +375,7 @@ LOCAL_LDFLAGS := -lrt -ldl
LOCAL_SHARED_LIBRARIES += \
libruntime \
libresource \
stub/libascend_hal \

include $(BUILD_HOST_SHARED_LIBRARY)

@@ -388,7 +393,8 @@ endif

LOCAL_C_INCLUDES := $(RUNNER_LOCAL_C_INCLUDES)

LOCAL_SRC_FILES := ../../out/ge/lib64/stub/ge_api.cc
LOCAL_SRC_FILES := ../../out/ge/lib64/stub/ge_api.cc \
../../out/ge/lib64/stub/ge_prof.cc \


LOCAL_SHARED_LIBRARIES :=
@@ -438,6 +444,7 @@ LOCAL_SRC_FILES := $(LIBGE_LOCAL_SRC_FILES)
LOCAL_SRC_FILES += $(LIBCLIENT_LOCAL_SRC_FILES)

LOCAL_STATIC_LIBRARIES := libge_memory \
libadump_server \

LOCAL_SHARED_LIBRARIES := \
libc_sec \
@@ -450,6 +457,7 @@ LOCAL_LDFLAGS := -lrt -ldl
LOCAL_SHARED_LIBRARIES += \
libruntime \
libresource \
stub/libascend_hal \

include $(BUILD_HOST_STATIC_LIBRARY)

@@ -469,6 +477,7 @@ LOCAL_SRC_FILES := $(LIBGE_LOCAL_SRC_FILES)
LOCAL_SRC_FILES += $(LIBCLIENT_LOCAL_SRC_FILES)

LOCAL_STATIC_LIBRARIES := libge_memory \
libadump_server \

LOCAL_SHARED_LIBRARIES := \
libc_sec \
@@ -481,5 +490,6 @@ LOCAL_LDFLAGS := -lrt -ldl
LOCAL_SHARED_LIBRARIES += \
libruntime \
libresource \
libascend_hal \

include $(BUILD_STATIC_LIBRARY)

+ 3
- 0
src/ge/ge_runtime/runtime_model.cc View File

@@ -344,6 +344,9 @@ void RuntimeModel::RtStreamDestory() noexcept {

void RuntimeModel::RtLabelDestory() noexcept {
for (size_t i = 0; i < label_list_.size(); i++) {
if (label_list_[i] == nullptr) {
continue;
}
if (rtLabelDestroy(label_list_[i]) != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Destroy label failed! Index: %zu.", i);
return;


+ 9
- 2
src/ge/generator/ge_generator.cc View File

@@ -136,6 +136,13 @@ static Status AddInputs(const ComputeGraphPtr &graph, const NodePtr &node, GeTen
bool attr) {
GE_CHECK_NOTNULL_EXEC(graph, return PARAM_INVALID);
GE_CHECK_NOTNULL_EXEC(node, return PARAM_INVALID);

auto format = tensor.GetFormat();
auto data_type = tensor.GetDataType();
if (format == FORMAT_RESERVED && data_type == DT_UNDEFINED) {
return SUCCESS;
}

string op_type;
if (!AttrUtils::GetStr(tensor, kAttrOpType, op_type) || op_type.empty()) {
op_type = DATA;
@@ -521,8 +528,8 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &in
const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff,
bool is_offline) {
GE_CHECK_NOTNULL_EXEC(op_desc, return PARAM_INVALID);
if (!inputs.empty() && (inputs.size() != op_desc->GetInputsSize())) {
GELOGE(PARAM_INVALID, "Tensor size: %zu, Inputs size: %zu", inputs.size(), op_desc->GetInputsSize());
if (!inputs.empty() && (inputs.size() != op_desc->GetAllInputsSize())) {
GELOGE(PARAM_INVALID, "Tensor size: %zu, Inputs size: %zu", inputs.size(), op_desc->GetAllInputsSize());
return PARAM_INVALID;
}
if (!outputs.empty() && (outputs.size() != op_desc->GetOutputsSize())) {


+ 18
- 4
src/ge/graph/build/memory/block_mem_assigner.cc View File

@@ -413,7 +413,8 @@ BlockMemAssigner::BlockMemAssigner(ComputeGraphPtr compute_graph, const map<stri
life_time_(0) {}

BlockMemAssigner::~BlockMemAssigner() {
for (MemoryBlock *memory_block : memory_blocks_) {
GELOGD("blocks_store_ size : %lu", blocks_store_.size());
for (MemoryBlock *memory_block : blocks_store_) {
GE_DELETE_NEW_SINGLE(memory_block);
}
}
@@ -544,7 +545,7 @@ bool CanReuseBySize(const map<string, uint64_t> &reusable_block_counts, const Me
}

bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t out_index, std::string &peer_name,
uint32_t &peer_input_index) {
uint32_t &peer_input_index, bool &no_need_assign_memory) {
if (n == nullptr || n->GetAllOutDataAnchors().size() <= 0) {
return false;
}
@@ -571,6 +572,11 @@ bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t ou

// If GetBool fail, is_input_continuous is false.
(void)ge::AttrUtils::GetBool(peer_in_node_desc, ATTR_NAME_CONTINUOUS_INPUT, is_input_continuous);

GE_IF_BOOL_EXEC(is_input_continuous && CheckIsZeroMemNodeType(peer_node->GetType()),
GELOGI("Node[%s] output[%u] no_need_assign_memory.", n->GetName().c_str(), out_index);
no_need_assign_memory = true; return false;);

if (is_input_continuous) {
if (n->GetOwnerComputeGraph() != nullptr) {
string graph_name = n->GetOwnerComputeGraph()->GetName();
@@ -828,6 +834,7 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size,
}
}
memory_blocks_.emplace_back(block);
blocks_store_.emplace_back(block);
return block;
}

@@ -1143,8 +1150,10 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector
bool out_node_set_continuous_input = false;
bool no_need_assign_memory = ((size == 0) || CheckIsZeroMemNodeType(node->GetType()));
if (!no_need_assign_memory) {
out_node_set_continuous_input = IsOutNodeSetContinuousInput(node, i, peer_name, peer_input_index);
no_need_assign_memory = IsAtomicOutputMemory(node, i, is_atomic, out_node_set_continuous_input);
out_node_set_continuous_input =
IsOutNodeSetContinuousInput(node, i, peer_name, peer_input_index, no_need_assign_memory);
GE_IF_BOOL_EXEC(!no_need_assign_memory,
no_need_assign_memory = IsAtomicOutputMemory(node, i, is_atomic, out_node_set_continuous_input););
}
no_need_assign_memory = (no_need_assign_memory || IsKnownSubgraphData(node));
if (no_need_assign_memory) {
@@ -1296,6 +1305,11 @@ void MergeBlocks(std::vector<MemoryBlock *> &dest, std::vector<MemoryBlock *> &s
return;
}
if (dest[i] != nullptr && src[i] != nullptr) {
if (!dest[i]->reuse_mem_ || !src[i]->reuse_mem_) {
GELOGD("Diff batch's workspace can't be reused, i: %zu, dest[i]: %s, stream: %ld, src[i]: %s, stream: %ld.", i,
dest[i]->String().c_str(), dest[i]->stream_id_, src[i]->String().c_str(), src[i]->stream_id_);
continue;
}
for (auto &symbol : src[i]->SymbolList()) {
dest[i]->AddSymbol(symbol);
}


+ 2
- 1
src/ge/graph/build/memory/block_mem_assigner.h View File

@@ -259,6 +259,7 @@ class BlockMemAssigner : public MemAssigner {
ge::ComputeGraphPtr compute_graph_;

std::vector<MemoryBlock *> memory_blocks_;
std::vector<MemoryBlock *> blocks_store_;

std::vector<NodeTypeIndex> zero_memory_list_;

@@ -357,7 +358,7 @@ class BlockMemAssigner : public MemAssigner {
bool IsZeroCopyBlock(const NodePtr &node, bool continuous);

bool IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t out_index, std::string &peer_name,
uint32_t &peer_input_index);
uint32_t &peer_input_index, bool &no_need_assign_memory);

///
/// @ingroup GE


+ 199
- 159
src/ge/graph/build/memory/graph_mem_assigner.cc View File

@@ -39,6 +39,33 @@ const size_t kVirtualInputNodeOutputSize = 1;
const size_t kVirtualOutputNodeInputSize = 1;
const size_t kVirtualNodeDataIndex = 0;
const char *const kMbatchNodeNameFlag = "_ascend_mbatch_batch_";
int64_t GetSymbolOutputOffset(const std::map<std::string, std::string> &anchor_to_symbol,
const std::map<std::string, std::list<ge::NodeIndexIO>> &symbol_to_anchors,
const ge::NodePtr &node, const uint32_t i) {
ge::NodeIndexIO cur_node_index_io(node, i, ge::kOut);
auto iter1 = anchor_to_symbol.find(cur_node_index_io.ToString());
if (iter1 == anchor_to_symbol.end()) {
return ge::kInvalidOffset;
}
auto out_symbol = iter1->second;
auto iter2 = symbol_to_anchors.find(out_symbol);
if (iter2 == symbol_to_anchors.end()) {
return ge::kInvalidOffset;
}
for (const auto &node_index_io : iter2->second) {
if (node_index_io.value_ == out_symbol) {
vector<int64_t> output_list = node->GetOpDesc()->GetOutputOffset();
vector<int64_t> symbol_output_list = node_index_io.node_->GetOpDesc()->GetOutputOffset();
if (node_index_io.index_ >= symbol_output_list.size()) {
return ge::kInvalidOffset;
}
GELOGD("Node %s %uth output offset is %ld, Symbol %s output offset is %ld.", node->GetName().c_str(), i,
output_list[i], iter2->first.c_str(), symbol_output_list.at(node_index_io.index_));
return symbol_output_list.at(node_index_io.index_);
}
}
return ge::kInvalidOffset;
}
} // namespace
namespace ge {
Status VariableMemoryAssigner::Assign() {
@@ -227,7 +254,10 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, size_t &mem_offse
if (mem_offset > VarManager::Instance(session_id)->GetGraphMemoryMaxSize()) {
GELOGE(ge::FAILED, "Current memoffset %zu is greater than memory manager malloc max size %zu", mem_offset,
VarManager::Instance(session_id)->GetGraphMemoryMaxSize());
ErrorManager::GetInstance().ATCReportErrMessage("E19022");
ErrorManager::GetInstance().ATCReportErrMessage(
"E19022", {"size", "item", "maxsize"},
{std::to_string(mem_offset), "featuremap",
std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())});
return ge::FAILED;
}
return SUCCESS;
@@ -292,11 +322,19 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) {
GELOGE(ge::FAILED,
"There is an atomic conflict between the current node and the peer out node, not supported!");
return ge::FAILED;
} else if (is_loop_graph) {
GE_CHK_STATUS_RET(SetLoopGraphAtomicAttr(node, mem_clean_start));
} else {
GE_CHK_STATUS_RET(SetAtomicCleanAttr(nullptr, {mem_clean_start}, {mem_clean_size}),
"SetAtomicCleanAttr failed.");
}

const auto &in_control_anchor = node->GetInControlAnchor();
GE_CHECK_NOTNULL(in_control_anchor);
for (const auto &peer_out_control_anchor : in_control_anchor->GetPeerOutControlAnchors()) {
auto peer_out_node = peer_out_control_anchor->GetOwnerNode();
if (peer_out_node->GetType() == ATOMICADDRCLEAN) {
ret = SetAtomicCleanAttr(peer_out_node, {mem_clean_start}, {mem_clean_size});
if (ret != SUCCESS) {
GELOGE(ret, "Failed to set attr for atomic addr clean node %s.", peer_out_node->GetName().c_str());
return ret;
}
}
}
}
}
@@ -810,68 +848,37 @@ Status GraphMemoryAssigner::ReAssignVirtualNodesMemory(map<string, vector<NodePt
}

Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) {
GE_CHECK_NOTNULL(compute_graph_);
// Atomic op memory start addr
int64_t atomic_mem_start = static_cast<int64_t>(memory_offset_[0].mem_offset_);
GELOGI("Begin to reAssign atomic memory, atomic initial address mem_offset = %zu!", memory_offset_[0].mem_offset_);

vector<NodePtr> connect_netoutput_nodes;
for (auto &node : compute_graph_->GetAllNodes()) {
auto node_op_desc = node->GetOpDesc();
if (node_op_desc == nullptr) {
continue;
}

bool is_atomic = false;
// If GetBool fail, is_atomic is false.
(void)ge::AttrUtils::GetBool(node_op_desc, ATOMIC_ATTR_IS_ATOMIC_NODE, is_atomic);
if (!is_atomic) {
continue;
}

bool is_ref = false;
// If GetBool fail, is_ref is false.
(void)ge::AttrUtils::GetBool(node_op_desc, ATTR_NAME_REFERENCE, is_ref);
if (is_ref) {
GELOGE(ge::PARAM_INVALID, "The node %s cannot have both atomic and ref attribute.",
node_op_desc->GetName().c_str());
return ge::PARAM_INVALID;
}

vector<int> is_connect_netoutput;
// If GetBool fail, attr is_connect_netoutput is an empty vector.
(void)ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_NODE_CONNECT_OUTPUT, is_connect_netoutput);
if (!is_connect_netoutput.empty()) {
connect_netoutput_nodes.emplace_back(node);
continue;
}
map<NodePtr, vector<NodePtr>> normal_atomic_and_clean_nodes_map;
vector<NodePtr> connecting_output_atomic_nodes;
Status status = FilterAtomicNodesForMemoryAssign(normal_atomic_and_clean_nodes_map, connecting_output_atomic_nodes);
if (status != SUCCESS) {
GELOGE(status, "Failed to filter atomic nodes for memory assignment.");
return status;
}

// Atomic op memory start addr of loop graph
int64_t loop_graph_atomic_mem_start = static_cast<int64_t>(memory_offset_[0].mem_offset_);
vector<int64_t> mem_offset_end;
if (AssignAtomicOutputAndWorkspaceMemory(node, mem_offset_end) != SUCCESS) {
GELOGE(FAILED, "Assign atomic output and workspace memory failed, node is %s.", node->GetName().c_str());
return FAILED;
}
for (auto &iter : normal_atomic_and_clean_nodes_map) {
int64_t atomic_mem_start = static_cast<int64_t>(memory_offset_[0].mem_offset_);
GELOGD("Begin to reAssign atomic memory, atomic address memory start = %ld", atomic_mem_start);

/// In networks with loop op, atomic op uses atomic_addr_clean op independently,
/// so we need to set the attr separately.
if (is_loop_graph) {
GE_CHK_STATUS_RET(SetLoopGraphAtomicAttr(node, loop_graph_atomic_mem_start));
for (auto &atomic_node : iter.second) {
vector<int64_t> mem_offset_end;
status = AssignAtomicOutputAndWorkspaceMemory(atomic_node, mem_offset_end);
if (status != SUCCESS) {
GELOGE(status, "Assign atomic output and workspace memory failed, node name is %s.",
atomic_node->GetName().c_str());
return status;
}
}
}

// In networks without loop op, the same atomic addr clean op is used for atomic op
if (!is_loop_graph) {
// Set the address attr of atomic clean operator
int64_t atomic_mem_size = memory_offset_[0].mem_offset_ - atomic_mem_start;
if (atomic_mem_size != 0) {
GE_CHK_STATUS_RET(SetAtomicCleanAttr(nullptr, {atomic_mem_start}, {atomic_mem_size}),
"SetAtomicCleanAttr failed.");
int64_t atomic_mem_size = static_cast<int64_t>(memory_offset_[0].mem_offset_) - atomic_mem_start;
status = SetAtomicCleanAttr(iter.first, {atomic_mem_start}, {atomic_mem_size});
if (status != SUCCESS) {
GELOGE(status, "Failed to set attr for atomic addr clean node %s.", iter.first->GetName().c_str());
return status;
}
}

if (AssignConnectNetOutputAtomicMemory(connect_netoutput_nodes) != SUCCESS) {
if (AssignConnectNetOutputAtomicMemory(connecting_output_atomic_nodes) != SUCCESS) {
GELOGE(FAILED, "Failed to assign memory of nodes that connect to netoutput.");
return FAILED;
}
@@ -879,6 +886,55 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) {
return SUCCESS;
}

Status GraphMemoryAssigner::FilterAtomicNodesForMemoryAssign(map<NodePtr, vector<NodePtr>> &normal_atomic_nodes_map,
vector<NodePtr> &connecting_output_atomic_nodes) {
GE_CHECK_NOTNULL(compute_graph_);
for (const auto &node : compute_graph_->GetAllNodes()) {
if (node->GetType() == ATOMICADDRCLEAN) {
vector<NodePtr> tmp_normal_atomic_nodes;
const auto &out_control_anchor = node->GetOutControlAnchor();
GE_CHECK_NOTNULL(out_control_anchor);
for (const auto &peer_in_control_anchor : out_control_anchor->GetPeerInControlAnchors()) {
if (peer_in_control_anchor != nullptr) {
auto peer_in_node = peer_in_control_anchor->GetOwnerNode();
auto peer_in_node_desc = peer_in_node->GetOpDesc();
if (peer_in_node_desc != nullptr) {
bool is_atomic_node = false;
// If GetBool fail, is_atomic_node is false.
(void)ge::AttrUtils::GetBool(peer_in_node_desc, ATOMIC_ATTR_IS_ATOMIC_NODE, is_atomic_node);
if (is_atomic_node) {
bool is_reference = false;
// If GetBool fail, is_reference is false.
(void)ge::AttrUtils::GetBool(peer_in_node_desc, ATTR_NAME_REFERENCE, is_reference);
if (is_reference) {
GELOGE(ge::PARAM_INVALID, "The node %s cannot have both atomic and is_reference attribute.",
peer_in_node_desc->GetName().c_str());
return ge::PARAM_INVALID;
}

vector<int> is_connecting_output;
// If GetBool fail, attr is_connecting_output is an empty vector.
(void)ge::AttrUtils::GetListInt(peer_in_node_desc, ATTR_NAME_NODE_CONNECT_OUTPUT, is_connecting_output);
if (is_connecting_output.empty()) {
tmp_normal_atomic_nodes.emplace_back(peer_in_node);
continue;
}
connecting_output_atomic_nodes.emplace_back(peer_in_node);
tmp_normal_atomic_nodes.clear();
break;
}
}
}
}

if (!tmp_normal_atomic_nodes.empty()) {
normal_atomic_nodes_map[node] = tmp_normal_atomic_nodes;
}
}
}
return SUCCESS;
}

Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodePtr &node,
vector<int64_t> &mem_offset_end) {
auto node_op_desc = node->GetOpDesc();
@@ -908,6 +964,8 @@ Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodeP
GELOGE(ret, "Assign atomic workspace memory failed, node is %s.", node_op_desc->GetName().c_str());
return ret;
}
} else {
GELOGW("Current atomic node %s does not have attr ATOMIC_WORKSPACE_INFO.", node->GetName().c_str());
}

return SUCCESS;
@@ -1186,6 +1244,12 @@ Status GraphMemoryAssigner::AssignFusionAtomicWorkspaceMemory(const ge::OpDescPt
}

Status GraphMemoryAssigner::CheckOffset() {
std::map<std::string, std::string> anchor_to_symbol;
std::map<std::string, std::list<NodeIndexIO>> symbol_to_anchors;
if (GraphUtils::GetRefMapping(compute_graph_, symbol_to_anchors, anchor_to_symbol) != GRAPH_SUCCESS) {
GELOGE(FAILED, "Get ref-mapping for graph %s failed.", compute_graph_->GetName().c_str());
return FAILED;
}
for (const ge::NodePtr &node : compute_graph_->GetAllNodes()) {
GE_CHECK_NOTNULL(node->GetOpDesc());
vector<int64_t> input_list = node->GetOpDesc()->GetInputOffset();
@@ -1195,13 +1259,26 @@ Status GraphMemoryAssigner::CheckOffset() {
return FAILED;
}
}

bool need_update_output = false;
vector<int64_t> output_list = node->GetOpDesc()->GetOutputOffset();
for (auto output : output_list) {
if (output == ge::kInvalidOffset) {
for (uint32_t i = 0; i < output_list.size(); ++i) {
if (output_list[i] == ge::kInvalidOffset) {
GELOGE(FAILED, "Invalid offset in node: %s output: %ld.", node->GetName().c_str(), ge::kInvalidOffset);
return FAILED;
}
if (node->GetType() == IDENTITY || node->GetType() == READVARIABLEOP) {
auto symbol_offset = GetSymbolOutputOffset(anchor_to_symbol, symbol_to_anchors, node, i);
if (symbol_offset != ge::kInvalidOffset && output_list[i] != symbol_offset) {
output_list[i] = symbol_offset;
need_update_output = true;
}
}
}
if (need_update_output) {
node->GetOpDesc()->SetOutputOffset(output_list);
}

vector<int64_t> workspace_list = node->GetOpDesc()->GetWorkspace();
for (auto workspace : workspace_list) {
if (workspace == ge::kInvalidOffset) {
@@ -1280,6 +1357,7 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector<
vector<int64_t> memory_type;
auto tmp_op_desc = node->GetOpDesc();
origin_input_list = tmp_op_desc->GetInputOffset();
int64_t valid_input_index = 0;
bool has_mem_type_attr = ge::AttrUtils::GetListInt(tmp_op_desc, ATTR_NAME_INPUT_MEM_TYPE_LIST, memory_type);
for (const auto &anchor : node->GetAllInDataAnchors()) {
vector<int64_t> output_list;
@@ -1293,8 +1371,9 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector<
auto last_peer_out_op_desc = last_peer_out_node->GetOpDesc();
GE_CHECK_NOTNULL(last_peer_out_op_desc);
output_list = last_peer_out_op_desc->GetOutputOffset();
if (output_list.size() > static_cast<size_t>(peer_out_anchor->GetIdx())) {
auto input_index = anchor->GetIdx();
auto out_index = static_cast<unsigned long>(peer_out_anchor->GetIdx());
if (output_list.size() > static_cast<size_t>(out_index)) {
int64_t input_offset = output_list.at(out_index);
if (has_mem_type_attr) {
auto input_size = tmp_op_desc->GetInputsSize();
auto ori_input_offset_list_size = origin_input_list.size();
@@ -1308,26 +1387,21 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector<
}
// not hbm keep orignal inputoffest
// hbm inputoffset = original inputoffset + outputoffset
input_list.emplace_back(memory_type[input_index] == RT_MEMORY_L1
? origin_input_list[input_index]
: origin_input_list[input_index] + output_list.at(peer_out_anchor->GetIdx()));
GELOGI("fuison: node[%s] input[%d] is set from node[%s] out index[%d] offset[%ld]",
tmp_op_desc->GetName().c_str(), input_index,
peer_out_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), peer_out_anchor->GetIdx(),
input_list.back());
} else {
int64_t output_offset = output_list.at(peer_out_anchor->GetIdx());
const auto &in_node = GetKnownInputNode(peer_out_anchor->GetOwnerNode());
if (in_node->GetType() == CONSTANT) {
GeTensorDesc tensor_desc = tmp_op_desc->GetInputDesc(input_index);
GE_CHK_STATUS(TensorUtils::GetDataOffset(tensor_desc, output_offset));
}

GELOGI("node[%s] input[%d] is set from node[%s] out index[%d] offset[%ld]", tmp_op_desc->GetName().c_str(),
input_index, peer_out_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), peer_out_anchor->GetIdx(),
output_offset);
input_list.emplace_back(output_offset);
input_offset = (memory_type[valid_input_index] == RT_MEMORY_L1
? origin_input_list[valid_input_index]
: origin_input_list[valid_input_index] + output_list.at(out_index));
}
const auto &in_node = GetKnownInputNode(peer_out_anchor->GetOwnerNode());
if (in_node->GetType() == CONSTANT) {
GeTensorDesc tensor_desc = tmp_op_desc->GetInputDesc(static_cast<uint32_t>(anchor->GetIdx()));
GE_CHK_STATUS(TensorUtils::GetDataOffset(tensor_desc, input_offset));
}

GELOGI("%s node[%s] input[%d] is set from node[%s] out index[%lu] offset[%ld]",
has_mem_type_attr == true ? "Fusion" : "", tmp_op_desc->GetName().c_str(), valid_input_index,
peer_out_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(), out_index, input_offset);
input_list.emplace_back(input_offset);
valid_input_index++;
}
}
return ge::SUCCESS;
@@ -1422,83 +1496,49 @@ Status GraphMemoryAssigner::SetIndependentAtomicAttr(const ge::NodePtr &node, in
return SUCCESS;
}

Status GraphMemoryAssigner::SetLoopGraphAtomicAttr(const ge::NodePtr &node, int64_t atomic_mem_start) {
// set the address attr of atomic clean operator for loop graph
int64_t atomic_mem_size = memory_offset_[0].mem_offset_ - atomic_mem_start;
GELOGI("SetLoopGraphAtomicAttr beign, atomic_addr_clean start size is %ld, mem_size is %ld, mem_offset is %zu.",
atomic_mem_start, atomic_mem_size, memory_offset_[0].mem_offset_);
const auto &in_control_anchor = node->GetInControlAnchor();
if (atomic_mem_size != 0 && in_control_anchor != nullptr) {
for (auto &peer_out_control_anchor : in_control_anchor->GetPeerOutControlAnchors()) {
if (peer_out_control_anchor == nullptr) {
continue;
}
auto peer_out_node = peer_out_control_anchor->GetOwnerNode();
auto peer_out_node_desc = peer_out_node->GetOpDesc();
if (peer_out_node_desc == nullptr) {
continue;
}

GELOGD("SetLoopGraphAtomicAttr, node is %s, op type is %s.", peer_out_node_desc->GetName().c_str(),
peer_out_node_desc->GetType().c_str());

if (peer_out_node_desc->GetType() == ATOMICADDRCLEAN) {
GE_CHK_STATUS_EXEC(SetAtomicCleanAttr(peer_out_node, {atomic_mem_start}, {atomic_mem_size}),
GELOGE(FAILED, "SetAtomicCleanAttr failed.");
return FAILED);
}
}
}
return SUCCESS;
}

ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &n, const vector<int64_t> &atomic_mem_start,
ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &node, const vector<int64_t> &atomic_mem_start,
const vector<int64_t> &atomic_mem_size) {
for (ge::NodePtr &node : compute_graph_->GetAllNodes()) {
auto node_op_desc = node->GetOpDesc();
GE_IF_BOOL_EXEC(node_op_desc == nullptr, continue);

if (((n != nullptr) && (node->GetName() == n->GetName())) ||
((n == nullptr) && (node_op_desc->GetType() == ATOMICADDRCLEAN))) {
vector<int64_t> workspace_vector = node_op_desc->GetWorkspace();
vector<int64_t> workspace_byte_vector = node_op_desc->GetWorkspaceBytes();
workspace_vector.insert(workspace_vector.end(), atomic_mem_start.begin(), atomic_mem_start.end());
workspace_byte_vector.insert(workspace_byte_vector.end(), atomic_mem_size.begin(), atomic_mem_size.end());
node_op_desc->SetWorkspace(workspace_vector);
node_op_desc->SetWorkspaceBytes(workspace_byte_vector);

std::vector<int64_t> mem_start_vector;
// If GetListInt fail, mem_start_vector is empty.
(void)ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector);
mem_start_vector.insert(mem_start_vector.end(), atomic_mem_start.begin(), atomic_mem_start.end());
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector),
GELOGE(FAILED, "SetListInt failed.");
return FAILED);

std::vector<int64_t> mem_size_vector;
// If GetListInt fail, mem_size_vector is empty.
(void)ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector);
mem_size_vector.insert(mem_size_vector.end(), atomic_mem_size.begin(), atomic_mem_size.end());
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector),
GELOGE(FAILED, "SetListInt failed.");
return FAILED);

std::stringstream ss;
for (auto iter : atomic_mem_start) {
ss << iter << " ";
}
string atomic_mem_start_str = ss.str();
ss.clear();
ss.str("");
for (auto iter : atomic_mem_size) {
ss << iter << " ";
}
string atomic_mem_size_str = ss.str();

GELOGI("[IMAS]SetAtomicCleanAttr : Set graph[%s] atomic_node[%s] output offset [%s] size[%s] streamid[%ld]",
node->GetOwnerComputeGraph()->GetName().c_str(), node_op_desc->GetName().c_str(),
atomic_mem_start_str.c_str(), atomic_mem_size_str.c_str(), node->GetOpDesc()->GetStreamId());
auto node_op_desc = node->GetOpDesc();
if (node_op_desc != nullptr) {
GELOGD("Node %s, set atomic clean attr start.", node->GetName().c_str());
vector<int64_t> workspace_vector = node_op_desc->GetWorkspace();
vector<int64_t> workspace_byte_vector = node_op_desc->GetWorkspaceBytes();
workspace_vector.insert(workspace_vector.end(), atomic_mem_start.begin(), atomic_mem_start.end());
workspace_byte_vector.insert(workspace_byte_vector.end(), atomic_mem_size.begin(), atomic_mem_size.end());
node_op_desc->SetWorkspace(workspace_vector);
node_op_desc->SetWorkspaceBytes(workspace_byte_vector);

std::vector<int64_t> mem_start_vector;
// If GetListInt fail, mem_start_vector is empty.
(void)ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector);
mem_start_vector.insert(mem_start_vector.end(), atomic_mem_start.begin(), atomic_mem_start.end());
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector),
GELOGE(FAILED, "SetListInt failed.");
return FAILED);

std::vector<int64_t> mem_size_vector;
// If GetListInt fail, mem_size_vector is empty.
(void)ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector);
mem_size_vector.insert(mem_size_vector.end(), atomic_mem_size.begin(), atomic_mem_size.end());
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector),
GELOGE(FAILED, "SetListInt failed.");
return FAILED);

std::stringstream ss;
for (auto iter : atomic_mem_start) {
ss << iter << " ";
}
string atomic_mem_start_str = ss.str();
ss.clear();
ss.str("");
for (auto iter : atomic_mem_size) {
ss << iter << " ";
}
string atomic_mem_size_str = ss.str();

GELOGI("[IMAS]SetAtomicCleanAttr : Set graph[%s] atomic_node[%s] output offset [%s] size[%s] streamid[%ld]",
node->GetOwnerComputeGraph()->GetName().c_str(), node_op_desc->GetName().c_str(),
atomic_mem_start_str.c_str(), atomic_mem_size_str.c_str(), node->GetOpDesc()->GetStreamId());
}
return SUCCESS;
}


+ 6
- 7
src/ge/graph/build/memory/graph_mem_assigner.h View File

@@ -135,6 +135,9 @@ class GraphMemoryAssigner {

ge::Status ReAssignAtomicMemory(bool is_loop_graph);

ge::Status FilterAtomicNodesForMemoryAssign(std::map<NodePtr, vector<NodePtr>> &normal_atomic_nodes_map,
std::vector<NodePtr> &connecting_output_atomic_nodes);

ge::Status AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start,
int64_t &continuous_mem_size);

@@ -165,16 +168,12 @@ class GraphMemoryAssigner {

ge::Status SetIndependentAtomicAttr(const ge::NodePtr &node, int64_t atomic_mem_start,
const std::vector<int64_t> &mem_offset_end);
///
/// @brief set loop graph atomic attr
/// @param node, atomic memory assignment start offset
/// @param atomic_mem_start: atomic op memory start address
///
ge::Status SetLoopGraphAtomicAttr(const ge::NodePtr &node, int64_t atomic_mem_start);

ge::Status SetAtomicCleanAttr(const ge::NodePtr &n, const std::vector<int64_t> &atomic_mem_start,
ge::Status SetAtomicCleanAttr(const ge::NodePtr &node, const std::vector<int64_t> &atomic_mem_start,
const std::vector<int64_t> &atomic_mem_size);

ge::Status IsIndependentAtomicClean(const ge::NodePtr &node, bool &is_independent_atomic_clean_node);

void AlignMemOffset(const int64_t &mem_align_size);

ge::Status UpdateOpInputOffset(const NodePtr &node, vector<int64_t> &input_list) const;


+ 56
- 20
src/ge/graph/build/task_generator.cc View File

@@ -266,6 +266,14 @@ Status TaskGenerator::GenerateTask(RunContext &run_context, ComputeGraphPtr &gra
if (is_unknown_shape) {
GE_CHK_STATUS_RET(SetUnknownShapeStream(run_context, stream), "Set unknown shape stream failed.");
}
std::function<void()> callback = [&]() {
if (is_unknown_shape) {
if (DestroyUnknownShapeStream(run_context, stream) != SUCCESS) {
GELOGE(FAILED, "Destory unknown shape stream failed.");
}
}
};
GE_MAKE_GUARD(release, callback);

for (auto &node : graph->GetNodes(graph->GetGraphUnknownFlag())) {
OpDescPtr op_desc = node->GetOpDesc();
@@ -352,9 +360,6 @@ Status TaskGenerator::GenerateTask(RunContext &run_context, ComputeGraphPtr &gra
op_kernel_lib_name.c_str(), name.c_str(), type.c_str(), op_id, stream_id,
task_list_size_after - task_list_size_before);
}
if (is_unknown_shape) {
GE_CHK_STATUS_RET(DestroyUnknownShapeStream(run_context, stream), "Destory unknown shape stream failed.");
}
GE_TIMESTAMP_CALLNUM_EVENT_END(GenerateTask, "GraphBuild::GenerateTask");
return SUCCESS;
}
@@ -532,6 +537,9 @@ Status TaskGenerator::MarkNodeAndSetIndex(ComputeGraphPtr &graph) {
(void)ge_lib->DNNEngineManagerObj().GetDNNEngineName(node);
}

(void)op_desc->DelAttr(kIsFirstNode);
(void)op_desc->DelAttr(kIsLastNode);

all_stream_ops[op_desc->GetStreamId()].emplace_back(op_desc);
}

@@ -645,8 +653,6 @@ Status TaskGenerator::AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingP
vector<uint32_t> &all_reduce_nodes) const {
GELOGI("Start AutoFindBpOpIndex");
NodePtr bp_node = nullptr;
uint32_t last_bp = 0;
uint32_t iter_end = 0;
uint32_t current_idx = 0;
for (auto &node : graph->GetNodes(graph->GetGraphUnknownFlag())) {
OpDescPtr op_desc = node->GetOpDesc();
@@ -662,20 +668,40 @@ Status TaskGenerator::AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingP
all_reduce_nodes.emplace_back(current_idx);
GELOGI("Allreduce name %s, idx %u", op_desc->GetName().c_str(), current_idx);
}
if (op_desc->GetType() == NETOUTPUT) {
if (op_desc->GetName() == NODE_NAME_NET_OUTPUT) {
if (bp_node == nullptr) {
bp_node = node;
}
iter_end = current_idx;
GELOGI("Iter end name %s, idx %u", op_desc->GetName().c_str(), iter_end);
}
if (graph->GetNeedIteration()) {
if (op_desc->GetName() == NODE_NAME_NET_OUTPUT + '_' + NODE_NAME_STREAM_SWITCH + "_StreamActive") {
profiling_point.end_index.insert(current_idx);
GELOGI("Iter end name %s, idx %u, from Node_Output_IteratorCtrl_StreamSwitch_StreamActive",
op_desc->GetName().c_str(), current_idx);
}
if (op_desc->GetName() == NODE_NAME_FLOWCTRL_LOOP_ASSIGN) {
profiling_point.end_index.insert(current_idx);
GELOGI("Iter end name %s, idx %u, from FlowCtrl_LoopCond_ASSIGN", op_desc->GetName().c_str(), current_idx);
}
} else {
if (op_desc->GetName() == NODE_NAME_NET_OUTPUT) {
profiling_point.end_index.insert(current_idx);
GELOGI("Iter end name %s, idx %u, from NETOUTPUT", op_desc->GetName().c_str(), current_idx);
}
}
}
profiling_point.end_index = iter_end;

if (bp_node == nullptr) {
GELOGW("not find bp_node.");
return SUCCESS;
}

profiling_point.bp_index = FindLastBpFromBpNode(graph, bp_node);
return SUCCESS;
}

uint32_t TaskGenerator::FindLastBpFromBpNode(const ComputeGraphPtr &graph, const NodePtr &bp_node) const {
uint32_t last_bp = 0;
OpDescPtr bp_op_desc = nullptr;
for (auto &in_anchor : bp_node->GetAllInDataAnchors()) {
auto out_anchor = in_anchor->GetPeerOutAnchor();
@@ -691,7 +717,7 @@ Status TaskGenerator::AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingP
}

GE_CHECK_NOTNULL(bp_op_desc);
current_idx = 0;
uint32_t current_idx = 0;
for (auto &node : graph->GetNodes(graph->GetGraphUnknownFlag())) {
OpDescPtr op_desc = node->GetOpDesc();
GE_CHECK_NOTNULL(op_desc);
@@ -702,8 +728,7 @@ Status TaskGenerator::AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingP
break;
}
}
profiling_point.bp_index = last_bp;
return SUCCESS;
return last_bp;
}

Status TaskGenerator::FindFpOfEnv(const ComputeGraphPtr &graph, const std::string &fp_point_str,
@@ -734,7 +759,6 @@ Status TaskGenerator::FindBpOfEnv(const ComputeGraphPtr &graph, const std::strin
ProfilingPoint &profiling_point, vector<uint32_t> &all_reduce_nodes) const {
GELOGI("Start FindBpOfEnv");
uint32_t current_idx = 0;
uint32_t iter_end = 0;
uint32_t last_bp = 0;
for (auto &node : graph->GetNodes(graph->GetGraphUnknownFlag())) {
OpDescPtr op_desc = node->GetOpDesc();
@@ -745,10 +769,23 @@ Status TaskGenerator::FindBpOfEnv(const ComputeGraphPtr &graph, const std::strin
continue;
}

if (op_desc->GetType() == NETOUTPUT) {
iter_end = current_idx;
GELOGI("Iter end name %s, idx %u", op_desc->GetName().c_str(), iter_end);
if (graph->GetNeedIteration()) {
if (op_desc->GetName() == NODE_NAME_NET_OUTPUT + '_' + NODE_NAME_STREAM_SWITCH + "_StreamActive") {
profiling_point.end_index.insert(current_idx);
GELOGI("Iter end name %s, idx %u, from Node_Output_IteratorCtrl_StreamSwitch_StreamActive",
op_desc->GetName().c_str(), current_idx);
}
if (op_desc->GetName() == NODE_NAME_FLOWCTRL_LOOP_ASSIGN) {
profiling_point.end_index.insert(current_idx);
GELOGI("Iter end name %s, idx %u, from FlowCtrl_LoopCond_ASSIGN", op_desc->GetName().c_str(), current_idx);
}
} else {
if (op_desc->GetName() == NODE_NAME_NET_OUTPUT) {
profiling_point.end_index.insert(current_idx);
GELOGI("Iter end name %s, idx %u, from NETOUTPUT", op_desc->GetName().c_str(), current_idx);
}
}

if (op_desc->GetType() == HCOMALLREDUCE || op_desc->GetType() == HVDCALLBACKALLREDUCE) {
all_reduce_nodes.emplace_back(current_idx);
GELOGI("Allreduce name %s, idx %u", op_desc->GetName().c_str(), current_idx);
@@ -760,7 +797,6 @@ Status TaskGenerator::FindBpOfEnv(const ComputeGraphPtr &graph, const std::strin
}

profiling_point.bp_index = last_bp;
profiling_point.end_index = iter_end;
return SUCCESS;
}

@@ -857,7 +893,7 @@ Status TaskGenerator::InsertProfilingTaskBefore(const OpDescPtr &op_desc, const
bool is_profiling = (profiling_mode != nullptr) || ProfilingManager::Instance().ProfilingOn() ||
ProfilingManager::Instance().ProfilingTrainingTraceOn();
if (!is_profiling || (profiling_point.fp_index == 0) || (profiling_point.bp_index == 0) ||
(profiling_point.end_index == 0)) {
(profiling_point.end_index.empty())) {
return SUCCESS;
}
if (profiling_point.fp_index == node_index) {
@@ -914,7 +950,7 @@ Status TaskGenerator::InsertProfilingTaskAfter(const OpDescPtr &op_desc, const P
bool is_profiling = (profiling_mode != nullptr) || ProfilingManager::Instance().ProfilingOn() ||
ProfilingManager::Instance().ProfilingTrainingTraceOn();
if (!is_profiling || (profiling_point.fp_index == 0) || (profiling_point.bp_index == 0) ||
(profiling_point.end_index == 0)) {
(profiling_point.end_index.empty())) {
return SUCCESS;
}
if (profiling_point.bp_index == node_index) {
@@ -928,7 +964,7 @@ Status TaskGenerator::InsertProfilingTaskAfter(const OpDescPtr &op_desc, const P
bp_log_def->set_notify(false);
task_def_list.emplace_back(bp_task_def);
}
if (profiling_point.end_index == node_index) {
if (profiling_point.end_index.find(node_index) != profiling_point.end_index.end()) {
GELOGI("The iteration end operator is %s, idx %u", op_desc->GetName().c_str(), node_index);
TaskDef end_task_def;
end_task_def.set_type(RT_MODEL_TASK_PROFILER_TRACE);


+ 2
- 1
src/ge/graph/build/task_generator.h View File

@@ -36,7 +36,7 @@ class OpsKernelManager;
struct ProfilingPoint {
uint32_t fp_index = 0;
uint32_t bp_index = 0;
uint32_t end_index = 0;
std::set<uint32_t> end_index;
};
// Describes infos needed by generate task for fusion node
struct FusionTaskInfo {
@@ -112,6 +112,7 @@ class TaskGenerator {
Status AutoFindFpOpIndex(const ComputeGraphPtr &graph, ProfilingPoint &profiling_point) const;
Status AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingPoint &profiling_point,
vector<uint32_t> &all_reduce_nodes) const;
uint32_t FindLastBpFromBpNode(const ComputeGraphPtr &graph, const NodePtr &bp_node) const;

Status FindFpOfEnv(const ComputeGraphPtr &graph, const std::string &fp_point_str,
ProfilingPoint &profiling_point) const;


+ 0
- 2
src/ge/graph/common/ge_call_wrapper.h View File

@@ -18,8 +18,6 @@
#define GE_GE_CALL_WRAPPER_H_
#include "framework/common/debug/ge_log.h"

/*lint --emacro((773),GE_TIMESTAMP_START)*/
/*lint -esym(773,GE_TIMESTAMP_START)*/
#define GE_TIMESTAMP_START(stage) uint64_t startUsec_##stage = ge::GetCurrentTimestap()

#define GE_TIMESTAMP_END(stage, stage_name) \


+ 10
- 0
src/ge/graph/execute/graph_execute.cc View File

@@ -592,7 +592,17 @@ Status GraphExecutor::GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigI
GELOGW("GetAIPPInfo is not success.");
return ret;
}
return SUCCESS;
}

Status GraphExecutor::GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index) {
auto model_manager = ge::ModelManager::GetInstance();
GE_CHECK_NOTNULL(model_manager);
Status ret = model_manager->GetAippType(model_id, index, type, aipp_index);
if (ret != SUCCESS) {
GELOGW("Get aipp type is not success.");
return ret;
}
return SUCCESS;
}



+ 2
- 0
src/ge/graph/execute/graph_execute.h View File

@@ -75,6 +75,8 @@ class GraphExecutor {

static Status GetAIPPInfo(uint32_t model_id, uint32_t index, AippConfigInfo &aipp_info);

static Status GetAippType(uint32_t model_id, uint32_t index, InputAippType &type, size_t &aipp_index);

///
/// @ingroup ge
/// @brief Get dynamic batch_info


+ 33
- 22
src/ge/graph/load/new_model_manager/data_dumper.cc View File

@@ -671,12 +671,32 @@ Status DataDumper::LoadDumpInfo() {
op_mapping_info.set_flag(kAicpuLoadFlag);
op_mapping_info.set_dump_step(dump_properties_.GetDumpStep());
SetOpMappingLoopAddr(global_step_, loop_per_iter_, loop_cond_, op_mapping_info);
GELOGI("Dump step is %s and dump path is %s in load dump info", dump_properties_.GetDumpStep().c_str(),
dump_path.c_str());
GELOGI("Dump step is %s and dump path is %s dump model is %s in load dump info",
dump_properties_.GetDumpStep().c_str(), dump_path.c_str(), dump_list_key.c_str());
auto ret = BuildTaskInfo(op_mapping_info);
if (ret != SUCCESS) {
GELOGE(ret, "Build task info failed");
return ret;
}

SetEndGraphIdToAicpu(end_graph_task_id_, end_graph_stream_id_, op_mapping_info);

SetOpDebugIdToAicpu(op_debug_task_id_, op_debug_stream_id_, op_debug_addr_, op_mapping_info);

if (!op_list_.empty() || is_op_debug_ || is_end_graph_) {
auto ret = ExecuteLoadDumpInfo(op_mapping_info);
if (ret != SUCCESS) {
GELOGE(ret, "Execute load dump info failed");
return ret;
}
}
return SUCCESS;
}

Status DataDumper::BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info) {
for (const auto &op_iter : op_list_) {
auto op_desc = op_iter.op;
GELOGD("Op %s in model %s begin to add task in op_mapping_info", op_desc->GetName().c_str(), dump_list_key.c_str());
GELOGD("Op %s in model begin to add task in op_mapping_info", op_desc->GetName().c_str());
aicpu::dump::Task task;
task.set_end_graph(false);
task.set_task_id(op_iter.task_id);
@@ -695,16 +715,12 @@ Status DataDumper::LoadDumpInfo() {
}
if (dump_properties_.GetDumpMode() == kDumpInput) {
if (op_iter.is_task) {
Status ret = DumpInput(op_iter, task);
if (ret != SUCCESS) {
GELOGE(ret, "Dump input failed");
return ret;
}
GE_CHK_STATUS_RET(DumpInput(op_iter, task), "Dump input failed");
}
op_mapping_info.mutable_task()->Add(std::move(task));
continue;
}
if (dump_properties_.GetDumpMode() == kDumpAll) {
if (dump_properties_.GetDumpMode() == kDumpAll || is_op_debug_) {
auto ret = DumpOutput(op_iter, task);
if (ret != SUCCESS) {
GELOGE(ret, "Dump output failed when in dumping all");
@@ -721,18 +737,6 @@ Status DataDumper::LoadDumpInfo() {
continue;
}
}

SetEndGraphIdToAicpu(end_graph_task_id_, end_graph_stream_id_, op_mapping_info);

SetOpDebugIdToAicpu(op_debug_task_id_, op_debug_stream_id_, op_debug_addr_, op_mapping_info);

if (!op_list_.empty() || is_op_debug_) {
auto ret = ExecuteLoadDumpInfo(op_mapping_info);
if (ret != SUCCESS) {
GELOGE(ret, "Execute load dump info failed");
return ret;
}
}
return SUCCESS;
}

@@ -740,7 +744,6 @@ void DataDumper::SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id,
aicpu::dump::OpMappingInfo &op_mapping_info) {
if (dump_properties_.GetDumpMode() == kDumpOutput || dump_properties_.GetDumpMode() == kDumpInput ||
dump_properties_.GetDumpMode() == kDumpAll) {
GELOGI("Add end_graph_info to aicpu, task_id is %u, stream_id is %u", end_graph_task_id_, end_graph_stream_id_);
aicpu::dump::Task task;
task.set_end_graph(true);
task.set_task_id(end_graph_task_id_);
@@ -748,6 +751,14 @@ void DataDumper::SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id,
task.mutable_op()->set_op_name(NODE_NAME_END_GRAPH);
task.mutable_op()->set_op_type(ENDGRAPH);
op_mapping_info.mutable_task()->Add(std::move(task));

is_end_graph_ = true;
if (op_mapping_info.model_name_param_case() == aicpu::dump::OpMappingInfo::kModelName) {
GELOGI("Add end_graph_info to aicpu, model_name is %s, task_id is %u, stream_id is %u",
op_mapping_info.model_name().c_str(), end_graph_task_id_, end_graph_stream_id_);
return;
}
GELOGI("Add end_graph_info to aicpu, task_id is %u, stream_id is %u", end_graph_task_id_, end_graph_stream_id_);
}
}



+ 3
- 0
src/ge/graph/load/new_model_manager/data_dumper.h View File

@@ -116,6 +116,7 @@ class DataDumper {
std::vector<InnerDumpInfo> op_list_;
uint32_t end_graph_task_id_ = 0;
uint32_t end_graph_stream_id_ = 0;
bool is_end_graph_ = false;
std::multimap<std::string, InnerInputMapping> input_map_;
bool load_flag_;
uint32_t device_id_;
@@ -133,6 +134,8 @@ class DataDumper {

DumpProperties dump_properties_;

// Build task info of op mapping info
Status BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info);
Status DumpOutput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task);
Status DumpRefOutput(const DataDumper::InnerDumpInfo &inner_dump_info, aicpu::dump::Output &output, size_t i,
const std::string &node_name_index);


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save