Skip to content

Commit

Permalink
[nnpack] create a new port (#16344)
Browse files Browse the repository at this point in the history
* [psimd] create a new port

* [psimd] update baseline and port SHA

* [fp16] create a new port

* [fp16] update baseline and port SHA

* [fxdiv] create a new port

* [fxdiv] update baseline and port SHA

* [pthreadpool] create a new port

* [pthreadpool] update baseline and port SHA

* [nnpack] create a new port

* [nnpack] update baseline and port SHA

* [nnpack] use version-date

* [nnpack] disable windows

* there are no config for windows

* [nnpack] enforce psimd backend

There is a 'neon' backend, but it won't be considered for now

* [nnpack] update supports

* use more correct expression
  • Loading branch information
luncliff authored Apr 7, 2021
1 parent b466bd5 commit e1f1938
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 0 deletions.
98 changes: 98 additions & 0 deletions ports/nnpack/fix-cmakelists.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ecd2df..8565044 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,8 +12,6 @@ SET_PROPERTY(CACHE NNPACK_BACKEND PROPERTY STRINGS auto psimd scalar)
OPTION(NNPACK_CONVOLUTION_ONLY "Build only NNPACK functions for convolutional layer" OFF)
OPTION(NNPACK_INFERENCE_ONLY "Build only NNPACK functions for inference" OFF)
OPTION(NNPACK_CUSTOM_THREADPOOL "Build NNPACK for custom thread pool" OFF)
-SET(NNPACK_LIBRARY_TYPE "default" CACHE STRING "Type of library (shared, static, or default) to build")
-SET_PROPERTY(CACHE NNPACK_LIBRARY_TYPE PROPERTY STRINGS default static shared)
OPTION(NNPACK_BUILD_TESTS "Build NNPACK unit tests" ON)

# ---[ CMake options
@@ -442,15 +440,7 @@ ELSE()
SET(NNPACK_BACKEND_C_SRCS ${NNPACK_BACKEND_SRCS})
ENDIF()

-IF(NNPACK_LIBRARY_TYPE STREQUAL "default")
- ADD_LIBRARY(nnpack ${NNPACK_INIT_SRCS} ${NNPACK_LAYER_SRCS} ${NNPACK_BACKEND_C_SRCS} ${NNPACK_BACKEND_PEACHPY_OBJS})
-ELSEIF(NNPACK_LIBRARY_TYPE STREQUAL "shared")
- ADD_LIBRARY(nnpack SHARED ${NNPACK_INIT_SRCS} ${NNPACK_LAYER_SRCS} ${NNPACK_BACKEND_C_SRCS} ${NNPACK_BACKEND_PEACHPY_OBJS})
-ELSEIF(NNPACK_LIBRARY_TYPE STREQUAL "static")
- ADD_LIBRARY(nnpack STATIC ${NNPACK_INIT_SRCS} ${NNPACK_LAYER_SRCS} ${NNPACK_BACKEND_C_SRCS} ${NNPACK_BACKEND_PEACHPY_OBJS})
-ELSE()
- MESSAGE(FATAL_ERROR "Unsupported NNPACK library type \"${NNPACK_LIBRARY_TYPE}\". Must be \"static\", \"shared\", or \"default\"")
-ENDIF()
+ADD_LIBRARY(nnpack ${NNPACK_INIT_SRCS} ${NNPACK_LAYER_SRCS} ${NNPACK_BACKEND_C_SRCS} ${NNPACK_BACKEND_PEACHPY_OBJS})
NNPACK_TARGET_ENABLE_C99(nnpack)
IF(IOS OR CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv5te|armv7-a|armv7l)$")
IF(IOS AND NNPACK_BACKEND STREQUAL "neon")
@@ -496,7 +486,7 @@ NNPACK_TARGET_ENABLE_C99(nnpack_reference_layers)
TARGET_INCLUDE_DIRECTORIES(nnpack_reference_layers PUBLIC include)

# ---[ 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 "")
@@ -505,10 +495,11 @@ IF(NOT TARGET cpuinfo)
"${CPUINFO_SOURCE_DIR}"
"${CONFU_DEPENDENCIES_BINARY_DIR}/cpuinfo")
ENDIF()
-TARGET_LINK_LIBRARIES(nnpack PRIVATE cpuinfo)
+find_package(cpuinfo CONFIG REQUIRED)
+target_link_libraries(nnpack PUBLIC 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(
@@ -525,33 +516,37 @@ ENDIF()
TARGET_LINK_LIBRARIES(nnpack_reference_layers PUBLIC pthreadpool)

# ---[ 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(nnpack PRIVATE fxdiv)
+find_path(FXDIV_INCLUDE_DIRS "fxdiv.h")
+target_include_directories(nnpack 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(nnpack PRIVATE psimd)
+find_path(PSIMD_INCLUDE_DIRS "psimd.h")
+target_include_directories(nnpack 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(nnpack PRIVATE fp16)
-TARGET_LINK_LIBRARIES(nnpack_reference_layers PUBLIC fp16)
+find_path(FP16_INCLUDE_DIRS "fp16.h")
+target_include_directories(nnpack PRIVATE ${FP16_INCLUDE_DIRS})
+target_include_directories(nnpack_reference_layers PUBLIC ${FP16_INCLUDE_DIRS})

INSTALL(TARGETS nnpack
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
24 changes: 24 additions & 0 deletions ports/nnpack/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
vcpkg_fail_port_install(ON_TARGET "Windows")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Maratyszcza/nnpack
REF c07e3a0400713d546e0dea2d5466dd22ea389c73
SHA512 f0b261e8698b412d12dd739e5d0cf71c284965ae28da735ae22814a004358ba3ecaea6cd26fa17b594c0245966b7dd2561c1e05c6cbf0592fd7b85ea0f21eb37
PATCHES
fix-cmakelists.patch
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DNNPACK_BACKEND=psimd
-DNNPACK_BUILD_TESTS=OFF
-DNNPACK_BUILD_BENCHMARKS=OFF
-DNNPACK_CUSTOM_THREADPOOL=OFF
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()

file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
14 changes: 14 additions & 0 deletions ports/nnpack/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "nnpack",
"version-date": "2021-02-21",
"description": "Acceleration package for neural networks on multi-core CPUs",
"homepage": "https://github.com/Maratyszcza/NNPACK",
"supports": "linux & osx",
"dependencies": [
"cpuinfo",
"fp16",
"fxdiv",
"psimd",
"pthreadpool"
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4240,6 +4240,10 @@
"baseline": "1.3.0",
"port-version": 0
},
"nnpack": {
"baseline": "2021-02-21",
"port-version": 0
},
"nonius": {
"baseline": "2019-04-20-1",
"port-version": 0
Expand Down
9 changes: 9 additions & 0 deletions versions/n-/nnpack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "bea4835350da5cce1c030ee7d9590fdae88860ae",
"version-date": "2021-02-21",
"port-version": 0
}
]
}

0 comments on commit e1f1938

Please sign in to comment.