@@ -90,24 +90,40 @@ if(TORCHAO_BUILD_CPU_AARCH64)
9090 add_subdirectory (kernels/cpu/aarch64)
9191endif ()
9292
93-
94-
9593if (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)
109108endif ()
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
112128if (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- )
184202endif ()
0 commit comments