@@ -88,13 +88,9 @@ option(onnxruntime_USE_RKNPU "Build with RKNPU support" OFF)
8888option (onnxruntime_USE_DNNL "Build with DNNL support" OFF )
8989option (onnxruntime_USE_JSEP "Build with JavaScript implemented kernels support" OFF )
9090option (onnxruntime_USE_SVE "Build with SVE support in MLAS" OFF )
91+ option (onnxruntime_USE_ARM_NEON_NCHWC "Build with ARM Neon NCHWc kernels in MLAS" OFF )
9192
9293option (onnxruntime_USE_KLEIDIAI "Build with KleidiAI integration in MLAS" OFF )
93- # iOS simulator build explicitly builds targets with USE_KLEIDIAI=ON so attempting to force override if so
94- if (APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" )
95- message (WARNING "Disabling KleidiAI: not supported on Apple x86_64 platforms" )
96- set (onnxruntime_USE_KLEIDIAI OFF CACHE BOOL "" FORCE)
97- endif ()
9894option (onnxruntime_BUILD_UNIT_TESTS "Build ONNXRuntime unit tests" ON )
9995option (onnxruntime_BUILD_CSHARP "Build C# library" OFF )
10096option (onnxruntime_BUILD_OBJC "Build Objective-C library" OFF )
@@ -258,6 +254,8 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_
258254 message (FATAL_ERROR "GCC version must be greater than or equal to 11.1" )
259255endif ()
260256
257+ include (detect_onnxruntime_target_platform.cmake)
258+
261259# ENABLE_TRAINING includes all training functionality
262260# The following 2 entry points
263261# 1. ORTModule
@@ -434,14 +432,6 @@ set(ORTTRAINING_SOURCE_DIR ${ORTTRAINING_ROOT}/orttraining)
434432
435433include (adjust_global_compile_flags.cmake)
436434
437- if (APPLE )
438- if (NOT CMAKE_OSX_ARCHITECTURES)
439- message ("Building ONNX Runtime for ${CMAKE_HOST_SYSTEM_PROCESSOR} CPU ARCH" )
440- endif ()
441- elseif (NOT WIN32 AND NOT APPLE )
442- message ("Building ONNX Runtime for ${onnxruntime_target_platform} CPU ARCH" )
443- endif ()
444-
445435# We need to link with libatomic on systems that do not have built-in atomics, or
446436# don't have built-in support for 8 byte atomics
447437# Derived from https://github.com/protocolbuffers/protobuf/blob/master/cmake/CMakeLists.txt
@@ -513,6 +503,66 @@ if (onnxruntime_BUILD_SHARED_LIB OR onnxruntime_ENABLE_PYTHON)
513503 endif ()
514504endif ()
515505
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+
516566#Dependencies begin
517567get_filename_component (ONNXRUNTIME_ROOT "${ONNXRUNTIME_ROOT} " ABSOLUTE )
518568get_filename_component (ORTTRAINING_ROOT "${ORTTRAINING_ROOT} " ABSOLUTE )
@@ -663,43 +713,6 @@ else()
663713 endif ()
664714endif ()
665715
666- if (onnxruntime_USE_SVE)
667- if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" AND CMAKE_SYSTEM_NAME STREQUAL "Linux" )
668- check_cxx_compiler_flag("-march=armv8.2-a+sve" HAS_ARM64_SVE)
669- if (HAS_ARM64_SVE)
670- message (STATUS "Compiler supports SVE!" )
671- else ()
672- message (WARNING "onnxruntime_USE_SVE was set but compiler does not support SVE. It will be disabled." )
673- set (onnxruntime_USE_SVE OFF )
674- endif ()
675- else ()
676- message (WARNING "onnxruntime_USE_SVE was set but it is not supported on this platform. It will be disabled." )
677- set (onnxruntime_USE_SVE OFF )
678- endif ()
679- endif ()
680-
681- if (onnxruntime_USE_KLEIDIAI AND (
682- (onnxruntime_target_platform STREQUAL "aarch64" ) OR
683- (onnxruntime_target_platform STREQUAL "ARM64" ) OR
684- (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" )))
685-
686- # TODO Add checks for MSVC Compilation
687- if (NOT MSVC )
688- check_cxx_compiler_flag(-march=armv8.2-a+dotprod HAS_ARM64_DOTPROD)
689- check_cxx_compiler_flag(-march=armv8.2-a+i8mm HAS_ARM64_I8MM)
690- if (NOT HAS_ARM64_DOTPROD)
691- message (FATAL_ERROR "The compiler doesn't support dotprod" )
692- endif ()
693- if (NOT HAS_ARM64_I8MM)
694- message (FATAL_ERROR "The compiler doesn't support i8mm" )
695- endif ()
696- else ()
697- message (STATUS "Skipping -march= checks on MSVC (not supported), assuming dotprod/i8mm support manually." )
698- set (HAS_ARM64_DOTPROD TRUE )
699- set (HAS_ARM64_I8MM TRUE )
700- endif ()
701- endif ()
702-
703716#names in this var must match the directory names under onnxruntime/core/providers
704717#ONNXRUNTIME_PROVIDER_NAMES is the list of providers that needs to export additional symbols in the global namespace.
705718#For example CUDA EP exports "OrtSessionOptionsAppendExecutionProvider_CUDA", which is a global function.
0 commit comments