From f2d5f14e37bb2bbb795bdfbbed8adcf96c59435c Mon Sep 17 00:00:00 2001 From: huangxinjing Date: Fri, 20 Nov 2020 11:17:20 +0800 Subject: [PATCH] Fix review bot --- .../frontend/parallel/auto_parallel/operator_costmodel.cc | 3 +-- mindspore/ccsrc/frontend/parallel/ops_info/slice_info.cc | 1 - .../parallel/ops_info/uniform_candidate_sampler_info.cc | 3 --- .../frontend/parallel/ops_info/unsorted_segment_op_info.cc | 4 +--- .../frontend/parallel/ops_info/unsorted_segment_op_info.h | 1 - .../parallel/pipeline_transformer/pipeline_transformer.cc | 7 ++----- .../parallel/pipeline_transformer/pipeline_transformer.h | 4 ++++ mindspore/ccsrc/frontend/parallel/step_parallel.cc | 5 ----- 8 files changed, 8 insertions(+), 20 deletions(-) diff --git a/mindspore/ccsrc/frontend/parallel/auto_parallel/operator_costmodel.cc b/mindspore/ccsrc/frontend/parallel/auto_parallel/operator_costmodel.cc index 20e7b1931b1..7d0d7d81261 100644 --- a/mindspore/ccsrc/frontend/parallel/auto_parallel/operator_costmodel.cc +++ b/mindspore/ccsrc/frontend/parallel/auto_parallel/operator_costmodel.cc @@ -913,14 +913,13 @@ double GatherV2PCost::GetBackwardCommCost(const std::vector &inputs, double UniformCandidateSamplerCost::GetForwardComputationCost(const std::vector &inputs, const std::vector &outputs, int64_t stage_id) const { - double result = 0.0; Shape input0_slice_shape = inputs[0].slice_shape(); if (inputs_type_lengths_.size() != inputs.size()) { MS_LOG(EXCEPTION) << "Invalid inputs type size " << inputs_type_lengths_.size() << " for UniformCandidateSampler cost"; } - result = ListProduct(input0_slice_shape) * static_cast(inputs_type_lengths_[0]); + double result = ListProduct(input0_slice_shape) * static_cast(inputs_type_lengths_[0]); return result; } diff --git a/mindspore/ccsrc/frontend/parallel/ops_info/slice_info.cc b/mindspore/ccsrc/frontend/parallel/ops_info/slice_info.cc index 4fe2380b8e0..bcc9991b86e 100644 --- a/mindspore/ccsrc/frontend/parallel/ops_info/slice_info.cc +++ b/mindspore/ccsrc/frontend/parallel/ops_info/slice_info.cc @@ -279,6 +279,5 @@ Status SliceInfo::ComputeReplaceGraph(const CNodePtr &cnode) { return SUCCESS; } - } // namespace parallel } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/parallel/ops_info/uniform_candidate_sampler_info.cc b/mindspore/ccsrc/frontend/parallel/ops_info/uniform_candidate_sampler_info.cc index 58f8c6a8215..ac9013a10d0 100644 --- a/mindspore/ccsrc/frontend/parallel/ops_info/uniform_candidate_sampler_info.cc +++ b/mindspore/ccsrc/frontend/parallel/ops_info/uniform_candidate_sampler_info.cc @@ -30,7 +30,6 @@ namespace mindspore { namespace parallel { - Status UniformCandidateSamplerInfo::GetUniformSamplerAttrInt64(const std::string &args, int64_t *value) { auto iter = attrs_.find(args); if (iter == attrs_.end()) { @@ -276,7 +275,6 @@ Status UniformCandidateSamplerInfo::InitForCostModel(const StrategyPtr &strategy ReplaceGraphPtr UniformCandidateSamplerInfo::replace_graph(const CNodePtr &cnode) { auto input_strategy = strategy_->GetInputDim().at(0); - // Only when the axis-1 is sharded, we need to modify the attribute if (input_strategy.size() == 2 && input_strategy[1] > 1) { if (ComputeReplaceGraph(cnode) != SUCCESS) { @@ -311,6 +309,5 @@ Status UniformCandidateSamplerInfo::ComputeReplaceGraph(const CNodePtr &cnode) { return SUCCESS; } - } // namespace parallel } // namespace mindspore diff --git a/mindspore/ccsrc/frontend/parallel/ops_info/unsorted_segment_op_info.cc b/mindspore/ccsrc/frontend/parallel/ops_info/unsorted_segment_op_info.cc index 0451cf86b36..2d535ca31af 100644 --- a/mindspore/ccsrc/frontend/parallel/ops_info/unsorted_segment_op_info.cc +++ b/mindspore/ccsrc/frontend/parallel/ops_info/unsorted_segment_op_info.cc @@ -331,7 +331,6 @@ Status UnsortedSegmentMinInfo::ComputeReplaceGraph(const CNodePtr &cnode) { return SUCCESS; } - // The UnsortedSegmentMaxInfo is almost same with UnsortedSegmentMinInfo // Except the reduceMin op in the ComputeReplaceGraph is replaced with reduceMax op ReplaceGraphPtr UnsortedSegmentMaxInfo::replace_graph(const CNodePtr &cnode) { @@ -351,9 +350,8 @@ Status UnsortedSegmentMaxInfo::ComputeReplaceGraph(const CNodePtr &cnode) { MS_LOG(ERROR) << "GenerateGraph Init failed"; return FAILED; } - // Get the attributes of the UnsortedSegmentMin + // Get the attributes of the UnsortedSegmentMax auto num_segments = GetValue(input_value_.at(2)); - // Step1: Output branch auto segment_max = gen_g.PushBack({gen_g.NewOpInst(UNSORTED_SEGMENT_MAX), gen_g.virtual_input_node(), gen_g.virtual_input_node(), CreatInt64Imm(num_segments)}); auto expandim_output = gen_g.PushBack({gen_g.NewOpInst(EXPAND_DIMS), segment_max, CreatInt64Imm(0)}); diff --git a/mindspore/ccsrc/frontend/parallel/ops_info/unsorted_segment_op_info.h b/mindspore/ccsrc/frontend/parallel/ops_info/unsorted_segment_op_info.h index f82f3bb0f9c..33866ab60f9 100644 --- a/mindspore/ccsrc/frontend/parallel/ops_info/unsorted_segment_op_info.h +++ b/mindspore/ccsrc/frontend/parallel/ops_info/unsorted_segment_op_info.h @@ -78,7 +78,6 @@ class UnsortedSegmentMinInfo : public UnsortedSegmentOpInfo { protected: Status ComputeReplaceGraph(const CNodePtr &cnode); }; - class UnsortedSegmentMaxInfo : public UnsortedSegmentOpInfo { public: UnsortedSegmentMaxInfo(const std::string &name, const Shapes &inputs_shape, const Shapes &outputs_shape, diff --git a/mindspore/ccsrc/frontend/parallel/pipeline_transformer/pipeline_transformer.cc b/mindspore/ccsrc/frontend/parallel/pipeline_transformer/pipeline_transformer.cc index eddb3f15351..e0066f849aa 100644 --- a/mindspore/ccsrc/frontend/parallel/pipeline_transformer/pipeline_transformer.cc +++ b/mindspore/ccsrc/frontend/parallel/pipeline_transformer/pipeline_transformer.cc @@ -22,7 +22,6 @@ #include #include #include "frontend/parallel/pipeline_transformer/pipeline_transformer.h" -#include "frontend/parallel/graph_util/generate_graph.h" #include "frontend/parallel/auto_parallel/graph_costmodel.h" #include "frontend/parallel/ops_info/ops_utils.h" #include "frontend/parallel/group_manager.h" @@ -33,8 +32,6 @@ namespace mindspore { namespace parallel { static std::unordered_map> parameter_color_map; -static std::pair IsSharedNode(const AnfNodePtr &node, const AnfNodeIndexSet &node_users); -static bool IsSomePrimitive(const CNodePtr &cnode, const std::string &name); static int send_tag = 0; static int recv_tag = 0; @@ -236,7 +233,7 @@ void PipelineTransformer::InsertReceive(const FuncGraphPtr &graph, const AnfNode manager_->SetEdge(use_node, index, recv); } -static std::pair IsSharedNode(const AnfNodePtr &node, const AnfNodeIndexSet &node_users) { +std::pair PipelineTransformer::IsSharedNode(const AnfNodePtr &node, const AnfNodeIndexSet &node_users) { std::set tag_set; auto node_stage = node->stage(); int min_tag = node_stage; @@ -368,7 +365,7 @@ void PipelineTransformer::ElimGraphStage() { } } -static bool IsSomePrimitive(const CNodePtr &cnode, const std::string &name) { +bool PipelineTransformer::IsSomePrimitive(const CNodePtr &cnode, const std::string &name) { ValueNodePtr anf_node = cnode->input(0)->cast(); MS_EXCEPTION_IF_NULL(anf_node); PrimitivePtr prim = anf_node->value()->cast(); diff --git a/mindspore/ccsrc/frontend/parallel/pipeline_transformer/pipeline_transformer.h b/mindspore/ccsrc/frontend/parallel/pipeline_transformer/pipeline_transformer.h index 974cb6c0073..53bd0343be3 100644 --- a/mindspore/ccsrc/frontend/parallel/pipeline_transformer/pipeline_transformer.h +++ b/mindspore/ccsrc/frontend/parallel/pipeline_transformer/pipeline_transformer.h @@ -18,9 +18,11 @@ #define MINDSPORE_CCSRC_FRONTEND_PARALLEL_PIPELINE_TRANSFORMER_PIPELINE_TRANSFORMER_H_ #include +#include #include "ir/value.h" #include "ir/graph_utils.h" #include "base/base.h" +#include "frontend/parallel/graph_util/generate_graph.h" namespace mindspore { namespace parallel { @@ -49,6 +51,8 @@ class PipelineTransformer { void ElimParameter(); private: + std::pair IsSharedNode(const AnfNodePtr &node, const AnfNodeIndexSet &node_users); + bool IsSomePrimitive(const CNodePtr &cnode, const std::string &name); void DoBroadCast(const FuncGraphPtr &func); SendAttr InsertSend(const FuncGraphPtr &graph, const AnfNodePtr ¶meter, const int &user_node_stage, const int &node_stage); diff --git a/mindspore/ccsrc/frontend/parallel/step_parallel.cc b/mindspore/ccsrc/frontend/parallel/step_parallel.cc index c66b3bb91ed..edb62f55218 100644 --- a/mindspore/ccsrc/frontend/parallel/step_parallel.cc +++ b/mindspore/ccsrc/frontend/parallel/step_parallel.cc @@ -54,11 +54,6 @@ static const std::set INVALID_LOSS_OPS = {GET_NEXT, VIRTUALLOSS}; // g_RefMap, for CNode B input i is a RefKey[Parameter C], // it will be one item in map with key: C, and value: (B, i) static std::map> g_RefMap; -static void HandleNoUsedParameter(const FuncGraphPtr &root); -static CNodePtr ReplaceNode(const Operator &op, const AnfNodePtr &pre_node, const FuncGraphPtr &func_graph, - const std::string &instance_name); -static void ApplyParallelOptOnParam(const FuncGraphPtr &root, const AnfNodePtr ¶meter, - const std::string &opt_shard_group); void SetCommunicationOpGroupLabel(std::vector new_node_input) { if (new_node_input.empty()) {