diff --git a/onnxruntime/core/providers/qnn/qnn_execution_provider.cc b/onnxruntime/core/providers/qnn/qnn_execution_provider.cc index 1d9242f8a5939..483ae03a362c0 100644 --- a/onnxruntime/core/providers/qnn/qnn_execution_provider.cc +++ b/onnxruntime/core/providers/qnn/qnn_execution_provider.cc @@ -697,6 +697,12 @@ QNNExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_viewer return result; } + if (IsNpuBackend(qnn_backend_manager_->GetQnnBackendType())) { + // Set the power config id and the default power mode from provider option for main thread, + // otherwise it will mess up the power mode if user just create session without run it. + GetPerThreadContext(); + } + // Report error if QNN CPU backend is loaded while CPU fallback is disabled if (disable_cpu_ep_fallback_ && qnn_backend_manager_->GetQnnBackendType() == qnn::QnnBackendType::CPU) { LOGS(logger, ERROR) << "Qnn CPU backend is loaded while CPU fallback is disabled."; @@ -895,7 +901,6 @@ Status QNNExecutionProvider::CompileFromOrtGraph(const std::vector& fused_nodes_and_graphs, std::vector& node_compute_funcs) { const auto& logger = *GetLogger(); - bool is_qnn_ctx_model = qnn::IsFusedGraphHasCtxNode(fused_nodes_and_graphs); onnxruntime::PathString context_cache_path;