Skip to content

[ARM:Bugfix] Enable MNNRankOneUpdate fallback on Apple Silicon - #4579

Open
lanling-47 wants to merge 1 commit into
alibaba:masterfrom
lanling-47:arm/apple-rankone-fallback
Open

[ARM:Bugfix] Enable MNNRankOneUpdate fallback on Apple Silicon#4579
lanling-47 wants to merge 1 commit into
alibaba:masterfrom
lanling-47:arm/apple-rankone-fallback

Conversation

@lanling-47

Copy link
Copy Markdown
Contributor

Description

The MNNRankOneUpdateDefault C++ fallback was guarded by #ifndef __aarch64__, which excludes Apple Silicon (which also defines __aarch64__). However, the NEON assembly path for MNNRankOneUpdate is not wired up for this op on Apple platforms, causing a missing implementation at link/runtime.

Fix by changing the guard to #if !defined(__aarch64__) || defined(__APPLE__), so the fallback is compiled on Apple Silicon as well.

Tested on: Apple M4 (ARM64, Apple Silicon)

Module

  • ARM

Type

  • Bugfix

Checklist

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

The MNNRankOneUpdateDefault C++ fallback was guarded by
#ifndef __aarch64__, which excludes Apple Silicon (which also
defines __aarch64__). However, the NEON assembly path for
MNNRankOneUpdate is not wired up for this op on Apple platforms,
causing a missing implementation at link/runtime.

Fix by also compiling the fallback when __APPLE__ is defined.

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

Copy link
Copy Markdown
Collaborator

Thanks for the fix. The missing-symbol problem is real, but using APPLE as the fallback condition is too broad and would disable the existing ARM64 NEON implementation for every Apple build.

The same guard covers three functions: MNNRankOneUpdateDefault, MNNDualMatVecDefault, and MNNDecayRankOneUpdateDefault. Therefore this change makes all three use the scalar C++ fallback on Apple ARM64, not only the function mentioned in the title, and can regress LinearAttention performance.

I verified on an Apple M4 that the current CMake path enables AArch64 assembly, compiles source/backend/cpu/arm/arm64/MNNRankOneUpdate.S successfully, and exports all three symbols. MNN.podspec also already includes this assembly source. The missing integration appears to be project/ios/MNN.xcodeproj, which does not reference MNNRankOneUpdate.S.

Please fix the affected build integration directly by adding MNNRankOneUpdate.S to the appropriate Apple ARM64 target, and also check whether MNNRankOneUpdateFp16.S is missing. If some Apple integration intentionally cannot compile the assembly, please add an explicit build macro indicating whether these assembly kernels are available and enable the fallback only for that configuration, rather than for all APPLE builds.

Please also update the title/description to reflect all three affected functions, rebase onto current master, and provide the exact failing build command plus validation for CMake, CocoaPods, and the iOS Xcode project.

@wangzhaode wangzhaode added the awaiting contributor Waiting for contributor to address review comments or rebase label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting contributor Waiting for contributor to address review comments or rebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants