Change IS_OUTPUT_ON from function to macro definition.

This commit is contained in:
张清华 2024-03-07 16:44:48 +08:00
parent 034ed7f90f
commit 93352168d2
2 changed files with 10 additions and 9 deletions

View File

@ -940,9 +940,9 @@ CNodePtr GetPrimalUser(const CNodePtr &j_user, const std::map<FuncGraphPtr, std:
// The CNode using the forward graph result and the gradient of the forward graph are not in the same graph.
// The EliminatePrimalGraph optimization can not be done. If the code use the forward network and its gradient,
// the forward network can not be eliminated. This may cause the decrease of the compilation and running efficiency.
MS_LOG(INFO) << "The gradient operation of forward network and the forward network are not called in the same"
<< " graph. The CNode to use the gradient result is: " << j_user->DebugString()
<< " This CNode is in graph: " << graph->ToString();
MS_LOG(DEBUG) << "The gradient operation of forward network and the forward network are not called in the same"
<< " graph. The CNode to use the gradient result is: " << j_user->DebugString()
<< " This CNode is in graph: " << graph->ToString();
return nullptr;
}

View File

@ -319,10 +319,11 @@ class MS_CORE_API LogWriter {
SUBMODULE_ID, excp_type, is_internal_exception) ^ \
mindspore::LogStream()
inline bool IS_OUTPUT_ON(enum MsLogLevel level) noexcept(true) {
return (static_cast<int>(level) >= mindspore::g_ms_submodule_log_levels[SUBMODULE_ID] &&
static_cast<int>(level) <= static_cast<int>(mindspore::this_thread_max_log_level));
}
#define MATCH_LEVEL(level) \
static_cast<int>(level) >= mindspore::g_ms_submodule_log_levels[SUBMODULE_ID] && \
static_cast<int>(level) <= static_cast<int>(mindspore::this_thread_max_log_level)
#define IS_OUTPUT_ON(level) (MATCH_LEVEL(level))
#define MS_LOG(level) MS_LOG_##level
@ -394,7 +395,7 @@ inline bool IS_OUTPUT_ON(enum MsLogLevel level) noexcept(true) {
if (!(condition)) { \
return false; \
} \
} while (false)
} while (0)
#define RETURN_IF_FALSE_WITH_LOG(condition, message) \
do { \
@ -402,7 +403,7 @@ inline bool IS_OUTPUT_ON(enum MsLogLevel level) noexcept(true) {
MS_LOG(ERROR) << message; \
return false; \
} \
} while (false)
} while (0)
#ifdef DEBUG
#include <cassert>