Skip to content

Commit 212a170

Browse files
author
zhouwg
committed
ggml-dsp:refine ggmlhexagon_dsp_add_f32
1 parent b86b527 commit 212a170

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

ggml/src/ggml-hexagon/ggml-hexagon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5584,7 +5584,7 @@ static bool ggmlhexagon_can_handle_op_through_qnn(ggml_backend_dev_t dev, const
55845584

55855585
struct ggml_tensor * src0 = op_tensor->src[0];
55865586
struct ggml_tensor * src1 = op_tensor->src[1];
5587-
const int64_t ne00 = src0->ne[0];;
5587+
const int64_t ne00 = src0->ne[0];
55885588
const int src0_rank = ggml_n_dims(src0);
55895589
int src1_rank = 0;
55905590
if (nullptr != src1) {

ggml/src/ggml-hexagon/kernels/add.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@ inline static void ggmlhexagon_dsp_add_f32 (const int n, float * z, const float
44
HVX_Vector * va;
55
HVX_Vector * vb;
66
HVX_Vector * vc;
7+
HVX_Vector qf32;
78
const int FLOATS_PER_VECTOR = 128 / sizeof(float);
89
const int block = n / FLOATS_PER_VECTOR;
910
const int left = n % FLOATS_PER_VECTOR;
1011
const int blocks = block * FLOATS_PER_VECTOR;
1112

12-
if (0 == block) {
13-
for (size_t i = 0; i < n; ++i)
14-
z[i] = x[i] + y[i];
15-
16-
return;
17-
}
18-
1913
if ((((uintptr_t)z | (uintptr_t)x | (uintptr_t)y) % ALIGN_128_BYTE) != 0) {
2014
GGMLHEXAGON_LOG_DEBUG("memaddress mismatch alignment 128 bytes z:%p x:%p y:%p", z, x, y);
2115
for (size_t i = 0; i < n; ++i)
@@ -28,7 +22,10 @@ inline static void ggmlhexagon_dsp_add_f32 (const int n, float * z, const float
2822
vb = (HVX_Vector *)y;
2923
vc = (HVX_Vector *)z;
3024
for (size_t i = 0; i < block; ++i) {
31-
*vc++ = Q6_Vsf_vadd_VsfVsf(*va++, *vb++);
25+
//*vc++ = Q6_Vsf_vadd_VsfVsf(*va++, *vb++);
26+
qf32 = Q6_Vqf32_vadd_VsfVsf(*va++, *vb++);
27+
*vc = Q6_Vsf_equals_Vqf32(qf32);
28+
vc++;
3229
}
3330

3431
if (left > 0) {

0 commit comments

Comments
 (0)