Browse Source

!1630 atomic and davinci_model

From: @dimitri_rose
Reviewed-by: @tangqunzhang,@ji_chen,@wqtshg
Signed-off-by: @ji_chen
tags/v1.3.0
mindspore-ci-bot Gitee 3 years ago
parent
commit
fabd1c394a
4 changed files with 44 additions and 27 deletions
  1. +24
    -18
      ge/graph/load/model_manager/model_manager.cc
  2. +14
    -6
      ge/graph/passes/atomic_addr_clean_pass.cc
  3. +4
    -2
      ge/graph/passes/atomic_addr_clean_pass.h
  4. +2
    -1
      ge/ir_build/option_utils.cc

+ 24
- 18
ge/graph/load/model_manager/model_manager.cc View File

@@ -456,26 +456,32 @@ void ModelManager::InsertModel(uint32_t model_id, shared_ptr<hybrid::HybridDavin
} }


Status ModelManager::DeleteModel(uint32_t id) { Status ModelManager::DeleteModel(uint32_t id) {
std::lock_guard<std::recursive_mutex> lock(map_mutex_);
// These two pointers are used to unbind erase() and model destruction process.
std::shared_ptr<DavinciModel> tmp_model;
std::shared_ptr<hybrid::HybridDavinciModel> tmp_hybrid_model;
{
std::lock_guard<std::recursive_mutex> lock(map_mutex_);


auto it = model_map_.find(id);
auto hybrid_model_it = hybrid_model_map_.find(id);
if (it != model_map_.end()) {
uint64_t session_id = it->second->GetSessionId();
std::string model_key = std::to_string(session_id) + "_" + std::to_string(id) + "_" +
std::to_string(it->second->SubModelId());
auto iter_aicpu_kernel = model_aicpu_kernel_.find(model_key);
if (iter_aicpu_kernel != model_aicpu_kernel_.end()) {
(void)model_aicpu_kernel_.erase(iter_aicpu_kernel);
auto it = model_map_.find(id);
auto hybrid_model_it = hybrid_model_map_.find(id);
if (it != model_map_.end()) {
uint64_t session_id = it->second->GetSessionId();
std::string model_key = std::to_string(session_id) + "_" + std::to_string(id) + "_" +
std::to_string(it->second->SubModelId());
auto iter_aicpu_kernel = model_aicpu_kernel_.find(model_key);
if (iter_aicpu_kernel != model_aicpu_kernel_.end()) {
(void)model_aicpu_kernel_.erase(iter_aicpu_kernel);
}
tmp_model = it->second;
(void)model_map_.erase(it);
} else if (hybrid_model_it != hybrid_model_map_.end()) {
tmp_hybrid_model = hybrid_model_it->second;
(void)hybrid_model_map_.erase(hybrid_model_it);
} else {
REPORT_INNER_ERROR("E19999", "model_id:%u not exist in model_map, check invalid", id);
GELOGE(ACL_ERROR_GE_EXEC_MODEL_ID_INVALID, "model id %u does not exists.", id);
return ACL_ERROR_GE_EXEC_MODEL_ID_INVALID;
} }
(void)model_map_.erase(it);
} else if (hybrid_model_it != hybrid_model_map_.end()) {
(void)hybrid_model_map_.erase(hybrid_model_it);
} else {
REPORT_INNER_ERROR("E19999", "model_id:%u not exist in model_map, check invalid",
id);
GELOGE(ACL_ERROR_GE_EXEC_MODEL_ID_INVALID, "model id %u does not exists.", id);
return ACL_ERROR_GE_EXEC_MODEL_ID_INVALID;
} }


return SUCCESS; return SUCCESS;


+ 14
- 6
ge/graph/passes/atomic_addr_clean_pass.cc View File

@@ -182,10 +182,11 @@ Status AtomicAddrCleanPass::HandleLoopGraph(ComputeGraphPtr &graph, const vector
} }


Status AtomicAddrCleanPass::HandleNormalGraph(ComputeGraphPtr &graph, const vector<NodePtr> &atomic_node_vec) { Status AtomicAddrCleanPass::HandleNormalGraph(ComputeGraphPtr &graph, const vector<NodePtr> &atomic_node_vec) {
GELOGD("Not loop graph and unknown graph. It will insert only 1 clean node.");
GELOGD("Not loop graph and unknown graph. It will insert atomic clean nodes.");


vector<NodePtr> common_atomic_nodes; vector<NodePtr> common_atomic_nodes;
auto ret = HandleDispersedAtomicNodes(graph, atomic_node_vec, common_atomic_nodes);
vector<NodePtr> dispersed_atomic_nodes;
auto ret = HandleDispersedAtomicNodes(graph, atomic_node_vec, common_atomic_nodes, dispersed_atomic_nodes);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "Handle dispersed atomic nodes failed, graph name is %s.", graph->GetName().c_str()); GELOGE(ret, "Handle dispersed atomic nodes failed, graph name is %s.", graph->GetName().c_str());
return ret; return ret;
@@ -222,7 +223,7 @@ Status AtomicAddrCleanPass::HandleNormalGraph(ComputeGraphPtr &graph, const vect
} }
} }
} }
return LinkToPotentialPrecedenceNode(graph, clean_addr_node);
return LinkToPotentialPrecedenceNode(graph, clean_addr_node, dispersed_atomic_nodes);
} }


// Add control edges from atomic clean node to all potential precedence nodes which may execute before atomic clean // Add control edges from atomic clean node to all potential precedence nodes which may execute before atomic clean
@@ -231,7 +232,8 @@ Status AtomicAddrCleanPass::HandleNormalGraph(ComputeGraphPtr &graph, const vect
// edges from atomic clean node to the nodes that may be the first node on each stream. Generally, the first nodes on // edges from atomic clean node to the nodes that may be the first node on each stream. Generally, the first nodes on
// each stream are successors of Data/Variable, and Data/Variable won't generate task or execute, so we link to the // each stream are successors of Data/Variable, and Data/Variable won't generate task or execute, so we link to the
// successors of Data/Variable. // successors of Data/Variable.
Status AtomicAddrCleanPass::LinkToPotentialPrecedenceNode(ComputeGraphPtr &graph, NodePtr &atomic_clean_node) {
Status AtomicAddrCleanPass::LinkToPotentialPrecedenceNode(ComputeGraphPtr &graph, NodePtr &atomic_clean_node,
const vector<NodePtr> &dispersed_atomic_nodes) {
GELOGD("Start to add control edges from %s to all second-nodes behind first-nodes which have no input.", GELOGD("Start to add control edges from %s to all second-nodes behind first-nodes which have no input.",
atomic_clean_node->GetName().c_str()); atomic_clean_node->GetName().c_str());
auto out_ctrl_anchor = atomic_clean_node->GetOutControlAnchor(); auto out_ctrl_anchor = atomic_clean_node->GetOutControlAnchor();
@@ -246,6 +248,10 @@ Status AtomicAddrCleanPass::LinkToPotentialPrecedenceNode(ComputeGraphPtr &graph
auto second_nodes = node->GetOutAllNodes(); auto second_nodes = node->GetOutAllNodes();
for (const auto &second_node : second_nodes) { for (const auto &second_node : second_nodes) {
GE_CHECK_NOTNULL(second_node); GE_CHECK_NOTNULL(second_node);
if ((std::find(dispersed_atomic_nodes.begin(), dispersed_atomic_nodes.end(), second_node) !=
dispersed_atomic_nodes.end()) || (second_node->GetType() == NETOUTPUT)) {
continue;
}
auto in_ctrl_anchor = second_node->GetInControlAnchor(); auto in_ctrl_anchor = second_node->GetInControlAnchor();
GE_CHECK_NOTNULL(in_ctrl_anchor); GE_CHECK_NOTNULL(in_ctrl_anchor);
if (!out_ctrl_anchor->IsLinkedWith(in_ctrl_anchor)) { if (!out_ctrl_anchor->IsLinkedWith(in_ctrl_anchor)) {
@@ -260,7 +266,8 @@ Status AtomicAddrCleanPass::LinkToPotentialPrecedenceNode(ComputeGraphPtr &graph


Status AtomicAddrCleanPass::HandleDispersedAtomicNodes(ComputeGraphPtr &graph, Status AtomicAddrCleanPass::HandleDispersedAtomicNodes(ComputeGraphPtr &graph,
const std::vector<NodePtr> &atomic_node_vec, const std::vector<NodePtr> &atomic_node_vec,
std::vector<NodePtr> &common_atomic_nodes) {
std::vector<NodePtr> &common_atomic_nodes,
vector<NodePtr> &dispersed_atomic_nodes) {
int index = 0; int index = 0;
for (const auto &node : atomic_node_vec) { for (const auto &node : atomic_node_vec) {
vector<int> node_anchors_connect_netoutput; vector<int> node_anchors_connect_netoutput;
@@ -280,7 +287,7 @@ Status AtomicAddrCleanPass::HandleDispersedAtomicNodes(ComputeGraphPtr &graph,
oss << node_name << "_" << index; oss << node_name << "_" << index;
node_name = oss.str(); node_name = oss.str();
dispersed_node_op_desc->SetName(node_name); dispersed_node_op_desc->SetName(node_name);
GELOGD("Inserted dispersed atomic clean node name is %s", node_name.c_str());
GELOGD("Inserted dispersed atomic clean node [%s] before [%s]", node_name.c_str(), node->GetName().c_str());
++index; ++index;
Status ret = LinkToAtomicNode(node, dispersed_clean_addr_node); Status ret = LinkToAtomicNode(node, dispersed_clean_addr_node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
@@ -288,6 +295,7 @@ Status AtomicAddrCleanPass::HandleDispersedAtomicNodes(ComputeGraphPtr &graph,
node->GetName().c_str(), dispersed_clean_addr_node->GetName().c_str()); node->GetName().c_str(), dispersed_clean_addr_node->GetName().c_str());
return ret; return ret;
} }
dispersed_atomic_nodes.emplace_back(node);
} else { } else {
common_atomic_nodes.emplace_back(node); common_atomic_nodes.emplace_back(node);
} }


+ 4
- 2
ge/graph/passes/atomic_addr_clean_pass.h View File

@@ -73,7 +73,8 @@ class AtomicAddrCleanPass : public GraphPass {
* @param atomic_clean_node * @param atomic_clean_node
* @return * @return
*/ */
Status LinkToPotentialPrecedenceNode(ComputeGraphPtr &graph, NodePtr &atomic_clean_node);
Status LinkToPotentialPrecedenceNode(ComputeGraphPtr &graph, NodePtr &atomic_clean_node,
const std::vector<NodePtr> &dispersed_atomic_nodes);


/** /**
* Check if this node is atomic op. * Check if this node is atomic op.
@@ -90,7 +91,8 @@ class AtomicAddrCleanPass : public GraphPass {
Status CompileUnknownGraphOp(const vector<NodePtr> &atomic_node_vec); Status CompileUnknownGraphOp(const vector<NodePtr> &atomic_node_vec);


Status HandleDispersedAtomicNodes(ComputeGraphPtr &graph, const std::vector<NodePtr> &atomic_node_vec, Status HandleDispersedAtomicNodes(ComputeGraphPtr &graph, const std::vector<NodePtr> &atomic_node_vec,
std::vector<NodePtr> &common_atomic_nodes);
std::vector<NodePtr> &common_atomic_nodes,
std::vector<NodePtr> &dispersed_atomic_nodes);


bool CheckAtomicFromOpsKernel(const NodePtr &node); bool CheckAtomicFromOpsKernel(const NodePtr &node);




+ 2
- 1
ge/ir_build/option_utils.cc View File

@@ -239,7 +239,8 @@ bool CheckDynamicImagesizeInputShapeValid(map<string, vector<int64_t>> shape_map
bool is_char_valid = isdigit(c) || (c == ',') || (c == ' ') || (c == ';'); bool is_char_valid = isdigit(c) || (c == ',') || (c == ' ') || (c == ';');
if (!is_char_valid) { if (!is_char_valid) {
ErrorManager::GetInstance().ATCReportErrMessage( ErrorManager::GetInstance().ATCReportErrMessage(
"E10033", {"value", "reason"}, {dynamic_image_size, kDynamicImageSizeError});
"E10001", {"parameter", "value", "reason"},
{"dynamic_image_size", dynamic_image_size.c_str(), kDynamicImageSizeError});
GELOGE(ge::PARAM_INVALID, "[Check][DynamicImageSizeInputShape] --dynamic_image_size:%s is invalid. reason: %s", GELOGE(ge::PARAM_INVALID, "[Check][DynamicImageSizeInputShape] --dynamic_image_size:%s is invalid. reason: %s",
dynamic_image_size.c_str(), kDynamicImageSizeError); dynamic_image_size.c_str(), kDynamicImageSizeError);
return false; return false;


Loading…
Cancel
Save