Skip to content

fbcode//executorch/backends/qualcomm/runtime:runtime #12879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backends/qualcomm/runtime/QnnExecuTorchBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Error QnnExecuTorchBackend::execute(
DelegateHandle* handle,
EValue** args) const {
ET_CHECK_OR_RETURN_ERROR(
delegate_map_rev_.count(handle) != 0,
delegate_map_rev_.contains(handle),
Internal,
"DelegateHandle has been deleted");
QnnManager* qnn_manager = static_cast<QnnManager*>(handle);
Expand Down
4 changes: 2 additions & 2 deletions backends/qualcomm/runtime/SharedBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int32_t SharedBuffer::MemToFd(void* buf) {
void SharedBuffer::FreeMem(void* buf) {
if (!initialize_) {
QNN_EXECUTORCH_LOG_ERROR("Shared memory not initialized.");
} else if (restore_map_.count(buf) == 0) {
} else if (!restore_map_.contains(buf)) {
QNN_EXECUTORCH_LOG_WARN("Don't free an unallocated tensor.");
} else {
rpc_mem_free_(restore_map_[buf]);
Expand All @@ -156,7 +156,7 @@ void SharedBuffer::FreeMem(void* buf) {
}

bool SharedBuffer::IsAllocated(void* buf) {
return restore_map_.count(buf) != 0U;
return restore_map_.contains(buf);
}

Error SharedBuffer::Load() {
Expand Down
4 changes: 2 additions & 2 deletions backends/qualcomm/runtime/backends/QnnGraphCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Error QnnGraph::Configure(const std::string& graph_name) {
Internal,
"Fail to make graph config.");

if (handle_.count(graph_name)) {
if (handle_.contains(graph_name)) {
QNN_EXECUTORCH_LOG_ERROR(
"Graph '%s' has been configured.", graph_name.c_str());
return Error::Ok;
Expand Down Expand Up @@ -75,7 +75,7 @@ Qnn_ErrorHandle_t QnnGraph::GraphExecute(
const std::string& graph_name,
const std::vector<Qnn_Tensor_t>& input_tensor_structs,
std::vector<Qnn_Tensor_t>& output_tensor_structs) {
if (!handle_.count(graph_name)) {
if (!handle_.contains(graph_name)) {
QNN_EXECUTORCH_LOG_ERROR(
"graph name: %s does not exist.", graph_name.c_str());
return QNN_COMMON_ERROR_GENERAL;
Expand Down
14 changes: 7 additions & 7 deletions backends/qualcomm/runtime/backends/QnnImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Error QnnImplementation::StartBackend(
// library_path=libQnnHtp_2.so
// for different QnnBackend instances.
// So we warning out here.
if (loaded_backend_.count(backend_id) > 0) {
if (loaded_backend_.contains(backend_id)) {
QNN_EXECUTORCH_LOG_WARN(
"lib_path %s is loaded, but backend %d "
"already exists. Overwriting previous loaded backend...",
Expand All @@ -122,7 +122,7 @@ Error QnnImplementation::StartBackend(
}
loaded_backend_[backend_id] = provider_list[0];

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

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

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

// really don't expect.
if (loaded_backend_.count(backend_id) == 0 ||
loaded_lib_handle_.count(backend_id) == 0) {
if (!loaded_backend_.contains(backend_id) ||
!loaded_lib_handle_.contains(backend_id)) {
QNN_EXECUTORCH_LOG_ERROR(
"library %s is loaded but "
"loaded backend count=%zu, "
"loaded lib_handle count=%zu",
lib_path_.c_str(),
loaded_backend_.count(backend_id),
loaded_lib_handle_.count(backend_id));
loaded_backend_.contains(backend_id),
loaded_lib_handle_.contains(backend_id));
return Error::Internal;
}
} // be_init_mutex_ release.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bool QnnOpPackageManager::Add(std::string qnn_op_name) {

bool QnnOpPackageManager::Has(std::string qnn_op_name) {
const std::lock_guard<std::mutex> lock(table_mutex_);
return qnn_op_package_path_set_.count(qnn_op_name) > 0;
return qnn_op_package_path_set_.contains(qnn_op_name);
}

bool QnnOpPackageManager::Erase(std::string qnn_op_name) {
Expand Down
Loading