@@ -5,6 +5,9 @@ set(MLAS_ROOT ${ONNXRUNTIME_ROOT}/core/mlas)
55set (MLAS_SRC_DIR ${MLAS_ROOT} /lib)
66set (MLAS_INC_DIR ${MLAS_ROOT} /inc)
77
8+ # mlas_private_compile_definitions contains compile definitions that are private to onnxruntime_mlas and targets which
9+ # use internal MLAS headers like mlasi.h.
10+ set (mlas_private_compile_definitions)
811#
912# All hardware agnostic source files here
1013# hardware specific files would cause trouble in
@@ -133,9 +136,9 @@ function(setup_mlas_source_for_windows)
133136 )
134137
135138 if (onnxruntime_USE_ARM_NEON_NCHWC)
136- setup_arm_neon_nchwc()
139+ setup_arm_neon_nchwc()
137140 endif ()
138-
141+
139142 if (onnxruntime_USE_KLEIDIAI)
140143 setup_kleidiai()
141144 endif ()
@@ -293,11 +296,12 @@ endfunction()
293296
294297function (setup_arm_neon_nchwc)
295298 target_sources (onnxruntime_mlas PRIVATE
296- ${MLAS_SRC_DIR} /sconv.h
299+ ${MLAS_SRC_DIR} /sconv.h
297300 ${MLAS_SRC_DIR} /sconv_kernel_neon.cpp
298301 ${MLAS_SRC_DIR} /spool_kernel_neon.cpp
299302 )
300- target_compile_definitions (onnxruntime_mlas PRIVATE MLAS_USE_ARM_NEON_NCHWC)
303+ list (APPEND mlas_private_compile_definitions MLAS_USE_ARM_NEON_NCHWC)
304+ set (mlas_private_compile_definitions ${mlas_private_compile_definitions} PARENT_SCOPE)
301305endfunction ()
302306
303307if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten" )
@@ -445,25 +449,25 @@ else()
445449 ${MLAS_SRC_DIR} /eltwise_kernel_neon.cpp
446450 ${MLAS_SRC_DIR} /sqnbitgemm_kernel_neon_int8_i8mm.cpp
447451 )
448-
452+
449453 # Conditionally add the SVE implementation if compiler supports it
450454 if (onnxruntime_USE_SVE)
451455 list (APPEND mlas_platform_srcs ${MLAS_SRC_DIR} /sve/mlasi_sve.h)
452456 list (APPEND mlas_platform_srcs ${MLAS_SRC_DIR} /sve/elementwise_sve.cpp)
453457 set_source_files_properties (${MLAS_SRC_DIR} /sve/elementwise_sve.cpp PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+sve+fp16 " )
454- target_compile_definitions (onnxruntime_mlas PRIVATE MLAS_USE_SVE)
458+ list ( APPEND mlas_private_compile_definitions MLAS_USE_SVE)
455459 endif ()
456460
457461 if (onnxruntime_USE_ARM_NEON_NCHWC)
458- setup_arm_neon_nchwc()
462+ setup_arm_neon_nchwc()
459463 endif ()
460-
464+
461465 if (onnxruntime_USE_KLEIDIAI)
462466 setup_kleidiai()
463467 endif ()
464468 set_source_files_properties (${MLAS_SRC_DIR} /sqnbitgemm_kernel_neon_int8.cpp
465469 PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+dotprod" )
466- set_source_files_properties (${MLAS_SRC_DIR} /sqnbitgemm_kernel_neon_int8_i8mm.cpp
470+ set_source_files_properties (${MLAS_SRC_DIR} /sqnbitgemm_kernel_neon_int8_i8mm.cpp
467471 PROPERTIES COMPILE_FLAGS " -march=armv8.2-a+i8mm " )
468472
469473 if (NOT APPLE )
@@ -806,6 +810,8 @@ foreach(mlas_target ${ONNXRUNTIME_MLAS_LIBS})
806810 target_include_directories (${mlas_target} PRIVATE ${MLAS_INC_DIR} ${MLAS_SRC_DIR} )
807811 onnxruntime_add_include_to_target(${mlas_target} ${GSL_TARGET} )
808812
813+ target_compile_definitions (${mlas_target} PRIVATE ${mlas_private_compile_definitions} )
814+
809815 set_target_properties (${mlas_target} PROPERTIES FOLDER "ONNXRuntime" )
810816endforeach ()
811817
0 commit comments