Skip to content

Commit

Permalink
limit patch to Apple x86_64 target builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
edgchen1 committed Oct 3, 2024
1 parent a8bd0d9 commit bef19a6
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion cmake/external/xnnpack.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,37 @@ endif()
FetchContent_Declare(psimd URL ${DEP_URL_psimd} URL_HASH SHA1=${DEP_SHA1_psimd})
onnxruntime_fetchcontent_makeavailable(psimd)
set(PSIMD_SOURCE_DIR ${psimd_SOURCE_DIR})

block(PROPAGATE fp16_PATCH_COMMAND)
# only apply fp16 patch for Apple x86_64 targets

if(APPLE)
if(NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
if ("x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES)
set(fp16_PATCH_REQUIRED 1)
endif()
else()
# CMAKE_OSX_ARCHITECTURES unspecified, check host
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(fp16_PATCH_REQUIRED 1)
endif()
endif()
endif()

if(fp16_PATCH_REQUIRED)
message(STATUS "Applying fp16 patch.")
set(fp16_PATCH_FILE ${PROJECT_SOURCE_DIR}/patches/fp16/remove_math_h_dependency_from_fp16_h.patch)
set(fp16_PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${fp16_PATCH_FILE})
else()
set(fp16_PATCH_COMMAND "")
endif()
endblock()

FetchContent_Declare(
fp16
URL ${DEP_URL_fp16}
URL_HASH SHA1=${DEP_SHA1_fp16}
PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/fp16/remove_math_h_dependency_from_fp16_h.patch
PATCH_COMMAND ${fp16_PATCH_COMMAND}
)
onnxruntime_fetchcontent_makeavailable(fp16)

Expand Down

0 comments on commit bef19a6

Please sign in to comment.