!45184 Fix clean code warning
Merge pull request !45184 from 胡彬/clean-code-master
This commit is contained in:
commit
f7168c8ee7
|
@ -62,6 +62,7 @@ void EliminateDuplicatedTupleGetItem(const FuncGraphPtr &graph, const FuncGraphM
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto getitem_cnode = node->cast<CNodePtr>();
|
auto getitem_cnode = node->cast<CNodePtr>();
|
||||||
|
MS_EXCEPTION_IF_NULL(getitem_cnode);
|
||||||
KernelWithIndex input_with_index{getitem_cnode->input(kRealInputNodeIndexInTupleGetItem),
|
KernelWithIndex input_with_index{getitem_cnode->input(kRealInputNodeIndexInTupleGetItem),
|
||||||
GetGetitemIndex(getitem_cnode)};
|
GetGetitemIndex(getitem_cnode)};
|
||||||
if (getitem_dup_map.count(input_with_index) == 0) {
|
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 {
|
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>();
|
auto c_main = main->cast<CNodePtr>();
|
||||||
MS_EXCEPTION_IF_NULL(c_main);
|
MS_EXCEPTION_IF_NULL(c_main);
|
||||||
auto c_node = node->cast<CNodePtr>();
|
auto c_node = node->cast<CNodePtr>();
|
||||||
|
|
|
@ -35,6 +35,7 @@ const AnfNodePtr ConvertDynamicBroadcastTo::Process(const FuncGraphPtr &func_gra
|
||||||
auto input_x = common::AnfAlgo::GetInputNode(ori_cnode, 0);
|
auto input_x = common::AnfAlgo::GetInputNode(ori_cnode, 0);
|
||||||
CNodePtr broadcast_to_node =
|
CNodePtr broadcast_to_node =
|
||||||
opt::NewCNode({NewValueNode(std::make_shared<Primitive>(broadcast_to_op_name)), input_x}, func_graph, {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());
|
broadcast_to_node->set_abstract(node->abstract());
|
||||||
auto shape_ptr = node->abstract()->BuildShape()->cast<abstract::ShapePtr>();
|
auto shape_ptr = node->abstract()->BuildShape()->cast<abstract::ShapePtr>();
|
||||||
MS_EXCEPTION_IF_NULL(shape_ptr);
|
MS_EXCEPTION_IF_NULL(shape_ptr);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
namespace mindspore {
|
namespace mindspore {
|
||||||
namespace opt {
|
namespace opt {
|
||||||
bool ConvertUnusedTupleParaToMakeTuple::Run(const FuncGraphPtr &func_graph) {
|
bool ConvertUnusedTupleParaToMakeTuple::Run(const FuncGraphPtr &func_graph) {
|
||||||
|
MS_EXCEPTION_IF_NULL(func_graph);
|
||||||
auto kernel_graph = dyn_cast<session::KernelGraph>(func_graph);
|
auto kernel_graph = dyn_cast<session::KernelGraph>(func_graph);
|
||||||
MS_EXCEPTION_IF_NULL(kernel_graph);
|
MS_EXCEPTION_IF_NULL(kernel_graph);
|
||||||
for (auto &input : kernel_graph->inputs()) {
|
for (auto &input : kernel_graph->inputs()) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ CNodePtr NewConcatNode(const FuncGraphPtr &func_graph, const std::pair<std::vect
|
||||||
|
|
||||||
size_t input_num = node_info.first.size() - 1;
|
size_t input_num = node_info.first.size() - 1;
|
||||||
common::AnfAlgo::SetNodeAttr(kAttrAxis, MakeValue<int64_t>(0), concat_node);
|
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)};
|
std::vector<int64_t> dyn_input_size{UlongToLong(input_num)};
|
||||||
common::AnfAlgo::SetNodeAttr(kAttrDynInputSizes, MakeValue(dyn_input_size), concat_node);
|
common::AnfAlgo::SetNodeAttr(kAttrDynInputSizes, MakeValue(dyn_input_size), concat_node);
|
||||||
return concat_node;
|
return concat_node;
|
||||||
|
|
|
@ -40,6 +40,7 @@ bool GradientsAllReduceDependLastSend::Run(const FuncGraphPtr &graph) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto cnode = node->cast<CNodePtr>();
|
auto cnode = node->cast<CNodePtr>();
|
||||||
|
MS_EXCEPTION_IF_NULL(cnode);
|
||||||
if (IsPrimitiveCNode(cnode, prim::kPrimAllReduce) && common::AnfAlgo::IsFusion(cnode)) {
|
if (IsPrimitiveCNode(cnode, prim::kPrimAllReduce) && common::AnfAlgo::IsFusion(cnode)) {
|
||||||
auto last_input = cnode->inputs().back();
|
auto last_input = cnode->inputs().back();
|
||||||
if (IsPrimitiveCNode(last_input, prim::kPrimTensorMove)) {
|
if (IsPrimitiveCNode(last_input, prim::kPrimTensorMove)) {
|
||||||
|
@ -66,6 +67,7 @@ bool GradientsAllReduceDependLastSend::InsertDependBetweenAllReduceAndSend(const
|
||||||
const CNodePtr &last_send) const {
|
const CNodePtr &last_send) const {
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
FuncGraphManagerPtr manager = graph->manager();
|
FuncGraphManagerPtr manager = graph->manager();
|
||||||
|
MS_EXCEPTION_IF_NULL(manager);
|
||||||
for (auto &addn : addn_list) {
|
for (auto &addn : addn_list) {
|
||||||
std::vector<AnfNodePtr> inputs = {NewValueNode(std::make_shared<Primitive>(prim::kPrimDepend->name())), addn,
|
std::vector<AnfNodePtr> inputs = {NewValueNode(std::make_shared<Primitive>(prim::kPrimDepend->name())), addn,
|
||||||
last_send};
|
last_send};
|
||||||
|
|
|
@ -22,10 +22,12 @@
|
||||||
namespace mindspore {
|
namespace mindspore {
|
||||||
namespace opt {
|
namespace opt {
|
||||||
namespace {
|
namespace {
|
||||||
const int axis_input_index = 2;
|
constexpr int axis_input_index = 2;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AnfNodePtr ReduceSumOptimizer::NewRankOp(const AnfNodePtr &cnode, const KernelGraphPtr &kernel_graph) const {
|
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;
|
std::vector<AnfNodePtr> rank_inputs;
|
||||||
auto prim = std::make_shared<Primitive>(prim::kPrimRank->name());
|
auto prim = std::make_shared<Primitive>(prim::kPrimRank->name());
|
||||||
rank_inputs.push_back(NewValueNode(prim));
|
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 {
|
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;
|
std::vector<AnfNodePtr> range_inputs;
|
||||||
auto prim = std::make_shared<Primitive>(prim::kPrimRange->name());
|
auto prim = std::make_shared<Primitive>(prim::kPrimRange->name());
|
||||||
range_inputs.push_back(NewValueNode(prim));
|
range_inputs.push_back(NewValueNode(prim));
|
||||||
|
|
Loading…
Reference in New Issue