From bad19b9c9efa9e24c919d7e6f9af2630ee7885bb Mon Sep 17 00:00:00 2001 From: Chi Lo Date: Thu, 6 Feb 2025 17:25:22 -0800 Subject: [PATCH] handle status --- .../providers/tensorrt/tensorrt_execution_provider.cc | 11 ++++++++--- onnxruntime/core/session/provider_bridge_ort.cc | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc index bce845b52c2b2..48fbb6c6fedee 100644 --- a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc +++ b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc @@ -2670,10 +2670,15 @@ TensorrtExecutionProvider::GetCapability(const GraphViewer& graph, */ std::function>(const GraphViewer&)> selection_func; - auto status = g_host->GetOptimizerByName("ConstantFoldingDQ", selection_func); std::vector> selection_cc; - if (selection_func) { - selection_cc = selection_func(graph); + std::string optimizer_name = "ConstantFoldingDQ"; + auto status = g_host->GetOptimizerByName(optimizer_name, selection_func); + if (status == Status::OK()) { + if (selection_func) { + selection_cc = selection_func(graph); + } + } else { + LOGS_DEFAULT(WARNING) << "[TensorRT EP] Can't get optimizer " << optimizer_name; } std::unordered_set trt_selection_node_set; // The qualified dq nodes selected by TRT EP diff --git a/onnxruntime/core/session/provider_bridge_ort.cc b/onnxruntime/core/session/provider_bridge_ort.cc index 46346e9457f21..483ef09468165 100644 --- a/onnxruntime/core/session/provider_bridge_ort.cc +++ b/onnxruntime/core/session/provider_bridge_ort.cc @@ -222,8 +222,9 @@ struct ProviderHostImpl : ProviderHost { if (func.has_value()) { selection_func = func.value(); + } else { + return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Failed to get optimizer " + optimizer_name); } - return Status::OK(); };