From 90a44ca5bd3098dee9f7fe97b2ce2beb23c94291 Mon Sep 17 00:00:00 2001 From: ZPaC Date: Sat, 19 Sep 2020 10:13:02 +0800 Subject: [PATCH] Fix code warning --- mindspore/ccsrc/ps/util.cc | 3 +++ mindspore/ccsrc/ps/worker_proxy.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mindspore/ccsrc/ps/util.cc b/mindspore/ccsrc/ps/util.cc index 08894e2c8f..a069e59784 100644 --- a/mindspore/ccsrc/ps/util.cc +++ b/mindspore/ccsrc/ps/util.cc @@ -122,6 +122,9 @@ int Util::LocalShard(int first_dim, int rank_id, int server_num) { } std::map Util::AllRankLocalShard(int first_dim, int rank_id, int server_num) { + if (first_dim <= 0 || server_num <= 0 || rank_id < 0) { + MS_LOG(EXCEPTION) << "Input values are invalid."; + } if (rank_id >= server_num) { MS_LOG(EXCEPTION) << "The rank ID " << rank_id << " should be less than the number of servers " << server_num; } diff --git a/mindspore/ccsrc/ps/worker_proxy.h b/mindspore/ccsrc/ps/worker_proxy.h index 2f4595cef5..9422d05d0c 100644 --- a/mindspore/ccsrc/ps/worker_proxy.h +++ b/mindspore/ccsrc/ps/worker_proxy.h @@ -548,8 +548,8 @@ void WorkerProxy::PrepareSparseGradient(const size_t begin, const size_t end, int offset = 0; int index = 0; size_t segment_data_size = segment_size * sizeof(T); - size_t dst_size = 0; - size_t src_size = 0; + size_t dst_size; + size_t src_size; void *dst_data = nullptr; void *src_data = nullptr; for (auto &pair : indice_to_grads) {