Skip to content

Commit d35de28

Browse files
committed
Address PR comments
1 parent 46df92e commit d35de28

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

onnxruntime/core/providers/qnn/builder/qnn_backend_manager.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,20 +1596,18 @@ bool QnnBackendManager::GetPerThreadHtpPowerConfigMapping(const std::thread::id&
15961596
PerThreadHtpPowerConfigs_t& htp_power_configs) {
15971597
std::lock_guard<std::mutex> lock(per_thread_power_configs_mutex_);
15981598

1599-
if (per_thread_power_configs_.find(thread_id) == per_thread_power_configs_.end()) {
1599+
auto it = per_thread_power_configs_.find(thread_id);
1600+
if (it == per_thread_power_configs_.end()) {
16001601
return false;
16011602
}
16021603

1603-
htp_power_configs = per_thread_power_configs_.at(thread_id);
1604+
htp_power_configs = it->second;
16041605
return true;
16051606
}
16061607

1607-
void QnnBackendManager::RemovePerThreadHtpPowerConfigs(const std::thread::id& thread_id) {
1608+
void QnnBackendManager::RemovePerThreadHtpPowerConfigMapping(const std::thread::id& thread_id) {
16081609
std::lock_guard<std::mutex> lock(per_thread_power_configs_mutex_);
1609-
auto res = per_thread_power_configs_.find(thread_id);
1610-
if (res != per_thread_power_configs_.end()) {
1611-
per_thread_power_configs_.erase(thread_id);
1612-
}
1610+
per_thread_power_configs_.erase(thread_id);
16131611
}
16141612

16151613
Status QnnBackendManager::DestroyHTPPowerConfigID(uint32_t htp_power_config_id) {

onnxruntime/core/providers/qnn/builder/qnn_backend_manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ class QnnBackendManager : public std::enable_shared_from_this<QnnBackendManager>
173173
uint32_t rpc_control_latency,
174174
uint32_t rpc_polling_time);
175175

176-
Status SetPerThreadHtpPowerConfigs(const std::thread::id& theard_id, bool post_run);
176+
Status SetPerThreadHtpPowerConfigs(const std::thread::id& thread_id, bool pre_run);
177177

178178
Status AddPerThreadHtpPowerConfigMapping(const std::thread::id& thread_id,
179179
const PerThreadHtpPowerConfigs_t& htp_power_configs);
180180

181-
void RemovePerThreadHtpPowerConfigs(const std::thread::id& thread_id);
181+
void RemovePerThreadHtpPowerConfigMapping(const std::thread::id& thread_id);
182182

183183
const QNN_INTERFACE_VER_TYPE& GetQnnInterface() { return qnn_interface_; }
184184

onnxruntime/core/providers/qnn/qnn_execution_provider.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ QNNExecutionProvider::QNNExecutionProvider(const ProviderOptions& provider_optio
653653
QNNExecutionProvider::~QNNExecutionProvider() {
654654
if (qnn_backend_manager_) {
655655
auto thread_id = std::this_thread::get_id();
656-
qnn_backend_manager_->RemovePerThreadHtpPowerConfigs(thread_id);
656+
qnn_backend_manager_->RemovePerThreadHtpPowerConfigMapping(thread_id);
657657
}
658658

659659
// Unregister the ETW callback
@@ -1455,7 +1455,7 @@ Status QNNExecutionProvider::OnRunEnd(bool /*sync_stream*/, const onnxruntime::R
14551455

14561456
if (managed_htp_power_config_id_->IsValid()) {
14571457
auto thread_id = std::this_thread::get_id();
1458-
qnn_backend_manager_->RemovePerThreadHtpPowerConfigs(thread_id);
1458+
qnn_backend_manager_->RemovePerThreadHtpPowerConfigMapping(thread_id);
14591459
}
14601460

14611461
return Status::OK();
@@ -1541,7 +1541,9 @@ QNNExecutionProvider::ManagedHtpPowerConfigId::ManagedHtpPowerConfigId(std::shar
15411541
}
15421542

15431543
QNNExecutionProvider::ManagedHtpPowerConfigId::~ManagedHtpPowerConfigId() {
1544-
ORT_IGNORE_RETURN_VALUE(qnn_backend_manager_->DestroyHTPPowerConfigID(htp_power_config_id_));
1544+
if (qnn_backend_manager_) {
1545+
ORT_IGNORE_RETURN_VALUE(qnn_backend_manager_->DestroyHTPPowerConfigID(htp_power_config_id_));
1546+
}
15451547
}
15461548

15471549
void QNNExecutionProvider::ManagedHtpPowerConfigId::CreateHtpPowerConfigId(uint32_t device_id,

0 commit comments

Comments
 (0)