What float-abi and fpu should be used for Raspberry Pi ARMv7l model so file?


#1

I’m trying to export model so file at the end of the compilation process
What float-abi and fpu should be used for Raspberry Pi ARMv7l?
I tried ["-mfloat-abi=hard","-mfpu=vfp"] - “so” file generation fails.

#target = "llvm -device=arm_cpu -model=bcm2837 -target=armv7l-linux-gnueabihf -mattr=+neon"
target = tvm.target.arm_cpu('rasp3b')
lib.export_library(path_lib, tvm.contrib.cc.create_shared, cc="/usr/bin/arm-linux-gnueabi-g++", options=["-mfloat-abi=hard","-mfpu=vfp"])

Error:

$ ./compile.py 
('model:', 'resnet50_v2', ', target:', llvm -device=arm_cpu -model=bcm2837 -target=armv7l-linux-gnueabihf -mattr=+neon, ', target_host:', None, ', opt_level:', 3, ', data_shape:', (1, 3, 224, 224))
Compiling...
No handlers could be found for logger "autotvm"
Compilation done
Saving files
('cmd: ', ['/usr/bin/arm-linux-gnueabi-g++', '-shared', '-fPIC', '-o', 'model.so', '/tmp/tmp988SCf/lib.o', '-mfloat-abi=hard', '-mfpu=vfp'])
Traceback (most recent call last):
  File "./compile.py", line 49, in <module>
    lib.export_library(path_lib, tvm.contrib.cc.create_shared, cc="/usr/bin/arm-linux-gnueabi-g++", options=["-mfloat-abi=hard","-mfpu=vfp"])
  File "/root/tvm/python/tvm/module.py", line 121, in export_library
    fcompile(file_name, files, **kwargs)
  File "/root/tvm/python/tvm/contrib/cc.py", line 33, in create_shared
    _linux_shared(output, objects, options, cc)
  File "/root/tvm/python/tvm/contrib/cc.py", line 59, in _linux_shared
    raise RuntimeError(msg)
RuntimeError: Compilation error:
/usr/lib/gcc-cross/arm-linux-gnueabi/5/../../../../arm-linux-gnueabi/bin/ld: error: /tmp/tmp988SCf/lib.o uses VFP register arguments, model.so does not
/usr/lib/gcc-cross/arm-linux-gnueabi/5/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file /tmp/tmp988SCf/lib.o
collect2: error: ld returned 1 exit status

[SOLVED] How to export model library to so file instead of tar for armv7 on x86 box
#2

Found the solution!!!
use “hf” HardFloat version g++ - arm-linux-gnueabihf-g++

compile and export model library for ARMv7 (Raspberry Pi 3B+) on x86 box

target = tvm.target.arm_cpu('rasp3b')
...
# Use hf HardFloat version of g++!!!
lib.export_library(“model.so”, cc="/usr/bin/arm-linux-gnueabihf-g++")

#3

Now that I think about it again, you can likely find the target triple by type the following command on your board

gcc -verbose 

#4

true

gcc --verbose
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.9/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Raspbian 4.9.2-10+deb8u1' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.9.2 (Raspbian 4.9.2-10+deb8u1)