Browse Source

!73 update ge src code folder

Merge pull request !73 from taoxiangdong/master
tags/v1.1.0
lujiale Gitee 4 years ago
parent
commit
b8e0cc7c2c
100 changed files with 582 additions and 74 deletions
  1. +10
    -10
      CMakeLists.txt
  2. +2
    -2
      build.sh
  3. +22
    -14
      ge/CMakeLists.txt
  4. +19
    -8
      ge/analyzer/analyzer.cc
  5. +2
    -0
      ge/analyzer/analyzer.h
  6. +11
    -9
      ge/client/CMakeLists.txt
  7. +1
    -1
      ge/client/ge_api.cc
  8. +375
    -0
      ge/client/ge_prof.cc
  9. +4
    -0
      ge/client/module.mk
  10. +10
    -7
      ge/common/CMakeLists.txt
  11. +0
    -0
      ge/common/auth/file_saver.cc
  12. +0
    -0
      ge/common/auth/file_saver.h
  13. +0
    -0
      ge/common/base64.h
  14. +0
    -0
      ge/common/context/ctx.cc
  15. +0
    -0
      ge/common/convert/pb2json.cc
  16. +0
    -0
      ge/common/convert/pb2json.h
  17. +0
    -0
      ge/common/cust_aicpu_kernel_store.cc
  18. +0
    -0
      ge/common/cust_aicpu_kernel_store.h
  19. +0
    -0
      ge/common/debug/memory_dumper.cc
  20. +0
    -0
      ge/common/debug/memory_dumper.h
  21. +3
    -8
      ge/common/dump/dump_manager.cc
  22. +0
    -1
      ge/common/dump/dump_manager.h
  23. +1
    -1
      ge/common/dump/dump_op.cc
  24. +0
    -0
      ge/common/dump/dump_op.h
  25. +34
    -3
      ge/common/dump/dump_properties.cc
  26. +18
    -0
      ge/common/dump/dump_properties.h
  27. +0
    -0
      ge/common/fmk_error_codes.cc
  28. +0
    -0
      ge/common/formats/format_transfers/datatype_transfer.cc
  29. +0
    -0
      ge/common/formats/format_transfers/datatype_transfer.h
  30. +0
    -0
      ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc
  31. +0
    -0
      ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h
  32. +0
    -0
      ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc
  33. +0
    -0
      ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h
  34. +0
    -0
      ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc
  35. +0
    -0
      ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h
  36. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fractal_nz.cc
  37. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fractal_nz.h
  38. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fractal_z.cc
  39. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fractal_z.h
  40. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fractal_zz.cc
  41. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fractal_zz.h
  42. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc
  43. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h
  44. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc
  45. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fracz_nchw.h
  46. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc
  47. +0
    -0
      ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h
  48. +0
    -0
      ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc
  49. +0
    -0
      ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h
  50. +0
    -0
      ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc
  51. +0
    -0
      ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h
  52. +0
    -0
      ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc
  53. +0
    -0
      ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h
  54. +0
    -0
      ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc
  55. +0
    -0
      ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h
  56. +0
    -0
      ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc
  57. +0
    -0
      ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h
  58. +0
    -0
      ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc
  59. +0
    -0
      ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h
  60. +0
    -0
      ge/common/formats/format_transfers/format_transfer_transpose.cc
  61. +0
    -0
      ge/common/formats/format_transfers/format_transfer_transpose.h
  62. +0
    -0
      ge/common/formats/formats.cc
  63. +0
    -0
      ge/common/formats/formats.h
  64. +0
    -0
      ge/common/formats/utils/formats_definitions.h
  65. +0
    -0
      ge/common/formats/utils/formats_trans_utils.cc
  66. +0
    -0
      ge/common/formats/utils/formats_trans_utils.h
  67. +0
    -0
      ge/common/fp16_t.cc
  68. +0
    -0
      ge/common/fp16_t.h
  69. +0
    -0
      ge/common/ge/datatype_util.cc
  70. +0
    -0
      ge/common/ge/datatype_util.h
  71. +0
    -0
      ge/common/ge/ge_util.h
  72. +6
    -3
      ge/common/ge/op_tiling_manager.cc
  73. +0
    -0
      ge/common/ge/op_tiling_manager.h
  74. +0
    -0
      ge/common/ge/plugin_manager.cc
  75. +0
    -0
      ge/common/ge/plugin_manager.h
  76. +0
    -0
      ge/common/ge/tbe_plugin_manager.cc
  77. +0
    -0
      ge/common/ge/tbe_plugin_manager.h
  78. +1
    -0
      ge/common/ge_common.mk
  79. +0
    -0
      ge/common/ge_format_util.cc
  80. +19
    -1
      ge/common/helper/model_cache_helper.cc
  81. +0
    -0
      ge/common/helper/model_cache_helper.h
  82. +17
    -2
      ge/common/helper/model_helper.cc
  83. +0
    -0
      ge/common/helper/om_file_helper.cc
  84. +0
    -0
      ge/common/kernel_store.cc
  85. +0
    -0
      ge/common/kernel_store.h
  86. +0
    -0
      ge/common/math/fp16_math.cc
  87. +0
    -0
      ge/common/math/fp16_math.h
  88. +0
    -0
      ge/common/math/math_util.h
  89. +0
    -0
      ge/common/math_util.h
  90. +0
    -0
      ge/common/model_parser/base.cc
  91. +0
    -0
      ge/common/model_parser/base.h
  92. +0
    -0
      ge/common/model_saver.cc
  93. +0
    -0
      ge/common/model_saver.h
  94. +0
    -0
      ge/common/module.mk
  95. +0
    -0
      ge/common/op/attr_value_util.cc
  96. +0
    -0
      ge/common/op/ge_op_utils.cc
  97. +15
    -2
      ge/common/profiling/profiling_manager.cc
  98. +1
    -1
      ge/common/profiling/profiling_manager.h
  99. +6
    -0
      ge/common/properties_manager.cc
  100. +5
    -1
      ge/common/properties_manager.h

+ 10
- 10
CMakeLists.txt View File

@@ -20,7 +20,7 @@ add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(GE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
set(GE_PROTO_DIR ${GE_SOURCE_DIR}/src)
set(GE_PROTO_DIR ${GE_SOURCE_DIR}/)

if (NOT BUILD_PATH)
set(BUILD_PATH "${CMAKE_SOURCE_DIR}/build")
@@ -112,19 +112,19 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILE__='\"$(subst $(realpath ${CMAKE

# compile libraries from following directories
# libgraph is compiled in any situation
add_subdirectory(${GE_SOURCE_DIR}/src/common/graph)
add_subdirectory(${GE_SOURCE_DIR}/metadef/graph)
if(ENABLE_D)
# if MindSpore compiles in D mode, compile the following libraries
add_subdirectory(${GE_SOURCE_DIR}/src/ge/common)
add_subdirectory(${GE_SOURCE_DIR}/src/ge/ge_runtime)
add_subdirectory(${GE_SOURCE_DIR}/ge/common)
add_subdirectory(${GE_SOURCE_DIR}/ge/ge_runtime)
elseif(GE_ONLY)
# standalone GraphEngine compiles all following libraries
add_subdirectory(${GE_SOURCE_DIR}/src/ge/common)
add_subdirectory(${GE_SOURCE_DIR}/src/ge/ge_runtime)
add_subdirectory(${GE_SOURCE_DIR}/src/ge/ge_local_engine)
add_subdirectory(${GE_SOURCE_DIR}/src/ge/graph/build/memory)
add_subdirectory(${GE_SOURCE_DIR}/src/ge/)
add_subdirectory(${GE_SOURCE_DIR}/src/ge/plugin/engine)
add_subdirectory(${GE_SOURCE_DIR}/ge/common)
add_subdirectory(${GE_SOURCE_DIR}/ge/ge_runtime)
add_subdirectory(${GE_SOURCE_DIR}/ge/ge_local_engine)
add_subdirectory(${GE_SOURCE_DIR}/ge/graph/build/memory)
add_subdirectory(${GE_SOURCE_DIR}/ge/)
add_subdirectory(${GE_SOURCE_DIR}/ge/plugin/engine)
endif()

# if (ENABLE_GE_COV OR ENABLE_GE_UT OR ENABLE_GE_ST)


+ 2
- 2
build.sh View File

@@ -191,8 +191,8 @@ generate_package()
mk_dir "${OUTPUT_PATH}/${ATC_PATH}/${OPSKERNEL_PATH}"

find output/ -name graphengine_lib.tar -exec rm {} \;
cp src/ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH}
cp src/ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH}
cp ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH}
cp ge/engine_manager/engine_conf.json ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH}

find output/ -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${FWK_PATH}/${NNENGINE_PATH}/../ \;
find output/ -maxdepth 1 -name libengine.so -exec cp -f {} ${OUTPUT_PATH}/${ATC_PATH}/${NNENGINE_PATH}/../ \;


src/ge/CMakeLists.txt → ge/CMakeLists.txt View File

@@ -18,20 +18,20 @@
# compiling proto files generates some warnings, use no-unused-variable to suppress them
set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}")
file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"../proto/fusion_model.proto"
"../proto/optimizer_priority.proto"
"${GE_SOURCE_DIR}/metadef/proto/fusion_model.proto"
"${GE_SOURCE_DIR}/metadef/proto/optimizer_priority.proto"
)
file(GLOB PROTO_CLIENT_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"../proto/ge_api.proto"
"${GE_SOURCE_DIR}/metadef/proto/ge_api.proto"
)
file(GLOB PROTO_HEADER_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"../proto/om.proto"
"../proto/task.proto"
"../proto/insert_op.proto"
"../proto/ge_ir.proto"
"../proto/fwk_adapter.proto"
"../proto/op_mapping_info.proto"
"../proto/dump_task.proto"
"${GE_SOURCE_DIR}/metadef/proto/om.proto"
"${GE_SOURCE_DIR}/metadef/proto/task.proto"
"${GE_SOURCE_DIR}/metadef/proto/insert_op.proto"
"${GE_SOURCE_DIR}/metadef/proto/ge_ir.proto"
"${GE_SOURCE_DIR}/metadef/proto/fwk_adapter.proto"
"${GE_SOURCE_DIR}/metadef/proto/op_mapping_info.proto"
"${GE_SOURCE_DIR}/metadef/proto/dump_task.proto"
)
ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST})
ge_protobuf_generate(ge PROTO_CLIENT_SRCS PROTO_CLIENT_HDRS ${PROTO_CLIENT_LIST})
@@ -39,15 +39,20 @@ ge_protobuf_generate(ge PROTO_HEADER_SRCS PROTO_HEADER_HDRS ${PROTO_HEADER_LIST}
# include directories
include_directories(${CMAKE_CURRENT_LIST_DIR})
include_directories(${GE_SOURCE_DIR})
include_directories(${GE_SOURCE_DIR}/src)
include_directories(${GE_SOURCE_DIR}/src/ge/analyzer)
include_directories(${GE_SOURCE_DIR}/ge)
include_directories(${GE_SOURCE_DIR}/ge/analyzer)
include_directories(${GE_SOURCE_DIR}/inc)
include_directories(${GE_SOURCE_DIR}/inc/common/util)
include_directories(${GE_SOURCE_DIR}/inc)
include_directories(${GE_SOURCE_DIR}/inc/external)
include_directories(${GE_SOURCE_DIR}/inc/external/graph)
include_directories(${GE_SOURCE_DIR}/inc/external/ge)
include_directories(${GE_SOURCE_DIR}/inc/framework)
include_directories(${GE_SOURCE_DIR}/inc/framework/common)
include_directories(${GE_SOURCE_DIR}/inc/graph)
include_directories(${GE_SOURCE_DIR}/metadef)
include_directories(${GE_SOURCE_DIR}/metadef/inc)
include_directories(${GE_SOURCE_DIR}/metadef/inc/external)
include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph)
include_directories(${GE_SOURCE_DIR}/metadef/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)
@@ -58,6 +63,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"
@@ -225,6 +231,7 @@ target_link_libraries(ge_runner
${msprof}
${runtime}
${resouce}
${ascend_hal}
rt
dl)

@@ -335,6 +342,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"

src/ge/analyzer/analyzer.cc → 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();
}

src/ge/analyzer/analyzer.h → 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_

src/ge/client/CMakeLists.txt → ge/client/CMakeLists.txt View File

@@ -17,18 +17,19 @@
# add all proto files, generate corresponding .h and .cc files
set(CMAKE_CXX_FLAGS "-Wno-unused-variable ${CMAKE_CXX_FLAGS}")
file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"../../proto/ge_api.proto"
"../proto/ge_api.proto"
)

file(GLOB PROTO_HEADER_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"../../proto/ge_ir.proto"
"../../proto/task.proto"
"../../proto/om.proto"
"../../proto/insert_op.proto"
"../proto/ge_ir.proto"
"../proto/task.proto"
"../proto/om.proto"
"../proto/insert_op.proto"
)

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})
@@ -36,14 +37,14 @@ ge_protobuf_generate(ge PROTO_HEADER_SRCS PROTO_HEADER_HDRS ${PROTO_HEADER_LIST}

# include directories
include_directories(${CMAKE_CURRENT_LIST_DIR})
include_directories(${GE_SOURCE_DIR}/src/ge)
include_directories(${GE_SOURCE_DIR}/src)
include_directories(${GE_SOURCE_DIR}/ge)
include_directories(${GE_SOURCE_DIR}/inc)
include_directories(${GE_SOURCE_DIR}/inc/external)
include_directories(${GE_SOURCE_DIR}/inc/external/graph)
include_directories(${GE_SOURCE_DIR}/inc/common)
include_directories(${GE_SOURCE_DIR}/inc/framework)
include_directories(${GE_SOURCE_DIR}/inc/graph)
include_directories(${GE_SOURCE_DIR}/metadef/inc)
include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph)
include_directories(${GE_SOURCE_DIR}/metadef/inc/graph)
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc)
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce)
include_directories(${CMAKE_BINARY_DIR})
@@ -66,5 +67,6 @@ target_link_libraries(ge_client
${slog}
${mmpa}
${runtime}
${msprof}
rt
dl)

src/ge/client/ge_api.cc → ge/client/ge_api.cc View File

@@ -39,7 +39,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

+ 375
- 0
ge/client/ge_prof.cc View File

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

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

namespace {
const uint32_t kMaxDeviceNum = 64;
const std::string PROFILING_INIT = "prof_init";
const std::string PROFILING_FINALIZE = "prof_finalize";
const std::string PROFILING_START = "prof_start";
const std::string PROFILING_STOP = "prof_stop";
const std::string DEVICES_NUMS = "devNums";
const std::string DEVICE_ID_LIST = "devIdList";
const std::string AICORE_METRICS = "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"},
{ge::kAicoreMetricsAll, "AICORE_METRICS_ALL"}};

const std::map<uint64_t, uint64_t> kDataTypeConfigMapping = {{ge::kProfAcl, PROF_ACL_API},
{ge::kProfTaskTime, PROF_TASK_TIME},
{ge::kProfAiCoreMetrics, PROF_AICORE_METRICS},
{ge::kProfAicpuTrace, PROF_AICPU_TRACE},
{ge::kProfModelExecute, PROF_MODEL_EXECUTE},
{ge::kProfRuntimeApi, PROF_RUNTIME_API},
{ge::kProfRuntimeTrace, PROF_RUNTIME_TRACE},
{ge::kProfScheduleTimeline, PROF_SCHEDULE_TIMELINE},
{ge::kProfScheduleTrace, PROF_SCHEDULE_TRACE},
{ge::kProfAiVectorCoreMetrics, PROF_AIVECTORCORE_METRICS},
{ge::kProfSubtaskTime, PROF_SUBTASK_TIME},
{ge::kProfTrainingTrace, PROF_TRAINING_TRACE},
{ge::kProfHcclTrace, PROF_HCCL_TRACE},
{ge::kProfDataProcess, PROF_DATA_PROCESS},
{ge::kProfTaskTrace, PROF_TASK_TRACE},
{ge::kProfModelLoad, PROF_MODEL_LOAD}};
} // 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 = PROFILING_INIT;
command.module_index = kProfModelLoad | kProfTrainingTrace;
ret = graph_loader.CommandHandle(command);
if (ret != SUCCESS) {
GELOGE(ret, "Handle profiling command %s failed, config = %s", PROFILING_INIT.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 = PROFILING_FINALIZE;
Status ret = graph_loader.CommandHandle(command);
if (ret != SUCCESS) {
GELOGE(ret, "Handle profiling command %s failed.", PROFILING_FINALIZE.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(DEVICES_NUMS);
prof_config_params.emplace_back(std::to_string(profiler_config->config.devNums));
prof_config_params.emplace_back(DEVICE_ID_LIST);
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(AICORE_METRICS);
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);
uint64_t data_type = 0;
for (auto &iter : kDataTypeConfigMapping) {
if ((iter.first & data_type_config) == iter.first) {
data_type |= iter.second;
}
}
config->config.dataTypeConfig = data_type;
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 = PROFILING_START;
command.cmd_params = prof_params;
command.module_index = profiler_config->config.dataTypeConfig;
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;
}

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

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 = PROFILING_STOP;
command.cmd_params = prof_params;
command.module_index = profiler_config->config.dataTypeConfig;
ret = graph_loader.CommandHandle(command);
if (ret != SUCCESS) {
GELOGE(ret, "Handle profiling command failed");
return FAILED;
}

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

src/ge/client/module.mk → 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,6 +70,8 @@ LOCAL_SHARED_LIBRARIES := \
libregister \
libge_compiler \
libge_common \
libmsprof



LOCAL_LDFLAGS := -lrt -ldl
@@ -102,6 +105,7 @@ LOCAL_SHARED_LIBRARIES := \
libruntime \
libge_compiler \
libge_common \
libmsprof


LOCAL_LDFLAGS := -lrt -ldl

src/ge/common/CMakeLists.txt → ge/common/CMakeLists.txt View File

@@ -15,10 +15,10 @@

# libge_common.so
file(GLOB PROTO_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
"../../proto/om.proto"
"../../proto/ge_ir.proto"
"../../proto/task.proto"
"../../proto/insert_op.proto"
"${GE_SOURCE_DIR}/metadef/proto/om.proto"
"${GE_SOURCE_DIR}/metadef/proto/ge_ir.proto"
"${GE_SOURCE_DIR}/metadef/proto/task.proto"
"${GE_SOURCE_DIR}/metadef/proto/insert_op.proto"
)

file(GLOB SRC_LIST RELATIVE ${CMAKE_CURRENT_LIST_DIR}
@@ -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"
@@ -71,13 +72,15 @@ ge_protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST})
# include directories
include_directories(${CMAKE_CURRENT_LIST_DIR})
include_directories(${CMAKE_CURRENT_LIST_DIR}/op)
include_directories(${GE_SOURCE_DIR}/src/ge)
include_directories(${GE_SOURCE_DIR}/ge)
include_directories(${GE_SOURCE_DIR}/inc)
include_directories(${GE_SOURCE_DIR}/inc/common/util)
include_directories(${GE_SOURCE_DIR}/inc/external)
include_directories(${GE_SOURCE_DIR}/inc/external/graph)
include_directories(${GE_SOURCE_DIR}/inc/framework)
include_directories(${GE_SOURCE_DIR}/inc/graph)
include_directories(${GE_SOURCE_DIR}/metadef/inc)
include_directories(${GE_SOURCE_DIR}/metadef/inc/external)
include_directories(${GE_SOURCE_DIR}/metadef/inc/external/graph)
include_directories(${GE_SOURCE_DIR}/metadef/inc/graph)
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc)
include_directories(${GE_SOURCE_DIR}/third_party/fwkacllib/inc/cce)
include_directories(${CMAKE_BINARY_DIR})

src/ge/common/auth/file_saver.cc → ge/common/auth/file_saver.cc View File


src/ge/common/auth/file_saver.h → ge/common/auth/file_saver.h View File


src/ge/common/base64.h → ge/common/base64.h View File


src/ge/common/context/ctx.cc → ge/common/context/ctx.cc View File


src/ge/common/convert/pb2json.cc → ge/common/convert/pb2json.cc View File


src/ge/common/convert/pb2json.h → ge/common/convert/pb2json.h View File


src/ge/common/cust_aicpu_kernel_store.cc → ge/common/cust_aicpu_kernel_store.cc View File


src/ge/common/cust_aicpu_kernel_store.h → ge/common/cust_aicpu_kernel_store.h View File


src/ge/common/debug/memory_dumper.cc → ge/common/debug/memory_dumper.cc View File


src/ge/common/debug/memory_dumper.h → ge/common/debug/memory_dumper.h View File


src/ge/common/dump/dump_manager.cc → 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_;

src/ge/common/dump/dump_manager.h → 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();

src/ge/common/dump/dump_op.cc → ge/common/dump/dump_op.cc View File


src/ge/common/dump/dump_op.h → ge/common/dump/dump_op.h View File


src/ge/common/dump/dump_properties.cc → 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_;

src/ge/common/dump/dump_properties.h → 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;

src/ge/common/fmk_error_codes.cc → ge/common/fmk_error_codes.cc View File


src/ge/common/formats/format_transfers/datatype_transfer.cc → ge/common/formats/format_transfers/datatype_transfer.cc View File


src/ge/common/formats/format_transfers/datatype_transfer.h → ge/common/formats/format_transfers/datatype_transfer.h View File


src/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc → ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc View File


src/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h → ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.h View File


src/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc → ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc View File


src/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h → ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.h View File


src/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc → ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc View File


src/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h → ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.h View File


src/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc → ge/common/formats/format_transfers/format_transfer_fractal_nz.cc View File


src/ge/common/formats/format_transfers/format_transfer_fractal_nz.h → ge/common/formats/format_transfers/format_transfer_fractal_nz.h View File


src/ge/common/formats/format_transfers/format_transfer_fractal_z.cc → ge/common/formats/format_transfers/format_transfer_fractal_z.cc View File


src/ge/common/formats/format_transfers/format_transfer_fractal_z.h → ge/common/formats/format_transfers/format_transfer_fractal_z.h View File


src/ge/common/formats/format_transfers/format_transfer_fractal_zz.cc → ge/common/formats/format_transfers/format_transfer_fractal_zz.cc View File


src/ge/common/formats/format_transfers/format_transfer_fractal_zz.h → ge/common/formats/format_transfers/format_transfer_fractal_zz.h View File


src/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc → ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc View File


src/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h → ge/common/formats/format_transfers/format_transfer_fracz_hwcn.h View File


src/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc → ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc View File


src/ge/common/formats/format_transfers/format_transfer_fracz_nchw.h → ge/common/formats/format_transfers/format_transfer_fracz_nchw.h View File


src/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc → ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc View File


src/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h → ge/common/formats/format_transfers/format_transfer_fracz_nhwc.h View File


src/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc → ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc View File


src/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h → ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.h View File


src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc → ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc View File


src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h → ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.h View File


src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc → ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc View File


src/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h → ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.h View File


src/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc → ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc View File


src/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h → ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.h View File


src/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc → ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc View File


src/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h → ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.h View File


src/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc → ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc View File


src/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h → ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h View File


src/ge/common/formats/format_transfers/format_transfer_transpose.cc → ge/common/formats/format_transfers/format_transfer_transpose.cc View File


src/ge/common/formats/format_transfers/format_transfer_transpose.h → ge/common/formats/format_transfers/format_transfer_transpose.h View File


src/ge/common/formats/formats.cc → ge/common/formats/formats.cc View File


src/ge/common/formats/formats.h → ge/common/formats/formats.h View File


src/ge/common/formats/utils/formats_definitions.h → ge/common/formats/utils/formats_definitions.h View File


src/ge/common/formats/utils/formats_trans_utils.cc → ge/common/formats/utils/formats_trans_utils.cc View File


src/ge/common/formats/utils/formats_trans_utils.h → ge/common/formats/utils/formats_trans_utils.h View File


src/ge/common/fp16_t.cc → ge/common/fp16_t.cc View File


src/ge/common/fp16_t.h → ge/common/fp16_t.h View File


src/ge/common/ge/datatype_util.cc → ge/common/ge/datatype_util.cc View File


src/ge/common/ge/datatype_util.h → ge/common/ge/datatype_util.h View File


src/ge/common/ge/ge_util.h → ge/common/ge/ge_util.h View File


src/ge/common/ge/op_tiling_manager.cc → 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;

src/ge/common/ge/op_tiling_manager.h → ge/common/ge/op_tiling_manager.h View File


src/ge/common/ge/plugin_manager.cc → ge/common/ge/plugin_manager.cc View File


src/ge/common/ge/plugin_manager.h → ge/common/ge/plugin_manager.h View File


src/ge/common/ge/tbe_plugin_manager.cc → ge/common/ge/tbe_plugin_manager.cc View File


src/ge/common/ge/tbe_plugin_manager.h → ge/common/ge/tbe_plugin_manager.h View File


src/ge/common/ge_common.mk → 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 \

src/ge/common/ge_format_util.cc → ge/common/ge_format_util.cc View File


src/ge/common/helper/model_cache_helper.cc → 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;

src/ge/common/helper/model_cache_helper.h → ge/common/helper/model_cache_helper.h View File


src/ge/common/helper/model_helper.cc → 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;
}

src/ge/common/helper/om_file_helper.cc → ge/common/helper/om_file_helper.cc View File


src/ge/common/kernel_store.cc → ge/common/kernel_store.cc View File


src/ge/common/kernel_store.h → ge/common/kernel_store.h View File


src/ge/common/math/fp16_math.cc → ge/common/math/fp16_math.cc View File


src/ge/common/math/fp16_math.h → ge/common/math/fp16_math.h View File


src/ge/common/math/math_util.h → ge/common/math/math_util.h View File


src/ge/common/math_util.h → ge/common/math_util.h View File


src/ge/common/model_parser/base.cc → ge/common/model_parser/base.cc View File


src/ge/common/model_parser/base.h → ge/common/model_parser/base.h View File


src/ge/common/model_saver.cc → ge/common/model_saver.cc View File


src/ge/common/model_saver.h → ge/common/model_saver.h View File


src/ge/common/module.mk → ge/common/module.mk View File


src/ge/common/op/attr_value_util.cc → ge/common/op/attr_value_util.cc View File


src/ge/common/op/ge_op_utils.cc → ge/common/op/ge_op_utils.cc View File


src/ge/common/profiling/profiling_manager.cc → ge/common/profiling/profiling_manager.cc View File

@@ -51,10 +51,23 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager &ProfilingMana
return profiling_manager;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::Init(const Options &options) {
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::Init(const Options &options,
bool convert_2_phy_device_id) {
#ifdef DAVINCI_SUPPORT_PROFILING
vector<int32_t>().swap(device_id_);
device_id_.push_back(options.device_id);
// profiling need phy device id
if (!convert_2_phy_device_id) {
device_id_.push_back(options.device_id);
} else {
uint32_t phy_device_id = 0;
rtError_t rt_ret = rtGetDevicePhyIdByIndex(static_cast<uint32_t>(options.device_id), &phy_device_id);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "runtime get phy_device_id failed, current phy_device_id:%u", phy_device_id);
return FAILED;
}
device_id_.push_back(phy_device_id);
}

job_id_ = options.job_id;

Status ret;

src/ge/common/profiling/profiling_manager.h → ge/common/profiling/profiling_manager.h View File

@@ -69,7 +69,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager {
ProfilingManager();
virtual ~ProfilingManager();
static ProfilingManager &Instance();
ge::Status Init(const Options &options);
ge::Status Init(const Options &options, bool convert_2_phy_device_id = false);
ge::Status InitFromOptions(const Options &options);
ge::Status InitFromAclCfg(const std::string &config);
ge::Status StartProfiling(int32_t iter, int32_t device_id);

src/ge/common/properties_manager.cc → 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);

src/ge/common/properties_manager.h → 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:

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

Loading…
Cancel
Save