Skip to content

Commit 1526dfe

Browse files
authored
Update KleidiAI (#2692)
* Update KleidiAI * up * up * up
1 parent 0fd0cae commit 1526dfe

File tree

3 files changed

+53
-31
lines changed

3 files changed

+53
-31
lines changed

torchao/experimental/CMakeLists.txt

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,40 @@ if(TORCHAO_BUILD_CPU_AARCH64)
9090
add_subdirectory(kernels/cpu/aarch64)
9191
endif()
9292

93-
94-
9593
if (NOT TARGET cpuinfo)
9694
# For some reason cpuinfo package has unused functions/variables
9795
# TODO (T215533422): fix upstream
98-
set(CPUINFO_BUILD_UNIT_TESTS OFF CACHE BOOL "Disable unit tests" FORCE)
99-
set(CPUINFO_BUILD_MOCK_TESTS OFF CACHE BOOL "Disable mock tests" FORCE)
100-
set(CPUINFO_BUILD_BENCHMARKS OFF CACHE BOOL "Disable benchmarks" FORCE)
10196
add_compile_options(-Wno-unused-function -Wno-unused-variable)
10297
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
10398
include(FetchContent)
99+
set(CPUINFO_BUILD_UNIT_TESTS OFF CACHE BOOL "" FORCE)
100+
set(CPUINFO_BUILD_MOCK_TESTS OFF CACHE BOOL "" FORCE)
101+
set(CPUINFO_BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE)
104102
FetchContent_Declare(cpuinfo
105103
GIT_REPOSITORY https://github.com/pytorch/cpuinfo.git
106-
GIT_TAG c61fe919607bbc534d7a5a5707bdd7041e72c5ff)
104+
GIT_TAG c61fe919607bbc534d7a5a5707bdd7041e72c5ff
105+
)
107106
FetchContent_MakeAvailable(
108107
cpuinfo)
109108
endif()
110109

110+
if (TORCHAO_BUILD_KLEIDIAI)
111+
if (NOT TARGET kleidiai)
112+
include(FetchContent)
113+
# KleidiAI is an open-source library that provides optimized
114+
# performance-critical routines, also known as micro-kernels, for artificial
115+
# intelligence (AI) workloads tailored for Arm® CPUs.
116+
set(KLEIDIAI_BUILD_TESTS OFF CACHE BOOL "" FORCE)
117+
set(KLEIDIAI_BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE)
118+
FetchContent_Declare(kleidiai
119+
GIT_REPOSITORY https://git.gitlab.arm.com/kleidi/kleidiai.git
120+
GIT_TAG v1.12.0
121+
)
122+
FetchContent_MakeAvailable(kleidiai)
123+
endif()
124+
endif()
125+
126+
111127
# Build ATen ops
112128
if(TORCHAO_BUILD_ATEN_OPS)
113129
find_package(Torch REQUIRED)
@@ -124,6 +140,9 @@ if(TORCHAO_BUILD_ATEN_OPS)
124140
target_link_torchao_parallel_backend(torchao_ops_aten "${TORCHAO_PARALLEL_BACKEND}")
125141
if (TORCHAO_BUILD_CPU_AARCH64)
126142
target_link_libraries(torchao_ops_aten PRIVATE torchao_kernels_aarch64)
143+
if (TORCHAO_BUILD_KLEIDIAI)
144+
target_link_libraries(torchao_ops_aten PRIVATE kleidiai)
145+
endif()
127146
endif()
128147
target_link_libraries(torchao_ops_aten PRIVATE cpuinfo)
129148
target_include_directories(torchao_ops_aten PRIVATE "${TORCH_INCLUDE_DIRS}")
@@ -168,17 +187,16 @@ if(TORCHAO_BUILD_EXECUTORCH_OPS)
168187

169188
list(TRANSFORM _torchao_op_srcs_executorch PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
170189
add_library(torchao_ops_executorch STATIC ${_torchao_op_srcs_executorch})
171-
target_link_torchao_parallel_backend(torchao_ops_executorch executorch)
172-
target_include_directories(torchao_ops_executorch PRIVATE "${EXECUTORCH_INCLUDE_DIRS}")
190+
173191
target_compile_definitions(torchao_ops_executorch PRIVATE USE_EXECUTORCH=1)
192+
193+
# This links to ExecuTorch
194+
target_link_torchao_parallel_backend(torchao_ops_executorch executorch)
174195
if (TORCHAO_BUILD_CPU_AARCH64)
175196
target_link_libraries(torchao_ops_executorch PRIVATE torchao_kernels_aarch64)
197+
if (TORCHAO_BUILD_KLEIDIAI)
198+
target_link_libraries(torchao_ops_executorch PRIVATE kleidiai)
199+
endif()
176200
endif()
177201
target_link_libraries(torchao_ops_executorch PRIVATE cpuinfo)
178-
install(
179-
TARGETS
180-
torchao_ops_executorch
181-
EXPORT _targets
182-
DESTINATION lib
183-
)
184202
endif()

torchao/experimental/kernels/cpu/aarch64/CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,4 @@ if (TORCHAO_BUILD_CPU_AARCH64)
1212
${CMAKE_CURRENT_SOURCE_DIR}/quantization/quantize.cpp
1313
${CMAKE_CURRENT_SOURCE_DIR}/valpacking/interleave.cpp
1414
)
15-
if (TORCHAO_BUILD_KLEIDIAI)
16-
include(FetchContent)
17-
# KleidiAI is an open-source library that provides optimized
18-
# performance-critical routines, also known as micro-kernels, for artificial
19-
# intelligence (AI) workloads tailored for Arm® CPUs.
20-
FetchContent_Declare(kleidiai
21-
GIT_REPOSITORY https://git.gitlab.arm.com/kleidi/kleidiai.git
22-
GIT_TAG v1.5.0)
23-
FetchContent_MakeAvailable(kleidiai)
24-
25-
target_link_libraries(torchao_kernels_aarch64 PUBLIC kleidiai)
26-
endif()
27-
28-
install(
29-
TARGETS torchao_kernels_aarch64
30-
DESTINATION lib
31-
)
3215
endif()

torchao/experimental/ops/tests/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ endif()
2929

3030
if(TORCHAO_BUILD_KLEIDIAI)
3131
add_compile_definitions(TORCHAO_ENABLE_KLEIDI=1)
32+
# TODO: build tests at top-level so we can use same KleidiAI version
33+
if (NOT TARGET kleidiai)
34+
include(FetchContent)
35+
# KleidiAI is an open-source library that provides optimized
36+
# performance-critical routines, also known as micro-kernels, for artificial
37+
# intelligence (AI) workloads tailored for Arm® CPUs.
38+
set(KLEIDIAI_BUILD_TESTS OFF CACHE BOOL "" FORCE)
39+
set(KLEIDIAI_BUILD_BENCHMARKS OFF CACHE BOOL "" FORCE)
40+
FetchContent_Declare(kleidiai
41+
GIT_REPOSITORY https://git.gitlab.arm.com/kleidi/kleidiai.git
42+
GIT_TAG v1.12.0
43+
)
44+
FetchContent_MakeAvailable(kleidiai)
45+
endif()
3246
endif()
3347

3448
if(TORCHAO_BUILD_ARM_I8MM)
@@ -80,6 +94,13 @@ if (TORCHAO_BUILD_CPU_AARCH64)
8094
torchao_kernels_aarch64
8195
)
8296
endif()
97+
if (TORCHAO_BUILD_KLEIDIAI)
98+
target_link_libraries(
99+
test_linear_8bit_act_xbit_weight
100+
PRIVATE
101+
kleidiai
102+
)
103+
endif()
83104
target_link_torchao_parallel_backend(test_linear_8bit_act_xbit_weight "${TORCHAO_PARALLEL_BACKEND}")
84105

85106
add_executable(

0 commit comments

Comments
 (0)