From 2fcc95096a37cb0e7a9aac6c16cd04635919a2e7 Mon Sep 17 00:00:00 2001 From: hangangqiang Date: Mon, 26 Apr 2021 10:45:01 +0800 Subject: [PATCH] fix mindspore lite codex --- .../converter/legacy_optimizer/graph/switch_pass.cc | 13 +++++++++---- .../lite/tools/optimizer/graph/functionalize_cond.h | 2 +- .../tools/optimizer/graph/functionalize_while.h | 2 +- .../tools/optimizer/graph/primitive_adjust_pass.h | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mindspore/lite/tools/converter/legacy_optimizer/graph/switch_pass.cc b/mindspore/lite/tools/converter/legacy_optimizer/graph/switch_pass.cc index 9bd89ea7a27..ec6e49fb23c 100644 --- a/mindspore/lite/tools/converter/legacy_optimizer/graph/switch_pass.cc +++ b/mindspore/lite/tools/converter/legacy_optimizer/graph/switch_pass.cc @@ -59,8 +59,9 @@ STATUS SwitchPass::Run(mindspore::schema::MetaGraphT *graph) { if (type != schema::PrimitiveType_PartialFusion) { continue; } + MS_ASSERT(node != nullptr); MS_ASSERT(node->primitive != nullptr); - MS_ASSERT(node->primitive->value..AsPartialFusion() != nullptr); + MS_ASSERT(node->primitive->value.AsPartialFusion() != nullptr); auto partial_prim = node->primitive->value.AsPartialFusion(); if (partial_prim->sub_graph_index == -1) { continue; @@ -467,7 +468,9 @@ STATUS SingleSwitchPass::Init() { } // get cond_graph_nodes_ - MS_ASSERT(first_partial_node_->primitive->value..AsPartialFusion() != nullptr); + MS_ASSERT(first_partial_node_ != nullptr); + MS_ASSERT(first_partial_node_->primitive != nullptr); + MS_ASSERT(first_partial_node_->primitive->value.AsPartialFusion() != nullptr); first_subgraph_index_ = first_partial_node_->primitive->value.AsPartialFusion()->sub_graph_index; auto cond_node_indices = graph_->subGraph.at(first_subgraph_index_)->nodeIndices; for (auto &index : cond_node_indices) { @@ -623,8 +626,9 @@ STATUS SingleSwitchPass::UpdateSubgraphOutput(const size_t &subgraph_index, sche STATUS SingleSwitchPass::ConcatCondSubgraphInputAndOutput() { if (first_subgraph_index_ == -1) { + MS_ASSERT(first_partial_node_ != nullptr); MS_ASSERT(first_partial_node_->primitive != nullptr); - MS_ASSERT(first_partial_node_->primitive->value..AsPartialFusion() != nullptr); + MS_ASSERT(first_partial_node_->primitive->value.AsPartialFusion() != nullptr); first_partial_node_->primitive->value.AsPartialFusion()->sub_graph_index = -1; return RET_OK; } @@ -644,8 +648,9 @@ STATUS SingleSwitchPass::ConcatCondSubgraphInputAndOutput() { STATUS SingleSwitchPass::ConcatBodySubgraphInputAndOutput() { if (second_subgraph_index_ == -1) { + MS_ASSERT(first_partial_node_ != nullptr); MS_ASSERT(first_partial_node_->primitive != nullptr); - MS_ASSERT(first_partial_node_->primitive->value..AsPartialFusion() != nullptr); + MS_ASSERT(first_partial_node_->primitive->value.AsPartialFusion() != nullptr); first_partial_node_->primitive->value.AsPartialFusion()->sub_graph_index = -1; return RET_OK; } diff --git a/mindspore/lite/tools/optimizer/graph/functionalize_cond.h b/mindspore/lite/tools/optimizer/graph/functionalize_cond.h index 7bc1b27886e..847aec3016e 100644 --- a/mindspore/lite/tools/optimizer/graph/functionalize_cond.h +++ b/mindspore/lite/tools/optimizer/graph/functionalize_cond.h @@ -36,7 +36,7 @@ class FunctionalizeCond { public: FunctionalizeCond(FuncGraphPtr fg, CNodePtr merge_node) : fg_(fg), merge_node_(merge_node) {} - ~FunctionalizeCond() = default; + virtual ~FunctionalizeCond() = default; STATUS Process(); diff --git a/mindspore/lite/tools/optimizer/graph/functionalize_while.h b/mindspore/lite/tools/optimizer/graph/functionalize_while.h index 0052883135b..75e05ce194e 100644 --- a/mindspore/lite/tools/optimizer/graph/functionalize_while.h +++ b/mindspore/lite/tools/optimizer/graph/functionalize_while.h @@ -35,7 +35,7 @@ class FunctionalizeWhile { FunctionalizeWhile(std::vector node_cluster, const CNodePtr &loop_cond_node, FuncGraphPtr fg) : node_cluster_(node_cluster), loop_cond_node_(loop_cond_node), fg_(fg) {} - ~FunctionalizeWhile() = default; + virtual ~FunctionalizeWhile() = default; // while STATUS BuildWhileNode(); diff --git a/mindspore/lite/tools/optimizer/graph/primitive_adjust_pass.h b/mindspore/lite/tools/optimizer/graph/primitive_adjust_pass.h index 729757d12f5..927529ebf98 100644 --- a/mindspore/lite/tools/optimizer/graph/primitive_adjust_pass.h +++ b/mindspore/lite/tools/optimizer/graph/primitive_adjust_pass.h @@ -57,6 +57,7 @@ class RegistryPrimitiveAdjust { RegistryPrimitiveAdjust(const std::string &key, PrimitiveAdjustCreator creator) { PrimitiveAdjustRegistry::GetInstance()->InsertPrimitiveAdjustMap(key, creator); } + virtual ~RegistryPrimitiveAdjust() = default; }; #define REGIST_PRIMITIVE_ADJUST(type, primitive_adjust_func) \