From 998ff0399b16e6276da6d6b0bccda5bac3b90f4f Mon Sep 17 00:00:00 2001 From: huanghui Date: Fri, 28 Aug 2020 16:34:12 +0800 Subject: [PATCH] clear codex and reviewbot warning --- .../cpu/scatter_nd_update_cpu_kernel.cc | 4 +-- .../cpu/scatter_nd_update_cpu_kernel.h | 8 ++--- .../kernel_compiler/cpu/unique_cpu_kernel.h | 5 ++- .../cpu/unique_with_pad_cpu_kernel.h | 4 +-- .../lamb_next_mv_with_decay_v1_rule.cc | 3 +- .../optimizer/pass/communication_op_fusion.cc | 35 +++++++++++-------- .../convert_const_input_to_tensor_input.cc | 1 - 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_nd_update_cpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_nd_update_cpu_kernel.cc index 71c81284a..b5899e008 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_nd_update_cpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_nd_update_cpu_kernel.cc @@ -93,9 +93,9 @@ void ScatterNdUpdateCPUKernel::LaunchKernel(const std::vector &input output_unit_offsets_[i] = offset; } + auto mem_size = inputs[0]->size; for (int i = 0; i < num_units_; i++) { - auto ret = - memcpy_s(x + output_unit_offsets_[i], unit_size_ * sizeof(T), updates + unit_size_ * i, unit_size_ * sizeof(T)); + auto ret = memcpy_s(x + output_unit_offsets_[i], mem_size, updates + unit_size_ * i, unit_size_ * sizeof(T)); if (ret != 0) { MS_LOG(EXCEPTION) << "memcpy_s error, errorno" << ret; } diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_nd_update_cpu_kernel.h b/mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_nd_update_cpu_kernel.h index 80b5714bb..4a64061c2 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_nd_update_cpu_kernel.h +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/scatter_nd_update_cpu_kernel.h @@ -39,10 +39,10 @@ class ScatterNdUpdateCPUKernel : public CPUKernel { private: void Check(const CNodePtr &kernel_node); - TypeId dtype_; - int unit_size_; - int num_units_; - int indices_unit_rank_; + TypeId dtype_{kTypeUnknown}; + int unit_size_{0}; + int num_units_{0}; + int indices_unit_rank_{0}; std::vector shape_; std::vector output_unit_offsets_; std::vector out_strides_; diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/unique_cpu_kernel.h b/mindspore/ccsrc/backend/kernel_compiler/cpu/unique_cpu_kernel.h index 8d77b284a..1fb5b299a 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/unique_cpu_kernel.h +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/unique_cpu_kernel.h @@ -39,8 +39,8 @@ class UniqueCPUKernel : public CPUKernel { private: void CheckParam(const CNodePtr &kernel_node); - size_t n_; - TypeId dtype_; + size_t n_{0}; + TypeId dtype_{kTypeUnknown}; }; MS_REG_CPU_KERNEL( @@ -57,5 +57,4 @@ MS_REG_CPU_KERNEL( UniqueCPUKernel); } // namespace kernel } // namespace mindspore - #endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_UNIQUE_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/unique_with_pad_cpu_kernel.h b/mindspore/ccsrc/backend/kernel_compiler/cpu/unique_with_pad_cpu_kernel.h index 5d063853b..23683a9c4 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/unique_with_pad_cpu_kernel.h +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/unique_with_pad_cpu_kernel.h @@ -40,7 +40,7 @@ class UniqueWithPadCPUKernel : public CPUKernel { private: void CheckParam(const CNodePtr &kernel_node); int64_t n_{0}; - TypeId dtype_{0}; + TypeId dtype_{kTypeUnknown}; }; MS_REG_CPU_KERNEL(UniqueWithPad, @@ -58,8 +58,6 @@ MS_REG_CPU_KERNEL(UniqueWithPad, .AddOutputAttr(kNumberTypeInt64) .AddOutputAttr(kNumberTypeInt64), UniqueWithPadCPUKernel); - } // namespace kernel } // namespace mindspore - #endif // MINDSPORE_CCSRC_BACKEND_KERNEL_COMPILER_CPU_UNIQUE_WITH_PAD_CPU_KERNEL_H_ diff --git a/mindspore/ccsrc/backend/optimizer/ascend/ir_fusion/lamb_next_mv_with_decay_v1_rule.cc b/mindspore/ccsrc/backend/optimizer/ascend/ir_fusion/lamb_next_mv_with_decay_v1_rule.cc index f21433b3c..955eb9d02 100644 --- a/mindspore/ccsrc/backend/optimizer/ascend/ir_fusion/lamb_next_mv_with_decay_v1_rule.cc +++ b/mindspore/ccsrc/backend/optimizer/ascend/ir_fusion/lamb_next_mv_with_decay_v1_rule.cc @@ -195,8 +195,7 @@ const AnfNodePtr LambNextMVWithDecayV1Rule::Process(const FuncGraphPtr &func_gra std::vector fusion_node_outputs; CreateMultipleOutputsOfAnfNode(func_graph, fusion_node, kLambNextMVWithDecayV1OutputNum, &fusion_node_outputs); if (fusion_node_outputs.size() != kLambNextMVWithDecayV1OutputNum) { - MS_LOG(ERROR) << "create multiple outputs for fusion node fail!"; - return nullptr; + MS_LOG(EXCEPTION) << "create multiple outputs for fusion node fail!"; } (void)manager->Replace(add0, fusion_node_outputs[1]); diff --git a/mindspore/ccsrc/backend/optimizer/pass/communication_op_fusion.cc b/mindspore/ccsrc/backend/optimizer/pass/communication_op_fusion.cc index 3042e822a..f3ba66726 100644 --- a/mindspore/ccsrc/backend/optimizer/pass/communication_op_fusion.cc +++ b/mindspore/ccsrc/backend/optimizer/pass/communication_op_fusion.cc @@ -97,6 +97,25 @@ void CheckInputs(const std::vector &fusion_inputs) { MS_LOG(EXCEPTION) << "Different communication op in one segment cannot share the same input"; } } + +bool CheckSegments(size_t segments, size_t communication_op_node_size, std::vector *segment_index) { + MS_EXCEPTION_IF_NULL(segment_index); + if (segments >= communication_op_node_size) { + MS_LOG(INFO) << "fusion not changed: segment_num=" << segments + << ", communication_op_node_size=" << communication_op_node_size; + return false; + } + if (segment_index->at(segments - 1) != communication_op_node_size - 1) { + MS_LOG(EXCEPTION) << "the last segment index is invalid."; + } + for (size_t i = 0; i < segments - 1; ++i) { + if (segment_index->at(i) > segment_index->at(i + 1)) { + MS_LOG(EXCEPTION) << "illegal split: segment_index[" << i << "]=" << segment_index->at(i) << ", segment_index[ " + << i + 1 << "]=" << segment_index->at(i + 1); + } + } + return true; +} } // namespace bool CommunicationOpFusion::GetSplitSegments(const CommunicationOpInfo &communication_op_info, size_t *segment_num, @@ -137,22 +156,8 @@ bool CommunicationOpFusion::GetSplitSegments(const CommunicationOpInfo &communic segment_index->push_back(communication_op_node_size - 1); } - if (segments >= communication_op_node_size) { - MS_LOG(INFO) << "fusion not changed: segment_num=" << segments - << ", communication_op_node_size=" << communication_op_node_size; - return false; - } - if (segment_index->at(segments - 1) != communication_op_node_size - 1) { - MS_LOG(EXCEPTION) << "the last segment index is invalid."; - } - for (size_t i = 0; i < segments - 1; ++i) { - if (segment_index->at(i) > segment_index->at(i + 1)) { - MS_LOG(EXCEPTION) << "illegal split: segment_index[" << i << "]=" << segment_index->at(i) << ", segment_index[ " - << i + 1 << "]=" << segment_index->at(i + 1); - } - } *segment_num = segments; - return true; + return CheckSegments(segments, communication_op_node_size, segment_index); } AnfNodePtr CommunicationOpFusion::CreateFusedCommunicationOp(const FuncGraphPtr &func_graph, diff --git a/mindspore/ccsrc/backend/optimizer/pass/convert_const_input_to_tensor_input.cc b/mindspore/ccsrc/backend/optimizer/pass/convert_const_input_to_tensor_input.cc index 05e86cdff..7abcd586e 100644 --- a/mindspore/ccsrc/backend/optimizer/pass/convert_const_input_to_tensor_input.cc +++ b/mindspore/ccsrc/backend/optimizer/pass/convert_const_input_to_tensor_input.cc @@ -28,7 +28,6 @@ namespace mindspore { namespace opt { namespace { - AnfNodePtr CreateTensorInput(const AnfNodePtr &node, const KernelGraphPtr &kernel_graph, const AnfNodePtr &input_node) { MS_EXCEPTION_IF_NULL(input_node); auto value_node = input_node->cast(); -- GitLab