Skip to content

Commit 1c0f6db

Browse files
authored
hexagon: apply repl optimization in flash attn softmax as ggml-org#22993 (ggml-org#23455)
1 parent cec51c7 commit 1c0f6db

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

ggml/src/ggml-hexagon/htp/hmx-flash-attn-ops.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,9 +852,10 @@ static void fa_softmax_thread(unsigned int n, unsigned int i, void * data) {
852852
v_s_rowmax1 = hvx_vec_reduce_max_f16(v_s_rowmax1);
853853

854854
// Splat m_prev[r], m_prev[r+1] from the per-row accumulator.
855-
// vror brings the target lane to lane 0, then extract + re-splat.
856-
HVX_Vector v_m_prev0 = hvx_vec_splat_f16(hvx_vec_get_f16(Q6_V_vror_VR(m_prev_v, r_vec_off * 2)));
857-
HVX_Vector v_m_prev1 = hvx_vec_splat_f16(hvx_vec_get_f16(Q6_V_vror_VR(m_prev_v, (r_vec_off + 1) * 2)));
855+
// vror brings the target lane to lane 0, then vdelta replicates it
856+
// across all lanes — stays in the vector domain (no store/reload).
857+
HVX_Vector v_m_prev0 = hvx_vec_repl_f16(Q6_V_vror_VR(m_prev_v, r_vec_off * 2));
858+
HVX_Vector v_m_prev1 = hvx_vec_repl_f16(Q6_V_vror_VR(m_prev_v, (r_vec_off + 1) * 2));
858859

859860
// HVX max — both operands are splats, so result is splat of m_new.
860861
HVX_Vector v_dup_m0 = Q6_Vhf_vmax_VhfVhf(v_m_prev0, v_s_rowmax0);

0 commit comments

Comments
 (0)