Skip to content

use combine_x for sse/avx vector combination#6113

Merged
nihui merged 2 commits into
Tencent:masterfrom
nihui:x86-combine
Jun 8, 2025
Merged

use combine_x for sse/avx vector combination#6113
nihui merged 2 commits into
Tencent:masterfrom
nihui:x86-combine

Conversation

@nihui

@nihui nihui commented Jun 8, 2025

Copy link
Copy Markdown
Member

No description provided.

@github-actions github-actions Bot added the x86 label Jun 8, 2025
@codecov-commenter

codecov-commenter commented Jun 8, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 94.75655% with 14 lines in your changes missing coverage. Please review.

Project coverage is 95.59%. Comparing base (23b64c9) to head (0e54b5c).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/layer/x86/convolution_3x3_winograd.h 86.04% 12 Missing ⚠️
src/layer/x86/innerproduct_fp.h 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6113      +/-   ##
==========================================
- Coverage   95.59%   95.59%   -0.01%     
==========================================
  Files         829      829              
  Lines      270462   270452      -10     
==========================================
- Hits       258556   258546      -10     
  Misses      11906    11906              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Jun 8, 2025

Copy link
Copy Markdown

The binary size change of libncnn.so (bytes)

architecture base size pr size difference
x86_64 16495480 16495480 0 😘
armhf 7384096 7384096 0 😘
aarch64 10777496 10777496 0 😘

@nihui
nihui requested a review from Copilot June 8, 2025 09:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR consolidates manual AVX/SSE insert intrinsics into unified combine* helper functions for cleaner vector concatenation.

  • Introduced #if __AVX2__ fallback in combine4x2_epi32 and added new combine helpers.
  • Replaced direct _mm*_insert* calls with combine4x2_ps, combine4x2_epi32, combine8x2_ps, and combine4x4_ps across x86 layer implementations.
  • Added #include "x86_usability.h" where helper functions are used.

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/layer/x86/x86_usability.h Added AVX2 guard to combine4x2_epi32 with fallback.
src/layer/x86/unaryop_x86.cpp Replaced _mm512_insertf32x8 with combine8x2_ps.
src/layer/x86/shufflechannel_x86.cpp Added include and used combine4x2_ps.
src/layer/x86/scale_x86.cpp Replaced multiple insert intrinsics with combine helpers.
src/layer/x86/rmsnorm_x86.cpp Swapped insert calls for combine4x2_ps/combine8x2_ps.
src/layer/x86/prelu_x86.cpp Used combine helpers in slope loading.
src/layer/x86/lstm_int8.h Replaced integer insert with combine4x2_epi32.
src/layer/x86/layernorm_x86.cpp Replaced insert calls with combine helpers.
src/layer/x86/innerproduct_gemm_fp.h Replaced _mm256_insertf128_ps/_mm512_insertf32x8 with combine.
src/layer/x86/innerproduct_fp.h Swapped out insert intrinsics for combine calls.
src/layer/x86/groupnorm_x86.cpp Used combine helpers for mean/var broadcasts.
src/layer/x86/gemm_x86.cpp Replaced insert intrinsics in transpose-pack with combine.
src/layer/x86/convolution_packed_int8.h Replaced integer insert calls with combine4x2_epi32.
src/layer/x86/convolution_packed.h Used combine* helpers instead of nested insert intrinsics.
src/layer/x86/convolution_3x3_winograd_int8.h Swapped _mm512_inserti32x8 with combine8x2_epi32.
src/layer/x86/convolution_3x3_winograd.h Replaced insert intrinsics in Winograd transforms.
src/layer/x86/convolution1d_packed.h Updated insert intrinsics to combine helpers.
src/layer/x86/binaryop_x86.cpp Replaced broadcast insert calls with combine helpers.
src/layer/x86/batchnorm_x86.cpp Used combine* helpers for parameter loading.
Comments suppressed due to low confidence (1)

src/layer/x86/x86_usability.h:888

  • The fallback branch for combine4x2_epi32 uses _mm256_insertf128_si256, which appears to be the float-version intrinsic. It should use the integer insert intrinsic _mm256_inserti128_si256 to correctly handle __m256i vectors.
return _mm256_insertf128_si256(_mm256_castsi128_si256(a), b, 1);

@nihui
nihui merged commit 87e8b5f into Tencent:master Jun 8, 2025
79 of 81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants