From 2bf98d550218bbf740cb65e59b34ed67a7dbcd43 Mon Sep 17 00:00:00 2001 From: caifubi Date: Mon, 15 Jun 2020 11:28:51 +0800 Subject: [PATCH] fix code review --- .../ccsrc/device/ascend/profiling/reporter/desc_reporter.cc | 6 +++--- .../device/ascend/profiling/reporter/graph_desc_reporter.cc | 1 + mindspore/ccsrc/kernel/hccl/hccl_kernel.cc | 2 +- mindspore/ccsrc/kernel/hccl/hcom_all_broadcast.cc | 5 +++++ mindspore/ccsrc/kernel/hccl/hcom_all_gather.cc | 4 ++++ mindspore/ccsrc/kernel/hccl/hcom_all_reduce.cc | 4 ++++ mindspore/ccsrc/kernel/hccl/hcom_all_reduce_scatter.cc | 4 ++++ mindspore/ccsrc/kernel/hccl/hcom_util.cc | 2 ++ 8 files changed, 24 insertions(+), 4 deletions(-) diff --git a/mindspore/ccsrc/device/ascend/profiling/reporter/desc_reporter.cc b/mindspore/ccsrc/device/ascend/profiling/reporter/desc_reporter.cc index bf61471827..61087de26f 100644 --- a/mindspore/ccsrc/device/ascend/profiling/reporter/desc_reporter.cc +++ b/mindspore/ccsrc/device/ascend/profiling/reporter/desc_reporter.cc @@ -42,14 +42,14 @@ void DescReporter::ReportByLine(const std::string &data, const std::string &file report_data.data = (unsigned char *)data.c_str() + cur_size; auto ret = memcpy_s(report_data.tag, MSPROF_ENGINE_MAX_TAG_LEN + 1, file_name.c_str(), file_name.length()); if (ret != 0) { - MS_LOG(EXCEPTION) << "memcpy_s report data tag failed"; + MS_LOG(EXCEPTION) << "Memcpy_s report data tag failed"; } auto report_ret = reporter->Report(&report_data); if (report_ret != 0) { - MS_LOG(EXCEPTION) << "report data failed"; + MS_LOG(EXCEPTION) << "Report data failed"; } if (report_size == 0) { - MS_LOG(WARNING) << "report_size is 0"; + MS_LOG(WARNING) << "Report_size is 0"; break; } cur_size += report_size; diff --git a/mindspore/ccsrc/device/ascend/profiling/reporter/graph_desc_reporter.cc b/mindspore/ccsrc/device/ascend/profiling/reporter/graph_desc_reporter.cc index f4f4b3362c..e052d66c56 100644 --- a/mindspore/ccsrc/device/ascend/profiling/reporter/graph_desc_reporter.cc +++ b/mindspore/ccsrc/device/ascend/profiling/reporter/graph_desc_reporter.cc @@ -30,6 +30,7 @@ void GraphDescReporter::ReportData() { } std::vector input_data_list; std::vector output_data_list; + MS_EXCEPTION_IF_NULL(node); auto op_name = node->fullname_with_scope(); auto op_type = AnfAlgo::GetCNodeName(node); auto input_size = AnfAlgo::GetInputTensorNum(node); diff --git a/mindspore/ccsrc/kernel/hccl/hccl_kernel.cc b/mindspore/ccsrc/kernel/hccl/hccl_kernel.cc index 493998c168..87fb8d743d 100644 --- a/mindspore/ccsrc/kernel/hccl/hccl_kernel.cc +++ b/mindspore/ccsrc/kernel/hccl/hccl_kernel.cc @@ -129,7 +129,7 @@ std::vector HcclKernel::GenTask(const std::vector &inpu const std::vector &workspace, const std::vector &outputs, uint32_t stream_id) { if (inputs.empty() || outputs.empty()) { - MS_LOG(EXCEPTION) << "inputs or outputs is empty"; + MS_LOG(EXCEPTION) << "Inputs or outputs is empty"; } stream_id_ = stream_id; std::string hccl_type = AnfAlgo::GetCNodeName(anf_node_); diff --git a/mindspore/ccsrc/kernel/hccl/hcom_all_broadcast.cc b/mindspore/ccsrc/kernel/hccl/hcom_all_broadcast.cc index dba692606c..9dbe708ef9 100644 --- a/mindspore/ccsrc/kernel/hccl/hcom_all_broadcast.cc +++ b/mindspore/ccsrc/kernel/hccl/hcom_all_broadcast.cc @@ -32,7 +32,12 @@ bool HcomAllBroadCastKernel::Launch(const std::vector &inputs, if (context_ptr->enable_task_sink()) { return true; } + if (inputs.empty() || hccl_data_type_list_.empty()) { + MS_LOG(ERROR) << "BroadCast param is empty"; + return false; + } const char *tag = "Hccl-BroadCast"; + MS_EXCEPTION_IF_NULL(inputs[0]); hcclResult_t ret = hcom_broadcast(tag, inputs[0]->addr, hccl_count_, hccl_data_type_list_[0], root_id_, nullptr, stream_ptr); if (ret != HCCL_SUCCESS) { diff --git a/mindspore/ccsrc/kernel/hccl/hcom_all_gather.cc b/mindspore/ccsrc/kernel/hccl/hcom_all_gather.cc index 67cd1001e3..6494f7fd12 100644 --- a/mindspore/ccsrc/kernel/hccl/hcom_all_gather.cc +++ b/mindspore/ccsrc/kernel/hccl/hcom_all_gather.cc @@ -31,6 +31,10 @@ bool HcomAllGatherKernel::Launch(const std::vector &inputs, const st if (context_ptr->enable_task_sink()) { return true; } + if (inputs.empty() || hccl_data_type_list_.empty()) { + MS_LOG(ERROR) << "AllGather param is empty"; + return false; + } const char *tag = "Hccl-AllGather"; hcclResult_t ret = hcom_all_gather(tag, inputs[0]->addr, outputs[0]->addr, hccl_count_, hccl_data_type_list_[0], nullptr, stream_ptr); diff --git a/mindspore/ccsrc/kernel/hccl/hcom_all_reduce.cc b/mindspore/ccsrc/kernel/hccl/hcom_all_reduce.cc index 2bf9823e5d..35a058e766 100644 --- a/mindspore/ccsrc/kernel/hccl/hcom_all_reduce.cc +++ b/mindspore/ccsrc/kernel/hccl/hcom_all_reduce.cc @@ -31,6 +31,10 @@ bool HcomAllReduceKernel::Launch(const std::vector &inputs, const st if (context_ptr->enable_task_sink()) { return true; } + if (inputs.empty() || outputs.empty() || hccl_data_type_list_.empty()) { + MS_LOG(ERROR) << "AllReduce param is empty"; + return false; + } const char *tag = "Hccl-AllReduce"; hcclResult_t ret = hcom_all_reduce(tag, inputs[0]->addr, outputs[0]->addr, hccl_count_, hccl_data_type_list_[0], op_type_, nullptr, stream_ptr); diff --git a/mindspore/ccsrc/kernel/hccl/hcom_all_reduce_scatter.cc b/mindspore/ccsrc/kernel/hccl/hcom_all_reduce_scatter.cc index 05217108d9..dea516885d 100644 --- a/mindspore/ccsrc/kernel/hccl/hcom_all_reduce_scatter.cc +++ b/mindspore/ccsrc/kernel/hccl/hcom_all_reduce_scatter.cc @@ -32,6 +32,10 @@ bool HcomAllReduceScatterKernel::Launch(const std::vector &inputs, if (context_ptr->enable_task_sink()) { return true; } + if (inputs.empty() || outputs.empty() || hccl_data_type_list_.empty()) { + MS_LOG(ERROR) << "ReduceScatter param is empty"; + return false; + } const char *tag = "Hccl-ReduceScatter"; hcclResult_t ret = hcom_reduce_scatter(tag, inputs[0]->addr, outputs[0]->addr, hccl_count_, hccl_data_type_list_[0], op_type_, nullptr, stream_ptr); diff --git a/mindspore/ccsrc/kernel/hccl/hcom_util.cc b/mindspore/ccsrc/kernel/hccl/hcom_util.cc index f2d35878d8..61a4d43eb5 100644 --- a/mindspore/ccsrc/kernel/hccl/hcom_util.cc +++ b/mindspore/ccsrc/kernel/hccl/hcom_util.cc @@ -66,6 +66,7 @@ bool HcomUtil::GetHcomDataType(const AnfNodePtr &anf_node, vector &shape, size_t *size) { + MS_EXCEPTION_IF_NULL(size); int tmp_size = 1; uint32_t type_size = 4; for (size_t i = 0; i < shape.size(); i++) { @@ -84,6 +85,7 @@ bool HcomUtil::GetHcclOpSize(const hcclDataType_t &data_type, const vector