Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion aphrodite_kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ endif()
#
if (NOT APHRODITE_TARGET_DEVICE STREQUAL "cuda" AND
NOT APHRODITE_TARGET_DEVICE STREQUAL "rocm")
if (APHRODITE_TARGET_DEVICE STREQUAL "cpu")
if (APHRODITE_TARGET_DEVICE STREQUAL "cpu" OR
APHRODITE_TARGET_DEVICE STREQUAL "android")
include(${CMAKE_CURRENT_LIST_DIR}/cmake/cpu_extension.cmake)
else()
return()
Expand Down
26 changes: 26 additions & 0 deletions aphrodite_kernels/cmake/cpu_extension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,32 @@ if(USE_ONEDNN)
${APHRODITE_EXT_SRC})
endif()

# Mobile-optimized kernels (ARM NEON) for Android
if(APHRODITE_TARGET_DEVICE STREQUAL "android")
message(STATUS "Building mobile-optimized kernels for Android")
set(APHRODITE_MOBILE_SRC
"csrc/cpu/mobile/quant.cpp"
"csrc/cpu/mobile/blas.cpp"
"csrc/cpu/mobile/gemm.cpp"
"csrc/cpu/mobile/reduce.cpp"
"csrc/cpu/mobile/scalar.cpp"
"csrc/cpu/mobile/nn.cpp"
"csrc/cpu/mobile/attention.cpp"
"csrc/cpu/mobile/torch_bindings.cpp")
set(APHRODITE_EXT_SRC
${APHRODITE_EXT_SRC}
${APHRODITE_MOBILE_SRC})
# Add ARM NEON compile flags for mobile kernels
# Note: These flags may already be set by ASIMD_FOUND detection above
# but we ensure they're present for Android builds
if(NOT ASIMD_FOUND)
list(APPEND CXX_COMPILE_FLAGS
"-march=armv8-a+neon"
"-mfpu=neon-fp-armv8")
endif()
message(STATUS "Mobile kernel source files: ${APHRODITE_MOBILE_SRC}")
endif()

message(STATUS "CPU extension source files: ${APHRODITE_EXT_SRC}")

#
Expand Down
1 change: 1 addition & 0 deletions aphrodite_kernels/csrc/cpu/mobile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mobile-optimized compute kernels, based on [cactus](https://github.com/cactus-compute/cactus).
1,268 changes: 1,268 additions & 0 deletions aphrodite_kernels/csrc/cpu/mobile/attention.cpp

Large diffs are not rendered by default.

Loading