From 71b6370b4d31c02a003f52030f302bf2fd09285b Mon Sep 17 00:00:00 2001 From: baihuawei Date: Sun, 28 Jun 2020 17:10:03 +0800 Subject: [PATCH] clear warning --- .../ccsrc/device/ascend/ascend_device_address.cc | 2 -- .../ccsrc/device/ascend/ascend_kernel_runtime.cc | 9 +++++---- mindspore/ccsrc/device/ascend/kernel_select_ascend.cc | 1 - mindspore/ccsrc/device/cpu/mpi/mpi_adapter.cc | 3 --- mindspore/ccsrc/device/kernel_runtime_manager.cc | 11 ++++++++--- mindspore/ccsrc/kernel/common_utils.cc | 7 ------- .../ccsrc/kernel/cpu/embedding_look_up_cpu_kernel.cc | 7 +++---- mindspore/ccsrc/kernel/cpu/reduce_cpu_kernel.cc | 1 - mindspore/ccsrc/kernel/cpu/reduce_cpu_kernel.h | 1 - 9 files changed, 16 insertions(+), 26 deletions(-) diff --git a/mindspore/ccsrc/device/ascend/ascend_device_address.cc b/mindspore/ccsrc/device/ascend/ascend_device_address.cc index ccf9dfe405..f678518541 100644 --- a/mindspore/ccsrc/device/ascend/ascend_device_address.cc +++ b/mindspore/ccsrc/device/ascend/ascend_device_address.cc @@ -375,7 +375,6 @@ bool AscendDeviceAddress::LoadMemToHost(bool trans_flag, const std::string &tens tensor_data->SetTensor(out_tensor); tensor_data->SetSlot(slot); ret = tensor_loader->LoadNewTensor(tensor_data); - } else { mindspore::tensor::TensorPtr out_tensor = std::make_shared(type_id_, host_shape); size_t host_size = out_tensor->data().nbytes(); @@ -395,7 +394,6 @@ bool AscendDeviceAddress::LoadMemToHost(bool trans_flag, const std::string &tens return ret; } #endif - } // namespace ascend } // namespace device } // namespace mindspore diff --git a/mindspore/ccsrc/device/ascend/ascend_kernel_runtime.cc b/mindspore/ccsrc/device/ascend/ascend_kernel_runtime.cc index 99be7bd3a2..dd1be39e55 100644 --- a/mindspore/ccsrc/device/ascend/ascend_kernel_runtime.cc +++ b/mindspore/ccsrc/device/ascend/ascend_kernel_runtime.cc @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#define PATH_MAX 0x3ffff #include "device/ascend/ascend_kernel_runtime.h" #include #include @@ -21,7 +21,6 @@ #include #include #include - #include "device/ascend/ascend_device_address.h" #include "device/cpu/mpi/mpi_adapter.h" #include "utils/context/ms_context.h" @@ -433,7 +432,6 @@ bool AscendKernelRuntime::GenTask(const session::KernelGraph *graph) { assign_instance.GetWaitStreams(&wait_active_stream_list); std::vector force_copy_stream_list; assign_instance.GetHcomStreams(&force_copy_stream_list); - MS_LOG(INFO) << "call DavinciModel total stream num:" << resource_manager.get_cur_stream_num() << ", total event num:" << resource_manager.get_cur_event_num() << ", total label num:" << label_assign_instance.GetLabelNum(NOT_NULL(graph)) @@ -444,7 +442,6 @@ bool AscendKernelRuntime::GenTask(const session::KernelGraph *graph) { task_info_list, empty_list, empty_list, empty_list, empty_list, wait_active_stream_list, force_copy_stream_list, 0, 0, 0, 0, 0, 0, resource_manager.get_cur_stream_num(), label_assign_instance.GetLabelNum(NOT_NULL(graph)), resource_manager.get_cur_event_num(), 0); - auto ret = graph_model_map_.insert(std::make_pair(graph->graph_id(), model)); if (!ret.second) { MS_LOG(EXCEPTION) << "Duplicate GraphId! Please check in ascend_session."; @@ -625,6 +622,10 @@ bool AscendKernelRuntime::HcclInit() { return false; } } + if (strlen(config_path_str) > PATH_MAX) { + MS_LOG(ERROR) << "file path oversize"; + return false; + } std::string rank_id_str = GetRankId(); auto full_path = realpath(config_path_str, nullptr); if (full_path == nullptr) { diff --git a/mindspore/ccsrc/device/ascend/kernel_select_ascend.cc b/mindspore/ccsrc/device/ascend/kernel_select_ascend.cc index 4e56721fe0..cecbcfe617 100644 --- a/mindspore/ccsrc/device/ascend/kernel_select_ascend.cc +++ b/mindspore/ccsrc/device/ascend/kernel_select_ascend.cc @@ -24,7 +24,6 @@ #include #include #include - #include "common/utils.h" #include "debug/anf_ir_dump.h" #include "operator/ops.h" diff --git a/mindspore/ccsrc/device/cpu/mpi/mpi_adapter.cc b/mindspore/ccsrc/device/cpu/mpi/mpi_adapter.cc index 1307e49644..9b06c0a40a 100644 --- a/mindspore/ccsrc/device/cpu/mpi/mpi_adapter.cc +++ b/mindspore/ccsrc/device/cpu/mpi/mpi_adapter.cc @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #include "device/cpu/mpi/mpi_adapter.h" #ifdef ENABLE_MPI #include @@ -262,9 +261,7 @@ bool MPIAdapter::AllGather(const float *input, float *output, const std::vector< if (comm == MPI_COMM_NULL) { RAISE_EXCEPTION_WITH_PARAM("create mpi comm fail! rankid:", rank_id_); } - auto ret = MPI_Allgather(input, data_num, MPI_FLOAT, output, data_num, MPI_FLOAT, comm); - if (ret != MPI_SUCCESS) { RAISE_EXCEPTION_WITH_PARAM("mpi allgater fail!ret = ", ret); } diff --git a/mindspore/ccsrc/device/kernel_runtime_manager.cc b/mindspore/ccsrc/device/kernel_runtime_manager.cc index 0f95f3e79b..29d74762b4 100644 --- a/mindspore/ccsrc/device/kernel_runtime_manager.cc +++ b/mindspore/ccsrc/device/kernel_runtime_manager.cc @@ -56,9 +56,14 @@ KernelRuntime *KernelRuntimeManager::GetSingleKernelRuntime(const std::string &d auto cur_runtime_key = runtime_map_.begin()->first; auto find_pos = cur_runtime_key.rfind('_'); if (find_pos != std::string::npos) { - auto cur_device_id = cur_runtime_key.substr(find_pos + 1); - MS_LOG(EXCEPTION) << "Can't change device id in runtime, already set device id: " << cur_device_id - << ", set device id: " << device_id << " failed"; + if (cur_runtime_key.size() > find_pos + 1) { + auto cur_device_id = cur_runtime_key.substr(find_pos + 1); + MS_LOG(EXCEPTION) << "Can't change device id in runtime, already set device id: " << cur_device_id + << ", set device id: " << device_id << " failed"; + } else { + MS_LOG(EXCEPTION) << "Can't change device id in runtime, current runtime_key size error, set device id: " + << device_id << " failed"; + } } } return GetKernelRuntime(device_name, device_id); diff --git a/mindspore/ccsrc/kernel/common_utils.cc b/mindspore/ccsrc/kernel/common_utils.cc index 868abeb1cc..012fecbadb 100644 --- a/mindspore/ccsrc/kernel/common_utils.cc +++ b/mindspore/ccsrc/kernel/common_utils.cc @@ -721,19 +721,16 @@ std::vector> GetOutputIndex(const std::vectorDebugString(2) << "] of [" << output->func_graph()->ToString() << "] found no related kernel info."; @@ -744,18 +741,14 @@ std::vector> GetOutputIndex(const std::vector *node_list) { MS_EXCEPTION_IF_NULL(node_list); - MS_EXCEPTION_IF_NULL(func_graph); - std::vector node_lists = TopoSort(func_graph->get_return()); for (auto const &node : node_lists) { if (!AnfAlgo::IsRealKernel(node) || !node->isa()) { continue; } - auto cnode = node->cast(); MS_EXCEPTION_IF_NULL(cnode); - if (IsValueNode(cnode->input(kAnfPrimitiveIndex))) { node_list->push_back(node); } diff --git a/mindspore/ccsrc/kernel/cpu/embedding_look_up_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/embedding_look_up_cpu_kernel.cc index 6c8b1ba28f..c8c2c667ad 100644 --- a/mindspore/ccsrc/kernel/cpu/embedding_look_up_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/embedding_look_up_cpu_kernel.cc @@ -115,9 +115,9 @@ bool EmbeddingLookUpCPUKernel::Launch(const std::vector &inp return true; } -void LookUpTable_task(const float *input_addr, float *output_addr, int *indices_addr, size_t indices_lens, size_t num, - size_t dim0, size_t dim1, size_t dim2, int offset, size_t axis, std::vector input_shape, - size_t input_lens) { +void LookUpTable_task(const float *input_addr, float *output_addr, const int *indices_addr, size_t indices_lens, + size_t num, size_t dim0, size_t dim1, size_t dim2, int offset, size_t axis, + std::vector input_shape, size_t input_lens) { size_t lens = num * sizeof(float); for (size_t i = 0; i < indices_lens; ++i) { int indices = indices_addr[i] - offset; @@ -134,7 +134,6 @@ void LookUpTable_task(const float *input_addr, float *output_addr, int *indices_ } else if (axis == 0) { pos = CPUKernelUtils::CalcOffset(input_shape, index, 0, 0, 0); } - if (pos + num <= input_lens) { auto ret = memcpy_s(output_addr, lens, input_addr + pos, lens); if (ret != EOK) { diff --git a/mindspore/ccsrc/kernel/cpu/reduce_cpu_kernel.cc b/mindspore/ccsrc/kernel/cpu/reduce_cpu_kernel.cc index b12371c933..e56f2af8c7 100644 --- a/mindspore/ccsrc/kernel/cpu/reduce_cpu_kernel.cc +++ b/mindspore/ccsrc/kernel/cpu/reduce_cpu_kernel.cc @@ -55,7 +55,6 @@ void ReduceCPUKernel::InitKernel(const CNodePtr &kernel_node) { } } else if (axis_addr->isa()) { int axis = AnfAlgo::GetNodeAttr(kernel_node, AXIS); - if (axis >= 0 && IntToSize(axis) >= shape_.size()) { MS_LOG(EXCEPTION) << "axis value is oversize."; } diff --git a/mindspore/ccsrc/kernel/cpu/reduce_cpu_kernel.h b/mindspore/ccsrc/kernel/cpu/reduce_cpu_kernel.h index 27d28ba3bd..3317ec72ed 100644 --- a/mindspore/ccsrc/kernel/cpu/reduce_cpu_kernel.h +++ b/mindspore/ccsrc/kernel/cpu/reduce_cpu_kernel.h @@ -46,7 +46,6 @@ MS_REG_CPU_KERNEL(ReduceMax, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOu ReduceCPUKernel); MS_REG_CPU_KERNEL(ReduceSum, KernelAttr().AddInputAttr(kNumberTypeFloat32).AddOutputAttr(kNumberTypeFloat32), ReduceCPUKernel); - } // namespace kernel } // namespace mindspore #endif // MINDSPORE_CCSRC_KERNEL_CPU_REDUCE_CPU_KERNEL_H_