sync-from-trunk-to-blue-zone-0928

pull/74/head
wuweikang 4 years ago
parent 86596e18ef
commit bf316a3eeb

@ -91,6 +91,7 @@ else()
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})
endif()
# add compile flags

@ -25,22 +25,11 @@
namespace ge {
enum ProfDataTypeConfig {
kProfAcl = 0x0001,
kProfTaskTime = 0x0002,
kProfAiCoreMetrics = 0x0004,
kProfAicpuTrace = 0x0008,
kProfModelExecute = 0x0010,
kProfRuntimeApi = 0x0020,
kProfRuntimeTrace = 0x0040,
kProfScheduleTimeline = 0x0080,
kProfScheduleTrace = 0x0100,
kProfAiVectorCoreMetrics = 0x0200,
kProfSubtaskTime = 0x0400,
kProfTrainingTrace = 0x0800,
kProfHcclTrace = 0x1000,
kProfDataProcess = 0x2000,
kProfTaskTrace = 0x3842,
kProfModelLoad = 0x8000000000000000
kProfHcclTrace = 0x1000
};
enum ProfilingAicoreMetrics {
@ -49,20 +38,64 @@ enum ProfilingAicoreMetrics {
kAicoreSynchronization = 2,
kAicoreMemory = 3,
kAicoreInternalMemory = 4,
kAicoreStall = 5,
kAicoreMetricsAll = 255 // only for op_trace
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

@ -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";

@ -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);

@ -141,8 +141,12 @@ 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;

@ -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_;

@ -122,8 +122,12 @@ 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";

@ -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;

@ -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 \

@ -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

@ -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,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)
@ -227,6 +228,7 @@ target_link_libraries(ge_runner
${runtime}
${resouce}
${ascend_hal}
${adump_server}
rt
dl)
@ -237,6 +239,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"

@ -29,13 +29,14 @@ 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 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"},
@ -43,25 +44,7 @@ const std::map<ge::ProfilingAicoreMetrics, std::string> kProfAicoreMetricsToStri
{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}};
{ge::kAicoreStall, "AICORE_STALL"}};
} // namespace
static bool g_graph_prof_init_ = false;
@ -107,11 +90,11 @@ Status aclgrphProfInit(const char *profiler_path, uint32_t length) {
GraphLoader graph_loader;
Command command;
command.cmd_params.clear();
command.cmd_type = PROFILING_INIT;
command.module_index = kProfModelLoad | kProfTrainingTrace;
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", PROFILING_INIT.c_str(), profiler_path);
GELOGE(ret, "Handle profiling command %s failed, config = %s", kProfilingInit.c_str(), profiler_path);
return ret;
}
if (!g_graph_prof_init_) {
@ -143,10 +126,10 @@ Status aclgrphProfFinalize() {
GraphLoader graph_loader;
Command command;
command.cmd_params.clear();
command.cmd_type = PROFILING_FINALIZE;
command.cmd_type = kProfilingFinalize;
Status ret = graph_loader.CommandHandle(command);
if (ret != SUCCESS) {
GELOGE(ret, "Handle profiling command %s failed.", PROFILING_FINALIZE.c_str());
GELOGE(ret, "Handle profiling command %s failed.", kProfilingFinalize.c_str());
return ret;
}
@ -164,9 +147,9 @@ Status aclgrphProfFinalize() {
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(kDeviceNums);
prof_config_params.emplace_back(std::to_string(profiler_config->config.devNums));
prof_config_params.emplace_back(DEVICE_ID_LIST);
prof_config_params.emplace_back(kDeviceIdList);
std::string devID = "";
if (profiler_config->config.devNums == 0) {
GELOGW("The device num is invalid.");
@ -180,7 +163,7 @@ bool TransProfConfigToParam(const aclgrphProfConfig *profiler_config, vector<str
}
prof_config_params.push_back(devID);
prof_config_params.push_back(AICORE_METRICS);
prof_config_params.push_back(kAicoreMetrics);
auto iter =
kProfAicoreMetricsToString.find(static_cast<ProfilingAicoreMetrics>(profiler_config->config.aicoreMetrics));
if (iter == kProfAicoreMetricsToString.end()) {
@ -250,13 +233,7 @@ aclgrphProfConfig *aclgrphProfCreateConfig(uint32_t *deviceid_list, uint32_t dev
}
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;
config->config.dataTypeConfig = data_type_config;
GELOGI("Successfully create prof config.");
return config;
}
@ -309,9 +286,11 @@ Status aclgrphProfStart(aclgrphProfConfig *profiler_config) {
GraphLoader graph_loader;
Command command;
command.cmd_params.clear();
command.cmd_type = PROFILING_START;
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");
@ -360,9 +339,11 @@ Status aclgrphProfStop(aclgrphProfConfig *profiler_config) {
GraphLoader graph_loader;
Command command;
command.cmd_params.clear();
command.cmd_type = PROFILING_STOP;
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);
ret = graph_loader.CommandHandle(command);
if (ret != SUCCESS) {
GELOGE(ret, "Handle profiling command failed");

@ -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; }

@ -55,19 +55,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In
bool convert_2_phy_device_id) {
#ifdef DAVINCI_SUPPORT_PROFILING
vector<int32_t>().swap(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;
@ -76,6 +63,20 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ge::Status ProfilingManager::In
ret = InitFromAclCfg(recv_profiling_config_);
} else {
ret = InitFromOptions(options);
if (ret == SUCCESS && is_load_profiling_) {
// 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);
}
}
}
if (ret != SUCCESS) {
GELOGE(ret, "Failed to init profiling.");
@ -868,14 +869,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;
}

@ -58,7 +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 MAX_CONFIG_FILE_BYTE = 10 * 1024 * 1024;
constexpr uint32_t kMaxConfigFileByte = 10 * 1024 * 1024;
} // namespace
namespace ge {
@ -512,9 +512,9 @@ FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) {
stat.st_mode);
return false;
}
if (stat.st_size > MAX_CONFIG_FILE_BYTE) {
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, MAX_CONFIG_FILE_BYTE);
resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte);
return false;
}
return true;

@ -745,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_) {

@ -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 \
@ -371,7 +372,6 @@ LOCAL_SRC_FILES += $(BUILER_SRC_FILES)
LOCAL_SRC_FILES += $(ANALYZER_SRC_FILES)
LOCAL_STATIC_LIBRARIES := libge_memory \
libadump_server_stub \
LOCAL_SHARED_LIBRARIES := \
libc_sec \
@ -436,7 +436,6 @@ LOCAL_C_INCLUDES := $(DEVICE_LOCAL_C_INCLUDES)
LOCAL_C_INCLUDES += $(ANALYZER_LOCAL_INCLUDES)
LOCAL_STATIC_LIBRARIES := libge_memory \
libadump_server_stub \
LOCAL_SHARED_LIBRARIES := \
libc_sec \

@ -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 \
@ -392,8 +392,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_prof.cc
LOCAL_SRC_FILES := ../../out/ge/lib64/stub/ge_api.cc \
../../out/ge/lib64/stub/ge_prof.cc \
LOCAL_SHARED_LIBRARIES :=

@ -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) {

@ -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

@ -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() {
@ -1191,6 +1218,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();
@ -1200,13 +1233,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) {

@ -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;
}

@ -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

@ -125,7 +125,7 @@ DavinciModel::DavinciModel(int32_t priority, const std::shared_ptr<ModelListener
rt_model_stream_(nullptr),
is_inner_model_stream_(false),
is_async_mode_(false),
last_execute_mode_(false),
last_execute_mode_(INITIALIZATION),
session_id_(0),
device_id_(0),
maxDumpOpNum_(0),
@ -1573,6 +1573,48 @@ Status DavinciModel::GetAIPPInfo(uint32_t index, AippConfigInfo &aipp_info) {
return SUCCESS;
}
Status DavinciModel::GetAippType(uint32_t index, InputAippType &type, size_t &aipp_index) {
GE_CHK_BOOL_RET_STATUS(index < data_op_list_.size(), PARAM_INVALID, "Index %u is invalid.", index);
// Set default value
type = DATA_WITHOUT_AIPP;
aipp_index = 0xFFFFFFFF; // default invalid value
OpDescPtr data_op = data_op_list_[index];
GE_CHECK_NOTNULL(data_op);
if (!data_op->HasAttr(ATTR_DATA_RELATED_AIPP_MODE)) {
GELOGW("There is no aipp releated info with index %u.", index);
return SUCCESS;
}
std::string data_mode;
(void)AttrUtils::GetStr(data_op, ATTR_DATA_RELATED_AIPP_MODE, data_mode);
if (data_mode == "static_aipp") {
type = DATA_WITH_STATIC_AIPP;
} else if (data_mode == "dynamic_aipp") {
type = DATA_WITH_DYNAMIC_AIPP;
} else if (data_mode == "dynamic_aipp_conf") {
type = DYNAMIC_AIPP_NODE;
} else {
GELOGE(INTERNAL_ERROR, "The info of aipp releated info %s is invalid with index %u.", data_mode.c_str(), index);
return INTERNAL_ERROR;
}
if (type == DATA_WITH_DYNAMIC_AIPP) {
string releated_name;
(void)AttrUtils::GetStr(data_op, ATTR_DATA_AIPP_DATA_NAME_MAP, releated_name);
for (size_t i = 0; i < data_op_list_.size(); ++i) {
GE_CHECK_NOTNULL(data_op_list_[i]);
if (data_op_list_[i]->GetName() == releated_name) {
GELOGI("Find aipp_data [%s] index %zu from index %u", releated_name.c_str(), i, index);
aipp_index = i;
}
}
if (aipp_index == 0xFFFFFFFF) {
GELOGE(INTERNAL_ERROR, "Can not find aipp data node from index %u", index);
return INTERNAL_ERROR;
}
}
return SUCCESS;
}
void DavinciModel::SetDynamicSize(const std::vector<uint64_t> &batch_num, int32_t dynamic_type) {
batch_size_.clear();
if (batch_num.empty()) {
@ -1666,9 +1708,9 @@ void DavinciModel::CreateInputDimsInfo(const OpDescPtr &op_desc, Format format,
return;
}
// judge if this data is linked dynamic aipp first, multiply batch has been considered
if (op_desc->HasAttr("_dynamic_aipp_input_dims")) {
if (op_desc->HasAttr(ATTR_DYNAMIC_AIPP_INPUT_DIMS)) {
vector<int64_t> dynamic_aipp_input_dims;
(void)AttrUtils::GetListInt(op_desc, "_dynamic_aipp_input_dims", dynamic_aipp_input_dims);
(void)AttrUtils::GetListInt(op_desc, ATTR_DYNAMIC_AIPP_INPUT_DIMS, dynamic_aipp_input_dims);
SetInputDimsInfo(dynamic_aipp_input_dims, format, input);
return;
} else {
@ -3371,11 +3413,15 @@ bool DavinciModel::IsBroadCastOpData(const ge::NodePtr &var_node) {
/// @return Status
///
Status DavinciModel::InitModelStream(rtStream_t stream) {
ExecuteMode curr_mode = is_async_mode_ ? ASYNCHRONIZATION : SYNCHRONIZATION;
GE_CHK_BOOL_RET_STATUS((curr_mode == last_execute_mode_) || (last_execute_mode_ == INITIALIZATION), INTERNAL_ERROR,
"NnExecute not support mix execute.");
last_execute_mode_ = curr_mode;
// asynchronize mode, use user input stream.
if (is_async_mode_) {
rt_model_stream_ = stream;
is_inner_model_stream_ = false;
last_execute_mode_ = true;
return SUCCESS;
}
@ -3387,14 +3433,12 @@ Status DavinciModel::InitModelStream(rtStream_t stream) {
rt_model_stream_ = stream;
is_inner_model_stream_ = false;
last_execute_mode_ = false;
return SUCCESS;
}
if (last_execute_mode_ || (rt_model_stream_ == nullptr)) {
if (rt_model_stream_ == nullptr) {
GE_CHK_RT_RET(rtStreamCreateWithFlags(&rt_model_stream_, priority_, RT_STREAM_FORBIDDEN_DEFAULT));
is_inner_model_stream_ = true;
last_execute_mode_ = false;
}
return SUCCESS;

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

Loading…
Cancel
Save