From 7e387c65089d05ec68455c1db04c5453dbba1cca Mon Sep 17 00:00:00 2001 From: Ivan Berg Date: Mon, 8 Jan 2024 19:43:36 -0800 Subject: [PATCH] Rename ORTTraceLoggingKeyword and more lint NITs --- include/onnxruntime/core/common/logging/logging.h | 6 +++--- onnxruntime/core/common/logging/logging.cc | 3 ++- onnxruntime/core/framework/execution_providers.h | 2 +- .../core/platform/windows/logging/etw_sink.cc | 14 +++++++------- onnxruntime/core/platform/windows/telemetry.cc | 2 +- .../providers/qnn/builder/qnn_backend_manager.cc | 4 ++-- .../core/providers/qnn/qnn_execution_provider.cc | 2 +- onnxruntime/core/session/inference_session.cc | 6 +++--- onnxruntime/core/session/provider_registration.cc | 2 +- 9 files changed, 21 insertions(+), 20 deletions(-) diff --git a/include/onnxruntime/core/common/logging/logging.h b/include/onnxruntime/core/common/logging/logging.h index e8d888f31665c..2b9912ea77389 100644 --- a/include/onnxruntime/core/common/logging/logging.h +++ b/include/onnxruntime/core/common/logging/logging.h @@ -76,11 +76,11 @@ struct Category { }; /// -/// TraceLogging keywords for categories of dynamic logging enablement +/// ORT TraceLogging keywords for categories of dynamic logging enablement /// -enum class TraceLoggingKeyword : uint64_t { +enum class ORTTraceLoggingKeyword : uint64_t { Session = 0x1, // ORT Session TraceLoggingWrite - Logs = 0x2, // LOGS() Macro ORT logs. Pair with an appropiate level depending on detail required + Logs = 0x2, // LOGS() Macro ORT logs. Pair with an appropriate level depending on detail required Reserved1 = 0x4, // Reserved if we want to add some specific sub-categories instead of just LOGS() or other uses Reserved2 = 0x8, Reserved3 = 0x10, diff --git a/onnxruntime/core/common/logging/logging.cc b/onnxruntime/core/common/logging/logging.cc index c7ca157c3c3a7..eac9a7fa08081 100644 --- a/onnxruntime/core/common/logging/logging.cc +++ b/onnxruntime/core/common/logging/logging.cc @@ -268,7 +268,8 @@ std::unique_ptr EnhanceLoggerWithEtw(std::unique_ptr existingLogge Severity OverrideLevelWithEtw(Severity originalSeverity) { #ifdef _WIN32 auto& manager = logging::EtwRegistrationManager::Instance(); - if (manager.IsEnabled() && (manager.Keyword() & static_cast(onnxruntime::logging::TraceLoggingKeyword::Logs)) != 0) { + if (manager.IsEnabled() && + (manager.Keyword() & static_cast(onnxruntime::logging::ORTTraceLoggingKeyword::Logs)) != 0) { return manager.MapLevelToSeverity(); } #endif // _WIN32 diff --git a/onnxruntime/core/framework/execution_providers.h b/onnxruntime/core/framework/execution_providers.h index 500055ea903d5..61147e4367876 100644 --- a/onnxruntime/core/framework/execution_providers.h +++ b/onnxruntime/core/framework/execution_providers.h @@ -48,7 +48,7 @@ class ExecutionProviders { TraceLoggingWrite( telemetry_provider_handle, "ProviderOptions", - TraceLoggingKeyword(static_cast(onnxruntime::logging::TraceLoggingKeyword::Session)), + TraceLoggingKeyword(static_cast(onnxruntime::logging::ORTTraceLoggingKeyword::Session)), TraceLoggingLevel(WINEVENT_LEVEL_INFO), TraceLoggingString(provider_id.c_str(), "ProviderId"), TraceLoggingString(config_pair.first.c_str(), "Key"), diff --git a/onnxruntime/core/platform/windows/logging/etw_sink.cc b/onnxruntime/core/platform/windows/logging/etw_sink.cc index 9b4cbd1628a55..5fb7f7a65161d 100644 --- a/onnxruntime/core/platform/windows/logging/etw_sink.cc +++ b/onnxruntime/core/platform/windows/logging/etw_sink.cc @@ -178,13 +178,13 @@ void EtwSink::SendImpl(const Timestamp& timestamp, const std::string& logger_id, // TraceLoggingWrite requires (painfully) a compile time constant for the TraceLoggingLevel, // forcing us to use an ugly macro for the call. #define ETW_EVENT_NAME "ONNXRuntimeLogEvent" -#define TRACE_LOG_WRITE(level) \ - TraceLoggingWrite(etw_provider_handle, ETW_EVENT_NAME, \ - TraceLoggingKeyword(static_cast(onnxruntime::logging::TraceLoggingKeyword::Logs)), \ - TraceLoggingLevel(level), \ - TraceLoggingString(logger_id.c_str(), "logger"), \ - TraceLoggingString(message.Category(), "category"), \ - TraceLoggingString(message.Location().ToString().c_str(), "location"), \ +#define TRACE_LOG_WRITE(level) \ + TraceLoggingWrite(etw_provider_handle, ETW_EVENT_NAME, \ + TraceLoggingKeyword(static_cast(onnxruntime::logging::ORTTraceLoggingKeyword::Logs)), \ + TraceLoggingLevel(level), \ + TraceLoggingString(logger_id.c_str(), "logger"), \ + TraceLoggingString(message.Category(), "category"), \ + TraceLoggingString(message.Location().ToString().c_str(), "location"), \ TraceLoggingString(message.Message().c_str(), "message")) const auto severity{message.Severity()}; diff --git a/onnxruntime/core/platform/windows/telemetry.cc b/onnxruntime/core/platform/windows/telemetry.cc index a70b24d50e943..a9849873fd060 100644 --- a/onnxruntime/core/platform/windows/telemetry.cc +++ b/onnxruntime/core/platform/windows/telemetry.cc @@ -244,7 +244,7 @@ void WindowsTelemetry::LogSessionCreation(uint32_t session_id, int64_t ir_versio TraceLoggingBool(true, "UTCReplace_AppSessionGuid"), TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage), TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES), - TraceLoggingKeyword(static_cast(onnxruntime::logging::TraceLoggingKeyword::Session)), + TraceLoggingKeyword(static_cast(onnxruntime::logging::ORTTraceLoggingKeyword::Session)), TraceLoggingLevel(WINEVENT_LEVEL_INFO), // Telemetry info TraceLoggingUInt8(0, "schemaVersion"), diff --git a/onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc b/onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc index f7c429a91c69c..ca6a2238e520d 100644 --- a/onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc +++ b/onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc @@ -853,7 +853,7 @@ Status QnnBackendManager::ExtractBackendProfilingInfo() { auto& provider = env.GetTelemetryProvider(); if (provider.IsEnabled()) { auto keyword = provider.Keyword(); - if ((keyword & static_cast(onnxruntime::logging::TraceLoggingKeyword::Profiling)) != 0) { + if ((keyword & static_cast(onnxruntime::logging::ORTTraceLoggingKeyword::Profiling)) != 0) { tracelogging_provider_ep_enabled = true; } } @@ -1033,7 +1033,7 @@ void QnnBackendManager::LogQnnProfileEventAsTraceLogging( TraceLoggingWrite( telemetry_provider_handle, "QNNProfilingEvent", - TraceLoggingKeyword(static_cast(onnxruntime::logging::TraceLoggingKeyword::Profiling)), + TraceLoggingKeyword(static_cast(onnxruntime::logging::ORTTraceLoggingKeyword::Profiling)), TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE), TraceLoggingValue(timestamp, "Timestamp"), TraceLoggingString(message.c_str(), "Message"), diff --git a/onnxruntime/core/providers/qnn/qnn_execution_provider.cc b/onnxruntime/core/providers/qnn/qnn_execution_provider.cc index ef612d22f6b09..e5856e85e19e8 100644 --- a/onnxruntime/core/providers/qnn/qnn_execution_provider.cc +++ b/onnxruntime/core/providers/qnn/qnn_execution_provider.cc @@ -152,7 +152,7 @@ QNNExecutionProvider::QNNExecutionProvider(const ProviderOptions& provider_optio if (provider.IsEnabled()) { auto level = provider.Level(); auto keyword = provider.Keyword(); - if ((keyword & static_cast(onnxruntime::logging::TraceLoggingKeyword::Profiling)) != 0) { + if ((keyword & static_cast(onnxruntime::logging::ORTTraceLoggingKeyword::Profiling)) != 0) { if (level != 0) { if (level == 5) { LOGS_DEFAULT(INFO) << "Overriding profiling to basic based on ETW level: " << static_cast(level); diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index b4671ddd0713b..93877c8dd66bd 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -479,7 +479,7 @@ void InferenceSession::TraceSessionOptions(const SessionOptions& session_options #ifdef _WIN32 TraceLoggingWrite(telemetry_provider_handle, "SessionOptions", - TraceLoggingKeyword(static_cast(onnxruntime::logging::TraceLoggingKeyword::Session)), + TraceLoggingKeyword(static_cast(onnxruntime::logging::ORTTraceLoggingKeyword::Session)), TraceLoggingLevel(WINEVENT_LEVEL_INFO), TraceLoggingUInt8(static_cast(session_options.execution_mode), "execution_mode"), TraceLoggingUInt8(static_cast(session_options.execution_order), "execution_order"), @@ -501,7 +501,7 @@ void InferenceSession::TraceSessionOptions(const SessionOptions& session_options TraceLoggingWrite( telemetry_provider_handle, "SessionOptions_IntraOrtThreadPoolParams", - TraceLoggingKeyword(static_cast(onnxruntime::logging::TraceLoggingKeyword::Session)), + TraceLoggingKeyword(static_cast(onnxruntime::logging::ORTTraceLoggingKeyword::Session)), TraceLoggingLevel(WINEVENT_LEVEL_INFO), TraceLoggingInt32(session_options.intra_op_param.thread_pool_size, "thread_pool_size"), TraceLoggingBoolean(session_options.intra_op_param.auto_set_affinity, "auto_set_affinity"), @@ -515,7 +515,7 @@ void InferenceSession::TraceSessionOptions(const SessionOptions& session_options TraceLoggingWrite( telemetry_provider_handle, "SessionOptions_ConfigEntry", - TraceLoggingKeyword(static_cast(onnxruntime::logging::TraceLoggingKeyword::Session)), + TraceLoggingKeyword(static_cast(onnxruntime::logging::ORTTraceLoggingKeyword::Session)), TraceLoggingLevel(WINEVENT_LEVEL_INFO), TraceLoggingString(config_pair.first.c_str(), "Key"), TraceLoggingString(config_pair.second.c_str(), "Value")); diff --git a/onnxruntime/core/session/provider_registration.cc b/onnxruntime/core/session/provider_registration.cc index 73c646f1186ef..b012406bd026a 100644 --- a/onnxruntime/core/session/provider_registration.cc +++ b/onnxruntime/core/session/provider_registration.cc @@ -77,7 +77,7 @@ ORT_API_STATUS_IMPL(OrtApis::SessionOptionsAppendExecutionProvider, TraceLoggingWrite( telemetry_provider_handle, "ProviderOptionsAppendExecutionProvider", - TraceLoggingKeyword(static_cast(onnxruntime::logging::TraceLoggingKeyword::Session)), + TraceLoggingKeyword(static_cast(onnxruntime::logging::ORTTraceLoggingKeyword::Session)), TraceLoggingLevel(WINEVENT_LEVEL_INFO), TraceLoggingString(provider_name, "ProviderName"), TraceLoggingString(config_pair.first.c_str(), "Key"),