make the constant condition first

This commit is contained in:
hongruichen 2024-06-19 10:29:53 +08:00
parent 65a14d9e9a
commit aeef0c68f4

View file

@ -2051,8 +2051,8 @@ public:
} }
~ggml_qnn_tensor_readwrite() { ~ggml_qnn_tensor_readwrite() {
if (_context && _context->device == QNN_BACKEND_NPU && if ((_tensorType == QNN_TENSOR_TYPE_APP_READWRITE || _tensorType == QNN_TENSOR_TYPE_APP_READ) &&
(_tensorType == QNN_TENSOR_TYPE_APP_READWRITE || _tensorType == QNN_TENSOR_TYPE_APP_READ)) { _context && _context->device == QNN_BACKEND_NPU) {
uint8_t * qnn_buffer = static_cast<uint8_t *>(_context->instance->get_rpcmem_from_memhandle( uint8_t * qnn_buffer = static_cast<uint8_t *>(_context->instance->get_rpcmem_from_memhandle(
QNN_VER_PTR(*_qnn_tensor)->memHandle)); QNN_VER_PTR(*_qnn_tensor)->memHandle));
memcpy(_tensor->data, qnn_buffer, ggml_nbytes(_tensor)); memcpy(_tensor->data, qnn_buffer, ggml_nbytes(_tensor));