Skip to content

Commit 59a2fbe

Browse files
committed
ggml-qnn: sync from branch kantvai-ggmlqnn-npurpc
1 parent c6a04c6 commit 59a2fbe

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

ggml/src/ggml-qnn/ggml-qnn.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,8 @@ struct ggml_backend_qnn_context {
11321132
struct qcom_socinfo socinfo;
11331133
} ;
11341134

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);
11371137
static void reset_idx() {
11381138
g_ggmltensor_idx = 0;
11391139
}
@@ -1143,7 +1143,7 @@ static void inc_idx() {
11431143
}
11441144

11451145
static int32_t get_idx() {
1146-
return g_ggmltensor_idx;
1146+
return g_ggmltensor_idx.load();
11471147
}
11481148

11491149
// 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,
14741474
Qnn_ErrorHandle_t error = QNN_SUCCESS;
14751475
char tensor_name[GGML_MAX_NAME] = {0};
14761476

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
14781478
if (nullptr != name) {
14791479
snprintf(tensor_name, GGML_MAX_NAME, "tensor_%-8d", get_idx());
14801480
} else {
@@ -2762,7 +2762,6 @@ int qnn_instance::qnn_finalize() {
27622762
Qnn_ErrorHandle_t error = QNN_SUCCESS;
27632763

27642764
GGMLQNN_LOG_DEBUG("enter %s\n", __func__);
2765-
//TODO:should be removed in the future
27662765
reset_idx();
27672766

27682767
free_rpcmem();
@@ -3451,7 +3450,7 @@ static void ggml_qnn_mul_mat(ggml_backend_t backend, ggml_tensor * op) {
34513450
}
34523451
};
34533452

3454-
Qnn_Tensor_t out_0_inputs[] = {*p_tensor0,*p_tensor1};
3453+
Qnn_Tensor_t out_0_inputs[] = {*p_tensor0, *p_tensor1};
34553454
Qnn_Tensor_t out_0_outputs[] = {*p_tensor2_transpose};
34563455
Qnn_OpConfig_t out_0 = {
34573456
QNN_OPCONFIG_VERSION_1, .v1 =
@@ -3488,7 +3487,7 @@ static void ggml_qnn_mul_mat(ggml_backend_t backend, ggml_tensor * op) {
34883487

34893488
//step-6: finalize qnn graph and execute qnn graph
34903489
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};
34923491
Qnn_Tensor_t output_tensors_0[] = {*p_tensor2};
34933492
CHECK_QNN_API(error, qnn_raw_interface.graphExecute(graph_handle,
34943493
input_tensors_0, 2,

0 commit comments

Comments
 (0)