mirror of
https://github.com/ggml-org/whisper.cpp.git
synced 2026-10-21 09:41:29 +02:00
hexagon: add back missing contiguous fast-path and hvx_copy_uu for each run (llama/28886)
This commit is contained in:
committed by
Georgi Gerganov
parent
9e6e308ee8
commit
7dd0ce904c
@@ -126,6 +126,13 @@ static void cpy_thread_##NAME##_reshape(unsigned int nth, unsigned int ith, void
|
|||||||
const uint32_t th_end = MIN(th_start + th_nelem, ct->elem_start + ct->nelem); \
|
const uint32_t th_end = MIN(th_start + th_nelem, ct->elem_start + ct->nelem); \
|
||||||
if (th_start >= th_end) return; \
|
if (th_start >= th_end) return; \
|
||||||
\
|
\
|
||||||
|
if (htp_tensor_is_contiguous(src0, ELEM_SIZE) && htp_tensor_is_contiguous(dst, ELEM_SIZE)) { \
|
||||||
|
hvx_copy_uu((uint8_t *) dst->data + (size_t) th_start * ELEM_SIZE, \
|
||||||
|
(const uint8_t *) src0->data + (size_t) th_start * ELEM_SIZE, \
|
||||||
|
th_end - th_start, ELEM_SIZE); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
const uint32_t ne01_ne00 = ne01 * ne00; \
|
const uint32_t ne01_ne00 = ne01 * ne00; \
|
||||||
const uint32_t ne02_ne01_ne00 = ne02 * ne01_ne00; \
|
const uint32_t ne02_ne01_ne00 = ne02 * ne01_ne00; \
|
||||||
const uint32_t ne1_ne0 = ne1 * ne0; \
|
const uint32_t ne1_ne0 = ne1 * ne0; \
|
||||||
@@ -149,11 +156,21 @@ static void cpy_thread_##NAME##_reshape(unsigned int nth, unsigned int ith, void
|
|||||||
char * dst_ptr = (char *) dst->data + i10*nb0 + i11*nb1 + i12*nb2 + i13*nb3; \
|
char * dst_ptr = (char *) dst->data + i10*nb0 + i11*nb1 + i12*nb2 + i13*nb3; \
|
||||||
const char * src0_ptr = (const char *) src0->data + i00*nb00 + i01*nb01 + i02*nb02 + i03*nb03; \
|
const char * src0_ptr = (const char *) src0->data + i00*nb00 + i01*nb01 + i02*nb02 + i03*nb03; \
|
||||||
\
|
\
|
||||||
for (; e < th_end; e++) { \
|
const bool rows_contig = (nb00 == ELEM_SIZE) && (nb0 == ELEM_SIZE); \
|
||||||
*((ELEM_TYPE *) dst_ptr) = *((const ELEM_TYPE *) src0_ptr); \
|
|
||||||
\
|
\
|
||||||
dst_ptr += nb0; \
|
while (e < th_end) { \
|
||||||
if (++i10 == ne0) { \
|
uint32_t run = 1; \
|
||||||
|
if (rows_contig) { \
|
||||||
|
run = MIN(MIN(ne00 - i00, ne0 - i10), th_end - e); \
|
||||||
|
hvx_copy_uu((uint8_t *) dst_ptr, (const uint8_t *) src0_ptr, run, ELEM_SIZE); \
|
||||||
|
} else { \
|
||||||
|
*((ELEM_TYPE *) dst_ptr) = *((const ELEM_TYPE *) src0_ptr); \
|
||||||
|
} \
|
||||||
|
e += run; \
|
||||||
|
\
|
||||||
|
dst_ptr += run * nb0; \
|
||||||
|
i10 += run; \
|
||||||
|
if (i10 == ne0) { \
|
||||||
i10 = 0; \
|
i10 = 0; \
|
||||||
if (++i11 == ne1) { \
|
if (++i11 == ne1) { \
|
||||||
i11 = 0; \
|
i11 = 0; \
|
||||||
@@ -165,8 +182,9 @@ static void cpy_thread_##NAME##_reshape(unsigned int nth, unsigned int ith, void
|
|||||||
dst_ptr = (char *) dst->data + i11*nb1 + i12*nb2 + i13*nb3; \
|
dst_ptr = (char *) dst->data + i11*nb1 + i12*nb2 + i13*nb3; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
src0_ptr += nb00; \
|
src0_ptr += run * nb00; \
|
||||||
if (++i00 == ne00) { \
|
i00 += run; \
|
||||||
|
if (i00 == ne00) { \
|
||||||
i00 = 0; \
|
i00 = 0; \
|
||||||
if (++i01 == ne01) { \
|
if (++i01 == ne01) { \
|
||||||
i01 = 0; \
|
i01 = 0; \
|
||||||
|
|||||||
Reference in New Issue
Block a user