From aeef0c68f498001495a18e251c16a4a3fcad2e88 Mon Sep 17 00:00:00 2001 From: hongruichen Date: Wed, 19 Jun 2024 10:29:53 +0800 Subject: [PATCH] make the constant condition first --- ggml-qnn.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ggml-qnn.cpp b/ggml-qnn.cpp index 47810c933..5b4d665dc 100644 --- a/ggml-qnn.cpp +++ b/ggml-qnn.cpp @@ -2051,8 +2051,8 @@ public: } ~ggml_qnn_tensor_readwrite() { - if (_context && _context->device == QNN_BACKEND_NPU && - (_tensorType == QNN_TENSOR_TYPE_APP_READWRITE || _tensorType == QNN_TENSOR_TYPE_APP_READ)) { + if ((_tensorType == QNN_TENSOR_TYPE_APP_READWRITE || _tensorType == QNN_TENSOR_TYPE_APP_READ) && + _context && _context->device == QNN_BACKEND_NPU) { uint8_t * qnn_buffer = static_cast(_context->instance->get_rpcmem_from_memhandle( QNN_VER_PTR(*_qnn_tensor)->memHandle)); memcpy(_tensor->data, qnn_buffer, ggml_nbytes(_tensor));