Skip to content

[ARM:Perf] Add fast path for SME2 FP16 Pack with small channel count#4578

Open
lanling-47 wants to merge 1 commit into
alibaba:masterfrom
lanling-47:arm/sme2-pack-fastpath
Open

[ARM:Perf] Add fast path for SME2 FP16 Pack with small channel count#4578
lanling-47 wants to merge 1 commit into
alibaba:masterfrom
lanling-47:arm/sme2-pack-fastpath

Conversation

@lanling-47

Copy link
Copy Markdown
Contributor

Description

Add a fast path in Sme2MNNPackC4ForMatMul_A_FP16 for the case where all channels fit in one NC8HW8 slice (lMain == 0 && l <= pack), e.g., the first convolution layer with ic=3.

The original code processes all remaining rows/columns using per-element division + modulo for address calculation. For small channel counts, this generates unnecessary integer division instructions.

The fast path uses simplified linear addressing with 2-wide uint32_t copy for FP16 pairs, completely eliminating div/mod operations. The original slow path is preserved in the else branch for larger channel counts.

Tested on: Apple M4 (SME2 capable, ARMv9)

Module

  • ARM

Type

  • Perf

Checklist

  • Commit message format: [Module:Type] Description
  • Compiles without errors
  • Tested on Apple M4 (SME2 capable)
  • No unrelated style changes

… channel count

When all channels fit in a single NC8HW8 slice (lMain == 0 && l <= pack),
such as the first convolution layer with ic=3, the original code uses
per-element division/modulo for address calculation. This adds a fast
path that uses simplified linear addressing with 2-wide uint32_t copy,
eliminating the expensive integer div/mod operations entirely.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Jun 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@lanling-47

Copy link
Copy Markdown
Contributor Author

I have added the email address to my GitHub account and signed the CLA. Please recheck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants