Skip to content

Commit 509c0fb

Browse files
author
zhouwg
committed
ggml-qnn: refine the entire ggml-qnn.cpp to make code more clear
1 parent 34452c8 commit 509c0fb

File tree

6 files changed

+123
-121
lines changed

6 files changed

+123
-121
lines changed

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

Lines changed: 105 additions & 103 deletions
Large diffs are not rendered by default.

ggml/src/ggml-qnn/kernels/ggmlop_ap_skel.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,10 @@ __QAIC_SLIM_EXPORT const Interface __QAIC_SLIM(ggmlop_slim) = {4,&(methodArrays[
288288
#ifdef __cplusplus
289289
extern "C" {
290290
#endif
291-
__QAIC_STUB_EXPORT int __QAIC_STUB(ggmlop_open)(const char* uri, remote_handle64* h) __QAIC_STUB_ATTRIBUTE {
291+
__QAIC_STUB_EXPORT int __QAIC_STUB(ggmlop_dsp_open)(const char* uri, remote_handle64* h) __QAIC_STUB_ATTRIBUTE {
292292
return __QAIC_REMOTE(remote_handle64_open)(uri, h);
293293
}
294-
__QAIC_STUB_EXPORT int __QAIC_STUB(ggmlop_close)(remote_handle64 h) __QAIC_STUB_ATTRIBUTE {
294+
__QAIC_STUB_EXPORT int __QAIC_STUB(ggmlop_dsp_close)(remote_handle64 h) __QAIC_STUB_ATTRIBUTE {
295295
return __QAIC_REMOTE(remote_handle64_close)(h);
296296
}
297297
static __inline int _stub_unpack(_ATTRIBUTE_UNUSED remote_arg* _praROutPost, _ATTRIBUTE_UNUSED remote_arg* _ppraROutPost[1], _ATTRIBUTE_UNUSED void* _primROut, _ATTRIBUTE_UNUSED uint32_t _rout0[1], _ATTRIBUTE_UNUSED uint64_t _rout1[4], _ATTRIBUTE_UNUSED uint64_t _rout2[4], _ATTRIBUTE_UNUSED uint32_t _rout3[1], _ATTRIBUTE_UNUSED uint32_t _rout4[1], _ATTRIBUTE_UNUSED char* _rout5[1], _ATTRIBUTE_UNUSED uint32_t _rout5Len[1]) {
@@ -419,11 +419,11 @@ static __inline int _stub_method(remote_handle64 _handle, uint32_t _mid, uint64_
419419
_allocator_deinit(_al);
420420
return _nErr;
421421
}
422-
__QAIC_STUB_EXPORT int __QAIC_STUB(ggmlop_add)(remote_handle64 _handle, const dsptensor* src0, const dsptensor* src1, dsptensor* dst) __QAIC_STUB_ATTRIBUTE {
422+
__QAIC_STUB_EXPORT int __QAIC_STUB(ggmlop_dsp_add)(remote_handle64 _handle, const dsptensor* src0, const dsptensor* src1, dsptensor* dst) __QAIC_STUB_ATTRIBUTE {
423423
uint32_t _mid = 2;
424424
return _stub_method(_handle, _mid, (uint64_t*)src0, (uint64_t*)src1, (uint64_t*)dst);
425425
}
426-
__QAIC_STUB_EXPORT int __QAIC_STUB(ggmlop_mulmat)(remote_handle64 _handle, const dsptensor* src0, const dsptensor* src1, dsptensor* dst) __QAIC_STUB_ATTRIBUTE {
426+
__QAIC_STUB_EXPORT int __QAIC_STUB(ggmlop_dsp_mulmat)(remote_handle64 _handle, const dsptensor* src0, const dsptensor* src1, dsptensor* dst) __QAIC_STUB_ATTRIBUTE {
427427
uint32_t _mid = 3;
428428
return _stub_method(_handle, _mid, (uint64_t*)src0, (uint64_t*)src1, (uint64_t*)dst);
429429
}

ggml/src/ggml-qnn/kernels/ggmlop_ap_skel.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,17 +268,17 @@ struct dsptensor {
268268
* @param h, resulting handle
269269
* @retval, 0 on success
270270
*/
271-
__QAIC_HEADER_EXPORT int __QAIC_HEADER(ggmlop_open)(const char* uri, remote_handle64* h) __QAIC_HEADER_ATTRIBUTE;
271+
__QAIC_HEADER_EXPORT int __QAIC_HEADER(ggmlop_dsp_open)(const char* uri, remote_handle64* h) __QAIC_HEADER_ATTRIBUTE;
272272
/**
273273
* Closes a handle. If this is the last handle to close, the session
274274
* is closed as well, releasing all the allocated resources.
275275
276276
* @param h, the handle to close
277277
* @retval, 0 on success, should always succeed
278278
*/
279-
__QAIC_HEADER_EXPORT int __QAIC_HEADER(ggmlop_close)(remote_handle64 h) __QAIC_HEADER_ATTRIBUTE;
280-
__QAIC_HEADER_EXPORT int __QAIC_HEADER(ggmlop_add)(remote_handle64 _h, const dsptensor * src0, const dsptensor * src1, dsptensor * dst) __QAIC_HEADER_ATTRIBUTE;
281-
__QAIC_HEADER_EXPORT int __QAIC_HEADER(ggmlop_mulmat)(remote_handle64 _h, const dsptensor * src0, const dsptensor * src1, dsptensor * dst) __QAIC_HEADER_ATTRIBUTE;
279+
__QAIC_HEADER_EXPORT int __QAIC_HEADER(ggmlop_dsp_close)(remote_handle64 h) __QAIC_HEADER_ATTRIBUTE;
280+
__QAIC_HEADER_EXPORT int __QAIC_HEADER(ggmlop_dsp_add)(remote_handle64 _h, const dsptensor * src0, const dsptensor * src1, dsptensor * dst) __QAIC_HEADER_ATTRIBUTE;
281+
__QAIC_HEADER_EXPORT int __QAIC_HEADER(ggmlop_dsp_mulmat)(remote_handle64 _h, const dsptensor * src0, const dsptensor * src1, dsptensor * dst) __QAIC_HEADER_ATTRIBUTE;
282282
#ifndef ggmlop_URI
283283
#define ggmlop_URI "file:///libggmlop_skel.so?ggmlop_skel_handle_invoke&_modver=1.0&_idlver=0.0.1"
284284
#endif /*ggmlop_URI*/

ggml/src/ggml-qnn/kernels/ggmlop_cdsp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#define ggml_tensor dsptensor
1111

12-
int ggmlop_open(const char*uri, remote_handle64* handle) {
12+
int ggmlop_dsp_open(const char*uri, remote_handle64* handle) {
1313
void *tptr = NULL;
1414
FARF(HIGH, "uri %s", uri);
1515
tptr = (void *)malloc(1);
@@ -18,7 +18,7 @@ int ggmlop_open(const char*uri, remote_handle64* handle) {
1818
return 0;
1919
}
2020

21-
int ggmlop_close(remote_handle64 handle) {
21+
int ggmlop_dsp_close(remote_handle64 handle) {
2222
if (handle)
2323
free((void*)handle);
2424
return 0;
@@ -279,9 +279,9 @@ static void ggml_compute_forward_add_f32(
279279
}
280280
}
281281

282-
int ggmlop_add(remote_handle64 h, const ggml_tensor * src0, const ggml_tensor * src1, ggml_tensor * dst)
282+
int ggmlop_dsp_add(remote_handle64 h, const ggml_tensor * src0, const ggml_tensor * src1, ggml_tensor * dst)
283283
{
284-
FARF(HIGH, "=============== DSP: ggmlop_add ");
284+
FARF(HIGH, "=============== DSP: ggmlop_dsp_add ");
285285
switch (src0->type) {
286286
case GGML_TYPE_F32:
287287
{
@@ -349,8 +349,8 @@ int ggmlop_add(remote_handle64 h, const ggml_tensor * src0, const ggml_tensor *
349349
}
350350

351351

352-
int ggmlop_mulmat(remote_handle64 h, const ggml_tensor * src0, const ggml_tensor * src1, ggml_tensor * dst) {
353-
FARF(HIGH, "=============== DSP: ggmlop_mulmat ");
352+
int ggmlop_dsp_mulmat(remote_handle64 h, const ggml_tensor * src0, const ggml_tensor * src1, ggml_tensor * dst) {
353+
FARF(HIGH, "=============== DSP: ggmlop_dsp_mulmat ");
354354

355355
GGML_TENSOR_BINARY_OP_LOCALS
356356

ggml/src/ggml-qnn/kernels/ggmlop_cdsp_skel.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,13 +573,13 @@ static __inline int _skel_method_2(int (*_pfn)(const char*, remote_handle64*), u
573573
__QAIC_SKEL_EXPORT int __QAIC_SKEL(ggmlop_skel_handle_invoke)(remote_handle64 _h, uint32_t _sc, remote_arg* _pra) __QAIC_SKEL_ATTRIBUTE {
574574
switch(REMOTE_SCALARS_METHOD(_sc)){
575575
case 0:
576-
return _skel_method_2(__QAIC_IMPL(ggmlop_open), _sc, _pra);
576+
return _skel_method_2(__QAIC_IMPL(ggmlop_dsp_open), _sc, _pra);
577577
case 1:
578-
return _skel_method_1(__QAIC_IMPL(ggmlop_close), _sc, _pra);
578+
return _skel_method_1(__QAIC_IMPL(ggmlop_dsp_close), _sc, _pra);
579579
case 2:
580-
return _skel_method(__QAIC_IMPL(ggmlop_add), _h, _sc, _pra);
580+
return _skel_method(__QAIC_IMPL(ggmlop_dsp_add), _h, _sc, _pra);
581581
case 3:
582-
return _skel_method(__QAIC_IMPL(ggmlop_mulmat), _h, _sc, _pra);
582+
return _skel_method(__QAIC_IMPL(ggmlop_dsp_mulmat), _h, _sc, _pra);
583583
}
584584
return AEE_EUNSUPPORTED;
585585
}
32 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)