@@ -1132,8 +1132,8 @@ struct ggml_backend_qnn_context {
1132
1132
struct qcom_socinfo socinfo;
1133
1133
} ;
1134
1134
1135
- // TODO: the following global vars and three helper funcs should be removed in the future
1136
- static int32_t g_ggmltensor_idx = 0 ;
1135
+ // the following helper funcs are used to ensure every QNN tensor name is unique
1136
+ static std::atomic< int32_t > g_ggmltensor_idx ( 0 ) ;
1137
1137
static void reset_idx () {
1138
1138
g_ggmltensor_idx = 0 ;
1139
1139
}
@@ -1143,7 +1143,7 @@ static void inc_idx() {
1143
1143
}
1144
1144
1145
1145
static int32_t get_idx () {
1146
- return g_ggmltensor_idx;
1146
+ return g_ggmltensor_idx. load () ;
1147
1147
}
1148
1148
1149
1149
// file:///opt/qcom/aistack/qairt/2.31.0.250130/docs/QNN/general/quantization.html
@@ -1474,7 +1474,7 @@ static Qnn_Tensor_t * ggml_qnn_create_general_tensor(const ggml_tensor * tensor,
1474
1474
Qnn_ErrorHandle_t error = QNN_SUCCESS;
1475
1475
char tensor_name[GGML_MAX_NAME] = {0 };
1476
1476
1477
- // TODO:remove get_idx() and inc_idx() in the future but ensure the tensor name is unique
1477
+ // ensure the tensor name is unique
1478
1478
if (nullptr != name) {
1479
1479
snprintf (tensor_name, GGML_MAX_NAME, " tensor_%-8d" , get_idx ());
1480
1480
} else {
@@ -2762,7 +2762,6 @@ int qnn_instance::qnn_finalize() {
2762
2762
Qnn_ErrorHandle_t error = QNN_SUCCESS;
2763
2763
2764
2764
GGMLQNN_LOG_DEBUG (" enter %s\n " , __func__);
2765
- // TODO:should be removed in the future
2766
2765
reset_idx ();
2767
2766
2768
2767
free_rpcmem ();
@@ -3451,7 +3450,7 @@ static void ggml_qnn_mul_mat(ggml_backend_t backend, ggml_tensor * op) {
3451
3450
}
3452
3451
};
3453
3452
3454
- Qnn_Tensor_t out_0_inputs[] = {*p_tensor0,*p_tensor1};
3453
+ Qnn_Tensor_t out_0_inputs[] = {*p_tensor0, *p_tensor1};
3455
3454
Qnn_Tensor_t out_0_outputs[] = {*p_tensor2_transpose};
3456
3455
Qnn_OpConfig_t out_0 = {
3457
3456
QNN_OPCONFIG_VERSION_1, .v1 =
@@ -3488,7 +3487,7 @@ static void ggml_qnn_mul_mat(ggml_backend_t backend, ggml_tensor * op) {
3488
3487
3489
3488
// step-6: finalize qnn graph and execute qnn graph
3490
3489
CHECK_QNN_API (error, qnn_raw_interface.graphFinalize (graph_handle, NULL , NULL ));
3491
- Qnn_Tensor_t input_tensors_0[] = {*p_tensor0,*p_tensor1};
3490
+ Qnn_Tensor_t input_tensors_0[] = {*p_tensor0, *p_tensor1};
3492
3491
Qnn_Tensor_t output_tensors_0[] = {*p_tensor2};
3493
3492
CHECK_QNN_API (error, qnn_raw_interface.graphExecute (graph_handle,
3494
3493
input_tensors_0, 2 ,
0 commit comments