Skip to content

Commit bc997ee

Browse files
HectorSVCashrit-ms
authored andcommitted
Fix the power mode issue for the case that run from context model (#23330)
### Description Set power config id and the default power mode from provider option (if there is) for main thread, otherwise it will mess up the power mode if user just create session without run it. The issue fixed by this PR is: Process 1 just creates the session without run it. Then, start process 2 which creates the session and run it with power saver mode. The result is with burst power mode.
1 parent 2e40cba commit bc997ee

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

onnxruntime/core/providers/qnn/qnn_execution_provider.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,12 @@ QNNExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_viewer
707707
return result;
708708
}
709709

710+
if (IsNpuBackend(qnn_backend_manager_->GetQnnBackendType())) {
711+
// Set the power config id and the default power mode from provider option for main thread,
712+
// otherwise it will mess up the power mode if user just create session without run it.
713+
GetPerThreadContext();
714+
}
715+
710716
// Report error if QNN CPU backend is loaded while CPU fallback is disabled
711717
if (disable_cpu_ep_fallback_ && qnn_backend_manager_->GetQnnBackendType() == qnn::QnnBackendType::CPU) {
712718
LOGS(logger, ERROR) << "Qnn CPU backend is loaded while CPU fallback is disabled.";
@@ -905,7 +911,6 @@ Status QNNExecutionProvider::CompileFromOrtGraph(const std::vector<FusedNodeAndG
905911
Status QNNExecutionProvider::Compile(const std::vector<FusedNodeAndGraph>& fused_nodes_and_graphs,
906912
std::vector<NodeComputeInfo>& node_compute_funcs) {
907913
const auto& logger = *GetLogger();
908-
909914
bool is_qnn_ctx_model = qnn::IsFusedGraphHasCtxNode(fused_nodes_and_graphs);
910915

911916
onnxruntime::PathString context_cache_path;

0 commit comments

Comments
 (0)