Closed NHZlX closed 6 years ago
I try the cmake
method.
Assume the nnpack directory is $NNPACK
step one:
Download the android.toolchain.cmake to $NNPACK/
step two:
Add the following code on the head of $NNAPCK/CMakeLists.txt
if(CMAKE_TOOLCHAIN_FILE)
get_filename_component(CMAKE_TOOLCHAIN_FILE_NAME ${CMAKE_TOOLCHAIN_FILE} NAME)
find_file(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE_NAME} PATHS ${CMAKE_SOURCE_DIR} NO_DEFAULT_PATH)
message(STATUS "CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}")
endif()
step three(build armv7):
$ cd $NNPACK
$ mkdir android_build
$ cd android_build
$ cmake .. \
-DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake \
-DANDROID_ABI="armeabi-v7a with NEON" \
-DANDROID_NATIVE_API_LEVEL=21 \
-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 \
-DANDROID_STL_FORCE_FEATURES=OFF \
-DCMAKE_INSTALL_PREFIX=./install \
$ make -j `nproc`
$ make install
build armv8:
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake \
-DANDROID_ABI="arm64-v8a" \
-DANDROID_NATIVE_API_LEVEL=21 \
-DANDROID_TOOLCHAIN_NAME=aarch64-linux-android-4.9 \
-DANDROID_STL_FORCE_FEATURES=OFF \
-DCMAKE_INSTALL_PREFIX=./install \
but it has the following problem:
Scanning dependencies of target nnpack_reference_layers
[ 11%] Building C object CMakeFiles/nnpack_reference_layers.dir/src/ref/convolution-output.c.o
[ 13%] Building C object CMakeFiles/nnpack_reference_layers.dir/src/ref/convolution-input-gradient.c.o
[ 16%] Building C object CMakeFiles/nnpack_reference_layers.dir/src/ref/convolution-kernel.c.o
[ 18%] Building C object CMakeFiles/nnpack_reference_layers.dir/src/ref/fully-connected-output.c.o
[ 20%] Building C object CMakeFiles/nnpack_reference_layers.dir/src/ref/max-pooling-output.c.o
[ 23%] Building C object CMakeFiles/nnpack_reference_layers.dir/src/ref/softmax-output.c.o
[ 25%] Building C object CMakeFiles/nnpack_reference_layers.dir/src/ref/relu-output.c.o
In file included from /Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/activations.h:25:0,
from /Users/xingzhaolong/third_party/SOURCE/NNPACK/src/ref/relu-output.c:3:
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h: In function 'vld1q_f32_f16':
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h:46:4: warning: implicit declaration of function 'vcvt_f32_f16' [-Wimplicit-function-declaration]
return vcvt_f32_f16((float16x4_t) vld1_u16((const uint16_t*) address));
^
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h:46:25: error: 'float16x4_t' undeclared (first use in this function)
return vcvt_f32_f16((float16x4_t) vld1_u16((const uint16_t*) address));
^
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h:46:25: note: each undeclared identifier is reported only once for each function it appears in
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h:46:38: error: expected ')' before 'vld1_u16'
return vcvt_f32_f16((float16x4_t) vld1_u16((const uint16_t*) address));
^
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h: In function 'vld1q_f32_f16_aligned':
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h:50:25: error: 'float16x4_t' undeclared (first use in this function)
return vcvt_f32_f16((float16x4_t)
^
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h:51:5: error: expected ')' before 'vld1_u16'
vld1_u16((const uint16_t*) __builtin_assume_aligned(address, sizeof(float16x4_t))));
^
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h: In function 'vst1q_f16_f32':
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h:55:4: warning: implicit declaration of function 'vcvt_f16_f32' [-Wimplicit-function-declaration]
vst1_u16((uint16_t*) address, (uint16x4_t) vcvt_f16_f32(vector));
^
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h:55:4: error: can't convert between vector values of different size
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h: In function 'vst1q_f16_f32_aligned':
/Users/xingzhaolong/third_party/SOURCE/NNPACK/include/nnpack/arm_neon.h:60:5: error: can't convert between vector values of different size
(uint16x4_t) vcvt_f16_f32(vector));
^
make[2]: *** [CMakeFiles/nnpack_reference_layers.dir/src/ref/relu-output.c.o] Error 1
make[1]: *** [CMakeFiles/nnpack_reference_layers.dir/all] Error 2
make: *** [all] Error 2
help welcome.
Which NDK version do you use? Version r15c should work.
It's r14b
, i will try r15c
, thanks .
I test the r15c
version NDK, the problem still exists.
The aarch64-linux-android-4.9
toolchain doesn't support NEON-FP16 intrinsics. Clang toolchain will work.
Clang toolchain
works for me, many thanks
the log is
I feel that the way Ninja compiled is not transparent for me I meet the same problem in a docker linux env.