tensorflow: armeabi-v7a assembler error
Click to expand!
Issue Type
Bug
Have you reproduced the bug with TF nightly?
No
Source
source
Tensorflow Version
v2.12.0-rc1
Custom Code
No
OS Platform and Distribution
Ubuntu 22.04
Mobile device
N/A
Python version
N/A
Bazel version
Using CMake
GCC/Compiler version
Clang, NDK 25b
CUDA/cuDNN version
No response
GPU model and memory
No response
Current Behaviour?
Building tensorflow lite (v2.12.0-rc1) for Android armeabi-v7a using CMake and NDK 25b, I get the following invalid assembly code error:
tflite-runtime/tensorflow/lite/tools/pip_package/gen/tflite_pip/python3/cmake_build/xnnpack/src/xnnpack/math.h:311:13: error: invalid output constraint \'=t\' in asm\n : [i] "=t" (i)
The cause is here (a more recent freeze) https://github.com/google/XNNPACK/blob/test_515720556/src/xnnpack/math.h#L332
Android arm64-v8a builds and runs without error. With an earlier tensorflow lite version (v2.8.0) both armeabi-v7a and arm64-v8a built and ran without error.
As I read it '=t' is documented as a valid constraint for “ARM family”, but the assembler thinks this is not the case.
https://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html#Simple-Constraints
https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints
Support at XNNPACK said a compiler flag -mfpu=vfp is required to enable the assembly code https://github.com/google/XNNPACK/issues/4348#issuecomment-1445437613 , and that the flag was set. Then suggested without reference that this was a Clang bug, and did not offer a workaround.
Further investigation suggested Clang was not the issue https://github.com/google/XNNPACK/issues/4348#issuecomment-1465060489
The CMake build script covers eight conditions for various arm 32 bit devices. Only two of these (both -march=armv6) set the required flag. The -mfpu=vfp flag is not set for -march=armv7-a, which I suspect is the cause of this issue. https://github.com/google/XNNPACK/blob/master/CMakeLists.txt#L546-L553
XNNPACK support responded, but we did not communicate successfully (as shown by https://github.com/google/XNNPACK/issues/4348#issuecomment-1465103944 and https://github.com/google/XNNPACK/issues/4348#issuecomment-1465259707) ; and we did not get a resolution. Since tflite depends on XNNPACK, I look for resolution here. Thank you.
### Standalone code to reproduce the issue
```shell
This is a build issue, no extra code.
Relevant log output
tflite-runtime/tensorflow/lite/tools/pip_package/gen/tflite_pip/python3/cmake_build/xnnpack/src/xnnpack/math.h:311:13: error: invalid output constraint \'=t\' in asm\n : [i] "=t" (i)
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 21 (3 by maintainers)
Commits related to this issue
- Fix xnnpack compile error on arm32 (#18291) ### Description <!-- Describe your changes. --> Use different march flag to workaround what appears to be a clang issue. See https://github.com/tensor... — committed to microsoft/onnxruntime by skottmckay 8 months ago
- Fix xnnpack compile error on arm32 (#18291) ### Description <!-- Describe your changes. --> Use different march flag to workaround what appears to be a clang issue. See https://github.com/tensor... — committed to kleiti/onnxruntime by skottmckay 8 months ago
Trying to compile v2.15.0 for armeabi-v7a, with NDK 25c (officially supported now I believe) and running into the same problem. Applying the fixes from https://github.com/microsoft/onnxruntime/commit/8d298f6f78f3280ece8d42ddb50caa6e81a6826f to XNNPACK’s CMakeLists.txt gets me past the first issue, but the build then later fails on XNNPACK microkernel compilation with below (rather cryptic) error:
Long cryptic error (click me)
Any update regarding this?
----- Update Building with NDK 21e also fails with below error
@pkgoogle 5 weeks have passed, any clarity on this issue?