]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
hexagon: apply repl optimization in flash attn softmax as #22993 (#23455)
authorYiwei Shao <redacted>
Sun, 24 May 2026 02:56:59 +0000 (19:56 -0700)
committerGitHub <redacted>
Sun, 24 May 2026 02:56:59 +0000 (19:56 -0700)
ggml/src/ggml-hexagon/htp/hmx-flash-attn-ops.c

index 4a4ff0b331daf50581544484e7fd74d292da5a16..9e1b778b01fb59b0cac2a508adeb2c34215b8c4f 100644 (file)
@@ -852,9 +852,10 @@ static void fa_softmax_thread(unsigned int n, unsigned int i, void * data) {
             v_s_rowmax1 = hvx_vec_reduce_max_f16(v_s_rowmax1);
 
             // Splat m_prev[r], m_prev[r+1] from the per-row accumulator.
-            // vror brings the target lane to lane 0, then extract + re-splat.
-            HVX_Vector v_m_prev0 = hvx_vec_splat_f16(hvx_vec_get_f16(Q6_V_vror_VR(m_prev_v, r_vec_off * 2)));
-            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)));
+            // vror brings the target lane to lane 0, then vdelta replicates it
+            // across all lanes — stays in the vector domain (no store/reload).
+            HVX_Vector v_m_prev0 = hvx_vec_repl_f16(Q6_V_vror_VR(m_prev_v, r_vec_off * 2));
+            HVX_Vector v_m_prev1 = hvx_vec_repl_f16(Q6_V_vror_VR(m_prev_v, (r_vec_off + 1) * 2));
 
             // HVX max — both operands are splats, so result is splat of m_new.
             HVX_Vector v_dup_m0 = Q6_Vhf_vmax_VhfVhf(v_m_prev0, v_s_rowmax0);