Skip to content

Commit

Permalink
[cpuinfo,xnnpack] Update to 2024-11 releases (#292)
Browse files Browse the repository at this point in the history
* ci: exclude apple-* ports

* [cpuinfo] update to 2024-10-23

* pytorch/cpuinfo@dff2616

* [xnnpack] update to 2024-11-09

* google/XNNPACK@4ea82e5
* support test/benchmark build

* [xnnpack] disable unused options

* [xnnpack] remove WINDOWS_USE_MSBUILD
  • Loading branch information
luncliff authored Nov 17, 2024
1 parent ba74d7b commit c9603df
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 196 deletions.
4 changes: 2 additions & 2 deletions ports/cpuinfo/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO pytorch/cpuinfo
REF fa1c679da8d19e1d87f20175ae1ec10995cd3dd3
SHA512 02e14115b2f91dc555b6181b7f9b422506e8db8ca0858e936045711cc93e0313bc2416298cf0f9619ced6c497a34fd4a4a4bcadcacfc0fe68a1c1ced2bd00558
REF dff2616ddd49122b63abcf44d2c097483b77f861
SHA512 de681a8cdc0e33cac7b875fabcb05aef8f41cfdeeeb3a1231ae145e6c39c2d5b2b96ad768dc55141b34e0d60291f1e4ef4283bbc2678d04155629a05e9c0f9b0
HEAD_REF main
)

Expand Down
2 changes: 1 addition & 1 deletion ports/cpuinfo/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cpuinfo",
"version-date": "2024-08-31",
"version-date": "2024-10-23",
"description": "CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)",
"homepage": "https://github.com/pytorch/cpuinfo",
"license": "BSD-2-Clause",
Expand Down
135 changes: 22 additions & 113 deletions ports/xnnpack/fix-cmake.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dd4f4fe..9526aa4 100644
index 4c5eb1c..ce3ab36 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -182,7 +182,7 @@ ENDIF()
@@ -328,7 +328,7 @@ ENDIF()
# ---[ Build flags
IF(NOT CMAKE_SYSTEM_NAME)
MESSAGE(FATAL_ERROR "CMAKE_SYSTEM_NAME not defined")
Expand All @@ -11,7 +11,7 @@ index dd4f4fe..9526aa4 100644
MESSAGE(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_NAME value \"${CMAKE_SYSTEM_NAME}\"")
ENDIF()
IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
@@ -952,7 +952,7 @@ TARGET_INCLUDE_DIRECTORIES(normalization PRIVATE include src)
@@ -1034,7 +1034,7 @@ TARGET_INCLUDE_DIRECTORIES(normalization PRIVATE include src)
TARGET_INCLUDE_DIRECTORIES(packing PRIVATE include src)
TARGET_INCLUDE_DIRECTORIES(logging PRIVATE include src)
IF(XNNPACK_BUILD_LIBRARY)
Expand All @@ -20,121 +20,30 @@ index dd4f4fe..9526aa4 100644
TARGET_INCLUDE_DIRECTORIES(XNNPACK PRIVATE src)
TARGET_INCLUDE_DIRECTORIES(allocator PRIVATE include src)
TARGET_INCLUDE_DIRECTORIES(cache PRIVATE include src)
@@ -964,6 +964,10 @@ IF(XNNPACK_BUILD_LIBRARY)
TARGET_INCLUDE_DIRECTORIES(memory PRIVATE include src)
TARGET_INCLUDE_DIRECTORIES(mutex PRIVATE include src)
TARGET_INCLUDE_DIRECTORIES(post-operation PUBLIC include src)
+ if(ANDROID)
+ find_library(LOG_LIB NAMES log REQUIRED)
+ target_link_libraries(XNNPACK PRIVATE log)
+ endif()
IF(WIN32)
# Target Windows 7+ API
TARGET_COMPILE_DEFINITIONS(XNNPACK PRIVATE _WIN32_WINNT=0x0601)
@@ -987,7 +991,9 @@ IF(LIBM)
ENDIF()

# ---[ Configure cpuinfo
-IF(NOT TARGET cpuinfo)
+find_package(cpuinfo CONFIG REQUIRED)
+add_library(cpuinfo ALIAS cpuinfo::cpuinfo)
+IF(FALSE)
IF(NOT XNNPACK_USE_SYSTEM_LIBS)
SET(CPUINFO_BUILD_TOOLS OFF CACHE BOOL "")
SET(CPUINFO_BUILD_UNIT_TESTS OFF CACHE BOOL "")
@@ -1009,12 +1015,12 @@ IF(NOT TARGET cpuinfo)
ENDIF()
IF(XNNPACK_BUILD_LIBRARY)
TARGET_LINK_LIBRARIES(hardware-config PRIVATE cpuinfo)
- TARGET_LINK_LIBRARIES(XNNPACK PRIVATE cpuinfo)
+ TARGET_LINK_LIBRARIES(XNNPACK PUBLIC cpuinfo::cpuinfo)
ENDIF()

# ---[ Configure pthreadpool
IF(NOT TARGET pthreadpool)
- IF(NOT XNNPACK_USE_SYSTEM_LIBS)
+ IF(FALSE)
SET(PTHREADPOOL_BUILD_TESTS OFF CACHE BOOL "")
SET(PTHREADPOOL_BUILD_BENCHMARKS OFF CACHE BOOL "")
SET(PTHREADPOOL_ALLOW_DEPRECATED_API OFF CACHE BOOL "")
@@ -1022,13 +1028,14 @@ IF(NOT TARGET pthreadpool)
"${PTHREADPOOL_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}/pthreadpool")
ELSE()
- ADD_LIBRARY(pthreadpool SHARED IMPORTED)
- FIND_LIBRARY(PTHREADPOOL_LIBRARY pthreadpool PATHS "${PTHREADPOOL_SOURCE_DIR}/lib")
+ ADD_LIBRARY(pthreadpool STATIC IMPORTED)
+ find_library(PTHREADPOOL_LIBRARY NAMES pthreadpool REQUIRED)
IF(NOT PTHREADPOOL_LIBRARY)
MESSAGE(FATAL_ERROR "Cannot find pthreadpool")
ENDIF()
FIND_PACKAGE(Threads REQUIRED)
- TARGET_INCLUDE_DIRECTORIES(pthreadpool INTERFACE "${PTHREADPOOL_SOURCE_DIR}/include")
+ find_path(PTHREADPOOL_INCLUDE_DIRS "pthreadpool.h" REQUIRED)
+ TARGET_INCLUDE_DIRECTORIES(pthreadpool INTERFACE "${PTHREADPOOL_INCLUDE_DIRS}")
TARGET_LINK_LIBRARIES(pthreadpool INTERFACE Threads::Threads)
SET_PROPERTY(TARGET pthreadpool PROPERTY IMPORTED_LOCATION "${PTHREADPOOL_LIBRARY}")
SET_PROPERTY(TARGET pthreadpool PROPERTY IMPORTED_IMPLIB "${PTHREADPOOL_LIBRARY}")
@@ -1046,7 +1053,9 @@ TARGET_LINK_LIBRARIES(microparams-init PRIVATE pthreadpool)
TARGET_LINK_LIBRARIES(normalization PRIVATE pthreadpool)
TARGET_LINK_LIBRARIES(packing PRIVATE pthreadpool)
IF(XNNPACK_BUILD_LIBRARY)
- TARGET_LINK_LIBRARIES(XNNPACK PUBLIC pthreadpool)
+ get_filename_component(PTHREADPOOL_LIBDIR "${PTHREADPOOL_LIBRARY}" PATH)
+ target_link_directories(XNNPACK PUBLIC ${PTHREADPOOL_LIBDIR})
+ TARGET_LINK_LIBRARIES(XNNPACK PUBLIC ${PTHREADPOOL_LIBRARY})
TARGET_LINK_LIBRARIES(allocator PRIVATE pthreadpool)
TARGET_LINK_LIBRARIES(cache PRIVATE memory pthreadpool)
TARGET_LINK_LIBRARIES(subgraph PRIVATE pthreadpool)
@@ -1059,7 +1068,10 @@ IF(XNNPACK_BUILD_LIBRARY)
ENDIF()

# ---[ Configure FXdiv
-IF(NOT TARGET fxdiv)
+find_path(FXDIV_INCLUDE_DIRS "fxdiv.h" REQUIRED)
+add_library(fxdiv INTERFACE)
+target_include_directories(fxdiv INTERFACE ${FXDIV_INCLUDE_DIRS})
+IF(FALSE)
IF(NOT XNNPACK_USE_SYSTEM_LIBS)
SET(FXDIV_BUILD_TESTS OFF CACHE BOOL "")
SET(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "")
@@ -1067,7 +1079,7 @@ IF(NOT TARGET fxdiv)
"${FXDIV_SOURCE_DIR}"
"${CMAKE_BINARY_DIR}/FXdiv")
ELSE()
- FIND_FILE(FXDIV_HDR fxdiv.h PATH_SUFFIXES include PATHS "${FXDIV_SOURCE_DIR}")
+ find_path(FXDIV_HDR NAMES "fxdiv.h" REQUIRED)
@@ -1141,7 +1141,7 @@ IF(NOT TARGET fxdiv)
IF(NOT FXDIV_HDR)
MESSAGE(FATAL_ERROR "Cannot find fxdiv")
ENDIF()
@@ -1086,7 +1098,10 @@ IF(XNNPACK_BUILD_LIBRARY)
ENDIF()
- ADD_LIBRARY(fxdiv STATIC "${FXDIV_HDR}")
+ ADD_LIBRARY(fxdiv INTERFACE "${FXDIV_HDR}")
TARGET_INCLUDE_DIRECTORIES(fxdiv INTERFACE "${FXDIV_SOURCE_DIR}/include")
SET_PROPERTY(TARGET fxdiv PROPERTY LINKER_LANGUAGE C)
ENDIF()
@@ -779,7 +779,7 @@ ADD_CUSTOM_COMMAND(
# all other XNNPACK targets.
ADD_LIBRARY(xnnpack-base INTERFACE)

# ---[ Configure FP16
-IF(NOT TARGET fp16)
+find_path(FP16_INCLUDE_DIRS "fp16.h" REQUIRED)
+add_library(fp16 INTERFACE)
+target_include_directories(fp16 INTERFACE ${FP16_INCLUDE_DIRS})
+IF(FALSE)
IF(NOT XNNPACK_USE_SYSTEM_LIBS)
SET(FP16_BUILD_TESTS OFF CACHE BOOL "")
SET(FP16_BUILD_BENCHMARKS OFF CACHE BOOL "")
@@ -1117,9 +1132,18 @@ IF(XNNPACK_BUILD_LIBRARY)
-ADD_LIBRARY(microkernels-prod STATIC ${PROD_MICROKERNEL_SRCS} ${TABLE_SRCS})
+ADD_LIBRARY(microkernels-prod OBJECT ${PROD_MICROKERNEL_SRCS} ${TABLE_SRCS})
IF(XNNPACK_BUILD_ALL_MICROKERNELS)
ADD_LIBRARY(microkernels-all STATIC ${NON_PROD_MICROKERNEL_SRCS})
TARGET_LINK_LIBRARIES(microkernels-all PUBLIC microkernels-prod)
@@ -1156,7 +1156,7 @@ IF(XNNPACK_BUILD_LIBRARY)
ENDIF()

TARGET_LINK_LIBRARIES(XNNPACK PRIVATE fp16)
INSTALL(TARGETS XNNPACK
+ # EXPORT xnnpack-targets # requires object targets to be in export set
IF(XNNPACK_BUILD_LIBRARY)
- INSTALL(TARGETS XNNPACK microkernels-prod
+ INSTALL(TARGETS XNNPACK # microkernels-prod
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+ # install(EXPORT xnnpack-targets DESTINATION ${CMAKE_INSTALL_DATAROOTDIR})
+
+ include(CMakePackageConfigHelpers)
+ get_filename_component(CONFIG_FILE_PATH ${CMAKE_CURRENT_BINARY_DIR}/xnnpack-config.cmake ABSOLUTE)
+ configure_package_config_file(
+ cmake/xnnpack-config.template.cmake ${CONFIG_FILE_PATH}
+ INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR})
+ install(FILES ${CONFIG_FILE_PATH} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR})
ENDIF()

# ---[ XNNPACK unit tests
47 changes: 20 additions & 27 deletions ports/xnnpack/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,60 @@ if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()

# for onnxruntime, using just before https://github.com/google/XNNPACK/commit/142aceb06d509b57d02ddc2a9558ab35eacbb6fb

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO google/XNNPACK
REF 92c6254f6a2a57f394248f66271a77f4f48a27aa # 2024-05-06
SHA512 71fe88ba951ff353288f07ae2119301d046750c850b268eb01435816848adfd9a8f5d701d3ce134fe9b3178c4f70410fad5e5ed2521292f7c17320a904d3ac7a
REF 4ea82e595b36106653175dcb04b2aa532660d0d8 # 2024-11-09
SHA512 b9e711e1c69a24e347f64ee21c60a609bff25e36153216382acd3d431e466b127eea81b1d80f00f84699a426c44f8a3566d9b95d0e87079c34f527e05c2db787
HEAD_REF master
PATCHES
fix-cmake.patch
)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/xnnpack-config.template.cmake" DESTINATION "${SOURCE_PATH}/cmake")

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
test XNNPACK_BUILD_ALL_MICROKERNELS
kleidi XNNPACK_ENABLE_KLEIDIAI
)

vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
WINDOWS_USE_MSBUILD
OPTIONS
${FEATURE_OPTIONS}
${PLATFORM_OPTIONS}
-DXNNPACK_USE_SYSTEM_LIBS=ON
-DXNNPACK_ENABLE_ASSEMBLY=${USE_ASSEMBLY}
"-DCPUINFO_SOURCE_DIR:PATH=${CURRENT_INSTALLED_DIR}"
"-DPTHREADPOOL_SOURCE_DIR:PATH=${CURRENT_INSTALLED_DIR}"
"-DFXDIV_SOURCE_DIR:PATH=${CURRENT_INSTALLED_DIR}"
-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()
vcpkg_cmake_config_fixup(CONFIG_PATH share PACKAGE_NAME xnnpack)

file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
Expand Down
18 changes: 12 additions & 6 deletions ports/xnnpack/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
{
"name": "xnnpack",
"version-date": "2024-05-06",
"version-date": "2024-11-09",
"description": "High-efficiency floating-point neural network inference operators for mobile, server, and Web",
"homepage": "https://github.com/google/XNNPACK",
"dependencies": [
"cpuinfo",
"fp16",
"fxdiv",
"pthreadpool",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
],
"features": {
"test": {
"description": "Build and run tests",
"dependencies": [
"benchmark",
"gtest"
]
}
}
}
36 changes: 0 additions & 36 deletions ports/xnnpack/xnnpack-config.template.cmake

This file was deleted.

10 changes: 1 addition & 9 deletions test/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "test",
"version-date": "2024-08-11",
"version-date": "2024-11-12",
"description": "vcpkg registry maintained by @luncliff",
"homepage": "https://github.com/luncliff/vcpkg-registry",
"supports": "windows | linux | osx | ios",
"dependencies": [
"abseil",
{
"name": "apple-crypto",
"platform": "osx | ios"
},
{
"name": "apple-nio-ssl",
"platform": "osx | ios"
},
{
"name": "coreml-tools",
"platform": "osx | ios"
Expand Down
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"port-version": 0
},
"cpuinfo": {
"baseline": "2024-08-31",
"baseline": "2024-10-23",
"port-version": 0
},
"d3d12-transition-layer": {
Expand Down Expand Up @@ -225,7 +225,7 @@
"port-version": 0
},
"xnnpack": {
"baseline": "2024-05-06",
"baseline": "2024-11-09",
"port-version": 0
},
"xnvctrl": {
Expand Down
5 changes: 5 additions & 0 deletions versions/c-/cpuinfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "2089f31fe6a7f7368d19275e65e95c8218fac585",
"version-date": "2024-10-23",
"port-version": 0
},
{
"git-tree": "f3e0fc439df6a5a6fc0f37a5a55d19108bbfc523",
"version-date": "2024-08-31",
Expand Down
5 changes: 5 additions & 0 deletions versions/x-/xnnpack.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "e9942d4fce22c45ac9e31234591db9a2a9ed10e1",
"version-date": "2024-11-09",
"port-version": 0
},
{
"git-tree": "86d1be113bb49c5e4c0580184754c742f5a18e7a",
"version-date": "2024-05-06",
Expand Down

0 comments on commit c9603df

Please sign in to comment.