Skip to content

Commit 75078fa

Browse files
CodemodService Botfacebook-github-bot
authored andcommitted
fbcode//executorch/backends/qualcomm/runtime:runtime
Reviewed By: dtolnay Differential Revision: D79042066
1 parent 6d4b68a commit 75078fa

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

backends/qualcomm/runtime/QnnExecuTorchBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Error QnnExecuTorchBackend::execute(
116116
DelegateHandle* handle,
117117
EValue** args) const {
118118
ET_CHECK_OR_RETURN_ERROR(
119-
delegate_map_rev_.count(handle) != 0,
119+
delegate_map_rev_.contains(handle),
120120
Internal,
121121
"DelegateHandle has been deleted");
122122
QnnManager* qnn_manager = static_cast<QnnManager*>(handle);

backends/qualcomm/runtime/SharedBuffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ int32_t SharedBuffer::MemToFd(void* buf) {
147147
void SharedBuffer::FreeMem(void* buf) {
148148
if (!initialize_) {
149149
QNN_EXECUTORCH_LOG_ERROR("Shared memory not initialized.");
150-
} else if (restore_map_.count(buf) == 0) {
150+
} else if (!restore_map_.contains(buf)) {
151151
QNN_EXECUTORCH_LOG_WARN("Don't free an unallocated tensor.");
152152
} else {
153153
rpc_mem_free_(restore_map_[buf]);
@@ -156,7 +156,7 @@ void SharedBuffer::FreeMem(void* buf) {
156156
}
157157

158158
bool SharedBuffer::IsAllocated(void* buf) {
159-
return restore_map_.count(buf) != 0U;
159+
return restore_map_.contains(buf);
160160
}
161161

162162
Error SharedBuffer::Load() {

backends/qualcomm/runtime/backends/QnnGraphCommon.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Error QnnGraph::Configure(const std::string& graph_name) {
2222
Internal,
2323
"Fail to make graph config.");
2424

25-
if (handle_.count(graph_name)) {
25+
if (handle_.contains(graph_name)) {
2626
QNN_EXECUTORCH_LOG_ERROR(
2727
"Graph '%s' has been configured.", graph_name.c_str());
2828
return Error::Ok;
@@ -75,7 +75,7 @@ Qnn_ErrorHandle_t QnnGraph::GraphExecute(
7575
const std::string& graph_name,
7676
const std::vector<Qnn_Tensor_t>& input_tensor_structs,
7777
std::vector<Qnn_Tensor_t>& output_tensor_structs) {
78-
if (!handle_.count(graph_name)) {
78+
if (!handle_.contains(graph_name)) {
7979
QNN_EXECUTORCH_LOG_ERROR(
8080
"graph name: %s does not exist.", graph_name.c_str());
8181
return QNN_COMMON_ERROR_GENERAL;

backends/qualcomm/runtime/backends/QnnImplementation.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Error QnnImplementation::StartBackend(
113113
// library_path=libQnnHtp_2.so
114114
// for different QnnBackend instances.
115115
// So we warning out here.
116-
if (loaded_backend_.count(backend_id) > 0) {
116+
if (loaded_backend_.contains(backend_id)) {
117117
QNN_EXECUTORCH_LOG_WARN(
118118
"lib_path %s is loaded, but backend %d "
119119
"already exists. Overwriting previous loaded backend...",
@@ -122,7 +122,7 @@ Error QnnImplementation::StartBackend(
122122
}
123123
loaded_backend_[backend_id] = provider_list[0];
124124

125-
if (loaded_lib_handle_.count(backend_id) > 0) {
125+
if (loaded_lib_handle_.contains(backend_id)) {
126126
QNN_EXECUTORCH_LOG_WARN("closing %pK...", loaded_lib_handle_[backend_id]);
127127

128128
int dlclose_error = dlclose(loaded_lib_handle_[backend_id]);
@@ -183,7 +183,7 @@ Error QnnImplementation::Load(const QnnSaver_Config_t** saver_config) {
183183
{
184184
const std::lock_guard<std::mutex> lock(be_init_mutex_);
185185

186-
if (lib_path_to_backend_id_.count(lib_path_) == 0) {
186+
if (!lib_path_to_backend_id_.contains(lib_path_)) {
187187
Error st = StartBackend(lib_path_, saver_config);
188188
ET_CHECK_OR_RETURN_ERROR(
189189
st == Error::Ok, Internal, "Fail to start backend");
@@ -193,15 +193,15 @@ Error QnnImplementation::Load(const QnnSaver_Config_t** saver_config) {
193193
backend_id = lib_path_to_backend_id_[lib_path_];
194194

195195
// really don't expect.
196-
if (loaded_backend_.count(backend_id) == 0 ||
197-
loaded_lib_handle_.count(backend_id) == 0) {
196+
if (!loaded_backend_.contains(backend_id) ||
197+
!loaded_lib_handle_.contains(backend_id)) {
198198
QNN_EXECUTORCH_LOG_ERROR(
199199
"library %s is loaded but "
200200
"loaded backend count=%zu, "
201201
"loaded lib_handle count=%zu",
202202
lib_path_.c_str(),
203-
loaded_backend_.count(backend_id),
204-
loaded_lib_handle_.count(backend_id));
203+
loaded_backend_.contains(backend_id),
204+
loaded_lib_handle_.contains(backend_id));
205205
return Error::Internal;
206206
}
207207
} // be_init_mutex_ release.

backends/qualcomm/runtime/backends/QnnOpPackageManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bool QnnOpPackageManager::Add(std::string qnn_op_name) {
1919

2020
bool QnnOpPackageManager::Has(std::string qnn_op_name) {
2121
const std::lock_guard<std::mutex> lock(table_mutex_);
22-
return qnn_op_package_path_set_.count(qnn_op_name) > 0;
22+
return qnn_op_package_path_set_.contains(qnn_op_name);
2323
}
2424

2525
bool QnnOpPackageManager::Erase(std::string qnn_op_name) {

0 commit comments

Comments
 (0)