Browse Source

!15263 [GraphKernel] fix static check warning about memory leaked

From: @dayschan
Reviewed-by: @gaoxiong1,@ckey_dou
Signed-off-by: @ckey_dou
pull/15263/MERGE
mindspore-ci-bot Gitee 5 years ago
parent
commit
e9b2aec7e2
1 changed files with 6 additions and 8 deletions
  1. +6
    -8
      mindspore/ccsrc/backend/optimizer/graph_kernel/graph_kernel_splitter.cc

+ 6
- 8
mindspore/ccsrc/backend/optimizer/graph_kernel/graph_kernel_splitter.cc View File

@@ -172,7 +172,7 @@ class AreaGraph {
// Build an area graph to maintain the relation between areas.
// Input node_groups: A group list, each element is a AnfNode list representing the node set in this group.
static AreaGraphPtr BuildAreaGraph(const std::vector<AnfNodePtrList> &node_groups) {
auto area_graph = AreaGraphPtr(new AreaGraph(node_groups));
auto area_graph = std::make_shared<AreaGraph>(node_groups);
if (area_graph == nullptr) return nullptr;
if (!area_graph->TopoSort()) {
MS_LOG(WARNING) << "The groups have a cycle.";
@@ -209,9 +209,6 @@ class AreaGraph {
return;
}

~AreaGraph() = default;

private:
explicit AreaGraph(const std::vector<AnfNodePtrList> &node_groups) : edge_prev_(node_groups.size()) {
for (size_t i = 0; i < node_groups.size(); ++i) {
areas_.emplace_back(node_groups[i]);
@@ -237,7 +234,9 @@ class AreaGraph {
}
}
}
~AreaGraph() = default;

private:
// Topological sort the areas.
bool TopoSort() {
std::vector<int> out_degree(edge_prev_.size(), 0);
@@ -350,15 +349,14 @@ class Splitter {
MS_EXCEPTION_IF_NULL(main_cnode);
MS_EXCEPTION_IF_NULL(main_cnode->func_graph());
MS_EXCEPTION_IF_NULL(split_schemer);
return SplitterPtr(new Splitter(main_cnode, split_schemer));
return std::make_shared<Splitter>(main_cnode, split_schemer);
}

~Splitter() = default;

private:
Splitter(const CNodePtr &main_cnode, SplitSchemerPtr split_schemer)
: main_func_graph_(main_cnode->func_graph()), old_subgraph_cnode_(main_cnode), split_schemer_(split_schemer) {}
~Splitter() = default;

private:
void ResetInlinedNodesKernelInfo() {
for (const auto &node : inlined_nodes_) {
ResetKernelInfo(node);


Loading…
Cancel
Save