Skip to content

Commit e75c029

Browse files
committed
ggml: add hw_accel in data structure
1 parent 8f253ef commit e75c029

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

ggml.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,6 +2195,7 @@ struct ggml_context {
21952195
bool mem_buffer_owned;
21962196
bool no_alloc;
21972197
bool no_alloc_save; // this is used to save the no_alloc state when using scratch buffers
2198+
bool use_hwaccel;
21982199

21992200
int n_objects;
22002201

@@ -2754,6 +2755,7 @@ struct ggml_context * ggml_init(struct ggml_init_params params) {
27542755
/*.mem_buffer_owned =*/ params.mem_buffer ? false : true,
27552756
/*.no_alloc =*/ params.no_alloc,
27562757
/*.no_alloc_save =*/ params.no_alloc,
2758+
/*.use_hwaccel =*/ params.use_hwaccel,
27572759
/*.n_objects =*/ 0,
27582760
/*.objects_begin =*/ NULL,
27592761
/*.objects_end =*/ NULL,

ggml.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ extern "C" {
657657
size_t mem_size; // bytes
658658
void * mem_buffer; // if NULL, memory will be allocated internally
659659
bool no_alloc; // don't allocate memory for the tensor data
660+
bool use_hwaccel;
660661
};
661662

662663

whisper.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4066,6 +4066,14 @@ static int whisper_has_openvino(void) {
40664066
#endif
40674067
}
40684068

4069+
static int whisper_has_qnn(void) {
4070+
#ifdef GGML_USE_QNN
4071+
return 1;
4072+
#else
4073+
return 0;
4074+
#endif
4075+
}
4076+
40694077
const char * whisper_print_system_info(void) {
40704078
static std::string s;
40714079

@@ -4086,7 +4094,9 @@ const char * whisper_print_system_info(void) {
40864094
s += "VSX = " + std::to_string(ggml_cpu_has_vsx()) + " | ";
40874095
s += "CUDA = " + std::to_string(ggml_cpu_has_cuda()) + " | ";
40884096
s += "COREML = " + std::to_string(whisper_has_coreml()) + " | ";
4089-
s += "OPENVINO = " + std::to_string(whisper_has_openvino()) ;
4097+
s += "OPENVINO = " + std::to_string(whisper_has_openvino()) + " | ";
4098+
s += "QNN = " + std::to_string(whisper_has_qnn()) ;
4099+
40904100

40914101
return s.c_str();
40924102
}
@@ -6518,6 +6528,9 @@ WHISPER_API const char * whisper_bench_ggml_mul_mat_str(int n_threads) {
65186528
/*.no_alloc =*/ false,
65196529
};
65206530

6531+
#ifdef GGML_USE_QNN
6532+
gparams.use_hwaccel = true;
6533+
#endif
65216534
struct ggml_context * ctx0 = ggml_init(gparams);
65226535

65236536
struct ggml_tensor * a = ggml_new_tensor_2d(ctx0, wtype, N, N);

0 commit comments

Comments
 (0)