google / XNNPACK

High-efficiency floating-point neural network inference operators for mobile, server, and Web

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error: incompatible types when assigning to type ‘int32x4_t’ from type ‘int’

fwz-fpga opened this issue · comments

I have a device with linux os && armv7.
Recently, I need to cross compile to build xnnpack lib, host is x86_64 cpu. And the toolchain is gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabi.
With this toolchain, the error is
error: incompatible types when assigning to type ‘int32x4_t’ from type ‘int’ vacc0x0123 = vcvtnq_s32_f32(vproduct0x0123);
I find that arm_neon.h in gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabi doesn't have this vcvtnq_s32_f32 intrinsic.
This toolchain is for AArch32, is it the problem of toolchain?
I have tried gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabi , it is the same error.

As for complie, I have tried another toolchain gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu this is for aarch64, it works fine.

So what's the problem, aarch32 toolchain not support some xnnpack kernels?

Like this, https://github.com/google/XNNPACK/pull/1404/files , modify the cmakelist.txt, remove XNNPACK_NEONDOT_MICROKERNEL_SRCS, it can build success. :(

In which source file do you get the error?

XNNPACK/src/qs8-gemm/gen/1x8c4-minmax-fp32-neondot.c:94:16: error: incompatible types when assigning to type ‘int32x4_t’ from type ‘int’
vacc0x0123 = vcvtnq_s32_f32(vproduct0x0123);

toolchain.cmake

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7)
set(TOOLCHAIN_DIR /root/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabi/bin)
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/arm-linux-gnueabi-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/arm-linux-gnueabi-g++)
add_compile_options(-fstack-protector-all -Wall -mfloat-abi=softfp)

The compiler lacks the right intrinsic function. XNNPACK includes a polyfill for this intrinsic, but for some reason it doesn't get used:

#if XNN_ARCH_ARM && (defined(__ARM_NEON) || defined(__ARM_NEON__))
#include <arm_neon.h>
// AArch32 GCC targeting ARMv8 NEON, see
// - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71233
// - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95399
#if defined(__GNUC__) && !defined(__clang__) && (__ARM_ARCH >= 8)
static XNN_INTRINSIC
int32x4_t vcvtnq_s32_f32(float32x4_t v) {
return vcvtq_s32_f32(vrndnq_f32(v));
}
#endif // AArch32 GCC targeting ARMv8 NEON
#endif // ARM NEON

I know the reason, I use this commit 16d79ed

#if XNN_ARCH_ARM && defined(__GNUC__) && !defined(__clang__) && defined(__ARM_NEON__)
#include <arm_neon.h>
static XNN_INTRINSIC
int32x4_t vcvtnq_s32_f32(float32x4_t v) {
return vcvtq_s32_f32(vrndnq_f32(v));
}
#endif // AArch32 GCC
code in(#ifdef AVX512F not compile)
Now master is ok.

THX :)