-
Notifications
You must be signed in to change notification settings - Fork 4k
Move KleidiAI support detection to CMake logic. #26178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dca7f2a
Move KleidiAI support detection to CMake logic.
edgchen1 a6c22de
move cmake detection earlier, refactor so that onnxruntime_target_pla…
edgchen1 30e1508
some fixes
edgchen1 90444bb
update logging about target platform
edgchen1 a4aeadd
update onnxruntime_USE_SVE platform check to use onnxruntime_target_p…
edgchen1 102d3e2
Merge remote-tracking branch 'origin/main' into edgchen1/kleidiai_sup…
edgchen1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # This file will set the onnxruntime_target_platform variable, if applicable. | ||
| # onnxruntime_target_platform identifies the platform to compile for. | ||
| block(PROPAGATE onnxruntime_target_platform) | ||
|
|
||
| unset(onnxruntime_target_platform) | ||
|
|
||
| if (MSVC) | ||
| if (CMAKE_VS_PLATFORM_NAME) | ||
| # Multi-platform generator | ||
| set(onnxruntime_target_platform ${CMAKE_VS_PLATFORM_NAME}) | ||
| else() | ||
| set(onnxruntime_target_platform ${CMAKE_SYSTEM_PROCESSOR}) | ||
| endif() | ||
|
|
||
| if (onnxruntime_target_platform STREQUAL "ARM64" OR | ||
| onnxruntime_target_platform STREQUAL "ARM64EC") | ||
| # Do nothing. We'll just use the current value of onnxruntime_target_platform. | ||
| elseif (onnxruntime_target_platform STREQUAL "ARM" OR | ||
| CMAKE_GENERATOR MATCHES "ARM") | ||
| set(onnxruntime_target_platform "ARM") | ||
| elseif (onnxruntime_target_platform STREQUAL "x64" OR | ||
| onnxruntime_target_platform STREQUAL "x86_64" OR | ||
| onnxruntime_target_platform STREQUAL "AMD64" OR | ||
| CMAKE_GENERATOR MATCHES "Win64") | ||
| set(onnxruntime_target_platform "x64") | ||
| elseif (onnxruntime_target_platform STREQUAL "Win32" OR | ||
| onnxruntime_target_platform STREQUAL "x86" OR | ||
| onnxruntime_target_platform STREQUAL "i386" OR | ||
| onnxruntime_target_platform STREQUAL "i686") | ||
| set(onnxruntime_target_platform "x86") | ||
| else() | ||
| message(FATAL_ERROR "Unknown target platform: ${onnxruntime_target_platform}") | ||
| endif() | ||
| elseif(APPLE) | ||
| if(DEFINED CMAKE_OSX_ARCHITECTURES) | ||
| # We'll only set onnxruntime_target_platform when CMAKE_OSX_ARCHITECTURES specifies a single architecture. | ||
| list(LENGTH CMAKE_OSX_ARCHITECTURES CMAKE_OSX_ARCHITECTURES_LEN) | ||
| if(CMAKE_OSX_ARCHITECTURES_LEN EQUAL 1) | ||
| set(onnxruntime_target_platform ${CMAKE_OSX_ARCHITECTURES}) | ||
| endif() | ||
| else() | ||
| set(onnxruntime_target_platform ${CMAKE_SYSTEM_PROCESSOR}) | ||
| endif() | ||
| else() | ||
| #XXX: Sometimes the value of CMAKE_SYSTEM_PROCESSOR is set but it's wrong. For example, if you run an armv7 docker | ||
| #image on an aarch64 machine with an aarch64 Ubuntu host OS, in the docker instance cmake may still report | ||
| # CMAKE_SYSTEM_PROCESSOR as aarch64 by default. Given compiling this code may need more than 2GB memory, we do not | ||
| # support compiling for ARM32 natively(only support cross-compiling), we will ignore this issue for now. | ||
| if(NOT CMAKE_SYSTEM_PROCESSOR) | ||
| message(WARNING "CMAKE_SYSTEM_PROCESSOR is not set. Please set it in your toolchain cmake file.") | ||
| # Try to detect it | ||
| if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") | ||
| execute_process( | ||
| COMMAND "${CMAKE_C_COMPILER}" -dumpmachine | ||
| OUTPUT_VARIABLE GCC_DUMP_MACHINE_OUT | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_VARIABLE _err | ||
| RESULT_VARIABLE _res | ||
| ) | ||
| if(NOT _res EQUAL 0) | ||
| message(SEND_ERROR "Failed to run 'gcc -dumpmachine':\n ${_res}") | ||
| endif() | ||
| string(REPLACE "-" ";" GCC_DUMP_MACHINE_OUT_LIST "${GCC_DUMP_MACHINE_OUT}") | ||
| list(LENGTH GCC_DUMP_MACHINE_OUT_LIST GCC_TRIPLET_LEN) | ||
| if(GCC_TRIPLET_LEN EQUAL 4) | ||
| list(GET GCC_DUMP_MACHINE_OUT_LIST 0 CMAKE_SYSTEM_PROCESSOR) | ||
| message("Setting CMAKE_SYSTEM_PROCESSOR to ${CMAKE_SYSTEM_PROCESSOR}") | ||
| endif() | ||
| endif() | ||
| endif() | ||
| set(onnxruntime_target_platform ${CMAKE_SYSTEM_PROCESSOR}) | ||
| endif() | ||
|
|
||
| if(DEFINED onnxruntime_target_platform) | ||
| message(STATUS "onnxruntime_target_platform = ${onnxruntime_target_platform}") | ||
| else() | ||
| message(WARNING "onnxruntime_target_platform is not set") | ||
| endif() | ||
|
|
||
| endblock() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.