Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FP16 causes cross-compilation errors for x86-64 targets on macOS. #6989

Open
Tinuv-Dev opened this issue Aug 31, 2024 · 3 comments
Open

FP16 causes cross-compilation errors for x86-64 targets on macOS. #6989

Tinuv-Dev opened this issue Aug 31, 2024 · 3 comments

Comments

@Tinuv-Dev
Copy link

I attempted to cross-compile XNNPACK today using the latest code from the master branch, but the compilation failed with an error. I am quite puzzled by this because I was able to successfully cross-compile XNNPACK not long ago.

After analyzing the error, I found that it is likely caused by the use of FP16. It seems that a recent commit (5443c56, commit message: “Add a typedef for float16 to uint16”) added #include <fp16/fp16.h> to libXNNPACK-source-master/src/xnnpack/math.h. This inclusion causes a compilation error when cross-compiling for the x86-64 target (including macOS x86-64 physical devices and iOS x86-64 simulators). It appears that FP16 is a library used for optimization. Could you add an option to the CMakeLists.txt file that allows me to disable FP16 optimization? Alternatively, if there is another way to do this, I would appreciate any guidance that would allow me to successfully cross-compile.

Additional Information:

•	macOS Version: macOS Sequoia 15.0 beta 7
•	Xcode Version: Version 16.0 beta 6 (16A5230g)

Log Information:

[  0%] Built target pthreadpool
[  0%] Built target cpuinfo_internals
[  1%] Built target cpuinfo
[  1%] Built target microparams-init
[  1%] Built target normalization
[  1%] Built target indirection
[  1%] Built target logging
[  1%] Built target microkernel-utils
[  1%] Built target allocator
[  1%] Built target hardware-config
[  1%] Built target cache
[  1%] Built target mutex
[  1%] Built target memory
[  1%] Built target packing
[  1%] Built target operator-utils
[  1%] Built target operator-run
[  1%] Built target operators
[  1%] Building C object CMakeFiles/subgraph.dir/src/runtime.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/memory-planner.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/argmax-pooling-2d.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/abs.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/add2.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/average-pooling-2d.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/bankers-rounding.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/batch-matrix-multiply.c.o
[  0%] Building C object CMakeFiles/microkernels-prod.dir/src/f32-avgpool/f32-avgpool-9p8x-minmax-sse-c4.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/ceiling.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/clamp.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/concatenate.c.o
In file included from /Users/tinuv/Downloads/build1/build/libXNNPACK-source-master/src/f32-avgpool/f32-avgpool-9p8x-minmax-sse-c4.c:12:
In file included from /Users/tinuv/Downloads/build1/build/libXNNPACK-source-master/src/xnnpack/avgpool.h:15:
In file included from /Users/tinuv/Downloads/build1/build/libXNNPACK-source-master/src/xnnpack/microparams.h:12:
In file included from /Users/tinuv/Downloads/build1/build/libXNNPACK-source-master/src/xnnpack/math.h:21:
In file included from /Users/tinuv/Downloads/build1/build/libXNNPACK-build/macos/scratch/x86_64/FP16-source/include/fp16/fp16.h:10:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:614:27: error: _Float16 is not supported on this target
  614 | extern _Float16 __fabsf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                           ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:614:8: error: _Float16 is not supported on this target
  614 | extern _Float16 __fabsf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:615:28: error: _Float16 is not supported on this target
  615 | extern _Float16 __hypotf16(_Float16, _Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                            ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:615:38: error: _Float16 is not supported on this target
  615 | extern _Float16 __hypotf16(_Float16, _Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                                      ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:615:8: error: _Float16 is not supported on this target
  615 | extern _Float16 __hypotf16(_Float16, _Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:616:27: error: _Float16 is not supported on this target
  616 | extern _Float16 __sqrtf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                           ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:616:8: error: _Float16 is not supported on this target
  616 | extern _Float16 __sqrtf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:617:27: error: _Float16 is not supported on this target
  617 | extern _Float16 __ceilf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                           ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:617:8: error: _Float16 is not supported on this target
  617 | extern _Float16 __ceilf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:618:28: error: _Float16 is not supported on this target
  618 | extern _Float16 __floorf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                            ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:618:8: error: _Float16 is not supported on this target
  618 | extern _Float16 __floorf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:619:27: error: _Float16 is not supported on this target
  619 | extern _Float16 __rintf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), wat[  1%] Built target pthreadpool
chos(11.0), tvos(18.0));
      |                           ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:619:8: error: _Float16 is not supported on this target
  619 | extern _Float16 __rintf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:620:28: error: _Float16 is not supported on this target
  620 | extern _Float16 __roundf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                            ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:620:8: error: _Float16 is not supported on this target
  620 | extern _Float16 __roundf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:621:28: error: _Float16 is not supported on this target
  621 | extern _Float16 __truncf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                            ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:621:8: error: _Float16 is not supported on this target
  621 | extern _Float16 __truncf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:622:31: error: _Float16 is not supported on this target
  622 | extern _Float16 __copysignf16(_Float16, _Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                               ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:622:41: error: _Float16 is not supported on this target
  622 | extern _Float16 __copysignf16(_Float16, _Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                                         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/microkernels-prod.dir/src/f32-avgpool/f32-avgpool-9p8x-minmax-sse-c4.c.o] Error 1
make[1]: *** [CMakeFiles/microkernels-prod.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/convert.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/convolution-2d.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/copy.c.o
[  1%] Built target logging
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/deconvolution-2d.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/copysign.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/depth-to-space-2d.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/divide.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/depthwise-convolution-2d.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/even-split.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/elu.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/exp.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/floor.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/fully-connected-sparse.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/fully-connected.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/gelu.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/global-sum-pooling.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/global-average-pooling.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/hardswish.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/leaky-relu.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/log.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/max-pooling-2d.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/maximum2.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/minimum2.c.o
[  1%] Building C object CMakeFiles/microkernels-prod.dir/src/f32-avgpool/f32-avgpool-9p8x-minmax-sse-c4.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/multiply2.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/negate.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/reciprocal-square-root.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/prelu.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/reshape-helpers.c.o
In file included from /Users/tinuv/Downloads/build1/build/libXNNPACK-source-master/src/f32-avgpool/f32-avgpool-9p8x-minmax-sse-c4.c:12:
In file included from /Users/tinuv/Downloads/build1/build/libXNNPACK-source-master/src/xnnpack/avgpool.h:15:
In file included from /Users/tinuv/Downloads/build1/build/libXNNPACK-source-master/src/xnnpack/microparams.h:12:
In file included from /Users/tinuv/Downloads/build1/build/libXNNPACK-source-master/src/xnnpack/math.h:21:
In file included from /Users/tinuv/Downloads/build1/build/libXNNPACK-build/macos/scratch/x86_64/FP16-source/include/fp16/fp16.h:10:
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:614:27: error: _Float16 is not supported on this target
  614 | extern _Float16 __fabsf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                           ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:614:8: error: _Float16 is not supported on this target
  614 | extern _Float16 __fabsf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:615:28: error: _Float16 is not supported on this target
  615 | extern _Float16 __hypotf16(_Float16, _Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                            ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:615:38: error: _Float16 is not supported on this target
  615 | extern _Float16 __hypotf16(_Float16, _Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                                      ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:615:8: error: _Float16 is not supported on this target
  615 | extern _Float16 __hypotf16(_Float16, _Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:616:27: error: _Float16 is not supported on this target
  616 | extern _Float16 __sqrtf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                           ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:616:8: error: _Float16 is not supported on this target
  616 | extern _Float16 __sqrtf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:617:27: error: _Float16 is not supported on this target
  617 | extern _Float16 __ceilf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                           ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:617:8: error: _Float16 is not supported on this target
  617 | extern _Float16 __ceilf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:618:28: error: _Float16 is not supported on this target
  618 | extern _Float16 __floorf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                            ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:618:8: error: _Float16 is not supported on this target
  618 | extern _Float16 __floorf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:619:27: error: _Float16 is not supported on this target
  619 | extern _Float16 __rintf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                           ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:619:8: error: _Float16 is not supported on this target
  619 | extern _Float16 __rintf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:620:28: error: _Float16 is not supported on this target
  620 | extern _Float16 __roundf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                            ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:620:8: error: _Float16 is not supported on this target
  620 | extern _Float16 __roundf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:621:28: error: _Float16 is not supported on this target
  621 | extern _Float16 __truncf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                            ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:621:8: error: _Float16 is not supported on this target
  621 | extern _Float16 __truncf16(_Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |        ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:622:31: error: _Float16 is not supported on this target
  622 | extern _Float16 __copysignf16(_Float16, _Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                               ^
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk/usr/include/math.h:622:41: error: _Float16 is not supported on this target
  622 | extern _Float16 __copysignf16(_Float16, _Float16) __API_AVAILABLE(macos(15.0), ios(18.0), watchos(11.0), tvos(18.0));
      |                                         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [CMakeFiles/microkernels-prod.dir/src/f32-avgpool/f32-avgpool-9p8x-minmax-sse-c4.c.o] Error 1
make[1]: *** [CMakeFiles/microkernels-prod.dir/all] Error 2
make: *** [all] Error 2
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/scaled-dot-product-attention.c.o     
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/sigmoid.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/softmax.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/space-to-depth-2d.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/square-root.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/square.c.o
(base) ---------------------------------------------------------------------------------------------
~/Downloads/build1/build/libXNNPACK-build/macos/scratch/x86_64 » [  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/squared-difference.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/static-constant-pad.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/static-mean.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/static-resize-bilinear-2d.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/static-slice.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/static-transpose.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/subtract.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/tanh.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/unpooling-2d.c.o
[  1%] Building C object CMakeFiles/subgraph.dir/src/subgraph/validation.c.o
[  2%] Building C object CMakeFiles/subgraph.dir/src/tensor.c.o
[  2%] Built target subgraph
make: *** [all] Error 2

@dsharlet
Copy link
Collaborator

I think FP16 really is a necessary dependency, it's not optional for optimization. The thing that would need to be optional is support for float16 ops, which AFAIK is not and cannot easily be made so.

Maratyszcza/FP16#32 is a workaround for this that might be easy for you to apply.

Can you share how you are attempting to cross-compile XNNPACK? I'm not sure if this is an issue with the cross compilation setup (which could be looking for the wrong math.h, i.e. using an x86 math.h when it should be using an ARM one), or an issue with XNNPACK's build.

@tinuv
Copy link

tinuv commented Sep 1, 2024

https://github.com/Tinuv-Dev/TensorflowLiteBuilder

I'm happy to share my build script, even though it's a bit rough. You just need to enable libXNNPACK in the TensorflowLiteBuilder and comment out the other libraries.

extension TensorflowLiteBuilder {
    func initLibrayList() -> [Library] {
        var libraryList: [Library] = []
        // libraryList.append(.libAbseil)
        // libraryList.append(.libeigen)
        // libraryList.append(.libflatbuffers)
        // libraryList.append(.libNEON_2_SSE)
        // libraryList.append(.libcpuinfo)
        // libraryList.append(.libruy)
        // libraryList.append(.libpthreadpool)
        libraryList.append(.libXNNPACK)
        // libraryList.append(.libtensorflow)
        return libraryList
    }
}

After that, modify your workDirectory and other configurations as needed.

    static let workDirectory = "file:///your/work/path"
    static let buildDirectory = workDirectory + "/build"
    static let distDirectory = workDirectory + "/dist"
    static let patchDirector = workDirectory + "/patch"
    static let platforms = PlatformType.allCases.filter { ![.watchos, .watchsimulator, .android].contains($0) }

then run the main file to build with XNNPACK. You can see in the Builder file that I checked out the source code for XNNPACK to a specific commit ID to successfully compile it. If you comment out those statements, you'll be able to see the errors I described.

    func obtainSource() {
        if !FileManager.default.fileExists(atPath: lib.libSourceDirectory.path()) {
            var arguments = ["clone", "--recurse-submodules"]
            arguments.append(contentsOf: ["--branch", lib.libVersion, lib.libRepoURL, lib.libSourceDirectory.path()])
            try! Utility.launch(path: "/usr/bin/git", arguments: arguments)
            //if lib == .libXNNPACK {
            //    try! Utility.launch(path: "/usr/bin/git", arguments: ["checkout", "e716e05befe59f2512f82432fb161ba1fea9969a"],currentDirectoryURL: lib.libSourceDirectory)
            //}
        }
    }

@tinuv
Copy link

tinuv commented Sep 1, 2024

Some compilation options can be found in the LibXNNPACKBuilder file.

copybara-service bot pushed a commit that referenced this issue Oct 4, 2024
This dependency is causing issues on some platforms. We have a workaround: https://github.com/Maratyszcza/fp16 that some users have implemented (e.g. https://github.com/microsoft/onnxruntime/pull/22294/files), but it doesn't make sense to hack this workaround into everything that depends on XNNPACK.

This PR pulls the small part of the fp16 library we actually need in XNNPACK, and removes the dependency.

Fixes #6989

FUTURE_COPYBARA_INTEGRATE_REVIEW=#7128 from imaginationtech:img_patch30_f32_f16_vcvt 2f40edd
PiperOrigin-RevId: 682156616
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants