Skip to content

armv8.4 bf16 gemm optimization - #6714

Merged
nihui merged 11 commits into
Tencent:masterfrom
nihui:arm84-bf16
May 12, 2026
Merged

armv8.4 bf16 gemm optimization#6714
nihui merged 11 commits into
Tencent:masterfrom
nihui:arm84-bf16

Conversation

@nihui

@nihui nihui commented May 11, 2026

Copy link
Copy Markdown
Member

No description provided.

@github-actions github-actions Bot added the arm label May 11, 2026
@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.

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

Copy link
Copy Markdown

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: 9147e65201

ℹ️ 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/arm/gemm_bf16s.h Outdated
@nihui nihui changed the title [WIP] armv8.4 bf16 gemm optimization armv8.4 bf16 gemm optimization May 12, 2026
@nihui
nihui requested a review from Copilot May 12, 2026 02:14
@nihui

nihui commented May 12, 2026

Copy link
Copy Markdown
Member Author

@codex review

@codecov-commenter

codecov-commenter commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.90975% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.86%. Comparing base (5a4a483) to head (2e2c4d5).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/layer/arm/gemm_fp16s.h 99.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6714      +/-   ##
==========================================
- Coverage   93.93%   93.86%   -0.08%     
==========================================
  Files         933      932       -1     
  Lines      302704   307523    +4819     
==========================================
+ Hits       284356   288660    +4304     
- Misses      18348    18863     +515     

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

ℹ️ 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".

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 targets improved ARMv8.4 BF16 GEMM performance by adding BF16-aware packing paths and refactoring the BF16 GEMM flow to accumulate into FP32 tiles and apply alpha/beta during the final unpack step (instead of pre-scaling C).

Changes:

  • Added runtime dispatch hooks to call BF16-instruction implementations when the runtime CPU supports BF16 but the baseline build lacks BF16/FP16 vector arithmetic.
  • Added __ARM_FEATURE_BF16_VECTOR_ARITHMETIC-gated fast paths in BF16 pack/transpose-pack routines.
  • Refactored BF16 GEMM tiling to always use a per-thread FP32 workspace tile and moved beta handling into unpack_output_tile_fp32_to_bf16().

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

File Description
src/layer/arm/gemm_bf16s_fp16s.h Adds runtime BF16 dispatch and new BF16-vector-arithmetic packing/transpose-packing fast paths.
src/layer/arm/gemm_arm.cpp Refactors BF16 GEMM tile loop to use FP32 tile + unified unpack applying alpha/beta.
src/layer/arm/gemm_arm_bf16.cpp Adds BF16-target wrapper entry points for runtime-dispatched BF16 code paths.
src/layer/arm/arm_usability.h Uses vcvt_bf16_f32 when BF16 vector arithmetic is available.

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

Comment thread src/layer/arm/gemm_bf16s_fp16s.h Outdated
Comment thread src/layer/arm/gemm_bf16s_fp16s.h Outdated
Comment thread src/layer/arm/gemm_bf16s_fp16s.h Outdated
Comment thread src/layer/arm/gemm_bf16s_fp16s.h Outdated
Comment thread src/layer/arm/gemm_arm.cpp
@nihui nihui closed this May 12, 2026
@nihui nihui reopened this May 12, 2026
@nihui
nihui merged commit ef9eb9d into Tencent:master May 12, 2026
57 of 60 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.

4 participants