1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

dnn: enable the existing SIMD attention-softmax on scalable RVV

This commit is contained in:
Teddy-Yangjiale
2026-07-26 00:06:23 +08:00
parent 864f9594ad
commit 73c580723c
@@ -102,7 +102,7 @@ void run_fused_softmax(
const int tmax = is_causal ? std::min(past_seq_len + tq + 1, seq_len_kv) : seq_len_kv;
float maxVal = -FLT_MAX;
int tk = 0;
#if CV_SIMD
#if (CV_SIMD || CV_SIMD_SCALABLE)
const int w = VTraits<v_float32>::vlanes();
v_float32 v_max_val = vx_setall_f32(maxVal);
v_float32 v_softcap = vx_setall_f32(softcap);
@@ -173,7 +173,7 @@ void run_fused_softmax(
if (do_softmax) {
float sum = 0.f;
tk = 0;
#if CV_SIMD
#if (CV_SIMD || CV_SIMD_SCALABLE)
v_float32 v_sum = vx_setzero_f32();
v_float32 v_max_val_shift = vx_setall_f32(maxVal);
for (; tk <= seq_len_kv - w; tk += w) {
@@ -192,7 +192,7 @@ void run_fused_softmax(
float inv_sum = 1.f / sum;
tk = 0;
#if CV_SIMD
#if (CV_SIMD || CV_SIMD_SCALABLE)
v_float32 v_inv_sum = vx_setall_f32(inv_sum);
for (; tk <= seq_len_kv - w; tk += w) {
v_float32 v_val = vx_load(&data[offset + tk]);