@@ -91,11 +91,6 @@ option(onnxruntime_USE_SVE "Build with SVE support in MLAS" OFF)
9191option (onnxruntime_USE_ARM_NEON_NCHWC "Build with ARM Neon NCHWc kernels in MLAS" OFF )
9292
9393option (onnxruntime_USE_KLEIDIAI "Build with KleidiAI integration in MLAS" OFF )
94- # iOS simulator build explicitly builds targets with USE_KLEIDIAI=ON so attempting to force override if so
95- if (APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" )
96- message (WARNING "Disabling KleidiAI: not supported on Apple x86_64 platforms" )
97- set (onnxruntime_USE_KLEIDIAI OFF CACHE BOOL "" FORCE)
98- endif ()
9994option (onnxruntime_BUILD_UNIT_TESTS "Build ONNXRuntime unit tests" ON )
10095option (onnxruntime_BUILD_CSHARP "Build C# library" OFF )
10196option (onnxruntime_BUILD_OBJC "Build Objective-C library" OFF )
@@ -259,6 +254,8 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_
259254 message (FATAL_ERROR "GCC version must be greater than or equal to 11.1" )
260255endif ()
261256
257+ include (detect_onnxruntime_target_platform.cmake)
258+
262259# ENABLE_TRAINING includes all training functionality
263260# The following 2 entry points
264261# 1. ORTModule
@@ -435,14 +432,6 @@ set(ORTTRAINING_SOURCE_DIR ${ORTTRAINING_ROOT}/orttraining)
435432
436433include (adjust_global_compile_flags.cmake)
437434
438- if (APPLE )
439- if (NOT CMAKE_OSX_ARCHITECTURES)
440- message ("Building ONNX Runtime for ${CMAKE_HOST_SYSTEM_PROCESSOR} CPU ARCH" )
441- endif ()
442- elseif (NOT WIN32 AND NOT APPLE )
443- message ("Building ONNX Runtime for ${onnxruntime_target_platform} CPU ARCH" )
444- endif ()
445-
446435# We need to link with libatomic on systems that do not have built-in atomics, or
447436# don't have built-in support for 8 byte atomics
448437# Derived from https://github.com/protocolbuffers/protobuf/blob/master/cmake/CMakeLists.txt
@@ -514,6 +503,66 @@ if (onnxruntime_BUILD_SHARED_LIB OR onnxruntime_ENABLE_PYTHON)
514503 endif ()
515504endif ()
516505
506+ if (onnxruntime_USE_ARM_NEON_NCHWC)
507+ message (STATUS "Building MLAS with ARM Neon NCHWc kernels" )
508+ endif ()
509+
510+ if (onnxruntime_USE_SVE)
511+ if (LINUX AND onnxruntime_target_platform STREQUAL "aarch64" )
512+ check_cxx_compiler_flag("-march=armv8.2-a+sve" HAS_ARM64_SVE)
513+ if (HAS_ARM64_SVE)
514+ message (STATUS "Compiler supports SVE!" )
515+ else ()
516+ message (WARNING "onnxruntime_USE_SVE was set but compiler does not support SVE. It will be disabled." )
517+ set (onnxruntime_USE_SVE OFF )
518+ endif ()
519+ else ()
520+ message (WARNING "onnxruntime_USE_SVE was set but it is not supported on this platform. It will be disabled." )
521+ set (onnxruntime_USE_SVE OFF )
522+ endif ()
523+ endif ()
524+
525+ if (onnxruntime_USE_KLEIDIAI)
526+ function (is_kleidiai_supported is_supported_var)
527+ # check for supported target platforms
528+ if (NOT (onnxruntime_target_platform STREQUAL "aarch64" OR
529+ onnxruntime_target_platform STREQUAL "ARM64" OR
530+ onnxruntime_target_platform STREQUAL "arm64" ))
531+ message (WARNING "KleidiAI is not supported on this platform." )
532+
533+ set (${is_supported_var} FALSE PARENT_SCOPE)
534+ return ()
535+ endif ()
536+
537+ # check for compiler support
538+ if (MSVC )
539+ # TODO detect on MSVC
540+ else ()
541+ check_cxx_compiler_flag(-march=armv8.2-a+dotprod HAS_ARM64_DOTPROD)
542+ check_cxx_compiler_flag(-march=armv8.2-a+i8mm HAS_ARM64_I8MM)
543+ if (NOT HAS_ARM64_DOTPROD)
544+ message (WARNING "The compiler doesn't support dotprod instructions." )
545+ endif ()
546+ if (NOT HAS_ARM64_I8MM)
547+ message (WARNING "The compiler doesn't support i8mm instructions." )
548+ endif ()
549+ if (NOT HAS_ARM64_DOTPROD OR NOT HAS_ARM64_I8MM)
550+ set (${is_supported_var} FALSE PARENT_SCOPE)
551+ return ()
552+ endif ()
553+ endif ()
554+
555+ set (${is_supported_var} TRUE PARENT_SCOPE)
556+ endfunction ()
557+
558+ is_kleidiai_supported(is_kleidiai_supported_result)
559+
560+ if (NOT is_kleidiai_supported_result)
561+ message (WARNING "onnxruntime_USE_KLEIDIAI was set but it is not supported. It will be disabled." )
562+ set (onnxruntime_USE_KLEIDIAI OFF )
563+ endif ()
564+ endif ()
565+
517566#Dependencies begin
518567get_filename_component (ONNXRUNTIME_ROOT "${ONNXRUNTIME_ROOT} " ABSOLUTE )
519568get_filename_component (ORTTRAINING_ROOT "${ORTTRAINING_ROOT} " ABSOLUTE )
@@ -664,47 +713,6 @@ else()
664713 endif ()
665714endif ()
666715
667- if (onnxruntime_USE_ARM_NEON_NCHWC)
668- message (STATUS "Building MLAS with ARM Neon NCHWc kernels" )
669- endif ()
670-
671- if (onnxruntime_USE_SVE)
672- if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" AND CMAKE_SYSTEM_NAME STREQUAL "Linux" )
673- check_cxx_compiler_flag("-march=armv8.2-a+sve" HAS_ARM64_SVE)
674- if (HAS_ARM64_SVE)
675- message (STATUS "Compiler supports SVE!" )
676- else ()
677- message (WARNING "onnxruntime_USE_SVE was set but compiler does not support SVE. It will be disabled." )
678- set (onnxruntime_USE_SVE OFF )
679- endif ()
680- else ()
681- message (WARNING "onnxruntime_USE_SVE was set but it is not supported on this platform. It will be disabled." )
682- set (onnxruntime_USE_SVE OFF )
683- endif ()
684- endif ()
685-
686- if (onnxruntime_USE_KLEIDIAI AND (
687- (onnxruntime_target_platform STREQUAL "aarch64" ) OR
688- (onnxruntime_target_platform STREQUAL "ARM64" ) OR
689- (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" )))
690-
691- # TODO Add checks for MSVC Compilation
692- if (NOT MSVC )
693- check_cxx_compiler_flag(-march=armv8.2-a+dotprod HAS_ARM64_DOTPROD)
694- check_cxx_compiler_flag(-march=armv8.2-a+i8mm HAS_ARM64_I8MM)
695- if (NOT HAS_ARM64_DOTPROD)
696- message (FATAL_ERROR "The compiler doesn't support dotprod" )
697- endif ()
698- if (NOT HAS_ARM64_I8MM)
699- message (FATAL_ERROR "The compiler doesn't support i8mm" )
700- endif ()
701- else ()
702- message (STATUS "Skipping -march= checks on MSVC (not supported), assuming dotprod/i8mm support manually." )
703- set (HAS_ARM64_DOTPROD TRUE )
704- set (HAS_ARM64_I8MM TRUE )
705- endif ()
706- endif ()
707-
708716#names in this var must match the directory names under onnxruntime/core/providers
709717#ONNXRUNTIME_PROVIDER_NAMES is the list of providers that needs to export additional symbols in the global namespace.
710718#For example CUDA EP exports "OrtSessionOptionsAppendExecutionProvider_CUDA", which is a global function.
0 commit comments