Skip to content

Commit

Permalink
Attempt to fix Linux Build 2 by having TraceLogging only for Win32. A…
Browse files Browse the repository at this point in the history
…lso log out EP Key/Value options
  • Loading branch information
ivberg committed Dec 5, 2023
1 parent 54cd9c9 commit 7bcba7c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
17 changes: 16 additions & 1 deletion onnxruntime/core/framework/execution_providers.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include "core/framework/execution_provider.h"
#include "core/graph/graph_viewer.h"
#include "core/common/logging/logging.h"
#ifdef _WIN32
#include "core/platform/tracing.h"
#endif

namespace onnxruntime {

Expand All @@ -36,7 +39,19 @@ class ExecutionProviders {
ORT_IGNORE_RETURN_VALUE(provider_idx_map_.insert({provider_id, new_provider_idx}));

// update execution provider options
exec_provider_options_[provider_id] = p_exec_provider->GetProviderOptions();
auto providerOptions = p_exec_provider->GetProviderOptions();
exec_provider_options_[provider_id] = providerOptions;

#ifdef _WIN32
for (const auto& config_pair : providerOptions) {
TraceLoggingWrite(
telemetry_provider_handle,
"ProviderOptions",
TraceLoggingString(provider_id.c_str(), "ProviderId"),
TraceLoggingString(config_pair.first.c_str(), "Key"),
TraceLoggingString(config_pair.second.c_str(), "Value"));
}
#endif

exec_provider_ids_.push_back(provider_id);
exec_providers_.push_back(p_exec_provider);
Expand Down
5 changes: 5 additions & 0 deletions onnxruntime/core/session/inference_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
#include "core/platform/Barrier.h"
#include "core/platform/ort_mutex.h"
#include "core/platform/threadpool.h"
#ifdef _WIN32
#include "core/platform/tracing.h"
#endif
#include "core/providers/cpu/controlflow/utils.h"
#include "core/providers/cpu/cpu_execution_provider.h"
#ifdef USE_DML // TODO: This is necessary for the workaround in TransformGraph
Expand Down Expand Up @@ -461,6 +463,7 @@ void InferenceSession::ConstructorCommon(const SessionOptions& session_options,
void InferenceSession::TraceSessionOptions(const SessionOptions& session_options) {
LOGS(*session_logger_, INFO) << session_options;

#ifdef _WIN32
TraceLoggingWrite(telemetry_provider_handle,
"SessionOptions",
TraceLoggingUInt8(static_cast<UINT8>(session_options.execution_mode), "execution_mode"),
Expand Down Expand Up @@ -498,6 +501,8 @@ void InferenceSession::TraceSessionOptions(const SessionOptions& session_options
TraceLoggingString(config_pair.first.c_str(), "Key"),
TraceLoggingString(config_pair.second.c_str(), "Value"));
}
#endif

}

Check warning on line 506 in onnxruntime/core/session/inference_session.cc

View workflow job for this annotation

GitHub Actions / Lint C++

[cpplint] reported by reviewdog 🐶 Redundant blank line at the end of a code block should be deleted. [whitespace/blank_line] [3] Raw Output: onnxruntime/core/session/inference_session.cc:506: Redundant blank line at the end of a code block should be deleted. [whitespace/blank_line] [3]

InferenceSession::InferenceSession(const SessionOptions& session_options, const Environment& session_env)
Expand Down
17 changes: 17 additions & 0 deletions onnxruntime/core/session/provider_registration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#include "core/session/ort_apis.h"
#include "core/providers/openvino/openvino_provider_factory_creator.h"

#ifdef _WIN32
#include <Windows.h> // For some reason, including tracing.h is having compile errors without this

#include "core/platform/tracing.h"
#endif

#if defined(USE_DML)
#include "core/providers/dml/dml_provider_factory_creator.h"
#endif
Expand Down Expand Up @@ -66,6 +72,17 @@ ORT_API_STATUS_IMPL(OrtApis::SessionOptionsAppendExecutionProvider,
return status;
}

#ifdef _WIN32
for (const auto& config_pair : provider_options) {
TraceLoggingWrite(
telemetry_provider_handle,
"ProviderOptionsAppendExecutionProvider",
TraceLoggingString(provider_name, "ProviderName"),
TraceLoggingString(config_pair.first.c_str(), "Key"),
TraceLoggingString(config_pair.second.c_str(), "Value"));
}
#endif

auto create_not_supported_status = [&provider_name]() {
return OrtApis::CreateStatus(ORT_INVALID_ARGUMENT,
(std::string(provider_name) + " execution provider is not supported in this build. ").c_str());
Expand Down

0 comments on commit 7bcba7c

Please sign in to comment.