diff --git a/mindspore/ccsrc/backend/optimizer/somas/somas.cc b/mindspore/ccsrc/backend/optimizer/somas/somas.cc index b75fb5d5d6..8f85b1b8f8 100644 --- a/mindspore/ccsrc/backend/optimizer/somas/somas.cc +++ b/mindspore/ccsrc/backend/optimizer/somas/somas.cc @@ -1353,7 +1353,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); @@ -1469,7 +1469,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; @@ -1492,7 +1492,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_) { @@ -1536,7 +1536,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."; @@ -1561,7 +1561,7 @@ void Somas::DumpOfflineIR(const string filename) { ofs.close(); } -std::string Somas::SomasMemory() { +std::string Somas::SomasMemory() const { std::ostringstream oss; std::map mem_map; @@ -1628,7 +1628,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; diff --git a/mindspore/ccsrc/backend/optimizer/somas/somas.h b/mindspore/ccsrc/backend/optimizer/somas/somas.h index 4a04ab4323..4b3172b3a9 100644 --- a/mindspore/ccsrc/backend/optimizer/somas/somas.h +++ b/mindspore/ccsrc/backend/optimizer/somas/somas.h @@ -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 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(); diff --git a/mindspore/ccsrc/debug/env_config_parser.cc b/mindspore/ccsrc/debug/env_config_parser.cc index 803ad930f7..d29d29b649 100644 --- a/mindspore/ccsrc/debug/env_config_parser.cc +++ b/mindspore/ccsrc/debug/env_config_parser.cc @@ -66,7 +66,7 @@ std::optional 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> 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> 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(); diff --git a/mindspore/ccsrc/debug/env_config_parser.h b/mindspore/ccsrc/debug/env_config_parser.h index 49bac32216..e38c2b6735 100644 --- a/mindspore/ccsrc/debug/env_config_parser.h +++ b/mindspore/ccsrc/debug/env_config_parser.h @@ -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> 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); diff --git a/mindspore/ccsrc/debug/rdr/base_recorder.cc b/mindspore/ccsrc/debug/rdr/base_recorder.cc index f90fb98fde..b9cd0ace0e 100644 --- a/mindspore/ccsrc/debug/rdr/base_recorder.cc +++ b/mindspore/ccsrc/debug/rdr/base_recorder.cc @@ -37,7 +37,7 @@ void BaseRecorder::SetFilename(const std::string &filename) { } } -std::optional BaseRecorder::GetFileRealPath(const std::string &suffix) { +std::optional BaseRecorder::GetFileRealPath(const std::string &suffix) const { std::string filename; if (filename_.empty()) { filename = module_ + delimiter_ + name_; diff --git a/mindspore/ccsrc/debug/rdr/base_recorder.h b/mindspore/ccsrc/debug/rdr/base_recorder.h index 805aa5d7de..5defde2958 100644 --- a/mindspore/ccsrc/debug/rdr/base_recorder.h +++ b/mindspore/ccsrc/debug/rdr/base_recorder.h @@ -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 GetFileRealPath(const std::string &suffix = ""); + std::optional GetFileRealPath(const std::string &suffix = "") const; void SetDirectory(const std::string &directory); void SetFilename(const std::string &filename); diff --git a/mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.cc b/mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.cc index b01d5febb2..b8064a589e 100644 --- a/mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.cc +++ b/mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.cc @@ -30,7 +30,7 @@ std::string Vector2String(const std::vector &v) { return str; } -json ExecNode::ExecNode2Json() { +json ExecNode::ExecNode2Json() const { json exec_node; exec_node[kAttrIndex] = index_; exec_node[kAttrNodeName] = node_name_; diff --git a/mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.h b/mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.h index c67319a37f..8d08a800c7 100644 --- a/mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.h +++ b/mindspore/ccsrc/debug/rdr/stream_exec_order_recorder.h @@ -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 exec_order_; diff --git a/mindspore/ccsrc/debug/rdr/string_recorder.h b/mindspore/ccsrc/debug/rdr/string_recorder.h index 1424ad8461..f21c400878 100644 --- a/mindspore/ccsrc/debug/rdr/string_recorder.h +++ b/mindspore/ccsrc/debug/rdr/string_recorder.h @@ -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_;