[ARM:Perf] Add fast path for SME2 FP16 Pack with small channel count#4578
Open
lanling-47 wants to merge 1 commit into
Open
[ARM:Perf] Add fast path for SME2 FP16 Pack with small channel count#4578lanling-47 wants to merge 1 commit into
lanling-47 wants to merge 1 commit into
Conversation
… 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>
Contributor
Author
|
I have added the email address to my GitHub account and signed the CLA. Please recheck. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add a fast path in
Sme2MNNPackC4ForMatMul_A_FP16for the case where all channels fit in one NC8HW8 slice (lMain == 0 && l <= pack), e.g., the first convolution layer withic=3.The original code processes all remaining rows/columns using per-element
division + modulofor address calculation. For small channel counts, this generates unnecessary integer division instructions.The fast path uses simplified linear addressing with 2-wide
uint32_tcopy for FP16 pairs, completely eliminatingdiv/modoperations. The original slow path is preserved in theelsebranch for larger channel counts.Tested on: Apple M4 (SME2 capable, ARMv9)
Module
Type
Checklist
[Module:Type] Description