Skip to content

refactor mips loongArch packing coding style#6745

Merged
nihui merged 4 commits into
Tencent:masterfrom
nihui:mips-cc
May 26, 2026
Merged

refactor mips loongArch packing coding style#6745
nihui merged 4 commits into
Tencent:masterfrom
nihui:mips-cc

Conversation

@nihui
Copy link
Copy Markdown
Member

@nihui nihui commented May 26, 2026

No description provided.

@tencent-adm
Copy link
Copy Markdown
Member

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5ae9a6ef03

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/layer/loongarch/packing_loongarch.cpp
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 26, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.12%. Comparing base (d928f2a) to head (c61e7db).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/net.cpp 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6745      +/-   ##
==========================================
- Coverage   95.43%   95.12%   -0.31%     
==========================================
  Files         944      944              
  Lines      410856   409767    -1089     
==========================================
- Hits       392094   389805    -2289     
- Misses      18762    19962    +1200     

☔ 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.

@nihui
Copy link
Copy Markdown
Member Author

nihui commented May 26, 2026

@codex review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the MIPS and LoongArch packing layer code to simplify nested #if preprocessor guards into a flatter style, and aligns the bf16 elempack-selection branches in testutil.cpp, perfutil.cpp, and net.cpp to a uniform per-platform #elif structure. Adds a new test_slice_4 covering slice configurations whose sliced sizes mix % 8 == 0 and non-multiple-of-8 parts (exercising the elempack-selection logic touched in this PR).

Changes:

  • In packing_loongarch.cpp, unconditionally declare pack1to8/pack8to1/pack4to8/pack8to4 and move __loongarch_sx/__loongarch_asx guards down to wrap only the SIMD inner loops; remove a few small LSX/LASX intrinsic fast paths in favor of scalar code.
  • In packing_mips.cpp, replace #if __mips_msa guarded MSA fast-paths for two bf16 pack8to4 inner loops with scalar implementations.
  • In net.cpp, tests/testutil.cpp, and tests/perf/perfutil.cpp, split the combined NCNN_LASX || NCNN_LSX 16-bit elempack-resolution block into separate #elif NCNN_LASX / #elif NCNN_LSX branches and normalize the bf16-storage condition ordering.
  • Add test_slice_4 to tests/test_slice.cpp.

Reviewed changes

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

Show a summary per file
File Description
src/layer/loongarch/packing_loongarch.cpp Flatten nested #if __loongarch_sx/_asx guards; drop a few LSX/LASX intrinsic paths for pack4to8/pack8to4 in favor of scalar loops.
src/layer/mips/packing_mips.cpp Remove MSA SIMD fast path in two bf16 pack8to4 inner loops, leaving the scalar implementation.
src/net.cpp Split combined `NCNN_LASX
tests/testutil.cpp Same refactor of the 16-bit elempack-selection branches as in net.cpp.
tests/perf/perfutil.cpp Same refactor of the 16-bit elempack-selection branches as in net.cpp.
tests/test_slice.cpp Adds test_slice_4 exercising slice indices that mix %8==0 and non-multiple-of-8 chunk sizes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c61e7dbb5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/layer/loongarch/packing_loongarch.cpp
Comment thread src/layer/mips/packing_mips.cpp
@nihui nihui merged commit b768248 into Tencent:master May 26, 2026
107 of 110 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants