From f20e2817eafc28cc8d389879b7ba1fcf0752547f Mon Sep 17 00:00:00 2001 From: "zhou.weiguo" Date: Fri, 26 Apr 2024 10:12:20 +0800 Subject: [PATCH] modify codes according to review comments --- ggml-qnn.cpp | 6 ++++++ llama.cpp | 4 ++-- tests/test-backend-ops.cpp | 4 ---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ggml-qnn.cpp b/ggml-qnn.cpp index 83e3a237c76588..812535876ac47b 100644 --- a/ggml-qnn.cpp +++ b/ggml-qnn.cpp @@ -4666,6 +4666,12 @@ static ggml_guid_t ggml_backend_qnn_guid() { static ggml_backend_t ggml_backend_qnn_reg_init(const char * params, void * user_data) { + if (nullptr == params) { + //this is data path of prebuit QNN libs provided by Qualcomm + //can be obtained through JNI from Java layer such as "/data/data/com.ggml.llamacpp/" + //or hardcoded to "/data/local/tmp/" which is an Android OS defined path + params = "/data/local/tmp/"; + } ggml_backend_t qnn_backend = ggml_backend_qnn_init((int) (intptr_t) user_data, params); return qnn_backend; diff --git a/llama.cpp b/llama.cpp index 872108b453ac5d..21d258dbd0440e 100644 --- a/llama.cpp +++ b/llama.cpp @@ -15403,8 +15403,8 @@ struct llama_context * llama_new_context_with_model( #elif defined(GGML_USE_QNN) if (model->n_gpu_layers > 0) { //the second param is data path of prebuit QNN libs provided by Qualcomm - //in Andorid APP mode, can be obtained through JNI from Java layer - //in Andorid terminal mode, can be hardcoded to "/data/local/tmp" + //can be obtained through JNI from Java layer such as "/data/data/com.ggml.llamacpp/" + //or hardcoded to "/data/local/tmp/" ggml_backend_t backend = ggml_backend_qnn_init(model->main_gpu, "/data/local/tmp/"); if (nullptr == backend) { LLAMA_LOG_ERROR("%s: failed to initialize QNN backend\n", __func__); diff --git a/tests/test-backend-ops.cpp b/tests/test-backend-ops.cpp index 9f4afa35954670..02daad24b030ab 100644 --- a/tests/test-backend-ops.cpp +++ b/tests/test-backend-ops.cpp @@ -2225,11 +2225,7 @@ int main(int argc, char ** argv) { continue; } -#ifdef GGML_USE_QNN - ggml_backend_t backend = ggml_backend_reg_init_backend(i, "/data/local/tmp/"); -#else ggml_backend_t backend = ggml_backend_reg_init_backend(i, NULL); -#endif GGML_ASSERT(backend != NULL); if (backend_filter == NULL && ggml_backend_is_cpu(backend)) {