!10199 fix env param by adding accepted value

From: @jiang-shuqiang
Reviewed-by: 
Signed-off-by:
This commit is contained in:
mindspore-ci-bot 2020-12-19 16:09:23 +08:00 committed by Gitee
commit 512cd38406
2 changed files with 21 additions and 3 deletions

View File

@ -72,6 +72,7 @@ Debugger::Debugger()
initial_suspend_(true),
not_dataset_graph_sum_(0),
version_("") {
CheckDebuggerEnabledParam();
if (CheckDebuggerEnabled()) {
// configure partial memory reuse
partial_memory_ = CheckDebuggerPartialMemoryEnabled();
@ -222,15 +223,30 @@ bool Debugger::CheckDebuggerDumpEnabled() {
bool Debugger::CheckDebuggerEnabled() {
// get env variables to configure debugger
const char *env_enable_str = std::getenv("ENABLE_MS_DEBUGGER");
if (env_enable_str != nullptr) {
if (std::strcmp(env_enable_str, "1") == 0) {
const char *env_enable_char = std::getenv("ENABLE_MS_DEBUGGER");
if (env_enable_char != nullptr) {
std::string env_enable_str = env_enable_char;
(void)std::transform(env_enable_str.begin(), env_enable_str.end(), env_enable_str.begin(), ::tolower);
if (env_enable_str == "1" || env_enable_str == "true") {
return true;
}
}
return false;
}
void Debugger::CheckDebuggerEnabledParam() {
// check the value of env variable ENABLE_MS_DEBUGGER
const char *env_enable_char = std::getenv("ENABLE_MS_DEBUGGER");
if (env_enable_char != nullptr) {
std::string env_enable_str = env_enable_char;
(void)std::transform(env_enable_str.begin(), env_enable_str.end(), env_enable_str.begin(), ::tolower);
if (env_enable_str != "0" && env_enable_str != "1" && env_enable_str != "false" && env_enable_str != "true") {
MS_LOG(WARNING) << "Env variable ENABLE_MS_DEBUGGER should be True/False/1/0 (case insensitive), but get: "
<< env_enable_str;
}
}
}
bool Debugger::CheckDebuggerPartialMemoryEnabled() {
const char *env_partial_mem_str = std::getenv("MS_DEBUGGER_PARTIAL_MEM");
if (env_partial_mem_str != nullptr) {

View File

@ -164,6 +164,8 @@ class Debugger : public std::enable_shared_from_this<Debugger> {
// check if debugger enabled
bool CheckDebuggerEnabled();
void CheckDebuggerEnabledParam();
bool CheckDebuggerPartialMemoryEnabled();
// check and save graph pointer