[qnnpack] create a new port (#17065)

* [qnnpack] create a new port

* [qnnpack] create a patch

* [qnnpack] update baseline and port SHA

* [qnnpack] update supports

* the project only checks linux/osx

* Update ports/qnnpack/portfile.cmake

Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>

* Update ports/qnnpack/portfile.cmake

Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>

* [qnnpack] apply 'vcpkg-cmake'

* [qnnpack] use unofficial-cpuinfo

* [qnnpack] fix wrong support expression

Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
This commit is contained in:
Park DongHa 2021-05-07 09:44:36 +09:00 committed by GitHub
parent 7c23c13db0
commit 2b1f2ca96a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 241 additions and 0 deletions

View File

@ -0,0 +1,23 @@
vcpkg_fail_port_install(ON_TARGET "Windows")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO pytorch/QNNPACK
REF 7d2a4e9931a82adc3814275b6219a03e24e36b4c
SHA512 437a835acfedae851a9a8572fa6eea9854dcb8bcca499bc4a2582314e44f5f199778e857932da4aecf943bea7cb2eb5b1c41d4b4ca6075bddbe0f18b2c7b9127
HEAD_REF master
PATCHES
use-packages.patch
)
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
-DQNNPACK_BUILD_TESTS=OFF
-DQNNPACK_BUILD_BENCHMARKS=OFF
)
vcpkg_cmake_install()
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include
${CURRENT_PACKAGES_DIR}/debug/bin
)

View File

@ -0,0 +1,187 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a5ddc49..05e1279 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,8 +13,6 @@ PROJECT(QNNPACK C CXX ASM)
# ---[ Options.
OPTION(QNNPACK_CUSTOM_THREADPOOL "Build QNNPACK for custom thread pool" OFF)
-SET(QNNPACK_LIBRARY_TYPE "default" CACHE STRING "Type of library (shared, static, or default) to build")
-SET_PROPERTY(CACHE QNNPACK_LIBRARY_TYPE PROPERTY STRINGS default static shared)
OPTION(QNNPACK_BUILD_TESTS "Build QNNPACK unit tests" ON)
OPTION(QNNPACK_BUILD_BENCHMARKS "Build QNNPACK benchmarks" ON)
@@ -53,11 +51,11 @@ SET(CONFU_DEPENDENCIES_SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps"
SET(CONFU_DEPENDENCIES_BINARY_DIR "${CMAKE_BINARY_DIR}/deps"
CACHE PATH "Confu-style dependencies binary directory")
-IF(NOT DEFINED CLOG_SOURCE_DIR)
+IF(FALSE)
SET(CLOG_SOURCE_DIR "${PROJECT_SOURCE_DIR}/deps/clog")
ENDIF()
-IF(NOT DEFINED CPUINFO_SOURCE_DIR)
+IF(FALSE)
MESSAGE(STATUS "Downloading cpuinfo to ${CONFU_DEPENDENCIES_SOURCE_DIR}/cpuinfo (define CPUINFO_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadCpuinfo.cmake "${CONFU_DEPENDENCIES_BINARY_DIR}/cpuinfo-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
@@ -67,7 +65,7 @@ IF(NOT DEFINED CPUINFO_SOURCE_DIR)
SET(CPUINFO_SOURCE_DIR "${CONFU_DEPENDENCIES_SOURCE_DIR}/cpuinfo" CACHE STRING "cpuinfo source directory")
ENDIF()
-IF(NOT DEFINED FP16_SOURCE_DIR)
+IF(FALSE)
MESSAGE(STATUS "Downloading FP16 to ${CONFU_DEPENDENCIES_SOURCE_DIR}/fp16 (define FP16_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadFP16.cmake "${CONFU_DEPENDENCIES_BINARY_DIR}/fp16-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
@@ -77,7 +75,7 @@ IF(NOT DEFINED FP16_SOURCE_DIR)
SET(FP16_SOURCE_DIR "${CONFU_DEPENDENCIES_SOURCE_DIR}/fp16" CACHE STRING "FP16 source directory")
ENDIF()
-IF(NOT DEFINED FXDIV_SOURCE_DIR)
+IF(FALSE)
MESSAGE(STATUS "Downloading FXdiv to ${CONFU_DEPENDENCIES_SOURCE_DIR}/fxdiv (define FXDIV_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadFXdiv.cmake "${CONFU_DEPENDENCIES_BINARY_DIR}/fxdiv-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
@@ -87,7 +85,7 @@ IF(NOT DEFINED FXDIV_SOURCE_DIR)
SET(FXDIV_SOURCE_DIR "${CONFU_DEPENDENCIES_SOURCE_DIR}/fxdiv" CACHE STRING "FXdiv source directory")
ENDIF()
-IF(NOT DEFINED PSIMD_SOURCE_DIR)
+IF(FALSE)
MESSAGE(STATUS "Downloading PSimd to ${CONFU_DEPENDENCIES_SOURCE_DIR}/psimd (define PSIMD_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadPSimd.cmake "${CONFU_DEPENDENCIES_BINARY_DIR}/psimd-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
@@ -97,7 +95,7 @@ IF(NOT DEFINED PSIMD_SOURCE_DIR)
SET(PSIMD_SOURCE_DIR "${CONFU_DEPENDENCIES_SOURCE_DIR}/psimd" CACHE STRING "PSimd source directory")
ENDIF()
-IF(NOT DEFINED PTHREADPOOL_SOURCE_DIR)
+IF(FALSE)
MESSAGE(STATUS "Downloading pthreadpool to ${CONFU_DEPENDENCIES_SOURCE_DIR}/pthreadpool (define PTHREADPOOL_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadPThreadPool.cmake "${CONFU_DEPENDENCIES_BINARY_DIR}/pthreadpool-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
@@ -107,7 +105,7 @@ IF(NOT DEFINED PTHREADPOOL_SOURCE_DIR)
SET(PTHREADPOOL_SOURCE_DIR "${CONFU_DEPENDENCIES_SOURCE_DIR}/pthreadpool" CACHE STRING "pthreadpool source directory")
ENDIF()
-IF(QNNPACK_BUILD_TESTS AND NOT DEFINED GOOGLETEST_SOURCE_DIR)
+IF(FALSE)
MESSAGE(STATUS "Downloading Google Test to ${CONFU_DEPENDENCIES_SOURCE_DIR}/googletest (define GOOGLETEST_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadGoogleTest.cmake "${CONFU_DEPENDENCIES_BINARY_DIR}/googletest-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
@@ -117,7 +115,7 @@ IF(QNNPACK_BUILD_TESTS AND NOT DEFINED GOOGLETEST_SOURCE_DIR)
SET(GOOGLETEST_SOURCE_DIR "${CONFU_DEPENDENCIES_SOURCE_DIR}/googletest" CACHE STRING "Google Test source directory")
ENDIF()
-IF(QNNPACK_BUILD_BENCHMARKS AND NOT DEFINED GOOGLEBENCHMARK_SOURCE_DIR)
+IF(FALSE)
MESSAGE(STATUS "Downloading Google Benchmark to ${CONFU_DEPENDENCIES_SOURCE_DIR}/googlebenchmark (define GOOGLEBENCHMARK_SOURCE_DIR to avoid it)")
CONFIGURE_FILE(cmake/DownloadGoogleBenchmark.cmake "${CONFU_DEPENDENCIES_BINARY_DIR}/googlebenchmark-download/CMakeLists.txt")
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
@@ -229,15 +227,7 @@ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|x86_64)$" OR IOS_ARCH MATCHES "^(i
LIST(APPEND QNNPACK_UKERNELS ${QNNPACK_X86_SSE2_UKERNELS})
ENDIF()
-IF(QNNPACK_LIBRARY_TYPE STREQUAL "default")
- ADD_LIBRARY(qnnpack ${QNNPACK_INIT_SRCS} ${QNNPACK_EXEC_SRCS} ${QNNPACK_UKERNELS})
-ELSEIF(QNNPACK_LIBRARY_TYPE STREQUAL "shared")
- ADD_LIBRARY(qnnpack SHARED ${QNNPACK_INIT_SRCS} ${QNNPACK_EXEC_SRCS} ${QNNPACK_UKERNELS})
-ELSEIF(QNNPACK_LIBRARY_TYPE STREQUAL "static")
- ADD_LIBRARY(qnnpack STATIC ${QNNPACK_INIT_SRCS} ${QNNPACK_EXEC_SRCS} ${QNNPACK_UKERNELS})
-ELSE()
- MESSAGE(FATAL_ERROR "Unsupported QNNPACK library type \"${QNNPACK_LIBRARY_TYPE}\". Must be \"static\", \"shared\", or \"default\"")
-ENDIF()
+ADD_LIBRARY(qnnpack ${QNNPACK_INIT_SRCS} ${QNNPACK_EXEC_SRCS} ${QNNPACK_UKERNELS})
SET_TARGET_PROPERTIES(qnnpack PROPERTIES
C_STANDARD 99
C_EXTENSIONS YES)
@@ -272,7 +262,7 @@ TARGET_INCLUDE_DIRECTORIES(qnnpack PRIVATE src)
SET_TARGET_PROPERTIES(qnnpack PROPERTIES PUBLIC_HEADER include/qnnpack.h)
# ---[ Configure clog
-IF(NOT TARGET clog)
+IF(FALSE)
SET(CLOG_BUILD_TESTS OFF CACHE BOOL "")
SET(CLOG_RUNTIME_TYPE "${CPUINFO_RUNTIME_TYPE}" CACHE STRING "")
ADD_SUBDIRECTORY(
@@ -281,10 +271,9 @@ IF(NOT TARGET clog)
# We build static version of clog but a dynamic library may indirectly depend on it
SET_PROPERTY(TARGET clog PROPERTY POSITION_INDEPENDENT_CODE ON)
ENDIF()
-TARGET_LINK_LIBRARIES(qnnpack PRIVATE clog)
# ---[ Configure cpuinfo
-IF(NOT TARGET cpuinfo)
+IF(FALSE)
SET(CPUINFO_BUILD_TOOLS OFF CACHE BOOL "")
SET(CPUINFO_BUILD_UNIT_TESTS OFF CACHE BOOL "")
SET(CPUINFO_BUILD_MOCK_TESTS OFF CACHE BOOL "")
@@ -293,17 +282,19 @@ IF(NOT TARGET cpuinfo)
"${CPUINFO_SOURCE_DIR}"
"${CONFU_DEPENDENCIES_BINARY_DIR}/cpuinfo")
ENDIF()
-TARGET_LINK_LIBRARIES(qnnpack PRIVATE cpuinfo)
+
+find_package(unofficial-cpuinfo CONFIG REQUIRED)
+target_link_libraries(qnnpack PUBLIC unofficial::cpuinfo::clog unofficial::cpuinfo::cpuinfo)
# ---[ Configure pthreadpool
-IF(NOT TARGET pthreadpool)
+IF(FALSE)
SET(PTHREADPOOL_BUILD_TESTS OFF CACHE BOOL "")
SET(PTHREADPOOL_BUILD_BENCHMARKS OFF CACHE BOOL "")
ADD_SUBDIRECTORY(
"${PTHREADPOOL_SOURCE_DIR}"
"${CONFU_DEPENDENCIES_BINARY_DIR}/pthreadpool")
ENDIF()
-IF(QNNPACK_CUSTOM_THREADPOOL)
+IF(FALSE)
# Depend on pthreadpool interface, but not on implementation.
# This is used when QNNPACK user (e.g. Caffe2) provides its own threadpool implementation.
TARGET_LINK_LIBRARIES(qnnpack PUBLIC pthreadpool_interface)
@@ -312,34 +303,38 @@ ELSE()
ENDIF()
# ---[ Configure FXdiv
-IF(NOT TARGET fxdiv)
+IF(FALSE)
SET(FXDIV_BUILD_TESTS OFF CACHE BOOL "")
SET(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "")
ADD_SUBDIRECTORY(
"${FXDIV_SOURCE_DIR}"
"${CONFU_DEPENDENCIES_BINARY_DIR}/fxdiv")
ENDIF()
-TARGET_LINK_LIBRARIES(qnnpack PRIVATE fxdiv)
+find_path(FXDIV_INCLUDE_DIRS "fxdiv.h")
+target_include_directories(qnnpack PRIVATE ${FXDIV_INCLUDE_DIRS})
# ---[ Configure psimd
-IF(NOT TARGET psimd)
+IF(FALSE)
ADD_SUBDIRECTORY(
"${PSIMD_SOURCE_DIR}"
"${CONFU_DEPENDENCIES_BINARY_DIR}/psimd")
ENDIF()
-TARGET_LINK_LIBRARIES(qnnpack PRIVATE psimd)
+find_path(PSIMD_INCLUDE_DIRS "psimd.h")
+target_include_directories(qnnpack PRIVATE ${PSIMD_INCLUDE_DIRS})
# ---[ Configure FP16
-IF(NOT TARGET fp16)
+IF(FALSE)
SET(FP16_BUILD_TESTS OFF CACHE BOOL "")
SET(FP16_BUILD_BENCHMARKS OFF CACHE BOOL "")
ADD_SUBDIRECTORY(
"${FP16_SOURCE_DIR}"
"${CONFU_DEPENDENCIES_BINARY_DIR}/fp16")
ENDIF()
-TARGET_LINK_LIBRARIES(qnnpack PRIVATE fp16)
+find_path(FP16_INCLUDE_DIRS "fp16.h")
+target_include_directories(qnnpack PRIVATE ${FP16_INCLUDE_DIRS})
INSTALL(TARGETS qnnpack
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

18
ports/qnnpack/vcpkg.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "qnnpack",
"version-date": "2021-02-26",
"description": "Quantized Neural Network PACKage - mobile-optimized implementation of quantized neural network operators",
"homepage": "https://github.com/pytorch/QNNPACK",
"supports": "linux | osx",
"dependencies": [
"cpuinfo",
"fp16",
"fxdiv",
"psimd",
"pthreadpool",
{
"name": "vcpkg-cmake",
"host": true
}
]
}

View File

@ -5000,6 +5000,10 @@
"baseline": "8.0.2",
"port-version": 0
},
"qnnpack": {
"baseline": "2021-02-26",
"port-version": 0
},
"qpid-proton": {
"baseline": "0.32.0",
"port-version": 0

9
versions/q-/qnnpack.json Normal file
View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "b433ea1861106777f4f358ba433eeea488e91c3a",
"version-date": "2021-02-26",
"port-version": 0
}
]
}