Skip to content

Commit

Permalink
[xnnpack] support test/benchmark build
Browse files Browse the repository at this point in the history
  • Loading branch information
luncliff committed Nov 9, 2024
1 parent 965d0e6 commit bc23d4a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
33 changes: 12 additions & 21 deletions ports/xnnpack/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,43 @@ vcpkg_from_github(
if(VCPKG_TARGET_IS_WINDOWS)
# see https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics?view=msvc-170
# see https://github.com/google/XNNPACK/blob/master/scripts/build-windows-arm64.cmd
# see ${SOURCE_PATH}/scripts/build-windows-arm64.cmd
if(VCPKG_TARGET_ARCHITECTURE MATCHES "arm")
list(APPEND PLATFORM_OPTIONS
-DXNNPACK_ENABLE_ARM_FP16_SCALAR=OFF
-DXNNPACK_ENABLE_ARM_BF16=OFF # `bfloat16_t` type is missing
-DXNNPACK_ENABLE_ARM_FP16_VECTOR=ON # `__fp16` type is missing
# -DXNNPACK_ENABLE_ARM_FP16_VECTOR=ON # `__fp16` type is missing
)
endif()
elseif(VCPKG_TARGET_IS_ANDROID)
# see https://github.com/google/XNNPACK/blob/master/scripts/build-android-armv7.sh
# see ${SOURCE_PATH}/scripts/build-android-armv7.sh
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
list(APPEND PLATFORM_OPTIONS -DXNNPACK_ENABLE_ARM_BF16=OFF)
endif()
elseif(VCPKG_TARGET_IS_IOS)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm")
set(IOS_ARCH "armv7")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(IOS_ARCH "arm64")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
set(IOS_ARCH "x86_64")
else()
message(FATAL_ERROR "Unexpected VCPKG_TARGET_ARCHITECTURE")
endif()
list(APPEND PLATFORM_OPTIONS -DIOS_ARCH=${IOS_ARCH})
endif()

set(USE_ASSEMBLY true)
if(VCPKG_TARGET_IS_WINDOWS AND (VCPKG_TARGET_ARCHITECTURE MATCHES "arm"))
set(USE_ASSEMBLY false)
endif()

vcpkg_find_acquire_program(PYTHON3)
message(STATUS "Using python3: ${PYTHON3}")

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
test XNNPACK_BUILD_TESTS
test XNNPACK_BUILD_BENCHMARKS
)

vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
WINDOWS_USE_MSBUILD
OPTIONS
${FEATURE_OPTIONS}
${PLATFORM_OPTIONS}
-DXNNPACK_USE_SYSTEM_LIBS=ON
"-DCPUINFO_SOURCE_DIR:PATH=${CURRENT_INSTALLED_DIR}"
"-DPTHREADPOOL_SOURCE_DIR:PATH=${CURRENT_INSTALLED_DIR}"
"-DFXDIV_SOURCE_DIR:PATH=${CURRENT_INSTALLED_DIR}"
-DXNNPACK_ENABLE_ASSEMBLY=${USE_ASSEMBLY}
-DXNNPACK_ENABLE_ASSEMBLY=ON
-DXNNPACK_ENABLE_MEMOPT=ON
-DXNNPACK_ENABLE_SPARSE=ON
-DXNNPACK_BUILD_TESTS=OFF
-DXNNPACK_BUILD_BENCHMARKS=OFF
"-DPython_EXECUTABLE:FILEPATH=${PYTHON3}"
)
vcpkg_cmake_install()
Expand Down
11 changes: 10 additions & 1 deletion ports/xnnpack/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,14 @@
"name": "vcpkg-cmake",
"host": true
}
]
],
"features": {
"test": {
"description": "Build and run tests",
"dependencies": [
"benchmark",
"gtest"
]
}
}
}

0 comments on commit bc23d4a

Please sign in to comment.