[ARM:Bugfix] Enable MNNRankOneUpdate fallback on Apple Silicon - #4579
[ARM:Bugfix] Enable MNNRankOneUpdate fallback on Apple Silicon#4579lanling-47 wants to merge 1 commit into
Conversation
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>
|
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. |
Description
The
MNNRankOneUpdateDefaultC++ fallback was guarded by#ifndef __aarch64__, which excludes Apple Silicon (which also defines__aarch64__). However, the NEON assembly path forMNNRankOneUpdateis 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
Type
Checklist
[Module:Type] Description