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 71c81284a5c908de7abb35cd25c3c0791b1b721b..b5899e008be49c29611ba6c71a8abf38a260ca09 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 80b5714bb29c033a2108821f0fbf77b6427f6de1..4a64061c2a7ad1faa1d86cc8aeefc6f7115924c4 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 8d77b284a0a1513ec28c7e5aa789b8a177bf5788..1fb5b299aade219170f3a8add6101d95311add50 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 5d063853bfc0fd9c80e9dddc30764c1ffcc832bc..23683a9c4d53b165f8a4a44bea832fcae911669f 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 f21433b3c648944bccbd1e29a510e071015c9194..955eb9d022ab95d9f5beba998b748c59c13f2104 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 3042e822a4b52d7b4dc76b02f8767f30eeaf39e4..f3ba66726a9588e17f04cc7e333aae9b3a32757a 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 05e86cdff79034a88f4a9e60e094f4c2842b9dd4..7abcd586eb8534b112ac360c98d7c24dfa9151c2 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();