Skip to content

Commit 2ae4afa

Browse files
AbrilRBSperseoGI
andauthored
xnnpack: KleidiAI support (#29142)
* KleidiAI support * msvc * Use is_msvc --------- Co-authored-by: PerseoGI <[email protected]>
1 parent 063f1bd commit 2ae4afa

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

recipes/xnnpack/all/conanfile.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from conan.errors import ConanInvalidConfiguration
33
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
44
from conan.tools.files import copy, get, replace_in_file
5-
from conan.tools.microsoft import check_min_vs
5+
from conan.tools.microsoft import check_min_vs, is_msvc
66
from conan.tools.scm import Version
77
import os
88

@@ -44,12 +44,18 @@ def export_sources(self):
4444
def layout(self):
4545
cmake_layout(self, src_folder="src")
4646

47+
@property
48+
def _with_kleidiai(self):
49+
return Version(self.version) >= "cci.20241203" and "arm" in str(self.settings.arch) and not is_msvc(self)
50+
4751
def requirements(self):
4852
self.requires("cpuinfo/[>=cci.20231129]")
4953
self.requires("fp16/cci.20210320")
5054
# https://github.com/google/XNNPACK/blob/ed5f9c0562e016a08b274a4579de5ef500fec134/include/xnnpack.h#L15
5155
self.requires("pthreadpool/cci.20231129", transitive_headers=True)
5256
self.requires("fxdiv/cci.20200417")
57+
if self._with_kleidiai:
58+
self.requires("kleidiai/1.18.0")
5359

5460
def validate(self):
5561
check_min_vs(self, 192)
@@ -85,9 +91,8 @@ def generate(self):
8591
tc.variables["CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"] = True
8692
# To export symbols for shared msvc
8793
tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
88-
# TODO Support?
8994
if Version(self.version) >= "cci.20241203":
90-
tc.cache_variables["XNNPACK_ENABLE_KLEIDIAI"] = False
95+
tc.cache_variables["XNNPACK_ENABLE_KLEIDIAI"] = self._with_kleidiai
9196
tc.generate()
9297

9398
deps = CMakeDeps(self)
@@ -101,6 +106,7 @@ def generate(self):
101106
deps.set_property("pthreadpool", "cmake_target_name", "pthreadpool")
102107
deps.set_property("fp16", "cmake_target_name", "fp16")
103108
deps.set_property("fxdiv", "cmake_target_name", "fxdiv")
109+
deps.set_property("kleidiai", "cmake_target_name", "kleidiai")
104110
deps.generate()
105111

106112
def _patch_sources(self):
@@ -126,7 +132,6 @@ def package(self):
126132
cmake.install()
127133

128134
def package_info(self):
129-
# TODO: XNN_LOG_LEVEL definition?
130135
self.cpp_info.components["xnnpack"].libs = ["XNNPACK"]
131136
self.cpp_info.components["xnnpack"].requires = [
132137
"fxdiv::fxdiv",
@@ -141,6 +146,10 @@ def package_info(self):
141146
"fxdiv::fxdiv",
142147
]
143148
self.cpp_info.components["xnnpack"].requires.append("microkernels-prod")
149+
if self._with_kleidiai:
150+
self.cpp_info.components["microkernels-prod"].requires.append("kleidiai::kleidiai")
151+
self.cpp_info.components["xnnpack"].requires.append("kleidiai::kleidiai")
152+
144153
if self.settings.os in ["Linux", "FreeBSD"]:
145154
self.cpp_info.components["microkernels-prod"].system_libs = ["m"]
146155

recipes/xnnpack/all/xnnpack_project_include.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ find_package(cpuinfo REQUIRED CONFIG)
1313
find_package(pthreadpool REQUIRED CONFIG)
1414
find_package(fp16 REQUIRED CONFIG)
1515
find_package(fxdiv REQUIRED CONFIG)
16+
if (XNNPACK_ENABLE_KLEIDIAI)
17+
find_package(KleidiAI REQUIRED CONFIG)
18+
endif()

0 commit comments

Comments
 (0)