Browse Source

fix ci warning:

1. Use 'const' for member functions that do not modify member variables
2. Use the 'override' keyword when overriding virtual functions
tags/v1.3.0
luopengting 5 years ago
parent
commit
786eb319a1
9 changed files with 29 additions and 28 deletions
  1. +6
    -6
      mindspore/ccsrc/backend/optimizer/somas/somas.cc
  2. +6
    -6
      mindspore/ccsrc/backend/optimizer/somas/somas.h
  3. +3
    -3
      mindspore/ccsrc/debug/env_config_parser.cc
  4. +7
    -6
      mindspore/ccsrc/debug/env_config_parser.h
  5. +1
    -1
      mindspore/ccsrc/debug/rdr/base_recorder.cc
  6. +2
    -2
      mindspore/ccsrc/debug/rdr/base_recorder.h
  7. +1
    -1
      mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.cc
  8. +2
    -2
      mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.h
  9. +1
    -1
      mindspore/ccsrc/debug/rdr/string_recorder.h

+ 6
- 6
mindspore/ccsrc/backend/optimizer/somas/somas.cc View File

@@ -1401,7 +1401,7 @@ std::string Somas::GetSplitName(const std::string &scope_name) const {
}
}

std::string Somas::SomasInfo(bool calc_hash) {
std::string Somas::SomasInfo(bool calc_hash) const {
std::ostringstream oss;
if (!calc_hash) {
DumpParameters(oss);
@@ -1516,7 +1516,7 @@ void Somas::DumpParameters(std::ostringstream &oss) const {
}
}

void Somas::DumpSomasInfoIR(const string filename) {
void Somas::DumpSomasInfoIR(const string filename) const {
if (filename.size() > PATH_MAX) {
MS_LOG(ERROR) << "File path " << filename << " is too long.";
return;
@@ -1539,7 +1539,7 @@ void Somas::DumpSomasInfoIR(const string filename) {
ofs.close();
}

std::string Somas::Offline() {
std::string Somas::Offline() const {
std::ostringstream oss;

for (auto tensor : tensors_list_) {
@@ -1583,7 +1583,7 @@ std::string Somas::Offline() {
return oss.str();
}

void Somas::DumpOfflineIR(const string filename) {
void Somas::DumpOfflineIR(const string filename) const {
MS_LOG(INFO) << "Printing somas-log-from-graph log: " << filename;
if (filename.size() > PATH_MAX) {
MS_LOG(ERROR) << "File path " << filename << " is too long.";
@@ -1608,7 +1608,7 @@ void Somas::DumpOfflineIR(const string filename) {
ofs.close();
}

std::string Somas::SomasMemory() {
std::string Somas::SomasMemory() const {
std::ostringstream oss;

std::map<size_t, size_t> mem_map;
@@ -1675,7 +1675,7 @@ std::string Somas::SomasMemory() {
return oss.str();
}

void Somas::DumpSomasMemoryIR(const string filename) {
void Somas::DumpSomasMemoryIR(const string filename) const {
if (filename.size() > PATH_MAX) {
MS_LOG(ERROR) << "File path " << filename << " is too long.";
return;


+ 6
- 6
mindspore/ccsrc/backend/optimizer/somas/somas.h View File

@@ -49,10 +49,10 @@ class Somas {
uint8_t *GetNodeOutputPtr(const AnfNodePtr &node, size_t index) const;
uint8_t *GetNodeWorkSpacePtr(const AnfNodePtr &node, size_t index) const;

std::string SomasInfo(bool calc_hash = false);
std::string SomasMemory();
void DumpSomasInfoIR(const string filename);
void DumpSomasMemoryIR(const string filename);
std::string SomasInfo(bool calc_hash = false) const;
std::string SomasMemory() const;
void DumpSomasInfoIR(const string filename) const;
void DumpSomasMemoryIR(const string filename) const;

static bool NodeSort(SomasNodePtr, SomasNodePtr);
std::vector<DynamicBitSet> reuse_matrix_;
@@ -124,8 +124,8 @@ class Somas {

bool Assign(const session::KernelGraph *graph);

std::string Offline();
void DumpOfflineIR(const string filename);
std::string Offline() const;
void DumpOfflineIR(const string filename) const;
std::string GetSplitName(const string &scope_name) const;
size_t CalcLowerBound() const;
void GenGraphStatisticInfo();


+ 3
- 3
mindspore/ccsrc/debug/env_config_parser.cc View File

@@ -66,7 +66,7 @@ std::optional<std::string> GetRdrPathFromEnv() {
}

bool EnvConfigParser::CheckJsonStringType(const nlohmann::json &content, const std::string &setting_key,
const std::string &key) {
const std::string &key) const {
if (!content.is_string()) {
MS_LOG(WARNING) << "Json Parse Failed. The '" << key << "' in '" << setting_key << "' should be string."
<< " Please check the config file '" << config_file_ << "' set by 'env_config_path' in context.";
@@ -76,7 +76,7 @@ bool EnvConfigParser::CheckJsonStringType(const nlohmann::json &content, const s
}

std::optional<nlohmann::detail::iter_impl<const nlohmann::json>> EnvConfigParser::CheckJsonKeyExist(
const nlohmann::json &content, const std::string &setting_key, const std::string &key) {
const nlohmann::json &content, const std::string &setting_key, const std::string &key) const {
auto iter = content.find(key);
if (iter == content.end()) {
MS_LOG(WARNING) << "Check json failed, '" << key << "' not found in '" << setting_key << "'."
@@ -86,7 +86,7 @@ std::optional<nlohmann::detail::iter_impl<const nlohmann::json>> EnvConfigParser
return iter;
}

std::string EnvConfigParser::GetIfstreamString(const std::ifstream &ifstream) {
std::string EnvConfigParser::GetIfstreamString(const std::ifstream &ifstream) const {
std::stringstream buffer;
buffer << ifstream.rdbuf();
return buffer.str();


+ 7
- 6
mindspore/ccsrc/debug/env_config_parser.h View File

@@ -48,21 +48,22 @@ class EnvConfigParser {
std::string config_file_{""};
bool already_parsed_{false};

// rdr
bool rdr_enabled_{false};
bool has_rdr_setting_{false};
std::string rdr_path_{"./rdr/"};

// memreuse
bool sys_memreuse_{true};

void ParseFromFile();
void ParseFromEnv();
std::string GetIfstreamString(const std::ifstream &ifstream);
void ParseRdrSetting(const nlohmann::json &content);

bool CheckJsonStringType(const nlohmann::json &content, const std::string &setting_key, const std::string &key);
std::string GetIfstreamString(const std::ifstream &ifstream) const;
bool CheckJsonStringType(const nlohmann::json &content, const std::string &setting_key, const std::string &key) const;
std::optional<nlohmann::detail::iter_impl<const nlohmann::json>> CheckJsonKeyExist(const nlohmann::json &content,
const std::string &setting_key,
const std::string &key);
const std::string &key) const;
void ParseRdrSetting(const nlohmann::json &content);
void ParseRdrPath(const nlohmann::json &content);
void ParseRdrEnable(const nlohmann::json &content);
void ParseMemReuseSetting(const nlohmann::json &content);


+ 1
- 1
mindspore/ccsrc/debug/rdr/base_recorder.cc View File

@@ -37,7 +37,7 @@ void BaseRecorder::SetFilename(const std::string &filename) {
}
}

std::optional<std::string> BaseRecorder::GetFileRealPath(const std::string &suffix) {
std::optional<std::string> BaseRecorder::GetFileRealPath(const std::string &suffix) const {
std::string filename;
if (filename_.empty()) {
filename = module_ + delimiter_ + name_;


+ 2
- 2
mindspore/ccsrc/debug/rdr/base_recorder.h View File

@@ -54,12 +54,12 @@ class BaseRecorder {
timestamp_ = ss.str();
}
}
virtual ~BaseRecorder() {}
~BaseRecorder() {}

std::string GetModule() const { return module_; }
std::string GetName() const { return name_; }
std::string GetTimeStamp() const { return timestamp_; }
std::optional<std::string> GetFileRealPath(const std::string &suffix = "");
std::optional<std::string> GetFileRealPath(const std::string &suffix = "") const;

void SetDirectory(const std::string &directory);
void SetFilename(const std::string &filename);


+ 1
- 1
mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.cc View File

@@ -30,7 +30,7 @@ std::string Vector2String(const std::vector<uint32_t> &v) {
return str;
}

json ExecNode::ExecNode2Json() {
json ExecNode::ExecNode2Json() const {
json exec_node;
exec_node[kAttrIndex] = index_;
exec_node[kAttrNodeName] = node_name_;


+ 2
- 2
mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.h View File

@@ -36,7 +36,7 @@ class ExecNode {
void SetEventId(const uint32_t &event_id) { event_id_ = event_id; }
void SetLabelId(const uint32_t &label_id) { label_ids_.push_back(label_id); }
void SetActiveStreamId(const uint32_t &active_stream_id) { active_stream_ids_.push_back(active_stream_id); }
json ExecNode2Json();
json ExecNode2Json() const;

private:
size_t index_;
@@ -93,7 +93,7 @@ class StreamExecOrderRecorder : public BaseRecorder {
}
}
~StreamExecOrderRecorder() {}
virtual void Export();
void Export() override;

private:
std::vector<ExecNodePtr> exec_order_;


+ 1
- 1
mindspore/ccsrc/debug/rdr/string_recorder.h View File

@@ -27,7 +27,7 @@ class StringRecorder : public BaseRecorder {
StringRecorder(const std::string &module, const std::string &name, const std::string &data)
: BaseRecorder(module, name), data_(data) {}
~StringRecorder() {}
virtual void Export();
void Export() override;

private:
std::string data_;


Loading…
Cancel
Save