tensorflow: XNNPack Error configuring CMake to build an installable package

Click to expand!

Issue Type

Build/Install

Source

source

Tensorflow Version

latest master (commit 9906c67e30c2def772d2a9057c98265d904d8b97)

Custom Code

No

OS Platform and Distribution

MacOS 12.4

Mobile device

No response

Python version

No response

Bazel version

No response

GCC/Compiler version

Apple clang version 13.1.6 (clang-1316.0.21.2.5) Target: arm64-apple-darwin21.5.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

CUDA/cuDNN version

No response

GPU model and memory

No response

Current Behaviour?

When configuring a build to produce an installable package per the instructions (https://www.tensorflow.org/lite/guide/build_cmake#build_installable_package), I get the following error: 


CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "XNNPACK" that is not in any export set.


### Standalone code to reproduce the issue

```shell
This is my command to generate my build files that produces the error I pasted above: 

cmake -GNinja -S ./third_party/tensorflow/tensorflow/lite -B ./deps/build/tensorflow \
  -DTFLITE_ENABLE_INSTALL:BOOL=ON \
  -DCMAKE_FIND_PACKAGE_PREFER_CONFIG:BOOL=ON \
  -DCMAKE_INSTALL_PREFIX:PATH=./deps/install/tensorflow \
  -Dcpuinfo_DIR:PATH=./deps/install/cpuinfo/share/cpuinfo \
  -Druy_DIR:PATH=./deps/install/ruy/lib/cmake/ruy \
  -Dabsl_DIR:PATH=./deps/install/abseil-cpp/lib/cmake/absl \
  -DEigen3_DIR:PATH=./deps/install/eigen/share/eigen3/cmake \
  -DNEON_2_SSE_DIR:PATH=./deps/install/ARM_NEON_2_x86_SSE/lib/cmake/NEON_2_SSE \
  -DFlatbuffers_DIR:PATH=./deps/install/flatbuffers/lib/cmake/flatbuffers

All the dependencies (cpuinfo, ruy, absl, eigen, NEON_2_SSE, Flatbuffers) are built from source and installed at the paths specified.

If I add -DTFLITE_ENABLE_XNNPACK:BOOL=OFF then then everything works.



### Relevant log output

_No response_</details>

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

TL;DR

The error

CMake Error: install(EXPORT "tensorflow-liteTargets" ...) includes target "tensorflow-lite" which requires target "XNNPACK" that is not in any export set.

results from two repos

How to fix

XNNPACK

XNNPACK’s CMakeList.txt failed to integrate with the FetchContent build flow. To make it works, modify XNNPACK’s CMakeList.txt

- TARGET_INCLUDE_DIRECTORIES(XNNPACK PUBLIC include)
+ TARGET_INCLUDE_DIRECTORIES(XNNPACK
+  PUBLIC
+  "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
+  "$<INSTALL_INTERFACE:include>"
+ )

and

- INSTALL(TARGETS XNNPACK
+ INSTALL(TARGETS XNNPACK pthreadpool pthreadpool_interface allocator
+   EXPORT XNNPACK
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
    PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+ INSTALL(
+   EXPORT XNNPACK
+   DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ )

pthreadpool

After fixing the issue of XNNPACK, pthreadpool’s error will show.

To fix it, modify pthreadpool’s CMakeList.txt as follow

- TARGET_INCLUDE_DIRECTORIES(pthreadpool_interface include) 
+ TARGET_INCLUDE_DIRECTORIES(pthreadpool_interface 
+  INTERFACE 
+    "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
+    "$<INSTALL_INTERFACE:include>"
+ )

@eesaber , Thanks for investigating on this and providing a solution, would it be possible for you to create a PR for the same in the relevant repositories. From your observation, I see there is no dependency on TFLite, does this issue still needs to be kept open in this repo?

@sachinprasadhs I am willing to create PR if the relevant repositories are accepting them.

However, even if the PR is accepted and the issue is fixed, we still need to update the xnnpack.cmake file in the tensorflow/lite/tools/cmake/modules/.

# ...
OverridableFetchContent_Declare(
  xnnpack
  GIT_REPOSITORY https://github.com/google/XNNPACK
  # Sync with tensorflow/workspace2.bzl
  GIT_TAG b9d4073a6913891ce9cbd8965c8d506075d2a45a # 👈 to the fixed commit

we need to modify the GIT_TAG to reference the commit that fixes the issue. This will ensure that the fix is pulled into the codebase when building the project in the future.

So, I recommend keeping this issue open until the xnnpack.cmake file is updated to the correct commit