From af8f0c657dfbe127ad9833b232fc5d5fb0c28590 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 02:00:59 +0000 Subject: [PATCH 1/3] Initial plan From dc1388b1dc6018fd98ce3b5616bb1eb7d25f53f2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 02:07:26 +0000 Subject: [PATCH 2/3] Add error handling for run-level profiler initialization Co-authored-by: xiaofeihan1 <107654914+xiaofeihan1@users.noreply.github.com> --- onnxruntime/core/session/inference_session.cc | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index 8fbba20d2a3c4..97f20f1c5a4f9 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -2938,16 +2938,28 @@ Status InferenceSession::Run(const RunOptions& run_options, "Ignoring run-level profiling request."; } if (run_options.enable_profiling && !session_profiler_.IsEnabled()) { - run_profiler.emplace(); - run_profiler->Initialize(session_logger_); - PathString profile_file = ToPathString(run_options.profile_file_prefix); - profile_file.append(ORT_TSTR("_")); - profile_file.append(GetCurrentTimeString()); - profile_file.append(ORT_TSTR(".json")); - for (auto& ep : execution_providers_) { - run_profiler->AddEpProfilers(ep->GetProfiler()); + try { + run_profiler.emplace(); + run_profiler->Initialize(session_logger_); + PathString profile_file = ToPathString(run_options.profile_file_prefix); + profile_file.append(ORT_TSTR("_")); + profile_file.append(GetCurrentTimeString()); + profile_file.append(ORT_TSTR(".json")); + for (auto& ep : execution_providers_) { + run_profiler->AddEpProfilers(ep->GetProfiler()); + } + run_profiler->StartProfiling(profile_file); + + // Verify profiler was successfully initialized and enabled + if (!run_profiler->IsEnabled()) { + LOGS(*session_logger_, WARNING) << "Failed to enable run-level profiler. Profiling will not be performed for this run."; + run_profiler.reset(); + } + } catch (const std::exception& ex) { + LOGS(*session_logger_, WARNING) << "Failed to initialize run-level profiler: " << ex.what() + << ". Profiling will not be performed for this run."; + run_profiler.reset(); } - run_profiler->StartProfiling(profile_file); } TimePoint tp = std::chrono::high_resolution_clock::now(); From e41456a5ec2a5c21ef1f72d6d19d83f69a3bcd21 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 16 Jan 2026 02:09:23 +0000 Subject: [PATCH 3/3] Remove unnecessary blank line Co-authored-by: xiaofeihan1 <107654914+xiaofeihan1@users.noreply.github.com> --- onnxruntime/core/session/inference_session.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/onnxruntime/core/session/inference_session.cc b/onnxruntime/core/session/inference_session.cc index 97f20f1c5a4f9..de56faac6736a 100644 --- a/onnxruntime/core/session/inference_session.cc +++ b/onnxruntime/core/session/inference_session.cc @@ -2949,7 +2949,6 @@ Status InferenceSession::Run(const RunOptions& run_options, run_profiler->AddEpProfilers(ep->GetProfiler()); } run_profiler->StartProfiling(profile_file); - // Verify profiler was successfully initialized and enabled if (!run_profiler->IsEnabled()) { LOGS(*session_logger_, WARNING) << "Failed to enable run-level profiler. Profiling will not be performed for this run.";