From e1e11b841d2e7282c773b68c5d2766487b49155d Mon Sep 17 00:00:00 2001 From: buxue Date: Wed, 22 Apr 2020 16:44:13 +0800 Subject: [PATCH] fix codedex --- mindspore/ccsrc/pipeline/pipeline.cc | 2 +- mindspore/ccsrc/pipeline/pipeline_ge.cc | 2 +- mindspore/ccsrc/utils/contract.h | 2 ++ mindspore/ccsrc/utils/profile.cc | 28 +++++++++++++++---------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/mindspore/ccsrc/pipeline/pipeline.cc b/mindspore/ccsrc/pipeline/pipeline.cc index 5b5cae404..fca105d13 100644 --- a/mindspore/ccsrc/pipeline/pipeline.cc +++ b/mindspore/ccsrc/pipeline/pipeline.cc @@ -584,7 +584,7 @@ void ExecutorPy::ProcessVmArg(const py::tuple &args, const std::string &phase, V if (ms_context->backend_policy() == kMsConvert && py::isinstance(arg)) { MS_LOG(EXCEPTION) << "Args[" << i << "] is numpy array, not tensor"; } - (*arg_list).push_back(arg); + arg_list->push_back(arg); } ResourcePtr res = GetResource(phase); diff --git a/mindspore/ccsrc/pipeline/pipeline_ge.cc b/mindspore/ccsrc/pipeline/pipeline_ge.cc index e3b10b73b..1da85b569 100644 --- a/mindspore/ccsrc/pipeline/pipeline_ge.cc +++ b/mindspore/ccsrc/pipeline/pipeline_ge.cc @@ -462,7 +462,7 @@ void ProcessGeArg(const std::map &info, const py:: MS_LOG(EXCEPTION) << "Args convert error"; } if (converted->isa()) { - (*inputs).push_back(converted->cast()); + inputs->push_back(converted->cast()); } else { MS_LOG(EXCEPTION) << "Args " << converted->ToString() << " is not tensor"; } diff --git a/mindspore/ccsrc/utils/contract.h b/mindspore/ccsrc/utils/contract.h index fc257b3e2..6ef992824 100644 --- a/mindspore/ccsrc/utils/contract.h +++ b/mindspore/ccsrc/utils/contract.h @@ -28,6 +28,7 @@ class ContractError : public std::logic_error { public: explicit ContractError(const std::string &msg) : std::logic_error(msg) {} explicit ContractError(const char *msg) : std::logic_error(msg) {} + ~ContractError() override = default; }; struct Signatory { @@ -60,6 +61,7 @@ class Ensures : public EnsuresAccess { } template >> Ensures(const Ensures &other) : value_(other.get()) {} + ~Ensures() = default; T get() const { return value_; } T &get() { return value_; } diff --git a/mindspore/ccsrc/utils/profile.cc b/mindspore/ccsrc/utils/profile.cc index 997cc1b56..e9e7920e0 100644 --- a/mindspore/ccsrc/utils/profile.cc +++ b/mindspore/ccsrc/utils/profile.cc @@ -38,26 +38,32 @@ void PrintProfile(std::ostringstream &oss, const TimeInfo &time_info, int indent void PrintTimeInfoMap(std::ostringstream &oss, const TimeInfoMap &dict, int indent = 0, std::map *sums = nullptr, const std::string &prefix = "") { - for (auto iter = dict.begin(); iter != dict.end(); ++iter) { - if (iter->second == nullptr) { + size_t count = 0; + for (const auto &iter : dict) { + count++; + if (iter.second == nullptr) { continue; } // indent by multiples of 4 spaces. - auto name = iter->first.substr(TIME_INFO_PREFIX_NUM_LEN); + if (iter.first.size() < TIME_INFO_PREFIX_NUM_LEN) { + MS_LOG(EXCEPTION) << "In TimeInfoMap, the " << count << "th string key is " << iter.first + << ", but the length is less than " << TIME_INFO_PREFIX_NUM_LEN; + } + auto name = iter.first.substr(TIME_INFO_PREFIX_NUM_LEN); oss << std::setw(indent * 4) << "" - << "[" << name << "]: " << iter->second->time_; - if (iter->second->dict_ != nullptr) { - oss << ", [" << iter->second->dict_->size() << "]"; + << "[" << name << "]: " << iter.second->time_; + if (iter.second->dict_ != nullptr) { + oss << ", [" << iter.second->dict_->size() << "]"; } oss << "\n"; std::string newPrefix = prefix; - if (iter->first.find("Cycle ") == std::string::npos) { - newPrefix = prefix.empty() ? iter->first : prefix + "." + iter->first; + if (iter.first.find("Cycle ") == std::string::npos) { + newPrefix = prefix.empty() ? iter.first : prefix + "." + iter.first; } - PrintProfile(oss, *iter->second, indent + 1, sums, newPrefix); - if (iter->second->dict_ == nullptr) { - (*sums)[newPrefix] += iter->second->time_; + PrintProfile(oss, *iter.second, indent + 1, sums, newPrefix); + if (iter.second->dict_ == nullptr) { + (*sums)[newPrefix] += iter.second->time_; } } } -- GitLab