From: Georgi Gerganov Date: Tue, 4 Nov 2025 18:40:52 +0000 (+0200) Subject: ggml : fix conv2d_dw SVE path (#1380) X-Git-Tag: upstream/0.9.4.185~47 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=7b6abb2b92fcef35cb01c6ce6ada9bd85306522d;p=pkg%2Fggml%2Fsources%2Fggml ggml : fix conv2d_dw SVE path (#1380) * Fix test-conv2d-dw failure on ARM SVE by using runtime vector length The ggml_compute_forward_conv_2d_dw_cwhn function was using a hardcoded GGML_F32_EPR (8) for SIMD vectorization, but on ARM SVE the actual vector length varies by hardware. This caused incorrect computation when processing CWHN layout tensors on ARM machines. Fix by using svcntw() to get the runtime SVE vector length instead of the compile-time constant. Co-authored-by: ggerganov * ci : reduce sam score threshold * ci : update bbox checks for sam test --------- Co-authored-by: copilot-swe-agent[bot] Co-authored-by: ggerganov --- diff --git a/ci/run.sh b/ci/run.sh index a6fb7e66..0285bed8 100644 --- a/ci/run.sh +++ b/ci/run.sh @@ -294,14 +294,16 @@ function gg_run_sam { python3 ../examples/sam/convert-pth-to-ggml.py ${path_models}/sam_vit_b_01ec64.pth ${path_models}/ 1 # Test default parameters - (time ./bin/sam -m ${model_f16} -i ${img_0} ) 2>&1 | tee -a $OUT/${ci}-main.log + (time ./bin/sam -m ${model_f16} -i ${img_0} -st 0.925 ) 2>&1 | tee -a $OUT/${ci}-main.log grep -q "point prompt" $OUT/${ci}-main.log - grep -q "bbox (371, 436), (144, 168)" $OUT/${ci}-main.log + grep -q "bbox (371, 436), (144, 168)" $OUT/${ci}-main.log || + grep -q "bbox (370, 439), (144, 168)" $OUT/${ci}-main.log # Test box prompt and single mask output - (time ./bin/sam -m ${model_f16} -i ${img_0} -b 368,144,441,173 -sm) 2>&1 | tee -a $OUT/${ci}-main.log + (time ./bin/sam -m ${model_f16} -i ${img_0} -st 0.925 -b 368,144,441,173 -sm) 2>&1 | tee -a $OUT/${ci}-main.log grep -q "box prompt" $OUT/${ci}-main.log - grep -q "bbox (370, 439), (144, 169)" $OUT/${ci}-main.log + grep -q "bbox (370, 439), (144, 169)" $OUT/${ci}-main.log || + grep -q "bbox (370, 439), (144, 168)" $OUT/${ci}-main.log set +e } diff --git a/src/ggml-cpu/ops.cpp b/src/ggml-cpu/ops.cpp index f66d36ff..21c2f74f 100644 --- a/src/ggml-cpu/ops.cpp +++ b/src/ggml-cpu/ops.cpp @@ -7084,7 +7084,11 @@ static void ggml_compute_forward_conv_2d_dw_cwhn( const int64_t row_end = MIN(row_start + rows_per_thread, rows_total); #ifdef GGML_SIMD - const int64_t pkg_size = GGML_F32_EPR; + #if defined(__ARM_FEATURE_SVE) + const int64_t pkg_size = svcntw(); + #else + const int64_t pkg_size = GGML_F32_EPR; + #endif const int64_t pkg_count = c / pkg_size; const int64_t c_pkg_end = pkg_count * pkg_size; #else