!45184 Fix clean code warning

Merge pull request !45184 from 胡彬/clean-code-master
This commit is contained in:
i-robot 2022-11-07 08:49:15 +00:00 committed by Gitee
commit f7168c8ee7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 13 additions and 2 deletions

View File

@ -62,6 +62,7 @@ void EliminateDuplicatedTupleGetItem(const FuncGraphPtr &graph, const FuncGraphM
continue;
}
auto getitem_cnode = node->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(getitem_cnode);
KernelWithIndex input_with_index{getitem_cnode->input(kRealInputNodeIndexInTupleGetItem),
GetGetitemIndex(getitem_cnode)};
if (getitem_dup_map.count(input_with_index) == 0) {
@ -105,6 +106,8 @@ bool BackendCSE::CheckEqualKernelBuildInfo(const AnfNodePtr &main, const AnfNode
}
bool BackendCSE::CheckEqualCnodeInputs(const AnfNodePtr &main, const AnfNodePtr &node) const {
MS_EXCEPTION_IF_NULL(main);
MS_EXCEPTION_IF_NULL(node);
auto c_main = main->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(c_main);
auto c_node = node->cast<CNodePtr>();

View File

@ -35,6 +35,7 @@ const AnfNodePtr ConvertDynamicBroadcastTo::Process(const FuncGraphPtr &func_gra
auto input_x = common::AnfAlgo::GetInputNode(ori_cnode, 0);
CNodePtr broadcast_to_node =
opt::NewCNode({NewValueNode(std::make_shared<Primitive>(broadcast_to_op_name)), input_x}, func_graph, {node});
MS_EXCEPTION_IF_NULL(broadcast_to_node);
broadcast_to_node->set_abstract(node->abstract());
auto shape_ptr = node->abstract()->BuildShape()->cast<abstract::ShapePtr>();
MS_EXCEPTION_IF_NULL(shape_ptr);

View File

@ -22,6 +22,7 @@
namespace mindspore {
namespace opt {
bool ConvertUnusedTupleParaToMakeTuple::Run(const FuncGraphPtr &func_graph) {
MS_EXCEPTION_IF_NULL(func_graph);
auto kernel_graph = dyn_cast<session::KernelGraph>(func_graph);
MS_EXCEPTION_IF_NULL(kernel_graph);
for (auto &input : kernel_graph->inputs()) {

View File

@ -67,7 +67,7 @@ CNodePtr NewConcatNode(const FuncGraphPtr &func_graph, const std::pair<std::vect
size_t input_num = node_info.first.size() - 1;
common::AnfAlgo::SetNodeAttr(kAttrAxis, MakeValue<int64_t>(0), concat_node);
common::AnfAlgo::SetNodeAttr(kAttrInputNums, MakeValue<int64_t>(static_cast<int64_t>(input_num)), concat_node);
common::AnfAlgo::SetNodeAttr(kAttrInputNums, MakeValue<int64_t>(UlongToLong(input_num)), concat_node);
std::vector<int64_t> dyn_input_size{UlongToLong(input_num)};
common::AnfAlgo::SetNodeAttr(kAttrDynInputSizes, MakeValue(dyn_input_size), concat_node);
return concat_node;

View File

@ -40,6 +40,7 @@ bool GradientsAllReduceDependLastSend::Run(const FuncGraphPtr &graph) {
continue;
}
auto cnode = node->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(cnode);
if (IsPrimitiveCNode(cnode, prim::kPrimAllReduce) && common::AnfAlgo::IsFusion(cnode)) {
auto last_input = cnode->inputs().back();
if (IsPrimitiveCNode(last_input, prim::kPrimTensorMove)) {
@ -66,6 +67,7 @@ bool GradientsAllReduceDependLastSend::InsertDependBetweenAllReduceAndSend(const
const CNodePtr &last_send) const {
bool changed = false;
FuncGraphManagerPtr manager = graph->manager();
MS_EXCEPTION_IF_NULL(manager);
for (auto &addn : addn_list) {
std::vector<AnfNodePtr> inputs = {NewValueNode(std::make_shared<Primitive>(prim::kPrimDepend->name())), addn,
last_send};

View File

@ -22,10 +22,12 @@
namespace mindspore {
namespace opt {
namespace {
const int axis_input_index = 2;
constexpr int axis_input_index = 2;
} // namespace
AnfNodePtr ReduceSumOptimizer::NewRankOp(const AnfNodePtr &cnode, const KernelGraphPtr &kernel_graph) const {
MS_EXCEPTION_IF_NULL(cnode);
MS_EXCEPTION_IF_NULL(kernel_graph);
std::vector<AnfNodePtr> rank_inputs;
auto prim = std::make_shared<Primitive>(prim::kPrimRank->name());
rank_inputs.push_back(NewValueNode(prim));
@ -38,6 +40,8 @@ AnfNodePtr ReduceSumOptimizer::NewRankOp(const AnfNodePtr &cnode, const KernelGr
}
AnfNodePtr ReduceSumOptimizer::NewRangeOp(const AnfNodePtr &rank_op, const KernelGraphPtr &kernel_graph) const {
MS_EXCEPTION_IF_NULL(rank_op);
MS_EXCEPTION_IF_NULL(kernel_graph);
std::vector<AnfNodePtr> range_inputs;
auto prim = std::make_shared<Primitive>(prim::kPrimRange->name());
range_inputs.push_back(NewValueNode(prim));